[gtk/path-tests: 123/125] curve2: Add a zoom slider
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/path-tests: 123/125] curve2: Add a zoom slider
- Date: Sat, 26 Dec 2020 19:08:08 +0000 (UTC)
commit 34f7097f95ed63bae68f686bfd4f5de1984f3280
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Dec 18 00:32:53 2020 -0500
curve2: Add a zoom slider
This is useful to test that path caching doesn't currently
pay attention to the scale.
tests/curve2.c | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/tests/curve2.c b/tests/curve2.c
index 6b16222d7d..b8acd23a93 100644
--- a/tests/curve2.c
+++ b/tests/curve2.c
@@ -30,6 +30,8 @@ struct _DemoWidget
graphene_rect_t bounds;
gboolean show_cairo;
+
+ double zoom;
};
struct _DemoWidgetClass
@@ -115,6 +117,8 @@ demo_widget_snapshot (GtkWidget *widget,
gtk_snapshot_save (snapshot);
+ gtk_snapshot_scale (snapshot, self->zoom, self->zoom);
+
width = gtk_widget_get_width (widget);
height = gtk_widget_get_width (widget);
@@ -265,13 +269,14 @@ demo_widget_measure (GtkWidget *widget,
int *natural_baseline)
{
DemoWidget *self = DEMO_WIDGET (widget);
-
- *minimum = *natural = 0;
+ float size;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- *minimum = *natural = self->bounds.origin.x + self->bounds.size.width;
+ size = self->zoom * (self->bounds.origin.x + self->bounds.size.width);
else
- *minimum = *natural = self->bounds.origin.y + self->bounds.size.height;
+ size = self->zoom * (self->bounds.origin.y + self->bounds.size.height);
+
+ *minimum = *natural = (int)size;
}
static void
@@ -440,6 +445,16 @@ init_demo (DemoWidget *demo,
demo->stroke = gsk_stroke_new (20);
demo->outline_stroke = gsk_stroke_new (1);
+
+ demo->zoom = 1;
+}
+
+static void
+zoom_changed (GtkRange *range,
+ DemoWidget *self)
+{
+ self->zoom = gtk_range_get_value (range);
+ gtk_widget_queue_resize (GTK_WIDGET (self));
}
static void
@@ -607,6 +622,7 @@ main (int argc, char *argv[])
GtkWidget *popover, *button, *grid;
GtkWidget *header, *toggle, *combo, *spin;
GtkWidget *sw;
+ GtkWidget *zoom_scale;
int row;
gtk_init ();
@@ -627,6 +643,13 @@ main (int argc, char *argv[])
button = gtk_menu_button_new ();
gtk_menu_button_set_icon_name (GTK_MENU_BUTTON (button), "emblem-system-symbolic");
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);
+
+ zoom_scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 1, 20, 0.25);
+ gtk_range_set_value (GTK_RANGE (zoom_scale), 1);
+ g_signal_connect (zoom_scale, "value-changed", G_CALLBACK (zoom_changed), demo);
+ gtk_widget_set_size_request (zoom_scale, 150, -1);
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (header), zoom_scale);
+
gtk_window_set_titlebar (GTK_WINDOW (window), header);
popover = gtk_popover_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]