summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2013-07-31 11:42:55 +0100
committerBen Murdoch <benm@google.com>2013-07-31 11:42:55 +0100
commitfb250657ef40d7500f20882d5c9909c1013367d3 (patch)
treee7885d8f55b77d8ec4430fa4ec78add75c7270d8 /ui
parent8b098b9dd9d1242c3db3032622b35d8469d47ac4 (diff)
downloadchromium_org-fb250657ef40d7500f20882d5c9909c1013367d3.tar.gz
Merge from Chromium at DEPS revision r214456
This commit was generated by merge_to_master.py. Change-Id: If3f38c7966c2034e96c669968f72ea1e57f41964
Diffstat (limited to 'ui')
-rw-r--r--ui/compositor/context_provider_from_context_factory.cc5
-rw-r--r--ui/compositor/context_provider_from_context_factory.h1
-rw-r--r--ui/views/controls/combobox/combobox.cc25
-rw-r--r--ui/views/controls/combobox/combobox.h13
-rw-r--r--ui/views/controls/prefix_delegate.h34
-rw-r--r--ui/views/controls/prefix_selector.cc182
-rw-r--r--ui/views/controls/prefix_selector.h (renamed from ui/views/controls/tree/tree_view_selector.h)26
-rw-r--r--ui/views/controls/prefix_selector_unittest.cc89
-rw-r--r--ui/views/controls/tree/tree_view.cc35
-rw-r--r--ui/views/controls/tree/tree_view.h22
-rw-r--r--ui/views/controls/tree/tree_view_selector.cc179
-rw-r--r--ui/views/controls/tree/tree_view_unittest.cc10
-rw-r--r--ui/views/examples/views_examples.exe.manifest15
-rw-r--r--ui/views/views.gyp10
-rw-r--r--ui/webui/resources/images/2x/apps/topbar_button_close.pngbin0 -> 241 bytes
-rw-r--r--ui/webui/resources/images/2x/apps/topbar_button_maximize.pngbin0 -> 128 bytes
-rw-r--r--ui/webui/resources/images/2x/apps/topbar_button_minimize.pngbin0 -> 217 bytes
-rw-r--r--ui/webui/resources/images/2x/apps/topbar_button_settings.pngbin0 -> 402 bytes
-rw-r--r--ui/webui/resources/images/apps/topbar_button_close.pngbin0 -> 174 bytes
-rw-r--r--ui/webui/resources/images/apps/topbar_button_maximize.pngbin0 -> 103 bytes
-rw-r--r--ui/webui/resources/images/apps/topbar_button_minimize.pngbin0 -> 164 bytes
-rw-r--r--ui/webui/resources/images/apps/topbar_button_settings.pngbin0 -> 220 bytes
22 files changed, 414 insertions, 232 deletions
diff --git a/ui/compositor/context_provider_from_context_factory.cc b/ui/compositor/context_provider_from_context_factory.cc
index c6f779050a..262998a886 100644
--- a/ui/compositor/context_provider_from_context_factory.cc
+++ b/ui/compositor/context_provider_from_context_factory.cc
@@ -61,6 +61,11 @@ bool ContextProviderFromContextFactory::DestroyedOnMainThread() {
return destroyed_;
}
+void ContextProviderFromContextFactory::SetLostContextCallback(
+ const LostContextCallback& cb) {
+ NOTIMPLEMENTED();
+}
+
bool ContextProviderFromContextFactory::InitializeOnMainThread() {
if (context3d_)
return true;
diff --git a/ui/compositor/context_provider_from_context_factory.h b/ui/compositor/context_provider_from_context_factory.h
index 9877ab3ad2..57be7f47ef 100644
--- a/ui/compositor/context_provider_from_context_factory.h
+++ b/ui/compositor/context_provider_from_context_factory.h
@@ -24,6 +24,7 @@ class ContextProviderFromContextFactory
virtual class GrContext* GrContext() OVERRIDE;
virtual void VerifyContexts() OVERRIDE;
virtual bool DestroyedOnMainThread() OVERRIDE;
+ virtual void SetLostContextCallback(const LostContextCallback& cb) OVERRIDE;
protected:
ContextProviderFromContextFactory(ContextFactory* factory);
diff --git a/ui/views/controls/combobox/combobox.cc b/ui/views/controls/combobox/combobox.cc
index 7a9a91dea7..4c10788623 100644
--- a/ui/views/controls/combobox/combobox.cc
+++ b/ui/views/controls/combobox/combobox.cc
@@ -13,6 +13,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/views/controls/combobox/combobox_listener.h"
#include "ui/views/controls/native/native_view_host.h"
+#include "ui/views/controls/prefix_selector.h"
#include "ui/views/widget/widget.h"
namespace views {
@@ -71,6 +72,28 @@ void Combobox::SetInvalid(bool invalid) {
native_wrapper_->ValidityStateChanged();
}
+ui::TextInputClient* Combobox::GetTextInputClient() {
+ if (!selector_)
+ selector_.reset(new PrefixSelector(this));
+ return selector_.get();
+}
+
+int Combobox::GetRowCount() {
+ return model()->GetItemCount();
+}
+
+int Combobox::GetSelectedRow() {
+ return selected_index_;
+}
+
+void Combobox::SetSelectedRow(int row) {
+ SetSelectedIndex(row);
+}
+
+string16 Combobox::GetTextForRow(int row) {
+ return model()->GetItemAt(row);
+}
+
////////////////////////////////////////////////////////////////////////////////
// Combobox, View overrides:
@@ -128,6 +151,8 @@ void Combobox::OnFocus() {
}
void Combobox::OnBlur() {
+ if (selector_)
+ selector_->OnViewBlur();
if (native_wrapper_)
native_wrapper_->HandleBlur();
}
diff --git a/ui/views/controls/combobox/combobox.h b/ui/views/controls/combobox/combobox.h
index 3fc6708bec..e71604e423 100644
--- a/ui/views/controls/combobox/combobox.h
+++ b/ui/views/controls/combobox/combobox.h
@@ -9,6 +9,7 @@
#include "ui/gfx/native_widget_types.h"
#include "ui/views/controls/combobox/native_combobox_wrapper.h"
+#include "ui/views/controls/prefix_delegate.h"
#include "ui/views/view.h"
namespace gfx {
@@ -22,9 +23,10 @@ class ComboboxModel;
namespace views {
class ComboboxListener;
+class PrefixSelector;
// A non-editable combobox (aka a drop-down list).
-class VIEWS_EXPORT Combobox : public View {
+class VIEWS_EXPORT Combobox : public PrefixDelegate {
public:
// The combobox's class name.
static const char kViewClassName[];
@@ -82,6 +84,13 @@ class VIEWS_EXPORT Combobox : public View {
virtual void OnFocus() OVERRIDE;
virtual void OnBlur() OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
+ virtual ui::TextInputClient* GetTextInputClient() OVERRIDE;
+
+ // Overridden from PrefixDelegate:
+ virtual int GetRowCount() OVERRIDE;
+ virtual int GetSelectedRow() OVERRIDE;
+ virtual void SetSelectedRow(int row) OVERRIDE;
+ virtual string16 GetTextForRow(int row) OVERRIDE;
protected:
// Overridden from View:
@@ -108,6 +117,8 @@ class VIEWS_EXPORT Combobox : public View {
// The accessible name of this combobox.
string16 accessible_name_;
+ scoped_ptr<PrefixSelector> selector_;
+
DISALLOW_COPY_AND_ASSIGN(Combobox);
};
diff --git a/ui/views/controls/prefix_delegate.h b/ui/views/controls/prefix_delegate.h
new file mode 100644
index 0000000000..41d30d43cc
--- /dev/null
+++ b/ui/views/controls/prefix_delegate.h
@@ -0,0 +1,34 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_VIEWS_CONTROLS_PREFIX_DELEGATE_H_
+#define UI_VIEWS_CONTROLS_PREFIX_DELEGATE_H_
+
+#include "ui/views/view.h"
+
+namespace views {
+
+// An interface used to expose lists of items for selection by text input.
+class VIEWS_EXPORT PrefixDelegate : public View {
+ public:
+ // Returns the total number of selectable items.
+ virtual int GetRowCount() = 0;
+
+ // Returns the row of the currently selected item, or -1 if no item is
+ // selected.
+ virtual int GetSelectedRow() = 0;
+
+ // Sets the selection to the specified row.
+ virtual void SetSelectedRow(int row) = 0;
+
+ // Returns the item at the specified row.
+ virtual string16 GetTextForRow(int row) = 0;
+
+ protected:
+ virtual ~PrefixDelegate() {}
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_CONTROLS_PREFIX_DELEGATE_H_
diff --git a/ui/views/controls/prefix_selector.cc b/ui/views/controls/prefix_selector.cc
new file mode 100644
index 0000000000..12208c01ee
--- /dev/null
+++ b/ui/views/controls/prefix_selector.cc
@@ -0,0 +1,182 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/controls/prefix_selector.h"
+
+#include "base/i18n/case_conversion.h"
+#include "ui/base/ime/text_input_type.h"
+#include "ui/base/range/range.h"
+#include "ui/views/controls/prefix_delegate.h"
+#include "ui/views/widget/widget.h"
+
+namespace views {
+
+namespace {
+
+const int64 kTimeBeforeClearingMS = 1000;
+
+void ConvertRectToScreen(const views::View* src, gfx::Rect* r) {
+ DCHECK(src);
+
+ gfx::Point new_origin = r->origin();
+ views::View::ConvertPointToScreen(src, &new_origin);
+ r->set_origin(new_origin);
+}
+
+} // namespace
+
+PrefixSelector::PrefixSelector(PrefixDelegate* delegate)
+ : prefix_delegate_(delegate) {
+}
+
+PrefixSelector::~PrefixSelector() {
+}
+
+void PrefixSelector::OnViewBlur() {
+ ClearText();
+}
+
+void PrefixSelector::SetCompositionText(
+ const ui::CompositionText& composition) {
+}
+
+void PrefixSelector::ConfirmCompositionText() {
+}
+
+void PrefixSelector::ClearCompositionText() {
+}
+
+void PrefixSelector::InsertText(const string16& text) {
+ OnTextInput(text);
+}
+
+void PrefixSelector::InsertChar(char16 ch, int flags) {
+ OnTextInput(string16(1, ch));
+}
+
+gfx::NativeWindow PrefixSelector::GetAttachedWindow() const {
+ return prefix_delegate_->GetWidget()->GetNativeWindow();
+}
+
+ui::TextInputType PrefixSelector::GetTextInputType() const {
+ return ui::TEXT_INPUT_TYPE_TEXT;
+}
+
+bool PrefixSelector::CanComposeInline() const {
+ return false;
+}
+
+gfx::Rect PrefixSelector::GetCaretBounds() {
+ gfx::Rect rect(prefix_delegate_->GetVisibleBounds().origin(), gfx::Size());
+ // TextInputClient::GetCaretBounds is expected to return a value in screen
+ // coordinates.
+ ConvertRectToScreen(prefix_delegate_, &rect);
+ return rect;
+}
+
+bool PrefixSelector::GetCompositionCharacterBounds(uint32 index,
+ gfx::Rect* rect) {
+ // TextInputClient::GetCompositionCharacterBounds is expected to fill |rect|
+ // in screen coordinates and GetCaretBounds returns screen coordinates.
+ *rect = GetCaretBounds();
+ return false;
+}
+
+bool PrefixSelector::HasCompositionText() {
+ return false;
+}
+
+bool PrefixSelector::GetTextRange(ui::Range* range) {
+ *range = ui::Range();
+ return false;
+}
+
+bool PrefixSelector::GetCompositionTextRange(ui::Range* range) {
+ *range = ui::Range();
+ return false;
+}
+
+bool PrefixSelector::GetSelectionRange(ui::Range* range) {
+ *range = ui::Range();
+ return false;
+}
+
+bool PrefixSelector::SetSelectionRange(const ui::Range& range) {
+ return false;
+}
+
+bool PrefixSelector::DeleteRange(const ui::Range& range) {
+ return false;
+}
+
+bool PrefixSelector::GetTextFromRange(const ui::Range& range,
+ string16* text) {
+ return false;
+}
+
+void PrefixSelector::OnInputMethodChanged() {
+ ClearText();
+}
+
+bool PrefixSelector::ChangeTextDirectionAndLayoutAlignment(
+ base::i18n::TextDirection direction) {
+ return true;
+}
+
+void PrefixSelector::ExtendSelectionAndDelete(size_t before, size_t after) {
+}
+
+void PrefixSelector::EnsureCaretInRect(const gfx::Rect& rect) {
+}
+
+void PrefixSelector::OnTextInput(const string16& text) {
+ // Small hack to filter out 'tab' input, as the expectation is that tabs
+ // should cycle input elements, not influence selection.
+ if (text.length() == 1 && text.at(0) == 0x09)
+ return;
+
+ const int row_count = prefix_delegate_->GetRowCount();
+ if (row_count == 0)
+ return;
+
+ // Search for |text| if it has been a while since the user typed, otherwise
+ // append |text| to |current_text_| and search for that. If it has been a
+ // while search after the current row, otherwise search starting from the
+ // current row.
+ int row = std::max(0, prefix_delegate_->GetSelectedRow());
+ const base::TimeTicks now(base::TimeTicks::Now());
+ if ((now - time_of_last_key_).InMilliseconds() < kTimeBeforeClearingMS) {
+ current_text_ += text;
+ } else {
+ current_text_ = text;
+ if (prefix_delegate_->GetSelectedRow() >= 0)
+ row = (row + 1) % row_count;
+ }
+ time_of_last_key_ = now;
+
+ const int start_row = row;
+ const string16 lower_text(base::i18n::ToLower(current_text_));
+ do {
+ if (TextAtRowMatchesText(row, current_text_)) {
+ prefix_delegate_->SetSelectedRow(row);
+ return;
+ }
+ row = (row + 1) % row_count;
+ } while (row != start_row);
+}
+
+bool PrefixSelector::TextAtRowMatchesText(int row,
+ const string16& lower_text) {
+ const string16 model_text(
+ base::i18n::ToLower(prefix_delegate_->GetTextForRow(row)));
+ return (model_text.size() >= lower_text.size()) &&
+ (model_text.compare(0, lower_text.size(), lower_text) == 0);
+}
+
+void PrefixSelector::ClearText() {
+ current_text_.clear();
+ time_of_last_key_ = base::TimeTicks();
+}
+
+} // namespace views
diff --git a/ui/views/controls/tree/tree_view_selector.h b/ui/views/controls/prefix_selector.h
index 170ed902fa..b587f77f47 100644
--- a/ui/views/controls/tree/tree_view_selector.h
+++ b/ui/views/controls/prefix_selector.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_VIEWS_CONTROLS_TREE_TREE_VIEW_SELECTOR_H_
-#define UI_VIEWS_CONTROLS_TREE_TREE_VIEW_SELECTOR_H_
+#ifndef UI_VIEWS_CONTROLS_PREFIX_SELECTOR_H_
+#define UI_VIEWS_CONTROLS_PREFIX_SELECTOR_H_
#include "base/strings/string16.h"
#include "base/time/time.h"
@@ -12,17 +12,17 @@
namespace views {
-class TreeView;
+class PrefixDelegate;
-// TreeViewSelector is used to change the selection in the tree as the user
+// PrefixSelector is used to change the selection in a view as the user
// types characters.
-class VIEWS_EXPORT TreeViewSelector : public ui::TextInputClient {
+class VIEWS_EXPORT PrefixSelector : public ui::TextInputClient {
public:
- explicit TreeViewSelector(TreeView* tree);
- virtual ~TreeViewSelector();
+ explicit PrefixSelector(PrefixDelegate* delegate);
+ virtual ~PrefixSelector();
- // Invoked from the tree when it loses focus.
- void OnTreeViewBlur();
+ // Invoked from the view when it loses focus.
+ void OnViewBlur();
// ui::TextInputClient:
virtual void SetCompositionText(
@@ -61,16 +61,16 @@ class VIEWS_EXPORT TreeViewSelector : public ui::TextInputClient {
// Clears |current_text_| and resets |time_of_last_key_|.
void ClearText();
- TreeView* tree_;
+ PrefixDelegate* prefix_delegate_;
// Time OnTextInput() was last invoked.
base::TimeTicks time_of_last_key_;
string16 current_text_;
- DISALLOW_COPY_AND_ASSIGN(TreeViewSelector);
+ DISALLOW_COPY_AND_ASSIGN(PrefixSelector);
};
} // namespace views
-#endif // UI_VIEWS_CONTROLS_TREE_TREE_VIEW_SELECTOR_H_
+#endif // UI_VIEWS_CONTROLS_PREFIX_SELECTOR_H_
diff --git a/ui/views/controls/prefix_selector_unittest.cc b/ui/views/controls/prefix_selector_unittest.cc
new file mode 100644
index 0000000000..c39e6cc652
--- /dev/null
+++ b/ui/views/controls/prefix_selector_unittest.cc
@@ -0,0 +1,89 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/controls/prefix_selector.h"
+
+#include <string>
+
+#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
+#include "ui/views/controls/prefix_delegate.h"
+#include "ui/views/test/views_test_base.h"
+
+namespace views {
+
+class TestPrefixDelegate : public PrefixDelegate {
+ public:
+ TestPrefixDelegate() : selected_row_(0) {
+ rows_.push_back(ASCIIToUTF16("aardvark"));
+ rows_.push_back(ASCIIToUTF16("antelope"));
+ rows_.push_back(ASCIIToUTF16("badger"));
+ rows_.push_back(ASCIIToUTF16("gnu"));
+ }
+
+ virtual ~TestPrefixDelegate() {}
+
+ virtual int GetRowCount() OVERRIDE {
+ return static_cast<int>(rows_.size());
+ }
+
+ virtual int GetSelectedRow() OVERRIDE {
+ return selected_row_;
+ }
+
+ virtual void SetSelectedRow(int row) OVERRIDE {
+ selected_row_ = row;
+ }
+
+ virtual string16 GetTextForRow(int row) OVERRIDE {
+ return rows_[row];
+ }
+
+ private:
+ std::vector<string16> rows_;
+ int selected_row_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestPrefixDelegate);
+};
+
+class PrefixSelectorTest : public ViewsTestBase {
+ public:
+ PrefixSelectorTest() {
+ selector_.reset(new PrefixSelector(&delegate_));
+ }
+
+ protected:
+ scoped_ptr<PrefixSelector> selector_;
+ TestPrefixDelegate delegate_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(PrefixSelectorTest);
+};
+
+TEST_F(PrefixSelectorTest, PrefixSelect) {
+ selector_->InsertText(ASCIIToUTF16("an"));
+ EXPECT_EQ(1, delegate_.GetSelectedRow());
+
+ // Invoke OnViewBlur() to reset time.
+ selector_->OnViewBlur();
+ selector_->InsertText(ASCIIToUTF16("a"));
+ EXPECT_EQ(0, delegate_.GetSelectedRow());
+
+ selector_->OnViewBlur();
+ selector_->InsertText(ASCIIToUTF16("g"));
+ EXPECT_EQ(3, delegate_.GetSelectedRow());
+
+ selector_->OnViewBlur();
+ selector_->InsertText(ASCIIToUTF16("b"));
+ selector_->InsertText(ASCIIToUTF16("a"));
+ EXPECT_EQ(2, delegate_.GetSelectedRow());
+
+ selector_->OnViewBlur();
+ selector_->InsertText(ASCIIToUTF16("\t"));
+ selector_->InsertText(ASCIIToUTF16("b"));
+ selector_->InsertText(ASCIIToUTF16("a"));
+ EXPECT_EQ(2, delegate_.GetSelectedRow());
+}
+
+} // namespace views
diff --git a/ui/views/controls/tree/tree_view.cc b/ui/views/controls/tree/tree_view.cc
index b2a162b783..1d550a2ff7 100644
--- a/ui/views/controls/tree/tree_view.cc
+++ b/ui/views/controls/tree/tree_view.cc
@@ -18,10 +18,10 @@
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/skia_util.h"
#include "ui/native_theme/native_theme.h"
+#include "ui/views/controls/prefix_selector.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/controls/tree/tree_view_controller.h"
-#include "ui/views/controls/tree/tree_view_selector.h"
#include "ui/views/ime/input_method.h"
using ui::TreeModel;
@@ -315,13 +315,6 @@ void TreeView::SetRootShown(bool root_shown) {
DrawnNodesChanged();
}
-int TreeView::GetRowCount() {
- int row_count = root_.NumExpandedNodes();
- if (!root_shown_)
- row_count--;
- return row_count;
-}
-
ui::TreeModelNode* TreeView::GetNodeForRow(int row) {
int depth = 0;
InternalNode* node = GetNodeByRow(row, &depth);
@@ -369,7 +362,7 @@ bool TreeView::OnMousePressed(const ui::MouseEvent& event) {
ui::TextInputClient* TreeView::GetTextInputClient() {
if (!selector_)
- selector_.reset(new TreeViewSelector(this));
+ selector_.reset(new PrefixSelector(this));
return selector_.get();
}
@@ -497,6 +490,26 @@ void TreeView::OnDidChangeFocus(View* focused_before, View* focused_now) {
CommitEdit();
}
+int TreeView::GetRowCount() {
+ int row_count = root_.NumExpandedNodes();
+ if (!root_shown_)
+ row_count--;
+ return row_count;
+}
+
+int TreeView::GetSelectedRow() {
+ ui::TreeModelNode* model_node = GetSelectedNode();
+ return model_node ? GetRowForNode(model_node) : -1;
+}
+
+void TreeView::SetSelectedRow(int row) {
+ SetSelectedNode(GetNodeForRow(row));
+}
+
+string16 TreeView::GetTextForRow(int row) {
+ return GetNodeForRow(row)->GetTitle();
+}
+
gfx::Point TreeView::GetKeyboardContextMenuLocation() {
int y = height() / 2;
if (selected_node_) {
@@ -596,7 +609,7 @@ void TreeView::OnFocus() {
void TreeView::OnBlur() {
SchedulePaintForNode(selected_node_);
if (selector_)
- selector_->OnTreeViewBlur();
+ selector_->OnViewBlur();
}
bool TreeView::OnClickOrTap(const ui::LocatedEvent& event) {
@@ -985,7 +998,7 @@ void TreeView::InternalNode::Reset(ui::TreeModelNode* node) {
text_width_ = 0;
}
-int TreeView::InternalNode::NumExpandedNodes() {
+int TreeView::InternalNode::NumExpandedNodes() const {
int result = 1; // For this.
if (!is_expanded_)
return result;
diff --git a/ui/views/controls/tree/tree_view.h b/ui/views/controls/tree/tree_view.h
index cca0b33c27..da2a5205a6 100644
--- a/ui/views/controls/tree/tree_view.h
+++ b/ui/views/controls/tree/tree_view.h
@@ -13,6 +13,7 @@
#include "ui/base/models/tree_node_model.h"
#include "ui/gfx/font.h"
#include "ui/gfx/image/image_skia.h"
+#include "ui/views/controls/prefix_delegate.h"
#include "ui/views/controls/textfield/textfield_controller.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/view.h"
@@ -21,7 +22,7 @@ namespace views {
class Textfield;
class TreeViewController;
-class TreeViewSelector;
+class PrefixSelector;
// TreeView displays hierarchical data as returned from a TreeModel. The user
// can expand, collapse and edit the items. A Controller may be attached to
@@ -30,10 +31,10 @@ class TreeViewSelector;
// Note on implementation. This implementation doesn't scale well. In particular
// it does not store any row information, but instead calculates it as
// necessary. But it's more than adequate for current uses.
-class VIEWS_EXPORT TreeView : public View,
- public ui::TreeModelObserver,
+class VIEWS_EXPORT TreeView : public ui::TreeModelObserver,
public TextfieldController,
- public FocusChangeListener {
+ public FocusChangeListener,
+ public PrefixDelegate {
public:
TreeView();
virtual ~TreeView();
@@ -103,9 +104,6 @@ class VIEWS_EXPORT TreeView : public View,
controller_ = controller;
}
- // Returns the number of rows.
- int GetRowCount();
-
// Returns the node for the specified row, or NULL for an invalid row index.
ui::TreeModelNode* GetNodeForRow(int row);
@@ -149,6 +147,12 @@ class VIEWS_EXPORT TreeView : public View,
virtual void OnDidChangeFocus(View* focused_before,
View* focused_now) OVERRIDE;
+ // PrefixDelegate overrides:
+ virtual int GetRowCount() OVERRIDE;
+ virtual int GetSelectedRow() OVERRIDE;
+ virtual void SetSelectedRow(int row) OVERRIDE;
+ virtual string16 GetTextForRow(int row) OVERRIDE;
+
protected:
// View overrides:
virtual gfx::Point GetKeyboardContextMenuLocation() OVERRIDE;
@@ -190,7 +194,7 @@ class VIEWS_EXPORT TreeView : public View,
int text_width() const { return text_width_; }
// Returns the total number of descendants (including this node).
- int NumExpandedNodes();
+ int NumExpandedNodes() const;
// Returns the max width of all descendants (including this node). |indent|
// is how many pixels each child is indented and |depth| is the depth of
@@ -378,7 +382,7 @@ class VIEWS_EXPORT TreeView : public View,
// control, icon and offsets.
int text_offset_;
- scoped_ptr<TreeViewSelector> selector_;
+ scoped_ptr<PrefixSelector> selector_;
DISALLOW_COPY_AND_ASSIGN(TreeView);
};
diff --git a/ui/views/controls/tree/tree_view_selector.cc b/ui/views/controls/tree/tree_view_selector.cc
deleted file mode 100644
index f3bd055091..0000000000
--- a/ui/views/controls/tree/tree_view_selector.cc
+++ /dev/null
@@ -1,179 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/views/controls/tree/tree_view_selector.h"
-
-#include "base/i18n/case_conversion.h"
-#include "ui/base/ime/text_input_type.h"
-#include "ui/base/range/range.h"
-#include "ui/views/controls/tree/tree_view.h"
-#include "ui/views/widget/widget.h"
-
-namespace views {
-
-namespace {
-
-const int64 kTimeBeforeClearingMS = 1000;
-
-void ConvertRectToScreen(const views::View* src, gfx::Rect* r) {
- DCHECK(src);
-
- gfx::Point new_origin = r->origin();
- views::View::ConvertPointToScreen(src, &new_origin);
- r->set_origin(new_origin);
-}
-
-} // namespace
-
-TreeViewSelector::TreeViewSelector(TreeView* tree)
- : tree_(tree) {
-}
-
-TreeViewSelector::~TreeViewSelector() {
-}
-
-void TreeViewSelector::OnTreeViewBlur() {
- ClearText();
-}
-
-void TreeViewSelector::SetCompositionText(
- const ui::CompositionText& composition) {
-}
-
-void TreeViewSelector::ConfirmCompositionText() {
-}
-
-void TreeViewSelector::ClearCompositionText() {
-}
-
-void TreeViewSelector::InsertText(const string16& text) {
- OnTextInput(text);
-}
-
-void TreeViewSelector::InsertChar(char16 ch, int flags) {
- OnTextInput(string16(1, ch));
-}
-
-gfx::NativeWindow TreeViewSelector::GetAttachedWindow() const {
- return tree_->GetWidget()->GetNativeWindow();
-}
-
-ui::TextInputType TreeViewSelector::GetTextInputType() const {
- return ui::TEXT_INPUT_TYPE_TEXT;
-}
-
-bool TreeViewSelector::CanComposeInline() const {
- return false;
-}
-
-gfx::Rect TreeViewSelector::GetCaretBounds() {
- gfx::Rect rect(tree_->GetVisibleBounds().origin(), gfx::Size());
- // TextInputClient::GetCaretBounds is expected to return a value in screen
- // coordinates.
- ConvertRectToScreen(tree_, &rect);
- return rect;
-}
-
-bool TreeViewSelector::GetCompositionCharacterBounds(uint32 index,
- gfx::Rect* rect) {
- // TextInputClient::GetCompositionCharacterBounds is expected to fill |rect|
- // in screen coordinates and GetCaretBounds returns screen coordinates.
- *rect = GetCaretBounds();
- return false;
-}
-
-bool TreeViewSelector::HasCompositionText() {
- return false;
-}
-
-bool TreeViewSelector::GetTextRange(ui::Range* range) {
- *range = ui::Range();
- return false;
-}
-
-bool TreeViewSelector::GetCompositionTextRange(ui::Range* range) {
- *range = ui::Range();
- return false;
-}
-
-bool TreeViewSelector::GetSelectionRange(ui::Range* range) {
- *range = ui::Range();
- return false;
-}
-
-bool TreeViewSelector::SetSelectionRange(const ui::Range& range) {
- return false;
-}
-
-bool TreeViewSelector::DeleteRange(const ui::Range& range) {
- return false;
-}
-
-bool TreeViewSelector::GetTextFromRange(const ui::Range& range,
- string16* text) {
- return false;
-}
-
-void TreeViewSelector::OnInputMethodChanged() {
- ClearText();
-}
-
-bool TreeViewSelector::ChangeTextDirectionAndLayoutAlignment(
- base::i18n::TextDirection direction) {
- return true;
-}
-
-void TreeViewSelector::ExtendSelectionAndDelete(size_t before, size_t after) {
-}
-
-void TreeViewSelector::EnsureCaretInRect(const gfx::Rect& rect) {
-}
-
-void TreeViewSelector::OnTextInput(const string16& text) {
- const int row_count = tree_->GetRowCount();
- if (row_count == 0)
- return;
-
- // Search for |text| if it has been a while since the user typed, otherwise
- // append |text| to |current_text_| and search for that. If it has been a
- // while search after the current row, otherwise search starting from the
- // current row.
- int row = (tree_->GetSelectedNode() != NULL) ?
- tree_->GetRowForNode(tree_->GetSelectedNode()) : 0;
- const base::TimeTicks now(base::TimeTicks::Now());
- if ((now - time_of_last_key_).InMilliseconds() < kTimeBeforeClearingMS) {
- current_text_ += text;
- } else {
- current_text_ = text;
- if (tree_->GetSelectedNode())
- row = (row + 1) % row_count;
- }
- time_of_last_key_ = now;
-
- const int start_row = row;
- const string16 lower_text(base::i18n::ToLower(current_text_));
- do {
- if (TextAtRowMatchesText(row, current_text_)) {
- tree_->SetSelectedNode(tree_->GetNodeForRow(row));
- return;
- }
- row = (row + 1) % row_count;
- } while (row != start_row);
-}
-
-bool TreeViewSelector::TextAtRowMatchesText(int row,
- const string16& lower_text) {
- ui::TreeModelNode* node = tree_->GetNodeForRow(row);
- DCHECK(node);
- const string16 model_text(base::i18n::ToLower(node->GetTitle()));
- return (model_text.size() >= lower_text.size()) &&
- (model_text.compare(0, lower_text.size(), lower_text) == 0);
-}
-
-void TreeViewSelector::ClearText() {
- current_text_.clear();
- time_of_last_key_ = base::TimeTicks();
-}
-
-} // namespace views
diff --git a/ui/views/controls/tree/tree_view_unittest.cc b/ui/views/controls/tree/tree_view_unittest.cc
index 582c9aeabe..1864ff9a9b 100644
--- a/ui/views/controls/tree/tree_view_unittest.cc
+++ b/ui/views/controls/tree/tree_view_unittest.cc
@@ -9,8 +9,8 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/base/models/tree_node_model.h"
+#include "ui/views/controls/prefix_selector.h"
#include "ui/views/controls/textfield/textfield.h"
-#include "ui/views/controls/tree/tree_view_selector.h"
#include "ui/views/test/views_test_base.h"
using ui::TreeModel;
@@ -60,7 +60,7 @@ class TreeViewTest : public ViewsTestBase {
void CollapseOrSelectParent();
void ExpandOrSelectChild();
int GetRowCount();
- TreeViewSelector* selector() { return tree_.selector_.get(); }
+ PrefixSelector* selector() { return tree_.selector_.get(); }
ui::TreeNodeModel<TestNode > model_;
TreeView tree_;
@@ -394,12 +394,12 @@ TEST_F(TreeViewTest, SelectOnKeyStroke) {
selector()->InsertText(ASCIIToUTF16("1"));
EXPECT_EQ("b1", GetSelectedNodeTitle());
- // Invoke OnTreeViewBlur() to reset time.
- selector()->OnTreeViewBlur();
+ // Invoke OnViewBlur() to reset time.
+ selector()->OnViewBlur();
selector()->InsertText(ASCIIToUTF16("z"));
EXPECT_EQ("b1", GetSelectedNodeTitle());
- selector()->OnTreeViewBlur();
+ selector()->OnViewBlur();
selector()->InsertText(ASCIIToUTF16("a"));
EXPECT_EQ("a", GetSelectedNodeTitle());
}
diff --git a/ui/views/examples/views_examples.exe.manifest b/ui/views/examples/views_examples.exe.manifest
index 92f2e4456a..79c35aac86 100644
--- a/ui/views/examples/views_examples.exe.manifest
+++ b/ui/views/examples/views_examples.exe.manifest
@@ -1,21 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
- <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
- <application>
- <!--This Id value indicates the application supports Windows Vista functionality -->
- <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
- <!--This Id value indicates the application supports Windows 7 functionality-->
- <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
- </application>
- </compatibility>
-
+ <!--The compatibility section will be merged from build/win/compatibility.manifest -->
+
<dependency>
<dependentAssembly>
<assemblyIdentity type="Win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
</dependentAssembly>
</dependency>
-
+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
@@ -23,5 +16,5 @@
</requestedPrivileges>
</security>
</trustInfo>
-
+
</assembly> \ No newline at end of file
diff --git a/ui/views/views.gyp b/ui/views/views.gyp
index 7b21a7dc07..ea0285b9b2 100644
--- a/ui/views/views.gyp
+++ b/ui/views/views.gyp
@@ -166,6 +166,9 @@
'controls/native/native_view_host_aura.h',
'controls/native/native_view_host_win.cc',
'controls/native/native_view_host_win.h',
+ 'controls/prefix_delegate.h',
+ 'controls/prefix_selector.cc',
+ 'controls/prefix_selector.h',
'controls/progress_bar.cc',
'controls/progress_bar.h',
'controls/resize_area.cc',
@@ -232,8 +235,6 @@
'controls/tree/tree_view.h',
'controls/tree/tree_view_controller.cc',
'controls/tree/tree_view_controller.h',
- 'controls/tree/tree_view_selector.cc',
- 'controls/tree/tree_view_selector.h',
'corewm/base_focus_rules.cc',
'corewm/base_focus_rules.h',
'corewm/compound_event_filter.cc',
@@ -698,6 +699,7 @@
'controls/menu/menu_model_adapter_unittest.cc',
'controls/native/native_view_host_aura_unittest.cc',
'controls/native/native_view_host_unittest.cc',
+ 'controls/prefix_selector_unittest.cc',
'controls/progress_bar_unittest.cc',
'controls/scrollbar/scrollbar_unittest.cc',
'controls/scroll_view_unittest.cc',
@@ -1018,7 +1020,9 @@
},
'msvs_settings': {
'VCManifestTool': {
- 'AdditionalManifestFiles': 'examples\\views_examples.exe.manifest',
+ 'AdditionalManifestFiles': [
+ 'examples\\views_examples.exe.manifest',
+ ],
},
'VCLinkerTool': {
'SubSystem': '2', # Set /SUBSYSTEM:WINDOWS
diff --git a/ui/webui/resources/images/2x/apps/topbar_button_close.png b/ui/webui/resources/images/2x/apps/topbar_button_close.png
new file mode 100644
index 0000000000..7a280844a8
--- /dev/null
+++ b/ui/webui/resources/images/2x/apps/topbar_button_close.png
Binary files differ
diff --git a/ui/webui/resources/images/2x/apps/topbar_button_maximize.png b/ui/webui/resources/images/2x/apps/topbar_button_maximize.png
new file mode 100644
index 0000000000..59377a4dc4
--- /dev/null
+++ b/ui/webui/resources/images/2x/apps/topbar_button_maximize.png
Binary files differ
diff --git a/ui/webui/resources/images/2x/apps/topbar_button_minimize.png b/ui/webui/resources/images/2x/apps/topbar_button_minimize.png
new file mode 100644
index 0000000000..f4fb7ef671
--- /dev/null
+++ b/ui/webui/resources/images/2x/apps/topbar_button_minimize.png
Binary files differ
diff --git a/ui/webui/resources/images/2x/apps/topbar_button_settings.png b/ui/webui/resources/images/2x/apps/topbar_button_settings.png
new file mode 100644
index 0000000000..b474c4c1fa
--- /dev/null
+++ b/ui/webui/resources/images/2x/apps/topbar_button_settings.png
Binary files differ
diff --git a/ui/webui/resources/images/apps/topbar_button_close.png b/ui/webui/resources/images/apps/topbar_button_close.png
new file mode 100644
index 0000000000..b902560b7c
--- /dev/null
+++ b/ui/webui/resources/images/apps/topbar_button_close.png
Binary files differ
diff --git a/ui/webui/resources/images/apps/topbar_button_maximize.png b/ui/webui/resources/images/apps/topbar_button_maximize.png
new file mode 100644
index 0000000000..3bd557fa5a
--- /dev/null
+++ b/ui/webui/resources/images/apps/topbar_button_maximize.png
Binary files differ
diff --git a/ui/webui/resources/images/apps/topbar_button_minimize.png b/ui/webui/resources/images/apps/topbar_button_minimize.png
new file mode 100644
index 0000000000..109a7c59ed
--- /dev/null
+++ b/ui/webui/resources/images/apps/topbar_button_minimize.png
Binary files differ
diff --git a/ui/webui/resources/images/apps/topbar_button_settings.png b/ui/webui/resources/images/apps/topbar_button_settings.png
new file mode 100644
index 0000000000..ef0724a389
--- /dev/null
+++ b/ui/webui/resources/images/apps/topbar_button_settings.png
Binary files differ