From: Matthew Fernandez Date: Sat, 15 Jan 2022 23:58:15 +0000 (-0800) Subject: API BREAK: use a C99 bool for other 'GVJ_t' boolean fields X-Git-Tag: 3.0.0~64^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0631d2eb3a1b57d82fc1c95b4474f5031cd5dad6;p=graphviz API BREAK: use a C99 bool for other 'GVJ_t' boolean fields --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 58d9dfdd1..85f329813 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/lib/gvc/gvcjob.h b/lib/gvc/gvcjob.h index 5bfd6f651..7db10ed21 100644 --- a/lib/gvc/gvcjob.h +++ b/lib/gvc/gvcjob.h @@ -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, diff --git a/lib/gvc/gvevent.c b/lib/gvc/gvevent.c index d1c6d07b5..4c8df09dc 100644 --- a/lib/gvc/gvevent.c +++ b/lib/gvc/gvevent.c @@ -11,6 +11,7 @@ #include "config.h" #include +#include #include #include @@ -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) diff --git a/plugin.demo/xgtk/src/callbacks.c b/plugin.demo/xgtk/src/callbacks.c index 06435185b..d3ee9f2ee 100644 --- a/plugin.demo/xgtk/src/callbacks.c +++ b/plugin.demo/xgtk/src/callbacks.c @@ -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; } diff --git a/plugin/glitz/gvdevice_glitz.c b/plugin/glitz/gvdevice_glitz.c index 09b6b3c08..0de8db49f 100644 --- a/plugin/glitz/gvdevice_glitz.c +++ b/plugin/glitz/gvdevice_glitz.c @@ -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), diff --git a/plugin/gtk/callbacks.c b/plugin/gtk/callbacks.c index 53d4f7d39..08cf5c082 100644 --- a/plugin/gtk/callbacks.c +++ b/plugin/gtk/callbacks.c @@ -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; } diff --git a/plugin/xlib/gvdevice_xlib.c b/plugin/xlib/gvdevice_xlib.c index 78cc13528..8d8b19813 100644 --- a/plugin/xlib/gvdevice_xlib.c +++ b/plugin/xlib/gvdevice_xlib.c @@ -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),