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

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

Issue 1338103002: Create c/b/ui/views/layout_constants.*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
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 "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
11 #include "chrome/browser/themes/theme_properties.h" 11 #include "chrome/browser/ui/views/layout_constants.h"
12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
13 #include "ui/accessibility/ax_view_state.h" 13 #include "ui/accessibility/ax_view_state.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/models/menu_model.h" 15 #include "ui/base/models/menu_model.h"
16 #include "ui/base/resource/material_design/material_design_controller.h" 16 #include "ui/base/resource/material_design/material_design_controller.h"
17 #include "ui/base/theme_provider.h" 17 #include "ui/base/theme_provider.h"
18 #include "ui/gfx/display.h" 18 #include "ui/gfx/display.h"
19 #include "ui/gfx/screen.h" 19 #include "ui/gfx/screen.h"
20 #include "ui/strings/grit/ui_strings.h" 20 #include "ui/strings/grit/ui_strings.h"
21 #include "ui/views/animation/ink_drop_animation_controller.h" 21 #include "ui/views/animation/ink_drop_animation_controller.h"
(...skipping 30 matching lines...) Expand all
52 } 52 }
53 53
54 bool ToolbarButton::IsMenuShowing() const { 54 bool ToolbarButton::IsMenuShowing() const {
55 return menu_showing_; 55 return menu_showing_;
56 } 56 }
57 57
58 gfx::Size ToolbarButton::GetPreferredSize() const { 58 gfx::Size ToolbarButton::GetPreferredSize() const {
59 gfx::Size size(image()->GetPreferredSize()); 59 gfx::Size size(image()->GetPreferredSize());
60 gfx::Size label_size = label()->GetPreferredSize(); 60 gfx::Size label_size = label()->GetPreferredSize();
61 if (label_size.width() > 0) { 61 if (label_size.width() > 0) {
62 const int horizontal_item_padding = GetThemeProvider()->GetDisplayProperty( 62 size.Enlarge(
63 ThemeProperties::PROPERTY_LOCATION_BAR_HORIZONTAL_PADDING); 63 label_size.width() + GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING),
64 size.Enlarge(label_size.width() + horizontal_item_padding, 0); 64 0);
65 } 65 }
66 // For non-material assets the entire size of the button is captured in the 66 // For non-material assets the entire size of the button is captured in the
67 // image resource. For Material Design the excess whitespace is being removed 67 // image resource. For Material Design the excess whitespace is being removed
68 // from the image assets. Enlarge the button by the theme provided insets. 68 // from the image assets. Enlarge the button by the theme provided insets.
69 if (ui::MaterialDesignController::IsModeMaterial()) { 69 if (ui::MaterialDesignController::IsModeMaterial()) {
70 ui::ThemeProvider* provider = GetThemeProvider(); 70 ui::ThemeProvider* provider = GetThemeProvider();
71 if (provider && provider->UsingSystemTheme()) { 71 if (provider && provider->UsingSystemTheme()) {
72 int inset = provider->GetDisplayProperty( 72 gfx::Insets insets(GetLayoutInsets(TOOLBAR_BUTTON));
73 ThemeProperties::PROPERTY_TOOLBAR_BUTTON_BORDER_INSET); 73 size.Enlarge(insets.width(), insets.height());
74 size.Enlarge(2 * inset, 2 * inset);
75 } 74 }
76 } 75 }
77 return size; 76 return size;
78 } 77 }
79 78
80 void ToolbarButton::Layout() { 79 void ToolbarButton::Layout() {
81 LabelButton::Layout(); 80 LabelButton::Layout();
82 LayoutInkDrop(); 81 LayoutInkDrop();
83 } 82 }
84 83
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 state->AddStateFlag(ui::AX_STATE_HASPOPUP); 183 state->AddStateFlag(ui::AX_STATE_HASPOPUP);
185 } 184 }
186 185
187 scoped_ptr<views::LabelButtonBorder> 186 scoped_ptr<views::LabelButtonBorder>
188 ToolbarButton::CreateDefaultBorder() const { 187 ToolbarButton::CreateDefaultBorder() const {
189 scoped_ptr<views::LabelButtonBorder> border = 188 scoped_ptr<views::LabelButtonBorder> border =
190 views::LabelButton::CreateDefaultBorder(); 189 views::LabelButton::CreateDefaultBorder();
191 190
192 ui::ThemeProvider* provider = GetThemeProvider(); 191 ui::ThemeProvider* provider = GetThemeProvider();
193 if (provider && provider->UsingSystemTheme()) { 192 if (provider && provider->UsingSystemTheme()) {
194 // Theme provided insets. 193 gfx::Insets insets(GetLayoutInsets(TOOLBAR_BUTTON));
195 int inset = provider->GetDisplayProperty( 194 border->set_insets(insets);
jonross 2015/09/14 15:27:10 Nit: border->set_insets(GetLayoutInsets(TOOLBAR_BU
Peter Kasting 2015/09/14 21:06:31 Done.
196 ThemeProperties::PROPERTY_TOOLBAR_BUTTON_BORDER_INSET);
197 border->set_insets(gfx::Insets(inset, inset, inset, inset));
198 } 195 }
199 196
200 return border.Pass(); 197 return border.Pass();
201 } 198 }
202 199
203 void ToolbarButton::ShowContextMenuForView(View* source, 200 void ToolbarButton::ShowContextMenuForView(View* source,
204 const gfx::Point& point, 201 const gfx::Point& point,
205 ui::MenuSourceType source_type) { 202 ui::MenuSourceType source_type) {
206 if (!enabled()) 203 if (!enabled())
207 return; 204 return;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 SetState(STATE_NORMAL); 322 SetState(STATE_NORMAL);
326 } 323 }
327 324
328 void ToolbarButton::LayoutInkDrop() { 325 void ToolbarButton::LayoutInkDrop() {
329 ink_drop_animation_controller_->SetInkDropSize(size()); 326 ink_drop_animation_controller_->SetInkDropSize(size());
330 } 327 }
331 328
332 const char* ToolbarButton::GetClassName() const { 329 const char* ToolbarButton::GetClassName() const {
333 return "ToolbarButton"; 330 return "ToolbarButton";
334 } 331 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698