usb_gadget: Switch to official Google product IDs.
[chromium-blink-merge.git] / ash / frame / caption_buttons / frame_caption_button.h
bloba348e301f19dd92d9db8a1803471c833e7ca3f46
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 virtual ~FrameCaptionButton();
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 inactive_icon_image_id,
42 int hovered_background_image_id,
43 int pressed_background_image_id);
45 // Returns true if the button is crossfading to new visuals set in
46 // SetImages().
47 bool IsAnimatingImageSwap() const;
49 // Sets the alpha to use for painting. Used to animate visibility changes.
50 void SetAlpha(int alpha);
52 // views::View overrides:
53 virtual gfx::Size GetPreferredSize() const OVERRIDE;
54 virtual const char* GetClassName() const OVERRIDE;
55 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
57 void set_paint_as_active(bool paint_as_active) {
58 paint_as_active_ = paint_as_active;
61 CaptionButtonIcon icon() const {
62 return icon_;
65 protected:
66 // views::CustomButton override:
67 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
69 private:
70 // Returns the icon image to paint based on |paint_as_active_|.
71 const gfx::ImageSkia& GetIconImageToPaint() const;
73 // Paints |to_center| centered within the button with |alpha|.
74 void PaintCentered(gfx::Canvas* canvas,
75 const gfx::ImageSkia& to_center,
76 int alpha);
78 // The button's current icon.
79 CaptionButtonIcon icon_;
81 // Whether the button should be painted as active.
82 bool paint_as_active_;
84 // Current alpha to use for painting.
85 int alpha_;
87 // The images and image ids used to paint the button.
88 int icon_image_id_;
89 int inactive_icon_image_id_;
90 int hovered_background_image_id_;
91 int pressed_background_image_id_;
92 gfx::ImageSkia icon_image_;
93 gfx::ImageSkia inactive_icon_image_;
94 gfx::ImageSkia hovered_background_image_;
95 gfx::ImageSkia pressed_background_image_;
97 // The icon image to crossfade from.
98 gfx::ImageSkia crossfade_icon_image_;
100 // Crossfade animation started when the button's images are changed by
101 // SetImages().
102 scoped_ptr<gfx::SlideAnimation> swap_images_animation_;
104 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButton);
107 } // namespace ash
109 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_