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

Side by Side Diff: chrome/browser/ui/views/wrench_menu.cc

Issue 11753018: Remove ScheduleAllView class from wrench_menu.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 | « no previous file | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/wrench_menu.h" 5 #include "chrome/browser/ui/views/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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 const ButtonType type_; 288 const ButtonType type_;
289 const bool use_new_menu_; 289 const bool use_new_menu_;
290 290
291 // See description above setter for details. 291 // See description above setter for details.
292 CustomButton* left_button_; 292 CustomButton* left_button_;
293 CustomButton* right_button_; 293 CustomButton* right_button_;
294 294
295 DISALLOW_COPY_AND_ASSIGN(MenuButtonBackground); 295 DISALLOW_COPY_AND_ASSIGN(MenuButtonBackground);
296 }; 296 };
297 297
298 // A View subclass that forces SchedulePaint to paint all. Normally when the
299 // mouse enters/exits a button the buttons invokes SchedulePaint. As part of the
300 // button border (MenuButtonBackground) is rendered by the button to the
301 // left/right of it SchedulePaint on the the button may not be enough, so this
302 // forces a paint all.
303 class ScheduleAllView : public views::View {
304 public:
305 ScheduleAllView() {}
306
307 // Overridden from views::View.
308 virtual void SchedulePaintInRect(const gfx::Rect& r) OVERRIDE {
309 View::SchedulePaintInRect(gfx::Rect(0, 0, width(), height()));
310 }
311
312 private:
313 DISALLOW_COPY_AND_ASSIGN(ScheduleAllView);
314 };
315
316 string16 GetAccessibleNameForWrenchMenuItem( 298 string16 GetAccessibleNameForWrenchMenuItem(
317 MenuModel* model, int item_index, int accessible_string_id) { 299 MenuModel* model, int item_index, int accessible_string_id) {
318 string16 accessible_name = l10n_util::GetStringUTF16(accessible_string_id); 300 string16 accessible_name = l10n_util::GetStringUTF16(accessible_string_id);
319 string16 accelerator_text; 301 string16 accelerator_text;
320 302
321 ui::Accelerator menu_accelerator; 303 ui::Accelerator menu_accelerator;
322 if (model->GetAcceleratorAt(item_index, &menu_accelerator)) { 304 if (model->GetAcceleratorAt(item_index, &menu_accelerator)) {
323 accelerator_text = 305 accelerator_text =
324 ui::Accelerator(menu_accelerator.key_code(), 306 ui::Accelerator(menu_accelerator.key_code(),
325 menu_accelerator.modifiers()).GetShortcutText(); 307 menu_accelerator.modifiers()).GetShortcutText();
326 } 308 }
327 309
328 return MenuItemView::GetAccessibleNameForMenuItem( 310 return MenuItemView::GetAccessibleNameForMenuItem(
329 accessible_name, accelerator_text); 311 accessible_name, accelerator_text);
330 } 312 }
331 313
332 // WrenchMenuView is a view that can contain text buttons. 314 // WrenchMenuView is a view that can contain text buttons.
333 class WrenchMenuView : public ScheduleAllView, public views::ButtonListener { 315 class WrenchMenuView : public views::View,
316 public views::ButtonListener {
334 public: 317 public:
335 WrenchMenuView(WrenchMenu* menu, MenuModel* menu_model) 318 WrenchMenuView(WrenchMenu* menu, MenuModel* menu_model)
336 : menu_(menu), 319 : menu_(menu),
337 menu_model_(menu_model) {} 320 menu_model_(menu_model) {}
338 321
322 // Overridden from views::View.
323 virtual void SchedulePaintInRect(const gfx::Rect& r) OVERRIDE {
324 // Normally when the mouse enters/exits a button the buttons invokes
325 // SchedulePaint. As part of the button border (MenuButtonBackground) is
326 // rendered by the button to the left/right of it SchedulePaint on the the
327 // button may not be enough, so this forces a paint all.
328 View::SchedulePaintInRect(gfx::Rect(0, 0, width(), height()));
tfarina 2013/01/04 19:15:34 nit: gfx::Rect(size())
329 }
330
339 TextButton* CreateAndConfigureButton(int string_id, 331 TextButton* CreateAndConfigureButton(int string_id,
340 MenuButtonBackground::ButtonType type, 332 MenuButtonBackground::ButtonType type,
341 int index, 333 int index,
342 MenuButtonBackground** background) { 334 MenuButtonBackground** background) {
343 return CreateButtonWithAccName( 335 return CreateButtonWithAccName(
344 string_id, type, index, background, string_id); 336 string_id, type, index, background, string_id);
345 } 337 }
346 338
347 TextButton* CreateButtonWithAccName(int string_id, 339 TextButton* CreateButtonWithAccName(int string_id,
348 MenuButtonBackground::ButtonType type, 340 MenuButtonBackground::ButtonType type,
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 bookmark_menu_delegate_.reset( 1145 bookmark_menu_delegate_.reset(
1154 new BookmarkMenuDelegate(browser_, 1146 new BookmarkMenuDelegate(browser_,
1155 browser_, 1147 browser_,
1156 parent, 1148 parent,
1157 first_bookmark_command_id_)); 1149 first_bookmark_command_id_));
1158 bookmark_menu_delegate_->Init( 1150 bookmark_menu_delegate_->Init(
1159 this, bookmark_menu_, model->bookmark_bar_node(), 0, 1151 this, bookmark_menu_, model->bookmark_bar_node(), 0,
1160 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1152 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1161 bookmark_utils::LAUNCH_WRENCH_MENU); 1153 bookmark_utils::LAUNCH_WRENCH_MENU);
1162 } 1154 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698