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/wrench_menu.cc

Issue 1228213003: Just set borders once when creating a views::LabelButton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review Created 5 years, 5 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/wrench_menu.h" 5 #include "chrome/browser/ui/views/toolbar/wrench_menu.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <set> 9 #include <set>
10 10
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 : LabelButton(listener, text), in_menu_background_(NULL) {} 261 : LabelButton(listener, text), in_menu_background_(NULL) {}
262 ~InMenuButton() override {} 262 ~InMenuButton() override {}
263 263
264 void Init(InMenuButtonBackground::ButtonType type) { 264 void Init(InMenuButtonBackground::ButtonType type) {
265 SetFocusable(true); 265 SetFocusable(true);
266 set_request_focus_on_press(false); 266 set_request_focus_on_press(false);
267 SetHorizontalAlignment(gfx::ALIGN_CENTER); 267 SetHorizontalAlignment(gfx::ALIGN_CENTER);
268 268
269 in_menu_background_ = new InMenuButtonBackground(type); 269 in_menu_background_ = new InMenuButtonBackground(type);
270 set_background(in_menu_background_); 270 set_background(in_menu_background_);
271 271 SetBorder(views::Border::CreateEmptyBorder(0, kHorizontalPadding, 0,
272 OnNativeThemeChanged(NULL); 272 kHorizontalPadding));
273 } 273 }
274 274
275 void SetOtherButtons(const InMenuButton* left, const InMenuButton* right) { 275 void SetOtherButtons(const InMenuButton* left, const InMenuButton* right) {
276 in_menu_background_->SetOtherButtons(left, right); 276 in_menu_background_->SetOtherButtons(left, right);
277 } 277 }
278 278
279 // views::LabelButton 279 // views::LabelButton
280 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { 280 void OnNativeThemeChanged(const ui::NativeTheme* theme) override {
281 const MenuConfig& menu_config = MenuConfig::instance(theme); 281 const MenuConfig& menu_config = MenuConfig::instance(theme);
282 SetBorder(views::Border::CreateEmptyBorder(
283 0, kHorizontalPadding, 0, kHorizontalPadding));
284 SetFontList(menu_config.font_list); 282 SetFontList(menu_config.font_list);
285 283
286 if (theme) { 284 if (theme) {
287 SetTextColor( 285 SetTextColor(
288 views::Button::STATE_DISABLED, 286 views::Button::STATE_DISABLED,
289 theme->GetSystemColor( 287 theme->GetSystemColor(
290 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor)); 288 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor));
291 SetTextColor( 289 SetTextColor(
292 views::Button::STATE_HOVERED, 290 views::Button::STATE_HOVERED,
293 theme->GetSystemColor( 291 theme->GetSystemColor(
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 0, 1249 0,
1252 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1250 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1253 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); 1251 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU);
1254 } 1252 }
1255 1253
1256 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { 1254 int WrenchMenu::ModelIndexFromCommandId(int command_id) const {
1257 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); 1255 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id);
1258 DCHECK(ix != command_id_to_entry_.end()); 1256 DCHECK(ix != command_id_to_entry_.end());
1259 return ix->second.second; 1257 return ix->second.second;
1260 } 1258 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698