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

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

Issue 12041085: Fix menu corners: the menu background was being painted as a rect when in fact, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch 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
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 #include "third_party/skia/include/core/SkPaint.h" 7 #include "third_party/skia/include/core/SkPaint.h"
8 #include "third_party/skia/include/core/SkPath.h" 8 #include "third_party/skia/include/core/SkPath.h"
9 #include "ui/base/accessibility/accessible_view_state.h" 9 #include "ui/base/accessibility/accessible_view_state.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
11 #include "ui/native_theme/native_theme.h" 11 #include "ui/native_theme/native_theme.h"
12 #include "ui/views/border.h" 12 #include "ui/views/border.h"
13 #include "ui/views/controls/menu/menu_config.h" 13 #include "ui/views/controls/menu/menu_config.h"
14 #include "ui/views/controls/menu/menu_controller.h" 14 #include "ui/views/controls/menu/menu_controller.h"
15 #include "ui/views/controls/menu/menu_item_view.h" 15 #include "ui/views/controls/menu/menu_item_view.h"
16 #include "ui/views/controls/menu/submenu_view.h" 16 #include "ui/views/controls/menu/submenu_view.h"
17 #include "ui/views/round_rect_painter.h" 17 #include "ui/views/round_rect_painter.h"
18 18
19 using ui::NativeTheme; 19 using ui::NativeTheme;
20 20
21 // Height of the scroll arrow. 21 // Height of the scroll arrow.
22 // This goes up to 4 with large fonts, but this is close enough for now. 22 // This goes up to 4 with large fonts, but this is close enough for now.
23 static const int scroll_arrow_height = 3; 23 static const int scroll_arrow_height = 3;
24 24
25 namespace views { 25 namespace views {
26 26
27 namespace { 27 namespace {
28 28
29 static const int kBorderPaddingDueToRoundedCorners = 1;
30
29 // MenuScrollButton ------------------------------------------------------------ 31 // MenuScrollButton ------------------------------------------------------------
30 32
31 // MenuScrollButton is used for the scroll buttons when not all menu items fit 33 // MenuScrollButton is used for the scroll buttons when not all menu items fit
32 // on screen. MenuScrollButton forwards appropriate events to the 34 // on screen. MenuScrollButton forwards appropriate events to the
33 // MenuController. 35 // MenuController.
34 36
35 class MenuScrollButton : public View { 37 class MenuScrollButton : public View {
36 public: 38 public:
37 MenuScrollButton(SubmenuView* host, bool is_up) 39 MenuScrollButton(SubmenuView* host, bool is_up)
38 : host_(host), 40 : host_(host),
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // Get the name from the submenu view. 246 // Get the name from the submenu view.
245 content_view_->GetAccessibleState(state); 247 content_view_->GetAccessibleState(state);
246 248
247 // Now change the role. 249 // Now change the role.
248 state->role = ui::AccessibilityTypes::ROLE_MENUBAR; 250 state->role = ui::AccessibilityTypes::ROLE_MENUBAR;
249 // Some AT (like NVDA) will not process focus events on menu item children 251 // Some AT (like NVDA) will not process focus events on menu item children
250 // unless a parent claims to be focused. 252 // unless a parent claims to be focused.
251 state->state = ui::AccessibilityTypes::STATE_FOCUSED; 253 state->state = ui::AccessibilityTypes::STATE_FOCUSED;
252 } 254 }
253 255
256 gfx::Insets MenuScrollViewContainer::GetInsets() const {
257 gfx::Insets insets = View::GetInsets();
258 if (MenuConfig::instance(ui::NativeTheme::instance()).has_rounded_corners) {
sky 2013/01/25 16:10:52 ui::NativeTheme::instance() -> GetNativeTheme()
varunjain 2013/01/25 18:50:40 not needed since I am using MenuConfig now.
259 insets += gfx::Insets(kBorderPaddingDueToRoundedCorners,
260 kBorderPaddingDueToRoundedCorners,
261 kBorderPaddingDueToRoundedCorners,
262 kBorderPaddingDueToRoundedCorners);
263 }
264 return insets;
265 }
266
254 void MenuScrollViewContainer::OnBoundsChanged( 267 void MenuScrollViewContainer::OnBoundsChanged(
255 const gfx::Rect& previous_bounds) { 268 const gfx::Rect& previous_bounds) {
256 gfx::Size content_pref = scroll_view_->GetContents()->GetPreferredSize(); 269 gfx::Size content_pref = scroll_view_->GetContents()->GetPreferredSize();
257 scroll_up_button_->SetVisible(content_pref.height() > height()); 270 scroll_up_button_->SetVisible(content_pref.height() > height());
258 scroll_down_button_->SetVisible(content_pref.height() > height()); 271 scroll_down_button_->SetVisible(content_pref.height() > height());
259 Layout(); 272 Layout();
260 } 273 }
261 274
262 } // namespace views 275 } // namespace views
OLDNEW
« ui/views/controls/menu/menu_host.cc ('K') | « ui/views/controls/menu/menu_scroll_view_container.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698