7ba395ca3c918f80a436e483a178bc4bf81b6b32
[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_SEL_L,
21   IMG_TAB_SEL_R,
22   IMG_TAB_UNSEL,
23   IMG_TAB_UNSEL_L,
24   IMG_TAB_UNSEL_R,
25   IMG_TAB_LINE,
26   IMG_TAB_LINEL,
27   IMG_TAB_LINER,
28   IMG_ICON_MISSING,
29   IMG_SELECTED_HILITE,
30   IMG_PREVIEW_MISSING,
31   IMG_ARROW_UP,
32   IMG_ARROW_DOWN,
33   IMG_ARROW_SCROLLBAR,
34   IMG_HOURGLASS,
35   IMG_FOLDER,
36   IMG_EXECBIN,
37   IMG_MAX, // before this point is loaded; after is generated
38   IMG_TRUEMAX
39 } mm_imgcache_e;
40
41 typedef struct {
42   mm_imgcache_e id;
43   char *confname;
44   void /*SDL_Surface*/ *i;
45 } mm_imgcache_t;
46
47 /* ui stuff
48  */
49
50 typedef enum {
51   uisb_none = 0,
52   uisb_x = 1,
53   uisb_y = (1<<1),
54   uisb_a = (1<<2),
55   uisb_b = (1<<3),
56   uisb_l = (1<<4),
57   uisb_r = (1<<5),
58   uisb_start = (1<<6),
59   uisb_select = (1<<7),
60   uisb_max
61 } ui_sdl_button_e;
62
63 unsigned char ui_setup ( void );
64 unsigned char ui_imagecache ( char *basepath );
65 unsigned char ui_pick_skin ( void ); // return >0 if skin has changed
66
67 void ui_render ( void );
68
69 void ui_loadscreen ( void );        // show screen while loading the menu
70 void ui_discoverscreen ( unsigned char clearscreen ); // screen to show while scanning for apps
71 void ui_cachescreen ( unsigned char clearscreen, char *filename ); // while caching icons, categories and preview-pics-Now-mode
72 void ui_show_hourglass ( unsigned char updaterect );
73 void ui_post_scan ( void );
74 unsigned char ui_show_info ( char *pndrun, pnd_disco_t *p );
75 void ui_aboutscreen ( char *textpath );
76 void ui_revealscreen ( void );
77
78 /* internal functions follow
79  */
80
81 // show a menu, return when selection made; -1 means no selection. Enter is pick.
82 int ui_modal_single_menu ( char *argv[], unsigned int argc, char *title, char *footer );
83
84 // run a forked app (ie: not wait for it to return)
85 unsigned char ui_forkexec ( char *argv[] ); // argv[0] is proggy to exec; argv last entry must be NULLptr
86
87 // create a thread of this guy, and it'll try to load the preview pic in background and then signal the app
88 unsigned char ui_threaded_defered_preview ( pnd_disco_t *p ); // callback
89 unsigned char ui_threaded_defered_icon ( void * ); // callback
90 unsigned char ui_threaded_timer_create ( void );
91 int ui_threaded_timer ( pnd_disco_t *p ); // callback
92
93 // change the focus
94 void ui_process_input ( pnd_dbusnotify_handle dbh, pnd_notify_handle nh );
95 void ui_push_left ( unsigned char forcecoil );
96 void ui_push_right ( unsigned char forcecoil );
97 void ui_push_up ( void );
98 void ui_push_down ( void );
99 void ui_push_exec ( void );
100 void ui_push_backup ( void );
101 void ui_push_ltrigger ( void );
102 void ui_push_rtrigger ( void );
103 unsigned char ui_determine_row ( mm_appref_t *a );
104 unsigned char ui_determine_screen_row ( mm_appref_t *a );
105 unsigned char ui_determine_screen_col ( mm_appref_t *a );
106
107 // detail panel hide/show
108 unsigned char ui_is_detail_hideable ( void ); // returns true if detail pane may be hidden with current skin
109 void ui_toggle_detail_pane ( void );          // toggle it on/off
110
111 // ui_render() can register tappable-areas which touchscreen code can then figure out if we made a hit
112 void ui_register_reset ( void );
113 void ui_register_tab ( unsigned char catnum, unsigned int x, unsigned int y, unsigned int w, unsigned int h );
114 void ui_register_app ( mm_appref_t *app, unsigned int x, unsigned int y, unsigned int w, unsigned int h );
115 void ui_touch_act ( unsigned int x, unsigned int y );
116
117 // deferred preview timer
118 void ui_set_selected ( mm_appref_t *r );
119 unsigned int ui_callback_f ( unsigned int t );
120
121 #endif