+int resize_by_layout(void *obj, int maximum_size)
+{
+ Area *child, *a = (Area*)obj;
+ int size, nb_by_content=0, nb_by_layout=0;
+
+ if (panel_horizontal) {
+ // detect free size for SIZE_BY_LAYOUT's Area
+ size = a->width - (2 * (a->paddingxlr + a->bg->border.width));
+ GSList *l;
+ for (l = a->list ; l ; l = l->next) {
+ child = (Area*)l->data;
+ if (child->on_screen && child->size_mode == SIZE_BY_CONTENT) {
+ size -= child->width;
+ nb_by_content++;
+ }
+ if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT)
+ nb_by_layout++;
+ }
+ if (nb_by_content+nb_by_layout)
+ size -= ((nb_by_content+nb_by_layout-1) * a->paddingx);
+ //printf("resize_panel : size_panel %d, size_layout %d\n", panel->area.width, size);
+
+ int width=0, modulo=0, old_width;
+ if (nb_by_layout) {
+ width = size / nb_by_layout;
+ modulo = size % nb_by_layout;
+ if (width > maximum_size && maximum_size != 0) {
+ width = maximum_size;
+ modulo = 0;
+ }
+ }
+
+ // resize SIZE_BY_LAYOUT objects
+ for (l = a->list ; l ; l = l->next) {
+ child = (Area*)l->data;
+ if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT) {
+ old_width = child->width;
+ child->width = width;
+ if (modulo) {
+ child->width++;
+ modulo--;
+ }
+ if (child->width != old_width)
+ child->on_changed = 1;
+ }
+ }
+ }
+ else {
+ // detect free size for SIZE_BY_LAYOUT's Area
+ size = a->height - (2 * (a->paddingxlr + a->bg->border.width));
+ GSList *l;
+ for (l = a->list ; l ; l = l->next) {
+ child = (Area*)l->data;
+ if (child->on_screen && child->size_mode == SIZE_BY_CONTENT) {
+ size -= child->height;
+ nb_by_content++;
+ }
+ if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT)
+ nb_by_layout++;
+ }
+ if (nb_by_content+nb_by_layout)
+ size -= ((nb_by_content+nb_by_layout-1) * a->paddingx);
+
+ int height=0, modulo=0, old_height;
+ if (nb_by_layout) {
+ height = size / nb_by_layout;
+ modulo = size % nb_by_layout;
+ if (height > maximum_size && maximum_size != 0) {
+ height = maximum_size;
+ modulo = 0;
+ }
+ }
+
+ // resize SIZE_BY_LAYOUT objects
+ for (l = a->list ; l ; l = l->next) {
+ child = (Area*)l->data;
+ if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT) {
+ old_height = child->height;
+ child->height = height;
+ if (modulo) {
+ child->height++;
+ modulo--;
+ }
+ if (child->height != old_height)
+ child->on_changed = 1;
+ }
+ }
+ }
+ return 0;
+}
+
+