#ifndef LAUNCH_SCREEN_H
#define LAUNCH_SCREEN_H

#include <X11/Xlib.h>
#include "desktop_parser.h"

/*
 * The Wii channel launch screen:
 *
 *   ┌─────────────────────────────┐
 *   │                             │
 *   │    [green preview area]     │
 *   │                             │
 *   ├─────────────────────────────┤  ← footer wave (same style as menu)
 *   │   [Wii Menu]    [▶ Start]   │
 *   └─────────────────────────────┘
 *
 * The green area is just a solid green fill — on real Wii it showed a
 * channel banner animation.  We show the app name over it instead.
 * "Wii Menu" → go back.  "Start" → actually launch the app.
 */

typedef enum {
    LAUNCH_BTN_NONE  = 0,
    LAUNCH_BTN_BACK  = 1,   /* "Wii Menu" — return to grid               */
    LAUNCH_BTN_START = 2    /* "Start"    — exec the app                 */
} LaunchButton;

typedef struct {
    Display      *dpy;
    Window        win;          /* same overlay window as main renderer    */
    GC            gc;
    int           screen;
    int           sw, sh;
    Pixmap        backbuf;

    XFontStruct  *font_title;   /* app name in preview                    */
    XFontStruct  *font_btn;     /* button labels                          */
    XFontStruct  *font_sub;     /* small hint text                        */

    const DesktopEntry *entry;  /* app being previewed                    */

    LaunchButton  focused_btn;  /* which pill is highlighted               */
    int           glow_phase;   /* 0-255 pulse for the focused btn        */

    /* footer geometry (mirrored from renderer so it looks the same) */
    int           footer_h;
} LaunchState;

/* Set up fonts, GC, backbuf (reuses the same Display/Window) */
void launch_screen_init(LaunchState *ls, Display *dpy, Window win,
                        int screen, int sw, int sh, int footer_h);

/* Change the app being previewed */
void launch_screen_set_entry(LaunchState *ls, const DesktopEntry *entry);

/* Advance glow animation */
void launch_screen_tick(LaunchState *ls);

/* Draw one frame */
void launch_screen_draw(LaunchState *ls);

/* Move button focus left/right, returns 1 if changed */
int  launch_screen_move(LaunchState *ls, int dir); /* -1 left, +1 right  */

/* Free resources */
void launch_screen_free(LaunchState *ls);

#endif /* LAUNCH_SCREEN_H */