taskbar+area: Implement center alignment
This commit is contained in:
@@ -153,7 +153,7 @@ void init_taskbar_panel(void *p)
|
||||
panel->g_taskbar.area.parent = panel;
|
||||
panel->g_taskbar.area.panel = panel;
|
||||
panel->g_taskbar.area.size_mode = SIZE_BY_LAYOUT;
|
||||
panel->g_taskbar.area.alignment = ALIGN_RIGHT;
|
||||
panel->g_taskbar.area.alignment = ALIGN_CENTER;
|
||||
panel->g_taskbar.area._resize = resize_taskbar;
|
||||
panel->g_taskbar.area._draw_foreground = draw_taskbar;
|
||||
panel->g_taskbar.area._on_change_layout = on_change_taskbar;
|
||||
|
||||
@@ -220,6 +220,45 @@ void size_by_layout (Area *a, int level)
|
||||
|
||||
pos -= a->paddingx;
|
||||
}
|
||||
} else if (a->alignment == ALIGN_CENTER) {
|
||||
|
||||
int children_size = 0;
|
||||
|
||||
for (l = a->list; l ; l = l->next) {
|
||||
Area *child = ((Area*)l->data);
|
||||
if (!child->on_screen)
|
||||
continue;
|
||||
|
||||
children_size += panel_horizontal ? child->width : child->height;
|
||||
children_size += (l == a->list) ? 0 : a->paddingx;
|
||||
}
|
||||
|
||||
int pos = (panel_horizontal ? a->posx : a->posy) + a->bg->border.width + a->paddingxlr;
|
||||
pos += ((panel_horizontal ? a->width : a->height) - children_size) / 2;
|
||||
|
||||
for (l = a->list; l ; l = l->next) {
|
||||
Area *child = ((Area*)l->data);
|
||||
if (!child->on_screen)
|
||||
continue;
|
||||
|
||||
if (panel_horizontal) {
|
||||
if (pos != child->posx) {
|
||||
// pos changed => redraw
|
||||
child->posx = pos;
|
||||
child->on_changed = 1;
|
||||
}
|
||||
} else {
|
||||
if (pos != child->posy) {
|
||||
// pos changed => redraw
|
||||
child->posy = pos;
|
||||
child->on_changed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
size_by_layout(child, level+1);
|
||||
|
||||
pos += panel_horizontal ? child->width + a->paddingx : child->height + a->paddingx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user