8beff3b806df3b8b4adea9981a41fea5f81c8467
[pandora-libraries.git] / minimenu / mmui.h
1
2 #ifndef h_mmui_h
3 #define h_mmui_h
4
5 /* this code actually _does_ something; this way, at least all the IO routines are in one place, so
6  * I know what to replace with something sensible later :)
7  * ... ahh, to have time to make this in C++ as an actual abstract interface...
8  */
9
10 /* staticly cached stuff, for UI
11  */
12
13 typedef enum {
14   IMG_BACKGROUND_800480 = 0,
15   IMG_BACKGROUND_TABMASK,
16   IMG_DETAIL_PANEL,
17   IMG_DETAIL_BG,
18   IMG_SELECTED_ALPHAMASK,
19   IMG_TAB_SEL,
20   IMG_TAB_UNSEL,
21   IMG_ICON_MISSING,
22   IMG_SELECTED_HILITE,
23   IMG_PREVIEW_MISSING,
24   IMG_ARROW_UP,
25   IMG_ARROW_DOWN,
26   IMG_ARROW_SCROLLBAR,
27   IMG_MAX, // before this point is loaded; after is generated
28   IMG_TRUEMAX
29 } mm_imgcache_e;
30
31 typedef struct {
32   mm_imgcache_e id;
33   char *confname;
34   void /*SDL_Surface*/ *i;
35 } mm_imgcache_t;
36
37 /* ui stuff
38  */
39
40 typedef enum {
41   uisb_none = 0,
42   uisb_x = 1,
43   uisb_y = (1<<1),
44   uisb_a = (1<<2),
45   uisb_b = (1<<3),
46   uisb_l = (1<<4),
47   uisb_r = (1<<5),
48   uisb_start = (1<<6),
49   uisb_select = (1<<7),
50   uisb_max
51 } ui_sdl_button_e;
52
53 unsigned char ui_setup ( void );
54 unsigned char ui_imagecache ( char *basepath );
55
56 #define CHANGED_NOTHING     (0)
57 #define CHANGED_CATEGORY    (1<<0)  /* changed to different category */
58 #define CHANGED_SELECTION   (1<<1)  /* changed app selection */
59 #define CHANGED_DATAUPDATE  (1<<2)  /* deferred preview pic or icon came in */
60 #define CHANGED_APPRELOAD   (1<<3)  /* new set of applications entirely */
61 #define CHANGED_EVERYTHING  (0xFFFF) /* redraw it all! */
62 void ui_render ( unsigned int render_mask );
63
64 void ui_loadscreen ( void );        // show screen while loading the menu
65 void ui_discoverscreen ( unsigned char clearscreen ); // screen to show while scanning for apps
66 void ui_cachescreen ( unsigned char clearscreen, char *filename ); // while caching icons, categories and preview-pics-Now-mode
67
68 // show a menu, return when selection made; -1 means no selection. Enter is pick.
69 int ui_modal_single_menu ( char *argv[], unsigned int argc, char *title, char *footer );
70
71 /* internal functions follow
72  */
73
74 // change the focus
75 void ui_process_input ( unsigned char block_p );
76 void ui_push_left ( unsigned char forcecoil );
77 void ui_push_right ( unsigned char forcecoil );
78 void ui_push_up ( void );
79 void ui_push_down ( void );
80 void ui_push_exec ( void );
81 void ui_push_ltrigger ( void );
82 void ui_push_rtrigger ( void );
83 unsigned char ui_determine_row ( mm_appref_t *a );
84 unsigned char ui_determine_screen_row ( mm_appref_t *a );
85 unsigned char ui_determine_screen_col ( mm_appref_t *a );
86
87 // ui_render() can register tappable-areas which touchscreen code can then figure out if we made a hit
88 void ui_register_reset ( void );
89 void ui_register_tab ( mm_category_t *category, unsigned int x, unsigned int y, unsigned int w, unsigned int h );
90 void ui_register_app ( pnd_disco_t *app, unsigned int x, unsigned int y, unsigned int w, unsigned int h );
91
92 // deferred preview timer
93 void ui_set_selected ( mm_appref_t *r );
94 unsigned int ui_callback_f ( unsigned int t );
95
96 #endif