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

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

Issue 10702136: Support high dpi in menu scroll arrow, submenu arrow and drag_utils. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort includes Created 8 years, 5 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_image_util.cc ('k') | no next file » | 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>
11 #endif 11 #endif
12 12
13 #include "third_party/skia/include/core/SkPaint.h"
14 #include "third_party/skia/include/core/SkPath.h"
13 #include "ui/base/accessibility/accessible_view_state.h" 15 #include "ui/base/accessibility/accessible_view_state.h"
14 #include "ui/base/native_theme/native_theme.h" 16 #include "ui/base/native_theme/native_theme.h"
15 #include "ui/gfx/canvas.h" 17 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/color_utils.h" 18 #include "ui/gfx/color_utils.h"
17 #include "ui/views/border.h" 19 #include "ui/views/border.h"
18 #include "ui/views/controls/menu/menu_config.h" 20 #include "ui/views/controls/menu/menu_config.h"
19 #include "ui/views/controls/menu/menu_controller.h" 21 #include "ui/views/controls/menu/menu_controller.h"
20 #include "ui/views/controls/menu/menu_item_view.h" 22 #include "ui/views/controls/menu/menu_item_view.h"
21 #include "ui/views/controls/menu/submenu_view.h" 23 #include "ui/views/controls/menu/submenu_view.h"
22 24
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 NativeTheme::kNormal, item_bounds, extra); 88 NativeTheme::kNormal, item_bounds, extra);
87 #if defined(OS_WIN) 89 #if defined(OS_WIN)
88 SkColor arrow_color = color_utils::GetSysSkColor(COLOR_MENUTEXT); 90 SkColor arrow_color = color_utils::GetSysSkColor(COLOR_MENUTEXT);
89 #else 91 #else
90 SkColor arrow_color = SK_ColorBLACK; 92 SkColor arrow_color = SK_ColorBLACK;
91 #endif 93 #endif
92 94
93 // Then the arrow. 95 // Then the arrow.
94 int x = width() / 2; 96 int x = width() / 2;
95 int y = (height() - config.scroll_arrow_height) / 2; 97 int y = (height() - config.scroll_arrow_height) / 2;
96 int delta_y = 1; 98
99 int x_left = x - config.scroll_arrow_height;
100 int x_right = x + config.scroll_arrow_height;
101 int y_bottom;
102
97 if (!is_up_) { 103 if (!is_up_) {
98 delta_y = -1; 104 y_bottom = y;
99 y += config.scroll_arrow_height; 105 y = y_bottom + config.scroll_arrow_height;
106 } else {
107 y_bottom = y + config.scroll_arrow_height;
100 } 108 }
101 for (int i = 0; i < config.scroll_arrow_height; ++i, --x, y += delta_y) 109 SkPath path;
102 canvas->FillRect(gfx::Rect(x, y, (i * 2) + 1, 1), arrow_color); 110 path.setFillType(SkPath::kWinding_FillType);
111 path.moveTo(SkIntToScalar(x), SkIntToScalar(y));
112 path.lineTo(SkIntToScalar(x_left), SkIntToScalar(y_bottom));
113 path.lineTo(SkIntToScalar(x_right), SkIntToScalar(y_bottom));
114 path.lineTo(SkIntToScalar(x), SkIntToScalar(y));
115 SkPaint paint;
116 paint.setStyle(SkPaint::kFill_Style);
117 paint.setAntiAlias(true);
118 paint.setColor(arrow_color);
119 canvas->DrawPath(path, paint);
103 } 120 }
104 121
105 private: 122 private:
106 // SubmenuView we were created for. 123 // SubmenuView we were created for.
107 SubmenuView* host_; 124 SubmenuView* host_;
108 125
109 // Direction of the button. 126 // Direction of the button.
110 bool is_up_; 127 bool is_up_;
111 128
112 // Preferred height. 129 // Preferred height.
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 255
239 void MenuScrollViewContainer::OnBoundsChanged( 256 void MenuScrollViewContainer::OnBoundsChanged(
240 const gfx::Rect& previous_bounds) { 257 const gfx::Rect& previous_bounds) {
241 gfx::Size content_pref = scroll_view_->GetContents()->GetPreferredSize(); 258 gfx::Size content_pref = scroll_view_->GetContents()->GetPreferredSize();
242 scroll_up_button_->SetVisible(content_pref.height() > height()); 259 scroll_up_button_->SetVisible(content_pref.height() > height());
243 scroll_down_button_->SetVisible(content_pref.height() > height()); 260 scroll_down_button_->SetVisible(content_pref.height() > height());
244 Layout(); 261 Layout();
245 } 262 }
246 263
247 } // namespace views 264 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_image_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698