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

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

Issue 2901503003: Rename GetPreferredSize to CalculatePreferredSize in ash/ (Closed)
Patch Set: improvements Created 3 years, 7 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 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_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ 5 #ifndef ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_
6 #define ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ 6 #define ASH_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"
(...skipping 29 matching lines...) Expand all
40 const gfx::VectorIcon& icon_image); 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;
51 const char* GetClassName() const override; 50 const char* GetClassName() const override;
52 void OnPaint(gfx::Canvas* canvas) override; 51 void OnPaint(gfx::Canvas* canvas) override;
53 52
54 void set_paint_as_active(bool paint_as_active) { 53 void set_paint_as_active(bool paint_as_active) {
55 paint_as_active_ = paint_as_active; 54 paint_as_active_ = paint_as_active;
56 } 55 }
57 56
58 void set_use_light_images(bool light) { use_light_images_ = light; } 57 void set_use_light_images(bool light) { use_light_images_ = light; }
59 58
60 CaptionButtonIcon icon() const { return icon_; } 59 CaptionButtonIcon icon() const { return icon_; }
61 60
62 void set_size(const gfx::Size& size) { size_ = size; }
63
64 protected: 61 protected:
65 // views::CustomButton override: 62 // views::CustomButton override:
66 void OnGestureEvent(ui::GestureEvent* event) override; 63 void OnGestureEvent(ui::GestureEvent* event) override;
67 64
68 private: 65 private:
69 // Determines what alpha to use for the icon based on animation and 66 // Determines what alpha to use for the icon based on animation and
70 // active state. 67 // active state.
71 int GetAlphaForIcon(int base_alpha) const; 68 int GetAlphaForIcon(int base_alpha) const;
72 69
73 // The button's current icon. 70 // The button's current icon.
74 CaptionButtonIcon icon_; 71 CaptionButtonIcon icon_;
75 72
76 // The size of the button.
77 gfx::Size size_;
78
79 // Whether the button should be painted as active. 73 // Whether the button should be painted as active.
80 bool paint_as_active_; 74 bool paint_as_active_;
81 75
82 // Whether to paint in a lighter color (for use on dark backgrounds). 76 // Whether to paint in a lighter color (for use on dark backgrounds).
83 bool use_light_images_; 77 bool use_light_images_;
84 78
85 // Current alpha to use for painting. 79 // Current alpha to use for painting.
86 int alpha_; 80 int alpha_;
87 81
88 // The image id (kept for the purposes of testing) and image used to paint the 82 // The image id (kept for the purposes of testing) and image used to paint the
89 // button's icon. 83 // button's icon.
90 const gfx::VectorIcon* icon_definition_ = nullptr; 84 const gfx::VectorIcon* icon_definition_ = nullptr;
91 gfx::ImageSkia icon_image_; 85 gfx::ImageSkia icon_image_;
92 86
93 // The icon image to crossfade from. 87 // The icon image to crossfade from.
94 gfx::ImageSkia crossfade_icon_image_; 88 gfx::ImageSkia crossfade_icon_image_;
95 89
96 // Crossfade animation started when the button's images are changed by 90 // Crossfade animation started when the button's images are changed by
97 // SetImage(). 91 // SetImage().
98 std::unique_ptr<gfx::SlideAnimation> swap_images_animation_; 92 std::unique_ptr<gfx::SlideAnimation> swap_images_animation_;
99 93
100 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButton); 94 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButton);
101 }; 95 };
102 96
103 } // namespace ash 97 } // namespace ash
104 98
105 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ 99 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_
OLDNEW
« no previous file with comments | « ash/autoclick/common/autoclick_ring_handler.cc ('k') | ash/frame/caption_buttons/frame_caption_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698