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

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_button.cc

Issue 139983009: ui::LocatedEvent location() returns gfx::PointF (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Undo accidental change. Created 6 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/toolbar/toolbar_button.h" 5 #include "chrome/browser/ui/views/toolbar/toolbar_button.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
9 #include "grit/theme_resources.h" 9 #include "grit/theme_resources.h"
10 #include "grit/ui_strings.h" 10 #include "grit/ui_strings.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 gfx::Size ToolbarButton::GetPreferredSize() { 49 gfx::Size ToolbarButton::GetPreferredSize() {
50 gfx::Size size(image()->GetPreferredSize()); 50 gfx::Size size(image()->GetPreferredSize());
51 gfx::Size label_size = label()->GetPreferredSize(); 51 gfx::Size label_size = label()->GetPreferredSize();
52 if (label_size.width() > 0) 52 if (label_size.width() > 0)
53 size.Enlarge(label_size.width() + LocationBarView::kItemPadding, 0); 53 size.Enlarge(label_size.width() + LocationBarView::kItemPadding, 0);
54 return size; 54 return size;
55 } 55 }
56 56
57 bool ToolbarButton::OnMousePressed(const ui::MouseEvent& event) { 57 bool ToolbarButton::OnMousePressed(const ui::MouseEvent& event) {
58 if (enabled() && ShouldShowMenu() && 58 if (enabled() && ShouldShowMenu() && IsTriggerableEvent(event) &&
59 IsTriggerableEvent(event) && HitTestPoint(event.location())) { 59 HitTestPoint(gfx::ToFlooredPoint(event.location()))) {
60 // Store the y pos of the mouse coordinates so we can use them later to 60 // Store the y pos of the mouse coordinates so we can use them later to
61 // determine if the user dragged the mouse down (which should pop up the 61 // determine if the user dragged the mouse down (which should pop up the
62 // drag down menu immediately, instead of waiting for the timer) 62 // drag down menu immediately, instead of waiting for the timer)
63 y_position_on_lbuttondown_ = event.y(); 63 y_position_on_lbuttondown_ = event.y();
64 64
65 // Schedule a task that will show the menu. 65 // Schedule a task that will show the menu.
66 const int kMenuTimerDelay = 500; 66 const int kMenuTimerDelay = 500;
67 base::MessageLoop::current()->PostDelayedTask( 67 base::MessageLoop::current()->PostDelayedTask(
68 FROM_HERE, 68 FROM_HERE,
69 base::Bind(&ToolbarButton::ShowDropDownMenu, 69 base::Bind(&ToolbarButton::ShowDropDownMenu,
(...skipping 15 matching lines...) Expand all
85 show_menu_factory_.InvalidateWeakPtrs(); 85 show_menu_factory_.InvalidateWeakPtrs();
86 ShowDropDownMenu(ui::GetMenuSourceTypeForEvent(event)); 86 ShowDropDownMenu(ui::GetMenuSourceTypeForEvent(event));
87 } 87 }
88 } 88 }
89 89
90 return result; 90 return result;
91 } 91 }
92 92
93 void ToolbarButton::OnMouseReleased(const ui::MouseEvent& event) { 93 void ToolbarButton::OnMouseReleased(const ui::MouseEvent& event) {
94 if (IsTriggerableEvent(event) || 94 if (IsTriggerableEvent(event) ||
95 (event.IsRightMouseButton() && !HitTestPoint(event.location()))) { 95 (event.IsRightMouseButton() &&
96 !HitTestPoint(gfx::ToFlooredPoint(event.location())))) {
96 LabelButton::OnMouseReleased(event); 97 LabelButton::OnMouseReleased(event);
97 } 98 }
98 99
99 if (IsTriggerableEvent(event)) 100 if (IsTriggerableEvent(event))
100 show_menu_factory_.InvalidateWeakPtrs(); 101 show_menu_factory_.InvalidateWeakPtrs();
101 } 102 }
102 103
103 void ToolbarButton::OnMouseCaptureLost() { 104 void ToolbarButton::OnMouseCaptureLost() {
104 } 105 }
105 106
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 227
227 // Need to explicitly clear mouse handler so that events get sent 228 // Need to explicitly clear mouse handler so that events get sent
228 // properly after the menu finishes running. If we don't do this, then 229 // properly after the menu finishes running. If we don't do this, then
229 // the first click to other parts of the UI is eaten. 230 // the first click to other parts of the UI is eaten.
230 SetMouseHandler(NULL); 231 SetMouseHandler(NULL);
231 232
232 // Set the state back to normal after the drop down menu is closed. 233 // Set the state back to normal after the drop down menu is closed.
233 if (state_ != STATE_DISABLED) 234 if (state_ != STATE_DISABLED)
234 SetState(STATE_NORMAL); 235 SetState(STATE_NORMAL);
235 } 236 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698