From 08cb5c6b15bf7040ac9ac307b761fdad70cc82dd Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Thu, 21 Jul 2022 18:24:25 -0700 Subject: [PATCH] smyrna btnToolZoomFit_clicked: rephrase unorthodox ternaries This function was using assignments on the right hand sides of ternary expressions. This is technically allowed, but leads to very hard to read code. --- cmd/smyrna/gui/toolboxcallbacks.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/cmd/smyrna/gui/toolboxcallbacks.c b/cmd/smyrna/gui/toolboxcallbacks.c index ff62a3fbc..5fd770bc7 100644 --- a/cmd/smyrna/gui/toolboxcallbacks.c +++ b/cmd/smyrna/gui/toolboxcallbacks.c @@ -28,10 +28,8 @@ void btnToolZoomFit_clicked(GtkWidget * widget, gpointer user_data) (void)widget; (void)user_data; - float z; - (view->active_camera >= 0) - ? (z = view->cameras[view->active_camera]->r) : (z = - view->zoom * -1); + float z = view->active_camera >= 0 ? view->cameras[view->active_camera]->r + : -view->zoom; float GDX = view->bdxRight / z - view->bdxLeft / z; float SDX = view->clipX2 - view->clipX1; @@ -39,21 +37,17 @@ void btnToolZoomFit_clicked(GtkWidget * widget, gpointer user_data) float SDY = view->clipY2 - view->clipY1; if (SDX / GDX <= SDY / GDY) { - (view->active_camera >= 0) ? - (view->cameras[view->active_camera]->r = - view->cameras[view->active_camera]->r / (SDX / - GDX)) : (view->zoom = - view->zoom / - (SDX / - GDX)); + if (view->active_camera >= 0) { + view->cameras[view->active_camera]->r /= SDX / GDX; + } else { + view->zoom /= SDX / GDX; + } } else { - (view->active_camera >= 0) ? - (view->cameras[view->active_camera]->r = - view->cameras[view->active_camera]->r / (SDY / - GDY)) : (view->zoom = - view->zoom / - (SDY / - GDY)); + if (view->active_camera >= 0) { + view->cameras[view->active_camera]->r /= SDY / GDY; + } else { + view->zoom /= SDY / GDY; + } } btnToolFit_clicked(NULL, NULL); -- 2.40.0