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

Side by Side Diff: mash/wm/frame/caption_buttons/frame_caption_button.h

Issue 2029883002: Moves mash/wm into ash/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_static_assert
Patch Set: move comment Created 4 years, 6 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 2015 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 MASH_WM_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_
6 #define MASH_WM_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "mash/wm/frame/caption_buttons/caption_button_types.h"
12 #include "ui/gfx/image/image_skia.h"
13 #include "ui/views/controls/button/custom_button.h"
14
15 namespace gfx {
16 class SlideAnimation;
17 }
18
19 namespace mash {
20 namespace wm {
21
22 // Base class for the window caption buttons (minimize, maximize, restore,
23 // close).
24 class FrameCaptionButton : public views::CustomButton {
25 public:
26 enum Animate { ANIMATE_YES, ANIMATE_NO };
27
28 static const char kViewClassName[];
29
30 FrameCaptionButton(views::ButtonListener* listener, CaptionButtonIcon icon);
31 ~FrameCaptionButton() override;
32
33 // Sets the images to use to paint the button. If |animate| is ANIMATE_YES,
34 // the button crossfades to the new visuals. If the image ids match those
35 // currently used by the button and |animate| is ANIMATE_NO the crossfade
36 // animation is progressed to the end.
37 void SetImages(CaptionButtonIcon icon,
38 Animate animate,
39 int icon_image_id,
40 int hovered_background_image_id,
41 int pressed_background_image_id);
42
43 // Returns true if the button is crossfading to new visuals set in
44 // SetImages().
45 bool IsAnimatingImageSwap() const;
46
47 // Sets the alpha to use for painting. Used to animate visibility changes.
48 void SetAlpha(int alpha);
49
50 // views::View overrides:
51 gfx::Size GetPreferredSize() const override;
52 const char* GetClassName() const override;
53 void OnPaint(gfx::Canvas* canvas) override;
54
55 void set_paint_as_active(bool paint_as_active) {
56 paint_as_active_ = paint_as_active;
57 }
58
59 CaptionButtonIcon icon() const { return icon_; }
60
61 int icon_image_id() const { return icon_image_id_; }
62
63 protected:
64 // views::CustomButton override:
65 void OnGestureEvent(ui::GestureEvent* event) override;
66
67 private:
68 // Paints |to_center| centered within the button with |alpha|.
69 void PaintCentered(gfx::Canvas* canvas,
70 const gfx::ImageSkia& to_center,
71 int alpha);
72
73 // The button's current icon.
74 CaptionButtonIcon icon_;
75
76 // Whether the button should be painted as active.
77 bool paint_as_active_;
78
79 // Current alpha to use for painting.
80 int alpha_;
81
82 // The images and image ids used to paint the button.
83 int icon_image_id_;
84 int hovered_background_image_id_;
85 int pressed_background_image_id_;
86 gfx::ImageSkia icon_image_;
87 gfx::ImageSkia hovered_background_image_;
88 gfx::ImageSkia pressed_background_image_;
89
90 // The icon image to crossfade from.
91 gfx::ImageSkia crossfade_icon_image_;
92
93 // Crossfade animation started when the button's images are changed by
94 // SetImages().
95 std::unique_ptr<gfx::SlideAnimation> swap_images_animation_;
96
97 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButton);
98 };
99
100 } // namespace wm
101 } // namespace mash
102
103 #endif // MASH_WM_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_
OLDNEW
« no previous file with comments | « mash/wm/frame/caption_buttons/caption_button_types.h ('k') | mash/wm/frame/caption_buttons/frame_caption_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698