Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: chrome/browser/ui/views/sidebar/sidebar_base_tab.h

Issue 6250141: Sidebar mini tabs UI (views version).... Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 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.
4
5 #ifndef CHROME_BROWSER_UI_VIEWS_SIDEBAR_SIDEBAR_BASE_TAB_H_
6 #define CHROME_BROWSER_UI_VIEWS_SIDEBAR_SIDEBAR_BASE_TAB_H_
7 #pragma once
8
9 #include "base/compiler_specific.h"
10 #include "base/ref_counted.h"
11 #include "base/scoped_ptr.h"
12 #include "chrome/browser/ui/views/sidebar/sidebar_tab_renderer_data.h"
13 #include "ui/base/animation/animation_container.h"
14 #include "ui/base/animation/animation_delegate.h"
15 #include "views/view.h"
16
17 namespace ui {
18 class Animation;
19 class SlideAnimation;
20 class ThrobAnimation;
21 } // namespace ui
22
23 class SidebarTabController;
24
25 // Generic sidebar tab view. It caches all data necessary for tab rendering,
26 // handles painting and animation, receives user interaction events and forwards
27 // them to the controller.
28 // SidebarBaseTab does not make state transition and layout decisions,
29 // it should be done in the concrete child classes.
30 class SidebarBaseTab : public views::View,
31 private ui::AnimationDelegate {
32 public:
33 explicit SidebarBaseTab(SidebarTabController* controller);
34 virtual ~SidebarBaseTab();
35
36 // views::View overrides:
37 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
38 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
39 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
40 virtual bool GetTooltipText(const gfx::Point& p,
41 std::wstring* tooltip) OVERRIDE;
42 virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE;
43
44 // Sets the data this tabs displays. Invokes DataChanged for subclasses to
45 // update themselves appropriately.
46 void SetData(const SidebarTabRendererData& data);
47 const SidebarTabRendererData& data() const { return data_; }
48
49 // Sets the network state. Returns true if the network state was changed.
50 bool UpdateLoadingAnimation(SidebarTabRendererData::NetworkState state);
51
52 // Starts/Stops a pulse animation.
53 void StartPulse();
54 void StopPulse();
55
56 // Used to set/check whether this tab is being animated closed.
57 void set_closing(bool closing) { closing_ = closing; }
58 bool closing() const { return closing_; }
59
60 // Sets the container all animations run from.
61 void set_animation_container(ui::AnimationContainer* container) {
62 animation_container_ = container;
63 }
64 ui::AnimationContainer* animation_container() const {
65 return animation_container_.get();
66 }
67
68 // Returns true if the tab is selected.
69 bool IsSelected() const;
70 // Returns true if the sidebar is expanded.
71 bool IsExpanded() const;
72
73 // Returns the current shape of this tab.
74 virtual void GetShape(gfx::Path* shape) const = 0;
75
76 protected:
77 // Invoked from SetData after |data_| has been updated to the new data.
78 virtual void DataChanged(const SidebarTabRendererData& old) {}
79
80 // Invoked if data_.network_state changes, or the network_state is not none.
81 virtual void AdvanceLoadingAnimation(
82 SidebarTabRendererData::NetworkState old_state,
83 SidebarTabRendererData::NetworkState state);
84
85 // Gets the throb value for the tab. When a tab is not selected the
86 // active background is drawn at |GetThrobValue()|%. This is used for hover,
87 // tab title change and pulsing.
88 double GetThrobValue();
89
90 // Paints the icon at the specified coordinates.
91 void PaintIcon(gfx::Canvas* canvas, int x, int y, int alpha);
92
93 private:
94 // The animation object used to swap the icon with the sad tab icon.
95 class IconCrashAnimation;
96
97 // ui::AnimationDelegate overrides:
98 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
99 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE;
100 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
101
102 // Set the temporary offset for the icon. This is used during the crash
103 // animation.
104 void SetIconHidingOffset(int offset);
105
106 void DisplayCrashedIcon();
107 void ResetCrashedIcon();
108
109 // Starts/Stops the crash animation.
110 void StartCrashAnimation();
111 void StopCrashAnimation();
112
113 // The controller.
114 SidebarTabController* const controller_;
115
116 SidebarTabRendererData data_;
117
118 // True if the tab is being closed.
119 bool closing_;
120
121 scoped_refptr<ui::AnimationContainer> animation_container_;
122 scoped_ptr<ui::ThrobAnimation> pulse_animation_;
123 scoped_ptr<ui::SlideAnimation> hover_animation_;
124 scoped_ptr<IconCrashAnimation> crash_animation_;
125 // The offset used to animate the icon location.
126 // It's used when the corresponding sidebar's tab contents crashes.
127 int icon_hiding_offset_;
128 bool should_display_crashed_icon_;
129 // The current index of the loading animation.
130 int loading_animation_frame_;
131
132 DISALLOW_COPY_AND_ASSIGN(SidebarBaseTab);
133 };
134
135 #endif // CHROME_BROWSER_UI_VIEWS_SIDEBAR_SIDEBAR_BASE_TAB_H_
136
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698