OLD | NEW |
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 "ui/app_list/search_box_model_observer.h" | 10 #include "ui/app_list/search_box_model_observer.h" |
11 #include "ui/app_list/speech_ui_model_observer.h" | 11 #include "ui/app_list/speech_ui_model_observer.h" |
| 12 #include "ui/gfx/shadow_value.h" |
12 #include "ui/views/controls/button/image_button.h" | 13 #include "ui/views/controls/button/image_button.h" |
13 #include "ui/views/controls/button/menu_button_listener.h" | 14 #include "ui/views/controls/button/menu_button_listener.h" |
14 #include "ui/views/controls/textfield/textfield_controller.h" | 15 #include "ui/views/controls/textfield/textfield_controller.h" |
15 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
16 | 17 |
17 namespace views { | 18 namespace views { |
18 class ImageView; | 19 class ImageView; |
19 class MenuButton; | 20 class MenuButton; |
20 class Textfield; | 21 class Textfield; |
21 } // namespace views | 22 } // namespace views |
(...skipping 19 matching lines...) Expand all Loading... |
41 public: | 42 public: |
42 SearchBoxView(SearchBoxViewDelegate* delegate, | 43 SearchBoxView(SearchBoxViewDelegate* delegate, |
43 AppListViewDelegate* view_delegate); | 44 AppListViewDelegate* view_delegate); |
44 ~SearchBoxView() override; | 45 ~SearchBoxView() override; |
45 | 46 |
46 void ModelChanged(); | 47 void ModelChanged(); |
47 bool HasSearch() const; | 48 bool HasSearch() const; |
48 void ClearSearch(); | 49 void ClearSearch(); |
49 void InvalidateMenu(); | 50 void InvalidateMenu(); |
50 | 51 |
| 52 // Sets the shadow border of the search box. |
| 53 void SetShadow(const gfx::ShadowValue& shadow); |
| 54 |
51 // Returns the bounds to use for the view (including the shadow) given the | 55 // Returns the bounds to use for the view (including the shadow) given the |
52 // desired bounds of the search box contents. | 56 // desired bounds of the search box contents. |
53 gfx::Rect GetViewBoundsForSearchBoxContentsBounds( | 57 gfx::Rect GetViewBoundsForSearchBoxContentsBounds( |
54 const gfx::Rect& rect) const; | 58 const gfx::Rect& rect) const; |
55 | 59 |
56 views::ImageButton* back_button() { return back_button_; } | 60 views::ImageButton* back_button() { return back_button_; } |
57 views::Textfield* search_box() { return search_box_; } | 61 views::Textfield* search_box() { return search_box_; } |
58 | 62 |
59 void set_contents_view(views::View* contents_view) { | 63 void set_contents_view(views::View* contents_view) { |
60 contents_view_ = contents_view; | 64 contents_view_ = contents_view; |
61 } | 65 } |
62 | 66 |
63 // Overridden from views::View: | 67 // Overridden from views::View: |
64 gfx::Size GetPreferredSize() const override; | 68 gfx::Size GetPreferredSize() const override; |
65 bool OnMouseWheel(const ui::MouseWheelEvent& event) override; | 69 bool OnMouseWheel(const ui::MouseWheelEvent& event) override; |
66 void OnEnabledChanged() override; | 70 void OnEnabledChanged() override; |
67 | 71 |
| 72 // Returns the shadow values for the search box at |z_height|. |
| 73 static gfx::ShadowValue GetShadowForZHeight(int z_height); |
| 74 |
68 private: | 75 private: |
69 // Updates model text and selection model with current Textfield info. | 76 // Updates model text and selection model with current Textfield info. |
70 void UpdateModel(); | 77 void UpdateModel(); |
71 | 78 |
72 // Fires query change notification. | 79 // Fires query change notification. |
73 void NotifyQueryChanged(); | 80 void NotifyQueryChanged(); |
74 | 81 |
75 // Overridden from views::TextfieldController: | 82 // Overridden from views::TextfieldController: |
76 void ContentsChanged(views::Textfield* sender, | 83 void ContentsChanged(views::Textfield* sender, |
77 const base::string16& new_contents) override; | 84 const base::string16& new_contents) override; |
(...skipping 30 matching lines...) Expand all Loading... |
108 views::MenuButton* menu_button_; // Owned by views hierarchy. | 115 views::MenuButton* menu_button_; // Owned by views hierarchy. |
109 views::Textfield* search_box_; // Owned by views hierarchy. | 116 views::Textfield* search_box_; // Owned by views hierarchy. |
110 views::View* contents_view_; // Owned by views hierarchy. | 117 views::View* contents_view_; // Owned by views hierarchy. |
111 | 118 |
112 DISALLOW_COPY_AND_ASSIGN(SearchBoxView); | 119 DISALLOW_COPY_AND_ASSIGN(SearchBoxView); |
113 }; | 120 }; |
114 | 121 |
115 } // namespace app_list | 122 } // namespace app_list |
116 | 123 |
117 #endif // UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_ | 124 #endif // UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_ |
OLD | NEW |