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),
|
strlen(button->backend->text),
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_NONE,
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
button->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT,
|
||||||
FALSE,
|
FALSE,
|
||||||
panel->scale);
|
panel->scale);
|
||||||
} else {
|
} else {
|
||||||
|
@ -312,6 +313,7 @@ int button_compute_desired_size(void *obj)
|
||||||
strlen(button->backend->text),
|
strlen(button->backend->text),
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_NONE,
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
button->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT,
|
||||||
FALSE,
|
FALSE,
|
||||||
panel->scale);
|
panel->scale);
|
||||||
}
|
}
|
||||||
|
@ -380,6 +382,7 @@ gboolean resize_button(void *obj)
|
||||||
strlen(button->backend->text),
|
strlen(button->backend->text),
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_NONE,
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
button->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT,
|
||||||
FALSE,
|
FALSE,
|
||||||
panel->scale);
|
panel->scale);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -349,6 +349,7 @@ void execp_compute_icon_text_geometry(Execp *execp,
|
||||||
strlen(execp->backend->text),
|
strlen(execp->backend->text),
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_NONE,
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
execp->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT,
|
||||||
execp->backend->has_markup,
|
execp->backend->has_markup,
|
||||||
panel->scale);
|
panel->scale);
|
||||||
|
|
||||||
|
|
|
@ -343,6 +343,7 @@ void init_taskbar_panel(void *p)
|
||||||
5,
|
5,
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_END,
|
PANGO_ELLIPSIZE_END,
|
||||||
|
panel->g_task.centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT,
|
||||||
FALSE,
|
FALSE,
|
||||||
panel->scale);
|
panel->scale);
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,7 @@ int taskbarname_compute_desired_size(void *obj)
|
||||||
strlen(taskbar_name->name),
|
strlen(taskbar_name->name),
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_NONE,
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
PANGO_ALIGN_CENTER,
|
||||||
FALSE,
|
FALSE,
|
||||||
panel->scale);
|
panel->scale);
|
||||||
|
|
||||||
|
@ -171,6 +172,7 @@ gboolean resize_taskbarname(void *obj)
|
||||||
strlen(taskbar_name->name),
|
strlen(taskbar_name->name),
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_NONE,
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
PANGO_ALIGN_CENTER,
|
||||||
FALSE,
|
FALSE,
|
||||||
panel->scale);
|
panel->scale);
|
||||||
|
|
||||||
|
|
|
@ -947,6 +947,7 @@ void area_compute_text_geometry(Area *area,
|
||||||
strlen(line1),
|
strlen(line1),
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_NONE,
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
PANGO_ALIGN_CENTER,
|
||||||
FALSE,
|
FALSE,
|
||||||
((Panel*)area->panel)->scale);
|
((Panel*)area->panel)->scale);
|
||||||
else
|
else
|
||||||
|
@ -962,6 +963,7 @@ void area_compute_text_geometry(Area *area,
|
||||||
strlen(line2),
|
strlen(line2),
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_NONE,
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
PANGO_ALIGN_CENTER,
|
||||||
FALSE,
|
FALSE,
|
||||||
((Panel*)area->panel)->scale);
|
((Panel*)area->panel)->scale);
|
||||||
else
|
else
|
||||||
|
|
|
@ -933,6 +933,7 @@ void get_text_size(const PangoFontDescription *font,
|
||||||
int text_len,
|
int text_len,
|
||||||
PangoWrapMode wrap,
|
PangoWrapMode wrap,
|
||||||
PangoEllipsizeMode ellipsis,
|
PangoEllipsizeMode ellipsis,
|
||||||
|
PangoAlignment alignment,
|
||||||
gboolean markup,
|
gboolean markup,
|
||||||
double scale)
|
double scale)
|
||||||
{
|
{
|
||||||
|
@ -951,6 +952,7 @@ void get_text_size(const PangoFontDescription *font,
|
||||||
PangoLayout *layout = pango_layout_new(context);
|
PangoLayout *layout = pango_layout_new(context);
|
||||||
pango_layout_set_width(layout, available_width * PANGO_SCALE);
|
pango_layout_set_width(layout, available_width * PANGO_SCALE);
|
||||||
pango_layout_set_height(layout, available_height * 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_wrap(layout, wrap);
|
||||||
pango_layout_set_ellipsize(layout, ellipsis);
|
pango_layout_set_ellipsize(layout, ellipsis);
|
||||||
pango_layout_set_font_description(layout, font);
|
pango_layout_set_font_description(layout, font);
|
||||||
|
@ -982,38 +984,41 @@ void get_text_size2(const PangoFontDescription *font,
|
||||||
int text_len,
|
int text_len,
|
||||||
PangoWrapMode wrap,
|
PangoWrapMode wrap,
|
||||||
PangoEllipsizeMode ellipsis,
|
PangoEllipsizeMode ellipsis,
|
||||||
|
PangoAlignment alignment,
|
||||||
gboolean markup,
|
gboolean markup,
|
||||||
double scale)
|
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
|
// We do multiple passes, because pango sucks
|
||||||
int actual_height, actual_width, overflow = 0;
|
int actual_height, actual_width, overflow = 0;
|
||||||
while (true) {
|
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)
|
if (actual_height <= *height)
|
||||||
break;
|
break;
|
||||||
if (*width >= available_width + 50)
|
if (*width >= available_width)
|
||||||
break;
|
break;
|
||||||
overflow = 1;
|
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_width,
|
||||||
available_height,
|
available_height,
|
||||||
*width,
|
*width,
|
||||||
*height,
|
*height,
|
||||||
actual_width,
|
actual_width,
|
||||||
actual_height);
|
actual_height,
|
||||||
|
text);
|
||||||
(*width)++;
|
(*width)++;
|
||||||
}
|
}
|
||||||
if (overflow) {
|
if (overflow) {
|
||||||
*height = actual_height;
|
*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_width,
|
||||||
available_height,
|
available_height,
|
||||||
*width,
|
*width,
|
||||||
*height,
|
*height,
|
||||||
actual_width,
|
actual_width,
|
||||||
actual_height);
|
actual_height,
|
||||||
|
text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,7 @@ void get_text_size2(const PangoFontDescription *font,
|
||||||
int text_len,
|
int text_len,
|
||||||
PangoWrapMode wrap,
|
PangoWrapMode wrap,
|
||||||
PangoEllipsizeMode ellipsis,
|
PangoEllipsizeMode ellipsis,
|
||||||
|
PangoAlignment alignment,
|
||||||
gboolean markup,
|
gboolean markup,
|
||||||
double scale);
|
double scale);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue