mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-25 16:52:29 +00:00
feat(gui): Sorry -- an apology app with a live parametric heart
A new desktop app whose whole point is to say sorry, and to look like
saying it took effort. Nothing in it is a static bitmap.
The heart is the classic parametric heart curve, x = 16sin^3(t) and
y = 13cos(t) - 5cos(2t) - 2cos(3t) - cos(4t), precomputed as a 96-point
integer polygon normalised to a half-width of 1000 and scanline-filled at
whatever size the beat currently has it at. Even-odd crossing counting is
what keeps the notch between the lobes open. The beat is a two-thump
cardiac envelope -- a strong systolic beat and a softer echo -- and the
fill carries a vertical gradient, a soft specular highlight on the upper
lobe, and a six-layer glow. The kernel is built -mno-sse with no floating
point, so every curve, gradient, easing and physics step is integer-only
and needs no trigonometry at runtime.
Around it: three apology letters that type themselves out a character at
a time, and a slow drift of small hearts using the same fill routine.
Answering "I forgive you" brightens the heart and bursts the drift
outward; answering "Not yet" dims it, slows the beat, and starts an
honest count of how long it has been waiting. Neither answer is an exit.
Supporting changes, all of them general rather than app-specific:
- gui_desktop_request_animation_frame(), so an app can opt into
full-rate recompositing instead of the ~10 Hz live-content
heartbeat. It is renewed per paint, so it lapses by itself when the
app stops animating or its window closes.
- gui_button_styled() and gui_hitzone() in SUB-WT, letting an app with
its own palette keep the toolkit's click handling. gui_button_colored
is now a thin wrapper over the former.
- A heart glyph in the icon set.
The glow layers skip whatever the heart body is about to cover, which
cuts their blended-pixel cost by roughly 3.5x and pays for the extra
layers that turn contour rings into a smooth halo.
Verified in QEMU on x86_64: all three states driven by real clicks --
hover, forgiveness (brighter heart, burst, live typewriter) and waiting
(dimmed heart, slower beat, running counter). Builds clean on x86_64,
aarch64 and armv8i.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Fh5z6V7nGPbHvqVG5p4CXX
This commit is contained in:
1 parent
5bd18c4733
commit
c9dfa6a1aa
9 files changed
+937
-13
No files matched your search
+26
-8
@@ -164,7 +164,20 @@ void gui_badge(int x, int y, const char* text, uint32_t bg, uint32_t fg) {
|
||||
// Interactive controls
|
||||
// ===========================================================================
|
||||
|
||||
bool gui_button_colored(int id, int x, int y, int w, int h, const char* label, uint32_t accent) {
|
||||
bool gui_hitzone(int id, int x, int y, int w, int h) {
|
||||
if (!hit_test(x, y, w, h)) return false;
|
||||
|
||||
g_input.hot_id = id;
|
||||
if (!g_input.mouse_clicked) return false;
|
||||
|
||||
g_input.mouse_clicked = false; // Claim the click
|
||||
g_input.active_id = id;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool gui_button_styled(int id, int x, int y, int w, int h, const char* label,
|
||||
uint32_t face, uint32_t face_hover, uint32_t face_press,
|
||||
uint32_t border, uint32_t text) {
|
||||
bool hovered = hit_test(x, y, w, h);
|
||||
bool pressed = hovered && g_input.mouse_down;
|
||||
bool clicked = false;
|
||||
@@ -179,22 +192,27 @@ bool gui_button_colored(int id, int x, int y, int w, int h, const char* label, u
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t face = pressed ? GUI_THEME_BG_DARK
|
||||
: hovered ? GUI_THEME_BG_ELEVATED
|
||||
: GUI_THEME_BG_SURFACE;
|
||||
uint32_t border = hovered ? accent : GUI_THEME_BORDER;
|
||||
|
||||
gui_gfx_fill_rect(SX(x), SY(y), w, h, face);
|
||||
gui_gfx_fill_rect(SX(x), SY(y), w, h,
|
||||
pressed ? face_press : hovered ? face_hover : face);
|
||||
gui_gfx_draw_rect(SX(x), SY(y), w, h, border);
|
||||
|
||||
// A pressed button shifts its label a pixel to sell the depression.
|
||||
int tx = x + (w - text_width(label)) / 2 + (pressed ? 1 : 0);
|
||||
int ty = y + (h - GUI_FONT_H) / 2 + (pressed ? 1 : 0);
|
||||
gui_gfx_draw_string(SX(tx), SY(ty), label, hovered ? GUI_THEME_TEXT_MAIN : GUI_THEME_TEXT_MUTED);
|
||||
gui_gfx_draw_string(SX(tx), SY(ty), label, text);
|
||||
|
||||
return clicked;
|
||||
}
|
||||
|
||||
bool gui_button_colored(int id, int x, int y, int w, int h, const char* label, uint32_t accent) {
|
||||
bool hovered = hit_test(x, y, w, h);
|
||||
|
||||
return gui_button_styled(id, x, y, w, h, label,
|
||||
GUI_THEME_BG_SURFACE, GUI_THEME_BG_ELEVATED, GUI_THEME_BG_DARK,
|
||||
hovered ? accent : GUI_THEME_BORDER,
|
||||
hovered ? GUI_THEME_TEXT_MAIN : GUI_THEME_TEXT_MUTED);
|
||||
}
|
||||
|
||||
bool gui_button(int id, int x, int y, int w, int h, const char* label) {
|
||||
return gui_button_colored(id, x, y, w, h, label, GUI_THEME_PRIMARY);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user