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

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

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

Powered by Google App Engine
This is Rietveld 408576698