]> granicus.if.org Git - graphviz/commitdiff
API BREAK: use a C99 bool for other 'GVJ_t' boolean fields
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 15 Jan 2022 23:58:15 +0000 (15:58 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 16 Jan 2022 17:46:33 +0000 (09:46 -0800)
CHANGELOG.md
lib/gvc/gvcjob.h
lib/gvc/gvevent.c
plugin.demo/xgtk/src/callbacks.c
plugin/glitz/gvdevice_glitz.c
plugin/gtk/callbacks.c
plugin/xlib/gvdevice_xlib.c

index 58d9dfdd161bc24f96dd4102d7abf24f6805e8a0..85f32981320a223b067ba4f524fcea3e1711b006 100644 (file)
@@ -37,7 +37,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
   C99 `bool` instead of a Graphviz-specific `boolean`.
 - **Breaking**: The `must_inline` and `nocache` fields of the `usershape_t`
   struct are now C99 `bool`s instead of Graphviz-specific `boolean`s.
-- **Breaking**: The `device_sets_dpi` and `external_context` fields of the
+- **Breaking**: The `device_sets_dpi`, `external_context`, `fit_mode`,
+  `needs_refresh`, `click`, `has_grown`, and `has_been_rendered` fields of the
   `GVJ_t` struct are now C99 `bool`s instead of Graphviz-specific `boolean`s.
 - **Breaking**: 1-bit fields of the `obj_state_s` struct are now unsigned
   instead of signed.
index 5bfd6f651d789757b15a4db3604725688b33c6fc..7db10ed21bf3e32f7009d2ea58bffb2821cfa300 100644 (file)
@@ -339,7 +339,7 @@ extern "C" {
        pointf  translation;    /* composite translation */
        pointf  devscale;       /* composite device to points: dpi, y_goes_down */
 
-       boolean fit_mode,
+       bool    fit_mode,
                needs_refresh,
                click,
                has_grown,
index d1c6d07b5db18ebcaa54c50174da53665c0b9db4..4c8df09dcb18e34285c7476dd5bfe73b84cf51c0 100644 (file)
@@ -11,6 +11,7 @@
 #include "config.h"
 
 #include <string.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <math.h>
 
@@ -170,7 +171,7 @@ static void gvevent_refresh(GVJ_t * job)
        gv_graph_state(job, g);
     }
     emit_graph(job, g);
-    job->has_been_rendered = TRUE;
+    job->has_been_rendered = true;
 }
 
 /* recursively find innermost cluster containing the point */
@@ -314,7 +315,7 @@ static void gvevent_find_current_obj(GVJ_t * job, pointf pointer)
        gvevent_leave_obj(job);
        job->current_obj = obj;
        gvevent_enter_obj(job);
-       job->needs_refresh = 1;
+       job->needs_refresh = true;
     }
 }
 
@@ -368,25 +369,25 @@ static void gvevent_button_press(GVJ_t * job, int button, pointf pointer)
     case 1: /* select / create in edit mode */
        gvevent_find_current_obj(job, pointer);
        gvevent_select_current_obj(job);
-        job->click = 1;
+        job->click = true;
        job->button = button;
-       job->needs_refresh = 1;
+       job->needs_refresh = true;
        break;
     case 2: /* pan */
-        job->click = 1;
+        job->click = true;
        job->button = button;
-       job->needs_refresh = 1;
+       job->needs_refresh = true;
        break;
     case 3: /* insert node or edge */
        gvevent_find_current_obj(job, pointer);
-        job->click = 1;
+        job->click = true;
        job->button = button;
-       job->needs_refresh = 1;
+       job->needs_refresh = true;
        break;
     case 4:
         /* scrollwheel zoom in at current mouse x,y */
 /* FIXME - should code window 0,0 point as feature with Y_GOES_DOWN */
-        job->fit_mode = 0;
+        job->fit_mode = false;
         if (job->rotation) {
             job->focus.x -= (pointer.y - job->height / 2.)
                     * (ZOOMFACTOR - 1.) / (job->zoom * job->devscale.y);
@@ -400,10 +401,10 @@ static void gvevent_button_press(GVJ_t * job, int button, pointf pointer)
                     * (ZOOMFACTOR - 1.) / (job->zoom * job->devscale.y);
         }
         job->zoom *= ZOOMFACTOR;
-        job->needs_refresh = 1;
+        job->needs_refresh = true;
         break;
     case 5: /* scrollwheel zoom out at current mouse x,y */
