Skip to content

Commit 0ae042e

Browse files
committed
Improve zoom behaviour
1 parent e56df79 commit 0ae042e

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

  • petalinux_project/project-spec/meta-user/recipes-apps/fractal-explorer/files

petalinux_project/project-spec/meta-user/recipes-apps/fractal-explorer/files/main.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,8 @@ static void redraw_overlay_surface(::window_context* ctx) {
599599
"x: %12.8f, y: %12.8f, scale: %12.8f\n"
600600
"\n"
601601
"fps (fpga / display): %.4f / %.4f",
602-
ctx->app.cr, ctx->app.ci, ctx->app.offset_x, ctx->app.offset_y, ctx->app.scale,
603-
ctx->v4l2_fps, ctx->display_fps);
602+
ctx->app.cr, ctx->app.ci, ctx->app.offset_x, ctx->app.offset_y,
603+
ctx->app.scale * ctx->app.scale, ctx->v4l2_fps, ctx->display_fps);
604604

605605
::cairo_set_font_size(cr, 13);
606606
for (auto [y, p] = std::tuple{0, std::begin(str)}; p < std::end(str) && *p;) {
@@ -752,8 +752,9 @@ static void handle_timer_events(window_context* ctx, std::uint32_t events) {
752752
if (ctx->joystick_fd >= 0) {
753753
const auto& j = ctx->joystick;
754754

755-
if (j.buttons[1] && app.scale_q >= -2.0) app.scale_q -= 0.001;
756-
if (j.buttons[2] && app.scale_q <= 7.25) app.scale_q += 0.001;
755+
const auto scale_step = j.buttons[6] ? 0.01 : 0.001;
756+
if (j.buttons[1] && app.scale_q >= -2.0) app.scale_q -= scale_step;
757+
if (j.buttons[2] && app.scale_q <= 7.25) app.scale_q += scale_step;
757758

758759
if (j.axes[4] > 0) shift_x += 2.0;
759760
if (j.axes[4] < 0) shift_x -= 2.0;

0 commit comments

Comments
 (0)