コード例 #1
0
ファイル: a3d_layer.c プロジェクト: danmokai/a3d-native
static void a3d_layer_layout(a3d_widget_t* widget,
                             int dragx, int dragy)
{
	assert(widget);
	LOGD("debug dragx=%i, dragy=%i", dragx, dragy);

	// the rect_clip is constant across all layers
	a3d_rect4f_t rect_clip;
	a3d_rect4f_intersect(&widget->rect_draw,
	                     &widget->rect_clip,
	                     &rect_clip);

	a3d_layer_t*    self = (a3d_layer_t*) widget;
	a3d_listitem_t* iter = a3d_list_head(self->list);
	while(iter)
	{
		a3d_widget_t* child = (a3d_widget_t*) a3d_list_peekitem(iter);

		// layout the layer
		float x = 0.0f;
		float y = 0.0f;
		a3d_widget_anchorPt(&widget->rect_draw,
		                    child->anchor,
		                    &x, &y);
		a3d_widget_layoutXYClip(child, x, y, &rect_clip,
		                        dragx, dragy);

		iter = a3d_list_next(iter);
	}
}
コード例 #2
0
ファイル: a3d_bulletbox.c プロジェクト: jeffboody/a3d-native
static void a3d_bulletbox_layout(a3d_widget_t* widget,
                                 int dragx, int dragy)
{
	assert(widget);

	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;

	// initialize the layout
	float x  = 0.0f;
	float y  = 0.0f;
	float t  = widget->rect_draw.t;
	float l  = widget->rect_draw.l;
	float h  = widget->rect_draw.h;
	float iw = icon->rect_border.w;
	float tw = text->rect_border.w;

	// layout icon
	a3d_rect4f_t rect_draw;
	rect_draw.t = t;
	rect_draw.l = l;
	rect_draw.w = iw;
	rect_draw.h = h;
	a3d_rect4f_t rect_clip;
	a3d_widget_anchorPt(&rect_draw, icon->anchor, &x, &y);
	a3d_rect4f_intersect(&rect_draw,
	                     &widget->rect_clip,
	                     &rect_clip);
	a3d_widget_layoutXYClip(icon, x, y, &rect_clip,
	                        dragx, dragy);

	// layout text
	rect_draw.l = l + A3D_BULLETBOX_SPACE*iw;
	rect_draw.w = tw;
	a3d_widget_anchorPt(&rect_draw, text->anchor, &x, &y);
	a3d_rect4f_intersect(&rect_draw,
	                     &widget->rect_clip,
	                     &rect_clip);
	a3d_widget_layoutXYClip(text, x, y, &rect_clip,
	                        dragx, dragy);
}
コード例 #3
0
ファイル: a3d_listbox.c プロジェクト: danmokai/a3d-native
static void a3d_listbox_layoutHorizontalStretch(a3d_listbox_t* self,
                                                int dragx, int dragy)
{
	assert(self);
	LOGD("debug dragx=%i, dragy=%i", dragx, dragy);

	// initialize the layout
	float x   = 0.0f;
	float y   = 0.0f;
	float t   = self->widget.rect_draw.t;
	float l   = self->widget.rect_draw.l;
	float w   = self->widget.rect_draw.w;
	float h   = self->widget.rect_draw.h;
	float cnt = (float) a3d_list_size(self->list);
	float dw  = w/cnt;
	a3d_rect4f_t rect_clip;
	a3d_rect4f_t rect_draw;

	a3d_listitem_t* iter = a3d_list_head(self->list);
	while(iter)
	{
		a3d_widget_t* child = (a3d_widget_t*) a3d_list_peekitem(iter);

		rect_draw.t = t;
		rect_draw.l = l;
		rect_draw.w = dw;
		rect_draw.h = h;
		l += dw;

		a3d_widget_anchorPt(&rect_draw, child->anchor, &x, &y);
		a3d_rect4f_intersect(&rect_draw,
		                     &self->widget.rect_clip,
		                     &rect_clip);
		a3d_widget_layoutXYClip(child, x, y, &rect_clip,
		                        dragx, dragy);

		iter = a3d_list_next(iter);
	}
}
コード例 #4
0
ファイル: a3d_listbox.c プロジェクト: danmokai/a3d-native
static void a3d_listbox_layoutVerticalShrink(a3d_listbox_t* self,
                                             int dragx, int dragy)
{
	assert(self);
	LOGD("debug dragx=%i, dragy=%i", dragx, dragy);

	// initialize the layout
	float x = 0.0f;
	float y = 0.0f;
	float t = self->widget.rect_draw.t;
	float l = self->widget.rect_draw.l;
	float w = self->widget.rect_draw.w;
	a3d_rect4f_t rect_clip;
	a3d_rect4f_t rect_draw;

	a3d_listitem_t* iter = a3d_list_head(self->list);
	while(iter)
	{
		a3d_widget_t* child = (a3d_widget_t*) a3d_list_peekitem(iter);
		float h = child->rect_border.h;

		rect_draw.t = t;
		rect_draw.l = l;
		rect_draw.w = w;
		rect_draw.h = h;
		t += h;

		a3d_widget_anchorPt(&rect_draw, child->anchor, &x, &y);
		a3d_rect4f_intersect(&rect_draw,
		                     &self->widget.rect_clip,
		                     &rect_clip);
		a3d_widget_layoutXYClip(child, x, y, &rect_clip,
		                        dragx, dragy);

		iter = a3d_list_next(iter);
	}
}