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