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

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

Issue 1505223004: Do not use assets for Ash window control button backgrounds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WIP for pkasting and estade feedback Created 5 years 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 "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "ash/frame/caption_buttons/caption_button_types.h" 9 #include "ash/frame/caption_buttons/caption_button_types.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 13 matching lines...) Expand all
24 enum Animate { 24 enum Animate {
25 ANIMATE_YES, 25 ANIMATE_YES,
26 ANIMATE_NO 26 ANIMATE_NO
27 }; 27 };
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 images 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 ids match those 35 // the button crossfades to the new visuals. If the image id 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 SetImages(CaptionButtonIcon icon, 38 void SetImage(CaptionButtonIcon icon, Animate animate, int icon_image_id);
39 Animate animate,
40 int icon_image_id,
41 int hovered_background_image_id,
42 int pressed_background_image_id);
43 39
44 // Returns true if the button is crossfading to new visuals set in 40 // Returns true if the button is crossfading to new visuals set in
45 // SetImages(). 41 // SetImage().
46 bool IsAnimatingImageSwap() const; 42 bool IsAnimatingImageSwap() const;
47 43
48 // Sets the alpha to use for painting. Used to animate visibility changes. 44 // Sets the alpha to use for painting. Used to animate visibility changes.
49 void SetAlpha(int alpha); 45 void SetAlpha(int alpha);
50 46
51 // views::View overrides: 47 // views::View overrides:
52 gfx::Size GetPreferredSize() const override; 48 gfx::Size GetPreferredSize() const override;
53 const char* GetClassName() const override; 49 const char* GetClassName() const override;
54 void OnPaint(gfx::Canvas* canvas) override; 50 void OnPaint(gfx::Canvas* canvas) override;
55 51
56 void set_paint_as_active(bool paint_as_active) { 52 void set_paint_as_active(bool paint_as_active) {
57 paint_as_active_ = paint_as_active; 53 paint_as_active_ = paint_as_active;
58 } 54 }
59 55
60 CaptionButtonIcon icon() const { 56 CaptionButtonIcon icon() const {
61 return icon_; 57 return icon_;
62 } 58 }
63 59
64 int icon_image_id() const { return icon_image_id_; } 60 int icon_image_id() const { return icon_image_id_; }
65 61
62 void set_size(const gfx::Size& size) { size_ = size; }
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
77 // The size of the button's hit region.
78 gfx::Size size_;
79
79 // Whether the button should be painted as active. 80 // Whether the button should be painted as active.
80 bool paint_as_active_; 81 bool paint_as_active_;
81 82
82 // Current alpha to use for painting. 83 // Current alpha to use for painting.
83 int alpha_; 84 int alpha_;
84 85
85 // The images and image ids used to paint the button. 86 // The image and image id used to paint the button's icon.
86 int icon_image_id_; 87 int icon_image_id_;
87 int hovered_background_image_id_;
88 int pressed_background_image_id_;
89 gfx::ImageSkia icon_image_; 88 gfx::ImageSkia icon_image_;
90 gfx::ImageSkia hovered_background_image_;
91 gfx::ImageSkia pressed_background_image_;
92 89
93 // The icon image to crossfade from. 90 // The icon image to crossfade from.
94 gfx::ImageSkia crossfade_icon_image_; 91 gfx::ImageSkia crossfade_icon_image_;
95 92
96 // Crossfade animation started when the button's images are changed by 93 // Crossfade animation started when the button's images are changed by
97 // SetImages(). 94 // SetImage().
98 scoped_ptr<gfx::SlideAnimation> swap_images_animation_; 95 scoped_ptr<gfx::SlideAnimation> swap_images_animation_;
99 96
100 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButton); 97 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButton);
101 }; 98 };
102 99
103 } // namespace ash 100 } // namespace ash
104 101
105 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ 102 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_
OLDNEW
« no previous file with comments | « no previous file | ash/frame/caption_buttons/frame_caption_button.cc » ('j') | ash/frame/caption_buttons/frame_caption_button.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698