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

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 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/models/menu_model.h"
sky 2012/08/21 03:03:25 remove this import
Mr4D (OOO till 08-26) 2012/08/21 15:37:16 Done.
8 #include "ui/base/native_theme/native_theme.h" 9 #include "ui/base/native_theme/native_theme.h"
9 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
10 #include "ui/views/controls/menu/menu_config.h" 11 #include "ui/views/controls/menu/menu_config.h"
11 12
12 namespace { 13 namespace {
13 14
14 const int kSeparatorHeight = 1; 15 const int kSeparatorHeight = 1;
15 16
16 } // namespace 17 } // namespace
17 18
18 namespace views { 19 namespace views {
19 20
20 void MenuSeparator::OnPaint(gfx::Canvas* canvas) { 21 void MenuSeparator::OnPaint(gfx::Canvas* canvas) {
21 canvas->FillRect(gfx::Rect(0, height() / 2, width(), kSeparatorHeight), 22 if (type_ == ui::UPPER_SEPARATOR) {
22 ui::NativeTheme::instance()->GetSystemColor( 23 canvas->FillRect(gfx::Rect(0, 0, width(), kSeparatorHeight),
23 ui::NativeTheme::kColorId_MenuSeparatorColor)); 24 ui::NativeTheme::instance()->GetSystemColor(
25 ui::NativeTheme::kColorId_MenuSeparatorColor));
26 } else if (type_ == ui::LOWER_SEPARATOR) {
27 canvas->FillRect(gfx::Rect(0,
28 height() - kSeparatorHeight,
29 width(),
30 kSeparatorHeight),
31 ui::NativeTheme::instance()->GetSystemColor(
32 ui::NativeTheme::kColorId_MenuSeparatorColor));
33 } else if (type_ != ui::SPACING_SEPARATOR) {
34 canvas->FillRect(gfx::Rect(0, height() / 2, width(), kSeparatorHeight),
35 ui::NativeTheme::instance()->GetSystemColor(
36 ui::NativeTheme::kColorId_MenuSeparatorColor));
37 }
24 } 38 }
25 39
26 gfx::Size MenuSeparator::GetPreferredSize() { 40 gfx::Size MenuSeparator::GetPreferredSize() {
41 int height = MenuConfig::instance().separator_height;
sky 2012/08/21 03:03:25 Add 3 constants for the specific separator types.
Mr4D (OOO till 08-26) 2012/08/21 15:37:16 Done.
42 if (type_ == ui::SPACING_SEPARATOR)
43 height = (height - kSeparatorHeight) / 2;
44 else if (type_ == ui::UPPER_SEPARATOR || type_ == ui::LOWER_SEPARATOR)
45 height = (height - kSeparatorHeight) / 2 + kSeparatorHeight;
27 return gfx::Size(10, // Just in case we're the only item in a menu. 46 return gfx::Size(10, // Just in case we're the only item in a menu.
28 MenuConfig::instance().separator_height); 47 height);
29 } 48 }
30 49
31 } // namespace views 50 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698