diff options
Diffstat (limited to 'examples/pugl_management_demo.c')
-rw-r--r-- | examples/pugl_management_demo.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/examples/pugl_management_demo.c b/examples/pugl_management_demo.c index 51d2f43..c9b3f4a 100644 --- a/examples/pugl_management_demo.c +++ b/examples/pugl_management_demo.c @@ -1,14 +1,12 @@ // Copyright 2012-2023 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC -/* - A demonstration of window types, states, and management. -*/ +// A demonstration of window types, states, and management -#include "test/test_utils.h" +#include <puglutil/test_utils.h> -#include "pugl/cairo.h" -#include "pugl/pugl.h" +#include <pugl/cairo.h> +#include <pugl/pugl.h> #include <cairo.h> @@ -37,12 +35,13 @@ onMainEvent(PuglView* view, const PuglEvent* event); static PuglStatus onExpose(PuglView* const view, const PuglExposeEvent* const event) { - PuglWorld* const world = puglGetWorld(view); - DemoApp* const app = (DemoApp*)puglGetWorldHandle(world); - const PuglRect frame = puglGetFrame(view); + PuglWorld* const world = puglGetWorld(view); + DemoApp* const app = (DemoApp*)puglGetWorldHandle(world); + const PuglPoint pos = puglGetPositionHint(view, PUGL_CURRENT_POSITION); + const PuglArea size = puglGetSizeHint(view, PUGL_CURRENT_SIZE); const PuglViewStyleFlags style = puglGetViewStyle(view); - const PuglCoord cx = (PuglCoord)(frame.width / 2U); - const PuglCoord cy = (PuglCoord)(frame.height / 2U); + const PuglCoord cx = (PuglCoord)(size.width / 2U); + const PuglCoord cy = (PuglCoord)(size.height / 2U); cairo_t* const cr = (cairo_t*)puglGetContext(view); // Clip to expose region @@ -61,29 +60,31 @@ onExpose(PuglView* const view, const PuglExposeEvent* const event) cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); // Draw position label - snprintf(buf, sizeof(buf), "Position: %5d, %5d", frame.x, frame.y); + snprintf(buf, sizeof(buf), "Position: %5d, %5d", pos.x, pos.y); cairo_text_extents(cr, buf, &extents); cairo_move_to( - cr, cx - extents.width / 2.0, cy + extents.height / 2.0 - 192.0); + cr, cx - (extents.width / 2.0), cy + (extents.height / 2.0) - 192.0); cairo_show_text(cr, buf); // Draw size label - snprintf(buf, sizeof(buf), "Size: %5u, %5u", frame.width, frame.height); + snprintf(buf, sizeof(buf), "Size: %5u, %5u", size.width, size.height); cairo_text_extents(cr, buf, &extents); cairo_move_to( - cr, cx - extents.width / 2.0, cy + extents.height / 2.0 - 144.0); + cr, cx - (extents.width / 2.0), cy + (extents.height / 2.0) - 144.0); cairo_show_text(cr, buf); // Draw scale label snprintf(buf, sizeof(buf), "Scale: %g", puglGetScaleFactor(view)); cairo_text_extents(cr, buf, &extents); - cairo_move_to(cr, cx - extents.width / 2.0, cy + extents.height / 2.0 - 96.0); + cairo_move_to( + cr, cx - (extents.width / 2.0), cy + (extents.height / 2.0) - 96.0); cairo_show_text(cr, buf); // Draw time label snprintf(buf, sizeof(buf), "Draw time: %g", puglGetTime(world)); cairo_text_extents(cr, buf, &extents); - cairo_move_to(cr, cx - extents.width / 2.0, cy + extents.height / 2.0 - 48.0); + cairo_move_to( + cr, cx - (extents.width / 2.0), cy + (extents.height / 2.0) - 48.0); cairo_show_text(cr, buf); // Draw style label @@ -100,7 +101,7 @@ onExpose(PuglView* const view, const PuglExposeEvent* const event) style & PUGL_VIEW_STYLE_DEMANDING ? " demanding" : "", style & PUGL_VIEW_STYLE_RESIZING ? " resizing" : ""); cairo_text_extents(cr, buf, &extents); - cairo_move_to(cr, cx - extents.width / 2.0, cy + extents.height / 2.0); + cairo_move_to(cr, cx - (extents.width / 2.0), cy + (extents.height / 2.0)); cairo_show_text(cr, buf); if (view == app->mainView.view) { @@ -108,7 +109,7 @@ onExpose(PuglView* const view, const PuglExposeEvent* const event) snprintf(buf, sizeof(buf), "Keys: Space T W H M F A B D Q"); cairo_text_extents(cr, buf, &extents); cairo_move_to( - cr, cx - extents.width / 2.0, cy + extents.height / 2.0 + 48.0); + cr, cx - (extents.width / 2.0), cy + (extents.height / 2.0) + 48.0); cairo_show_text(cr, buf); } |