blob: 1394e4ba668f4271940fe3f96d426219107ec45c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_
#define CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_
#pragma once
#include <string>
#include "base/scoped_ptr.h"
#include "chrome/browser/views/tabs/base_tab.h"
#include "gfx/point.h"
class MultiAnimation;
class SlideAnimation;
///////////////////////////////////////////////////////////////////////////////
//
// TabRenderer
//
// A View that renders a Tab, either in a TabStrip or in a DraggedTabView.
//
///////////////////////////////////////////////////////////////////////////////
class Tab : public BaseTab {
public:
// The menu button's class name.
static const char kViewClassName[];
explicit Tab(TabController* controller);
virtual ~Tab();
// Start/stop the mini-tab title animation.
void StartMiniTabTitleAnimation();
void StopMiniTabTitleAnimation();
// Set the background offset used to match the image in the inactive tab
// to the frame image.
void SetBackgroundOffset(const gfx::Point& offset) {
background_offset_ = offset;
}
// Paints the icon. Most of the time you'll want to invoke Paint directly, but
// in certain situations this invoked outside of Paint.
void PaintIcon(gfx::Canvas* canvas);
// Returns the minimum possible size of a single unselected Tab.
static gfx::Size GetMinimumUnselectedSize();
// Returns the minimum possible size of a selected Tab. Selected tabs must
// always show a close button and have a larger minimum size than unselected
// tabs.
static gfx::Size GetMinimumSelectedSize();
// Returns the preferred size of a single Tab, assuming space is
// available.
static gfx::Size GetStandardSize();
// Returns the width for mini-tabs. Mini-tabs always have this width.
static int GetMiniWidth();
// Loads the images to be used for the tab background.
static void LoadTabImages();
protected:
virtual const gfx::Rect& title_bounds() const { return title_bounds_; }
// BaseTab overrides:
virtual void DataChanged(const TabRendererData& old);
private:
// Overridden from views::View:
virtual void Paint(gfx::Canvas* canvas);
virtual void Layout();
virtual void OnThemeChanged();
virtual std::string GetClassName() const { return kViewClassName; }
virtual bool HasHitTestMask() const;
virtual void GetHitTestMask(gfx::Path* path) const;
virtual bool GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* origin);
// Paint various portions of the Tab
void PaintTabBackground(gfx::Canvas* canvas);
void PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas);
void PaintInactiveTabBackground(gfx::Canvas* canvas);
void PaintActiveTabBackground(gfx::Canvas* canvas);
// Returns the number of favicon-size elements that can fit in the tab's
// current size.
int IconCapacity() const;
// Returns whether the Tab should display a favicon.
bool ShouldShowIcon() const;
// Returns whether the Tab should display a close button.
bool ShouldShowCloseBox() const;
// Gets the throb value for the tab. When a tab is not selected the
// active background is drawn at |GetThrobValue()|%. This is used for hover,
// mini tab title change and pulsing.
double GetThrobValue();
// The bounds of various sections of the display.
gfx::Rect favicon_bounds_;
gfx::Rect title_bounds_;
// The offset used to paint the inactive background image.
gfx::Point background_offset_;
// Hover animation.
scoped_ptr<SlideAnimation> hover_animation_;
// Animation used when the title of an inactive mini tab changes.
scoped_ptr<MultiAnimation> mini_title_animation_;
struct TabImage {
SkBitmap* image_l;
SkBitmap* image_c;
SkBitmap* image_r;
int l_width;
int r_width;
int y_offset;
};
static TabImage tab_active;
static TabImage tab_inactive;
static TabImage tab_alpha;
// Whether we're showing the icon. It is cached so that we can detect when it
// changes and layout appropriately.
bool showing_icon_;
// Whether we are showing the close button. It is cached so that we can
// detect when it changes and layout appropriately.
bool showing_close_button_;
// The current color of the close button.
SkColor close_button_color_;
static bool initialized_;
DISALLOW_COPY_AND_ASSIGN(Tab);
};
#endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_
|