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

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

Issue 2744463002: Add VectorIconButton functionality to ImageButton. (Closed)
Patch Set: wip: address high-level comments 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>
9
10 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
11 #include "base/macros.h" 9 #include "base/macros.h"
12 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
13 #include "chrome/browser/ui/views/dropdown_bar_host_delegate.h" 11 #include "chrome/browser/ui/views/dropdown_bar_host_delegate.h"
14 #include "ui/views/controls/button/vector_icon_button_delegate.h" 12 #include "ui/views/controls/button/button.h"
13 #include "ui/views/controls/button/vector_icon_image_updater.h"
15 #include "ui/views/controls/textfield/textfield_controller.h" 14 #include "ui/views/controls/textfield/textfield_controller.h"
16 #include "ui/views/view.h" 15 #include "ui/views/view.h"
17 #include "ui/views/view_targeter_delegate.h" 16 #include "ui/views/view_targeter_delegate.h"
18 17
19 class FindBarHost; 18 class FindBarHost;
20 class FindNotificationDetails; 19 class FindNotificationDetails;
21 20
22 namespace gfx { 21 namespace gfx {
23 class Range; 22 class Range;
24 } 23 }
25 24
26 namespace views { 25 namespace views {
27 class Label; 26 class Label;
28 class Painter; 27 class Painter;
29 class Separator; 28 class Separator;
30 class Textfield; 29 class Textfield;
31 class VectorIconButton; 30 class ImageButton;
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::ButtonListener,
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 13 matching lines...) Expand all
67 // Clears the current Match Count value in the Find text box. 66 // Clears the current Match Count value in the Find text box.
68 void ClearMatchCount(); 67 void ClearMatchCount();
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::ButtonListener:
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;
80 78
81 // views::TextfieldController: 79 // views::TextfieldController:
82 bool HandleKeyEvent(views::Textfield* sender, 80 bool HandleKeyEvent(views::Textfield* sender,
83 const ui::KeyEvent& key_event) override; 81 const ui::KeyEvent& key_event) override;
84 void OnAfterUserAction(views::Textfield* sender) override; 82 void OnAfterUserAction(views::Textfield* sender) override;
85 void OnAfterPaste() override; 83 void OnAfterPaste() override;
86 84
87 // views::ViewTargeterDelegate: 85 // views::ViewTargeterDelegate:
88 views::View* TargetForRect(View* root, const gfx::Rect& rect) override; 86 views::View* TargetForRect(View* root, const gfx::Rect& rect) override;
89 87
90 private: 88 private:
89 class FindBarViewButtonImageUpdater : public views::VectorIconImageUpdater {
90 public:
91 FindBarViewButtonImageUpdater(const gfx::VectorIcon& icon,
92 FindBarView* parent);
93
94 protected:
95 // views::VectorIconImageUpdater:
96 SkColor GetVectorIconColor() const override;
97
98 private:
99 const FindBarView* parent_;
100 };
101
102 views::ImageButton* CreateButton(const gfx::VectorIcon& icon);
103
91 // Starts finding |search_text|. If the text is empty, stops finding. 104 // Starts finding |search_text|. If the text is empty, stops finding.
92 void Find(const base::string16& search_text); 105 void Find(const base::string16& search_text);
93 106
94 // Updates the appearance for the match count label. 107 // Updates the appearance for the match count label.
95 void UpdateMatchCountAppearance(bool no_match); 108 void UpdateMatchCountAppearance(bool no_match);
96 109
97 // DropdownBarView: 110 // DropdownBarView:
98 const char* GetClassName() const override; 111 const char* GetClassName() const override;
99 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; 112 void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
100 113
101 // Returns the color for the icons on the buttons per the current NativeTheme. 114 // Returns the color for the icons on the buttons per the current NativeTheme.
102 SkColor GetTextColorForIcon(); 115 SkColor GetTextColorForIcon();
103 116
104 // The OS-specific view for the find bar that acts as an intermediary 117 // The OS-specific view for the find bar that acts as an intermediary
105 // between us and the WebContentsView. 118 // between us and the WebContentsView.
106 FindBarHost* find_bar_host_; 119 FindBarHost* find_bar_host_;
107 120
108 // Used to detect if the input text, not including the IME composition text, 121 // Used to detect if the input text, not including the IME composition text,
109 // has changed or not. 122 // has changed or not.
110 base::string16 last_searched_text_; 123 base::string16 last_searched_text_;
111 124
112 // The controls in the window. 125 // The controls in the window.
113 views::Textfield* find_text_; 126 views::Textfield* find_text_;
114 std::unique_ptr<views::Painter> find_text_border_; 127 std::unique_ptr<views::Painter> find_text_border_;
115 views::Label* match_count_text_; 128 views::Label* match_count_text_;
116 views::View* focus_forwarder_view_; 129 views::View* focus_forwarder_view_;
117 views::Separator* separator_; 130 views::Separator* separator_;
118 views::VectorIconButton* find_previous_button_; 131 views::ImageButton* find_previous_button_;
119 views::VectorIconButton* find_next_button_; 132 views::ImageButton* find_next_button_;
120 views::VectorIconButton* close_button_; 133 views::ImageButton* close_button_;
121 134
122 // The preferred height of the find bar. 135 // The preferred height of the find bar.
123 int preferred_height_; 136 int preferred_height_;
124 137
125 DISALLOW_COPY_AND_ASSIGN(FindBarView); 138 DISALLOW_COPY_AND_ASSIGN(FindBarView);
126 }; 139 };
127 140
128 #endif // CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ 141 #endif // CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698