From: Pierre-Luc Beaudoin Date: Wed, 8 Apr 2009 00:49:15 +0000 (-0400) Subject: Fix padding X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ca61f03e24da569729ceadd9b738710457dc8f1;p=libchamplain Fix padding --- diff --git a/champlain/champlain-marker.c b/champlain/champlain-marker.c index 0555157..b11cb92 100644 --- a/champlain/champlain-marker.c +++ b/champlain/champlain-marker.c @@ -381,13 +381,18 @@ draw_marker (ChamplainMarker *marker) height = clutter_actor_get_height (actor); if (has_image) - clutter_actor_set_position (actor, total_width, (total_height - height) / 2.0); + { + clutter_actor_set_position (actor, total_width, (total_height - height) / 2.0); + total_width += clutter_actor_get_width (actor) + 2 * padding; + } else - clutter_actor_set_position (actor, padding, padding); + { + clutter_actor_set_position (actor, 2 * padding, padding); + total_width += clutter_actor_get_width (actor) + 4 * padding; + } - total_width += clutter_actor_get_width (actor) + 2 * padding; + height += 2 * padding; - height += padding; if (height > total_height) total_height = height; clutter_label_set_color (CLUTTER_LABEL (actor), priv->text_color); @@ -398,6 +403,12 @@ draw_marker (ChamplainMarker *marker) has_text = TRUE; } + if (has_image == FALSE && has_text == FALSE) + { + total_width = 30; + total_height = 30; + } + point = (total_height + 2 * padding) / 4.0; if (priv->background != NULL) @@ -441,7 +452,7 @@ draw_marker (ChamplainMarker *marker) if (has_text) clutter_actor_raise (text_actor, bg); if (has_image) - clutter_actor_raise (image_actor, bg); + clutter_actor_raise (image_actor, bg); clutter_actor_set_anchor_point (CLUTTER_ACTOR (marker), 0, total_height + point); } @@ -544,14 +555,11 @@ champlain_marker_new_with_image (const gchar *filename, GError **error) ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ()); ClutterActor *actor = clutter_texture_new_from_file (filename, error); - if (actor == NULL) + if (actor != NULL) { - g_object_unref (G_OBJECT (marker)); - return NULL; + champlain_marker_set_image (marker, actor); } - champlain_marker_set_image (marker, actor); - return CLUTTER_ACTOR (marker); } @@ -580,12 +588,10 @@ champlain_marker_new_full (const gchar *text, ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ()); ClutterActor *actor = clutter_texture_new_from_file (filename, error); - if (actor == NULL) + if (actor != NULL) { - g_object_unref (G_OBJECT (marker)); - return NULL; + champlain_marker_set_image (marker, actor); } - champlain_marker_set_image (marker, actor); champlain_marker_set_text (marker, text); return CLUTTER_ACTOR (marker);