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

Side by Side Diff: ui/views/controls/menu/menu_separator_views.cc

Issue 10837317: Setting the touch wrench menu as default menu for ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed second review Created 8 years, 4 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 (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 "ui/views/controls/menu/menu_separator.h" 5 #include "ui/views/controls/menu/menu_separator.h"
6 6
7 #include "third_party/skia/include/core/SkColor.h" 7 #include "third_party/skia/include/core/SkColor.h"
8 #include "ui/base/native_theme/native_theme.h" 8 #include "ui/base/native_theme/native_theme.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/views/controls/menu/menu_config.h" 10 #include "ui/views/controls/menu/menu_config.h"
11 11
12 namespace { 12 namespace {
13 13
14 const int kSeparatorHeight = 1; 14 const int kSeparatorHeight = 1;
15 15
16 } // namespace 16 } // namespace
17 17
18 namespace views { 18 namespace views {
19 19
20 void MenuSeparator::OnPaint(gfx::Canvas* canvas) { 20 void MenuSeparator::OnPaint(gfx::Canvas* canvas) {
21 canvas->FillRect(gfx::Rect(0, height() / 2, width(), kSeparatorHeight), 21 if (type_ == ui::UPPER_SEPARATOR) {
22 ui::NativeTheme::instance()->GetSystemColor( 22 canvas->FillRect(gfx::Rect(0, 0, width(), kSeparatorHeight),
23 ui::NativeTheme::kColorId_MenuSeparatorColor)); 23 ui::NativeTheme::instance()->GetSystemColor(
sky 2012/08/21 19:36:29 Since all branches get the color, move it earlier
Mr4D (OOO till 08-26) 2012/08/21 21:34:54 Not done it that way since that would have read th
24 ui::NativeTheme::kColorId_MenuSeparatorColor));
25 } else if (type_ == ui::LOWER_SEPARATOR) {
26 canvas->FillRect(gfx::Rect(0,
27 height() - kSeparatorHeight,
28 width(),
29 kSeparatorHeight),
30 ui::NativeTheme::instance()->GetSystemColor(
31 ui::NativeTheme::kColorId_MenuSeparatorColor));
32 } else if (type_ != ui::SPACING_SEPARATOR) {
33 canvas->FillRect(gfx::Rect(0, height() / 2, width(), kSeparatorHeight),
34 ui::NativeTheme::instance()->GetSystemColor(
35 ui::NativeTheme::kColorId_MenuSeparatorColor));
36 }
24 } 37 }
25 38
26 gfx::Size MenuSeparator::GetPreferredSize() { 39 gfx::Size MenuSeparator::GetPreferredSize() {
40 int height = MenuConfig::instance().separator_height;
41 switch(type_) {
42 case ui::SPACING_SEPARATOR:
43 height = MenuConfig::instance().separator_spacing_height;
44 break;
45 case ui::LOWER_SEPARATOR:
46 height = MenuConfig::instance().separator_lower_height;
47 break;
48 case ui::UPPER_SEPARATOR:
49 height = MenuConfig::instance().separator_upper_height;
50 break;
51 default:
52 height = MenuConfig::instance().separator_height;
53 break;
54 }
27 return gfx::Size(10, // Just in case we're the only item in a menu. 55 return gfx::Size(10, // Just in case we're the only item in a menu.
28 MenuConfig::instance().separator_height); 56 height);
29 } 57 }
30 58
31 } // namespace views 59 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698