implemented shrink option
This commit is contained in:
parent
a25954f8a6
commit
dd047ccd20
39
x.c
39
x.c
@ -203,7 +203,7 @@ static dimension_t calculate_dimensions(GSList *layouts)
|
|||||||
dim.h += (g_slist_length(layouts) - 1) * settings.separator_height;
|
dim.h += (g_slist_length(layouts) - 1) * settings.separator_height;
|
||||||
dim.h += g_slist_length(layouts) * settings.padding * 2;
|
dim.h += g_slist_length(layouts) * settings.padding * 2;
|
||||||
|
|
||||||
int text_width = 0;
|
int text_width = 0, total_width = 0;
|
||||||
for (GSList *iter = layouts; iter; iter = iter->next) {
|
for (GSList *iter = layouts; iter; iter = iter->next) {
|
||||||
colored_layout *cl = iter->data;
|
colored_layout *cl = iter->data;
|
||||||
int w,h;
|
int w,h;
|
||||||
@ -211,26 +211,31 @@ static dimension_t calculate_dimensions(GSList *layouts)
|
|||||||
dim.h += h;
|
dim.h += h;
|
||||||
text_width = MAX(w, text_width);
|
text_width = MAX(w, text_width);
|
||||||
|
|
||||||
if (dim.w <= 0) {
|
if (dim.w <= 0 || settings.shrink) {
|
||||||
/* dynamic width */
|
/* dynamic width */
|
||||||
if ((text_width + 2 * settings.h_padding) > scr.dim.w) {
|
total_width = MAX(text_width + 2 * settings.h_padding, total_width);
|
||||||
/* it's bigger than the screen */
|
|
||||||
/* subtract height from the unwrapped text */
|
/* subtract height from the unwrapped text */
|
||||||
dim.h -= h;
|
dim.h -= h;
|
||||||
|
|
||||||
|
if (total_width > scr.dim.w) {
|
||||||
/* set width to screen width */
|
/* set width to screen width */
|
||||||
dim.w = scr.dim.w - xctx.geometry.y * 2;
|
dim.w = scr.dim.w - xctx.geometry.y * 2;
|
||||||
|
} else if (total_width < xctx.geometry.w && settings.shrink) {
|
||||||
/* re-setup the layout */
|
/* set width to text width */
|
||||||
int width = dim.w;
|
dim.w = total_width + 2 * settings.frame_width;
|
||||||
width -= 2 * settings.h_padding;
|
|
||||||
width -= 2 * settings.frame_width;
|
|
||||||
r_setup_pango_layout(cl->l, width);
|
|
||||||
|
|
||||||
/* re-read information */
|
|
||||||
pango_layout_get_pixel_size(cl->l, &w, &h);
|
|
||||||
dim.h += h;
|
|
||||||
text_width = MAX(w, text_width);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* re-setup the layout */
|
||||||
|
int width = dim.w;
|
||||||
|
width -= 2 * settings.h_padding;
|
||||||
|
width -= 2 * settings.frame_width;
|
||||||
|
r_setup_pango_layout(cl->l, width);
|
||||||
|
|
||||||
|
/* re-read information */
|
||||||
|
pango_layout_get_pixel_size(cl->l, &w, &h);
|
||||||
|
dim.h += h;
|
||||||
|
text_width = MAX(w, text_width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user