static void a3d_bulletbox_size(a3d_widget_t* widget, float* w, float* h) { assert(widget); assert(w); assert(h); a3d_bulletbox_t* self = (a3d_bulletbox_t*) widget; a3d_widget_t* icon = (a3d_widget_t*) self->icon; a3d_widget_t* text = (a3d_widget_t*) self->text; float icon_w = *w; float icon_h = *h; a3d_widget_layoutSize(icon, &icon_w, &icon_h); float text_w = *w; float text_h = *h; a3d_widget_layoutSize(text, &text_w, &text_h); *w = A3D_BULLETBOX_SPACE*icon_w + text_w; *h = (icon_h > text_h) ? icon_h : text_h; }
static void a3d_layer_size(a3d_widget_t* widget, float* w, float* h) { assert(widget); assert(w); assert(h); LOGD("debug"); a3d_layer_t* self = (a3d_layer_t*) widget; a3d_listitem_t* iter = a3d_list_head(self->list); float wmax = 0.0f; float hmax = 0.0f; float tmp_w = 0.0f; float tmp_h = 0.0f; while(iter) { tmp_w = *w; tmp_h = *h; widget = (a3d_widget_t*) a3d_list_peekitem(iter); a3d_widget_layoutSize(widget, &tmp_w, &tmp_h); if(tmp_w > wmax) { wmax = tmp_w; } if(tmp_h > hmax) { hmax = tmp_h; } iter = a3d_list_next(iter); } *w = wmax; *h = hmax; }
static void a3d_listbox_size(a3d_widget_t* widget, float* w, float* h) { assert(widget); assert(w); assert(h); LOGD("debug"); a3d_listbox_t* self = (a3d_listbox_t*) widget; a3d_listitem_t* iter = a3d_list_head(self->list); float cnt = (float) a3d_list_size(self->list); float dw = *w/cnt; float dh = *h/cnt; if(self->orientation == A3D_LISTBOX_ORIENTATION_VERTICAL) { dw = *w; } else { dh = *h; } float wmax = 0.0f; float hmax = 0.0f; float wsum = 0.0f; float hsum = 0.0f; float tmp_w = 0.0f; float tmp_h = 0.0f; while(iter) { tmp_w = dw; tmp_h = dh; widget = (a3d_widget_t*) a3d_list_peekitem(iter); a3d_widget_layoutSize(widget, &tmp_w, &tmp_h); if(tmp_w > wmax) { wmax = tmp_w; } wsum += tmp_w; if(tmp_h > hmax) { hmax = tmp_h; } hsum += tmp_h; iter = a3d_list_next(iter); } if(self->orientation == A3D_LISTBOX_ORIENTATION_HORIZONTAL) { *w = wsum; *h = hmax; } else { *w = wmax; *h = hsum; } }