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

Side by Side Diff: ui/native_theme/native_theme_win.cc

Issue 2655553003: Native themes: Add menu separator part (Closed)
Patch Set: Created 3 years, 10 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
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/native_theme/native_theme_win.h" 5 #include "ui/native_theme/native_theme_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <uxtheme.h> 9 #include <uxtheme.h>
10 #include <vsstyle.h> 10 #include <vsstyle.h>
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 const gfx::Rect& rect, 257 const gfx::Rect& rect,
258 const ExtraParams& extra) const { 258 const ExtraParams& extra) const {
259 if (rect.IsEmpty()) 259 if (rect.IsEmpty())
260 return; 260 return;
261 261
262 switch (part) { 262 switch (part) {
263 case kMenuPopupGutter: 263 case kMenuPopupGutter:
264 PaintMenuGutter(canvas, rect); 264 PaintMenuGutter(canvas, rect);
265 return; 265 return;
266 case kMenuPopupSeparator: 266 case kMenuPopupSeparator:
267 PaintMenuSeparator(canvas, rect); 267 PaintMenuSeparator(canvas, rect, extra.menu_separator);
268 return; 268 return;
269 case kMenuPopupBackground: 269 case kMenuPopupBackground:
270 PaintMenuBackground(canvas, rect); 270 PaintMenuBackground(canvas, rect);
271 return; 271 return;
272 case kMenuItemBackground: 272 case kMenuItemBackground:
273 CommonThemePaintMenuItemBackground(this, canvas, state, rect, 273 CommonThemePaintMenuItemBackground(this, canvas, state, rect,
274 extra.menu_item); 274 extra.menu_item);
275 return; 275 return;
276 default: 276 default:
277 break; 277 break;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 UpdateSystemColors(); 367 UpdateSystemColors();
368 is_using_high_contrast_valid_ = false; 368 is_using_high_contrast_valid_ = false;
369 NotifyObservers(); 369 NotifyObservers();
370 } 370 }
371 371
372 void NativeThemeWin::UpdateSystemColors() { 372 void NativeThemeWin::UpdateSystemColors() {
373 for (int kSystemColor : kSystemColors) 373 for (int kSystemColor : kSystemColors)
374 system_colors_[kSystemColor] = color_utils::GetSysSkColor(kSystemColor); 374 system_colors_[kSystemColor] = color_utils::GetSysSkColor(kSystemColor);
375 } 375 }
376 376
377 void NativeThemeWin::PaintMenuSeparator(SkCanvas* canvas, 377 void NativeThemeWin::PaintMenuSeparator(
378 const gfx::Rect& rect) const { 378 SkCanvas* canvas,
379 const gfx::Rect& rect,
380 const MenuSeparatorExtraParams& extra) const {
379 SkPaint paint; 381 SkPaint paint;
380 paint.setColor(GetSystemColor(NativeTheme::kColorId_MenuSeparatorColor)); 382 paint.setColor(GetSystemColor(NativeTheme::kColorId_MenuSeparatorColor));
381 int position_y = rect.y() + rect.height() / 2; 383 int position_y = extra.paint_rect->y() + extra.paint_rect->height() / 2;
382 canvas->drawLine(rect.x(), position_y, rect.right(), position_y, paint); 384 canvas->drawLine(extra.paint_rect->x(), position_y, extra.paint_rect->right(),
385 position_y, paint);
383 } 386 }
384 387
385 void NativeThemeWin::PaintMenuGutter(SkCanvas* canvas, 388 void NativeThemeWin::PaintMenuGutter(SkCanvas* canvas,
386 const gfx::Rect& rect) const { 389 const gfx::Rect& rect) const {
387 SkPaint paint; 390 SkPaint paint;
388 paint.setColor(GetSystemColor(NativeTheme::kColorId_MenuSeparatorColor)); 391 paint.setColor(GetSystemColor(NativeTheme::kColorId_MenuSeparatorColor));
389 int position_x = rect.x() + rect.width() / 2; 392 int position_x = rect.x() + rect.width() / 2;
390 canvas->drawLine(position_x, rect.y(), position_x, rect.bottom(), paint); 393 canvas->drawLine(position_x, rect.y(), position_x, rect.bottom(), paint);
391 } 394 }
392 395
(...skipping 29 matching lines...) Expand all
422 case kMenuPopupArrow: 425 case kMenuPopupArrow:
423 PaintMenuArrow(hdc, state, rect, extra.menu_arrow); 426 PaintMenuArrow(hdc, state, rect, extra.menu_arrow);
424 return; 427 return;
425 case kMenuPopupBackground: 428 case kMenuPopupBackground:
426 PaintMenuBackground(hdc, rect); 429 PaintMenuBackground(hdc, rect);
427 return; 430 return;
428 case kMenuPopupGutter: 431 case kMenuPopupGutter:
429 PaintMenuGutter(hdc, rect); 432 PaintMenuGutter(hdc, rect);
430 return; 433 return;
431 case kMenuPopupSeparator: 434 case kMenuPopupSeparator:
432 PaintMenuSeparator(hdc, rect); 435 PaintMenuSeparator(hdc, rect, extra.menu_separator);
433 return; 436 return;
434 case kMenuItemBackground: 437 case kMenuItemBackground:
435 PaintMenuItemBackground(hdc, state, rect, extra.menu_item); 438 PaintMenuItemBackground(hdc, state, rect, extra.menu_item);
436 return; 439 return;
437 case kProgressBar: 440 case kProgressBar:
438 PaintProgressBar(hdc, rect, extra.progress_bar); 441 PaintProgressBar(hdc, rect, extra.progress_bar);
439 return; 442 return;
440 case kPushButton: 443 case kPushButton:
441 PaintPushButton(hdc, part, state, rect, extra.button); 444 PaintPushButton(hdc, part, state, rect, extra.button);
442 return; 445 return;
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 InflateRect(&inner_rect, -padding, -padding); 864 InflateRect(&inner_rect, -padding, -padding);
862 int color_index = state == kDisabled ? COLOR_GRAYTEXT : COLOR_WINDOWTEXT; 865 int color_index = state == kDisabled ? COLOR_GRAYTEXT : COLOR_WINDOWTEXT;
863 FillRect(hdc, &inner_rect, GetSysColorBrush(color_index)); 866 FillRect(hdc, &inner_rect, GetSysColorBrush(color_index));
864 } 867 }
865 868
866 return S_OK; 869 return S_OK;
867 } 870 }
868 871
869 HRESULT NativeThemeWin::PaintMenuSeparator( 872 HRESULT NativeThemeWin::PaintMenuSeparator(
870 HDC hdc, 873 HDC hdc,
871 const gfx::Rect& rect) const { 874 const gfx::Rect& rect,
872 RECT rect_win = rect.ToRECT(); 875 const MenuSeparatorExtraParams& extra) const {
876 RECT rect_win = extra.paint_rect->ToRECT();
873 877
874 HANDLE handle = GetThemeHandle(MENU); 878 HANDLE handle = GetThemeHandle(MENU);
875 if (handle && draw_theme_) { 879 if (handle && draw_theme_) {
876 // Delta is needed for non-classic to move separator up slightly. 880 // Delta is needed for non-classic to move separator up slightly.
877 --rect_win.top; 881 --rect_win.top;
878 --rect_win.bottom; 882 --rect_win.bottom;
879 return draw_theme_(handle, hdc, MENU_POPUPSEPARATOR, MPI_NORMAL, &rect_win, 883 return draw_theme_(handle, hdc, MENU_POPUPSEPARATOR, MPI_NORMAL, &rect_win,
880 NULL); 884 NULL);
881 } 885 }
882 886
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 break; 2106 break;
2103 case LAST: 2107 case LAST:
2104 NOTREACHED(); 2108 NOTREACHED();
2105 break; 2109 break;
2106 } 2110 }
2107 theme_handles_[theme_name] = handle; 2111 theme_handles_[theme_name] = handle;
2108 return handle; 2112 return handle;
2109 } 2113 }
2110 2114
2111 } // namespace ui 2115 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698