changeset 3036:b0f8da03187b

Fix multiple issues with vector fonts in the skinned interface.
author John Lindgren <john.lindgren@tds.net>
date Sat, 11 Apr 2009 08:26:51 -0400
parents 13a0e4377c20
children 91d50f13948a
files src/skins/ui_main.c src/skins/ui_skinned_textbox.c
diffstat 2 files changed, 15 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/skins/ui_main.c	Fri Apr 10 13:24:02 2009 +0200
+++ b/src/skins/ui_main.c	Sat Apr 11 08:26:51 2009 -0400
@@ -472,8 +472,8 @@
 
     if (aud_active_skin->properties.mainwin_text_width) {
         UI_SKINNED_TEXTBOX(mainwin_info)->width = aud_active_skin->properties.mainwin_text_width;
-        gtk_widget_set_size_request(mainwin_info, aud_active_skin->properties.mainwin_text_width * MAINWIN_SCALE_FACTOR,
-                                    UI_SKINNED_TEXTBOX(mainwin_info)->height * MAINWIN_SCALE_FACTOR );
+        gtk_widget_set_size_request (mainwin_info, aud_active_skin->properties.
+         mainwin_text_width * MAINWIN_SCALE_FACTOR, -1);
     }
 
     if (aud_active_skin->properties.mainwin_infobar_x && aud_active_skin->properties.mainwin_infobar_y)
--- a/src/skins/ui_skinned_textbox.c	Fri Apr 10 13:24:02 2009 +0200
+++ b/src/skins/ui_skinned_textbox.c	Sat Apr 11 08:26:51 2009 -0400
@@ -136,22 +136,22 @@
     klass->right_clicked = NULL;
     klass->scaled = ui_skinned_textbox_toggle_scaled;
 
-    textbox_signals[CLICKED] = 
+    textbox_signals[CLICKED] =
         g_signal_new ("clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
                       G_STRUCT_OFFSET (UiSkinnedTextboxClass, clicked), NULL, NULL,
                       g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
 
-    textbox_signals[DOUBLE_CLICKED] = 
+    textbox_signals[DOUBLE_CLICKED] =
         g_signal_new ("double-clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
                       G_STRUCT_OFFSET (UiSkinnedTextboxClass, double_clicked), NULL, NULL,
                       g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
 
-    textbox_signals[RIGHT_CLICKED] = 
+    textbox_signals[RIGHT_CLICKED] =
         g_signal_new ("right-clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
                       G_STRUCT_OFFSET (UiSkinnedTextboxClass, right_clicked), NULL, NULL,
                       g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
 
-    textbox_signals[DOUBLED] = 
+    textbox_signals[DOUBLED] =
         g_signal_new ("toggle-scaled", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
                       G_STRUCT_OFFSET (UiSkinnedTextboxClass, scaled), NULL, NULL,
                       g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
@@ -453,7 +453,7 @@
 
     priv->scaled = !priv->scaled;
 
-    gtk_widget_set_size_request(widget, textbox->width*(priv->scaled ? config.scale_factor : 1 ), 
+    gtk_widget_set_size_request(widget, textbox->width*(priv->scaled ? config.scale_factor : 1 ),
     textbox->height*(priv->scaled ? config.scale_factor : 1 ));
 
     gtk_widget_queue_draw(GTK_WIDGET(textbox));
@@ -488,6 +488,8 @@
     gint ascent, descent;
 
     g_return_if_fail(textbox != NULL);
+    gtk_widget_queue_resize (widget);
+    gtk_widget_queue_draw (widget);
 
     if (priv->font) {
         pango_font_description_free(priv->font);
@@ -519,11 +521,9 @@
     if (priv->font == NULL)
         return;
 
-    textbox->height = priv->font_ascent;
-    if (textbox->height > priv->nominal_height)
-        textbox->y -= (textbox->height - priv->nominal_height) / 2;
-    else
-        textbox->height = priv->nominal_height;
+    textbox->height = priv->font_ascent; /* The real height of the text is
+     ascent - descent (descent is negative), but we cut off descent pixels from
+     the top to make it fit better. See textbox_generate_xfont_pixmap. */
 }
 
 void ui_skinned_textbox_set_text(GtkWidget *widget, const gchar *text) {
@@ -586,7 +586,8 @@
     layout = gtk_widget_create_pango_layout(mainwin, pixmaptext);
     pango_layout_set_font_description(layout, priv->font);
 
-    gdk_draw_layout(pixmap, gc, 0, (priv->font_descent / 2), layout);
+    gdk_draw_layout (pixmap, gc, 0, priv->font_descent, layout); /* See
+     explanation in ui_skinned_textbox_set_xfont. */
     g_object_unref(layout);
 
     g_object_unref(maskgc);
@@ -736,7 +737,7 @@
         skin_draw_pixbuf(GTK_WIDGET(textbox), aud_active_skin,
                          priv->pixbuf, priv->skin_index,
                          x, y, i * aud_active_skin->properties.textbox_bitmap_font_width, 0,
-                         aud_active_skin->properties.textbox_bitmap_font_width, 
+                         aud_active_skin->properties.textbox_bitmap_font_width,
                          aud_active_skin->properties.textbox_bitmap_font_height);
     }
     g_free(stxt);