Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / ash / frame / caption_buttons / frame_caption_button.h
bloba54461d4eaad90f742b24c7b8091eee4fc378adb
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.
5 #ifndef ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_
6 #define ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_
8 #include "ash/ash_export.h"
9 #include "ash/frame/caption_buttons/caption_button_types.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/gfx/image/image_skia.h"
12 #include "ui/views/controls/button/custom_button.h"
14 namespace gfx {
15 class SlideAnimation;
18 namespace ash {
20 // Base class for the window caption buttons (minimize, maximize, restore,
21 // close).
22 class ASH_EXPORT FrameCaptionButton : public views::CustomButton {
23 public:
24 enum Animate {
25 ANIMATE_YES,
26 ANIMATE_NO
29 static const char kViewClassName[];
31 FrameCaptionButton(views::ButtonListener* listener, CaptionButtonIcon icon);
32 ~FrameCaptionButton() override;
34 // Sets the images 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
36 // currently used by the button and |animate| is ANIMATE_NO the crossfade
37 // animation is progressed to the end.
38 void SetImages(CaptionButtonIcon icon,
39 Animate animate,
40 int icon_image_id,
41 int hovered_background_image_id,
42 int pressed_background_image_id);
44 // Returns true if the button is crossfading to new visuals set in
45 // SetImages().
46 bool IsAnimatingImageSwap() const;
48 // Sets the alpha to use for painting. Used to animate visibility changes.
49 void SetAlpha(int alpha);
51 // views::View overrides:
52 gfx::Size GetPreferredSize() const override;
53 const char* GetClassName() const override;
54 void OnPaint(gfx::Canvas* canvas) override;
56 void set_paint_as_active(bool paint_as_active) {
57 paint_as_active_ = paint_as_active;
60 CaptionButtonIcon icon() const {
61 return icon_;
64 int icon_image_id() const { return icon_image_id_; }
66 protected:
67 // views::CustomButton override:
68 void OnGestureEvent(ui::GestureEvent* event) override;
70 private:
71 // Paints |to_center| centered within the button with |alpha|.
72 void PaintCentered(gfx::Canvas* canvas,
73 const gfx::ImageSkia& to_center,
74 int alpha);
76 // The button's current icon.
77 CaptionButtonIcon icon_;
79 // Whether the button should be painted as active.
80 bool paint_as_active_;
82 // Current alpha to use for painting.
83 int alpha_;
85 // The images and image ids used to paint the button.
86 int icon_image_id_;
87 int hovered_background_image_id_;
88 int pressed_background_image_id_;
89 gfx::ImageSkia icon_image_;
90 gfx::ImageSkia hovered_background_image_;
91 gfx::ImageSkia pressed_background_image_;
93 // The icon image to crossfade from.
94 gfx::ImageSkia crossfade_icon_image_;
96 // Crossfade animation started when the button's images are changed by
97 // SetImages().
98 scoped_ptr<gfx::SlideAnimation> swap_images_animation_;
100 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButton);
103 } // namespace ash
105 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_