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

Side by Side Diff: chrome/browser/ui/views/tabs/side_tab_strip.cc

Issue 6685069: Disambiguate OnMouseCaptureLost from OnMouseReleased, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments, fix tests, cleanup, etc. Created 9 years, 9 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
« no previous file with comments | « chrome/browser/ui/views/tabs/base_tab_strip.cc ('k') | ui/views/view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 36
37 private: 37 private:
38 TabStripController* controller_; 38 TabStripController* controller_;
39 39
40 DISALLOW_COPY_AND_ASSIGN(SideTabNewTabButton); 40 DISALLOW_COPY_AND_ASSIGN(SideTabNewTabButton);
41 }; 41 };
42 42
43 SideTabNewTabButton::SideTabNewTabButton(TabStripController* controller) 43 SideTabNewTabButton::SideTabNewTabButton(TabStripController* controller)
44 : SideTab(NULL), 44 : SideTab(NULL),
45 controller_(controller) { 45 controller_(controller) {
46 // Never show a close button for the new tab button. 46 // Never show a close button for the new tab button.
47 close_button()->SetVisible(false); 47 close_button()->SetVisible(false);
48 TabRendererData data; 48 TabRendererData data;
49 data.favicon = *ResourceBundle::GetSharedInstance().GetBitmapNamed( 49 data.favicon = *ResourceBundle::GetSharedInstance().GetBitmapNamed(
50 IDR_SIDETABS_NEW_TAB); 50 IDR_SIDETABS_NEW_TAB);
51 data.title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); 51 data.title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE);
52 SetData(data); 52 SetData(data);
53 } 53 }
54 54
55 bool SideTabNewTabButton::OnMousePressed(const views::MouseEvent& event) { 55 bool SideTabNewTabButton::OnMousePressed(const views::MouseEvent& event) {
56 return true; 56 return true;
57 } 57 }
58 58
59 void SideTabNewTabButton::OnMouseReleased(const views::MouseEvent& event, 59 void SideTabNewTabButton::OnMouseReleased(const views::MouseEvent& event) {
60 bool canceled) { 60 if (event.IsOnlyLeftMouseButton() && HitTest(event.location()))
61 if (!canceled && event.IsOnlyLeftMouseButton() && HitTest(event.location()))
62 controller_->CreateNewTab(); 61 controller_->CreateNewTab();
63 } 62 }
64 63
65 } // namespace 64 } // namespace
66 65
67 // static 66 // static
68 const int SideTabStrip::kTabStripInset = 3; 67 const int SideTabStrip::kTabStripInset = 3;
69 68
70 //////////////////////////////////////////////////////////////////////////////// 69 ////////////////////////////////////////////////////////////////////////////////
71 // SideTabStrip, public: 70 // SideTabStrip, public:
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 tab->SetBounds(layout_rect.x(), y, layout_rect.width(), 252 tab->SetBounds(layout_rect.x(), y, layout_rect.width(),
254 tab->GetPreferredSize().height()); 253 tab->GetPreferredSize().height());
255 tab->SchedulePaint(); 254 tab->SchedulePaint();
256 y += tab->height(); 255 y += tab->height();
257 } 256 }
258 } 257 }
259 258
260 int SideTabStrip::GetSizeNeededForTabs(const std::vector<BaseTab*>& tabs) { 259 int SideTabStrip::GetSizeNeededForTabs(const std::vector<BaseTab*>& tabs) {
261 return static_cast<int>(tabs.size()) * SideTab::GetPreferredHeight(); 260 return static_cast<int>(tabs.size()) * SideTab::GetPreferredHeight();
262 } 261 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/base_tab_strip.cc ('k') | ui/views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698