[email protected] | b6901f6 | 2012-01-13 19:14:53 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 2fcd9d2 | 2011-10-14 03:44:34 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 7634f96 | 2011-12-23 21:35:52 | [diff] [blame] | 5 | #ifndef ASH_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_ |
6 | #define ASH_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_ | ||||
[email protected] | 2fcd9d2 | 2011-10-14 03:44:34 | [diff] [blame] | 7 | #pragma once |
8 | |||||
[email protected] | a39a60e | 2012-03-10 00:40:06 | [diff] [blame] | 9 | #include "ash/launcher/launcher_button.h" |
[email protected] | 08028746 | 2011-12-16 18:52:17 | [diff] [blame] | 10 | #include "base/memory/scoped_ptr.h" |
11 | #include "base/timer.h" | ||||
[email protected] | 08028746 | 2011-12-16 18:52:17 | [diff] [blame] | 12 | #include "ui/base/animation/animation_delegate.h" |
[email protected] | a3469db4 | 2011-12-14 22:15:16 | [diff] [blame] | 13 | #include "ui/views/controls/button/image_button.h" |
[email protected] | 0c893bc | 2011-12-16 23:49:23 | [diff] [blame] | 14 | #include "ui/views/controls/glow_hover_controller.h" |
[email protected] | 2fcd9d2 | 2011-10-14 03:44:34 | [diff] [blame] | 15 | |
[email protected] | 08028746 | 2011-12-16 18:52:17 | [diff] [blame] | 16 | namespace ui { |
17 | class MultiAnimation; | ||||
18 | } | ||||
19 | |||||
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 20 | namespace ash { |
[email protected] | b5828c7 | 2012-03-14 04:14:57 | [diff] [blame] | 21 | |
22 | struct LauncherItem; | ||||
23 | |||||
[email protected] | 2fcd9d2 | 2011-10-14 03:44:34 | [diff] [blame] | 24 | namespace internal { |
25 | |||||
26 | // Button used for items on the launcher corresponding to tabbed windows. | ||||
[email protected] | a39a60e | 2012-03-10 00:40:06 | [diff] [blame] | 27 | class TabbedLauncherButton : public LauncherButton { |
[email protected] | 2fcd9d2 | 2011-10-14 03:44:34 | [diff] [blame] | 28 | public: |
[email protected] | b5828c7 | 2012-03-14 04:14:57 | [diff] [blame] | 29 | // Indicates if this button is incognito or not. |
30 | enum IncognitoState { | ||||
31 | STATE_INCOGNITO, | ||||
32 | STATE_NOT_INCOGNITO, | ||||
33 | }; | ||||
34 | |||||
[email protected] | a39a60e | 2012-03-10 00:40:06 | [diff] [blame] | 35 | static TabbedLauncherButton* Create(views::ButtonListener* listener, |
[email protected] | b5828c7 | 2012-03-14 04:14:57 | [diff] [blame] | 36 | LauncherButtonHost* host, |
37 | IncognitoState is_incognito); | ||||
[email protected] | 2fcd9d2 | 2011-10-14 03:44:34 | [diff] [blame] | 38 | virtual ~TabbedLauncherButton(); |
39 | |||||
40 | // Sets the images to display for this entry. | ||||
[email protected] | a39a60e | 2012-03-10 00:40:06 | [diff] [blame] | 41 | void SetTabImage(const SkBitmap& image); |
[email protected] | 2fcd9d2 | 2011-10-14 03:44:34 | [diff] [blame] | 42 | |
[email protected] | ec2b3c5 | 2012-04-19 02:40:44 | [diff] [blame] | 43 | // This only defines how the icon is drawn. Do not use it for other purposes. |
[email protected] | 734b1d1 | 2012-03-20 01:23:20 | [diff] [blame] | 44 | IncognitoState is_incognito() const { return is_incognito_; } |
45 | |||||
[email protected] | 2fcd9d2 | 2011-10-14 03:44:34 | [diff] [blame] | 46 | protected: |
[email protected] | a39a60e | 2012-03-10 00:40:06 | [diff] [blame] | 47 | TabbedLauncherButton(views::ButtonListener* listener, |
[email protected] | b5828c7 | 2012-03-14 04:14:57 | [diff] [blame] | 48 | LauncherButtonHost* host, |
49 | IncognitoState is_incognito); | ||||
[email protected] | a39a60e | 2012-03-10 00:40:06 | [diff] [blame] | 50 | // View override. |
[email protected] | 2b1fbb9d | 2012-02-08 07:30:51 | [diff] [blame] | 51 | virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
[email protected] | 2fcd9d2 | 2011-10-14 03:44:34 | [diff] [blame] | 52 | |
[email protected] | a39a60e | 2012-03-10 00:40:06 | [diff] [blame] | 53 | // LauncherButton override. |
54 | virtual IconView* CreateIconView() OVERRIDE; | ||||
55 | |||||
[email protected] | 2fcd9d2 | 2011-10-14 03:44:34 | [diff] [blame] | 56 | private: |
[email protected] | a39a60e | 2012-03-10 00:40:06 | [diff] [blame] | 57 | // Used as the delegate for |animation_|. |
58 | class IconView : public LauncherButton::IconView, | ||||
59 | public ui::AnimationDelegate { | ||||
[email protected] | 08028746 | 2011-12-16 18:52:17 | [diff] [blame] | 60 | public: |
[email protected] | 734b1d1 | 2012-03-20 01:23:20 | [diff] [blame] | 61 | explicit IconView(TabbedLauncherButton* host); |
[email protected] | a39a60e | 2012-03-10 00:40:06 | [diff] [blame] | 62 | virtual ~IconView(); |
[email protected] | 08028746 | 2011-12-16 18:52:17 | [diff] [blame] | 63 | |
64 | // ui::AnimationDelegateImpl overrides: | ||||
65 | virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | ||||
66 | virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | ||||
67 | |||||
[email protected] | a39a60e | 2012-03-10 00:40:06 | [diff] [blame] | 68 | // Sets the image to display for this entry. |
69 | void SetTabImage(const SkBitmap& image); | ||||
70 | |||||
71 | protected: | ||||
72 | // View override. | ||||
73 | virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | ||||
74 | |||||
[email protected] | 08028746 | 2011-12-16 18:52:17 | [diff] [blame] | 75 | private: |
76 | TabbedLauncherButton* host_; | ||||
[email protected] | a39a60e | 2012-03-10 00:40:06 | [diff] [blame] | 77 | SkBitmap image_; |
[email protected] | b6a46898 | 2012-05-05 19:37:06 | [diff] [blame] | 78 | SkBitmap animating_image_; |
[email protected] | 08028746 | 2011-12-16 18:52:17 | [diff] [blame] | 79 | |
[email protected] | a39a60e | 2012-03-10 00:40:06 | [diff] [blame] | 80 | // Used to animate image. |
81 | scoped_ptr<ui::MultiAnimation> animation_; | ||||
82 | |||||
[email protected] | a39a60e | 2012-03-10 00:40:06 | [diff] [blame] | 83 | // Background images. Which one is chosen depends on the type of the window. |
84 | static SkBitmap* browser_image_; | ||||
[email protected] | b5828c7 | 2012-03-14 04:14:57 | [diff] [blame] | 85 | static SkBitmap* incognito_browser_image_; |
[email protected] | a39a60e | 2012-03-10 00:40:06 | [diff] [blame] | 86 | // TODO[dave] implement panel specific image. |
87 | static SkBitmap* browser_panel_image_; | ||||
[email protected] | b5828c7 | 2012-03-14 04:14:57 | [diff] [blame] | 88 | static SkBitmap* incognito_browser_panel_image_; |
[email protected] | a39a60e | 2012-03-10 00:40:06 | [diff] [blame] | 89 | |
90 | DISALLOW_COPY_AND_ASSIGN(IconView); | ||||
[email protected] | 08028746 | 2011-12-16 18:52:17 | [diff] [blame] | 91 | }; |
92 | |||||
[email protected] | a39a60e | 2012-03-10 00:40:06 | [diff] [blame] | 93 | IconView* tabbed_icon_view() { |
94 | return static_cast<IconView*>(icon_view()); | ||||
95 | } | ||||
[email protected] | 0c893bc | 2011-12-16 23:49:23 | [diff] [blame] | 96 | |
[email protected] | ec2b3c5 | 2012-04-19 02:40:44 | [diff] [blame] | 97 | // Indicates how the icon is drawn. If true an Incognito symbol will be |
98 | // drawn. It does not necessarily indicate if the window is 'incognito'. | ||||
[email protected] | b5828c7 | 2012-03-14 04:14:57 | [diff] [blame] | 99 | const IncognitoState is_incognito_; |
100 | |||||
[email protected] | 2fcd9d2 | 2011-10-14 03:44:34 | [diff] [blame] | 101 | DISALLOW_COPY_AND_ASSIGN(TabbedLauncherButton); |
102 | }; | ||||
103 | |||||
104 | } // namespace internal | ||||
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 105 | } // namespace ash |
[email protected] | 2fcd9d2 | 2011-10-14 03:44:34 | [diff] [blame] | 106 | |
[email protected] | 7634f96 | 2011-12-23 21:35:52 | [diff] [blame] | 107 | #endif // ASH_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_ |