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

Side by Side Diff: chrome/browser/ui/views/find_bar_view.h

Issue 2744463002: Add VectorIconButton functionality to ImageButton. (Closed)
Patch Set: fix cros build Created 3 years, 9 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 CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "chrome/browser/ui/views/dropdown_bar_host_delegate.h" 13 #include "chrome/browser/ui/views/dropdown_bar_host_delegate.h"
14 #include "ui/views/controls/button/vector_icon_button_delegate.h" 14 #include "ui/views/controls/button/image_button.h"
15 #include "ui/views/controls/textfield/textfield_controller.h" 15 #include "ui/views/controls/textfield/textfield_controller.h"
16 #include "ui/views/view.h" 16 #include "ui/views/view.h"
17 #include "ui/views/view_targeter_delegate.h" 17 #include "ui/views/view_targeter_delegate.h"
18 18
19 class FindBarHost; 19 class FindBarHost;
20 class FindNotificationDetails; 20 class FindNotificationDetails;
21 21
22 namespace gfx { 22 namespace gfx {
23 class Range; 23 class Range;
24 } 24 }
25 25
26 namespace views { 26 namespace views {
27 class Label; 27 class Label;
28 class Painter; 28 class Painter;
29 class Separator; 29 class Separator;
30 class Textfield; 30 class Textfield;
31 class VectorIconButton;
32 } 31 }
33 32
34 //////////////////////////////////////////////////////////////////////////////// 33 ////////////////////////////////////////////////////////////////////////////////
35 // 34 //
36 // The FindBarView is responsible for drawing the UI controls of the 35 // The FindBarView is responsible for drawing the UI controls of the
37 // FindBar, the find text box, the 'Find' button and the 'Close' 36 // FindBar, the find text box, the 'Find' button and the 'Close'
38 // button. It communicates the user search words to the FindBarHost. 37 // button. It communicates the user search words to the FindBarHost.
39 // 38 //
40 //////////////////////////////////////////////////////////////////////////////// 39 ////////////////////////////////////////////////////////////////////////////////
41 class FindBarView : public views::View, 40 class FindBarView : public views::View,
42 public DropdownBarHostDelegate, 41 public DropdownBarHostDelegate,
43 public views::VectorIconButtonDelegate, 42 public views::ImageButtonDelegate,
44 public views::TextfieldController, 43 public views::TextfieldController,
45 public views::ViewTargeterDelegate { 44 public views::ViewTargeterDelegate {
46 public: 45 public:
47 explicit FindBarView(FindBarHost* host); 46 explicit FindBarView(FindBarHost* host);
48 ~FindBarView() override; 47 ~FindBarView() override;
49 48
50 // Accessors for the text and selection displayed in the text box. 49 // Accessors for the text and selection displayed in the text box.
51 void SetFindTextAndSelectedRange(const base::string16& find_text, 50 void SetFindTextAndSelectedRange(const base::string16& find_text,
52 const gfx::Range& selected_range); 51 const gfx::Range& selected_range);
53 base::string16 GetFindText() const; 52 base::string16 GetFindText() const;
(...skipping 15 matching lines...) Expand all
69 68
70 // views::View: 69 // views::View:
71 void Layout() override; 70 void Layout() override;
72 gfx::Size GetPreferredSize() const override; 71 gfx::Size GetPreferredSize() const override;
73 72
74 // DropdownBarHostDelegate: 73 // DropdownBarHostDelegate:
75 void SetFocusAndSelection(bool select_all) override; 74 void SetFocusAndSelection(bool select_all) override;
76 75
77 // views::VectorIconButtonDelegate: 76 // views::VectorIconButtonDelegate:
78 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 77 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
79 SkColor GetVectorIconBaseColor() const override; 78 SkColor GetVectorIconColor() const override;
80 79
81 // views::TextfieldController: 80 // views::TextfieldController:
82 bool HandleKeyEvent(views::Textfield* sender, 81 bool HandleKeyEvent(views::Textfield* sender,
83 const ui::KeyEvent& key_event) override; 82 const ui::KeyEvent& key_event) override;
84 void OnAfterUserAction(views::Textfield* sender) override; 83 void OnAfterUserAction(views::Textfield* sender) override;
85 void OnAfterPaste() override; 84 void OnAfterPaste() override;
86 85
87 // views::ViewTargeterDelegate: 86 // views::ViewTargeterDelegate:
88 views::View* TargetForRect(View* root, const gfx::Rect& rect) override; 87 views::View* TargetForRect(View* root, const gfx::Rect& rect) override;
89 88
90 private: 89 private:
91 // Starts finding |search_text|. If the text is empty, stops finding. 90 // Starts finding |search_text|. If the text is empty, stops finding.
92 void Find(const base::string16& search_text); 91 void Find(const base::string16& search_text);
93 92
94 // Updates the appearance for the match count label. 93 // Updates the appearance for the match count label.
95 void UpdateMatchCountAppearance(bool no_match); 94 void UpdateMatchCountAppearance(bool no_match);
96 95
96 views::ImageButton* CreateButton(const gfx::VectorIcon& icon);
97
97 // DropdownBarView: 98 // DropdownBarView:
98 const char* GetClassName() const override; 99 const char* GetClassName() const override;
99 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; 100 void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
100 101
101 // Returns the color for the icons on the buttons per the current NativeTheme. 102 // Returns the color for the icons on the buttons per the current NativeTheme.
102 SkColor GetTextColorForIcon(); 103 SkColor GetTextColorForIcon();
103 104
104 // The OS-specific view for the find bar that acts as an intermediary 105 // The OS-specific view for the find bar that acts as an intermediary
105 // between us and the WebContentsView. 106 // between us and the WebContentsView.
106 FindBarHost* find_bar_host_; 107 FindBarHost* find_bar_host_;
107 108
108 // Used to detect if the input text, not including the IME composition text, 109 // Used to detect if the input text, not including the IME composition text,
109 // has changed or not. 110 // has changed or not.
110 base::string16 last_searched_text_; 111 base::string16 last_searched_text_;
111 112
112 // The controls in the window. 113 // The controls in the window.
113 views::Textfield* find_text_; 114 views::Textfield* find_text_;
114 std::unique_ptr<views::Painter> find_text_border_; 115 std::unique_ptr<views::Painter> find_text_border_;
115 views::Label* match_count_text_; 116 views::Label* match_count_text_;
116 views::View* focus_forwarder_view_; 117 views::View* focus_forwarder_view_;
117 views::Separator* separator_; 118 views::Separator* separator_;
118 views::VectorIconButton* find_previous_button_; 119 views::ImageButton* find_previous_button_;
119 views::VectorIconButton* find_next_button_; 120 views::ImageButton* find_next_button_;
120 views::VectorIconButton* close_button_; 121 views::ImageButton* close_button_;
121 122
122 // The preferred height of the find bar. 123 // The preferred height of the find bar.
123 int preferred_height_; 124 int preferred_height_;
124 125
125 DISALLOW_COPY_AND_ASSIGN(FindBarView); 126 DISALLOW_COPY_AND_ASSIGN(FindBarView);
126 }; 127 };
127 128
128 #endif // CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ 129 #endif // CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698