static int game_list_show_rom_only_toggle(CHECK_BUTTON *self) { SLIST *sl=GUI_WIDGET(self)->pdata1; char *path=GUI_WIDGET(sl)->pdata1; if (WID_IS_CHECKED((WIDGET*)self)) game_only=SDL_TRUE; else game_only=SDL_FALSE; sl->l=create_list_from_dir(path); gui_slist_update(sl); sl->data_selected=NULL; return TAKE_EVENT; }
void gui_widget_screen_position(gui_widget_t* widget, point_t* point) { if(point == NULL) return; point->x = gui_widget_x(widget); point->y = gui_widget_y(widget); gui_object_t* parent = gui_object_parent(GUI_OBJECT(widget)); while(parent){ point->x += gui_widget_x(GUI_WIDGET(parent)); point->y += gui_widget_y(GUI_WIDGET(parent)); parent = gui_object_parent(parent); } }
void gui_widget_resize(gui_widget_t* widget, graphics_size_t width, graphics_size_t height) { graphics_size_t old_width = gui_widget_width(widget); graphics_size_t old_height = gui_widget_height(widget); if(old_width == width && old_height == height) return; graphics_size_t paint_width = MAX(width, old_width); graphics_size_t paint_height = MAX(height, old_height); rect_set_width(&widget->rect, width); rect_set_height(&widget->rect, height); gui_resize_event_t event; gui_resize_event_init(&event, width, height); gui_widget_resize_event(widget, &event); gui_object_t* parent = gui_object_parent(GUI_OBJECT(widget)); if(parent){ point_t point; gui_repaint_event_t event; gui_widget_screen_position(widget, &point); gui_repaint_event_init(&event, point.x, point.y, paint_width, paint_height); gui_widget_repaint_event(GUI_WIDGET(parent), &event); } gui_widget_repaint(widget, NULL); }
void gui_widget_move(gui_widget_t* widget, graphics_pos_t x, graphics_pos_t y) { if(x == gui_widget_x(widget) && y == gui_widget_y(widget)) return; gui_object_t* parent = gui_object_parent(GUI_OBJECT(widget)); if(gui_widget_visible(widget)){ if(parent){ rect_t rect; gui_repaint_event_t event; gui_widget_screen_rect(widget, &rect); rect_set_x(&widget->rect, x); rect_set_y(&widget->rect, y); gui_repaint_event_init_rect(&event, &rect); gui_widget_repaint_event(GUI_WIDGET(parent), &event); } else { rect_set_x(&widget->rect, x); rect_set_y(&widget->rect, y); } gui_widget_repaint(widget, NULL); } else { rect_set_x(&widget->rect, x); rect_set_y(&widget->rect, y); } }
void gui_widget_screen_rect(gui_widget_t* widget, rect_t* rect) { if(rect == NULL) return; rect_t widget_rect; gui_widget_rect(widget, &widget_rect); rect_t parent_rect; gui_object_t* parent = gui_object_parent(GUI_OBJECT(widget)); while(parent){ gui_widget_rect(GUI_WIDGET(parent), &parent_rect); widget_rect.left += parent_rect.left; widget_rect.top += parent_rect.top; widget_rect.right += parent_rect.left; widget_rect.bottom += parent_rect.top; //widget_rect.left = MAX(widget_rect.left, parent_rect.left); //widget_rect.top = MAX(widget_rect.top, parent_rect.top); //widget_rect.right = MIN(widget_rect.right, parent_rect.right); //widget_rect.bottom = MIN(widget_rect.bottom, parent_rect.bottom); parent = gui_object_parent(parent); } rect_copy(rect, &widget_rect); }
static int switch_effect(COMBO_LIST *self) { char *effect_name=self->text->text; COMBO_LIST *bcl=GUI_WIDGET(self)->pdata1; printf("set effect to %s\n",effect_name); screen_change_blitter_and_effect(NULL,effect_name); gui_combol_set_selection(self,neffect); gui_combol_set_selection(bcl,nblitter); return TAKE_EVENT; }
static int switch_blitter(COMBO_LIST *self) { char *blitter_name=self->text->text; COMBO_LIST *ecl=GUI_WIDGET(self)->pdata1; printf("set blitter to %s\n",blitter_name); screen_change_blitter_and_effect(blitter_name,NULL); gui_combol_set_selection(ecl,neffect); gui_combol_set_selection(self,nblitter); return TAKE_EVENT; }
static int change_panel(struct BUTTON* self) { WIDGET *w=(WIDGET*)GUI_WIDGET(self)->pdata1; if (w!=wid_current) { wid_current->unmap(wid_current); wid_current=w; wid_current->map(wid_current); } return TAKE_EVENT; }
bool gui_widget_visible_parents(gui_widget_t* widget) { if(!gui_widget_visible(widget)) return false; gui_object_t* parent = gui_object_parent(GUI_OBJECT(widget)); while(parent){ if(!gui_widget_visible(GUI_WIDGET(parent))) return false; parent = gui_object_parent(parent); } return true; }
graphics_pos_t gui_widget_screen_y(gui_widget_t* widget) { graphics_pos_t y = gui_widget_y(widget); gui_object_t* parent = gui_object_parent(GUI_OBJECT(widget)); while(parent){ y += gui_widget_y(GUI_WIDGET(parent)); parent = gui_object_parent(parent); } return y; }
graphics_pos_t gui_widget_screen_x(gui_widget_t* widget) { graphics_pos_t x = gui_widget_x(widget); gui_object_t* parent = gui_object_parent(GUI_OBJECT(widget)); while(parent){ x += gui_widget_x(GUI_WIDGET(parent)); parent = gui_object_parent(parent); } return x; }
static int game_list_sel_change(SLIST *self) { SLIST *sl=self; DRIVER *dr; static char *shotsdir=DATA_DIRECTORY"/shots"; if (self->data_selected) { G_GAME_LIST *gl=sl->data_selected->data; if (gl->dir) { update_game_info(NULL); return TAKE_EVENT; } if (game_only==SDL_TRUE) { update_game_info(gl->dr); } else { char *filepath=alloca(strlen((char*)GUI_WIDGET(self)->pdata1)+strlen(gl->file)+1); sprintf(filepath,"%s/%s",(char*)GUI_WIDGET(self)->pdata1,gl->file); if ((dr=get_driver_for_zip(filepath))!=NULL) { update_game_info(dr); } else { update_game_info(NULL); } } } return TAKE_EVENT; }
void gui_widget_set_visible(gui_widget_t* widget, bool visible) { if(widget->visible == visible) return; widget->visible = visible; if(visible){ gui_widget_repaint(widget, NULL); }else{ gui_object_t* parent = gui_object_parent(GUI_OBJECT(widget)); if(parent){ rect_t rect; gui_widget_screen_rect(widget, &rect); gui_widget_repaint(GUI_WIDGET(parent), &rect); } if(gui_widget_has_focus(widget)){ gui_clear_focus_widget(gui_object_gui(GUI_OBJECT(widget))); } } }
void gui_widget_screen_visible_position(gui_widget_t* widget, point_t* point, rect_t* rect) { if(point == NULL && rect == NULL) return; point_t widget_point; gui_widget_position(widget, &widget_point); rect_t widget_rect; gui_widget_rect(widget, &widget_rect); rect_t parent_rect; gui_object_t* parent = gui_object_parent(GUI_OBJECT(widget)); while(parent){ gui_widget_rect(GUI_WIDGET(parent), &parent_rect); widget_point.x += rect_x(&parent_rect); widget_point.y += rect_y(&parent_rect); widget_rect.left += parent_rect.left; widget_rect.top += parent_rect.top; widget_rect.right += parent_rect.left; widget_rect.bottom += parent_rect.top; widget_rect.left = MAX(widget_rect.left, parent_rect.left); widget_rect.top = MAX(widget_rect.top, parent_rect.top); widget_rect.right = MIN(widget_rect.right, parent_rect.right); widget_rect.bottom = MIN(widget_rect.bottom, parent_rect.bottom); parent = gui_object_parent(parent); } if(point) point_copy(point, &widget_point); if(rect) rect_copy(rect, &widget_rect); }
static void gui_wdiget_foreach_childs_repaint(void* widget, void* event) { gui_widget_repaint_event(GUI_WIDGET(widget), GUI_REPAINT_EVENT(event)); }
/* plop! */ static int test_click(struct BUTTON* self) { printf("Click!! %s\n",(char*)GUI_WIDGET(self)->pdata1); return TAKE_EVENT; }
static int game_list_double_click(SLIST* self) { SLIST *sl=self; if (sl->data_selected) { G_GAME_LIST *gl=sl->data_selected->data; if (gl->dir) { char *path=GUI_WIDGET(self)->pdata1; if (strcmp(gl->dir,".")==0) return TAKE_EVENT; if (strcmp(gl->dir,"..")==0) { char *t; if (strcmp(path,"/")==0) return TAKE_EVENT; /* if (path[strlen(path)-1]=='/') path[strlen(path)-1]=0; printf("PATH2=%s\n",path); */ /* t=strrchr(path,'/'); if (t) t[0]=0; */ t=strrchr(path,'/'); if (t) t[0]=0; if (strcmp(path,"")==0) sprintf(path,"/"); } else { if (path) path=realloc(path,strlen(path)+strlen(gl->dir)+2); else path=strdup("/"); GUI_WIDGET(self)->pdata1=path; if (strcmp(path,"/")==0) sprintf(path,"/%s",gl->dir); else sprintf(path,"%s/%s",path,gl->dir); //printf("Change dir %s path=%s\n",gl->dir,path); } /* recreate list */ list_erase_all(GUI_SLIST(sl)->l,NULL); GUI_SLIST(sl)->l=create_list_from_dir(path); gui_slist_update(GUI_SLIST(sl)); sl->data_selected=NULL; } else if (gl->dr) { char *filepath=alloca(strlen((char*)GUI_WIDGET(self)->pdata1)+strlen(gl->file)+1); sprintf(filepath,"%s/%s",(char*)GUI_WIDGET(self)->pdata1,gl->file); printf("Load game %s,%s\n",filepath,gl->dr->longname); if (init_game(filepath)) return QUIT_EVENT; else return TAKE_EVENT; } else { char *filepath=alloca(strlen((char*)GUI_WIDGET(self)->pdata1)+strlen(gl->file)+1); sprintf(filepath,"%s/%s",(char*)GUI_WIDGET(self)->pdata1,gl->file); printf("Should try to load file %s %s\n",filepath,gl->file); if (init_game(filepath)) return QUIT_EVENT; else return TAKE_EVENT; } } return TAKE_EVENT; }