[libgnomekbd] Make all symbol drawings full-width, using alignment to place them
- From: Corentin Noël <corentinnoel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgnomekbd] Make all symbol drawings full-width, using alignment to place them
- Date: Wed, 22 Jun 2022 07:25:32 +0000 (UTC)
commit 826cc95889b0a5bb2507d32a2960d2e4eac7a476
Author: Daniel Kahn Gillmor <dkg fifthhorseman net>
Date: Sat Jan 8 11:48:43 2022 -0500
Make all symbol drawings full-width, using alignment to place them
Currently, left-displayed symbols (those produced without AltGr) are
drawn on a key rendering in a full-width cell, but right-displayed
symbols (those produced with AltGr) are only drawn in half-width cells
on the key rendering.
This means that left-displayed symbols can still overlap with
right-hand symbols if they happen to be wide, but right-hand symbols
are more likely to be truncated ("ellipsized").
This change still allows the symbols to overlap, but makes
right-displayed symbols less likely to be ellipsized. We do this by
using alignment to place right-displayed symbols to the right, instead
of using a half-width cell.
libgnomekbd/gkbd-keyboard-drawing.c | 45 +++++++++++++------------------------
1 file changed, 15 insertions(+), 30 deletions(-)
---
diff --git a/libgnomekbd/gkbd-keyboard-drawing.c b/libgnomekbd/gkbd-keyboard-drawing.c
index 5d7c5ed..9271c69 100644
--- a/libgnomekbd/gkbd-keyboard-drawing.c
+++ b/libgnomekbd/gkbd-keyboard-drawing.c
@@ -927,6 +927,7 @@ draw_key_label_helper (GkbdKeyboardDrawingRenderContext * context,
gboolean is_pressed)
{
gint label_x, label_y, label_max_width, ycell;
+ PangoAlignment align;
if (keysym == 0)
return;
@@ -935,46 +936,30 @@ draw_key_label_helper (GkbdKeyboardDrawingRenderContext * context,
(unsigned) keysym, (char) keysym, (int) glp);
#endif
+ ycell = ((glp == GKBD_KEYBOARD_DRAWING_POS_BOTTOMLEFT) ||
+ (glp == GKBD_KEYBOARD_DRAWING_POS_BOTTOMRIGHT));
+ rotate_coordinate (x, y, x + padding,
+ y + padding + (height -
+ 2 * padding) *
+ ycell * 4 / 7, angle, &label_x,
+ &label_y);
+ label_max_width = PANGO_SCALE * (width - 2 * padding);
+
switch (glp) {
case GKBD_KEYBOARD_DRAWING_POS_TOPLEFT:
case GKBD_KEYBOARD_DRAWING_POS_BOTTOMLEFT:
- {
- ycell =
- glp == GKBD_KEYBOARD_DRAWING_POS_BOTTOMLEFT;
-
- rotate_coordinate (x, y, x + padding,
- y + padding + (height -
- 2 * padding) *
- ycell * 4 / 7, angle, &label_x,
- &label_y);
- label_max_width =
- PANGO_SCALE * (width - 2 * padding);
- break;
- }
+ align = PANGO_ALIGN_LEFT;
+ break;
case GKBD_KEYBOARD_DRAWING_POS_TOPRIGHT:
case GKBD_KEYBOARD_DRAWING_POS_BOTTOMRIGHT:
- {
- ycell =
- glp == GKBD_KEYBOARD_DRAWING_POS_BOTTOMRIGHT;
-
- rotate_coordinate (x, y,
- x + padding + (width -
- 2 * padding) *
- 4 / 7,
- y + padding + (height -
- 2 * padding) *
- ycell * 4 / 7, angle, &label_x,
- &label_y);
- label_max_width =
- PANGO_SCALE * ((width - 2 * padding) -
- (width - 2 * padding) * 4 / 7);
- break;
- }
+ align = PANGO_ALIGN_RIGHT;
+ break;
default:
return;
}
set_key_label_in_layout (context, keysym);
pango_layout_set_width (context->layout, label_max_width);
+ pango_layout_set_alignment (context->layout, align);
label_y -= (pango_layout_get_line_count (context->layout) - 1) *
(pango_font_description_get_size (context->font_desc) /
PANGO_SCALE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]