container deals with growable children
This commit is contained in:
@@ -84,6 +84,8 @@ printf("ALLOCATE container vertical %p\n", _this);
|
|||||||
struct gui *g = _gui;
|
struct gui *g = _gui;
|
||||||
struct container_widget *this = _this;
|
struct container_widget *this = _this;
|
||||||
struct widget_list *l;
|
struct widget_list *l;
|
||||||
|
int over_pixels = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (this->hints_are_valid == 1) goto hints_ok;
|
if (this->hints_are_valid == 1) goto hints_ok;
|
||||||
|
|
||||||
@@ -96,18 +98,29 @@ hints_ok:
|
|||||||
this->common.width = width;
|
this->common.width = width;
|
||||||
this->common.height = height;
|
this->common.height = height;
|
||||||
|
|
||||||
/* allocate */
|
/* TODO: some pixels won't be allocated, take care of it? */
|
||||||
l = this->common.children;
|
if (height > this->hint_height) {
|
||||||
while (l) {
|
int ngrowable = 0;
|
||||||
l->item->hints(g, l->item, &cwidth, &cheight);
|
for (i = 0; i < this->nchildren; i++) if (this->growable[i]) ngrowable++;
|
||||||
l->item->allocate(g, l->item, this->common.x, this->common.y + cy,
|
if (ngrowable)
|
||||||
//this->hint_width, cheight);
|
over_pixels = (height - this->hint_height) / ngrowable;
|
||||||
MAX(width, cwidth), cheight);
|
|
||||||
cy += cheight;
|
|
||||||
l = l->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cy != this->hint_height) ERR("reachable?\n");
|
/* allocate */
|
||||||
|
l = this->common.children;
|
||||||
|
i = 0;
|
||||||
|
while (l) {
|
||||||
|
int allocated_height;
|
||||||
|
l->item->hints(g, l->item, &cwidth, &cheight);
|
||||||
|
allocated_height = cheight + (this->growable[i] ? over_pixels : 0);
|
||||||
|
l->item->allocate(g, l->item, this->common.x, this->common.y + cy,
|
||||||
|
MAX(width, cwidth), allocated_height);
|
||||||
|
cy += allocated_height;
|
||||||
|
l = l->next;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (cy != this->hint_height) ERR("reachable?\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void horizontal_allocate(gui *_gui, widget *_this,
|
static void horizontal_allocate(gui *_gui, widget *_this,
|
||||||
@@ -119,6 +132,8 @@ printf("ALLOCATE container horizontal %p\n", _this);
|
|||||||
struct gui *g = _gui;
|
struct gui *g = _gui;
|
||||||
struct container_widget *this = _this;
|
struct container_widget *this = _this;
|
||||||
struct widget_list *l;
|
struct widget_list *l;
|
||||||
|
int over_pixels = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (this->hints_are_valid == 1) goto hints_ok;
|
if (this->hints_are_valid == 1) goto hints_ok;
|
||||||
|
|
||||||
@@ -131,17 +146,29 @@ hints_ok:
|
|||||||
this->common.width = width;
|
this->common.width = width;
|
||||||
this->common.height = height;
|
this->common.height = height;
|
||||||
|
|
||||||
/* allocate */
|
/* TODO: some pixels won't be allocated, take care of it? */
|
||||||
l = this->common.children;
|
if (width > this->hint_width) {
|
||||||
while (l) {
|
int ngrowable = 0;
|
||||||
l->item->hints(g, l->item, &cwidth, &cheight);
|
for (i = 0; i < this->nchildren; i++) if (this->growable[i]) ngrowable++;
|
||||||
l->item->allocate(g, l->item, this->common.x + cx, this->common.y,
|
if (ngrowable)
|
||||||
cwidth, MAX(height, cheight)/* this->hint_height */);
|
over_pixels = (width - this->hint_width) / ngrowable;
|
||||||
cx += cwidth;
|
|
||||||
l = l->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cx != this->hint_width) ERR("reachable?\n");
|
/* allocate */
|
||||||
|
l = this->common.children;
|
||||||
|
i = 0;
|
||||||
|
while (l) {
|
||||||
|
int allocated_width;
|
||||||
|
l->item->hints(g, l->item, &cwidth, &cheight);
|
||||||
|
allocated_width = cwidth + (this->growable[i] ? over_pixels : 0);
|
||||||
|
l->item->allocate(g, l->item, this->common.x + cx, this->common.y,
|
||||||
|
allocated_width, MAX(height, cheight)/* this->hint_height */);
|
||||||
|
cx += allocated_width;
|
||||||
|
l = l->next;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (cx != this->hint_width) ERR("reachable?\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vertical_hints(gui *_gui, widget *_w, int *width, int *height)
|
static void vertical_hints(gui *_gui, widget *_w, int *width, int *height)
|
||||||
|
|||||||
Reference in New Issue
Block a user