Compute layouts correctly with partial borders (issue #580)
This commit is contained in:
parent
77d2a74865
commit
ed802d7602
13 changed files with 450 additions and 365 deletions
|
@ -326,7 +326,7 @@ gboolean resize_battery(void *obj)
|
|||
|
||||
if (panel_horizontal) {
|
||||
int new_size = (bat_percentage_width > bat_time_width) ? bat_percentage_width : bat_time_width;
|
||||
new_size += 2 * battery->area.paddingxlr + 2 * battery->area.bg->border.width;
|
||||
new_size += 2 * battery->area.paddingxlr + left_right_border_width(&battery->area);
|
||||
if (new_size > battery->area.width || new_size < battery->area.width - 2) {
|
||||
// we try to limit the number of resize
|
||||
battery->area.width = new_size;
|
||||
|
@ -335,8 +335,8 @@ gboolean resize_battery(void *obj)
|
|||
ret = 1;
|
||||
}
|
||||
} else {
|
||||
int new_size =
|
||||
bat_percentage_height + bat_time_height + (2 * (battery->area.paddingxlr + battery->area.bg->border.width));
|
||||
int new_size = bat_percentage_height + bat_time_height + 2 * battery->area.paddingxlr +
|
||||
top_bottom_border_width(&battery->area);
|
||||
if (new_size > battery->area.height || new_size < battery->area.height - 2) {
|
||||
battery->area.height = new_size;
|
||||
battery->bat1_posy = (battery->area.height - bat_percentage_height - bat_time_height - 2) / 2;
|
||||
|
|
|
@ -276,7 +276,7 @@ gboolean resize_clock(void *obj)
|
|||
|
||||
if (panel_horizontal) {
|
||||
int new_size = (time_width > date_width) ? time_width : date_width;
|
||||
new_size += (2 * clock->area.paddingxlr) + (2 * clock->area.bg->border.width);
|
||||
new_size += 2 * clock->area.paddingxlr + left_right_border_width(&clock->area);
|
||||
if (new_size > clock->area.width || new_size < (clock->area.width - 6)) {
|
||||
// we try to limit the number of resizes
|
||||
clock->area.width = new_size + 1;
|
||||
|
@ -288,7 +288,7 @@ gboolean resize_clock(void *obj)
|
|||
result = TRUE;
|
||||
}
|
||||
} else {
|
||||
int new_size = time_height + date_height + (2 * (clock->area.paddingxlr + clock->area.bg->border.width));
|
||||
int new_size = time_height + date_height + 2 * clock->area.paddingxlr + top_bottom_border_width(&clock->area);
|
||||
if (new_size != clock->area.height) {
|
||||
// we try to limit the number of resizes
|
||||
clock->area.height = new_size;
|
||||
|
|
|
@ -322,8 +322,8 @@ gboolean resize_execp(void *obj)
|
|||
panel->area.height,
|
||||
!text_next_line
|
||||
? execp->area.width - icon_w - (icon_w ? interior_padding : 0) -
|
||||
2 * (horiz_padding + execp->area.bg->border.width)
|
||||
: execp->area.width - 2 * (horiz_padding + execp->area.bg->border.width),
|
||||
2 * horiz_padding - left_right_border_width(&execp->area)
|
||||
: execp->area.width - 2 * horiz_padding - left_right_border_width(&execp->area),
|
||||
execp->backend->text,
|
||||
strlen(execp->backend->text),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
|
@ -336,7 +336,7 @@ gboolean resize_execp(void *obj)
|
|||
int new_size = txt_width;
|
||||
if (icon_w)
|
||||
new_size += interior_padding + icon_w;
|
||||
new_size += 2 * (horiz_padding + execp->area.bg->border.width);
|
||||
new_size += 2 * horiz_padding + left_right_border_width(&execp->area);
|
||||
if (new_size > execp->area.width || new_size < (execp->area.width - 6)) {
|
||||
// we try to limit the number of resize
|
||||
execp->area.width = new_size + 1;
|
||||
|
@ -345,12 +345,10 @@ gboolean resize_execp(void *obj)
|
|||
} else {
|
||||
int new_size;
|
||||
if (!text_next_line) {
|
||||
new_size = txt_height + (2 * (vert_padding + execp->area.bg->border.width));
|
||||
if (new_size < icon_h + (2 * (vert_padding + execp->area.bg->border.width))) {
|
||||
new_size = icon_h + (2 * (vert_padding + execp->area.bg->border.width));
|
||||
}
|
||||
new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
|
||||
new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&execp->area));
|
||||
} else {
|
||||
new_size = icon_h + interior_padding + txt_height + (2 * (vert_padding + execp->area.bg->border.width));
|
||||
new_size = icon_h + interior_padding + txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
|
||||
}
|
||||
if (new_size != execp->area.height) {
|
||||
execp->area.height = new_size;
|
||||
|
@ -380,18 +378,18 @@ gboolean resize_execp(void *obj)
|
|||
if (icon_w) {
|
||||
if (!text_next_line) {
|
||||
execp->frontend->icony = (execp->area.height - icon_h) / 2;
|
||||
execp->frontend->iconx = execp->area.bg->border.width + horiz_padding;
|
||||
execp->frontend->iconx = left_border_width(&execp->area) + horiz_padding;
|
||||
execp->frontend->texty = (execp->area.height - txt_height) / 2;
|
||||
execp->frontend->textx = execp->frontend->iconx + icon_w + interior_padding;
|
||||
} else {
|
||||
execp->frontend->icony = (execp->area.height - icon_h - interior_padding - txt_height) / 2;
|
||||
execp->frontend->iconx = execp->area.bg->border.width + horiz_padding;
|
||||
execp->frontend->iconx = left_border_width(&execp->area) + horiz_padding;
|
||||
execp->frontend->texty = execp->frontend->icony + icon_h + interior_padding;
|
||||
execp->frontend->textx = execp->frontend->iconx;
|
||||
}
|
||||
} else {
|
||||
execp->frontend->texty = (execp->area.height - txt_height) / 2;
|
||||
execp->frontend->textx = execp->area.bg->border.width + horiz_padding;
|
||||
execp->frontend->textx = left_border_width(&execp->area) + horiz_padding;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,15 +57,15 @@ int freespace_get_max_size(Panel *p)
|
|||
continue;
|
||||
|
||||
if (panel_horizontal)
|
||||
size += a->width + (a->bg->border.width * 2) + p->area.paddingx;
|
||||
size += a->width + p->area.paddingx;
|
||||
else
|
||||
size += a->height + (a->bg->border.width * 2) + p->area.paddingy;
|
||||
size += a->height + p->area.paddingy;
|
||||
}
|
||||
|
||||
if (panel_horizontal)
|
||||
size = p->area.width - size - (p->area.bg->border.width * 2) - p->area.paddingxlr;
|
||||
size = p->area.width - size - left_right_border_width(&p->area) - p->area.paddingxlr;
|
||||
else
|
||||
size = p->area.height - size - (p->area.bg->border.width * 2) - p->area.paddingxlr;
|
||||
size = p->area.height - size - top_bottom_border_width(&p->area) - p->area.paddingxlr;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
|
|
@ -163,7 +163,8 @@ gboolean resize_launcher(void *obj)
|
|||
} else {
|
||||
icon_size = launcher->area.width;
|
||||
}
|
||||
icon_size = icon_size - (2 * launcher->area.bg->border.width) - (2 * launcher->area.paddingy);
|
||||
icon_size = icon_size - MAX(left_right_border_width(&launcher->area), top_bottom_border_width(&launcher->area)) -
|
||||
(2 * launcher->area.paddingy);
|
||||
if (launcher_max_icon_size > 0 && icon_size > launcher_max_icon_size)
|
||||
icon_size = launcher_max_icon_size;
|
||||
|
||||
|
@ -234,36 +235,36 @@ gboolean resize_launcher(void *obj)
|
|||
if (!count) {
|
||||
launcher->area.width = 0;
|
||||
} else {
|
||||
int height = launcher->area.height - 2 * launcher->area.bg->border.width - 2 * launcher->area.paddingy;
|
||||
int height = launcher->area.height - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy;
|
||||
// here icons_per_column always higher than 0
|
||||
icons_per_column = (height + launcher->area.paddingx) / (icon_size + launcher->area.paddingx);
|
||||
margin = height - (icons_per_column - 1) * (icon_size + launcher->area.paddingx) - icon_size;
|
||||
icons_per_row = count / icons_per_column + (count % icons_per_column != 0);
|
||||
launcher->area.width = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) +
|
||||
launcher->area.width = left_right_border_width(&launcher->area) + 2 * launcher->area.paddingxlr +
|
||||
(icon_size * icons_per_row) + ((icons_per_row - 1) * launcher->area.paddingx);
|
||||
}
|
||||
} else {
|
||||
if (!count) {
|
||||
launcher->area.height = 0;
|
||||
} else {
|
||||
int width = launcher->area.width - 2 * launcher->area.bg->border.width - 2 * launcher->area.paddingy;
|
||||
int width = launcher->area.width - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy;
|
||||
// here icons_per_row always higher than 0
|
||||
icons_per_row = (width + launcher->area.paddingx) / (icon_size + launcher->area.paddingx);
|
||||
margin = width - (icons_per_row - 1) * (icon_size + launcher->area.paddingx) - icon_size;
|
||||
icons_per_column = count / icons_per_row + (count % icons_per_row != 0);
|
||||
launcher->area.height = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) +
|
||||
launcher->area.height = top_bottom_border_width(&launcher->area) + 2 * launcher->area.paddingxlr +
|
||||
(icon_size * icons_per_column) + ((icons_per_column - 1) * launcher->area.paddingx);
|
||||
}
|
||||
}
|
||||
|
||||
int posx, posy;
|
||||
int start = launcher->area.bg->border.width + launcher->area.paddingy + margin / 2;
|
||||
int start;
|
||||
if (panel_horizontal) {
|
||||
posy = start;
|
||||
posx = launcher->area.bg->border.width + launcher->area.paddingxlr;
|
||||
posy = start = top_border_width(&launcher->area) + launcher->area.paddingy + margin / 2;
|
||||
posx = left_border_width(&launcher->area) + launcher->area.paddingxlr;
|
||||
} else {
|
||||
posx = start;
|
||||
posy = launcher->area.bg->border.width + launcher->area.paddingxlr;
|
||||
posx = start = left_border_width(&launcher->area) + launcher->area.paddingy + margin / 2;
|
||||
posy = top_border_width(&launcher->area) + launcher->area.paddingxlr;
|
||||
}
|
||||
|
||||
int i;
|
||||
|
@ -453,7 +454,10 @@ void launcher_load_icons(Launcher *launcher)
|
|||
if (entry.exec) {
|
||||
LauncherIcon *launcherIcon = calloc(1, sizeof(LauncherIcon));
|
||||
launcherIcon->area.panel = launcher->area.panel;
|
||||
snprintf(launcherIcon->area.name, sizeof(launcherIcon->area.name), "LauncherIcon %s", entry.name ? entry.name : "null");
|
||||
snprintf(launcherIcon->area.name,
|
||||
sizeof(launcherIcon->area.name),
|
||||
"LauncherIcon %s",
|
||||
entry.name ? entry.name : "null");
|
||||
launcherIcon->area._draw_foreground = draw_launcher_icon;
|
||||
launcherIcon->area.size_mode = LAYOUT_FIXED;
|
||||
launcherIcon->area._resize = NULL;
|
||||
|
|
|
@ -435,7 +435,9 @@ gboolean resize_panel(void *obj)
|
|||
for (int i = 0; i < panel->num_desktops; i++) {
|
||||
Taskbar *taskbar = &panel->taskbar[i];
|
||||
|
||||
int requested_size = (2 * taskbar->area.bg->border.width) + (2 * taskbar->area.paddingxlr);
|
||||
int requested_size = (panel_horizontal ? left_right_border_width(&taskbar->area)
|
||||
: top_bottom_border_width(&taskbar->area)) +
|
||||
2 * taskbar->area.paddingxlr;
|
||||
int items = 0;
|
||||
GList *l = taskbar->area.children;
|
||||
if (taskbarname_enabled)
|
||||
|
|
|
@ -131,7 +131,8 @@ gboolean resize_systray(void *obj)
|
|||
systray.icon_size = systray.area.height;
|
||||
else
|
||||
systray.icon_size = systray.area.width;
|
||||
systray.icon_size -= (2 * systray.area.bg->border.width) + (2 * systray.area.paddingy);
|
||||
systray.icon_size -= MAX(left_right_border_width(&systray.area), top_bottom_border_width(&systray.area)) +
|
||||
2 * systray.area.paddingy;
|
||||
if (systray_max_icon_size > 0)
|
||||
systray.icon_size = MIN(systray.icon_size, systray_max_icon_size);
|
||||
|
||||
|
@ -155,23 +156,23 @@ gboolean resize_systray(void *obj)
|
|||
fprintf(stderr, BLUE "%s:%d number of icons = %d" RESET "\n", __FUNCTION__, __LINE__, count);
|
||||
|
||||
if (panel_horizontal) {
|
||||
int height = systray.area.height - 2 * systray.area.bg->border.width - 2 * systray.area.paddingy;
|
||||
int height = systray.area.height - top_bottom_border_width(&systray.area) - 2 * systray.area.paddingy;
|
||||
// here icons_per_column always higher than 0
|
||||
systray.icons_per_column = (height + systray.area.paddingx) / (systray.icon_size + systray.area.paddingx);
|
||||
systray.margin =
|
||||
height - (systray.icons_per_column - 1) * (systray.icon_size + systray.area.paddingx) - systray.icon_size;
|
||||
systray.icons_per_row = count / systray.icons_per_column + (count % systray.icons_per_column != 0);
|
||||
systray.area.width = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) +
|
||||
systray.area.width = left_right_border_width(&systray.area) + 2 * systray.area.paddingxlr +
|
||||
(systray.icon_size * systray.icons_per_row) +
|
||||
((systray.icons_per_row - 1) * systray.area.paddingx);
|
||||
} else {
|
||||
int width = systray.area.width - 2 * systray.area.bg->border.width - 2 * systray.area.paddingy;
|
||||
int width = systray.area.width - left_right_border_width(&systray.area) - 2 * systray.area.paddingy;
|
||||
// here icons_per_row always higher than 0
|
||||
systray.icons_per_row = (width + systray.area.paddingx) / (systray.icon_size + systray.area.paddingx);
|
||||
systray.margin =
|
||||
width - (systray.icons_per_row - 1) * (systray.icon_size + systray.area.paddingx) - systray.icon_size;
|
||||
systray.icons_per_column = count / systray.icons_per_row + (count % systray.icons_per_row != 0);
|
||||
systray.area.height = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) +
|
||||
systray.area.height = top_bottom_border_width(&systray.area) + (2 * systray.area.paddingxlr) +
|
||||
(systray.icon_size * systray.icons_per_column) +
|
||||
((systray.icons_per_column - 1) * systray.area.paddingx);
|
||||
}
|
||||
|
@ -218,14 +219,15 @@ void on_change_systray(void *obj)
|
|||
// Based on this we calculate the positions of the tray icons.
|
||||
Panel *panel = systray.area.panel;
|
||||
int posx, posy;
|
||||
int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width +
|
||||
systray.area.paddingy + systray.margin / 2;
|
||||
int start;
|
||||
if (panel_horizontal) {
|
||||
posy = start;
|
||||
posx = systray.area.posx + systray.area.bg->border.width + systray.area.paddingxlr;
|
||||
posy = start = top_border_width(&panel->area) + panel->area.paddingy + top_border_width(&systray.area) +
|
||||
systray.area.paddingy + systray.margin / 2;
|
||||
posx = systray.area.posx + left_border_width(&systray.area) + systray.area.paddingxlr;
|
||||
} else {
|
||||
posx = start;
|
||||
posy = systray.area.posy + systray.area.bg->border.width + systray.area.paddingxlr;
|
||||
posx = start = left_border_width(&panel->area) + panel->area.paddingy + left_border_width(&systray.area) +
|
||||
systray.area.paddingy + systray.margin / 2;
|
||||
posy = systray.area.posy + top_border_width(&systray.area) + systray.area.paddingxlr;
|
||||
}
|
||||
|
||||
TrayWindow *traywin;
|
||||
|
|
|
@ -369,7 +369,7 @@ void draw_task_icon(Task *task, int text_width)
|
|||
else
|
||||
pos_x = (task->area.width - panel->g_task.icon_size1) / 2;
|
||||
} else {
|
||||
pos_x = task->area.bg->border.width + task->area.paddingxlr;
|
||||
pos_x = left_border_width(&task->area) + task->area.paddingxlr;
|
||||
}
|
||||
|
||||
// Render
|
||||
|
@ -393,7 +393,7 @@ void draw_task_icon(Task *task, int text_width)
|
|||
fprintf(stderr, "Task icon size: %d %d pos %d %d\n", imlib_image_get_width(), imlib_image_get_height(), pos_x, panel->g_task.icon_posy);
|
||||
fprintf(stderr, "Task max size : %d %d\n", panel->g_task.maximum_width, panel->g_task.maximum_height);
|
||||
fprintf(stderr, "Task area size: %d %d\n", task->area.width, task->area.height);
|
||||
fprintf(stderr, "Task border : %d\n", task->area.bg->border.width);
|
||||
fprintf(stderr, "Task border : %d\n", left_border_width(&task->area));
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,13 +167,15 @@ void init_taskbar_panel(void *p)
|
|||
panel->g_taskbar.area.resize_needed = 1;
|
||||
panel->g_taskbar.area.on_screen = TRUE;
|
||||
if (panel_horizontal) {
|
||||
panel->g_taskbar.area.posy = panel->area.bg->border.width + panel->area.paddingy;
|
||||
panel->g_taskbar.area.height = panel->area.height - (2 * panel->g_taskbar.area.posy);
|
||||
panel->g_taskbar.area.posy = top_border_width(&panel->area) + panel->area.paddingy;
|
||||
panel->g_taskbar.area.height =
|
||||
panel->area.height - top_bottom_border_width(&panel->area) - 2 * panel->area.paddingy;
|
||||
panel->g_taskbar.area_name.posy = panel->g_taskbar.area.posy;
|
||||
panel->g_taskbar.area_name.height = panel->g_taskbar.area.height;
|
||||
} else {
|
||||
panel->g_taskbar.area.posx = panel->area.bg->border.width + panel->area.paddingy;
|
||||
panel->g_taskbar.area.width = panel->area.width - (2 * panel->g_taskbar.area.posx);
|
||||
panel->g_taskbar.area.posx = left_border_width(&panel->area) + panel->area.paddingy;
|
||||
panel->g_taskbar.area.width =
|
||||
panel->area.width - left_right_border_width(&panel->area) - 2 * panel->area.paddingy;
|
||||
panel->g_taskbar.area_name.posx = panel->g_taskbar.area.posx;
|
||||
panel->g_taskbar.area_name.width = panel->g_taskbar.area.width;
|
||||
}
|
||||
|
@ -230,15 +232,19 @@ void init_taskbar_panel(void *p)
|
|||
|
||||
if (panel_horizontal) {
|
||||
panel->g_task.area.posy = panel->g_taskbar.area.posy +
|
||||
panel->g_taskbar.background[TASKBAR_NORMAL]->border.width +
|
||||
top_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) +
|
||||
panel->g_taskbar.area.paddingy;
|
||||
panel->g_task.area.width = panel->g_task.maximum_width;
|
||||
panel->g_task.area.height = panel->area.height - (2 * panel->g_task.area.posy);
|
||||
panel->g_task.area.height = panel->g_taskbar.area.height -
|
||||
top_bottom_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) -
|
||||
2 * panel->g_taskbar.area.paddingy;
|
||||
} else {
|
||||
panel->g_task.area.posx = panel->g_taskbar.area.posx +
|
||||
panel->g_taskbar.background[TASKBAR_NORMAL]->border.width +
|
||||
left_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) +
|
||||
panel->g_taskbar.area.paddingy;
|
||||
panel->g_task.area.width = panel->area.width - (2 * panel->g_task.area.posx);
|
||||
panel->g_task.area.width = panel->g_taskbar.area.width -
|
||||
left_right_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) -
|
||||
2 * panel->g_taskbar.area.paddingy;
|
||||
panel->g_task.area.height = panel->g_task.maximum_height;
|
||||
}
|
||||
|
||||
|
@ -268,13 +274,13 @@ void init_taskbar_panel(void *p)
|
|||
PANGO_ELLIPSIZE_END,
|
||||
FALSE);
|
||||
|
||||
panel->g_task.text_posx = panel->g_task.background[0]->border.width + panel->g_task.area.paddingxlr;
|
||||
panel->g_task.text_posx = left_bg_border_width(panel->g_task.background[0]) + panel->g_task.area.paddingxlr;
|
||||
panel->g_task.text_height = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);
|
||||
if (panel->g_task.has_icon) {
|
||||
panel->g_task.icon_size1 =
|
||||
MIN(MIN(panel->g_task.maximum_width, panel->g_task.maximum_height),
|
||||
panel->g_task.icon_size1 = MIN(MIN(panel->g_task.maximum_width, panel->g_task.maximum_height),
|
||||
MIN(panel->g_task.area.width, panel->g_task.area.height)) -
|
||||
(2 * panel->g_task.area.paddingy) - 2 * panel->g_task.area.bg->border.width;
|
||||
2 * panel->g_task.area.paddingy - MAX(left_right_border_width(&panel->g_task.area),
|
||||
top_bottom_border_width(&panel->g_task.area));
|
||||
panel->g_task.text_posx += panel->g_task.icon_size1 + panel->g_task.area.paddingx;
|
||||
panel->g_task.icon_posy = (panel->g_task.area.height - panel->g_task.icon_size1) / 2;
|
||||
if (0)
|
||||
|
@ -413,13 +419,13 @@ gboolean resize_taskbar(void *obj)
|
|||
break;
|
||||
}
|
||||
}
|
||||
taskbar->text_width =
|
||||
text_width - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingxlr;
|
||||
taskbar->text_width = text_width - panel->g_task.text_posx - right_border_width(&panel->g_task.area) -
|
||||
panel->g_task.area.paddingxlr;
|
||||
} else {
|
||||
relayout_with_constraint(&taskbar->area, panel->g_task.maximum_height);
|
||||
|
||||
taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.area.paddingy) - panel->g_task.text_posx -
|
||||
panel->g_task.area.bg->border.width - panel->g_task.area.paddingxlr;
|
||||
right_border_width(&panel->g_task.area) - panel->g_task.area.paddingxlr;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -147,14 +147,14 @@ gboolean resize_taskbarname(void *obj)
|
|||
FALSE);
|
||||
|
||||
if (panel_horizontal) {
|
||||
int new_size = name_width + (2 * (taskbar_name->area.paddingxlr + taskbar_name->area.bg->border.width));
|
||||
int new_size = name_width + 2 * taskbar_name->area.paddingxlr + left_right_border_width(&taskbar_name->area);
|
||||
if (new_size != taskbar_name->area.width) {
|
||||
taskbar_name->area.width = new_size;
|
||||
taskbar_name->posy = (taskbar_name->area.height - name_height) / 2;
|
||||
result = TRUE;
|
||||
}
|
||||
} else {
|
||||
int new_size = name_height + (2 * (taskbar_name->area.paddingxlr + taskbar_name->area.bg->border.width));
|
||||
int new_size = name_height + 2 * taskbar_name->area.paddingxlr + top_bottom_border_width(&taskbar_name->area);
|
||||
if (new_size != taskbar_name->area.height) {
|
||||
taskbar_name->area.height = new_size;
|
||||
taskbar_name->posy = (taskbar_name->area.height - name_height) / 2;
|
||||
|
|
|
@ -160,8 +160,8 @@ void tooltip_update_geometry()
|
|||
pango_layout_set_text(layout, g_tooltip.tooltip_text, -1);
|
||||
pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
|
||||
pango_layout_get_pixel_extents(layout, &r1, &r2);
|
||||
width = 2 * g_tooltip.bg->border.width + 2 * g_tooltip.paddingx + r2.width;
|
||||
height = 2 * g_tooltip.bg->border.width + 2 * g_tooltip.paddingy + r2.height;
|
||||
width = left_right_bg_border_width(g_tooltip.bg) + 2 * g_tooltip.paddingx + r2.width;
|
||||
height = top_bottom_bg_border_width(g_tooltip.bg) + 2 * g_tooltip.paddingy + r2.height;
|
||||
|
||||
if (panel_horizontal && panel_position & BOTTOM)
|
||||
y = panel->posy - height;
|
||||
|
@ -275,8 +275,8 @@ void tooltip_update()
|
|||
// I do not know why this is the right way, but with the below cairo_move_to it seems to be centered (horiz. and
|
||||
// vert.)
|
||||
cairo_move_to(c,
|
||||
-r1.x / 2 + g_tooltip.bg->border.width + g_tooltip.paddingx,
|
||||
-r1.y / 2 + 1 + g_tooltip.bg->border.width + g_tooltip.paddingy);
|
||||
-r1.x / 2 + left_bg_border_width(g_tooltip.bg) + g_tooltip.paddingx,
|
||||
-r1.y / 2 + 1 + top_bg_border_width(g_tooltip.bg) + g_tooltip.paddingy);
|
||||
pango_cairo_show_layout(c, layout);
|
||||
|
||||
g_object_unref(layout);
|
||||
|
|
111
src/util/area.c
111
src/util/area.c
|
@ -45,14 +45,14 @@ void initialize_positions(void *obj, int offset)
|
|||
for (GList *l = a->children; l; l = l->next) {
|
||||
Area *child = ((Area *)l->data);
|
||||
if (panel_horizontal) {
|
||||
child->posy = offset + a->bg->border.width + a->paddingy;
|
||||
child->height = a->height - (2 * (a->bg->border.width + a->paddingy));
|
||||
child->posy = offset + top_border_width(a) + a->paddingy;
|
||||
child->height = a->height - 2 * a->paddingy - top_bottom_border_width(a);
|
||||
if (child->_on_change_layout)
|
||||
child->_on_change_layout(child);
|
||||
initialize_positions(child, child->posy);
|
||||
} else {
|
||||
child->posx = offset + a->bg->border.width + a->paddingy;
|
||||
child->width = a->width - (2 * (a->bg->border.width + a->paddingy));
|
||||
child->posx = offset + left_border_width(a) + a->paddingy;
|
||||
child->width = a->width - 2 * a->paddingy - left_right_border_width(a);
|
||||
if (child->_on_change_layout)
|
||||
child->_on_change_layout(child);
|
||||
initialize_positions(child, child->posx);
|
||||
|
@ -108,7 +108,8 @@ void relayout_dynamic(Area *a, int level)
|
|||
// Layout children
|
||||
if (a->children) {
|
||||
if (a->alignment == ALIGN_LEFT) {
|
||||
int pos = (panel_horizontal ? a->posx : a->posy) + a->bg->border.width + a->paddingxlr;
|
||||
int pos =
|
||||
(panel_horizontal ? a->posx + left_border_width(a) : a->posy + top_border_width(a)) + a->paddingxlr;
|
||||
|
||||
for (GList *l = a->children; l; l = l->next) {
|
||||
Area *child = ((Area *)l->data);
|
||||
|
@ -134,8 +135,9 @@ void relayout_dynamic(Area *a, int level)
|
|||
pos += panel_horizontal ? child->width + a->paddingx : child->height + a->paddingx;
|
||||
}
|
||||
} else if (a->alignment == ALIGN_RIGHT) {
|
||||
int pos =
|
||||
(panel_horizontal ? a->posx + a->width : a->posy + a->height) - a->bg->border.width - a->paddingxlr;
|
||||
int pos = (panel_horizontal ? a->posx + a->width - right_border_width(a)
|
||||
: a->posy + a->height - bottom_border_width(a)) -
|
||||
a->paddingxlr;
|
||||
|
||||
for (GList *l = g_list_last(a->children); l; l = l->prev) {
|
||||
Area *child = ((Area *)l->data);
|
||||
|
@ -175,7 +177,7 @@ void relayout_dynamic(Area *a, int level)
|
|||
children_size += (l == a->children) ? 0 : a->paddingx;
|
||||
}
|
||||
|
||||
int pos = (panel_horizontal ? a->posx : a->posy) + a->bg->border.width + a->paddingxlr;
|
||||
int pos = (panel_horizontal ? a->posx + left_border_width(a) : a->posy + top_border_width(a)) + a->paddingxlr;
|
||||
pos += ((panel_horizontal ? a->width : a->height) - children_size) / 2;
|
||||
|
||||
for (GList *l = a->children; l; l = l->next) {
|
||||
|
@ -251,7 +253,7 @@ int relayout_with_constraint(Area *a, int maximum_size)
|
|||
|
||||
if (panel_horizontal) {
|
||||
// detect free size for LAYOUT_DYNAMIC Areas
|
||||
int size = a->width - (2 * (a->paddingxlr + a->bg->border.width));
|
||||
int size = a->width - 2 * a->paddingxlr - left_right_border_width(a);
|
||||
for (GList *l = a->children; l; l = l->next) {
|
||||
Area *child = (Area *)l->data;
|
||||
if (child->on_screen && child->size_mode == LAYOUT_FIXED) {
|
||||
|
@ -291,7 +293,7 @@ int relayout_with_constraint(Area *a, int maximum_size)
|
|||
}
|
||||
} else {
|
||||
// detect free size for LAYOUT_DYNAMIC's Area
|
||||
int size = a->height - (2 * (a->paddingxlr + a->bg->border.width));
|
||||
int size = a->height - 2 * a->paddingxlr - top_bottom_border_width(a);
|
||||
for (GList *l = a->children; l; l = l->next) {
|
||||
Area *child = (Area *)l->data;
|
||||
if (child->on_screen && child->size_mode == LAYOUT_FIXED) {
|
||||
|
@ -457,14 +459,10 @@ void draw_background(Area *a, cairo_t *c)
|
|||
a->bg->fill_color.alpha);
|
||||
// Not sure about this
|
||||
draw_rect(c,
|
||||
a->bg->border.mask & BORDER_LEFT ? a->bg->border.width : 0,
|
||||
a->bg->border.mask & BORDER_TOP ? a->bg->border.width : 0,
|
||||
a->width
|
||||
- (a->bg->border.mask & BORDER_LEFT ? a->bg->border.width : 0)
|
||||
- (a->bg->border.mask & BORDER_RIGHT ? a->bg->border.width : 0),
|
||||
a->height
|
||||
- (a->bg->border.mask & BORDER_TOP ? a->bg->border.width : 0)
|
||||
- (a->bg->border.mask & BORDER_BOTTOM ? a->bg->border.width : 0),
|
||||
left_border_width(a),
|
||||
top_border_width(a),
|
||||
a->width - left_right_border_width(a),
|
||||
a->height - top_bottom_border_width(a),
|
||||
a->bg->border.radius - a->bg->border.width / 1.571);
|
||||
|
||||
cairo_fill(c);
|
||||
|
@ -493,14 +491,10 @@ void draw_background(Area *a, cairo_t *c)
|
|||
a->bg->border.color.rgb[2],
|
||||
a->bg->border.color.alpha);
|
||||
draw_rect_on_sides(c,
|
||||
a->bg->border.mask & BORDER_LEFT ? a->bg->border.width / 2. : 0,
|
||||
a->bg->border.mask & BORDER_TOP ? a->bg->border.width / 2.0 : 0,
|
||||
a->width
|
||||
- (a->bg->border.mask & BORDER_LEFT ? a->bg->border.width / 2. : 0)
|
||||
- (a->bg->border.mask & BORDER_RIGHT ? a->bg->border.width / 2. : 0),
|
||||
a->height
|
||||
- (a->bg->border.mask & BORDER_TOP ? a->bg->border.width / 2. : 0)
|
||||
- (a->bg->border.mask & BORDER_BOTTOM ? a->bg->border.width / 2. : 0),
|
||||
left_border_width(a) / 2.,
|
||||
top_border_width(a) / 2.,
|
||||
a->width - left_right_border_width(a) / 2.,
|
||||
a->height - top_bottom_border_width(a) / 2.,
|
||||
a->bg->border.radius,
|
||||
a->bg->border.mask);
|
||||
|
||||
|
@ -713,3 +707,68 @@ Area *find_area_under_mouse(void *root, int x, int y)
|
|||
} while (new_result != result);
|
||||
return result;
|
||||
}
|
||||
|
||||
int left_border_width(Area *a)
|
||||
{
|
||||
return left_bg_border_width(a->bg);
|
||||
}
|
||||
|
||||
int right_border_width(Area *a)
|
||||
{
|
||||
return right_bg_border_width(a->bg);
|
||||
}
|
||||
|
||||
int top_border_width(Area *a)
|
||||
{
|
||||
return top_bg_border_width(a->bg);
|
||||
}
|
||||
|
||||
int bottom_border_width(Area *a)
|
||||
{
|
||||
return bottom_bg_border_width(a->bg);
|
||||
}
|
||||
|
||||
int left_right_border_width(Area *a)
|
||||
{
|
||||
return left_right_bg_border_width(a->bg);
|
||||
}
|
||||
|
||||
int top_bottom_border_width(Area *a)
|
||||
{
|
||||
return top_bottom_bg_border_width(a->bg);
|
||||
}
|
||||
|
||||
int bg_border_width(Background *bg, int mask)
|
||||
{
|
||||
return bg->border.mask & mask ? bg->border.width : 0;
|
||||
}
|
||||
|
||||
int left_bg_border_width(Background *bg)
|
||||
{
|
||||
return bg_border_width(bg, BORDER_LEFT);
|
||||
}
|
||||
|
||||
int top_bg_border_width(Background *bg)
|
||||
{
|
||||
return bg_border_width(bg, BORDER_TOP);
|
||||
}
|
||||
|
||||
int right_bg_border_width(Background *bg)
|
||||
{
|
||||
return bg_border_width(bg, BORDER_RIGHT);
|
||||
}
|
||||
|
||||
int bottom_bg_border_width(Background *bg)
|
||||
{
|
||||
return bg_border_width(bg, BORDER_BOTTOM);
|
||||
}
|
||||
|
||||
int left_right_bg_border_width(Background *bg)
|
||||
{
|
||||
return left_bg_border_width(bg) + right_bg_border_width(bg);
|
||||
}
|
||||
|
||||
int top_bottom_bg_border_width(Background *bg)
|
||||
{
|
||||
return top_bg_border_width(bg) + bottom_bg_border_width(bg);
|
||||
}
|
||||
|
|
|
@ -250,6 +250,20 @@ void relayout(Area *a);
|
|||
// If maximum_size > 0, it is an upper limit for the child size.
|
||||
int relayout_with_constraint(Area *a, int maximum_size);
|
||||
|
||||
int left_border_width(Area *a);
|
||||
int right_border_width(Area *a);
|
||||
int left_right_border_width(Area *a);
|
||||
int top_border_width(Area *a);
|
||||
int bottom_border_width(Area *a);
|
||||
int top_bottom_border_width(Area *a);
|
||||
|
||||
int left_bg_border_width(Background *bg);
|
||||
int right_bg_border_width(Background *bg);
|
||||
int top_bg_border_width(Background *bg);
|
||||
int bottom_bg_border_width(Background *bg);
|
||||
int left_right_bg_border_width(Background *bg);
|
||||
int top_bottom_bg_border_width(Background *bg);
|
||||
|
||||
// Rendering
|
||||
|
||||
// Sets the redraw_needed flag on the area and its descendants
|
||||
|
|
Loading…
Reference in a new issue