mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
* feat: add setAccentColor on Windows Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * refactor: unify GetSystemAccentColor Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * refactor: remove redundant parsing Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * chore: fixup documentation Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * Update docs/api/browser-window.md Co-authored-by: Will Anderson <andersonw@dropbox.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * Update docs/api/base-window.md Co-authored-by: Will Anderson <andersonw@dropbox.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
// Copyright (c) 2016 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef ELECTRON_SHELL_COMMON_COLOR_UTIL_H_
|
|
#define ELECTRON_SHELL_COMMON_COLOR_UTIL_H_
|
|
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
#include "build/build_config.h"
|
|
|
|
#if BUILDFLAG(IS_WIN)
|
|
#include <windows.h>
|
|
#endif
|
|
|
|
#include "third_party/skia/include/core/SkColor.h"
|
|
|
|
// SkColor is a typedef for uint32_t, this wrapper is to tag an SkColor for
|
|
// ease of use in gin converters.
|
|
struct WrappedSkColor {
|
|
WrappedSkColor() = default;
|
|
WrappedSkColor(SkColor c) : value(c) {} // NOLINT(runtime/explicit)
|
|
SkColor value;
|
|
operator SkColor() const { return value; }
|
|
};
|
|
|
|
namespace electron {
|
|
|
|
// Parses a CSS-style color string from hex, rgb(), rgba(),
|
|
// hsl(), hsla(), or color name formats.
|
|
std::optional<SkColor> ParseCSSColor(const std::string& color_string);
|
|
|
|
// Convert color to RGB hex value like "#RRGGBB".
|
|
std::string ToRGBHex(SkColor color);
|
|
|
|
// Convert color to RGBA hex value like "#RRGGBBAA".
|
|
std::string ToRGBAHex(SkColor color, bool include_hash = true);
|
|
|
|
#if BUILDFLAG(IS_WIN)
|
|
std::optional<DWORD> GetSystemAccentColor();
|
|
#endif
|
|
|
|
} // namespace electron
|
|
|
|
#endif // ELECTRON_SHELL_COMMON_COLOR_UTIL_H_
|