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

Side by Side Diff: ash/common/frame/caption_buttons/frame_caption_button.h

Issue 2620613005: Move more vector icons to respective directories and update code to (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | ash/common/frame/caption_buttons/frame_caption_button.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 ASH_COMMON_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ 5 #ifndef ASH_COMMON_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_
6 #define ASH_COMMON_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ 6 #define ASH_COMMON_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "ash/common/frame/caption_buttons/caption_button_types.h" 11 #include "ash/common/frame/caption_buttons/caption_button_types.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "ui/gfx/image/image_skia.h" 13 #include "ui/gfx/image/image_skia.h"
14 #include "ui/views/controls/button/custom_button.h" 14 #include "ui/views/controls/button/custom_button.h"
15 15
16 namespace gfx { 16 namespace gfx {
17 class SlideAnimation; 17 class SlideAnimation;
18 enum class VectorIconId; 18 struct VectorIcon;
19 } 19 }
20 20
21 namespace ash { 21 namespace ash {
22 22
23 // Base class for the window caption buttons (minimize, maximize, restore, 23 // Base class for the window caption buttons (minimize, maximize, restore,
24 // close). 24 // close).
25 class ASH_EXPORT FrameCaptionButton : public views::CustomButton { 25 class ASH_EXPORT FrameCaptionButton : public views::CustomButton {
26 public: 26 public:
27 enum Animate { ANIMATE_YES, ANIMATE_NO }; 27 enum Animate { ANIMATE_YES, ANIMATE_NO };
28 28
29 static const char kViewClassName[]; 29 static const char kViewClassName[];
30 30
31 FrameCaptionButton(views::ButtonListener* listener, CaptionButtonIcon icon); 31 FrameCaptionButton(views::ButtonListener* listener, CaptionButtonIcon icon);
32 ~FrameCaptionButton() override; 32 ~FrameCaptionButton() override;
33 33
34 // Sets the image to use to paint the button. If |animate| is ANIMATE_YES, 34 // Sets the image to use to paint the button. If |animate| is ANIMATE_YES,
35 // the button crossfades to the new visuals. If the image id matches the one 35 // the button crossfades to the new visuals. If the image matches the one
36 // currently used by the button and |animate| is ANIMATE_NO, the crossfade 36 // currently used by the button and |animate| is ANIMATE_NO, the crossfade
37 // animation is progressed to the end. 37 // animation is progressed to the end.
38 void SetImage(CaptionButtonIcon icon, 38 void SetImage(CaptionButtonIcon icon,
39 Animate animate, 39 Animate animate,
40 gfx::VectorIconId icon_image_id); 40 const gfx::VectorIcon& icon_image);
41 41
42 // Returns true if the button is crossfading to new visuals set in 42 // Returns true if the button is crossfading to new visuals set in
43 // SetImage(). 43 // SetImage().
44 bool IsAnimatingImageSwap() const; 44 bool IsAnimatingImageSwap() const;
45 45
46 // Sets the alpha to use for painting. Used to animate visibility changes. 46 // Sets the alpha to use for painting. Used to animate visibility changes.
47 void SetAlpha(int alpha); 47 void SetAlpha(int alpha);
48 48
49 // views::View overrides: 49 // views::View overrides:
50 gfx::Size GetPreferredSize() const override; 50 gfx::Size GetPreferredSize() const override;
51 const char* GetClassName() const override; 51 const char* GetClassName() const override;
52 void OnPaint(gfx::Canvas* canvas) override; 52 void OnPaint(gfx::Canvas* canvas) override;
53 53
54 void set_paint_as_active(bool paint_as_active) { 54 void set_paint_as_active(bool paint_as_active) {
55 paint_as_active_ = paint_as_active; 55 paint_as_active_ = paint_as_active;
56 } 56 }
57 57
58 void set_use_light_images(bool light) { use_light_images_ = light; } 58 void set_use_light_images(bool light) { use_light_images_ = light; }
59 59
60 CaptionButtonIcon icon() const { return icon_; } 60 CaptionButtonIcon icon() const { return icon_; }
61 61
62 gfx::VectorIconId icon_image_id() const { return icon_image_id_; }
63
64 void set_size(const gfx::Size& size) { size_ = size; } 62 void set_size(const gfx::Size& size) { size_ = size; }
65 63
66 protected: 64 protected:
67 // views::CustomButton override: 65 // views::CustomButton override:
68 void OnGestureEvent(ui::GestureEvent* event) override; 66 void OnGestureEvent(ui::GestureEvent* event) override;
69 67
70 private: 68 private:
71 // Paints |to_center| centered within the button with |alpha|. 69 // Paints |to_center| centered within the button with |alpha|.
72 void PaintCentered(gfx::Canvas* canvas, 70 void PaintCentered(gfx::Canvas* canvas,
73 const gfx::ImageSkia& to_center, 71 const gfx::ImageSkia& to_center,
74 int alpha); 72 int alpha);
75 73
76 // The button's current icon. 74 // The button's current icon.
77 CaptionButtonIcon icon_; 75 CaptionButtonIcon icon_;
78 76
79 // The size of the button. 77 // The size of the button.
80 gfx::Size size_; 78 gfx::Size size_;
81 79
82 // Whether the button should be painted as active. 80 // Whether the button should be painted as active.
83 bool paint_as_active_; 81 bool paint_as_active_;
84 82
85 // Whether to paint in a lighter color (for use on dark backgrounds). 83 // Whether to paint in a lighter color (for use on dark backgrounds).
86 bool use_light_images_; 84 bool use_light_images_;
87 85
88 // Current alpha to use for painting. 86 // Current alpha to use for painting.
89 int alpha_; 87 int alpha_;
90 88
91 // The image id (kept for the purposes of testing) and image used to paint the 89 // The image id (kept for the purposes of testing) and image used to paint the
92 // button's icon. 90 // button's icon.
93 gfx::VectorIconId icon_image_id_; 91 const gfx::VectorIcon* icon_definition_ = nullptr;
94 gfx::ImageSkia icon_image_; 92 gfx::ImageSkia icon_image_;
95 93
96 // The icon image to crossfade from. 94 // The icon image to crossfade from.
97 gfx::ImageSkia crossfade_icon_image_; 95 gfx::ImageSkia crossfade_icon_image_;
98 96
99 // Crossfade animation started when the button's images are changed by 97 // Crossfade animation started when the button's images are changed by
100 // SetImage(). 98 // SetImage().
101 std::unique_ptr<gfx::SlideAnimation> swap_images_animation_; 99 std::unique_ptr<gfx::SlideAnimation> swap_images_animation_;
102 100
103 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButton); 101 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButton);
104 }; 102 };
105 103
106 } // namespace ash 104 } // namespace ash
107 105
108 #endif // ASH_COMMON_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ 106 #endif // ASH_COMMON_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_
OLDNEW
« no previous file with comments | « no previous file | ash/common/frame/caption_buttons/frame_caption_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698