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

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

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 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 | « ui/views/controls/menu/menu_separator.h ('k') | ui/views/controls/menu/menu_separator_win.cc » ('j') | 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 "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/gfx/canvas.h" 8 #include "ui/gfx/canvas.h"
9 #include "ui/native_theme/native_theme.h" 9 #include "ui/native_theme/native_theme.h"
10 #include "ui/views/controls/menu/menu_config.h" 10 #include "ui/views/controls/menu/menu_config.h"
11 #include "ui/views/controls/menu/menu_item_view.h" 11 #include "ui/views/controls/menu/menu_item_view.h"
12 12
13 namespace { 13 namespace {
14 14
15 const int kSeparatorHeight = 1; 15 const int kSeparatorHeight = 1;
16 16
17 } // namespace 17 } // namespace
18 18
19 namespace views { 19 namespace views {
20 20
21 #if !defined(OS_WIN) 21 #if !defined(OS_WIN)
22 void MenuSeparator::OnPaint(gfx::Canvas* canvas) { 22 void MenuSeparator::OnPaint(gfx::Canvas* canvas) {
23 OnPaintAura(canvas); 23 OnPaintAura(canvas);
24 } 24 }
25 25
26 gfx::Size MenuSeparator::GetPreferredSize() { 26 gfx::Size MenuSeparator::GetPreferredSize() const {
27 return GetPreferredSizeAura(); 27 return GetPreferredSizeAura();
28 } 28 }
29 #endif 29 #endif
30 30
31 void MenuSeparator::OnPaintAura(gfx::Canvas* canvas) { 31 void MenuSeparator::OnPaintAura(gfx::Canvas* canvas) {
32 int pos = 0; 32 int pos = 0;
33 switch (type_) { 33 switch (type_) {
34 case ui::LOWER_SEPARATOR: 34 case ui::LOWER_SEPARATOR:
35 pos = height() - kSeparatorHeight; 35 pos = height() - kSeparatorHeight;
36 break; 36 break;
37 case ui::SPACING_SEPARATOR: 37 case ui::SPACING_SEPARATOR:
38 return; 38 return;
39 case ui::UPPER_SEPARATOR: 39 case ui::UPPER_SEPARATOR:
40 break; 40 break;
41 default: 41 default:
42 pos = height() / 2; 42 pos = height() / 2;
43 break; 43 break;
44 } 44 }
45 canvas->FillRect(gfx::Rect(0, pos, width(), kSeparatorHeight), 45 canvas->FillRect(gfx::Rect(0, pos, width(), kSeparatorHeight),
46 GetNativeTheme()->GetSystemColor( 46 GetNativeTheme()->GetSystemColor(
47 ui::NativeTheme::kColorId_MenuSeparatorColor)); 47 ui::NativeTheme::kColorId_MenuSeparatorColor));
48 } 48 }
49 49
50 gfx::Size MenuSeparator::GetPreferredSizeAura() { 50 gfx::Size MenuSeparator::GetPreferredSizeAura() const {
51 const MenuConfig& menu_config = parent_menu_item_->GetMenuConfig(); 51 const MenuConfig& menu_config = parent_menu_item_->GetMenuConfig();
52 int height = menu_config.separator_height; 52 int height = menu_config.separator_height;
53 switch(type_) { 53 switch(type_) {
54 case ui::SPACING_SEPARATOR: 54 case ui::SPACING_SEPARATOR:
55 height = menu_config.separator_spacing_height; 55 height = menu_config.separator_spacing_height;
56 break; 56 break;
57 case ui::LOWER_SEPARATOR: 57 case ui::LOWER_SEPARATOR:
58 height = menu_config.separator_lower_height; 58 height = menu_config.separator_lower_height;
59 break; 59 break;
60 case ui::UPPER_SEPARATOR: 60 case ui::UPPER_SEPARATOR:
61 height = menu_config.separator_upper_height; 61 height = menu_config.separator_upper_height;
62 break; 62 break;
63 default: 63 default:
64 height = menu_config.separator_height; 64 height = menu_config.separator_height;
65 break; 65 break;
66 } 66 }
67 return gfx::Size(10, // Just in case we're the only item in a menu. 67 return gfx::Size(10, // Just in case we're the only item in a menu.
68 height); 68 height);
69 } 69 }
70 70
71 } // namespace views 71 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_separator.h ('k') | ui/views/controls/menu/menu_separator_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698