-        job->fit_mode = 0;
+        job->fit_mode = false;
         job->zoom /= ZOOMFACTOR;
         if (job->rotation) {
             job->focus.x += (pointer.y - job->height / 2.)
@@ -417,7 +418,7 @@ static void gvevent_button_press(GVJ_t * job, int button, pointf pointer)
             job->focus.y -= (pointer.y - job->height / 2.)
                     * (ZOOMFACTOR - 1.) / (job->zoom * job->devscale.y);
         }
-        job->needs_refresh = 1;
+        job->needs_refresh = true;
         break;
     }
     job->oldpointer = pointer;
@@ -425,8 +426,8 @@ static void gvevent_button_press(GVJ_t * job, int button, pointf pointer)
 
 static void gvevent_button_release(GVJ_t *job, int button, pointf pointer)
 {
-    job->click = 0;
-    job->button = 0;
+    job->click = false;
+    job->button = false;
 }
 
 static void gvevent_motion(GVJ_t * job, pointf pointer)
@@ -454,7 +455,7 @@ static void gvevent_motion(GVJ_t * job, pointf pointer)
            job->focus.x -= dx / job->zoom;
            job->focus.y -= dy / job->zoom;
        }
-       job->needs_refresh = 1;
+       job->needs_refresh = true;
        break;
     case 3: /* drag with button 3 - drag inserted node or uncompleted edge */
        break;
@@ -469,49 +470,49 @@ static int quit_cb(GVJ_t * job)
 
 static int left_cb(GVJ_t * job)
 {
-    job->fit_mode = 0;
+    job->fit_mode = false;
     job->focus.x += PANFACTOR / job->zoom;
-    job->needs_refresh = 1;
+    job->needs_refresh = true;
     return 0;
 }
 
 static int right_cb(GVJ_t * job)
 {
-    job->fit_mode = 0;
+    job->fit_mode = false;
     job->focus.x -= PANFACTOR / job->zoom;
-    job->needs_refresh = 1;
+    job->needs_refresh = true;
     return 0;
 }
 
 static int up_cb(GVJ_t * job)
 {
-    job->fit_mode = 0;
+    job->fit_mode = false;
     job->focus.y += -(PANFACTOR / job->zoom);
-    job->needs_refresh = 1;
+    job->needs_refresh = true;
     return 0;
 }
 
 static int down_cb(GVJ_t * job)
 {
-    job->fit_mode = 0;
+    job->fit_mode = false;
     job->focus.y -= -(PANFACTOR / job->zoom);
-    job->needs_refresh = 1;
+    job->needs_refresh = true;
     return 0;
 }
 
 static int zoom_in_cb(GVJ_t * job)
 {
-    job->fit_mode = 0;
+    job->fit_mode = false;
     job->zoom *= ZOOMFACTOR;
-    job->needs_refresh = 1;
+    job->needs_refresh = true;
     return 0;
 }
 
 static int zoom_out_cb(GVJ_t * job)
 {
-    job->fit_mode = 0;
+    job->fit_mode = false;
     job->zoom /= ZOOMFACTOR;
-    job->needs_refresh = 1;
+    job->needs_refresh = true;
     return 0;
 }
 
@@ -534,7 +535,7 @@ static int toggle_fit_cb(GVJ_t * job)
                (double) job->height / (double) dflt_height);
        job->focus.x = 0.0;
        job->focus.y = 0.0;
-       job->needs_refresh = 1;
+       job->needs_refresh = true;
     }
     return 0;
 }
@@ -588,7 +589,7 @@ static void gvevent_read (GVJ_t * job, const char *filename, const char *layout)
        return;   /* FIXME - need some error handling */
     job->selected_obj = NULL;
     job->current_obj = NULL;
-    job->needs_refresh = 1;
+    job->needs_refresh = true;
 }
 
 static void gvevent_layout (GVJ_t * job, const char *layout)
index 06435185b998f3a53126b416750c27c8cb492e0f..d3ee9f2eedae42a8bab5f396ce384f5757a95b52 100644 (file)
@@ -328,10 +328,10 @@ on_drawingarea1_configure_event        (GtkWidget       *widget,
        job->zoom *= zoom_to_fit;
     }
     if (event->width > job->width || event->height > job->height)
-       job->has_grown = TRUE;
+       job->has_grown = true;
     job->width = event->width;
     job->height = event->height;
-    job->needs_refresh = TRUE;
+    job->needs_refresh = true;
 
     return FALSE;
 }
