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 CHROME_BROWSER_UI_TOUCH_TABS_TOUCH_TAB_H_ | 5 #ifndef CHROME_BROWSER_UI_TOUCH_TABS_TOUCH_TAB_H_ |
6 #define CHROME_BROWSER_UI_TOUCH_TABS_TOUCH_TAB_H_ | 6 #define CHROME_BROWSER_UI_TOUCH_TABS_TOUCH_TAB_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "chrome/browser/ui/views/tabs/base_tab.h" | 12 #include "chrome/browser/ui/views/tabs/base_tab.h" |
13 #include "ui/gfx/point.h" | 13 #include "ui/gfx/point.h" |
14 | 14 |
15 /////////////////////////////////////////////////////////////////////////////// | 15 /////////////////////////////////////////////////////////////////////////////// |
16 // | 16 // |
17 // TouchTab | 17 // TouchTab |
18 // | 18 // |
19 // A View that renders a TouchTab in a TouchTabStrip | 19 // A View that renders a TouchTab in a TouchTabStrip |
20 // | 20 // |
21 // TODO(wyck): Use transformable views for scrolling. | 21 // TODO(wyck): Use transformable views for scrolling. |
22 /////////////////////////////////////////////////////////////////////////////// | 22 /////////////////////////////////////////////////////////////////////////////// |
23 class TouchTab : public BaseTab { | 23 class TouchTab : public BaseTab { |
24 public: | 24 public: |
25 // The menu button's class name. | 25 // The menu button's class name. |
26 static const char kViewClassName[]; | 26 static const char kViewClassName[]; |
27 | 27 |
| 28 // The size of the favicon touch area. |
| 29 static const int kTouchTargetIconSize = 32; |
| 30 |
28 explicit TouchTab(TabController* controller); | 31 explicit TouchTab(TabController* controller); |
29 virtual ~TouchTab(); | 32 virtual ~TouchTab(); |
30 | 33 |
31 // Set the background offset used to match the image in the inactive tab | 34 // Set the background offset used to match the image in the inactive tab |
32 // to the frame image. | 35 // to the frame image. |
33 void set_background_offset(const gfx::Point& offset) { | 36 void set_background_offset(const gfx::Point& offset) { |
34 background_offset_ = offset; | 37 background_offset_ = offset; |
35 } | 38 } |
36 | 39 |
| 40 // get and set touch icon |
| 41 void set_touch_icon(const SkBitmap& bitmap) { |
| 42 touch_icon_ = bitmap; |
| 43 } |
| 44 const SkBitmap& touch_icon() const { |
| 45 return touch_icon_; |
| 46 } |
| 47 |
37 // Returns the minimum possible size of a single unselected Tab. | 48 // Returns the minimum possible size of a single unselected Tab. |
38 static gfx::Size GetMinimumUnselectedSize(); | 49 static gfx::Size GetMinimumUnselectedSize(); |
39 | 50 |
40 protected: | 51 protected: |
41 virtual const gfx::Rect& GetTitleBounds() const; | 52 virtual const gfx::Rect& GetTitleBounds() const; |
42 virtual const gfx::Rect& GetIconBounds() const; | 53 virtual const gfx::Rect& GetIconBounds() const; |
43 | 54 |
44 private: | 55 private: |
45 // Overridden from views::View: | 56 // Overridden from views::View: |
46 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; | 57 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; |
(...skipping 20 matching lines...) Expand all Loading... |
67 | 78 |
68 // the bounds of the title text | 79 // the bounds of the title text |
69 gfx::Rect title_bounds_; | 80 gfx::Rect title_bounds_; |
70 | 81 |
71 // the bounds of the favicon | 82 // the bounds of the favicon |
72 gfx::Rect favicon_bounds_; | 83 gfx::Rect favicon_bounds_; |
73 | 84 |
74 // The offset used to paint the inactive background image. | 85 // The offset used to paint the inactive background image. |
75 gfx::Point background_offset_; | 86 gfx::Point background_offset_; |
76 | 87 |
| 88 // The touch icon found |
| 89 SkBitmap touch_icon_; |
| 90 |
77 // 'l' is for left | 91 // 'l' is for left |
78 // 'c' is for center | 92 // 'c' is for center |
79 // 'r' is for right | 93 // 'r' is for right |
80 struct TouchTabImage { | 94 struct TouchTabImage { |
81 SkBitmap* image_l; | 95 SkBitmap* image_l; |
82 SkBitmap* image_c; | 96 SkBitmap* image_c; |
83 SkBitmap* image_r; | 97 SkBitmap* image_r; |
84 int l_width; | 98 int l_width; |
85 int r_width; | 99 int r_width; |
86 int y_offset; | 100 int y_offset; |
87 }; | 101 }; |
88 static TouchTabImage tab_active; | 102 static TouchTabImage tab_active; |
89 static TouchTabImage tab_inactive; | 103 static TouchTabImage tab_inactive; |
90 static TouchTabImage tab_alpha; | 104 static TouchTabImage tab_alpha; |
91 | 105 |
92 DISALLOW_COPY_AND_ASSIGN(TouchTab); | 106 DISALLOW_COPY_AND_ASSIGN(TouchTab); |
93 }; | 107 }; |
94 | 108 |
95 #endif // CHROME_BROWSER_UI_TOUCH_TABS_TOUCH_TAB_H_ | 109 #endif // CHROME_BROWSER_UI_TOUCH_TABS_TOUCH_TAB_H_ |
OLD | NEW |