By default will go for fast load now -- defer icons until later (as well as
[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_TAB_LINE,
22   IMG_TAB_LINEL,
23   IMG_TAB_LINER,
24   IMG_ICON_MISSING,
25   IMG_SELECTED_HILITE,
26   IMG_PREVIEW_MISSING,
27   IMG_ARROW_UP,
28   IMG_ARROW_DOWN,
29   IMG_ARROW_SCROLLBAR,
30   IMG_MAX, // before this point is loaded; after is generated
31   IMG_TRUEMAX
32 } mm_imgcache_e;
33
34 typedef struct {
35   mm_imgcache_e id;
36   char *confname;
37   void /*SDL_Surface*/ *i;
38 } mm_imgcache_t;
39
40 /* ui stuff
41  */
42
43 typedef enum {
44   uisb_none = 0,
45   uisb_x = 1,
46   uisb_y = (1<<1),
47   uisb_a = (1<<2),
48   uisb_b = (1<<3),
49   uisb_l = (1<<4),
50   uisb_r = (1<<5),
51   uisb_start = (1<<6),
52   uisb_select = (1<<7),
53   uisb_max
54 } ui_sdl_button_e;
55
56 unsigned char ui_setup ( void );
57 unsigned char ui_imagecache ( char *basepath );
58
59 #define CHANGED_NOTHING     (0)
60 #define CHANGED_CATEGORY    (1<<0)  /* changed to different category */
61 #define CHANGED_SELECTION   (1<<1)  /* changed app selection */
62 #define CHANGED_DATAUPDATE  (1<<2)  /* deferred preview pic or icon came in */
63 #define CHANGED_APPRELOAD   (1<<3)  /* new set of applications entirely */
64 #define CHANGED_EVERYTHING  (0xFFFF) /* redraw it all! */
65 void ui_render ( unsigned int render_mask );
66
67 void ui_loadscreen ( void );        // show screen while loading the menu
68 void ui_discoverscreen ( unsigned char clearscreen ); // screen to show while scanning for apps
69 void ui_cachescreen ( unsigned char clearscreen, char *filename ); // while caching icons, categories and preview-pics-Now-mode
70 void ui_post_scan ( void );
71
72 /* internal functions follow
73  */
74
75 // show a menu, return when selection made; -1 means no selection. Enter is pick.
76 int ui_modal_single_menu ( char *argv[], unsigned int argc, char *title, char *footer );
77
78 // run a forked app (ie: not wait for it to return)
79 unsigned char ui_forkexec ( char *argv[] ); // argv[0] is proggy to exec; argv last entry must be NULLptr
80
81 // create a thread of this guy, and it'll try to load the preview pic in background and then signal the app
82 unsigned char ui_threaded_defered_preview ( pnd_disco_t *p );
83 unsigned char ui_threaded_defered_icon ( void * );
84
85 // change the focus
86 void ui_process_input ( unsigned char block_p );
87 void ui_push_left ( unsigned char forcecoil );
88 void ui_push_right ( unsigned char forcecoil );
89 void ui_push_up ( void );
90 void ui_push_down ( void );
91 void ui_push_exec ( void );
92 void ui_push_ltrigger ( void );
93 void ui_push_rtrigger ( void );
94 unsigned char ui_determine_row ( mm_appref_t *a );
95 unsigned char ui_determine_screen_row ( mm_appref_t *a );
96 unsigned char ui_determine_screen_col ( mm_appref_t *a );
97 unsigned char ui_show_info ( char *pndrun, pnd_disco_t *p );
98
99 // ui_render() can register tappable-areas which touchscreen code can then figure out if we made a hit
100 void ui_register_reset ( void );
101 void ui_register_tab ( unsigned char catnum, unsigned int x, unsigned int y, unsigned int w, unsigned int h );
102 void ui_register_app ( mm_appref_t *app, unsigned int x, unsigned int y, unsigned int w, unsigned int h );
103 void ui_touch_act ( unsigned int x, unsigned int y );
104
105 // deferred preview timer
106 void ui_set_selected ( mm_appref_t *r );
107 unsigned int ui_callback_f ( unsigned int t );
108
109 #endif