index 09b6b3c083a1cb6a19d039e339250050bbcd9f8f..0de8db49fe97cddf7e0eab7087f85d6b6bd6780a 100644 (file)
@@ -80,10 +80,10 @@ static void handle_configure_notify(GVJ_t * job, XConfigureEvent * cev)
         job->zoom = MIN((double) cev->width / (double) job->width,
                        (double) cev->height / (double) job->height);
     if (cev->width > job->width || cev->height > job->height)
-        job->has_grown = 1;
+        job->has_grown = true;
     job->width = cev->width;
     job->height = cev->height;
-    job->needs_refresh = 1;
+    job->needs_refresh = true;
 }
 
 static void handle_expose(GVJ_t * job, XExposeEvent * eev)
@@ -244,8 +244,8 @@ static void update_display(GVJ_t *job, Display *dpy)
        XFreePixmap(dpy, window->pix);
        window->pix = XCreatePixmap(dpy, window->win,
                        job->width, job->height, window->depth);
-       job->has_grown = 0;
-       job->needs_refresh = 1;
+       job->has_grown = false;
+       job->needs_refresh = true;
     }
     if (job->needs_refresh) {
        XFillRectangle(dpy, window->pix, window->gc, 0, 0,
@@ -259,7 +259,7 @@ static void update_display(GVJ_t *job, Display *dpy)
        cairo_surface_destroy(surface);
        XCopyArea(dpy, window->pix, window->win, window->gc,
                        0, 0, job->width, job->height, 0, 0);
-        job->needs_refresh = 0;
+        job->needs_refresh = false;
     }
 }
 
@@ -282,8 +282,8 @@ static void init_window(GVJ_t *job, Display *dpy, int scr)
        return;
     }
     job->window = (void *)window;
-    job->fit_mode = 0;
-    job->needs_refresh = 1;
+    job->fit_mode = false;
+    job->needs_refresh = true;
 
     if (argb && (window->visual = find_argb_visual(dpy, scr))) {
         window->cmap = XCreateColormap(dpy, RootWindow(dpy, scr),
index 53d4f7d39a14033d9d68d1e75051b5cf806dab13..08cf5c0822715e8568b709ae5fa743d907f17653 100644 (file)
@@ -329,10 +329,10 @@ on_drawingarea1_configure_event        (GtkWidget       *widget,
        job->zoom *= zoom_to_fit;
     }
     if (event->width > job->width || event->height > job->height)
-       job->has_grown = TRUE;
+       job->has_grown = true;
     job->width = event->width;
     job->height = event->height;
-    job->needs_refresh = TRUE;
+    job->needs_refresh = true;
 
     return FALSE;
 }
index 78cc13528c018b24ab1d15c0cf18c3a794cedeca..8d8b198131b0b345606217787c7955ec89f7e3b0 100644 (file)
@@ -67,10 +67,10 @@ static void handle_configure_notify(GVJ_t * job, XConfigureEvent * cev)
        ((double) cev->width - (double) job->width) / (double) job->width,
        ((double) cev->height - (double) job->height) / (double) job->height);
     if (cev->width > job->width || cev->height > job->height)
-        job->has_grown = 1;
+        job->has_grown = true;
     job->width = cev->width;
     job->height = cev->height;
-    job->needs_refresh = 1;
+    job->needs_refresh = true;
 }
 
 static void handle_expose(GVJ_t * job, XExposeEvent * eev)
@@ -232,8 +232,8 @@ static void update_display(GVJ_t *job, Display *dpy)
        XFreePixmap(dpy, window->pix);
        window->pix = XCreatePixmap(dpy, window->win,
                        job->width, job->height, window->depth);
-       job->has_grown = 0;
-       job->needs_refresh = 1;
+       job->has_grown = false;
+       job->needs_refresh = true;
     }
     if (job->needs_refresh) {
        XFillRectangle(dpy, window->pix, window->gc, 0, 0,
@@ -247,7 +247,7 @@ static void update_display(GVJ_t *job, Display *dpy)
        cairo_surface_destroy(surface);
        XCopyArea(dpy, window->pix, window->win, window->gc,
                        0, 0, job->width, job->height, 0, 0);
-        job->needs_refresh = 0;
+        job->needs_refresh = false;
     }
 }
 
@@ -284,8 +284,8 @@ static void init_window(GVJ_t *job, Display *dpy, int scr)
     job->height = h;
 
     job->window = window;
-    job->fit_mode = 0;
-    job->needs_refresh = 1;
+    job->fit_mode = false;
+    job->needs_refresh = true;
 
     if (argb && (window->visual = find_argb_visual(dpy, scr))) {
         window->cmap = XCreateColormap(dpy, RootWindow(dpy, scr),