| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/controls/menu/menu_scroll_view_container.h" | 5 #include "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 "gfx/canvas.h" | 13 #include "gfx/canvas_skia.h" |
| 14 #include "gfx/color_utils.h" | 14 #include "gfx/color_utils.h" |
| 15 #include "views/border.h" | 15 #include "views/border.h" |
| 16 #include "third_party/skia/include/effects/SkGradientShader.h" | 16 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 17 #include "views/controls/menu/menu_config.h" | 17 #include "views/controls/menu/menu_config.h" |
| 18 #include "views/controls/menu/menu_controller.h" | 18 #include "views/controls/menu/menu_controller.h" |
| 19 #include "views/controls/menu/menu_item_view.h" | 19 #include "views/controls/menu/menu_item_view.h" |
| 20 #include "views/controls/menu/submenu_view.h" | 20 #include "views/controls/menu/submenu_view.h" |
| 21 | 21 |
| 22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
| 23 #include "gfx/native_theme_win.h" | 23 #include "gfx/native_theme_win.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 76 } |
| 77 | 77 |
| 78 virtual int OnPerformDrop(const DropTargetEvent& event) { | 78 virtual int OnPerformDrop(const DropTargetEvent& event) { |
| 79 return DragDropTypes::DRAG_NONE; | 79 return DragDropTypes::DRAG_NONE; |
| 80 } | 80 } |
| 81 | 81 |
| 82 virtual void Paint(gfx::Canvas* canvas) { | 82 virtual void Paint(gfx::Canvas* canvas) { |
| 83 const MenuConfig& config = MenuConfig::instance(); | 83 const MenuConfig& config = MenuConfig::instance(); |
| 84 | 84 |
| 85 #if defined(OS_WIN) | 85 #if defined(OS_WIN) |
| 86 HDC dc = canvas->beginPlatformPaint(); | 86 HDC dc = canvas->AsCanvasSkia()->beginPlatformPaint(); |
| 87 | 87 |
| 88 // The background. | 88 // The background. |
| 89 RECT item_bounds = { 0, 0, width(), height() }; | 89 RECT item_bounds = { 0, 0, width(), height() }; |
| 90 NativeTheme::instance()->PaintMenuItemBackground( | 90 NativeTheme::instance()->PaintMenuItemBackground( |
| 91 NativeTheme::MENU, dc, MENU_POPUPITEM, MPI_NORMAL, false, | 91 NativeTheme::MENU, dc, MENU_POPUPITEM, MPI_NORMAL, false, |
| 92 &item_bounds); | 92 &item_bounds); |
| 93 canvas->endPlatformPaint(); | 93 canvas->AsCanvasSkia()->endPlatformPaint(); |
| 94 | 94 |
| 95 SkColor arrow_color = color_utils::GetSysSkColor(COLOR_MENUTEXT); | 95 SkColor arrow_color = color_utils::GetSysSkColor(COLOR_MENUTEXT); |
| 96 #else | 96 #else |
| 97 SkColor arrow_color = SK_ColorBLACK; | 97 SkColor arrow_color = SK_ColorBLACK; |
| 98 #endif | 98 #endif |
| 99 | 99 |
| 100 // Then the arrow. | 100 // Then the arrow. |
| 101 int x = width() / 2; | 101 int x = width() / 2; |
| 102 int y = (height() - config.scroll_arrow_height) / 2; | 102 int y = (height() - config.scroll_arrow_height) / 2; |
| 103 int delta_y = 1; | 103 int delta_y = 1; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 SubmenuView::kSubmenuBorderSize)); | 178 SubmenuView::kSubmenuBorderSize)); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void MenuScrollViewContainer::PaintBackground(gfx::Canvas* canvas) { | 181 void MenuScrollViewContainer::PaintBackground(gfx::Canvas* canvas) { |
| 182 if (background()) { | 182 if (background()) { |
| 183 View::PaintBackground(canvas); | 183 View::PaintBackground(canvas); |
| 184 return; | 184 return; |
| 185 } | 185 } |
| 186 | 186 |
| 187 #if defined(OS_WIN) | 187 #if defined(OS_WIN) |
| 188 HDC dc = canvas->beginPlatformPaint(); | 188 HDC dc = canvas->AsCanvasSkia()->beginPlatformPaint(); |
| 189 RECT bounds = {0, 0, width(), height()}; | 189 RECT bounds = {0, 0, width(), height()}; |
| 190 NativeTheme::instance()->PaintMenuBackground( | 190 NativeTheme::instance()->PaintMenuBackground( |
| 191 NativeTheme::MENU, dc, MENU_POPUPBACKGROUND, 0, &bounds); | 191 NativeTheme::MENU, dc, MENU_POPUPBACKGROUND, 0, &bounds); |
| 192 canvas->endPlatformPaint(); | 192 canvas->AsCanvasSkia()->endPlatformPaint(); |
| 193 #elif defined(OS_CHROMEOS) | 193 #elif defined(OS_CHROMEOS) |
| 194 static const SkColor kGradientColors[2] = { | 194 static const SkColor kGradientColors[2] = { |
| 195 SK_ColorWHITE, | 195 SK_ColorWHITE, |
| 196 SkColorSetRGB(0xF0, 0xF0, 0xF0) | 196 SkColorSetRGB(0xF0, 0xF0, 0xF0) |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 static const SkScalar kGradientPoints[2] = { | 199 static const SkScalar kGradientPoints[2] = { |
| 200 SkIntToScalar(0), | 200 SkIntToScalar(0), |
| 201 SkIntToScalar(1) | 201 SkIntToScalar(1) |
| 202 }; | 202 }; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 213 SkPaint paint; | 213 SkPaint paint; |
| 214 paint.setShader(shader); | 214 paint.setShader(shader); |
| 215 shader->unref(); | 215 shader->unref(); |
| 216 | 216 |
| 217 paint.setStyle(SkPaint::kFill_Style); | 217 paint.setStyle(SkPaint::kFill_Style); |
| 218 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 218 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
| 219 | 219 |
| 220 canvas->FillRectInt(0, 0, width(), height(), paint); | 220 canvas->FillRectInt(0, 0, width(), height(), paint); |
| 221 #else | 221 #else |
| 222 // This is the same as COLOR_TOOLBAR. | 222 // This is the same as COLOR_TOOLBAR. |
| 223 canvas->drawColor(SkColorSetRGB(210, 225, 246), SkXfermode::kSrc_Mode); | 223 canvas->AsCanvasSkia()->drawColor(SkColorSetRGB(210, 225, 246), |
| 224 SkXfermode::kSrc_Mode); |
| 224 #endif | 225 #endif |
| 225 } | 226 } |
| 226 | 227 |
| 227 void MenuScrollViewContainer::Layout() { | 228 void MenuScrollViewContainer::Layout() { |
| 228 gfx::Insets insets = GetInsets(); | 229 gfx::Insets insets = GetInsets(); |
| 229 int x = insets.left(); | 230 int x = insets.left(); |
| 230 int y = insets.top(); | 231 int y = insets.top(); |
| 231 int width = View::width() - insets.width(); | 232 int width = View::width() - insets.width(); |
| 232 int content_height = height() - insets.height(); | 233 int content_height = height() - insets.height(); |
| 233 if (!scroll_up_button_->IsVisible()) { | 234 if (!scroll_up_button_->IsVisible()) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 } | 267 } |
| 267 | 268 |
| 268 bool MenuScrollViewContainer::GetAccessibleRole( | 269 bool MenuScrollViewContainer::GetAccessibleRole( |
| 269 AccessibilityTypes::Role* role) { | 270 AccessibilityTypes::Role* role) { |
| 270 DCHECK(role); | 271 DCHECK(role); |
| 271 *role = AccessibilityTypes::ROLE_MENUPOPUP; | 272 *role = AccessibilityTypes::ROLE_MENUPOPUP; |
| 272 return true; | 273 return true; |
| 273 } | 274 } |
| 274 | 275 |
| 275 } // namespace views | 276 } // namespace views |
| OLD | NEW |