mirror of https://github.com/cutefishos/settings
refactor(settings): take colours from the colour provider
parent
6966c10a52
commit
2c9367c84c
@ -0,0 +1,44 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reion Wong <reionwong@gmail.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "widgets/colors.h"
|
||||
|
||||
#include "ui/theme.h"
|
||||
|
||||
using namespace cutefish::ui;
|
||||
|
||||
namespace settings {
|
||||
|
||||
static constexpr Color kWhite = Color::rgb(0xFFFFFF);
|
||||
static constexpr Color kBlack = Color::rgb(0x000000);
|
||||
|
||||
void addSettingsColors(ColorMixer& mixer, const Theme& theme)
|
||||
{
|
||||
const bool dark = theme.darkMode;
|
||||
|
||||
mixer[SettingsColor::SidebarBackground] =
|
||||
withAlpha(dark ? lighter(ColorId::Background, 1.5) : darker(ColorId::Background, 1.05), 0.7);
|
||||
mixer[SettingsColor::SidebarItemCurrent] = withAlpha(ColorId::Text, dark ? 0.1 : 0.05);
|
||||
|
||||
mixer[SettingsColor::RowHighlight] = withAlpha(ColorId::Text, dark ? 0.05 : 0.15);
|
||||
mixer[SettingsColor::RowComboBoxHovered] = withAlpha(ColorId::Text, dark ? 0.08 : 0.06);
|
||||
mixer[SettingsColor::RowComboBoxOpen] = withAlpha(ColorId::Text, dark ? 0.12 : 0.1);
|
||||
mixer[SettingsColor::StandardButtonBackground] = dark ? Color::rgb(0x363636) : kWhite;
|
||||
mixer[SettingsColor::UserCardButtonBackground] = dark ? ColorRecipe(Color::rgb(0x363636))
|
||||
: ColorRecipe(ColorId::Background);
|
||||
mixer[SettingsColor::KeyCap] = dark ? lighter(ColorId::SecondBackground, 1.6)
|
||||
: darker(ColorId::SecondBackground, 1.08);
|
||||
mixer[SettingsColor::PreferredLanguageTag] = withAlpha(ColorId::Highlight, dark ? 0.2 : 0.12);
|
||||
mixer[SettingsColor::WallpaperPlaceholder] = dark ? kWhite : Color::rgb(0xC8CAD5);
|
||||
|
||||
mixer[SettingsColor::TimeZoneMapBackground] = dark ? kWhite.withAlpha(0.04) : kBlack.withAlpha(0.03);
|
||||
mixer[SettingsColor::TimeZoneMapPill] = dark ? kBlack.withAlpha(0.6) : kWhite.withAlpha(0.9);
|
||||
|
||||
mixer[SettingsColor::BatteryChipBackground] = dark ? ColorId::AlternateBackground : ColorId::Background;
|
||||
mixer[SettingsColor::BatteryChipBorder] = withAlpha(ColorId::Text, dark ? 0.1 : 0.08);
|
||||
mixer[SettingsColor::GraphGrid] = dark ? kWhite.withAlpha(0.08) : kBlack.withAlpha(0.06);
|
||||
mixer[SettingsColor::GraphBaseline] = dark ? kWhite.withAlpha(0.18) : kBlack.withAlpha(0.14);
|
||||
mixer[SettingsColor::GraphProbe] = dark ? kWhite.withAlpha(0.28) : kBlack.withAlpha(0.2);
|
||||
}
|
||||
|
||||
} // namespace settings
|
||||
@ -0,0 +1,43 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reion Wong <reionwong@gmail.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "ui/color_provider.h"
|
||||
|
||||
namespace settings {
|
||||
|
||||
// Settings' own colours, after the toolkit's; colors.cpp gives them for
|
||||
// each theme. Retune the look there rather than at the use sites.
|
||||
enum class SettingsColor : uint16_t {
|
||||
SidebarBackground = uint16_t(cutefish::ui::ColorId::ApplicationFirst),
|
||||
SidebarItemCurrent,
|
||||
|
||||
RowHighlight,
|
||||
RowComboBoxHovered,
|
||||
RowComboBoxOpen,
|
||||
StandardButtonBackground,
|
||||
UserCardButtonBackground,
|
||||
KeyCap,
|
||||
PreferredLanguageTag,
|
||||
WallpaperPlaceholder,
|
||||
|
||||
TimeZoneMapBackground,
|
||||
TimeZoneMapPill,
|
||||
|
||||
BatteryChipBackground,
|
||||
BatteryChipBorder,
|
||||
GraphGrid,
|
||||
GraphBaseline,
|
||||
GraphProbe,
|
||||
};
|
||||
|
||||
void addSettingsColors(cutefish::ui::ColorMixer& mixer, const cutefish::ui::Theme& theme);
|
||||
|
||||
// Added before main by every program that names one of the colours.
|
||||
[[maybe_unused]] inline const bool settingsColorsAdded =
|
||||
(cutefish::ui::ColorProvider::addMixer(addSettingsColors), true);
|
||||
|
||||
} // namespace settings
|
||||
Loading…
Reference in New Issue