feat: remove charmap in-window header, float the copy toast

The top header bar duplicated the window-manager title bar. Drop it: tabs
now sit at the top of the content area (window shrinks by the header's
height). The "Copied" confirmation moves from the header to a floating
accent toast anchored to the lower-right of the grid, drawn last.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-06 20:54:37 +02:00
parent 02a0cf66ad
commit 95beb8ae1a
+16 -25
View File
@@ -197,8 +197,7 @@ static constexpr int SET_COUNT = (int)(sizeof(SETS) / sizeof(SETS[0]));
// ==== Layout constants ==== // ==== Layout constants ====
static constexpr int INIT_W = 680; static constexpr int INIT_W = 680;
static constexpr int INIT_H = 500; static constexpr int INIT_H = 448;
static constexpr int HEADER_H = 52;
static constexpr int TAB_H = 40; static constexpr int TAB_H = 40;
static constexpr int FOOTER_H = 84; static constexpr int FOOTER_H = 84;
static constexpr int GRID_PAD = 12; static constexpr int GRID_PAD = 12;
@@ -206,7 +205,6 @@ static constexpr int CELL_GAP = 6;
static constexpr int CELL_TARGET = 54; // desired tile edge in px static constexpr int CELL_TARGET = 54; // desired tile edge in px
static constexpr int SCROLLBAR_W = 8; static constexpr int SCROLLBAR_W = 8;
static constexpr int TITLE_SIZE = 20;
static constexpr int TAB_SIZE = 16; static constexpr int TAB_SIZE = 16;
static constexpr int CELL_SIZE = 26; // glyph font size inside a tile static constexpr int CELL_SIZE = 26; // glyph font size inside a tile
static constexpr int PREVIEW_SIZE = 40; static constexpr int PREVIEW_SIZE = 40;
@@ -233,7 +231,6 @@ static mtk::Theme g_theme;
// ==== Derived layout ==== // ==== Derived layout ====
struct Layout { struct Layout {
Rect header;
Rect tabs; Rect tabs;
Rect grid; // interior area available for the tile grid Rect grid; // interior area available for the tile grid
Rect footer; Rect footer;
@@ -249,9 +246,8 @@ static const CharSet& cur_set() { return SETS[g_set]; }
static Layout compute_layout(int w, int h) { static Layout compute_layout(int w, int h) {
Layout L {}; Layout L {};
L.header = { 0, 0, w, HEADER_H }; L.tabs = { 0, 0, w, TAB_H };
L.tabs = { 0, HEADER_H, w, TAB_H }; int grid_top = TAB_H;
int grid_top = HEADER_H + TAB_H;
L.footer = { 0, h - FOOTER_H, w, FOOTER_H }; L.footer = { 0, h - FOOTER_H, w, FOOTER_H };
L.grid = { GRID_PAD, grid_top + GRID_PAD, L.grid = { GRID_PAD, grid_top + GRID_PAD,
w - GRID_PAD * 2, (h - FOOTER_H) - grid_top - GRID_PAD * 2 }; w - GRID_PAD * 2, (h - FOOTER_H) - grid_top - GRID_PAD * 2 };
@@ -425,27 +421,10 @@ static void render(Canvas& c) {
} }
c.fill_rect(L.tabs.x, L.tabs.y + L.tabs.h - 1, L.tabs.w, 1, g_theme.border); c.fill_rect(L.tabs.x, L.tabs.y + L.tabs.h - 1, L.tabs.w, 1, g_theme.border);
// ---- Header (opaque) ---- // Bold font for the footer name and Copy button.
c.fill_rect(L.header.x, L.header.y, L.header.w, L.header.h, g_theme.window_bg);
TrueTypeFont* title_font = TrueTypeFont* title_font =
(fonts::system_bold && fonts::system_bold->valid) ? fonts::system_bold (fonts::system_bold && fonts::system_bold->valid) ? fonts::system_bold
: fonts::system_font; : fonts::system_font;
int title_h = text_height(title_font, TITLE_SIZE);
draw_text(c, title_font, GRID_PAD, (HEADER_H - title_h) / 2,
"Character Map", g_theme.text, TITLE_SIZE);
// Toast pill (right side of header).
if (g_toast[0] && montauk::get_milliseconds() < g_toast_until) {
int tw = text_width(fonts::system_font, g_toast, TOAST_SIZE);
int pill_w = tw + 24, pill_h = 26;
int px = c.w - GRID_PAD - pill_w;
int py = (HEADER_H - pill_h) / 2;
c.fill_rounded_rect(px, py, pill_w, pill_h, pill_h / 2, g_theme.accent_soft);
draw_text(c, fonts::system_font, px + 12,
py + (pill_h - text_height(fonts::system_font, TOAST_SIZE)) / 2,
g_toast, g_theme.accent_hover, TOAST_SIZE);
}
c.fill_rect(L.header.x, L.header.y + L.header.h - 1, L.header.w, 1, g_theme.border);
// ---- Footer (opaque) ---- // ---- Footer (opaque) ----
c.fill_rect(L.footer.x, L.footer.y, L.footer.w, L.footer.h, g_theme.surface_alt); c.fill_rect(L.footer.x, L.footer.y, L.footer.w, L.footer.h, g_theme.surface_alt);
@@ -480,6 +459,18 @@ static void render(Canvas& c) {
draw_button(c, title_font, L.copy_btn.x, L.copy_btn.y, L.copy_btn.w, draw_button(c, title_font, L.copy_btn.x, L.copy_btn.y, L.copy_btn.w,
L.copy_btn.h, "Copy", btn_bg, g_theme.accent_fg, L.copy_btn.h, "Copy", btn_bg, g_theme.accent_fg,
g_theme.radius_md, TAB_SIZE); g_theme.radius_md, TAB_SIZE);
// ---- Toast (drawn last; floats over the lower-right of the grid) ----
if (g_toast[0] && montauk::get_milliseconds() < g_toast_until) {
int tw = text_width(fonts::system_font, g_toast, TOAST_SIZE);
int pill_w = tw + 24, pill_h = 28;
int px = c.w - GRID_PAD - pill_w;
int py = L.footer.y - GRID_PAD - pill_h;
c.fill_rounded_rect(px, py, pill_w, pill_h, pill_h / 2, g_theme.accent);
draw_text(c, fonts::system_font, px + 12,
py + (pill_h - text_height(fonts::system_font, TOAST_SIZE)) / 2,
g_toast, g_theme.accent_fg, TOAST_SIZE);
}
} }
// ==== Event handling ==== // ==== Event handling ====