Skip to content

Commit

Permalink
Mac: dark backgrounds in dark mode for secondary UI/menus.
Browse files Browse the repository at this point in the history
Bug: 850098
Change-Id: If6de5922311ba501c5a746d9228993b42eff0b60
Reviewed-on: https://chromium-review.googlesource.com/c/1291569
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Michael Wasserman <msw@chromium.org>
Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601709}
  • Loading branch information
speednoisemovement authored and Commit Bot committed Oct 22, 2018
1 parent e1a6e3d commit 42a6352
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 8 additions & 2 deletions ui/native_theme/native_theme_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ @interface NSWorkspace (Redeclarations)
namespace {

const SkColor kMenuPopupBackgroundColor = SK_ColorWHITE;
// TODO(crbug.com/893598): Finalize dark mode color.
const SkColor kMenuPopupBackgroundColorDarkMode =
SkColorSetRGB(0x2B, 0x2B, 0x2B);

// Helper to make indexing an array by an enum class easier.
template <class KEY, class VALUE>
Expand Down Expand Up @@ -123,7 +126,10 @@ SkColor ColorToGrayscale(SkColor color) {
case kColorId_FocusedMenuItemBackgroundColor:
return UsesHighContrastColors() ? SK_ColorDKGRAY : gfx::kGoogleGrey200;
case kColorId_MenuBackgroundColor:
return kMenuPopupBackgroundColor;
case kColorId_BubbleBackground:
case kColorId_DialogBackground:
return SystemDarkModeEnabled() ? kMenuPopupBackgroundColorDarkMode
: kMenuPopupBackgroundColor;
case kColorId_MenuSeparatorColor:
return UsesHighContrastColors() ? SK_ColorBLACK
: SkColorSetA(SK_ColorBLACK, 0x26);
Expand Down Expand Up @@ -160,7 +166,7 @@ SkColor ColorToGrayscale(SkColor color) {
const MenuBackgroundExtraParams& menu_background) const {
cc::PaintFlags flags;
flags.setAntiAlias(true);
flags.setColor(kMenuPopupBackgroundColor);
flags.setColor(GetSystemColor(kColorId_MenuBackgroundColor));
const SkScalar radius = SkIntToScalar(menu_background.corner_radius);
SkRect rect = gfx::RectToSkRect(gfx::Rect(size));
canvas->drawRoundRect(rect, radius, radius, flags);
Expand Down
7 changes: 6 additions & 1 deletion ui/views/bubble/footnote_container_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/layout/box_layout.h"
Expand Down Expand Up @@ -61,7 +62,11 @@ FootnoteContainerView::FootnoteContainerView(const gfx::Insets& margins,
FootnoteContainerView::~FootnoteContainerView() = default;

void FootnoteContainerView::SetCornerRadius(float corner_radius) {
SetBackground(std::make_unique<HalfRoundedRectBackground>(gfx::kGoogleGrey050,
// TODO(crbug.com/893598): Finalize dark mode color.
SkColor background_color = GetNativeTheme()->SystemDarkModeEnabled()
? gfx::kGoogleGrey800
: gfx::kGoogleGrey050;
SetBackground(std::make_unique<HalfRoundedRectBackground>(background_color,
corner_radius));
}

Expand Down

0 comments on commit 42a6352

Please sign in to comment.