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

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

Issue 11088037: Revert 160886 - Added MenuConfig setter to MenuItemView, updated rest of the code to use set MenuCo… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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_item_view_win.cc ('k') | ui/views/controls/menu/menu_separator.h » ('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_scroll_view_container.h" 5 #include "ui/views/controls/menu/menu_scroll_view_container.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <uxtheme.h> 9 #include <uxtheme.h>
10 #include <Vssym32.h> 10 #include <Vssym32.h>
(...skipping 30 matching lines...) Expand all
41 class MenuScrollButton : public View { 41 class MenuScrollButton : public View {
42 public: 42 public:
43 MenuScrollButton(SubmenuView* host, bool is_up) 43 MenuScrollButton(SubmenuView* host, bool is_up)
44 : host_(host), 44 : host_(host),
45 is_up_(is_up), 45 is_up_(is_up),
46 // Make our height the same as that of other MenuItemViews. 46 // Make our height the same as that of other MenuItemViews.
47 pref_height_(MenuItemView::pref_menu_height()) { 47 pref_height_(MenuItemView::pref_menu_height()) {
48 } 48 }
49 49
50 virtual gfx::Size GetPreferredSize() { 50 virtual gfx::Size GetPreferredSize() {
51 return gfx::Size( 51 return gfx::Size(MenuConfig::instance().scroll_arrow_height * 2 - 1,
52 host_->GetMenuItem()->GetMenuConfig().scroll_arrow_height * 2 - 1, 52 pref_height_);
53 pref_height_);
54 } 53 }
55 54
56 virtual bool CanDrop(const OSExchangeData& data) { 55 virtual bool CanDrop(const OSExchangeData& data) {
57 DCHECK(host_->GetMenuItem()->GetMenuController()); 56 DCHECK(host_->GetMenuItem()->GetMenuController());
58 return true; // Always return true so that drop events are targeted to us. 57 return true; // Always return true so that drop events are targeted to us.
59 } 58 }
60 59
61 virtual void OnDragEntered(const ui::DropTargetEvent& event) { 60 virtual void OnDragEntered(const ui::DropTargetEvent& event) {
62 DCHECK(host_->GetMenuItem()->GetMenuController()); 61 DCHECK(host_->GetMenuItem()->GetMenuController());
63 host_->GetMenuItem()->GetMenuController()->OnDragEnteredScrollButton( 62 host_->GetMenuItem()->GetMenuController()->OnDragEnteredScrollButton(
64 host_, is_up_); 63 host_, is_up_);
65 } 64 }
66 65
67 virtual int OnDragUpdated(const ui::DropTargetEvent& event) { 66 virtual int OnDragUpdated(const ui::DropTargetEvent& event) {
68 return ui::DragDropTypes::DRAG_NONE; 67 return ui::DragDropTypes::DRAG_NONE;
69 } 68 }
70 69
71 virtual void OnDragExited() { 70 virtual void OnDragExited() {
72 DCHECK(host_->GetMenuItem()->GetMenuController()); 71 DCHECK(host_->GetMenuItem()->GetMenuController());
73 host_->GetMenuItem()->GetMenuController()->OnDragExitedScrollButton(host_); 72 host_->GetMenuItem()->GetMenuController()->OnDragExitedScrollButton(host_);
74 } 73 }
75 74
76 virtual int OnPerformDrop(const ui::DropTargetEvent& event) { 75 virtual int OnPerformDrop(const ui::DropTargetEvent& event) {
77 return ui::DragDropTypes::DRAG_NONE; 76 return ui::DragDropTypes::DRAG_NONE;
78 } 77 }
79 78
80 virtual void OnPaint(gfx::Canvas* canvas) { 79 virtual void OnPaint(gfx::Canvas* canvas) {
81 const MenuConfig& config = host_->GetMenuItem()->GetMenuConfig(); 80 const MenuConfig& config = MenuConfig::instance();
82 81
83 // The background. 82 // The background.
84 gfx::Rect item_bounds(0, 0, width(), height()); 83 gfx::Rect item_bounds(0, 0, width(), height());
85 NativeTheme::ExtraParams extra; 84 NativeTheme::ExtraParams extra;
86 extra.menu_item.is_selected = false; 85 extra.menu_item.is_selected = false;
87 NativeTheme::instance()->Paint(canvas->sk_canvas(), 86 NativeTheme::instance()->Paint(canvas->sk_canvas(),
88 NativeTheme::kMenuItemBackground, 87 NativeTheme::kMenuItemBackground,
89 NativeTheme::kNormal, item_bounds, extra); 88 NativeTheme::kNormal, item_bounds, extra);
90 #if defined(OS_WIN) 89 #if defined(OS_WIN)
91 SkColor arrow_color = color_utils::GetSysSkColor(COLOR_MENUTEXT); 90 SkColor arrow_color = color_utils::GetSysSkColor(COLOR_MENUTEXT);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 scroll_up_button_ = new MenuScrollButton(content_view, true); 177 scroll_up_button_ = new MenuScrollButton(content_view, true);
179 scroll_down_button_ = new MenuScrollButton(content_view, false); 178 scroll_down_button_ = new MenuScrollButton(content_view, false);
180 AddChildView(scroll_up_button_); 179 AddChildView(scroll_up_button_);
181 AddChildView(scroll_down_button_); 180 AddChildView(scroll_down_button_);
182 181
183 scroll_view_ = new MenuScrollView(content_view); 182 scroll_view_ = new MenuScrollView(content_view);
184 AddChildView(scroll_view_); 183 AddChildView(scroll_view_);
185 184
186 MenuDelegate* delegate = content_view_->GetMenuItem()->GetDelegate(); 185 MenuDelegate* delegate = content_view_->GetMenuItem()->GetDelegate();
187 if (delegate) { 186 if (delegate) {
188 Border* border = delegate->CreateMenuBorder(); 187 set_border(delegate->CreateMenuBorder());
189 if (!border) {
190 const MenuConfig& menu_config =
191 content_view_->GetMenuItem()->GetMenuConfig();
192 border = Border::CreateEmptyBorder(
193 menu_config.submenu_vertical_margin_size,
194 menu_config.submenu_horizontal_margin_size,
195 menu_config.submenu_vertical_margin_size,
196 menu_config.submenu_horizontal_margin_size);
197 }
198 set_border(border);
199
200 set_background(delegate->CreateMenuBackground()); 188 set_background(delegate->CreateMenuBackground());
201 } 189 }
202 } 190 }
203 191
204 void MenuScrollViewContainer::OnPaintBackground(gfx::Canvas* canvas) { 192 void MenuScrollViewContainer::OnPaintBackground(gfx::Canvas* canvas) {
205 if (background()) { 193 if (background()) {
206 View::OnPaintBackground(canvas); 194 View::OnPaintBackground(canvas);
207 return; 195 return;
208 } 196 }
209 197
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 255
268 void MenuScrollViewContainer::OnBoundsChanged( 256 void MenuScrollViewContainer::OnBoundsChanged(
269 const gfx::Rect& previous_bounds) { 257 const gfx::Rect& previous_bounds) {
270 gfx::Size content_pref = scroll_view_->GetContents()->GetPreferredSize(); 258 gfx::Size content_pref = scroll_view_->GetContents()->GetPreferredSize();
271 scroll_up_button_->SetVisible(content_pref.height() > height()); 259 scroll_up_button_->SetVisible(content_pref.height() > height());
272 scroll_down_button_->SetVisible(content_pref.height() > height()); 260 scroll_down_button_->SetVisible(content_pref.height() > height());
273 Layout(); 261 Layout();
274 } 262 }
275 263
276 } // namespace views 264 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_item_view_win.cc ('k') | ui/views/controls/menu/menu_separator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698