Match perfectly text layout and drawing parameters #693
This commit is contained in:
parent
c3fdd76b58
commit
03675b152d
7 changed files with 22 additions and 7 deletions
|
@ -299,6 +299,7 @@ int button_compute_desired_size(void *obj)
|
|||
strlen(button->backend->text),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
button->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT,
|
||||
FALSE,
|
||||
panel->scale);
|
||||
} else {
|
||||
|
@ -312,6 +313,7 @@ int button_compute_desired_size(void *obj)
|
|||
strlen(button->backend->text),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
button->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT,
|
||||
FALSE,
|
||||
panel->scale);
|
||||
}
|
||||
|
@ -380,6 +382,7 @@ gboolean resize_button(void *obj)
|
|||
strlen(button->backend->text),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
button->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT,
|
||||
FALSE,
|
||||
panel->scale);
|
||||
} else {
|
||||
|
|
|
@ -349,6 +349,7 @@ void execp_compute_icon_text_geometry(Execp *execp,
|
|||
strlen(execp->backend->text),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
execp->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT,
|
||||
execp->backend->has_markup,
|
||||
panel->scale);
|
||||
|
||||
|
|
|
@ -343,6 +343,7 @@ void init_taskbar_panel(void *p)
|
|||
5,
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_END,
|
||||
panel->g_task.centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT,
|
||||
FALSE,
|
||||
panel->scale);
|
||||
|
||||
|
|
|
@ -144,6 +144,7 @@ int taskbarname_compute_desired_size(void *obj)
|
|||
strlen(taskbar_name->name),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
PANGO_ALIGN_CENTER,
|
||||
FALSE,
|
||||
panel->scale);
|
||||
|
||||
|
@ -171,6 +172,7 @@ gboolean resize_taskbarname(void *obj)
|
|||
strlen(taskbar_name->name),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
PANGO_ALIGN_CENTER,
|
||||
FALSE,
|
||||
panel->scale);
|
||||
|
||||
|
|
|
@ -947,6 +947,7 @@ void area_compute_text_geometry(Area *area,
|
|||
strlen(line1),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
PANGO_ALIGN_CENTER,
|
||||
FALSE,
|
||||
((Panel*)area->panel)->scale);
|
||||
else
|
||||
|
@ -962,6 +963,7 @@ void area_compute_text_geometry(Area *area,
|
|||
strlen(line2),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
PANGO_ALIGN_CENTER,
|
||||
FALSE,
|
||||
((Panel*)area->panel)->scale);
|
||||
else
|
||||
|
|
|
@ -933,6 +933,7 @@ void get_text_size(const PangoFontDescription *font,
|
|||
int text_len,
|
||||
PangoWrapMode wrap,
|
||||
PangoEllipsizeMode ellipsis,
|
||||
PangoAlignment alignment,
|
||||
gboolean markup,
|
||||
double scale)
|
||||
{
|
||||
|
@ -951,6 +952,7 @@ void get_text_size(const PangoFontDescription *font,
|
|||
PangoLayout *layout = pango_layout_new(context);
|
||||
pango_layout_set_width(layout, available_width * PANGO_SCALE);
|
||||
pango_layout_set_height(layout, available_height * PANGO_SCALE);
|
||||
pango_layout_set_alignment(layout, alignment);
|
||||
pango_layout_set_wrap(layout, wrap);
|
||||
pango_layout_set_ellipsize(layout, ellipsis);
|
||||
pango_layout_set_font_description(layout, font);
|
||||
|
@ -982,38 +984,41 @@ void get_text_size2(const PangoFontDescription *font,
|
|||
int text_len,
|
||||
PangoWrapMode wrap,
|
||||
PangoEllipsizeMode ellipsis,
|
||||
PangoAlignment alignment,
|
||||
gboolean markup,
|
||||
double scale)
|
||||
{
|
||||
get_text_size(font, height, width, available_height, available_width, text, text_len, wrap, ellipsis, markup, scale);
|
||||
get_text_size(font, height, width, available_height, available_width, text, text_len, wrap, ellipsis, alignment, markup, scale);
|
||||
|
||||
// We do multiple passes, because pango sucks
|
||||
int actual_height, actual_width, overflow = 0;
|
||||
while (true) {
|
||||
get_text_size(font, &actual_height, &actual_width, *height, *width, text, text_len, wrap, ellipsis, markup, scale);
|
||||
get_text_size(font, &actual_height, &actual_width, *height, *width, text, text_len, wrap, ellipsis, alignment, markup, scale);
|
||||
if (actual_height <= *height)
|
||||
break;
|
||||
if (*width >= available_width + 50)
|
||||
if (*width >= available_width)
|
||||
break;
|
||||
overflow = 1;
|
||||
fprintf(stderr, "tint2: text overflows, recomputing: available %dx%d, computed %dx%d, actual %dx%d\n",
|
||||
fprintf(stderr, "tint2: text overflows, recomputing: available %dx%d, computed %dx%d, actual %dx%d: %s\n",
|
||||
available_width,
|
||||
available_height,
|
||||
*width,
|
||||
*height,
|
||||
actual_width,
|
||||
actual_height);
|
||||
actual_height,
|
||||
text);
|
||||
(*width)++;
|
||||
}
|
||||
if (overflow) {
|
||||
*height = actual_height;
|
||||
fprintf(stderr, "tint2: text final size computed as: available %dx%d, computed %dx%d, actual %dx%d\n",
|
||||
fprintf(stderr, "tint2: text final size computed as: available %dx%d, computed %dx%d, actual %dx%d: %s\n",
|
||||
available_width,
|
||||
available_height,
|
||||
*width,
|
||||
*height,
|
||||
actual_width,
|
||||
actual_height);
|
||||
actual_height,
|
||||
text);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -122,6 +122,7 @@ void get_text_size2(const PangoFontDescription *font,
|
|||
int text_len,
|
||||
PangoWrapMode wrap,
|
||||
PangoEllipsizeMode ellipsis,
|
||||
PangoAlignment alignment,
|
||||
gboolean markup,
|
||||
double scale);
|
||||
|
||||
|
|
Loading…
Reference in a new issue