diff options
Diffstat (limited to 'src/gui')
| -rw-r--r-- | src/gui/base.h | 11 | ||||
| -rw-r--r-- | src/gui/dropdown.cpp | 50 |
2 files changed, 61 insertions, 0 deletions
diff --git a/src/gui/base.h b/src/gui/base.h index 230a63e..73816a7 100644 --- a/src/gui/base.h +++ b/src/gui/base.h @@ -69,6 +69,7 @@ extern struct GUI_LABEL* gui_label( I32 x, I32 y, const char* title, ... ); extern struct GUI_BUTTON* gui_button( I32 x, I32 y, I32 w, I32 h, const char* title, GUI_CALLBACK cb ); extern struct GUI_TEXTBOX* gui_textbox( I32 x, I32 y, I32 w, I32 h, const char* title, U32 maxlen, U8 allow_newl = 0 ); extern struct GUI_CHECKBOX* gui_checkbox( I32 x, I32 y, const char* title, U8* pval ); +extern struct GUI_DROPDOWN* gui_dropdown( I32 x, I32 y, I32 w, I32 h, const char* title, LIST<GUI_LIST_ENTRY>* list, I32* pval ); extern struct GUI_LIST* gui_list( I32 x, I32 y, I32 w, I32 h, const char* title, LIST<GUI_LIST_ENTRY>* list, I32* pval ); extern struct GUI_LIST_ENTRY* gui_list_get_selected( struct GUI_LIST* list ); @@ -181,6 +182,16 @@ struct GUI_CHECKBOX : GUI_BASE { GUI_CALLBACK cb; }; +struct GUI_DROPDOWN : GUI_BASE { + LIST<GUI_LIST_ENTRY>* plist; + I32* pval; + U8 held; + + GUI_CALLBACK cb; + GUI_WINDOW* listwnd; + GUI_VIEW* listview; +}; + struct GUI_TEXTBOX : GUI_BASE { char value[GUI_TEXTBOX_MAX]; diff --git a/src/gui/dropdown.cpp b/src/gui/dropdown.cpp new file mode 100644 index 0000000..68ebcc6 --- /dev/null +++ b/src/gui/dropdown.cpp @@ -0,0 +1,50 @@ +#include "base.h" + +const U32 DROPDOWN_TITLE_OFFSET = 15; + +void gui_dropdown_draw_fn( void* p ) { + GUI_DROPDOWN* drop = (GUI_DROPDOWN*)p; + + I32 x = gui_relx( drop ); + I32 y = gui_rely( drop ); + + CLR col = gui_is_fg_window( drop )? ui_clr.border : ui_clr.border_inactive; + gui_draw_frect( x, y, drop->w, drop->h, col ); + gui_draw_frect( x+1, y+1, drop->w-2, drop->h-2, ui_clr.bg_sec ); + + I32 middle = x + drop->w/2; + I32 middle_y = y + drop->h/2 - 7; + + gui_draw_str( middle, middle_y, ALIGN_C, FNT_JPN12, ui_clr.txt, drop->name ); +} + +void gui_dropdown_input_fn( void* p ) { + +} + +GUI_DROPDOWN* gui_dropdown( I32 x, I32 y, I32 w, I32 h, const char* title, LIST<GUI_LIST_ENTRY>* list, I32* pval ) { + if( !gui_check_target() ) return 0; + + GUI_DROPDOWN* dropdown = new GUI_DROPDOWN; + dropdown->x = x; + dropdown->y = y; + dropdown->w = w; + dropdown->h = h; + + dropdown->xbound = w; + dropdown->ybound = h + DROPDOWN_TITLE_OFFSET; + + dropdown->cb = 0; + dropdown->pval = pval; + dropdown->plist = list; + dropdown->draw_fn = gui_dropdown_draw_fn; + dropdown->input_fn = gui_dropdown_input_fn; + strcpy( dropdown->name, title ); + + dropdown->parent = gui_get_view(); + + gui_get_view()->children.push( dropdown ); + return dropdown; +} + + |
