Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: ui/app_list/views/search_box_view.h

Issue 2952763002: SearchBoxView now enables/disables cursor based on user interaction. (Closed)
Patch Set: rebased. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/app_list/views/app_list_view.cc ('k') | ui/app_list/views/search_box_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_ 5 #ifndef UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_
6 #define UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_ 6 #define UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 gfx::Rect GetViewBoundsForSearchBoxContentsBounds( 65 gfx::Rect GetViewBoundsForSearchBoxContentsBounds(
66 const gfx::Rect& rect) const; 66 const gfx::Rect& rect) const;
67 67
68 views::ImageButton* back_button(); 68 views::ImageButton* back_button();
69 views::Textfield* search_box() { return search_box_; } 69 views::Textfield* search_box() { return search_box_; }
70 70
71 void set_contents_view(views::View* contents_view) { 71 void set_contents_view(views::View* contents_view) {
72 contents_view_ = contents_view; 72 contents_view_ = contents_view;
73 } 73 }
74 74
75 // Whether the search box is active.
76 bool is_search_box_active() const { return is_search_box_active_; }
77
75 // Moves focus forward/backwards in response to TAB. 78 // Moves focus forward/backwards in response to TAB.
76 bool MoveTabFocus(bool move_backwards); 79 bool MoveTabFocus(bool move_backwards);
77 80
78 // Moves focus to contents or SearchBox and unselects buttons. 81 // Moves focus to contents or SearchBox and unselects buttons.
79 void ResetTabFocus(bool on_contents); 82 void ResetTabFocus(bool on_contents);
80 83
81 // Sets voice label for Back button depending on whether a folder is open. 84 // Sets voice label for Back button depending on whether a folder is open.
82 void SetBackButtonLabel(bool folder); 85 void SetBackButtonLabel(bool folder);
83 86
84 // Swaps the google icon with the back button. 87 // Swaps the google icon with the back button.
85 void ShowBackOrGoogleIcon(bool show_back_button); 88 void ShowBackOrGoogleIcon(bool show_back_button);
86 89
90 // Setting the search box active left aligns the placeholder text, changes
91 // the color of the placeholder text, and enables cursor blink. Setting the
92 // search box inactive center aligns the placeholder text, sets the color, and
93 // disables cursor blink.
94 void SetSearchBoxActive(bool active);
95
96 // Detects |ET_MOUSE_PRESSED| and |ET_GESTURE_TAP| events on the white
97 // background of the search box.
98 void HandleSearchBoxEvent(ui::LocatedEvent* located_event);
99
100 // Handles Gesture and Mouse Events sent from |search_box_|.
101 bool OnTextfieldEvent();
102
87 // Overridden from views::View: 103 // Overridden from views::View:
88 bool OnMouseWheel(const ui::MouseWheelEvent& event) override; 104 bool OnMouseWheel(const ui::MouseWheelEvent& event) override;
89 void OnEnabledChanged() override; 105 void OnEnabledChanged() override;
90 const char* GetClassName() const override; 106 const char* GetClassName() const override;
107 void OnGestureEvent(ui::GestureEvent* event) override;
108 void OnMouseEvent(ui::MouseEvent* event) override;
91 109
92 private: 110 private:
93 // Updates model text and selection model with current Textfield info. 111 // Updates model text and selection model with current Textfield info.
94 void UpdateModel(); 112 void UpdateModel();
95 113
96 // Fires query change notification. 114 // Fires query change notification.
97 void NotifyQueryChanged(); 115 void NotifyQueryChanged();
98 116
99 // Overridden from views::TextfieldController: 117 // Overridden from views::TextfieldController:
100 void ContentsChanged(views::Textfield* sender, 118 void ContentsChanged(views::Textfield* sender,
101 const base::string16& new_contents) override; 119 const base::string16& new_contents) override;
102 bool HandleKeyEvent(views::Textfield* sender, 120 bool HandleKeyEvent(views::Textfield* sender,
103 const ui::KeyEvent& key_event) override; 121 const ui::KeyEvent& key_event) override;
122 bool HandleMouseEvent(views::Textfield* sender,
123 const ui::MouseEvent& mouse_event) override;
124 bool HandleGestureEvent(views::Textfield* sender,
125 const ui::GestureEvent& gesture_event) override;
104 126
105 // Overridden from views::ButtonListener: 127 // Overridden from views::ButtonListener:
106 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 128 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
107 129
108 // Overridden from SearchBoxModelObserver: 130 // Overridden from SearchBoxModelObserver:
109 void SpeechRecognitionButtonPropChanged() override; 131 void SpeechRecognitionButtonPropChanged() override;
110 void HintTextChanged() override; 132 void HintTextChanged() override;
111 void SelectionModelChanged() override; 133 void SelectionModelChanged() override;
112 void Update() override; 134 void Update() override;
113 void WallpaperProminentColorsChanged() override; 135 void WallpaperProminentColorsChanged() override;
114 136
115 // Overridden from SpeechUIModelObserver: 137 // Overridden from SpeechUIModelObserver:
116 void OnSpeechRecognitionStateChanged( 138 void OnSpeechRecognitionStateChanged(
117 SpeechRecognitionState new_state) override; 139 SpeechRecognitionState new_state) override;
118 140
119 SearchBoxViewDelegate* delegate_; // Not owned. 141 SearchBoxViewDelegate* delegate_; // Not owned.
120 AppListViewDelegate* view_delegate_; // Not owned. 142 AppListViewDelegate* view_delegate_; // Not owned.
121 AppListModel* model_; // Owned by the profile-keyed service. 143 AppListModel* model_; // Owned by the profile-keyed service.
122 144
123 views::View* content_container_; // Owned by views hierarchy. 145 views::View* content_container_; // Owned by views hierarchy.
124 views::ImageView* google_icon_; // Owned by views hierarchy. 146 views::ImageView* google_icon_; // Owned by views hierarchy.
125 SearchBoxImageButton* back_button_; // Owned by views hierarchy. 147 SearchBoxImageButton* back_button_; // Owned by views hierarchy.
126 SearchBoxImageButton* speech_button_; // Owned by views hierarchy. 148 SearchBoxImageButton* speech_button_; // Owned by views hierarchy.
127 views::Textfield* search_box_; // Owned by views hierarchy. 149 views::Textfield* search_box_; // Owned by views hierarchy.
128 views::View* contents_view_; // Owned by views hierarchy. 150 views::View* contents_view_; // Owned by views hierarchy.
129 app_list::AppListView* app_list_view_; // Owned by views hierarchy. 151 app_list::AppListView* app_list_view_; // Owned by views hierarchy.
130 152
131 SearchBoxFocus focused_view_; // Which element has TAB'd focus. 153 SearchBoxFocus focused_view_; // Which element has TAB'd focus.
132 154
133 // Whether the fullscreen app list feature is enabled. 155 // Whether the fullscreen app list feature is enabled.
134 const bool is_fullscreen_app_list_enabled_; 156 const bool is_fullscreen_app_list_enabled_;
157 // Whether the search box is active.
158 bool is_search_box_active_ = false;
135 159
136 DISALLOW_COPY_AND_ASSIGN(SearchBoxView); 160 DISALLOW_COPY_AND_ASSIGN(SearchBoxView);
137 }; 161 };
138 162
139 } // namespace app_list 163 } // namespace app_list
140 164
141 #endif // UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_ 165 #endif // UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_
OLDNEW
« no previous file with comments | « ui/app_list/views/app_list_view.cc ('k') | ui/app_list/views/search_box_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698