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

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: Addressed Comments, refactored. 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
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 // Moves focus forward/backwards in response to TAB. 75 // Moves focus forward/backwards in response to TAB.
76 bool MoveTabFocus(bool move_backwards); 76 bool MoveTabFocus(bool move_backwards);
77 77
78 // Moves focus to contents or SearchBox and unselects buttons. 78 // Moves focus to contents or SearchBox and unselects buttons.
79 void ResetTabFocus(bool on_contents); 79 void ResetTabFocus(bool on_contents);
80 80
81 // Sets voice label for Back button depending on whether a folder is open. 81 // Sets voice label for Back button depending on whether a folder is open.
82 void SetBackButtonLabel(bool folder); 82 void SetBackButtonLabel(bool folder);
83 83
84 // Whether the search box is active.
85 bool is_search_box_active() const { return is_search_box_active_; }
86
87 // Setting the search box active left aligns the placeholder text, changes
xiyuan 2017/06/27 23:11:10 nit: get rid of one space between "search" and "bo
newcomer 2017/06/30 21:47:23 Done.
88 // the color of the placeholder text, and enables cursor blink. Setting the
89 // search box inactive center aligns the placeholder text, sets the color, and
90 // disables cursor blink.
91 void SetSearchBoxActive(bool active);
92
93 // Closes the |app_list_view_| if the search box gets unfocused.
94 void HandleSearchBoxEvent(ui::LocatedEvent* located_event,
95 ui::EventType type);
96
97 // Handles Gesture and Mouse Events sent from |search_box_|.
98 bool OnTextfieldEvent();
99
84 // Overridden from views::View: 100 // Overridden from views::View:
85 bool OnMouseWheel(const ui::MouseWheelEvent& event) override; 101 bool OnMouseWheel(const ui::MouseWheelEvent& event) override;
86 void OnEnabledChanged() override; 102 void OnEnabledChanged() override;
87 const char* GetClassName() const override; 103 const char* GetClassName() const override;
104 void OnGestureEvent(ui::GestureEvent* event) override;
105 void OnMouseEvent(ui::MouseEvent* event) override;
88 106
89 private: 107 private:
90 // Updates model text and selection model with current Textfield info. 108 // Updates model text and selection model with current Textfield info.
91 void UpdateModel(); 109 void UpdateModel();
92 110
93 // Fires query change notification. 111 // Fires query change notification.
94 void NotifyQueryChanged(); 112 void NotifyQueryChanged();
95 113
96 // Overridden from views::TextfieldController: 114 // Overridden from views::TextfieldController:
97 void ContentsChanged(views::Textfield* sender, 115 void ContentsChanged(views::Textfield* sender,
98 const base::string16& new_contents) override; 116 const base::string16& new_contents) override;
99 bool HandleKeyEvent(views::Textfield* sender, 117 bool HandleKeyEvent(views::Textfield* sender,
100 const ui::KeyEvent& key_event) override; 118 const ui::KeyEvent& key_event) override;
119 bool HandleMouseEvent(views::Textfield* sender,
120 const ui::MouseEvent& mouse_event) override;
121 bool HandleGestureEvent(views::Textfield* sender,
122 const ui::GestureEvent& gesture_event) override;
101 123
102 // Overridden from views::ButtonListener: 124 // Overridden from views::ButtonListener:
103 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 125 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
104 126
105 // Overridden from SearchBoxModelObserver: 127 // Overridden from SearchBoxModelObserver:
106 void SpeechRecognitionButtonPropChanged() override; 128 void SpeechRecognitionButtonPropChanged() override;
107 void HintTextChanged() override; 129 void HintTextChanged() override;
108 void SelectionModelChanged() override; 130 void SelectionModelChanged() override;
109 void Update() override; 131 void Update() override;
110 132
(...skipping 10 matching lines...) Expand all
121 SearchBoxImageButton* back_button_; // Owned by views hierarchy. 143 SearchBoxImageButton* back_button_; // Owned by views hierarchy.
122 SearchBoxImageButton* speech_button_; // Owned by views hierarchy. 144 SearchBoxImageButton* speech_button_; // Owned by views hierarchy.
123 views::Textfield* search_box_; // Owned by views hierarchy. 145 views::Textfield* search_box_; // Owned by views hierarchy.
124 views::View* contents_view_; // Owned by views hierarchy. 146 views::View* contents_view_; // Owned by views hierarchy.
125 app_list::AppListView* app_list_view_; // Owned by views hierarchy. 147 app_list::AppListView* app_list_view_; // Owned by views hierarchy.
126 148
127 SearchBoxFocus focused_view_; // Which element has TAB'd focus. 149 SearchBoxFocus focused_view_; // Which element has TAB'd focus.
128 150
129 // Whether the fullscreen app list feature is enabled. 151 // Whether the fullscreen app list feature is enabled.
130 const bool is_fullscreen_app_list_enabled_; 152 const bool is_fullscreen_app_list_enabled_;
153 // Whether the search box is active.
154 bool is_search_box_active_ = false;
131 155
132 DISALLOW_COPY_AND_ASSIGN(SearchBoxView); 156 DISALLOW_COPY_AND_ASSIGN(SearchBoxView);
133 }; 157 };
134 158
135 } // namespace app_list 159 } // namespace app_list
136 160
137 #endif // UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_ 161 #endif // UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698