mmenu; in list view, properly handle icon on demand loading
[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_SUBCATFOLDER,
38   IMG_DOTDOTFOLDER,
39   IMG_MAX, // before this point is loaded; after is generated
40   IMG_LIST_ALPHAMASK,
41   IMG_LIST_ALPHAMASK_W,
42   IMG_TRUEMAX
43 } mm_imgcache_e;
44
45 typedef struct {
46   mm_imgcache_e id;
47   char *confname;
48   char *alt_confname;
49   void /*SDL_Surface*/ *i;
50 } mm_imgcache_t;
51
52 /* ui stuff
53  */
54
55 typedef enum {
56   uisb_none = 0,
57   uisb_x = 1,
58   uisb_y = (1<<1),
59   uisb_a = (1<<2),
60   uisb_b = (1<<3),
61   uisb_l = (1<<4),
62   uisb_r = (1<<5),
63   uisb_start = (1<<6),
64   uisb_select = (1<<7),
65   uisb_max
66 } ui_sdl_button_e;
67
68 typedef enum {
69   uiv_icons = 0,
70   uiv_list,
71   uiv_max
72 } ui_viewmode_e;
73
74 unsigned char ui_setup ( void );
75 unsigned char ui_imagecache ( char *basepath );
76 unsigned char ui_pick_skin ( void ); // return >0 if skin has changed
77
78 void ui_render ( void );
79
80 void ui_loadscreen ( void );        // show screen while loading the menu
81 void ui_discoverscreen ( unsigned char clearscreen ); // screen to show while scanning for apps
82 void ui_cachescreen ( unsigned char clearscreen, char *filename ); // while caching icons, categories and preview-pics-Now-mode
83 void ui_show_hourglass ( unsigned char updaterect );
84 void ui_post_scan ( void );
85 unsigned char ui_show_info ( char *pndrun, pnd_disco_t *p );
86 void ui_aboutscreen ( char *textpath );
87 void ui_revealscreen ( void );
88 void ui_manage_categories ( void );
89 char *ui_pick_custom_category ( unsigned char mode ); // mode 0 == custom main only; 1 == custom main + FD main; 2 == custom main + FD mains-with-custom-subs
90
91 /* internal functions follow
92  */
93
94 // show a menu, return when selection made; -1 means no selection. Enter is pick.
95 int ui_modal_single_menu ( char *argv[], unsigned int argc, char *title, char *footer );
96
97 // run a forked app (ie: not wait for it to return)
98 unsigned char ui_forkexec ( char *argv[] ); // argv[0] is proggy to exec; argv last entry must be NULLptr
99
100 // create a thread of this guy, and it'll try to load the preview pic in background and then signal the app
101 unsigned char ui_threaded_defered_preview ( pnd_disco_t *p ); // callback
102 unsigned char ui_threaded_defered_icon ( void * ); // callback
103 unsigned char ui_threaded_timer_create ( void );
104 int ui_threaded_timer ( pnd_disco_t *p ); // callback
105
106 // change the focus
107 void ui_process_input ( pnd_dbusnotify_handle dbh, pnd_notify_handle nh );
108 void ui_push_left ( unsigned char forcecoil );
109 void ui_push_right ( unsigned char forcecoil );
110 void ui_push_up ( void );
111 void ui_push_down ( void );
112 void ui_push_exec ( void );
113 void ui_push_backup ( void );
114 void ui_push_ltrigger ( void );
115 void ui_push_rtrigger ( void );
116 unsigned char ui_determine_row ( mm_appref_t *a );
117 unsigned char ui_determine_screen_row ( mm_appref_t *a );
118 unsigned char ui_determine_screen_col ( mm_appref_t *a );
119
120 // detail panel hide/show
121 unsigned char ui_is_detail_hideable ( void ); // returns true if detail pane may be hidden with current skin
122 void ui_toggle_detail_pane ( void );          // toggle it on/off
123
124 // ui_render() can register tappable-areas which touchscreen code can then figure out if we made a hit
125 void ui_register_reset ( void );
126 void ui_register_tab ( unsigned char catnum, unsigned int x, unsigned int y, unsigned int w, unsigned int h );
127 void ui_register_app ( mm_appref_t *app, unsigned int x, unsigned int y, unsigned int w, unsigned int h );
128 void ui_touch_act ( unsigned int x, unsigned int y );
129
130 // deferred preview timer
131 void ui_set_selected ( mm_appref_t *r );
132 unsigned int ui_callback_f ( unsigned int t );
133
134 // 'popup' 'context' menu
135 void ui_menu_context ( mm_appref_t *a );
136 unsigned char ui_menu_oneby ( char *title, char *footer, char *one ); // return 0 (nada) or 1 (one) for they actually picked it
137 unsigned char ui_menu_twoby ( char *title, char *footer, char *one, char *two ); // return 0 (nada), 1 (one), 2 (two)
138 unsigned char ui_menu_get_text_line ( char *title, char *footer, char *initialvalue,
139                                       char *r_buffer, unsigned char maxlen, unsigned char numbersonlyp ); // populates r_buffer
140
141 // ovr-file edit
142 unsigned char ovr_replace_or_add ( mm_appref_t *a, char *keybase, char *newvalue ); // keybase does not include app#
143
144 #endif