/* * Updates the click offsets for the parent if the child click area * is out of the borders of the parent widget */ void ssd_widget_update_click_offsets( SsdWidget parent, SsdWidget child ) { SsdSize size_parent, size_child; if ( parent == NULL || child == NULL ) return; ssd_widget_get_size( child, &size_child, NULL ); ssd_widget_get_size( parent, &size_parent, NULL ); // Left offset if ( parent->position.x > ( child->position.x + child->click_offsets.left ) ) { parent->click_offsets.left = child->position.x + child->click_offsets.left - parent->position.x; } // Top offset if ( parent->position.y > ( child->position.y + child->click_offsets.top ) ) { parent->click_offsets.top = child->position.y + child->click_offsets.top - parent->position.y; } // Right if ( ( parent->position.x + size_parent.width ) < ( child->position.x + size_child.width + child->click_offsets.right ) ) { parent->click_offsets.right = child->position.x + size_child.width + child->click_offsets.top - parent->position.x - size_parent.width; } // Bottom if ( ( parent->position.y + size_parent.height ) < ( child->position.y + size_child.height + child->click_offsets.bottom ) ) { parent->click_offsets.bottom = child->position.y + size_child.height + child->click_offsets.bottom - parent->position.y - size_parent.height; } }
static int on_next (SsdWidget widget, const char *new_value) { static SsdWidget dialog; SsdWidget button; SsdWidget browserCont; SsdSize dlg_size, cnt_size; int browser_cont_flags = 0; ssd_dialog_hide_current(dec_close); if ( dialog != NULL ) { if (ssd_dialog_currently_active_name() && !strcmp(ssd_dialog_currently_active_name(), "BonusBrowserDlg")) ssd_dialog_hide_current(dec_close); ssd_dialog_free( "BonusBrowserDlg", FALSE ); dialog = NULL; } dialog = ssd_dialog_new ( "BonusBrowserDlg", "", on_dialog_close, SSD_CONTAINER_BORDER|SSD_DIALOG_FLOAT|SSD_DIALOG_MODAL| SSD_ALIGN_CENTER|SSD_ROUNDED_CORNERS|SSD_ROUNDED_BLACK); #ifndef TOUCH_SCREEN browser_cont_flags = SSD_ALIGN_VCENTER; ssd_dialog_add_vspace(dialog, 2 ,0); #else ssd_dialog_add_vspace(dialog, 5 ,0); #endif browserCont = ssd_container_new("BonusBrowserDlg.BrowserContainer","", SSD_MAX_SIZE, get_browser_height() , SSD_ALIGN_CENTER|browser_cont_flags); browserCont->context = (void *)widget->context; browserCont->draw = draw_browser_rect; ssd_widget_set_color(browserCont, NULL, NULL); ssd_widget_add(dialog, browserCont); #ifdef TOUCH_SCREEN ssd_dialog_add_vspace(dialog, 5 ,0); button = ssd_button_label("Close_button", roadmap_lang_get("Close"), SSD_ALIGN_CENTER, on_button_close); ssd_widget_add(dialog, button); button = ssd_button_label("Navigate_button", roadmap_lang_get("Navigate"), SSD_ALIGN_CENTER, on_button_navigate); button->context = widget->context; ssd_widget_add(dialog, button); #else ssd_widget_set_left_softkey_callback(dialog, NULL); ssd_widget_set_left_softkey_text(dialog, ""); #endif ssd_dialog_activate ("BonusBrowserDlg", NULL); ssd_dialog_recalculate( "BonusBrowserDlg" ); ssd_widget_get_size( dialog, &dlg_size, NULL ); ssd_widget_get_size( browserCont, &cnt_size, NULL ); return 1; }
/* Finds the clickable widgets (short and long click) at the deeper level, * for which the current position belongs to */ BOOL ssd_widget_find_clickable_by_pos (SsdWidget widget, const RoadMapGuiPoint *point, SsdWidget* widget_short_click, SsdWidget* widget_long_click ) { while ( widget != NULL ) { SsdSize size; ssd_widget_get_size ( widget, &size, NULL ); if ((widget->position.x <= point->x) && ((widget->position.x + size.width) >= point->x) && (widget->position.y <= point->y) && ((widget->position.y + size.height) >= point->y)) { if ( widget->short_click ) *widget_short_click = widget; if ( widget->long_click ) *widget_long_click = widget; if ( ssd_widget_find_clickable_by_pos( widget->children, point, widget_short_click, widget_long_click ) ) return TRUE; } widget = widget->next; } return FALSE; }
void ssd_widget_container_size (SsdWidget dialog, SsdSize *size) { SsdSize max_size; /* Calculate size recurisvely */ if (dialog->parent) { ssd_widget_container_size (dialog->parent, size); max_size.width = size->width; max_size.height = size->height; } else { max_size.width = roadmap_canvas_width (); #ifdef TOUCH_SCREEN max_size.height = roadmap_canvas_height (); #else max_size.height = roadmap_canvas_height () - roadmap_bar_bottom_height(); #endif } ssd_widget_get_size (dialog, size, &max_size); if (dialog->draw) { RoadMapGuiRect rect; rect.minx = 0; rect.miny = 0; rect.maxx = size->width - 1; rect.maxy = size->height - 1; dialog->draw (dialog, &rect, SSD_GET_SIZE|SSD_GET_CONTAINER_SIZE); size->width = rect.maxx - rect.minx + 1; size->height = rect.maxy - rect.miny + 1; } }
static void ssd_widget_draw_one (SsdWidget w, int x, int y, int height) { RoadMapGuiRect rect; SsdSize size; ssd_widget_get_size (w, &size, NULL); if (w->flags & SSD_ALIGN_VCENTER) { y += (height - size.height) / 2; } w->position.x = x; w->position.y = y; if (size.width && size.height) { rect.minx = x; rect.miny = y; rect.maxx = x + size.width - 1; rect.maxy = y + size.height - 1; #if 0 if (!w->parent) printf("****** start draw ******\n"); printf("draw - %s:%s x=%d-%d y=%d-%d ofset_x=%d ofset_y=%d \n", w->_typeid, w->name, rect.minx, rect.maxx, rect.miny, rect.maxy, w->offset_x, w->offset_y); #endif if (!RecalculateWidgets && ssd_widget_rect_in_screen(&rect)) w->draw(w, &rect, 0); if (w->children) ssd_widget_draw (w->children, &rect, w->flags); } }
void ssd_dialog_allign_focus(void){ SsdSize size; int height; int min; SsdWidget title; title = ssd_widget_get (RoadMapDialogCurrent->container, "title_bar"); if (title) min = title->cached_size.height; else min = 0; #ifndef TOUCH_SCREEN if (!is_screen_wide()) min += roadmap_bar_top_height(); if( SSD_TAB_CONTROL & RoadMapDialogCurrent->container->flags) min += ssd_tabcontrol_get_height(); #endif #ifdef TOUCH_SCREEN height = roadmap_canvas_height(); #else height = roadmap_canvas_height() - roadmap_bar_bottom_height(); #endif if (RoadMapDialogCurrent->in_focus && RoadMapDialogCurrent->scroll_container){ if ((RoadMapDialogCurrent->in_focus->position.y == -1) || (RoadMapDialogCurrent->in_focus->position.x == -1 )){ RoadMapDialogCurrent->in_focus->position.y = 0; RoadMapDialogCurrent->scroll_container->offset_y +=20; } ssd_widget_get_size(RoadMapDialogCurrent->in_focus, &size, NULL); if (( RoadMapDialogCurrent->in_focus->position.y == 0) || ((size.height + RoadMapDialogCurrent->in_focus->position.y) > height)){ while (( RoadMapDialogCurrent->in_focus->position.y == 0) || ((size.height + RoadMapDialogCurrent->in_focus->position.y) > height)) { ssd_widget_set_offset(RoadMapDialogCurrent->scroll_container, 0, RoadMapDialogCurrent->scroll_container->offset_y-20); ssd_dialog_draw(); } while (RoadMapDialogCurrent->in_focus->position.y < min){ ssd_widget_set_offset(RoadMapDialogCurrent->scroll_container, 0, RoadMapDialogCurrent->scroll_container->offset_y+20); ssd_dialog_draw(); } } else{ while (RoadMapDialogCurrent->in_focus->position.y < min){ ssd_widget_set_offset(RoadMapDialogCurrent->scroll_container, 0, RoadMapDialogCurrent->scroll_container->offset_y+20); ssd_dialog_draw(); } } } }
static SsdWidget ssd_progress_msg_dialog_new( void ) { SsdWidget dialog, group, text; SsdWidget text_cnt, spacer, button; int text_container_height = ADJ_SCALE( SSD_PROGRESS_MSG_TXT_CNT_HEIGHT ); SsdSize dlg_size; dialog = ssd_dialog_new( SSD_PROGRESS_MSG_DLG_NAME, "", NULL, SSD_CONTAINER_BORDER|SSD_PERSISTENT| SSD_DIALOG_FLOAT|SSD_ALIGN_CENTER| SSD_ALIGN_VCENTER|SSD_ROUNDED_CORNERS|SSD_ROUNDED_BLACK); if ( !dialog ) { roadmap_log( ROADMAP_ERROR, "Error creating progress message dialog" ); return NULL; } ssd_widget_get_size( dialog, &dlg_size, NULL ); group = ssd_container_new( "Text Group", NULL, SSD_MAX_SIZE, text_container_height, SSD_END_ROW|SSD_ALIGN_CENTER ); ssd_widget_set_color ( group, NULL, NULL ); /* * Container takes 85% of the dialog width. Aligned at the center vertically and horizontally. Text should fix the container * as much as possible */ text_cnt = ssd_container_new ( "Text container", NULL, dlg_size.width * 0.85, text_container_height, SSD_ALIGN_VCENTER|SSD_ALIGN_CENTER ); ssd_widget_set_color ( text_cnt, NULL, NULL); text = ssd_text_new( SSD_PROGRESS_MSG_TEXT_FLD, "", SSD_PROGRESS_MSG_FONT_SIZE, SSD_ALIGN_VCENTER|SSD_ALIGN_CENTER|SSD_TEXT_LABEL ); ssd_widget_set_color( text, "#ffffff","#ffffff" ); ssd_widget_add( text_cnt, text ); ssd_widget_add ( group, text_cnt ); ssd_widget_add ( dialog, group ); // Space below spacer = ssd_container_new( "spacer", NULL, SSD_MAX_SIZE, ADJ_SCALE( 3 ), SSD_END_ROW ); ssd_widget_set_color(spacer, NULL, NULL); ssd_widget_add( dialog, spacer ); #ifdef TOUCH_SCREEN button = ssd_button_label( "Hide Button", roadmap_lang_get("Hide"), SSD_ALIGN_CENTER, on_button_hide ); ssd_widget_add( dialog, button ); #endif return dialog; }
int ssd_dialog_drag_motion (RoadMapGuiPoint *point) { SsdDialog dialog = RoadMapDialogCurrent; if (dialog == NULL) return 0; if (dialog->container->flags & SSD_DIALOG_FLOAT){ if (LastPointerPoint.x == -1) return 0; else return 1; } if (dialog->scroll_container && dialog->scroll_container->drag_motion) return (*dialog->scroll_container->drag_motion)(dialog->container, point); else{ if ((dialog->scroll_container) && (dialog->scroll)){ int diff = abs(dialog->drag_last_motion.y - point->y); if (diff > 5){ int goffsef; LastPointerPoint.x = -1; goffsef = (int)(1 * (point->y - dialog->drag_start_point.y ) + dialog->stop_offset); if ((goffsef) > roadmap_canvas_height()/3){ dialog->scroll_counter = SCROLL_AFTER_END_COUNTER; return 1; } else{ SsdSize size; ssd_widget_get_size(dialog->scroll_container, &size, NULL); if (size.height > roadmap_canvas_height()){ if ((dialog->scroll_container->position.y + size.height) < roadmap_canvas_height()*2/3){ dialog->scroll_counter = SCROLL_AFTER_END_COUNTER; return 1; } } } dialog->drag_last_motion.y = point->y; dialog->drag_last_motion.x = point->x; ssd_widget_set_offset(dialog->scroll_container,0,goffsef); ssd_dialog_draw(); } return 1; } } return 1; }
BOOL ssd_widget_contains_point( SsdWidget widget, const RoadMapGuiPoint *point, BOOL use_offsets ) { SsdSize size; BOOL res; ssd_widget_get_size( widget, &size, NULL ); if (widget->flags & SSD_WIDGET_HIDE) { return FALSE; } res = ( ( point->x >= ( widget->position.x + widget->click_offsets.left * use_offsets ) ) && ( point->y >= ( widget->position.y + widget->click_offsets.top * use_offsets ) ) && ( point->x <= ( widget->position.x + size.width -1 + widget->click_offsets.right * use_offsets ) ) && ( point->y <= ( widget->position.y + size.height -1 + widget->click_offsets.bottom * use_offsets ) ) ); return res; }
/* Checks if the point relies in the vicinity of the widget defined by the given frame offsets */ BOOL ssd_widget_check_point_location ( SsdWidget widget, const RoadMapGuiPoint *point, int frame_offset_x, int frame_ofset_y ) { SsdSize size; BOOL res = FALSE; if ( widget ) { ssd_widget_get_size ( widget, &size, NULL ); if ( ( ( widget->position.x - frame_offset_x ) <= point->x) && ( ( widget->position.x + size.width + frame_offset_x ) >= point->x) && ( ( widget->position.y - frame_ofset_y ) <= point->y) && ( ( widget->position.y + size.height + frame_ofset_y ) >= point->y) ) { res = TRUE; } } return res; }
static void create_confirm_dialog (BOOL default_yes, const char * textYes, const char *textNo) { SsdWidget text; SsdWidget dialog,widget_title; SsdWidget text_con; SsdSize dlg_size; // const char *question_icon[] = {"question"}; #ifndef TOUCH_SCREEN int yes_flags = 0; int no_flags = 0; if(default_yes) yes_flags|= SSD_WS_DEFWIDGET; else no_flags |= SSD_WS_DEFWIDGET; #endif dialog = ssd_dialog_new ("confirm_dialog", "", NULL, SSD_CONTAINER_BORDER|SSD_DIALOG_FLOAT| SSD_ALIGN_CENTER|SSD_CONTAINER_TITLE|SSD_ALIGN_VCENTER|SSD_ROUNDED_CORNERS|SSD_POINTER_NONE); ssd_widget_set_color (dialog, "#000000", "#ff0000000"); ssd_widget_get_size( dialog, &dlg_size, NULL ); /* Spacer */ ssd_widget_add (dialog, ssd_container_new ("spacer1", NULL, 0, 15, SSD_END_ROW)); /* image_container = ssd_container_new ("image_container", NULL, SSD_MIN_SIZE, SSD_MIN_SIZE, SSD_ALIGN_RIGHT); ssd_widget_set_color (image_container, "#000000", "#ff0000000"); ssd_widget_add (image_container, ssd_button_new ("question", "question", question_icon , 1, SSD_ALIGN_CENTER|SSD_ALIGN_VCENTER , NULL)); // Image container ssd_widget_add (dialog,image_container); */ text_con = ssd_container_new ("text_container", NULL, ( dlg_size.width * 9 )/10, /* 90% of dialog width */ SSD_MIN_SIZE, SSD_END_ROW|SSD_ALIGN_CENTER ); ssd_widget_set_color (text_con, "#000000", "#ff0000000"); // Text box text = ssd_text_new ("text", "", 16, SSD_END_ROW|SSD_WIDGET_SPACE); ssd_widget_add (text_con,text); ssd_widget_add(dialog, text_con); widget_title = ssd_widget_get( dialog, "title_text" ); ssd_text_set_font_size( widget_title, 20 ); #ifdef TOUCH_SCREEN ssd_dialog_add_vspace( dialog, 10, SSD_START_NEW_ROW ); ssd_widget_add (dialog, ssd_button_label (roadmap_lang_get ("Yes"), textYes, SSD_ALIGN_CENTER| SSD_WS_TABSTOP, yes_button_callback)); ssd_widget_add (dialog, ssd_button_label (roadmap_lang_get ("No"), textNo, SSD_ALIGN_CENTER| SSD_WS_TABSTOP, no_button_callback)); #else set_soft_keys(dialog, textYes, textNo); #endif ssd_widget_add (dialog, ssd_container_new ("spacer2", NULL, 0, 10, SSD_START_NEW_ROW|SSD_WIDGET_SPACE)); }
static void draw (SsdWidget widget, RoadMapGuiRect *rect, int flags) { RoadMapGuiPoint points[5]; int count = 5; #ifdef OPENGL RoadMapGuiPoint position; RoadMapGuiPoint sign_bottom, sign_top; static RoadMapImage focus_image; #endif const char* background = widget->bg_color; if (!(flags & SSD_GET_SIZE)) { if (widget->in_focus && widget->focus_highlight ) background = "#b0d504"; else if (widget->background_focus) background = "#8a8a8a"; if (background) { if (widget->flags & SSD_ROUNDED_CORNERS){ RoadMapGuiRect erase_rect; erase_rect.minx = rect->minx + SSD_ROUNDED_CORNER_WIDTH; erase_rect.miny = rect->miny + SSD_ROUNDED_CORNER_HEIGHT; erase_rect.maxx = rect->maxx - SSD_ROUNDED_CORNER_WIDTH; erase_rect.maxy = rect->maxy - SSD_ROUNDED_CORNER_HEIGHT; roadmap_canvas_select_pen (bg); roadmap_canvas_set_foreground (background); //roadmap_canvas_erase_area (&erase_rect); } else{ if (!(widget->flags & SSD_DIALOG_TRANSPARENT)){ roadmap_canvas_select_pen (bg); roadmap_canvas_set_foreground (background); if ((widget->flags & SSD_CONTAINER_TXT_BOX) || (widget->flags & SSD_CONTAINER_SEARCH_BOX)){ rect->minx += 10; rect->maxx -= 10; } else roadmap_canvas_erase_area (rect); #if defined(OPENGL) && !defined(_WIN32) if (widget->in_focus && widget->focus_highlight ){ if (!focus_image) focus_image = roadmap_res_get( RES_BITMAP, RES_SKIN, "focus" ); if (focus_image){ sign_top.x = rect->minx; sign_top.y = rect->miny; position.x = roadmap_canvas_image_width(focus_image)/2; position.y = roadmap_canvas_image_height(focus_image) / 2; sign_bottom.x = rect->maxx; sign_bottom.y = rect->maxy; roadmap_canvas_draw_image_stretch( focus_image, &sign_top, &sign_bottom, &position, 0, IMAGE_NORMAL ); } } #endif } } } if ((widget->flags & SSD_SHADOW_BG) ) { draw_shadow_bg(); } if ((widget->flags & SSD_CONTAINER_TITLE) && !(widget->flags & SSD_DIALOG_FLOAT) && !(widget->flags & SSD_DIALOG_TRANSPARENT) ) { draw_bg(rect); } } if (widget->flags & SSD_CONTAINER_BORDER) { points[0].x = rect->minx + 1; #ifndef TOUCH_SCREEN points[0].y = rect->miny + 1; points[1].y = rect->miny + 1; points[4].y = rect->miny + 1; #else points[0].y = rect->miny; points[1].y = rect->miny; points[4].y = rect->miny ; #endif points[1].x = rect->maxx - 0; points[2].x = rect->maxx - 0; points[2].y = rect->maxy - 0; points[3].x = rect->minx + 1; points[3].y = rect->maxy - 0; points[4].x = rect->minx + 1; if (!(flags & SSD_GET_SIZE)) { const char *color = default_fg; RoadMapPosition *position = NULL; roadmap_canvas_select_pen (border); if (widget->fg_color) color = widget->fg_color; roadmap_canvas_set_foreground (color); if (widget->flags & SSD_ROUNDED_CORNERS){ int pointer_type = POINTER_NONE; int header_type = HEADER_NONE; int style = STYLE_NORMAL; int position_offset = widget->offset_y; #ifdef TOUCH_SCREEN widget->flags &= ~SSD_POINTER_MENU; #endif if (widget->flags & SSD_POINTER_MENU){ pointer_type = POINTER_MENU; #ifndef OPENGL points[2].y -= 17; #endif } else if (widget->flags & SSD_POINTER_COMMENT){ pointer_type = POINTER_COMMENT; #ifdef OPENGL points[2].y += 20; /* The height of the pointer */ #else points[2].y -= 7; #endif } else if (widget->flags & SSD_POINTER_NONE){ pointer_type = POINTER_NONE; if (!((widget->flags & SSD_ROUNDED_WHITE) || (widget->flags & SSD_ROUNDED_BLACK))) points[2].y -= 10; } if (widget->in_focus && widget->focus_highlight ) background = "#b0d504"; else if ((widget->flags & SSD_POINTER_COMMENT) | (widget->flags & SSD_POINTER_MENU) | (widget->flags & SSD_POINTER_NONE)) background = "#e4f1f9"; else background = "#f3f3f5"; background = "#d2dfef"; header_type = HEADER_NONE; if (widget->flags & SSD_ROUNDED_WHITE){ style = STYLE_WHITE; if (widget->in_focus && widget->focus_highlight ) background = "#b0d504"; else background = "#ffffff"; } if (widget->flags & SSD_ROUNDED_BLACK){ style = STYLE_BLACK; if (widget->in_focus && widget->focus_highlight ) background = "#b0d504"; else background = "#000000"; } if (widget->flags & SSD_POINTER_LOCATION){ if (widget->context != NULL){ pointer_type = POINTER_POSITION; position = (RoadMapPosition *)widget->context; //position_offset = ADJ_SCALE(-40); } } if (widget->flags & SSD_POINTER_FIXED_LOCATION){ if (widget->context != NULL){ pointer_type = POINTER_FIXED_POSITION; position = (RoadMapPosition *)widget->context; } } roadmap_display_border(style, header_type, pointer_type, &points[2], &points[0], background, position, position_offset); } else roadmap_canvas_draw_multiple_lines (1, &count, points, 1); } if (widget->flags & SSD_ROUNDED_CORNERS){ if (widget->flags & SSD_ROUNDED_WHITE){ rect->minx += 4; rect->miny += 4; rect->maxx -= 4; rect->maxy -= 4; } else{ rect->minx += 10; if ((widget->flags & SSD_CONTAINER_TITLE) || (widget->flags & SSD_POINTER_MENU) || (widget->flags & SSD_POINTER_NONE)) rect->miny += 10; else rect->miny += 4; rect->maxx -= 10; rect->maxy -= 10; } } else{ rect->minx += 2; rect->miny += 2; rect->maxx -= 2; rect->maxy -= 2; } } if (widget->flags & SSD_CONTAINER_TXT_BOX){ if (!(flags & SSD_GET_SIZE)){ if (background){ rect->minx -= 10; rect->maxx += 10; } draw_text_box(widget, rect); } rect->minx += 20; rect->miny += 10; rect->maxx -= 20; rect->maxy -= 10; } if (widget->flags & SSD_CONTAINER_SEARCH_BOX){ if (!(flags & SSD_GET_SIZE)){ if (background){ rect->minx -= 10; rect->maxx += 10; } draw_search_box(widget, rect); } rect->minx += 20; rect->miny += 10; rect->maxx -= 20; rect->maxy -= 10; } if (widget->flags & SSD_CONTAINER_TITLE){ ssd_widget_set_left_softkey_text(widget, widget->left_softkey); ssd_widget_set_right_softkey_text(widget, widget->right_softkey); } if ((flags & SSD_GET_CONTAINER_SIZE) && (widget->flags & SSD_CONTAINER_TITLE)) { SsdWidget title; title = ssd_widget_get (widget, "title_bar"); if (title) { SsdSize title_size; SsdSize max_size; max_size.width = rect->maxx - rect->minx + 1; max_size.height = rect->maxy - rect->miny + 1; ssd_widget_get_size (title, &title_size, &max_size); rect->miny += title_size.height; } } }
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 ssd_widget_draw_pack (SsdWidget w, const RoadMapGuiRect *rect) { SsdWidget row[MAX_WIDGETS_PER_ROW]; int width = rect->maxx - rect->minx + 1; int height = rect->maxy - rect->miny + 1; int minx = rect->minx; int cur_y = rect->miny; int cur_width = 0; int count = 0; SsdWidget w_last_drawn = NULL; SsdWidget w_prev = NULL; while (w != NULL) { SsdSize size = {0,0}; SsdSize max_size; if (w->flags & SSD_WIDGET_HIDE) { w = w->next; continue; } if (!count) { width = rect->maxx - rect->minx + 1; height = rect->maxy - cur_y + 1; minx = rect->minx; if (w->flags & SSD_WIDGET_SPACE) { width -= 4; height -= 2; cur_y += 2; minx += 2; } } if (!(w->flags & SSD_START_NEW_ROW)) { max_size.width = width - cur_width; max_size.height = height; ssd_widget_get_size (w, &size, &max_size); } if ((count == MAX_WIDGETS_PER_ROW) || ((count > 0) && (((cur_width + size.width) > width) || (w->flags & SSD_START_NEW_ROW)))) { if (w_last_drawn && (w_last_drawn->flags & SSD_WIDGET_SPACE)) { cur_y += SSD_WIDGET_SEP; } cur_y += ssd_widget_draw_row (row, count, width, height, minx, cur_y); count = 0; cur_width = 0; w_last_drawn = w_prev; w_prev = NULL; width = rect->maxx - rect->minx + 1; height = rect->maxy - cur_y + 1; minx = rect->minx; if (w->flags & SSD_WIDGET_SPACE) { width -= 4; height -= 2; cur_y += 2; minx += 2; } max_size.width = width; max_size.height = height; ssd_widget_get_size (w, &size, &max_size); } row[count++] = w; cur_width += size.width; if (w_prev && w_prev->flags & SSD_WIDGET_SPACE) { cur_width += SSD_WIDGET_SEP; } if (w->flags & SSD_END_ROW) { if (w_last_drawn && (w_last_drawn->flags & SSD_WIDGET_SPACE)) { cur_y += SSD_WIDGET_SEP; } cur_y += ssd_widget_draw_row (row, count, width, height, minx, cur_y); count = 0; cur_width = 0; w_last_drawn = w; w_prev = NULL; } w_prev = w; w = w->next; } if (count) { if (w_last_drawn && (w_last_drawn->flags & SSD_WIDGET_SPACE)) { cur_y += SSD_WIDGET_SEP; } ssd_widget_draw_row (row, count, width, height, minx, cur_y); } }
static void ssd_widget_draw_grid (SsdWidget w, const RoadMapGuiRect *rect) { SsdWidget widgets[MAX_WIDGETS_PER_ROW]; int width = rect->maxx - rect->minx + 1; int height = rect->maxy - rect->miny + 1; SsdSize max_size; int cur_y = rect->miny; int max_height = 0; int avg_width = 0; int count = 0; int width_per_row; int cur_width = 0; int rows; int num_widgets; int space; int i; max_size.width = width; max_size.height = height; while (w != NULL) { SsdSize size; ssd_widget_get_size (w, &size, &max_size); if (size.height > max_height) max_height = size.height; avg_width += size.width; widgets[count] = w; count++; if (count == sizeof(widgets) / sizeof(SsdWidget)) { roadmap_log (ROADMAP_FATAL, "Too many widgets in grid!"); } w = w->next; } max_height += SSD_WIDGET_SEP; avg_width = avg_width / count + 1; rows = height / max_height; if (rows == 0) rows = 1; while ((rows > 1) && ((count * avg_width / rows) < (width * 3 / 5))) rows--; if ((rows == 1) && (count > 2)) rows++; width_per_row = count * avg_width / rows; num_widgets = 0; space = (height - max_height*rows) / (rows + 1); for (i=0; i < count; i++) { SsdSize size; ssd_widget_get_size (widgets[i], &size, NULL); cur_width += avg_width; if (size.width > avg_width*1.5) { cur_width += avg_width; } num_widgets++; if ((cur_width >= width_per_row) || (i == (count-1))) { cur_y += space; ssd_widget_draw_grid_row (&widgets[i-num_widgets+1], num_widgets, width, avg_width, max_height, rect->minx, cur_y); cur_y += max_height; cur_width = 0; num_widgets = 0; } } }
static int ssd_widget_draw_row (SsdWidget *w, int count, int width, int height, int x, int y) { int row_height = 0; int cur_x; int total_width; int space; int vcenter = 0; int bottom = 0; int i; int rtl = ssd_widget_rtl(w[0]->parent); SsdWidget prev_widget; int orig_width = width; int orig_x = x; if (y > roadmap_canvas_height()){ return 0; } if (w[0]->flags & SSD_ALIGN_LTR) rtl = 0; if (rtl) cur_x = x; else cur_x = x + width; for (i=0; i<count; i++) { SsdSize size; ssd_widget_get_size (w[i], &size, NULL); if (size.height > row_height) row_height = size.height; if (w[i]->flags & SSD_ALIGN_VCENTER) vcenter = 1; if (w[i]->flags & SSD_ALIGN_BOTTOM) bottom = 1; } if (bottom) { y += (height - row_height); } else if (vcenter) { y += (height - row_height) / 2; } for (i=count-1; i>=0; i--) { SsdSize size; ssd_widget_get_size (w[i], &size, NULL); if (w[i]->flags & SSD_ALIGN_RIGHT) { cur_x += w[i]->offset_x; if (rtl) { if ((i < (count-1)) && (w[i+1]->flags & SSD_WIDGET_SPACE)) { cur_x += SSD_WIDGET_SEP; } ssd_widget_draw_one (w[i], cur_x, y + w[i]->offset_y, row_height); cur_x += size.width; } else { cur_x -= size.width; if ((i < (count-1)) && (w[i+1]->flags & SSD_WIDGET_SPACE)) { cur_x -= SSD_WIDGET_SEP; } ssd_widget_draw_one (w[i], cur_x, y + w[i]->offset_y, row_height); } //width -= size.width; if ((i < (count-1)) && (w[i+1]->flags & SSD_WIDGET_SPACE)) { //width -= SSD_WIDGET_SEP; } count--; if (i != count) { memmove (&w[i], &w[i+1], sizeof(w[0]) * count - i); } } } if (rtl) cur_x = x + width; else cur_x = x; prev_widget = NULL; while (count > 0) { SsdSize size; if (w[0]->flags & SSD_ALIGN_CENTER) { break; } ssd_widget_get_size (w[0], &size, NULL); if (rtl) { cur_x -= size.width; cur_x -= w[0]->offset_x; if (prev_widget && (prev_widget->flags & SSD_WIDGET_SPACE)) { cur_x -= SSD_WIDGET_SEP; } ssd_widget_draw_one (w[0], cur_x, y + w[0]->offset_y, row_height); } else { cur_x += w[0]->offset_x; if (prev_widget && (prev_widget->flags & SSD_WIDGET_SPACE)) { cur_x += SSD_WIDGET_SEP; } ssd_widget_draw_one (w[0], cur_x, y + w[0]->offset_y, row_height); cur_x += size.width; } width -= size.width; if (prev_widget && (prev_widget->flags & SSD_WIDGET_SPACE)) { width -= SSD_WIDGET_SEP; } prev_widget = *w; w++; count--; } if (count == 0) return row_height; /* align center */ total_width = 0; for (i=0; i<count; i++) { SsdSize size; ssd_widget_get_size (w[i], &size, NULL); total_width += size.width; } space = (width - total_width) / (count + 1); for (i=0; i<count; i++) { SsdSize size; ssd_widget_get_size (w[i], &size, NULL); // beginning of patch to take care of title which wasn't aligned to center - dan if (!strcmp(w[i]->name,"title_text")){ total_width=0; total_width += size.width; cur_x = orig_x; if (rtl) cur_x +=orig_width; space = (orig_width - total_width) / (count + 1); } // end of patch if (rtl) { cur_x -= space; cur_x -= size.width; cur_x -= w[i]->offset_x; ssd_widget_draw_one (w[i], cur_x, y + w[i]->offset_y, row_height); } else { cur_x += space; cur_x += w[i]->offset_x; ssd_widget_draw_one (w[i], cur_x, y + w[i]->offset_y, row_height); cur_x += size.width; } } return row_height; }
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(); } }
static void calc_pack_size (SsdWidget w_cur, RoadMapGuiRect *rect, SsdSize *size) { int width = rect->maxx - rect->minx + 1; int height = rect->maxy - rect->miny + 1; int cur_width = 0; int max_height = 0; int max_width = 0; int index_in_row= 0; SsdWidget w_last_drawn= NULL; SsdWidget w_prev = NULL; while( w_cur) { SsdSize max_size; SsdSize size = {0, 0}; // If hiding widget - hide also all children: if (w_cur->flags & SSD_WIDGET_HIDE) { w_cur = w_cur->next; continue; } if (0 == index_in_row) { width = rect->maxx - rect->minx + 1; // Padd with space? if (w_cur->flags & SSD_WIDGET_SPACE) { rect->miny += 2; width -= 2; cur_width += 2; } } if (!(w_cur->flags & SSD_START_NEW_ROW)) { max_size.width = width; max_size.height= rect->maxy - rect->miny + 1; ssd_widget_get_size (w_cur, &size, &max_size); } if ((index_in_row == MAX_WIDGETS_PER_ROW) || ((index_in_row > 0) && ((cur_width + size.width) > width)) || (w_cur->flags & SSD_START_NEW_ROW)) { if (cur_width > max_width) max_width = cur_width; if (w_last_drawn && (w_last_drawn->flags & SSD_WIDGET_SPACE)) { rect->miny += SSD_WIDGET_SEP; } index_in_row = 0; cur_width = 0; w_last_drawn = w_cur; w_prev = NULL; rect->miny += max_height; max_height = 0; if (w_cur->flags & SSD_WIDGET_SPACE) { rect->miny += 2; width -= 2; cur_width += 2; } max_size.width = width; max_size.height = rect->maxy - rect->miny + 1; ssd_widget_get_size (w_cur, &size, &max_size); } index_in_row++; cur_width += size.width; if (w_prev && w_prev->flags & SSD_WIDGET_SPACE) { cur_width += SSD_WIDGET_SEP; } if (size.height > max_height) max_height = size.height; if (w_cur->flags & SSD_END_ROW) { if (cur_width > max_width) max_width = cur_width; index_in_row = 0; cur_width = 0; rect->miny += max_height; if (w_last_drawn && (w_last_drawn->flags & SSD_WIDGET_SPACE)) { rect->miny += SSD_WIDGET_SEP; } max_height = 0; w_last_drawn = w_cur; w_prev = NULL; } w_prev = w_cur; w_cur = w_cur->next; } if (index_in_row) { if (cur_width > max_width) max_width = cur_width; index_in_row = 0; cur_width = 0; rect->miny += max_height; if (w_last_drawn && (w_last_drawn->flags & SSD_WIDGET_SPACE)) { rect->miny += SSD_WIDGET_SEP; } } size->width = max_width; size->height = height - (rect->maxy - rect->miny); }