| 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" |
| 11 #include "chrome/browser/ui/libgtkui/gtk_util.h" | 11 #include "chrome/browser/ui/libgtkui/gtk_util.h" |
| 12 #include "chrome/browser/ui/libgtkui/skia_utils_gtk.h" | 12 #include "chrome/browser/ui/libgtkui/skia_utils_gtk.h" |
| 13 #include "ui/gfx/color_palette.h" | 13 #include "ui/gfx/color_palette.h" |
| 14 #include "ui/gfx/color_utils.h" | 14 #include "ui/gfx/color_utils.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
| 16 #include "ui/gfx/skbitmap_operations.h" | 16 #include "ui/gfx/skbitmap_operations.h" |
| 17 #include "ui/gfx/skia_util.h" |
| 17 #include "ui/native_theme/native_theme_dark_aura.h" | 18 #include "ui/native_theme/native_theme_dark_aura.h" |
| 18 | 19 |
| 19 namespace libgtkui { | 20 namespace libgtkui { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 enum BackgroundRenderMode { | 24 enum BackgroundRenderMode { |
| 24 BG_RENDER_NORMAL, | 25 BG_RENDER_NORMAL, |
| 25 BG_RENDER_NONE, | 26 BG_RENDER_NONE, |
| 26 BG_RENDER_RECURSIVE, | 27 BG_RENDER_RECURSIVE, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 return GetFgColor("GtkMenu#menu GtkMenuItem#menuitem:hover GtkLabel"); | 104 return GetFgColor("GtkMenu#menu GtkMenuItem#menuitem:hover GtkLabel"); |
| 104 case ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor: | 105 case ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor: |
| 105 return GetFgColor("GtkMenu#menu GtkMenuItem#menuitem:disabled GtkLabel"); | 106 return GetFgColor("GtkMenu#menu GtkMenuItem#menuitem:disabled GtkLabel"); |
| 106 case ui::NativeTheme::kColorId_MenuItemSubtitleColor: | 107 case ui::NativeTheme::kColorId_MenuItemSubtitleColor: |
| 107 if (GtkVersionCheck(3, 20)) { | 108 if (GtkVersionCheck(3, 20)) { |
| 108 return GetFgColor("GtkMenu#menu GtkMenuItem#menuitem #accelerator"); | 109 return GetFgColor("GtkMenu#menu GtkMenuItem#menuitem #accelerator"); |
| 109 } | 110 } |
| 110 return GetFgColor( | 111 return GetFgColor( |
| 111 "GtkMenu#menu GtkMenuItem#menuitem GtkLabel.accelerator"); | 112 "GtkMenu#menu GtkMenuItem#menuitem GtkLabel.accelerator"); |
| 112 case ui::NativeTheme::kColorId_MenuSeparatorColor: | 113 case ui::NativeTheme::kColorId_MenuSeparatorColor: |
| 113 // MenuButton borders are used as vertical menu separators in Chrome. | |
| 114 case ui::NativeTheme::kColorId_EnabledMenuButtonBorderColor: | |
| 115 case ui::NativeTheme::kColorId_FocusedMenuButtonBorderColor: | |
| 116 case ui::NativeTheme::kColorId_HoverMenuButtonBorderColor: | |
| 117 if (GtkVersionCheck(3, 20)) { | 114 if (GtkVersionCheck(3, 20)) { |
| 118 return GetSeparatorColor( | 115 return GetSeparatorColor( |
| 119 "GtkMenu#menu GtkSeparator#separator.horizontal"); | 116 "GtkMenu#menu GtkSeparator#separator.horizontal"); |
| 120 } | 117 } |
| 121 return GetFgColor("GtkMenu#menu GtkMenuItem#menuitem.separator"); | 118 return GetFgColor("GtkMenu#menu GtkMenuItem#menuitem.separator"); |
| 122 | 119 |
| 123 // Label | 120 // Label |
| 124 case ui::NativeTheme::kColorId_LabelEnabledColor: | 121 case ui::NativeTheme::kColorId_LabelEnabledColor: |
| 125 return GetFgColor("GtkLabel"); | 122 return GetFgColor("GtkLabel"); |
| 126 case ui::NativeTheme::kColorId_LabelDisabledColor: | 123 case ui::NativeTheme::kColorId_LabelDisabledColor: |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 auto context = GetStyleContextFromCss("GtkMenu#menu GtkMenuItem#menuitem"); | 510 auto context = GetStyleContextFromCss("GtkMenu#menu GtkMenuItem#menuitem"); |
| 514 gtk_style_context_set_state(context, StateToStateFlags(state)); | 511 gtk_style_context_set_state(context, StateToStateFlags(state)); |
| 515 PaintWidget(canvas, rect, context, BG_RENDER_NORMAL, true); | 512 PaintWidget(canvas, rect, context, BG_RENDER_NORMAL, true); |
| 516 } | 513 } |
| 517 | 514 |
| 518 void NativeThemeGtk3::PaintMenuSeparator( | 515 void NativeThemeGtk3::PaintMenuSeparator( |
| 519 cc::PaintCanvas* canvas, | 516 cc::PaintCanvas* canvas, |
| 520 State state, | 517 State state, |
| 521 const gfx::Rect& rect, | 518 const gfx::Rect& rect, |
| 522 const MenuSeparatorExtraParams& menu_separator) const { | 519 const MenuSeparatorExtraParams& menu_separator) const { |
| 520 // TODO(estade): use GTK to draw vertical separators too. See |
| 521 // crbug.com/710183 |
| 522 if (menu_separator.type == ui::VERTICAL_SEPARATOR) { |
| 523 cc::PaintFlags paint; |
| 524 paint.setStyle(cc::PaintFlags::kFill_Style); |
| 525 paint.setColor( |
| 526 GetSystemColor(ui::NativeTheme::kColorId_MenuSeparatorColor)); |
| 527 canvas->drawRect(gfx::RectToSkRect(rect), paint); |
| 528 return; |
| 529 } |
| 530 |
| 523 auto separator_offset = [&](int separator_thickness) { | 531 auto separator_offset = [&](int separator_thickness) { |
| 524 switch (menu_separator.type) { | 532 switch (menu_separator.type) { |
| 525 case ui::LOWER_SEPARATOR: | 533 case ui::LOWER_SEPARATOR: |
| 526 return rect.height() - separator_thickness; | 534 return rect.height() - separator_thickness; |
| 527 case ui::UPPER_SEPARATOR: | 535 case ui::UPPER_SEPARATOR: |
| 528 return 0; | 536 return 0; |
| 529 default: | 537 default: |
| 530 return (rect.height() - separator_thickness) / 2; | 538 return (rect.height() - separator_thickness) / 2; |
| 531 } | 539 } |
| 532 }; | 540 }; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 | 600 |
| 593 if (frame_top_area.incognito) { | 601 if (frame_top_area.incognito) { |
| 594 bitmap = SkBitmapOperations::CreateHSLShiftedBitmap( | 602 bitmap = SkBitmapOperations::CreateHSLShiftedBitmap( |
| 595 bitmap, kDefaultTintFrameIncognito); | 603 bitmap, kDefaultTintFrameIncognito); |
| 596 } | 604 } |
| 597 | 605 |
| 598 canvas->drawBitmap(bitmap, rect.x(), rect.y()); | 606 canvas->drawBitmap(bitmap, rect.x(), rect.y()); |
| 599 } | 607 } |
| 600 | 608 |
| 601 } // namespace libgtkui | 609 } // namespace libgtkui |
| OLD | NEW |