OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_AURA_SHELL_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_ | 5 #ifndef UI_AURA_SHELL_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_ |
6 #define UI_AURA_SHELL_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_ | 6 #define UI_AURA_SHELL_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ui/aura_shell/launcher/launcher_types.h" | 9 #include "ui/aura_shell/launcher/launcher_types.h" |
10 #include "ui/views/controls/button/custom_button.h" | 10 #include "ui/views/controls/button/image_button.h" |
11 | 11 |
12 namespace aura_shell { | 12 namespace aura_shell { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 class LauncherButtonHost; | 15 class LauncherButtonHost; |
16 | 16 |
17 // Button used for items on the launcher corresponding to tabbed windows. | 17 // Button used for items on the launcher corresponding to tabbed windows. |
18 class TabbedLauncherButton : public views::CustomButton { | 18 class TabbedLauncherButton : public views::ImageButton { |
19 public: | 19 public: |
20 TabbedLauncherButton(views::ButtonListener* listener, | 20 TabbedLauncherButton(views::ButtonListener* listener, |
21 LauncherButtonHost* host); | 21 LauncherButtonHost* host); |
22 virtual ~TabbedLauncherButton(); | 22 virtual ~TabbedLauncherButton(); |
23 | 23 |
24 // Sets the images to display for this entry. | 24 // Sets the images to display for this entry. |
25 void SetImages(const LauncherTabbedImages& images); | 25 void SetImages(const LauncherTabbedImages& images); |
26 | 26 |
27 // View overrides: | |
28 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
29 | |
30 protected: | 27 protected: |
31 // View overrides: | 28 // View overrides: |
32 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 29 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
33 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; | 30 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; |
34 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; | 31 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; |
35 virtual void OnMouseCaptureLost() OVERRIDE; | 32 virtual void OnMouseCaptureLost() OVERRIDE; |
36 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; | 33 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; |
37 | 34 |
38 private: | 35 private: |
| 36 struct ImageSet { |
| 37 SkBitmap* normal_image; |
| 38 SkBitmap* pushed_image; |
| 39 SkBitmap* hot_image; |
| 40 }; |
| 41 |
| 42 // Creates an ImageSet using the specified image ids. Caller owns the returned |
| 43 // value. |
| 44 static ImageSet* CreateImageSet(int normal_id, int pushed_id, int hot_id); |
| 45 |
39 LauncherTabbedImages images_; | 46 LauncherTabbedImages images_; |
40 | 47 |
41 LauncherButtonHost* host_; | 48 LauncherButtonHost* host_; |
42 | 49 |
43 // Background images. Which one is chosen depends upon how many images are | 50 // Background images. Which one is chosen depends upon how many images are |
44 // provided. | 51 // provided. |
45 static SkBitmap* bg_image_1_; | 52 static ImageSet* bg_image_1_; |
46 static SkBitmap* bg_image_2_; | 53 static ImageSet* bg_image_2_; |
47 static SkBitmap* bg_image_3_; | 54 static ImageSet* bg_image_3_; |
48 | 55 |
49 DISALLOW_COPY_AND_ASSIGN(TabbedLauncherButton); | 56 DISALLOW_COPY_AND_ASSIGN(TabbedLauncherButton); |
50 }; | 57 }; |
51 | 58 |
52 } // namespace internal | 59 } // namespace internal |
53 } // namespace aura_shell | 60 } // namespace aura_shell |
54 | 61 |
55 #endif // UI_AURA_SHELL_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_ | 62 #endif // UI_AURA_SHELL_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_ |
OLD | NEW |