OLD | NEW |
---|---|
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 "ui/base/accessibility/accessible_view_state.h" | 13 #include "ui/base/accessibility/accessible_view_state.h" |
14 #include "ui/base/native_theme/native_theme.h" | 14 #include "ui/base/native_theme/native_theme.h" |
15 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
16 #include "ui/gfx/color_utils.h" | 16 #include "ui/gfx/color_utils.h" |
17 #include "ui/views/border.h" | 17 #include "ui/views/border.h" |
18 #include "ui/views/controls/menu/menu_config.h" | 18 #include "ui/views/controls/menu/menu_config.h" |
19 #include "ui/views/controls/menu/menu_controller.h" | 19 #include "ui/views/controls/menu/menu_controller.h" |
20 #include "ui/views/controls/menu/menu_item_view.h" | 20 #include "ui/views/controls/menu/menu_item_view.h" |
21 #include "ui/views/controls/menu/submenu_view.h" | 21 #include "ui/views/controls/menu/submenu_view.h" |
22 | 22 |
23 #include "third_party/skia/include/core/SkPath.h" | |
Ben Goodger (Google)
2012/07/12 03:12:45
sort with others
oshima
2012/07/12 04:00:19
Done.
| |
24 #include "third_party/skia/include/core/SkPaint.h" | |
25 | |
23 using ui::NativeTheme; | 26 using ui::NativeTheme; |
24 | 27 |
25 // Height of the scroll arrow. | 28 // Height of the scroll arrow. |
26 // This goes up to 4 with large fonts, but this is close enough for now. | 29 // This goes up to 4 with large fonts, but this is close enough for now. |
27 static const int scroll_arrow_height = 3; | 30 static const int scroll_arrow_height = 3; |
28 | 31 |
29 namespace views { | 32 namespace views { |
30 | 33 |
31 namespace { | 34 namespace { |
32 | 35 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 NativeTheme::kNormal, item_bounds, extra); | 89 NativeTheme::kNormal, item_bounds, extra); |
87 #if defined(OS_WIN) | 90 #if defined(OS_WIN) |
88 SkColor arrow_color = color_utils::GetSysSkColor(COLOR_MENUTEXT); | 91 SkColor arrow_color = color_utils::GetSysSkColor(COLOR_MENUTEXT); |
89 #else | 92 #else |
90 SkColor arrow_color = SK_ColorBLACK; | 93 SkColor arrow_color = SK_ColorBLACK; |
91 #endif | 94 #endif |
92 | 95 |
93 // Then the arrow. | 96 // Then the arrow. |
94 int x = width() / 2; | 97 int x = width() / 2; |
95 int y = (height() - config.scroll_arrow_height) / 2; | 98 int y = (height() - config.scroll_arrow_height) / 2; |
96 int delta_y = 1; | 99 |
100 int x_left = x - config.scroll_arrow_height; | |
101 int x_right = x + config.scroll_arrow_height; | |
102 int y_bottom; | |
103 | |
97 if (!is_up_) { | 104 if (!is_up_) { |
98 delta_y = -1; | 105 y_bottom = y; |
99 y += config.scroll_arrow_height; | 106 y = y_bottom + config.scroll_arrow_height; |
107 } else { | |
108 y_bottom = y + config.scroll_arrow_height; | |
100 } | 109 } |
101 for (int i = 0; i < config.scroll_arrow_height; ++i, --x, y += delta_y) | 110 SkPath path; |
102 canvas->FillRect(gfx::Rect(x, y, (i * 2) + 1, 1), arrow_color); | 111 path.setFillType(SkPath::kWinding_FillType); |
112 path.moveTo(SkIntToScalar(x), SkIntToScalar(y)); | |
113 path.lineTo(SkIntToScalar(x_left), SkIntToScalar(y_bottom)); | |
114 path.lineTo(SkIntToScalar(x_right), SkIntToScalar(y_bottom)); | |
115 path.lineTo(SkIntToScalar(x), SkIntToScalar(y)); | |
116 SkPaint paint; | |
117 paint.setStyle(SkPaint::kFill_Style); | |
118 paint.setAntiAlias(true); | |
119 paint.setColor(arrow_color); | |
120 canvas->DrawPath(path, paint); | |
103 } | 121 } |
104 | 122 |
105 private: | 123 private: |
106 // SubmenuView we were created for. | 124 // SubmenuView we were created for. |
107 SubmenuView* host_; | 125 SubmenuView* host_; |
108 | 126 |
109 // Direction of the button. | 127 // Direction of the button. |
110 bool is_up_; | 128 bool is_up_; |
111 | 129 |
112 // Preferred height. | 130 // Preferred height. |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 | 256 |
239 void MenuScrollViewContainer::OnBoundsChanged( | 257 void MenuScrollViewContainer::OnBoundsChanged( |
240 const gfx::Rect& previous_bounds) { | 258 const gfx::Rect& previous_bounds) { |
241 gfx::Size content_pref = scroll_view_->GetContents()->GetPreferredSize(); | 259 gfx::Size content_pref = scroll_view_->GetContents()->GetPreferredSize(); |
242 scroll_up_button_->SetVisible(content_pref.height() > height()); | 260 scroll_up_button_->SetVisible(content_pref.height() > height()); |
243 scroll_down_button_->SetVisible(content_pref.height() > height()); | 261 scroll_down_button_->SetVisible(content_pref.height() > height()); |
244 Layout(); | 262 Layout(); |
245 } | 263 } |
246 | 264 |
247 } // namespace views | 265 } // namespace views |
OLD | NEW |