void ssd_generic_icon_list_dialog_show( const char* title, int count, const char** labels, const void** values, const char** icons, const int* flags, PFN_ON_ITEM_SELECTED on_item_selected, PFN_ON_ITEM_SELECTED on_item_deleted, void* context, const char* left_softkey_text, SsdSoftKeyCallback left_softkey_callback, int list_height, int dialog_flags, BOOL add_next_button) { static SsdListContext list_context; SsdWidget list; int list_flags = 0; #if defined (OPENGL) /* * Borders are fast in OPENGL */ list_flags |= SSD_ALIGN_CENTER|SSD_CONTAINER_BORDER|SSD_ROUNDED_CORNERS|SSD_ROUNDED_WHITE; #endif // OPENGL list_context.on_item_selected= on_item_selected; list_context.on_item_deleted = on_item_deleted; list_context.context = context; list_context.left_softkey_callback = left_softkey_callback; if ( !ssd_dialog_exists( SSD_GEN_LIST_DLG_NAME ) ) { GenericList = ssd_dialog_new ( SSD_GEN_LIST_DLG_NAME, "", on_dialog_closed, SSD_CONTAINER_TITLE|dialog_flags); list = ssd_list_new ("list", SSD_MAX_SIZE, SSD_MAX_SIZE, inputtype_none, 0, NULL); ssd_widget_add (GenericList, list); } else{ GenericList->flags &= ~SSD_HEADER_BLACK; GenericList->flags |= dialog_flags; } ssd_widget_set_offset(GenericList,0,0); list = ssd_widget_get (GenericList, "list"); GenericList->set_value (GenericList->parent, title); ssd_widget_set_context (GenericList, &list_context); ssd_widget_reset_cache (list->parent); ssd_widget_reset_position(GenericList); ssd_list_resize ( list, list_height ); ssd_list_populate (list, count, labels, values,icons,flags, list_callback, del_callback, add_next_button); ssd_widget_set_left_softkey_text(GenericList, left_softkey_text); if (left_softkey_callback != NULL) ssd_widget_set_left_softkey_callback(GenericList, list_left_softkey_callback); ssd_dialog_activate (SSD_GEN_LIST_DLG_NAME, NULL); ssd_dialog_draw(); }
void ssd_widget_reset_cache (SsdWidget w) { SsdWidget child = w->children; w->cached_size.width = w->cached_size.height = -1; while (child != NULL) { ssd_widget_reset_cache (child); child = child->next; } }
void ssd_generic_list_dialog_show(const char* title, int count, const char** labels, const void** values, PFN_ON_ITEM_SELECTED on_item_selected, PFN_ON_ITEM_SELECTED on_item_deleted, void* context, int list_height ) { static SsdListContext list_context; SsdWidget list; int flags = 0; #if defined (OPENGL) /* * Borders are fast in OPENGL */ flags |= SSD_ALIGN_CENTER|SSD_CONTAINER_BORDER|SSD_ROUNDED_CORNERS|SSD_ROUNDED_WHITE; #endif // OPENGL list_context.on_item_selected= on_item_selected; list_context.on_item_deleted = on_item_deleted; list_context.context = context; list_context.left_softkey_callback = NULL; if (!GenericList) { GenericList = ssd_dialog_new ( SSD_GEN_LIST_DLG_NAME, "", on_dialog_closed, SSD_CONTAINER_TITLE); ssd_dialog_add_vspace (GenericList, 5, 0); list = ssd_list_new ("list", ssd_container_get_width(), SSD_MAX_SIZE, inputtype_none, flags, NULL); ssd_widget_add (GenericList, list); } list = ssd_widget_get (GenericList, "list"); ssd_widget_set_offset(GenericList,0,0); ssd_widget_set_left_softkey_text(GenericList, roadmap_lang_get("Exit_key")); ssd_widget_set_left_softkey_callback(GenericList, NULL); GenericList->set_value (GenericList->parent, title); ssd_widget_set_context (GenericList, &list_context); ssd_widget_reset_cache (list->parent); ssd_widget_reset_position(GenericList); ssd_list_resize ( list, list_height ); ssd_list_populate (list, count, labels, values, NULL, NULL, list_callback, del_callback, FALSE); ssd_dialog_activate ( SSD_GEN_LIST_DLG_NAME, NULL ); ssd_dialog_draw(); }
void ssd_dialog_reset_offset(){ SsdDialog dialog = RoadMapDialogCurrent; if( !dialog) return; if (!dialog->scroll_container) return; ssd_widget_set_offset(dialog->scroll_container, 0,0); ssd_widget_reset_cache(dialog->scroll_container); ssd_widget_reset_position(dialog->scroll_container); }
void ssd_dialog_redraw_screen_recursive( SsdDialog Dialog) { RoadMapGuiRect rect; SsdWidget container = Dialog->container; if( (SSD_DIALOG_FLOAT & container->flags) && Dialog->next) ssd_dialog_redraw_screen_recursive( Dialog->next); rect.minx = 0; rect.miny = 0; rect.maxx = roadmap_canvas_width() - 1; rect.maxy = roadmap_canvas_height() - 1; ssd_widget_reset_cache ( container); ssd_widget_draw ( container, &rect, 0); }
void ssd_widget_get_size (SsdWidget w, SsdSize *size, const SsdSize *max) { RoadMapGuiRect max_size_temp; SsdSize pack_size = {0, 0}; RoadMapGuiRect max_size = {0, 0, 0, 0}; int total_height_below = 0; *size = w->size; if ((w->size.height >= 0) && (w->size.width >= 0)) { return; } if (!max && (w->cached_size.width < 0)) { static SsdSize canvas_size; canvas_size.width = roadmap_canvas_width(); #ifdef TOUCH_SCREEN canvas_size.height = roadmap_canvas_height() ; #else canvas_size.height = roadmap_canvas_height() - roadmap_bar_bottom_height(); #endif max = &canvas_size; } else{ if (!max) max = &w->cached_size; } if ((w->cached_size.width >= 0) && (w->cached_size.height >= 0)) { *size = w->cached_size; return; } /* Comment by AGA. THere is no assignment for this flag if (size->height == SSD_MAX_SIZE) { /* Check if other siblings exists and should be placed below this one * SsdWidget below_w = w->next; while (below_w) { if (below_w->flags & SSD_ORDER_LAST) { SsdSize s; ssd_widget_get_size (below_w, &s, max); total_height_below += s.height; } below_w = below_w->next; } } */ if ((w->flags & SSD_DIALOG_FLOAT) && !(w->flags & SSD_DIALOG_TRANSPARENT)){ if ((size->width == SSD_MAX_SIZE) && ((max->width >= roadmap_canvas_width()) || (max->width >= roadmap_canvas_height()))){ if (roadmap_canvas_width() > roadmap_canvas_height()) { size->width = roadmap_canvas_height(); // printf("size->width,height %d,%d\n",size->width,size->height); } else size->width = roadmap_canvas_width()-20; #ifdef IPHONE size->width = 320 * roadmap_screen_get_screen_scale() / 100; #endif }else if (size->width == SSD_MAX_SIZE) size->width = max->width -20; if (size->height== SSD_MAX_SIZE) size->height= max->height - total_height_below; } else { if (size->width == SSD_MAX_SIZE) size->width = max->width; if (size->height== SSD_MAX_SIZE) size->height= max->height - total_height_below; } #ifdef IPHONE_NATIVE if (size->width > 320 * roadmap_screen_get_screen_scale() / 100) size->width = 320 * roadmap_screen_get_screen_scale() / 100; #endif //IPHONE if ((size->height >= 0) && (size->width >= 0)) { w->cached_size = *size; return; } if (size->width >= 0) { max_size.maxx = size->width - 1; } else { if (!max){ static SsdSize canvas_size; canvas_size.width = roadmap_canvas_width(); #ifdef TOUCH_SCREEN canvas_size.height = roadmap_canvas_height(); #else canvas_size.height = roadmap_canvas_height() - roadmap_bar_bottom_height(); #endif max = &canvas_size; } max_size.maxx = max->width - 1; } if (size->height >= 0) { max_size.maxy = size->height - 1; } else { max_size.maxy = max->height - 1; } max_size_temp = max_size; get_size(w,&pack_size, &max_size); if (w->flags & SSD_WIDGET_RESIZE) { /* * The following code will take affect when the caclculated size extends beyond the screen height, and * thus won't be shown fully. * In this case, we will extend the widget's width * as wide as possible, hoping that this will help fit the widget in the screen. - D.F. */ if((roadmap_canvas_width() > roadmap_canvas_height())){ if( (size->width == roadmap_canvas_height())&&(pack_size.height>roadmap_canvas_height())){ ssd_widget_reset_cache(w); pack_size.height = 0; pack_size.width = 0; size->width = roadmap_canvas_width(); max_size_temp.maxx = roadmap_canvas_width() -1; get_size(w,&pack_size, &max_size_temp); } } } if (size->height< 0) size->height = pack_size.height; if (size->width < 0) size->width = pack_size.width; w->cached_size = *size; }
int ssd_dialog_drag_end (RoadMapGuiPoint *point) { uint32_t time_diff, drag_diff, speed; SsdDialog dialog = RoadMapDialogCurrent; if (dialog == NULL) return 0; if (dialog->container->flags & SSD_DIALOG_FLOAT){ if (LastPointerPoint.x == -1) return 0; else return 1; } dialog->drag_end_time_ms = roadmap_time_get_millis(); dialog->drag_end_motion.y = point->y; dialog->drag_end_motion.x = point->x; time_diff = dialog->drag_end_time_ms - dialog->drag_start_time_ms; drag_diff = abs(dialog->drag_end_motion.y - dialog->drag_start_point.y); if (time_diff > 0) speed = (int)(drag_diff*10)/time_diff; #if 0 if ((dialog->scroll_counter < SCROLL_AFTER_END_COUNTER) && (drag_diff > 40)){ dialog->drag_speed = speed; roadmap_main_set_periodic (30, keep_dragging); dialog->time_active = TRUE; return 1; } #endif if (dialog->scroll_container && dialog->scroll_container->drag_end) return (*dialog->scroll_container->drag_end)(dialog->container, point); else if ((dialog->scroll_container) && (dialog->scroll)){ SsdWidget title; SsdSize size, size2; int height; int goffsef = (int)(1 * (point->y - dialog->drag_start_point.y ) + dialog->stop_offset); title = ssd_widget_get (RoadMapDialogCurrent->container, "title_bar"); height = roadmap_canvas_height() - title->cached_size.height - 4; ssd_widget_reset_cache(dialog->scroll_container); ssd_widget_get_size(dialog->scroll_container, &size, NULL); if (size.height == roadmap_canvas_height() +1){ ssd_widget_reset_cache(dialog->scroll_container); size2.width = SSD_MIN_SIZE; size2.height = SSD_MIN_SIZE; ssd_widget_get_size(dialog->scroll_container, &size, &size2); } if (size.height < height) goffsef = 0; else if ((goffsef + size.height) > height) { if (goffsef + dialog->scroll_container->position.y > dialog->container->children->cached_size.height) goffsef = 0 ; } else if ((goffsef + dialog->scroll_container->position.y + size.height ) < roadmap_canvas_height()){ goffsef = height - size.height -2 ; } ssd_widget_set_offset(dialog->scroll_container,0,goffsef); dialog->stop_offset = goffsef; ssd_dialog_draw(); } return 1; }
static void draw_dialog (SsdDialog dialog) { if (!dialog) { return; } else { RoadMapGuiRect rect; rect.minx = 0; #ifndef TOUCH_SCREEN if (is_screen_wide()) rect.miny = 1; else rect.miny = roadmap_bar_top_height()+1; rect.maxx = roadmap_canvas_width() -1; #else rect.miny = 1; rect.maxx = roadmap_canvas_width() -1; #endif #ifdef TOUCH_SCREEN rect.maxy = roadmap_canvas_height() - 1; #else rect.maxy = roadmap_canvas_height() - 1 - roadmap_bar_bottom_height() ; #endif ssd_widget_reset_cache (dialog->container); ssd_widget_draw (dialog->container, &rect, 0); if ((dialog->container->flags & SSD_CONTAINER_TITLE) && (dialog->scroll_container != NULL) && (dialog->scroll_container->offset_y < 0)){ SsdWidget title; SsdSize size; title = ssd_widget_get (dialog->container, "title_bar"); ssd_widget_get_size(title, &size, NULL); #ifndef TOUCH_SCREEN if (!is_screen_wide()){ rect.miny = roadmap_bar_top_height(); } else{ rect.miny = 0; } #else rect.miny = 1; #endif rect.maxy = rect.miny + size.height-1 ; title->draw(title, &rect, 0); rect.miny +=1; ssd_widget_draw(title->children, &rect, 0); } #ifndef TOUCH_SCREEN roadmap_bar_draw_bottom_bar(TRUE); if ((dialog->container->flags & SSD_CONTAINER_TITLE) && (dialog->scroll_container != NULL) && (dialog->scroll_container->offset_y < 0)) if (!is_screen_wide()) roadmap_bar_draw_top_bar(TRUE); #endif ssd_dialog_sort_tab_order( dialog); ssd_dialog_sort_tab_order_by_gui_position(); } }