2020-01-18 08:38:21 +00:00
|
|
|
/*
|
2024-10-04 11:19:50 +00:00
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
2021-10-26 13:30:52 +00:00
|
|
|
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
2022-01-01 17:26:19 +00:00
|
|
|
* Copyright (c) 2022, Filiph Sandström <filiph.sandstrom@filfatstudios.com>
|
2020-01-18 08:38:21 +00:00
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 08:38:21 +00:00
|
|
|
*/
|
|
|
|
|
2019-12-23 19:24:26 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-12-16 14:19:34 +00:00
|
|
|
#include <AK/ByteString.h>
|
2020-02-14 22:02:47 +00:00
|
|
|
#include <AK/Forward.h>
|
2022-04-02 17:27:22 +00:00
|
|
|
#include <AK/Vector.h>
|
2021-01-16 16:20:53 +00:00
|
|
|
#include <LibCore/AnonymousBuffer.h>
|
2021-08-25 20:22:07 +00:00
|
|
|
#include <LibCore/ConfigFile.h>
|
2020-02-06 11:04:00 +00:00
|
|
|
#include <LibGfx/Color.h>
|
2022-01-01 17:26:19 +00:00
|
|
|
#include <LibGfx/TextAlignment.h>
|
2019-12-23 19:24:26 +00:00
|
|
|
|
2020-02-06 10:56:38 +00:00
|
|
|
namespace Gfx {
|
|
|
|
|
2020-08-21 17:51:17 +00:00
|
|
|
#define ENUMERATE_COLOR_ROLES(C) \
|
2021-07-28 18:20:57 +00:00
|
|
|
C(Accent) \
|
2020-08-21 17:51:17 +00:00
|
|
|
C(ActiveLink) \
|
|
|
|
C(ActiveWindowBorder1) \
|
|
|
|
C(ActiveWindowBorder2) \
|
|
|
|
C(ActiveWindowTitle) \
|
|
|
|
C(ActiveWindowTitleShadow) \
|
|
|
|
C(ActiveWindowTitleStripes) \
|
|
|
|
C(Base) \
|
|
|
|
C(BaseText) \
|
2022-12-02 16:15:28 +00:00
|
|
|
C(Black) \
|
|
|
|
C(Blue) \
|
|
|
|
C(BrightBlack) \
|
|
|
|
C(BrightBlue) \
|
|
|
|
C(BrightCyan) \
|
|
|
|
C(BrightGreen) \
|
|
|
|
C(BrightMagenta) \
|
|
|
|
C(BrightRed) \
|
|
|
|
C(BrightWhite) \
|
|
|
|
C(BrightYellow) \
|
2020-08-21 17:51:17 +00:00
|
|
|
C(Button) \
|
|
|
|
C(ButtonText) \
|
2022-12-02 16:15:28 +00:00
|
|
|
C(ColorSchemeBackground) \
|
|
|
|
C(ColorSchemeForeground) \
|
|
|
|
C(Cyan) \
|
2022-03-05 00:28:03 +00:00
|
|
|
C(DisabledTextFront) \
|
|
|
|
C(DisabledTextBack) \
|
2020-08-21 17:51:17 +00:00
|
|
|
C(DesktopBackground) \
|
|
|
|
C(FocusOutline) \
|
2022-12-02 16:15:28 +00:00
|
|
|
C(Green) \
|
2021-06-12 01:50:23 +00:00
|
|
|
C(Gutter) \
|
|
|
|
C(GutterBorder) \
|
2020-08-21 17:51:17 +00:00
|
|
|
C(HighlightWindowBorder1) \
|
|
|
|
C(HighlightWindowBorder2) \
|
|
|
|
C(HighlightWindowTitle) \
|
|
|
|
C(HighlightWindowTitleShadow) \
|
|
|
|
C(HighlightWindowTitleStripes) \
|
2020-10-20 16:02:23 +00:00
|
|
|
C(HighlightSearching) \
|
|
|
|
C(HighlightSearchingText) \
|
2020-08-21 17:51:17 +00:00
|
|
|
C(HoverHighlight) \
|
|
|
|
C(InactiveSelection) \
|
|
|
|
C(InactiveSelectionText) \
|
|
|
|
C(InactiveWindowBorder1) \
|
|
|
|
C(InactiveWindowBorder2) \
|
|
|
|
C(InactiveWindowTitle) \
|
|
|
|
C(InactiveWindowTitleShadow) \
|
|
|
|
C(InactiveWindowTitleStripes) \
|
|
|
|
C(Link) \
|
2022-12-02 16:15:28 +00:00
|
|
|
C(Magenta) \
|
2020-08-21 17:51:17 +00:00
|
|
|
C(MenuBase) \
|
|
|
|
C(MenuBaseText) \
|
|
|
|
C(MenuSelection) \
|
|
|
|
C(MenuSelectionText) \
|
|
|
|
C(MenuStripe) \
|
|
|
|
C(MovingWindowBorder1) \
|
|
|
|
C(MovingWindowBorder2) \
|
|
|
|
C(MovingWindowTitle) \
|
|
|
|
C(MovingWindowTitleShadow) \
|
|
|
|
C(MovingWindowTitleStripes) \
|
2020-09-20 20:22:54 +00:00
|
|
|
C(PlaceholderText) \
|
2022-12-02 16:15:28 +00:00
|
|
|
C(Red) \
|
2020-08-21 17:51:17 +00:00
|
|
|
C(RubberBandBorder) \
|
|
|
|
C(RubberBandFill) \
|
|
|
|
C(Ruler) \
|
|
|
|
C(RulerActiveText) \
|
|
|
|
C(RulerBorder) \
|
|
|
|
C(RulerInactiveText) \
|
|
|
|
C(Selection) \
|
|
|
|
C(SelectionText) \
|
|
|
|
C(SyntaxComment) \
|
|
|
|
C(SyntaxControlKeyword) \
|
|
|
|
C(SyntaxIdentifier) \
|
|
|
|
C(SyntaxKeyword) \
|
|
|
|
C(SyntaxNumber) \
|
|
|
|
C(SyntaxOperator) \
|
|
|
|
C(SyntaxPreprocessorStatement) \
|
|
|
|
C(SyntaxPreprocessorValue) \
|
|
|
|
C(SyntaxPunctuation) \
|
|
|
|
C(SyntaxString) \
|
|
|
|
C(SyntaxType) \
|
2022-02-06 21:10:42 +00:00
|
|
|
C(SyntaxFunction) \
|
|
|
|
C(SyntaxVariable) \
|
|
|
|
C(SyntaxCustomType) \
|
|
|
|
C(SyntaxNamespace) \
|
|
|
|
C(SyntaxMember) \
|
|
|
|
C(SyntaxParameter) \
|
2020-08-21 17:51:17 +00:00
|
|
|
C(TextCursor) \
|
|
|
|
C(ThreedHighlight) \
|
|
|
|
C(ThreedShadow1) \
|
|
|
|
C(ThreedShadow2) \
|
2020-10-23 10:00:18 +00:00
|
|
|
C(Tooltip) \
|
|
|
|
C(TooltipText) \
|
2021-04-09 19:17:11 +00:00
|
|
|
C(Tray) \
|
|
|
|
C(TrayText) \
|
2020-08-21 17:51:17 +00:00
|
|
|
C(VisitedLink) \
|
2022-12-02 16:15:28 +00:00
|
|
|
C(White) \
|
2020-08-21 17:51:17 +00:00
|
|
|
C(Window) \
|
2022-12-02 16:15:28 +00:00
|
|
|
C(WindowText) \
|
|
|
|
C(Yellow)
|
2020-08-21 17:51:17 +00:00
|
|
|
|
2022-01-01 17:26:19 +00:00
|
|
|
#define ENUMERATE_ALIGNMENT_ROLES(C) \
|
|
|
|
C(TitleAlignment)
|
|
|
|
|
2021-10-26 13:30:52 +00:00
|
|
|
#define ENUMERATE_FLAG_ROLES(C) \
|
2022-12-02 16:15:28 +00:00
|
|
|
C(BoldTextAsBright) \
|
2022-04-23 14:23:22 +00:00
|
|
|
C(IsDark) \
|
|
|
|
C(TitleButtonsIconOnly)
|
2021-10-26 13:30:52 +00:00
|
|
|
|
2021-09-09 20:16:25 +00:00
|
|
|
#define ENUMERATE_METRIC_ROLES(C) \
|
2021-12-28 21:44:12 +00:00
|
|
|
C(BorderThickness) \
|
|
|
|
C(BorderRadius) \
|
2021-09-09 20:16:25 +00:00
|
|
|
C(TitleHeight) \
|
|
|
|
C(TitleButtonWidth) \
|
|
|
|
C(TitleButtonHeight)
|
|
|
|
|
|
|
|
#define ENUMERATE_PATH_ROLES(C) \
|
|
|
|
C(TitleButtonIcons) \
|
|
|
|
C(InactiveWindowShadow) \
|
|
|
|
C(ActiveWindowShadow) \
|
|
|
|
C(TaskbarShadow) \
|
|
|
|
C(MenuShadow) \
|
2022-12-02 16:15:28 +00:00
|
|
|
C(TooltipShadow) \
|
|
|
|
C(ColorScheme)
|
2021-09-09 20:16:25 +00:00
|
|
|
|
2019-12-24 19:57:54 +00:00
|
|
|
enum class ColorRole {
|
|
|
|
NoRole,
|
|
|
|
|
2020-08-21 17:51:17 +00:00
|
|
|
#undef __ENUMERATE_COLOR_ROLE
|
|
|
|
#define __ENUMERATE_COLOR_ROLE(role) role,
|
|
|
|
ENUMERATE_COLOR_ROLES(__ENUMERATE_COLOR_ROLE)
|
|
|
|
#undef __ENUMERATE_COLOR_ROLE
|
|
|
|
|
|
|
|
__Count,
|
2019-12-24 19:57:54 +00:00
|
|
|
|
2019-12-28 23:47:49 +00:00
|
|
|
Background = Window,
|
2019-12-24 19:57:54 +00:00
|
|
|
DisabledText = ThreedShadow1,
|
|
|
|
};
|
2019-12-24 11:13:10 +00:00
|
|
|
|
2023-04-29 14:41:29 +00:00
|
|
|
inline StringView to_string(ColorRole role)
|
2020-08-21 17:51:17 +00:00
|
|
|
{
|
|
|
|
switch (role) {
|
|
|
|
case ColorRole::NoRole:
|
2023-04-29 14:41:29 +00:00
|
|
|
return "NoRole"sv;
|
2020-08-21 17:51:17 +00:00
|
|
|
#undef __ENUMERATE_COLOR_ROLE
|
|
|
|
#define __ENUMERATE_COLOR_ROLE(role) \
|
|
|
|
case ColorRole::role: \
|
2023-04-29 14:41:29 +00:00
|
|
|
return #role##sv;
|
2020-08-21 17:51:17 +00:00
|
|
|
ENUMERATE_COLOR_ROLES(__ENUMERATE_COLOR_ROLE)
|
|
|
|
#undef __ENUMERATE_COLOR_ROLE
|
|
|
|
default:
|
2021-02-23 19:42:32 +00:00
|
|
|
VERIFY_NOT_REACHED();
|
2020-08-21 17:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-01 17:26:19 +00:00
|
|
|
enum class AlignmentRole {
|
|
|
|
NoRole,
|
|
|
|
|
|
|
|
#undef __ENUMERATE_ALIGNMENT_ROLE
|
|
|
|
#define __ENUMERATE_ALIGNMENT_ROLE(role) role,
|
|
|
|
ENUMERATE_ALIGNMENT_ROLES(__ENUMERATE_ALIGNMENT_ROLE)
|
|
|
|
#undef __ENUMERATE_ALIGNMENT_ROLE
|
|
|
|
|
|
|
|
__Count,
|
|
|
|
};
|
|
|
|
|
2023-04-29 14:41:29 +00:00
|
|
|
inline StringView to_string(AlignmentRole role)
|
2022-01-01 17:26:19 +00:00
|
|
|
{
|
|
|
|
switch (role) {
|
|
|
|
case AlignmentRole::NoRole:
|
2023-04-29 14:41:29 +00:00
|
|
|
return "NoRole"sv;
|
2022-01-01 17:26:19 +00:00
|
|
|
#undef __ENUMERATE_ALIGNMENT_ROLE
|
|
|
|
#define __ENUMERATE_ALIGNMENT_ROLE(role) \
|
|
|
|
case AlignmentRole::role: \
|
2023-04-29 14:41:29 +00:00
|
|
|
return #role##sv;
|
2022-01-01 17:26:19 +00:00
|
|
|
ENUMERATE_ALIGNMENT_ROLES(__ENUMERATE_ALIGNMENT_ROLE)
|
|
|
|
#undef __ENUMERATE_ALIGNMENT_ROLE
|
|
|
|
default:
|
|
|
|
VERIFY_NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-26 13:30:52 +00:00
|
|
|
enum class FlagRole {
|
|
|
|
NoRole,
|
|
|
|
|
|
|
|
#undef __ENUMERATE_FLAG_ROLE
|
|
|
|
#define __ENUMERATE_FLAG_ROLE(role) role,
|
|
|
|
ENUMERATE_FLAG_ROLES(__ENUMERATE_FLAG_ROLE)
|
|
|
|
#undef __ENUMERATE_FLAG_ROLE
|
|
|
|
|
|
|
|
__Count,
|
|
|
|
};
|
|
|
|
|
2023-04-29 14:41:29 +00:00
|
|
|
inline StringView to_string(FlagRole role)
|
2021-11-01 16:25:49 +00:00
|
|
|
{
|
|
|
|
switch (role) {
|
|
|
|
case FlagRole::NoRole:
|
2023-04-29 14:41:29 +00:00
|
|
|
return "NoRole"sv;
|
2021-11-01 16:25:49 +00:00
|
|
|
#undef __ENUMERATE_FLAG_ROLE
|
|
|
|
#define __ENUMERATE_FLAG_ROLE(role) \
|
|
|
|
case FlagRole::role: \
|
2023-04-29 14:41:29 +00:00
|
|
|
return #role##sv;
|
2021-11-01 16:25:49 +00:00
|
|
|
ENUMERATE_FLAG_ROLES(__ENUMERATE_FLAG_ROLE)
|
|
|
|
#undef __ENUMERATE_FLAG_ROLE
|
|
|
|
default:
|
|
|
|
VERIFY_NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-17 00:27:55 +00:00
|
|
|
enum class MetricRole {
|
|
|
|
NoRole,
|
2021-09-09 20:16:25 +00:00
|
|
|
|
|
|
|
#undef __ENUMERATE_METRIC_ROLE
|
|
|
|
#define __ENUMERATE_METRIC_ROLE(role) role,
|
|
|
|
ENUMERATE_METRIC_ROLES(__ENUMERATE_METRIC_ROLE)
|
|
|
|
#undef __ENUMERATE_METRIC_ROLE
|
|
|
|
|
|
|
|
__Count,
|
2020-07-17 00:27:55 +00:00
|
|
|
};
|
|
|
|
|
2023-04-29 14:41:29 +00:00
|
|
|
inline StringView to_string(MetricRole role)
|
2021-10-27 15:58:28 +00:00
|
|
|
{
|
|
|
|
switch (role) {
|
|
|
|
case MetricRole::NoRole:
|
2023-04-29 14:41:29 +00:00
|
|
|
return "NoRole"sv;
|
2021-10-27 15:58:28 +00:00
|
|
|
#undef __ENUMERATE_METRIC_ROLE
|
|
|
|
#define __ENUMERATE_METRIC_ROLE(role) \
|
|
|
|
case MetricRole::role: \
|
2023-04-29 14:41:29 +00:00
|
|
|
return #role##sv;
|
2021-10-27 15:58:28 +00:00
|
|
|
ENUMERATE_METRIC_ROLES(__ENUMERATE_METRIC_ROLE)
|
|
|
|
#undef __ENUMERATE_METRIC_ROLE
|
|
|
|
default:
|
|
|
|
VERIFY_NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-29 20:09:04 +00:00
|
|
|
enum class PathRole {
|
|
|
|
NoRole,
|
2021-09-09 20:16:25 +00:00
|
|
|
|
|
|
|
#undef __ENUMERATE_PATH_ROLE
|
|
|
|
#define __ENUMERATE_PATH_ROLE(role) role,
|
|
|
|
ENUMERATE_PATH_ROLES(__ENUMERATE_PATH_ROLE)
|
|
|
|
#undef __ENUMERATE_PATH_ROLE
|
|
|
|
|
|
|
|
__Count,
|
2020-07-29 20:09:04 +00:00
|
|
|
};
|
|
|
|
|
2022-07-11 17:32:29 +00:00
|
|
|
inline StringView to_string(PathRole role)
|
2021-10-27 15:58:28 +00:00
|
|
|
{
|
|
|
|
switch (role) {
|
|
|
|
case PathRole::NoRole:
|
2022-07-11 17:32:29 +00:00
|
|
|
return "NoRole"sv;
|
2021-10-27 15:58:28 +00:00
|
|
|
#undef __ENUMERATE_PATH_ROLE
|
|
|
|
#define __ENUMERATE_PATH_ROLE(role) \
|
|
|
|
case PathRole::role: \
|
2022-07-11 17:32:29 +00:00
|
|
|
return #role##sv;
|
2021-10-27 15:58:28 +00:00
|
|
|
ENUMERATE_PATH_ROLES(__ENUMERATE_PATH_ROLE)
|
|
|
|
#undef __ENUMERATE_PATH_ROLE
|
|
|
|
default:
|
|
|
|
VERIFY_NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-24 19:57:54 +00:00
|
|
|
struct SystemTheme {
|
2022-03-04 21:05:20 +00:00
|
|
|
ARGB32 color[(int)ColorRole::__Count];
|
2022-01-01 17:26:19 +00:00
|
|
|
Gfx::TextAlignment alignment[(int)AlignmentRole::__Count];
|
2021-10-26 13:30:52 +00:00
|
|
|
bool flag[(int)FlagRole::__Count];
|
2020-07-17 00:27:55 +00:00
|
|
|
int metric[(int)MetricRole::__Count];
|
2020-10-01 02:00:59 +00:00
|
|
|
char path[(int)PathRole::__Count][256]; // TODO: PATH_MAX?
|
2019-12-23 19:24:26 +00:00
|
|
|
};
|
|
|
|
|
2021-01-16 16:20:53 +00:00
|
|
|
Core::AnonymousBuffer& current_system_theme_buffer();
|
|
|
|
void set_system_theme(Core::AnonymousBuffer);
|
2023-12-16 14:19:34 +00:00
|
|
|
ErrorOr<Core::AnonymousBuffer> load_system_theme(Core::ConfigFile const&, Optional<ByteString> const& color_scheme = OptionalNone());
|
|
|
|
ErrorOr<Core::AnonymousBuffer> load_system_theme(ByteString const& path, Optional<ByteString> const& color_scheme = OptionalNone());
|
2020-02-06 10:56:38 +00:00
|
|
|
|
2022-04-02 17:27:22 +00:00
|
|
|
struct SystemThemeMetaData {
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString name;
|
2024-01-03 04:20:42 +00:00
|
|
|
ByteString menu_name;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString path;
|
2022-04-02 17:27:22 +00:00
|
|
|
};
|
|
|
|
|
2022-12-06 16:26:13 +00:00
|
|
|
ErrorOr<Vector<SystemThemeMetaData>> list_installed_system_themes();
|
2022-04-02 17:27:22 +00:00
|
|
|
|
2020-02-06 10:56:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
using Gfx::ColorRole;
|