[libshumate] vector: Silence warnings about gtk_widget_measure
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libshumate] vector: Silence warnings about gtk_widget_measure
- Date: Thu, 23 Jun 2022 21:16:33 +0000 (UTC)
commit 8839ab82ea0014d01c8872b011722d8117bb179b
Author: James Westman <james jwestman net>
Date: Fri May 27 11:49:28 2022 -0500
vector: Silence warnings about gtk_widget_measure
gtk_widget_measure needs to be called during the parent's size_allocate,
even if the results aren't used.
shumate/shumate-map-layer.c | 5 ++++
shumate/vector/shumate-vector-symbol-container.c | 4 ++++
shumate/vector/shumate-vector-symbol.c | 30 ++++++++++++++++++++++++
3 files changed, 39 insertions(+)
---
diff --git a/shumate/shumate-map-layer.c b/shumate/shumate-map-layer.c
index 05fc448..2f2c3f9 100644
--- a/shumate/shumate-map-layer.c
+++ b/shumate/shumate-map-layer.c
@@ -538,6 +538,11 @@ shumate_map_layer_size_allocate (GtkWidget *widget,
}
#ifdef SHUMATE_HAS_VECTOR_RENDERER
+ /* gtk_widget_measure needs to be called during size_allocate, but we don't
+ * care about the result here--the symbol container always gets the same
+ * size as the map layer */
+ gtk_widget_measure (GTK_WIDGET (self->symbols), GTK_ORIENTATION_VERTICAL, -1, NULL, NULL, NULL, NULL);
+
child_allocation.x = 0;
child_allocation.y = 0;
child_allocation.width = width;
diff --git a/shumate/vector/shumate-vector-symbol-container.c
b/shumate/vector/shumate-vector-symbol-container.c
index fd35ca8..a18ba8a 100644
--- a/shumate/vector/shumate-vector-symbol-container.c
+++ b/shumate/vector/shumate-vector-symbol-container.c
@@ -215,11 +215,15 @@ shumate_vector_symbol_container_size_allocate (GtkWidget *widget,
float tile_size_at_zoom = tile_size * powf (2, zoom_level - child->zoom);
float x = (child->tile_x + child->x) * tile_size_at_zoom - center_x + width/2.0;
float y = (child->tile_y + child->y) * tile_size_at_zoom - center_y + height/2.0;
+ int width, height;
gtk_widget_set_child_visible (GTK_WIDGET (child->symbol), child->marker->visible);
if (!child->marker->visible)
continue;
+ gtk_widget_measure (GTK_WIDGET (child->symbol), GTK_ORIENTATION_HORIZONTAL, -1, NULL, &width, NULL,
NULL);
+ gtk_widget_measure (GTK_WIDGET (child->symbol), GTK_ORIENTATION_VERTICAL, -1, NULL, &height, NULL,
NULL);
+
rotate_around_center (&x, &y, width, height, rotation);
alloc.x = x - child->width/2.0;
alloc.y = y - child->height/2.0;
diff --git a/shumate/vector/shumate-vector-symbol.c b/shumate/vector/shumate-vector-symbol.c
index c26610d..5940791 100644
--- a/shumate/vector/shumate-vector-symbol.c
+++ b/shumate/vector/shumate-vector-symbol.c
@@ -220,6 +220,35 @@ positive_mod (double i, double n)
}
+static void
+shumate_vector_symbol_measure (GtkWidget *widget,
+ GtkOrientation orientation,
+ int for_size,
+ int *minimum,
+ int *natural,
+ int *minimum_baseline,
+ int *natural_baseline)
+{
+ ShumateVectorSymbol *self = SHUMATE_VECTOR_SYMBOL (widget);
+
+ if (self->symbol_info->line_placement)
+ {
+ if (minimum)
+ *minimum = 0;
+ if (natural)
+ *natural = 0;
+ }
+ else
+ GTK_WIDGET_CLASS (shumate_vector_symbol_parent_class)->measure (widget,
+ orientation,
+ for_size,
+ minimum,
+ natural,
+ minimum_baseline,
+ natural_baseline);
+}
+
+
static void
shumate_vector_symbol_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
@@ -314,6 +343,7 @@ shumate_vector_symbol_class_init (ShumateVectorSymbolClass *klass)
object_class->set_property = shumate_vector_symbol_set_property;
widget_class->snapshot = shumate_vector_symbol_snapshot;
+ widget_class->measure = shumate_vector_symbol_measure;
obj_properties[PROP_SYMBOL_INFO] =
g_param_spec_boxed ("symbol-info",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]