From 3ca86b2197335b5c592f4652cc2778a59e1aa42d Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Tue, 2 Nov 2010 17:35:22 -0400 Subject: [PATCH] StIcon: Center the icon rather than scaling it up Scaling up icons from the loaded size to a larger size is uniformly ugly and results in a long series of "fuzzy icon" bugs. It's better to just load at the specified size and center. (Centering can be overridden by packing not-fill in the parent container.) https://bugzilla.gnome.org/show_bug.cgi?id=633865 --- src/st/st-icon.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/st/st-icon.c b/src/st/st-icon.c index 1e9295594..171698694 100644 --- a/src/st/st-icon.c +++ b/src/st/st-icon.c @@ -183,6 +183,21 @@ st_icon_allocate (ClutterActor *actor, ClutterActorBox content_box; st_theme_node_get_content_box (theme_node, box, &content_box); + + /* Center the texture in the allocation; scaling up the icon from the size + * we loaded it at is just a bad idea and probably accidental. Main downside + * of doing this is that it may not be obvious that they have to turn off + * fill to align the icon non-centered in the parent container. + * + * We don't use _st_allocate_fill() for a bit of efficiency and because we + * expect to get rid of the child actor in favor of a CoglTexture in the + * future. + */ + content_box.x1 = (int)(0.5 + content_box.x1 + (content_box.x2 - content_box.x1 - priv->icon_size) / 2.); + content_box.x2 = content_box.x1 + priv->icon_size; + content_box.y1 = (int)(0.5 + content_box.y1 + (content_box.y2 - content_box.y1 - priv->icon_size) / 2.); + content_box.y2 = content_box.y1 + priv->icon_size; + clutter_actor_allocate (priv->icon_texture, &content_box, flags); } }