static void set_area_ui_object_text (ui_object *obj, char *text) { int length; area_ui_object *area; ui_object *parent; area = obj->data; if (area->text) { safe_free (area->text); } area->text = NULL; if (text) { length = strlen (text); area->text = (char *) safe_malloc ((sizeof (char) * length) + 1); strcpy (area->text, text); } parent = get_ui_object_parent (obj); if (parent) { set_ui_object_redraw (parent, TRUE); while ((parent) && (get_ui_object_clear (parent))) { parent = get_ui_object_parent (parent); if (parent) { set_ui_object_redraw (parent, TRUE); } } } else { set_ui_object_redraw (obj, TRUE); } }
static float get_area_ui_object_virtual_y (ui_object *obj) { area_ui_object *area; float py = 0; ui_object *parent; if (get_ui_object_virtual_coords (obj)) { // is this right ? check parent = get_ui_object_parent (obj); if (parent) { //py = get_ui_object_virtual_y (parent); } area = (area_ui_object *) obj->data; return area->y_start + py; } else { float y; ui_object *parent; parent = get_ui_object_parent (obj); if (parent) { y = (get_ui_object_y (obj) - get_ui_object_y (parent)) / get_ui_object_y_size (parent); } else { y = get_ui_object_y (obj) / get_screen_height (video_screen); } return y; } }
static float get_area_ui_object_virtual_x (ui_object *obj) { area_ui_object *area; float px = 0; ui_object *parent; if (get_ui_object_virtual_coords (obj)) { // is this right ? check parent = get_ui_object_parent (obj); if (parent) { //px = get_ui_object_virtual_x (parent); } area = (area_ui_object *) obj->data; return area->x_start + px; } else { float x; ui_object *parent; parent = get_ui_object_parent (obj); if (parent) { x = (get_ui_object_x (obj) - get_ui_object_x (parent)) / get_ui_object_x_size (parent); } else { x = get_ui_object_x (obj) / get_screen_width (video_screen); } return x; } }
static void set_toggle_ui_object_state (ui_object *obj, int flag) { area_ui_object *area; ui_object *parent; area = obj->data; parent = get_ui_object_parent (obj); // toggle object state if (area->state == UI_OBJECT_STATE_ON) { area->state = UI_OBJECT_STATE_OFF; } else { area->state = UI_OBJECT_STATE_ON; } if (parent) { set_ui_object_redraw (parent, TRUE); while ((parent) && (get_ui_object_clear (parent))) { parent = get_ui_object_parent (parent); if (parent) { set_ui_object_redraw (parent, TRUE); } } } else { set_ui_object_redraw (obj, TRUE); } }
void set_toggle_button_off (ui_object *obj) { area_ui_object *area; ui_object *parent; area = obj->data; area->state = UI_OBJECT_STATE_OFF; parent = get_ui_object_parent (obj); if (parent) { set_ui_object_redraw (parent, TRUE); } else { set_ui_object_redraw (obj, TRUE); } }
static float get_area_ui_object_x (ui_object *obj) { area_ui_object *area; float px = 0; ui_object *parent; parent = get_ui_object_parent (obj); if (parent) { px = get_ui_object_x (parent); } area = obj->data; return area->x + px; }
void resize_pop_up_list (ui_object *obj) { float y; ui_object *parent; ASSERT (obj); ASSERT (obj->type == UI_TYPE_LIST_BOX); parent = get_ui_object_parent (obj); ASSERT (parent); ASSERT (parent->type == UI_TYPE_AREA); // // re-size the list objects when items are added // y = get_next_list_position (obj) / get_ui_object_y_size (parent); set_ui_object_virtual_y_size (obj, y); set_ui_object_virtual_y_size (obj, 1.0); }
static void notify_weapon_loading_page_change_weapon (ui_object *obj, void *arg) { entity *en; ui_object *gunship_page; int hardpoint; ASSERT (obj); hardpoint = get_ui_object_item_number2 (obj); gunship_page = get_ui_object_parent (obj); ASSERT (gunship_page); en = get_local_entity_safe_ptr (get_ui_object_item_number (gunship_page)); ASSERT (en); if (get_helicopter_allowed_to_rearm (en)) { weapon_loading_select_next_weapon (en, hardpoint); } rebuild_default_payload_list (en); }
static float get_area_ui_object_y (ui_object *obj) { area_ui_object *area; float py = 0; ui_object *parent; parent = get_ui_object_parent (obj); if (parent) { py = get_ui_object_y (parent); } area = obj->data; return area->y + py; }
static void set_area_ui_object_drawable (ui_object *obj, int flag) { ui_object *parent; area_ui_object *area; area = obj->data; if (area->drawable!= flag) { area->drawable = flag; if (area->drawable) { set_ui_object_redraw (obj, TRUE); } else { parent = get_ui_object_parent (obj); if (parent) { set_ui_object_redraw (parent, TRUE); while ((parent) && (get_ui_object_clear (parent))) { set_ui_object_redraw (parent, TRUE); parent = get_ui_object_parent (parent); } } } } }
void set_radio_button_on (ui_object *obj) { area_ui_object *area; ui_object *parent; area = obj->data; area->state = UI_OBJECT_STATE_ON; parent = get_ui_object_parent (obj); if (parent) { set_ui_object_redraw (parent, TRUE); while ((parent) && (get_ui_object_clear (parent))) { parent = get_ui_object_parent (parent); if (parent) { set_ui_object_redraw (parent, TRUE); } } } else { set_ui_object_redraw (obj, TRUE); } }
int check_ui_object_clipped (ui_object *obj) { int flag; ui_object *parent; float x1, x2, y1, y2, x_min, y_min, x_max, y_max, old_vp_x1, old_vp_y1, old_vp_x2, old_vp_y2; old_vp_x1 = active_viewport.x_min; old_vp_y1 = active_viewport.y_min; old_vp_x2 = active_viewport.x_max; old_vp_y2 = active_viewport.y_max; parent = get_ui_object_parent (obj); ASSERT (parent); x1 = get_ui_object_x (parent); y1 = get_ui_object_y (parent); x2 = x1 + get_ui_object_x_size (parent); y2 = y1 + get_ui_object_y_size (parent); x_min = get_ui_object_x (obj); y_min = get_ui_object_y (obj); x_max = x_min + get_ui_object_x_size (obj); y_max = y_min + get_ui_object_y_size (obj); set_viewport (x1, y1, x2, y2); flag = ui_clip_area (&x_min, &y_min, &x_max, &y_max); set_viewport (old_vp_x1, old_vp_y1, old_vp_x2, old_vp_y2); return flag; }
static float get_area_ui_object_y (ui_object *obj) { area_ui_object *area; float y, py = 0; ui_object *parent; parent = get_ui_object_parent (obj); if (parent) { py = get_ui_object_y (parent); } area = (area_ui_object *) obj->data; y = area->y_start + (get_ui_object_bounded_t_value (obj) * (area->y_end - area->y_start)); if (area->virtual_coords) { if (parent) { y *= get_ui_object_y_size (parent); } else { y *= get_screen_height (video_screen); } } return y + py; }
static float get_area_ui_object_x (ui_object *obj) { area_ui_object *area; float x, px = 0; ui_object *parent; parent = get_ui_object_parent (obj); if (parent) { px = get_ui_object_x (parent); } area = (area_ui_object *) obj->data; x = area->x_start + ( get_ui_object_bounded_t_value (obj) * ( area->x_end - area->x_start ) ); if (area->virtual_coords) { if (parent) { x *= get_ui_object_x_size (parent); } else { x *= get_screen_width (video_screen); } } return x + px; }
ui_object *locate_next_slider (ui_object *obj) { ui_object *current_object, *parent; // search through all next objects, starting with the first. // if not parent then start from current position. current_object = obj; parent = get_ui_object_parent (obj); if (parent) { current_object = get_ui_object_child (parent); } while (current_object) { if ( (current_object->type == UI_TYPE_VSLIDER) || (current_object->type == UI_TYPE_HSLIDER) || (current_object->type == UI_TYPE_HVSLIDER) || (current_object->type == UI_TYPE_MSLIDER) ) { return current_object; } current_object = get_ui_object_next (current_object); } return NULL; }
static void set_text_ui_object_text (ui_object *obj, char *text) { font_types old_font; int length; float pixel_length; area_ui_object *area; ui_object *parent; area = obj->data; if (area->text) { safe_free (area->text); } area->text = NULL; old_font = get_ui_font_type (); if (area->font_type != -1) { set_ui_font_type (area->font_type); } parent = get_ui_object_parent (obj); if (text) { length = strlen (text); pixel_length = ui_get_string_length (text); area->x_size_start = pixel_length + 5; area->y_size_start = ui_get_font_height () + LIST_ITEM_SPACING; if ((area->virtual_coords) && (parent)) { area->x_size_start /= get_ui_object_x_size (parent); area->y_size_start /= get_ui_object_y_size (parent); } area->text = (char *) safe_malloc ((sizeof (char) * length) + 1); strcpy (area->text, text); } if (parent) { set_ui_object_redraw (parent, TRUE); while ((parent) && (get_ui_object_clear (parent))) { parent = get_ui_object_parent (parent); if (parent) { set_ui_object_redraw (parent, TRUE); } } } else { set_ui_object_redraw (obj, TRUE); } set_ui_font_type (old_font); }
static void call_text_ui_object_function (ui_object *obj, void *arg) { void ((*function) (ui_object *object, void *arg)); text_ui_object *text; ui_object *notify_obj, *list_parent; int mouse_state, mouse_graphic_state; text = (text_ui_object *) obj->data; function = text->area.function; if (function) { //set_ui_object_redraw (obj, TRUE); { ui_object *temp_obj; temp_obj = obj; while (temp_obj) { set_ui_object_redraw (temp_obj, TRUE); if (!get_ui_object_clear (temp_obj)) { break; } temp_obj = get_ui_object_parent (temp_obj); } } if ((int) arg == BUTTON_STATE_DOWN) { set_ui_object_state (obj, UI_OBJECT_STATE_ON); } else { set_ui_object_state (obj, UI_OBJECT_STATE_OFF); } // // if list text get lists notify type // list_parent = get_ui_object_parent (obj); notify_obj = obj; if (list_parent->type == UI_TYPE_LIST_BOX) { notify_obj = list_parent; } if ( (get_ui_object_notify_on (notify_obj) == (int) arg) || (get_ui_object_notify_on (notify_obj) == NOTIFY_TYPE_BUTTON_EITHER) ) { mouse_state = get_mouse_on (); mouse_graphic_state = get_mouse_graphic_on (); // set_mouse_off (); ui_repaint (); function (obj, (void *) arg); } // if (mouse_state) // { // // set_mouse_on (); // } // // if (mouse_graphic_state) // { // // set_mouse_graphic_on (); // } } }
static void set_number_ui_object_state (ui_object *obj, int flag) { number_ui_object *number; ui_object *next, *parent; number = obj->data; if (flag == UI_OBJECT_STATE_ON) { parent = get_ui_object_parent (obj); if (parent) { next = get_ui_object_child (parent); } else { next = get_ui_object_next (obj); } while (next) { if (next->type == UI_TYPE_NUMBER) { number = next->data; number->area.state = UI_OBJECT_STATE_OFF; } next = get_ui_object_next (next); } number = obj->data; number->area.state = flag; if (parent) { set_ui_object_redraw (parent, TRUE); while ((parent) && (get_ui_object_clear (parent))) { parent = get_ui_object_parent (parent); if (parent) { set_ui_object_redraw (parent, TRUE); } } } else { set_ui_object_redraw (obj, TRUE); } } }
static void draw_area_ui_object (ui_object *obj) { float x, y, x1, y1, x2, y2; int redraw_flag = FALSE, masked, width, height, pitch; font_types font_id; area_ui_object *area; struct SCREEN *old_active_screen, *memory_graphic; unsigned short int *graphic; struct ZOOMABLE_GRAPHIC *zoomable_graphic; unsigned char *data; ui_object *parent; if (get_ui_object_redraw (obj)) { area = (area_ui_object *) obj->data; //debug_log ("AR_DRAW: drawing area %f, %f %f, %f", area->x, area->y, area->x_size, area->y_size); x1 = area->x; y1 = area->y; x2 = x1 + area->x_size; y2 = y1 + area->y_size; old_active_screen = get_active_screen (); if (get_ui_object_active_screen (obj)) { set_active_screen (get_ui_object_active_screen (obj)); } else { set_active_screen (video_screen); } if (lock_screen (active_screen)) { switch (get_ui_object_graphic_type (obj)) { case UI_OBJECT_GRAPHIC: { if (!get_ui_object_clear (obj)) { graphic = get_ui_object_graphic (obj); ui_draw_graphic (x1, y1, x2, y2, graphic); redraw_flag = TRUE; } else { parent = get_ui_object_parent (obj); if (parent) { graphic = get_ui_object_graphic (parent); ui_draw_part_graphic (x1, y1, x2, y2, x1, y1, graphic); redraw_flag = TRUE; } } break; } case UI_OBJECT_MEMORY_GRAPHIC: { memory_graphic = get_ui_object_memory_graphic (obj); if (lock_screen (memory_graphic)) { width = get_screen_width (memory_graphic); height = get_screen_height (memory_graphic); data = get_screen_data (memory_graphic); pitch = get_screen_pitch (memory_graphic); masked = get_ui_object_clear (obj); ui_draw_memory_graphic (obj, x1, y1, x2, y2, width, height, pitch, masked); unlock_screen (memory_graphic); } redraw_flag = TRUE; break; } case UI_OBJECT_ALPHA_GRAPHIC: { if (!get_ui_object_clear (obj)) { graphic = get_ui_object_graphic (obj); ui_draw_alpha_graphic (x1, y1, x2, y2, graphic); redraw_flag = TRUE; } else { parent = get_ui_object_parent (obj); if (parent) { graphic = get_ui_object_graphic (parent); ui_draw_part_alpha_graphic (x1, y1, x2, y2, x1, y1, graphic); redraw_flag = TRUE; } } break; } case UI_OBJECT_ZOOMABLE_PALETTE_GRAPHIC: { if (!get_ui_object_clear (obj)) { zoomable_graphic = get_ui_object_zoomable_palette_graphic (obj); draw_zoomable_graphic (zoomable_graphic, area->cx, area->cy, x1, y1, x2, y2, area->zoom); redraw_flag = TRUE; } break; } case UI_OBJECT_NO_GRAPHIC: default: { if (!get_ui_object_clear (obj)) { ui_draw_area (x1, y1, x2, y2); redraw_flag = TRUE; } } } // text position if (get_ui_object_text (obj)) { font_id = get_ui_font (); set_ui_font (get_ui_object_font (obj)); get_text_position (&x, &y, x1, y1, x2, y2, obj); ui_display_text (get_ui_object_text (obj), x, y); set_ui_font (font_id); redraw_flag = TRUE; } if (redraw_flag) { set_ui_repaint_area (x1 + ui_x_origin, y1 + ui_y_origin, x2 + ui_x_origin + 1, y2 + ui_y_origin + 1); } unlock_screen (active_screen); } set_active_screen (old_active_screen); area->redraw --; call_ui_object_draw_function (obj, NULL); } }
static void set_radio_ui_object_state (ui_object *obj, int flag) { area_ui_object *area; ui_object *next, *parent; area = obj->data; if (flag == UI_OBJECT_STATE_ON) { parent = get_ui_object_parent (obj); if (parent) { next = get_ui_object_child (parent); } else { next = get_ui_object_next (obj); } while (next) { if (next->type == UI_TYPE_RADIO) { area = next->data; area->state = UI_OBJECT_STATE_OFF; } next = get_ui_object_next (next); } area = obj->data; area->state = flag; if (parent) { set_ui_object_redraw (parent, TRUE); while ((parent) && (get_ui_object_clear (parent))) { parent = get_ui_object_parent (parent); if (parent) { set_ui_object_redraw (parent, TRUE); } } } else { set_ui_object_redraw (obj, TRUE); } } else if (flag == UI_OBJECT_STATE_HIGHLIGHTED) { area->state = flag; } else if (flag == UI_OBJECT_STATE_OFF) { // if (area->state == UI_OBJECT_STATE_HIGHLIGHTED) // Removed - DL { area->state = flag; } } }
static void set_text_ui_object_state (ui_object *obj, int flag) { area_ui_object *area; ui_object *next, *parent; area = obj->data; if (flag == UI_OBJECT_STATE_ON) { parent = get_ui_object_parent (obj); if (parent) { next = get_ui_object_child (parent); } else { next = get_ui_object_next (obj); } while (next) { if (next->type == UI_TYPE_TEXT) { area = next->data; area->state = UI_OBJECT_STATE_OFF; } next = get_ui_object_next (next); } area = obj->data; area->state = flag; if (parent) { set_ui_object_redraw (parent, TRUE); while ((parent) && (get_ui_object_clear (parent))) { parent = get_ui_object_parent (parent); if (parent) { set_ui_object_redraw (parent, TRUE); } } } else { set_ui_object_redraw (obj, TRUE); } } }
static void set_area_ui_object_parent (ui_object *obj, ui_object *parent) { area_ui_object *area; ui_object *next; // // Remove object from current_parents list // if (get_ui_object_parent (obj)) { ui_object *prev, *parent; next = get_ui_object_next (obj); prev = get_ui_object_prev (obj); parent = get_ui_object_parent (obj); if (next) { set_ui_object_prev (next, prev); } if (prev) { set_ui_object_next (prev, next); } if (get_ui_object_child (parent) == obj) { if (prev) { set_ui_object_child (parent, prev); } else if (next) { set_ui_object_child (parent, next); } else { set_ui_object_child (parent, NULL); } } } // // insert obj into new_parents list // area = (area_ui_object *) obj->data; next = get_ui_object_child (parent); if (area->next) { set_ui_object_prev (obj, NULL); area->parent = parent; set_ui_object_child (parent, obj); if (next) { set_ui_object_prev (next, obj); } } else if (next) { while (get_ui_object_next (next)) { next= get_ui_object_next (next); } set_ui_object_prev (obj, next); set_ui_object_next (next, obj); area->parent = parent; } else { area->parent = parent; set_area_ui_object_child (parent, obj); } }
ui_object *add_to_pop_up_list (char *text, ui_object *obj, ui_object *next_item, int list_id, int font_type, rgb_colour font_colour) { notify_types notify_on, highlighted_notify_on; ui_object *text_obj; int highlighted_font_type; float x_pos, list_x_size, list_y_size, new_position; rgb_colour highlighted_font_colour; // ASSERT (obj); // /* if (!obj) { return NULL; } */ // // // list_x_size = 1.0; //get_ui_object_x_size (obj) - 5; list_y_size = ui_get_font_height () / get_ui_object_y_size (obj); new_position = get_next_list_virtual_position (obj); // // If invalid font type specified, use the list box font type // if ((font_type < 0) || (font_type >= NUM_FONT_TYPES)) { font_type = get_ui_object_font_type (obj); } highlighted_font_type = get_ui_object_highlighted_font_type (obj); // // If invalid font colour specified, use the list box font colour // notify_on = get_ui_object_notify_on (obj); highlighted_notify_on = get_ui_object_highlighted_notify_on (obj); highlighted_font_colour = get_ui_object_highlighted_font_colour (obj); x_pos = 5.0 / get_ui_object_x_size (obj); text_obj = create_ui_object ( UI_TYPE_TEXT, UI_ATTR_NEXT (next_item), UI_ATTR_PARENT (obj), UI_ATTR_LIST_ITEM, UI_ATTR_VIRTUAL_SIZE (list_x_size, list_y_size), UI_ATTR_VIRTUAL_POSITION (x_pos, new_position), UI_ATTR_FONT_TYPE (font_type), UI_ATTR_FONT_COLOUR (font_colour.r, font_colour.g, font_colour.b, font_colour.a), UI_ATTR_HIGHLIGHTED_FONT_TYPE (highlighted_font_type), UI_ATTR_HIGHLIGHTED_FONT_COLOUR (highlighted_font_colour.r, highlighted_font_colour.g, highlighted_font_colour.b, highlighted_font_colour.a), UI_ATTR_TEXT (text), UI_ATTR_ITEM_NUMBER (list_id), UI_ATTR_ITEM_NUMBER2 (UI_LIST_NO_SELECTION), UI_ATTR_FUNCTION (ui_object_list_item_function), UI_ATTR_RIGHT_FUNCTION (ui_object_list_item_right_function), UI_ATTR_NOTIFY_ON (notify_on), UI_ATTR_HIGHLIGHTED_NOTIFY_ON (highlighted_notify_on), UI_ATTR_END ); // // Set list box to redraw, and parents if its clear. // set_ui_object_redraw (obj, TRUE); while ((obj) && (get_ui_object_clear (obj))) { obj = get_ui_object_parent (obj); if (obj) { set_ui_object_redraw (obj, TRUE); } } return text_obj; }
static void update_mslider_ui_object (ui_object *obj) { float parent_x1, parent_y1, parent_x2, parent_y2, parent_x_origin, parent_y_origin; float min, max, x1, y1, x2, y2; ui_object *object_to_slide, *parent; area_ui_object *area; float old_viewport_x1, old_viewport_y1, old_viewport_x2, old_viewport_y2; // store parents viewport data old_viewport_x1 = active_viewport.x_min; old_viewport_y1 = active_viewport.y_min; old_viewport_x2 = active_viewport.x_max; old_viewport_y2 = active_viewport.y_max; area = obj->data; // Scroll if required if (scroll) { min = get_ui_object_slider_min (obj); max = get_ui_object_slider_max (obj); object_to_slide = get_ui_object_next (obj); scroll_slider (object_to_slide, min, max, scroll); } // store parents viewport data parent = get_ui_object_parent (obj); parent_x_origin = get_ui_object_x_origin (parent); parent_y_origin = get_ui_object_y_origin (parent); parent_x1 = get_ui_object_x (parent); parent_y1 = get_ui_object_y (parent); parent_x2 = parent_x1 + get_ui_object_x_size (parent); parent_y2 = parent_y1 + get_ui_object_y_size (parent); if (area->drawable) { ui_set_origin (0, 0); draw_ui_object (obj); if (area->child) { x1 = get_ui_object_x (obj); y1 = get_ui_object_y (obj); x2 = x1 + get_ui_object_x_size (obj); y2 = y1 + get_ui_object_y_size (obj); ui_clip_area (&x1, &y1, &x2, &y2); set_viewport (x1, y1, x2, y2); ui_set_origin (0, 0); update_ui_object (area->child); } } if (area->next) { parent = get_ui_object_parent (obj); if (parent) { set_viewport (parent_x1, parent_y1, parent_x2, parent_y2); ui_set_origin (parent_x_origin, parent_y_origin); } update_ui_object (area->next); } set_viewport (old_viewport_x1, old_viewport_y1, old_viewport_x2, old_viewport_y2); }
static void update_menu_ui_object (ui_object *obj) { float x1, y1, x2, y2, parent_x1, parent_y1, parent_x2, parent_y2, grand_parent_x_origin = 0.0, grand_parent_y_origin = 0.0; ui_object *stack_head, *grand_parent, *parent; area_ui_object *area; area = obj->data; // store parents viewport data parent = get_ui_object_parent (obj); grand_parent = get_ui_object_parent (parent); if (parent) { if (grand_parent) { grand_parent_x_origin = get_ui_object_x_origin (grand_parent); grand_parent_y_origin = get_ui_object_y_origin (grand_parent); } ui_set_origin (grand_parent_x_origin, grand_parent_y_origin); parent_x1 = get_ui_object_x (parent); parent_y1 = get_ui_object_y (parent); parent_x2 = parent_x1 + get_ui_object_x_size (parent); parent_y2 = parent_y1 + get_ui_object_y_size (parent); x1 = parent_x1; y1 = parent_y1; x2 = parent_x2; y2 = parent_y2; ui_clip_area (&x1, &y1, &x2, &y2); x1 += grand_parent_x_origin; y1 += grand_parent_y_origin; x2 += grand_parent_x_origin; y2 += grand_parent_y_origin; set_viewport (x1, y1, x2, y2); } if (area->drawable) { draw_ui_object (obj); } // and its list head stack_head = obj->stack_head; if (stack_head) { parent = get_ui_object_parent (stack_head); grand_parent = get_ui_object_parent (parent); if (parent) { if (grand_parent) { grand_parent_x_origin = get_ui_object_x_origin (grand_parent); grand_parent_y_origin = get_ui_object_y_origin (grand_parent); } ui_set_origin (grand_parent_x_origin, grand_parent_y_origin); parent_x1 = get_ui_object_x (parent); parent_y1 = get_ui_object_y (parent); parent_x2 = parent_x1 + get_ui_object_x_size (parent); parent_y2 = parent_y1 + get_ui_object_y_size (parent); x1 = parent_x1; y1 = parent_y1; x2 = parent_x2; y2 = parent_y2; ui_clip_area (&x1, &y1, &x2, &y2); x1 += grand_parent_x_origin; y1 += grand_parent_y_origin; x2 += grand_parent_x_origin; y2 += grand_parent_y_origin; set_viewport (x1, y1, x2, y2); } if (area->drawable) { draw_ui_object (stack_head); } } // list head end if (area->next) { parent = get_ui_object_parent (obj); grand_parent = get_ui_object_parent (parent); if (parent) { if (grand_parent) { grand_parent_x_origin = get_ui_object_x_origin (grand_parent); grand_parent_y_origin = get_ui_object_y_origin (grand_parent); } ui_set_origin (grand_parent_x_origin, grand_parent_y_origin); parent_x1 = get_ui_object_x (parent); parent_y1 = get_ui_object_y (parent); parent_x2 = parent_x1 + get_ui_object_x_size (parent); parent_y2 = parent_y1 + get_ui_object_y_size (parent); x1 = parent_x1; y1 = parent_y1; x2 = parent_x2; y2 = parent_y2; x1 += grand_parent_x_origin; y1 += grand_parent_y_origin; x2 += grand_parent_x_origin; y2 += grand_parent_y_origin; set_viewport (x1, y1, x2, y2); parent_x1 += get_ui_object_x_origin (parent); parent_y1 += get_ui_object_y_origin (parent); ui_set_origin (parent_x1, parent_y1); } update_ui_object (area->next); } }
static void update_vslider_ui_object (ui_object *obj) { float parent_x1, parent_y1, parent_x2, parent_y2, parent_x_origin, parent_y_origin; float x1, y1, x2, y2; ui_object *parent; area_ui_object *area; float old_viewport_x1, old_viewport_y1, old_viewport_x2, old_viewport_y2; // store parents viewport data old_viewport_x1 = active_viewport.x_min; old_viewport_y1 = active_viewport.y_min; old_viewport_x2 = active_viewport.x_max; old_viewport_y2 = active_viewport.y_max; area = (area_ui_object *) obj->data; // store parents viewport data parent = get_ui_object_parent (obj); parent_x_origin = get_ui_object_x_origin (parent); parent_y_origin = get_ui_object_y_origin (parent); parent_x1 = get_ui_object_x (parent); parent_y1 = get_ui_object_y (parent); parent_x2 = parent_x1 + get_ui_object_x_size (parent); parent_y2 = parent_y1 + get_ui_object_y_size (parent); recalculate_slider_size (obj); if (area->drawable) { ui_set_origin (0, 0); draw_ui_object (obj); if (area->child) { x1 = get_ui_object_x (obj); y1 = get_ui_object_y (obj); x2 = x1 + get_ui_object_x_size (obj); y2 = y1 + get_ui_object_y_size (obj); ui_clip_area (&x1, &y1, &x2, &y2); set_viewport (x1, y1, x2, y2); ui_set_origin (0, 0); update_ui_object (area->child); } } set_viewport (old_viewport_x1, old_viewport_y1, old_viewport_x2, old_viewport_y2); if (area->next) { parent = get_ui_object_parent (obj); if (parent) { set_viewport (parent_x1, parent_y1, parent_x2, parent_y2); ui_set_origin (parent_x_origin, parent_y_origin); } update_ui_object (area->next); } }
void set_radio_buttons_off (ui_object *obj) { area_ui_object *area; ui_object *next, *parent; area = obj->data; parent = get_ui_object_parent (obj); if (parent) { next = get_ui_object_child (parent); } else { next = get_ui_object_next (obj); } while (next) { if (next->type == UI_TYPE_RADIO) { area = next->data; area->state = UI_OBJECT_STATE_OFF; } next = get_ui_object_next (next); } if (parent) { set_ui_object_redraw (parent, TRUE); while ((parent) && (get_ui_object_clear (parent))) { parent = get_ui_object_parent (parent); if (parent) { set_ui_object_redraw (parent, TRUE); } } } else { set_ui_object_redraw (obj, TRUE); } }
void ui_object_list_item_function (ui_object *obj, void *arg) { int list_position; ui_object *parent, *next_parent, *current_list_item; void ((*pfunction) (ui_object *obj, void *arg)); parent = get_ui_object_parent (obj); next_parent = parent; // set the next non-clear parent to redraw while ((next_parent) && (get_ui_object_clear (next_parent))) { next_parent = get_ui_object_parent (next_parent); if (next_parent) { set_ui_object_redraw (next_parent, TRUE); } } current_list_item = get_ui_object_child (parent); // find out what its list position is list_position = 0; while (current_list_item) { list_position ++; if (obj == current_list_item) { break; } current_list_item = get_ui_object_next (current_list_item); } #if LIST_DEBUG debug_log ("UI LIST: item %d", list_position); #endif // notify parents function pfunction = get_ui_object_function (parent); if (pfunction) { pfunction (obj, (void *) list_position); } }