aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-07-22 18:49:09 +0200
committerDavid Robillard <d@drobilla.net>2019-09-03 08:34:38 +0200
commit816607027012de0205e144f3edd3fdcfd43db563 (patch)
tree6baafc16e21b6186c51d9ada7c97116b6a30811c /test
parentf76954359229c25a6c9d29d6de3e75ab3a25f8dd (diff)
downloadpugl-816607027012de0205e144f3edd3fdcfd43db563.tar.gz
pugl-816607027012de0205e144f3edd3fdcfd43db563.tar.bz2
pugl-816607027012de0205e144f3edd3fdcfd43db563.zip
Add functions to get and set view size and position
Diffstat (limited to 'test')
-rw-r--r--test/pugl_cairo_test.c13
-rw-r--r--test/pugl_test.c4
2 files changed, 11 insertions, 6 deletions
diff --git a/test/pugl_cairo_test.c b/test/pugl_cairo_test.c
index 3ac2054..20a96e7 100644
--- a/test/pugl_cairo_test.c
+++ b/test/pugl_cairo_test.c
@@ -115,8 +115,9 @@ onDisplay(PuglView* view)
cairo_t* cr = (cairo_t*)puglGetContext(view);
// Draw background
- int width, height;
- puglGetSize(view, &width, &height);
+ const PuglRect frame = puglGetFrame(view);
+ const double width = frame.width;
+ const double height = frame.height;
if (entered) {
cairo_set_source_rgb(cr, 0.1, 0.1, 0.1);
} else {
@@ -126,8 +127,8 @@ onDisplay(PuglView* view)
cairo_fill(cr);
// Scale to view size
- const double scaleX = (width - (512 / (double)width)) / 512.0;
- const double scaleY = (height - (512 / (double)height)) / 512.0;
+ const double scaleX = (width - (512 / width)) / 512.0;
+ const double scaleY = (height - (512 / height)) / 512.0;
cairo_scale(cr, scaleX, scaleY);
// Draw button
@@ -206,9 +207,11 @@ main(int argc, char** argv)
world = puglNewWorld();
+ const PuglRect frame = { 0, 0, 512, 512 };
+
PuglView* view = puglNewView(world);
puglInitWindowClass(view, "PuglCairoTest");
- puglInitWindowSize(view, 512, 512);
+ puglSetFrame(view, frame);
puglInitWindowMinSize(view, 256, 256);
puglInitWindowHint(view, PUGL_RESIZABLE, resizable);
puglInitBackend(view, puglCairoBackend());
diff --git a/test/pugl_test.c b/test/pugl_test.c
index d6207fe..ea849a6 100644
--- a/test/pugl_test.c
+++ b/test/pugl_test.c
@@ -181,9 +181,11 @@ main(int argc, char** argv)
app.world = puglNewWorld();
+ const PuglRect frame = { 0, 0, 512, 512 };
+
PuglView* view = puglNewView(app.world);
puglInitWindowClass(view, "PuglTest");
- puglInitWindowSize(view, 512, 512);
+ puglSetFrame(view, frame);
puglInitWindowMinSize(view, 256, 256);
puglInitWindowAspectRatio(view, 1, 1, 16, 9);
puglInitBackend(view, puglGlBackend());