blob: ac9fbcd064da663b304ffb5ee0ddf0e32e7553e7 [file] [log] [blame]
[email protected]b6901f62012-01-13 19:14:531// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]2fcd9d22011-10-14 03:44:342// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]7634f962011-12-23 21:35:525#ifndef ASH_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_
6#define ASH_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_
[email protected]2fcd9d22011-10-14 03:44:347#pragma once
8
[email protected]a39a60e2012-03-10 00:40:069#include "ash/launcher/launcher_button.h"
[email protected]080287462011-12-16 18:52:1710#include "base/memory/scoped_ptr.h"
11#include "base/timer.h"
[email protected]080287462011-12-16 18:52:1712#include "ui/base/animation/animation_delegate.h"
[email protected]a3469db42011-12-14 22:15:1613#include "ui/views/controls/button/image_button.h"
[email protected]0c893bc2011-12-16 23:49:2314#include "ui/views/controls/glow_hover_controller.h"
[email protected]2fcd9d22011-10-14 03:44:3415
[email protected]080287462011-12-16 18:52:1716namespace ui {
17class MultiAnimation;
18}
19
[email protected]55f593352011-12-24 05:42:4620namespace ash {
[email protected]b5828c72012-03-14 04:14:5721
22struct LauncherItem;
23
[email protected]2fcd9d22011-10-14 03:44:3424namespace internal {
25
26// Button used for items on the launcher corresponding to tabbed windows.
[email protected]a39a60e2012-03-10 00:40:0627class TabbedLauncherButton : public LauncherButton {
[email protected]2fcd9d22011-10-14 03:44:3428 public:
[email protected]b5828c72012-03-14 04:14:5729 // Indicates if this button is incognito or not.
30 enum IncognitoState {
31 STATE_INCOGNITO,
32 STATE_NOT_INCOGNITO,
33 };
34
[email protected]a39a60e2012-03-10 00:40:0635 static TabbedLauncherButton* Create(views::ButtonListener* listener,
[email protected]b5828c72012-03-14 04:14:5736 LauncherButtonHost* host,
37 IncognitoState is_incognito);
[email protected]2fcd9d22011-10-14 03:44:3438 virtual ~TabbedLauncherButton();
39
40 // Sets the images to display for this entry.
[email protected]a39a60e2012-03-10 00:40:0641 void SetTabImage(const SkBitmap& image);
[email protected]2fcd9d22011-10-14 03:44:3442
[email protected]ec2b3c52012-04-19 02:40:4443 // This only defines how the icon is drawn. Do not use it for other purposes.
[email protected]734b1d12012-03-20 01:23:2044 IncognitoState is_incognito() const { return is_incognito_; }
45
[email protected]2fcd9d22011-10-14 03:44:3446 protected:
[email protected]a39a60e2012-03-10 00:40:0647 TabbedLauncherButton(views::ButtonListener* listener,
[email protected]b5828c72012-03-14 04:14:5748 LauncherButtonHost* host,
49 IncognitoState is_incognito);
[email protected]a39a60e2012-03-10 00:40:0650 // View override.
[email protected]2b1fbb9d2012-02-08 07:30:5151 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
[email protected]2fcd9d22011-10-14 03:44:3452
[email protected]a39a60e2012-03-10 00:40:0653 // LauncherButton override.
54 virtual IconView* CreateIconView() OVERRIDE;
55
[email protected]2fcd9d22011-10-14 03:44:3456 private:
[email protected]a39a60e2012-03-10 00:40:0657 // Used as the delegate for |animation_|.
58 class IconView : public LauncherButton::IconView,
59 public ui::AnimationDelegate {
[email protected]080287462011-12-16 18:52:1760 public:
[email protected]734b1d12012-03-20 01:23:2061 explicit IconView(TabbedLauncherButton* host);
[email protected]a39a60e2012-03-10 00:40:0662 virtual ~IconView();
[email protected]080287462011-12-16 18:52:1763
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]a39a60e2012-03-10 00:40:0668 // 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]080287462011-12-16 18:52:1775 private:
76 TabbedLauncherButton* host_;
[email protected]a39a60e2012-03-10 00:40:0677 SkBitmap image_;
[email protected]b6a468982012-05-05 19:37:0678 SkBitmap animating_image_;
[email protected]080287462011-12-16 18:52:1779
[email protected]a39a60e2012-03-10 00:40:0680 // Used to animate image.
81 scoped_ptr<ui::MultiAnimation> animation_;
82
[email protected]a39a60e2012-03-10 00:40:0683 // Background images. Which one is chosen depends on the type of the window.
84 static SkBitmap* browser_image_;
[email protected]b5828c72012-03-14 04:14:5785 static SkBitmap* incognito_browser_image_;
[email protected]a39a60e2012-03-10 00:40:0686 // TODO[dave] implement panel specific image.
87 static SkBitmap* browser_panel_image_;
[email protected]b5828c72012-03-14 04:14:5788 static SkBitmap* incognito_browser_panel_image_;
[email protected]a39a60e2012-03-10 00:40:0689
90 DISALLOW_COPY_AND_ASSIGN(IconView);
[email protected]080287462011-12-16 18:52:1791 };
92
[email protected]a39a60e2012-03-10 00:40:0693 IconView* tabbed_icon_view() {
94 return static_cast<IconView*>(icon_view());
95 }
[email protected]0c893bc2011-12-16 23:49:2396
[email protected]ec2b3c52012-04-19 02:40:4497 // 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]b5828c72012-03-14 04:14:5799 const IncognitoState is_incognito_;
100
[email protected]2fcd9d22011-10-14 03:44:34101 DISALLOW_COPY_AND_ASSIGN(TabbedLauncherButton);
102};
103
104} // namespace internal
[email protected]55f593352011-12-24 05:42:46105} // namespace ash
[email protected]2fcd9d22011-10-14 03:44:34106
[email protected]7634f962011-12-23 21:35:52107#endif // ASH_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_