blob: 9acb1fea90ee6b2efed8639364000b30cbaf8815 (
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
|
// Copyright (c) 2011 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_TOUCH_TABS_TOUCH_TAB_H_
#define CHROME_BROWSER_UI_TOUCH_TABS_TOUCH_TAB_H_
#pragma once
#include <string>
#include "base/scoped_ptr.h"
#include "chrome/browser/ui/views/tabs/base_tab.h"
#include "gfx/point.h"
///////////////////////////////////////////////////////////////////////////////
//
// TouchTab
//
// A View that renders a TouchTab in a TouchTabStrip
//
///////////////////////////////////////////////////////////////////////////////
class TouchTab : public BaseTab {
public:
// The menu button's class name.
static const char kViewClassName[];
explicit TouchTab(TabController* controller);
virtual ~TouchTab();
// Set the background offset used to match the image in the inactive tab
// to the frame image.
void set_background_offset(const gfx::Point& offset) {
background_offset_ = offset;
}
// Returns the minimum possible size of a single unselected Tab.
static gfx::Size GetMinimumUnselectedSize();
protected:
virtual const gfx::Rect& title_bounds() const { return title_bounds_; }
private:
// Overridden from views::View:
virtual void Paint(gfx::Canvas* canvas);
virtual void Layout();
virtual bool HasHitTestMask() const;
virtual void GetHitTestMask(gfx::Path* path) const;
// Paint various portions of the Tab
void PaintTabBackground(gfx::Canvas* canvas);
void PaintIcon(gfx::Canvas* canvas);
void PaintActiveTabBackground(gfx::Canvas* canvas);
// TODO(wyck): will eventually add OnTouchEvent when the Touch Tab Strip
// requires touch-specific event handling.
// Performs a one-time initialization of static resources such as tab images.
static void InitTabResources();
// Loads the images to be used for the tab background.
static void LoadTabImages();
// the bounds of the title text
gfx::Rect title_bounds_;
// the bounds of the favicon
gfx::Rect favicon_bounds_;
// The offset used to paint the inactive background image.
gfx::Point background_offset_;
// 'l' is for left
// 'c' is for center
// 'r' is for right
struct TouchTabImage {
SkBitmap* image_l;
SkBitmap* image_c;
SkBitmap* image_r;
int l_width;
int r_width;
int y_offset;
};
static TouchTabImage tab_active;
static TouchTabImage tab_inactive;
static TouchTabImage tab_alpha;
DISALLOW_COPY_AND_ASSIGN(TouchTab);
};
#endif // CHROME_BROWSER_UI_TOUCH_TABS_TOUCH_TAB_H_
|