fix hub text rendering on home

This commit is contained in:
bQUARKz 2026-05-16 08:36:08 +01:00
parent 2e214b544b
commit 13fc1bdbe4
Signed by: bquarkz
SSH Key Fingerprint: SHA256:Z7dgqoglWwoK6j6u4QC87OveEq74WOhFN+gitsxtkf8

View File

@ -195,11 +195,17 @@ fn activation_input_down(hw: &dyn HardwareBridge) -> bool {
fn render_home(gfx: &mut dyn GfxBridge, pointer_x: i32, pointer_y: i32) { fn render_home(gfx: &mut dyn GfxBridge, pointer_x: i32, pointer_y: i32) {
gfx.fill_rect(VIEWPORT.x, VIEWPORT.y, VIEWPORT.w, VIEWPORT.h, COLOR_BG); gfx.fill_rect(VIEWPORT.x, VIEWPORT.y, VIEWPORT.w, VIEWPORT.h, COLOR_BG);
draw_panel(gfx, TITLE_PANEL, COLOR_PANEL_DARK, COLOR_BORDER); draw_panel(gfx, TITLE_PANEL, COLOR_PANEL_DARK, COLOR_BORDER);
gfx.draw_text(TITLE_PANEL.x + 58, TITLE_PANEL.y + 9, "PROMETEU HUB", COLOR_TEXT); draw_buffer_text(gfx, TITLE_PANEL.x + 58, TITLE_PANEL.y + 9, "PROMETEU HUB", COLOR_TEXT);
draw_panel(gfx, HOME_PANEL, COLOR_PANEL, COLOR_BORDER); draw_panel(gfx, HOME_PANEL, COLOR_PANEL, COLOR_BORDER);
gfx.draw_text(HOME_PANEL.x + 26, HOME_PANEL.y + 22, "Native Shell Apps", COLOR_TEXT); draw_buffer_text(gfx, HOME_PANEL.x + 26, HOME_PANEL.y + 22, "Native Shell Apps", COLOR_TEXT);
gfx.draw_text(HOME_PANEL.x + 26, HOME_PANEL.y + 40, "first retro ui slice", COLOR_MUTED); draw_buffer_text(
gfx,
HOME_PANEL.x + 26,
HOME_PANEL.y + 40,
"first retro ui slice",
COLOR_MUTED,
);
for button in HOME_BUTTONS { for button in HOME_BUTTONS {
let hovered = rect_contains(button.rect, pointer_x, pointer_y); let hovered = rect_contains(button.rect, pointer_x, pointer_y);
@ -218,14 +224,14 @@ fn render_shell_window(
gfx.fill_rect(VIEWPORT.x, VIEWPORT.y, VIEWPORT.w, VIEWPORT.h, COLOR_BG); gfx.fill_rect(VIEWPORT.x, VIEWPORT.y, VIEWPORT.w, VIEWPORT.h, COLOR_BG);
draw_panel(gfx, viewport, COLOR_PANEL_DARK, COLOR_BORDER); draw_panel(gfx, viewport, COLOR_PANEL_DARK, COLOR_BORDER);
gfx.fill_rect(viewport.x + 4, viewport.y + 24, viewport.w - 8, viewport.h - 28, color); gfx.fill_rect(viewport.x + 4, viewport.y + 24, viewport.w - 8, viewport.h - 28, color);
gfx.draw_text(viewport.x + 10, viewport.y + 8, title, COLOR_TEXT); draw_buffer_text(gfx, viewport.x + 10, viewport.y + 8, title, COLOR_TEXT);
gfx.draw_text(viewport.x + 18, viewport.y + 44, "native fake shell", COLOR_PANEL_DARK); draw_buffer_text(gfx, viewport.x + 18, viewport.y + 44, "native fake shell", COLOR_PANEL_DARK);
let close_hovered = rect_contains(CLOSE_BUTTON, pointer_x, pointer_y); let close_hovered = rect_contains(CLOSE_BUTTON, pointer_x, pointer_y);
let close_fill = if close_hovered { COLOR_HILITE } else { COLOR_BUTTON }; let close_fill = if close_hovered { COLOR_HILITE } else { COLOR_BUTTON };
gfx.fill_rect(CLOSE_BUTTON.x, CLOSE_BUTTON.y, CLOSE_BUTTON.w, CLOSE_BUTTON.h, close_fill); gfx.fill_rect(CLOSE_BUTTON.x, CLOSE_BUTTON.y, CLOSE_BUTTON.w, CLOSE_BUTTON.h, close_fill);
gfx.draw_rect(CLOSE_BUTTON.x, CLOSE_BUTTON.y, CLOSE_BUTTON.w, CLOSE_BUTTON.h, COLOR_BORDER); gfx.draw_rect(CLOSE_BUTTON.x, CLOSE_BUTTON.y, CLOSE_BUTTON.w, CLOSE_BUTTON.h, COLOR_BORDER);
gfx.draw_text(CLOSE_BUTTON.x + 5, CLOSE_BUTTON.y + 4, "x", COLOR_TEXT); draw_buffer_text(gfx, CLOSE_BUTTON.x + 5, CLOSE_BUTTON.y + 4, "x", COLOR_TEXT);
} }
fn draw_panel(gfx: &mut dyn GfxBridge, rect: Rect, fill: Color, border: Color) { fn draw_panel(gfx: &mut dyn GfxBridge, rect: Rect, fill: Color, border: Color) {
@ -240,7 +246,17 @@ fn draw_button(gfx: &mut dyn GfxBridge, rect: Rect, label: &str, hovered: bool)
gfx.fill_rect(rect.x, rect.y, rect.w, rect.h, fill); gfx.fill_rect(rect.x, rect.y, rect.w, rect.h, fill);
gfx.draw_rect(rect.x, rect.y, rect.w, rect.h, border); gfx.draw_rect(rect.x, rect.y, rect.w, rect.h, border);
gfx.draw_rect(rect.x + 3, rect.y + 3, rect.w - 6, rect.h - 6, COLOR_MUTED); gfx.draw_rect(rect.x + 3, rect.y + 3, rect.w - 6, rect.h - 6, COLOR_MUTED);
gfx.draw_text(rect.x + 28, rect.y + 18, label, COLOR_TEXT); gfx.fill_rect(rect.x + 12, rect.y + 12, 16, 24, border);
gfx.draw_rect(rect.x + 34, rect.y + 12, 62, 24, COLOR_PANEL_DARK);
draw_buffer_text(gfx, rect.x + 40, rect.y + 21, label, COLOR_TEXT);
}
fn draw_buffer_text(gfx: &mut dyn GfxBridge, x: i32, y: i32, text: &str, color: Color) {
let mut cx = x;
for ch in text.chars() {
gfx.draw_char(cx, y, ch, color);
cx += 4;
}
} }
#[cfg(test)] #[cfg(test)]