Commit 60903a1a authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Reland: Windows native color mixer. Not yet instantiated.

Bug: 1003612
Change-Id: I6102b7923150414c339745b3831dc607b5c145ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1902719
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Robert Liao <robliao@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713310}
parent 1f02b90f
...@@ -30,6 +30,35 @@ jumbo_component("color") { ...@@ -30,6 +30,35 @@ jumbo_component("color") {
] ]
} }
jumbo_component("mixers") {
sources = [
"color_mixers.h",
]
defines = [ "IS_COLOR_IMPL" ]
deps = []
public_deps = [
"//base",
]
if (is_chromeos) {
sources += [ "cros/native_color_mixer.cc" ]
} else if (is_linux) {
sources += [ "linux/native_color_mixer.cc" ]
} else if (is_mac) {
sources += [ "mac/native_color_mixer.cc" ]
} else if (is_win) {
sources += [ "win/native_color_mixer.cc" ]
deps += [
":color",
"//ui/gfx:color_utils",
]
}
}
test("color_unittests") { test("color_unittests") {
sources = [ sources = [
"color_mixer_unittest.cc", "color_mixer_unittest.cc",
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef UI_COLOR_COLOR_ID_H_ #ifndef UI_COLOR_COLOR_ID_H_
#define UI_COLOR_COLOR_ID_H_ #define UI_COLOR_COLOR_ID_H_
#include "build/build_config.h"
namespace ui { namespace ui {
// ColorId contains identifiers for all input, intermediary, and output colors // ColorId contains identifiers for all input, intermediary, and output colors
...@@ -19,6 +21,40 @@ enum ColorIds : ColorId { ...@@ -19,6 +21,40 @@ enum ColorIds : ColorId {
// TODO(pkasting): Define this list. // TODO(pkasting): Define this list.
kColorX = kUiColorsStart, kColorX = kUiColorsStart,
#if defined(OS_WIN)
// Windows native colors
kColorNative3dDkShadow,
kColorNative3dLight,
kColorNativeActiveBorder,
kColorNativeActiveCaption,
kColorNativeAppWorkspace,
kColorNativeBackground,
kColorNativeBtnFace,
kColorNativeBtnHighlight,
kColorNativeBtnShadow,
kColorNativeBtnText,
kColorNativeCaptionText,
kColorNativeGradientActiveCaption,
kColorNativeGradientInactiveCaption,
kColorNativeGrayText,
kColorNativeHighlight,
kColorNativeHighlightText,
kColorNativeHotlight,
kColorNativeInactiveBorder,
kColorNativeInactiveCaption,
kColorNativeInactiveCaptionText,
kColorNativeInfoBk,
kColorNativeInfoText,
kColorNativeMenu,
kColorNativeMenuBar,
kColorNativeMenuHilight,
kColorNativeMenuText,
kColorNativeScrollbar,
kColorNativeWindow,
kColorNativeWindowFrame,
kColorNativeWindowText,
#endif // defined(OS_WIN)
// Embedders must start color IDs from this value. // Embedders must start color IDs from this value.
kUiColorsEnd, kUiColorsEnd,
...@@ -37,7 +73,10 @@ enum ColorSetIds : ColorSetId { ...@@ -37,7 +73,10 @@ enum ColorSetIds : ColorSetId {
kUiColorSetsStart = kUiColorsLast + 1, kUiColorSetsStart = kUiColorsLast + 1,
// TODO(pkasting): Define this list. // TODO(pkasting): Define this list.
kColorSetX = kUiColorSetsStart,
// A set of color IDs whose values match the native platform as closely as
// possible.
kColorSetNative = kUiColorSetsStart,
// Embedders must start color set IDs from this value. // Embedders must start color set IDs from this value.
kUiColorSetsEnd, kUiColorSetsEnd,
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_COLOR_COLOR_MIXERS_H_
#define UI_COLOR_COLOR_MIXERS_H_
#include "base/component_export.h"
namespace ui {
class ColorProvider;
// Adds native color mixers to |provider| that provide kColorSetNative, as well
// as mappings from this set to cross-platform IDs. This function should be
// implemented on a per-platform basis in relevant subdirectories.
void AddNativeColorMixers(ui::ColorProvider* provider);
// TODO(pkasting): Other color mixers, e.g.:
// * Chrome default colors
// * Native/Chrome priority ordering mixer
// * All ui/ control and other colors, created from the above
} // namespace ui
#endif // UI_COLOR_COLOR_MIXERS_H_
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/color/color_mixers.h"
#include "base/logging.h"
namespace ui {
void AddNativeColorMixers(ui::ColorProvider* provider) {
NOTIMPLEMENTED();
}
} // namespace ui
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/color/color_mixers.h"
#include "base/logging.h"
namespace ui {
void AddNativeColorMixers(ui::ColorProvider* provider) {
NOTIMPLEMENTED();
}
} // namespace ui
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/color/color_mixers.h"
#include "base/logging.h"
namespace ui {
void AddNativeColorMixers(ui::ColorProvider* provider) {
NOTIMPLEMENTED();
}
} // namespace ui
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/color/color_mixers.h"
#include <windows.h>
#include "ui/color/color_id.h"
#include "ui/color/color_mixer.h"
#include "ui/color/color_provider.h"
#include "ui/color/color_set.h"
#include "ui/gfx/color_utils.h"
namespace ui {
void AddMixerForNativeColors(ui::ColorProvider* provider) {
// TODO(pkasting): Not clear whether this is really the set of interest.
// Maybe there's some way to query colors used by UxTheme.dll, or maybe we
// should be hardcoding a list of colors for system light/dark modes based on
// reverse-engineering current Windows behavior. Or maybe the union of all
// these.
#define MAP(chrome, native) {chrome, color_utils::GetSysSkColor(native)}
provider->AddMixer()->AddSet(
{kColorSetNative,
{
MAP(kColorNative3dDkShadow, COLOR_3DDKSHADOW),
MAP(kColorNative3dLight, COLOR_3DLIGHT),
MAP(kColorNativeActiveBorder, COLOR_ACTIVEBORDER),
MAP(kColorNativeActiveCaption, COLOR_ACTIVECAPTION),
MAP(kColorNativeAppWorkspace, COLOR_APPWORKSPACE),
MAP(kColorNativeBackground, COLOR_BACKGROUND),
MAP(kColorNativeBtnFace, COLOR_BTNFACE),
MAP(kColorNativeBtnHighlight, COLOR_BTNHIGHLIGHT),
MAP(kColorNativeBtnShadow, COLOR_BTNSHADOW),
MAP(kColorNativeBtnText, COLOR_BTNTEXT),
MAP(kColorNativeCaptionText, COLOR_CAPTIONTEXT),
MAP(kColorNativeGradientActiveCaption, COLOR_GRADIENTACTIVECAPTION),
MAP(kColorNativeGradientInactiveCaption,
COLOR_GRADIENTINACTIVECAPTION),
MAP(kColorNativeGrayText, COLOR_GRAYTEXT),
MAP(kColorNativeHighlight, COLOR_HIGHLIGHT),
MAP(kColorNativeHighlightText, COLOR_HIGHLIGHTTEXT),
MAP(kColorNativeHotlight, COLOR_HOTLIGHT),
MAP(kColorNativeInactiveBorder, COLOR_INACTIVEBORDER),
MAP(kColorNativeInactiveCaption, COLOR_INACTIVECAPTION),
MAP(kColorNativeInactiveCaptionText, COLOR_INACTIVECAPTIONTEXT),
MAP(kColorNativeInfoBk, COLOR_INFOBK),
MAP(kColorNativeInfoText, COLOR_INFOTEXT),
MAP(kColorNativeMenu, COLOR_MENU),
MAP(kColorNativeMenuBar, COLOR_MENUBAR),
MAP(kColorNativeMenuHilight, COLOR_MENUHILIGHT),
MAP(kColorNativeMenuText, COLOR_MENUTEXT),
MAP(kColorNativeScrollbar, COLOR_SCROLLBAR),
MAP(kColorNativeWindow, COLOR_WINDOW),
MAP(kColorNativeWindowFrame, COLOR_WINDOWFRAME),
MAP(kColorNativeWindowText, COLOR_WINDOWTEXT),
}});
}
void AddMixerToMapToCrossPlatformIds(ui::ColorProvider* provider) {
// TODO(pkasting): Add recipes
}
void AddNativeColorMixers(ui::ColorProvider* provider) {
AddMixerForNativeColors(provider);
AddMixerToMapToCrossPlatformIds(provider);
}
} // namespace ui
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment