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

Side by Side Diff: ui/views/controls/button/vector_icon_button.h

Issue 2744463002: Add VectorIconButton functionality to ImageButton. (Closed)
Patch Set: WIP: use observer 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_VIEWS_CONTROLS_BUTTON_VECTOR_ICON_BUTTON_H_ 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_VECTOR_ICON_BUTTON_H_
6 #define UI_VIEWS_CONTROLS_BUTTON_VECTOR_ICON_BUTTON_H_ 6 #define UI_VIEWS_CONTROLS_BUTTON_VECTOR_ICON_BUTTON_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "ui/views/controls/button/image_button.h" 9 #include "ui/views/controls/button/image_button.h"
10 10
11 namespace gfx { 11 namespace gfx {
12 struct VectorIcon; 12 struct VectorIcon;
13 enum class VectorIconId; 13 enum class VectorIconId;
14 } 14 }
15 15
16 namespace views { 16 namespace views {
17 17
18 class VectorIconButtonDelegate; 18 class VectorIconButtonDelegate;
19 19
20 // A button that has an image and no text, with the image defined by a vector 20 // A button that has a image from a vector icon and no text.
21 // icon identifier.
22 class VIEWS_EXPORT VectorIconButton : public views::ImageButton { 21 class VIEWS_EXPORT VectorIconButton : public views::ImageButton {
23 public: 22 public:
24 explicit VectorIconButton(VectorIconButtonDelegate* delegate); 23 explicit VectorIconButton(VectorIconButtonDelegate* delegate);
25 ~VectorIconButton() override; 24 ~VectorIconButton() override;
26 25
27 // Sets the icon to display and provides a callback which should return the 26 // Sets the icon to display.
28 // text color from which to derive this icon's color. The one that takes an ID
29 // is deprecated and should be removed when all vector icons are identified by
30 // VectorIcon structs.
31 void SetIcon(gfx::VectorIconId id);
32 void SetIcon(const gfx::VectorIcon& icon); 27 void SetIcon(const gfx::VectorIcon& icon);
33 28
34 // views::ImageButton: 29 // views::ImageButton:
35 void OnThemeChanged() override; 30 void OnThemeChanged() override;
36 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; 31 void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
37 32
38 private: 33 private:
39 // Performs the work common to both SetIcon() variants.
40 void OnSetIcon();
41
42 // Called when something may have affected the button's images or colors. 34 // Called when something may have affected the button's images or colors.
43 void UpdateImagesAndColors(); 35 void UpdateImagesAndColors();
44 36
45 VectorIconButtonDelegate* delegate_; 37 VectorIconButtonDelegate* delegate_;
46 // TODO(estade): remove |id_| in favor of |icon_| once all callers have been
47 // updated.
48 gfx::VectorIconId id_;
49 const gfx::VectorIcon* icon_ = nullptr; 38 const gfx::VectorIcon* icon_ = nullptr;
50 39
51 DISALLOW_COPY_AND_ASSIGN(VectorIconButton); 40 DISALLOW_COPY_AND_ASSIGN(VectorIconButton);
52 }; 41 };
53 42
54 } // namespace views 43 } // namespace views
55 44
56 #endif // UI_VIEWS_CONTROLS_BUTTON_VECTOR_ICON_BUTTON_H_ 45 #endif // UI_VIEWS_CONTROLS_BUTTON_VECTOR_ICON_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698