Style the screenshot editor like Settings

This commit is contained in:
agrynco committed 2026-11-24 23:19:34 +02:00
1 parent f1e5b2b772
commit 81fbe6a216
5 files changed
+285 -120

No files matched your search

+1 -48
View File
@@ -16,7 +16,7 @@
#include <commctrl.h>
#include <commdlg.h>
#include <cwchar>
#include <dwmapi.h>
#include "ui_palette.h"
#include <map>
#include <richedit.h>
#include <set>
@@ -45,53 +45,6 @@ HFONT headingFont(HWND w)
{
return font(w, 27, FW_SEMIBOLD);
}
void fillSurface(HDC dc, const RECT &bounds, COLORREF color)
{
SetDCBrushColor(dc, color);
FillRect(dc, &bounds, reinterpret_cast<HBRUSH>(GetStockObject(DC_BRUSH)));
}
class WindowPalette
{
public:
WindowPalette() = default;
WindowPalette(const WindowPalette &) = delete;
WindowPalette &operator=(const WindowPalette &) = delete;
~WindowPalette() { if (brush_) DeleteObject(brush_); }
void refresh(std::optional<DWORD> colorization = std::nullopt)
{
HIGHCONTRASTW contrast{sizeof(contrast)};
highContrast = SystemParametersInfoW(SPI_GETHIGHCONTRAST, sizeof(contrast), &contrast, 0) &&
(contrast.dwFlags & HCF_HIGHCONTRASTON);
const auto background = GetSysColor(COLOR_WINDOW);
if (brush_) DeleteObject(brush_);
brush_ = nullptr;
if (highContrast) return;
DWORD argb{};
BOOL opaque{};
if (!colorization && SUCCEEDED(DwmGetColorizationColor(&argb, &opaque)))
colorization = argb;
const auto accent = colorization ? RGB(*colorization >> 16, *colorization >> 8, *colorization)
: GetSysColor(COLOR_HIGHLIGHT);
// Keep system window text readable even with a saturated accent.
const auto tint = [](int base, int accentChannel) { return (base * 92 + accentChannel * 8 + 50) / 100; };
color_ = RGB(tint(GetRValue(background), GetRValue(accent)),
tint(GetGValue(background), GetGValue(accent)),
tint(GetBValue(background), GetBValue(accent)));
brush_ = CreateSolidBrush(color_);
}
COLORREF color() const { return brush_ ? color_ : GetSysColor(COLOR_WINDOW); }
HBRUSH brush() const { return brush_ ? brush_ : GetSysColorBrush(COLOR_WINDOW); }
COLORREF edge() const { return highContrast ? GetSysColor(COLOR_WINDOWTEXT) : RGB(200, 213, 222); }
COLORREF secondaryText() const { return highContrast ? GetSysColor(COLOR_WINDOWTEXT) : RGB(70, 91, 112); }
bool highContrast{};
private:
COLORREF color_{};
HBRUSH brush_{};
};
#ifndef KS_CONFIG_APP
constexpr int HistoryHeading = 119, HistoryDescription = 120, HistoryHeaderHeight = 73;
constexpr int HistoryWidth = 760, HistoryHeight = 530, HistoryMargin = 24, HistoryFooterTop = 482;