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 #include "chrome/browser/ui/views/tabs/side_tab_strip.h" | 5 #include "chrome/browser/ui/views/tabs/side_tab_strip.h" |
6 | 6 |
7 #include "chrome/browser/ui/view_ids.h" | 7 #include "chrome/browser/ui/view_ids.h" |
8 #include "chrome/browser/ui/views/tabs/side_tab.h" | 8 #include "chrome/browser/ui/views/tabs/side_tab.h" |
9 #include "chrome/browser/ui/views/tabs/tab_strip_controller.h" | 9 #include "chrome/browser/ui/views/tabs/tab_strip_controller.h" |
10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 const SkColor kSeparatorColor = SkColorSetARGB(255, 151, 159, 179); | 22 const SkColor kSeparatorColor = SkColorSetARGB(255, 151, 159, 179); |
23 | 23 |
24 // Height of the separator. | 24 // Height of the separator. |
25 const int kSeparatorHeight = 1; | 25 const int kSeparatorHeight = 1; |
26 | 26 |
27 // The new tab button is rendered using a SideTab. | 27 // The new tab button is rendered using a SideTab. |
28 class SideTabNewTabButton : public SideTab { | 28 class SideTabNewTabButton : public SideTab { |
29 public: | 29 public: |
30 explicit SideTabNewTabButton(TabStripController* controller); | 30 explicit SideTabNewTabButton(TabStripController* controller); |
31 | 31 |
32 virtual bool ShouldPaintHighlight() const { return false; } | 32 virtual bool ShouldPaintHighlight() const OVERRIDE { return false; } |
33 virtual bool IsSelected() const { return false; } | 33 virtual bool IsSelected() const OVERRIDE { return false; } |
34 bool OnMousePressed(const views::MouseEvent& event); | 34 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; |
35 void OnMouseReleased(const views::MouseEvent& event, bool canceled); | 35 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; |
36 // TODO(msw): Remove? Overrides BaseTab::OnMouseCaptureLost() with no-op. | |
msw
2011/03/17 23:28:51
Need guidance / testing / investigation.
| |
37 virtual void OnMouseCaptureLost() OVERRIDE {} | |
36 | 38 |
37 private: | 39 private: |
38 TabStripController* controller_; | 40 TabStripController* controller_; |
39 | 41 |
40 DISALLOW_COPY_AND_ASSIGN(SideTabNewTabButton); | 42 DISALLOW_COPY_AND_ASSIGN(SideTabNewTabButton); |
41 }; | 43 }; |
42 | 44 |
43 SideTabNewTabButton::SideTabNewTabButton(TabStripController* controller) | 45 SideTabNewTabButton::SideTabNewTabButton(TabStripController* controller) |
44 : SideTab(NULL), | 46 : SideTab(NULL), |
45 controller_(controller) { | 47 controller_(controller) { |
46 // Never show a close button for the new tab button. | 48 // Never show a close button for the new tab button. |
47 close_button()->SetVisible(false); | 49 close_button()->SetVisible(false); |
48 TabRendererData data; | 50 TabRendererData data; |
49 data.favicon = *ResourceBundle::GetSharedInstance().GetBitmapNamed( | 51 data.favicon = *ResourceBundle::GetSharedInstance().GetBitmapNamed( |
50 IDR_SIDETABS_NEW_TAB); | 52 IDR_SIDETABS_NEW_TAB); |
51 data.title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); | 53 data.title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); |
52 SetData(data); | 54 SetData(data); |
53 } | 55 } |
54 | 56 |
55 bool SideTabNewTabButton::OnMousePressed(const views::MouseEvent& event) { | 57 bool SideTabNewTabButton::OnMousePressed(const views::MouseEvent& event) { |
56 return true; | 58 return true; |
57 } | 59 } |
58 | 60 |
59 void SideTabNewTabButton::OnMouseReleased(const views::MouseEvent& event, | 61 void SideTabNewTabButton::OnMouseReleased(const views::MouseEvent& event) { |
60 bool canceled) { | 62 if (event.IsOnlyLeftMouseButton() && HitTest(event.location())) |
61 if (!canceled && event.IsOnlyLeftMouseButton() && HitTest(event.location())) | |
62 controller_->CreateNewTab(); | 63 controller_->CreateNewTab(); |
63 } | 64 } |
64 | 65 |
65 } // namespace | 66 } // namespace |
66 | 67 |
67 // static | 68 // static |
68 const int SideTabStrip::kTabStripInset = 3; | 69 const int SideTabStrip::kTabStripInset = 3; |
69 | 70 |
70 //////////////////////////////////////////////////////////////////////////////// | 71 //////////////////////////////////////////////////////////////////////////////// |
71 // SideTabStrip, public: | 72 // SideTabStrip, public: |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 tab->SetBounds(layout_rect.x(), y, layout_rect.width(), | 251 tab->SetBounds(layout_rect.x(), y, layout_rect.width(), |
251 tab->GetPreferredSize().height()); | 252 tab->GetPreferredSize().height()); |
252 tab->SchedulePaint(); | 253 tab->SchedulePaint(); |
253 y += tab->height(); | 254 y += tab->height(); |
254 } | 255 } |
255 } | 256 } |
256 | 257 |
257 int SideTabStrip::GetSizeNeededForTabs(const std::vector<BaseTab*>& tabs) { | 258 int SideTabStrip::GetSizeNeededForTabs(const std::vector<BaseTab*>& tabs) { |
258 return static_cast<int>(tabs.size()) * SideTab::GetPreferredHeight(); | 259 return static_cast<int>(tabs.size()) * SideTab::GetPreferredHeight(); |
259 } | 260 } |
OLD | NEW |