OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/ui/libgtkui/native_theme_gtk3.h" | 5 #include "chrome/browser/ui/libgtkui/native_theme_gtk3.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "chrome/browser/ui/libgtkui/chrome_gtk_frame.h" | 9 #include "chrome/browser/ui/libgtkui/chrome_gtk_frame.h" |
10 #include "chrome/browser/ui/libgtkui/chrome_gtk_menu_subclasses.h" | 10 #include "chrome/browser/ui/libgtkui/chrome_gtk_menu_subclasses.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 RenderBackground(size, cr, context); | 46 RenderBackground(size, cr, context); |
47 break; | 47 break; |
48 case BG_RENDER_NONE: | 48 case BG_RENDER_NONE: |
49 break; | 49 break; |
50 } | 50 } |
51 if (render_frame) | 51 if (render_frame) |
52 gtk_render_frame(context, cr, 0, 0, size.width(), size.height()); | 52 gtk_render_frame(context, cr, 0, 0, size.width(), size.height()); |
53 return bitmap; | 53 return bitmap; |
54 } | 54 } |
55 | 55 |
56 void PaintWidget(SkCanvas* canvas, | 56 void PaintWidget(cc::PaintCanvas* canvas, |
57 const gfx::Rect& rect, | 57 const gfx::Rect& rect, |
58 GtkStyleContext* context, | 58 GtkStyleContext* context, |
59 BackgroundRenderMode bg_mode, | 59 BackgroundRenderMode bg_mode, |
60 bool render_frame) { | 60 bool render_frame) { |
61 canvas->drawBitmap( | 61 canvas->drawBitmap( |
62 GetWidgetBitmap(rect.size(), context, bg_mode, render_frame), rect.x(), | 62 GetWidgetBitmap(rect.size(), context, bg_mode, render_frame), rect.x(), |
63 rect.y()); | 63 rect.y()); |
64 } | 64 } |
65 | 65 |
66 GtkStateFlags StateToStateFlags(NativeThemeGtk3::State state) { | 66 GtkStateFlags StateToStateFlags(NativeThemeGtk3::State state) { |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 State state, | 447 State state, |
448 const gfx::Rect& rect) const { | 448 const gfx::Rect& rect) const { |
449 auto context = GetStyleContextFromCss( | 449 auto context = GetStyleContextFromCss( |
450 GtkVersionCheck(3, 19, 2) | 450 GtkVersionCheck(3, 19, 2) |
451 ? "GtkScrolledWindow#scrolledwindow #junction" | 451 ? "GtkScrolledWindow#scrolledwindow #junction" |
452 : "GtkScrolledWindow.scrolledwindow.scrollbars-junction"); | 452 : "GtkScrolledWindow.scrolledwindow.scrollbars-junction"); |
453 PaintWidget(canvas, rect, context, BG_RENDER_NORMAL, true); | 453 PaintWidget(canvas, rect, context, BG_RENDER_NORMAL, true); |
454 } | 454 } |
455 | 455 |
456 void NativeThemeGtk3::PaintMenuPopupBackground( | 456 void NativeThemeGtk3::PaintMenuPopupBackground( |
457 SkCanvas* canvas, | 457 cc::PaintCanvas* canvas, |
458 const gfx::Size& size, | 458 const gfx::Size& size, |
459 const MenuBackgroundExtraParams& menu_background) const { | 459 const MenuBackgroundExtraParams& menu_background) const { |
460 PaintWidget(canvas, gfx::Rect(size), GetStyleContextFromCss("GtkMenu#menu"), | 460 PaintWidget(canvas, gfx::Rect(size), GetStyleContextFromCss("GtkMenu#menu"), |
461 BG_RENDER_RECURSIVE, false); | 461 BG_RENDER_RECURSIVE, false); |
462 } | 462 } |
463 | 463 |
464 void NativeThemeGtk3::PaintMenuItemBackground( | 464 void NativeThemeGtk3::PaintMenuItemBackground( |
465 SkCanvas* canvas, | 465 cc::PaintCanvas* canvas, |
466 State state, | 466 State state, |
467 const gfx::Rect& rect, | 467 const gfx::Rect& rect, |
468 const MenuItemExtraParams& menu_item) const { | 468 const MenuItemExtraParams& menu_item) const { |
469 auto context = GetStyleContextFromCss("GtkMenu#menu GtkMenuItem#menuitem"); | 469 auto context = GetStyleContextFromCss("GtkMenu#menu GtkMenuItem#menuitem"); |
470 gtk_style_context_set_state(context, StateToStateFlags(state)); | 470 gtk_style_context_set_state(context, StateToStateFlags(state)); |
471 PaintWidget(canvas, rect, context, BG_RENDER_NORMAL, true); | 471 PaintWidget(canvas, rect, context, BG_RENDER_NORMAL, true); |
472 } | 472 } |
473 | 473 |
474 void NativeThemeGtk3::PaintMenuSeparator( | 474 void NativeThemeGtk3::PaintMenuSeparator( |
475 SkCanvas* canvas, | 475 SkCanvas* canvas, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 PaintWidget(canvas, gfx::Rect(x, y, w, h), context, BG_RENDER_NONE, true); | 522 PaintWidget(canvas, gfx::Rect(x, y, w, h), context, BG_RENDER_NONE, true); |
523 } else { | 523 } else { |
524 SkPaint paint; | 524 SkPaint paint; |
525 paint.setColor(SkColorFromStyleContext(context)); | 525 paint.setColor(SkColorFromStyleContext(context)); |
526 canvas->drawLine(x, y, x + w, y, paint); | 526 canvas->drawLine(x, y, x + w, y, paint); |
527 } | 527 } |
528 } | 528 } |
529 } | 529 } |
530 | 530 |
531 void NativeThemeGtk3::PaintFrameTopArea( | 531 void NativeThemeGtk3::PaintFrameTopArea( |
532 SkCanvas* canvas, | 532 cc::PaintCanvas* canvas, |
533 State state, | 533 State state, |
534 const gfx::Rect& rect, | 534 const gfx::Rect& rect, |
535 const FrameTopAreaExtraParams& frame_top_area) const { | 535 const FrameTopAreaExtraParams& frame_top_area) const { |
536 auto context = GetStyleContextFromCss(frame_top_area.use_custom_frame | 536 auto context = GetStyleContextFromCss(frame_top_area.use_custom_frame |
537 ? "#headerbar.header-bar.titlebar" | 537 ? "#headerbar.header-bar.titlebar" |
538 : "GtkMenuBar#menubar"); | 538 : "GtkMenuBar#menubar"); |
539 RemoveBorders(context); | 539 RemoveBorders(context); |
540 gtk_style_context_set_state(context, frame_top_area.is_active | 540 gtk_style_context_set_state(context, frame_top_area.is_active |
541 ? GTK_STATE_FLAG_NORMAL | 541 ? GTK_STATE_FLAG_NORMAL |
542 : GTK_STATE_FLAG_BACKDROP); | 542 : GTK_STATE_FLAG_BACKDROP); |
543 | 543 |
544 SkBitmap bitmap = | 544 SkBitmap bitmap = |
545 GetWidgetBitmap(rect.size(), context, BG_RENDER_RECURSIVE, false); | 545 GetWidgetBitmap(rect.size(), context, BG_RENDER_RECURSIVE, false); |
546 | 546 |
547 if (frame_top_area.incognito) { | 547 if (frame_top_area.incognito) { |
548 bitmap = SkBitmapOperations::CreateHSLShiftedBitmap( | 548 bitmap = SkBitmapOperations::CreateHSLShiftedBitmap( |
549 bitmap, kDefaultTintFrameIncognito); | 549 bitmap, kDefaultTintFrameIncognito); |
550 } | 550 } |
551 | 551 |
552 canvas->drawBitmap(bitmap, rect.x(), rect.y()); | 552 canvas->drawBitmap(bitmap, rect.x(), rect.y()); |
553 } | 553 } |
554 | 554 |
555 } // namespace libgtkui | 555 } // namespace libgtkui |
OLD | NEW |