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

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

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT 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 28 matching lines...) Expand all
39 } 39 }
40 40
41 void ToolbarButton::ClearPendingMenu() { 41 void ToolbarButton::ClearPendingMenu() {
42 show_menu_factory_.InvalidateWeakPtrs(); 42 show_menu_factory_.InvalidateWeakPtrs();
43 } 43 }
44 44
45 bool ToolbarButton::IsMenuShowing() const { 45 bool ToolbarButton::IsMenuShowing() const {
46 return menu_showing_; 46 return menu_showing_;
47 } 47 }
48 48
49 gfx::Size ToolbarButton::GetPreferredSize() { 49 gfx::Size ToolbarButton::GetPreferredSize() const {
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() &&
59 IsTriggerableEvent(event) && HitTestPoint(event.location())) { 59 IsTriggerableEvent(event) && HitTestPoint(event.location())) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 226
227 // Need to explicitly clear mouse handler so that events get sent 227 // 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 228 // 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. 229 // the first click to other parts of the UI is eaten.
230 SetMouseHandler(NULL); 230 SetMouseHandler(NULL);
231 231
232 // Set the state back to normal after the drop down menu is closed. 232 // Set the state back to normal after the drop down menu is closed.
233 if (state_ != STATE_DISABLED) 233 if (state_ != STATE_DISABLED)
234 SetState(STATE_NORMAL); 234 SetState(STATE_NORMAL);
235 } 235 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_button.h ('k') | chrome/browser/ui/views/toolbar/toolbar_button_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698