From 330b1fe69481e86484970b80af712f1d189ac374 Mon Sep 17 00:00:00 2001 From: Bernd Jendrissek Date: Wed, 19 Oct 2016 06:03:56 +0200 Subject: [PATCH] Pass PAGE * as parameter. --- gschem/include/prototype.h | 7 +++---- gschem/src/a_pan.c | 16 +++++----------- gschem/src/a_zoom.c | 6 +++--- gschem/src/i_callbacks.c | 20 +++++++++++++++----- gschem/src/o_misc.c | 2 +- gschem/src/x_event.c | 6 +++--- gschem/src/x_preview.c | 2 +- 7 files changed, 31 insertions(+), 28 deletions(-) diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h index fd4bf7d1a..26376ac28 100644 --- a/gschem/include/prototype.h +++ b/gschem/include/prototype.h @@ -5,10 +5,9 @@ struct st_factory *gschem_factory(GSCHEM_TOPLEVEL *w_current); /* gschem_toplevel.c */ GSCHEM_TOPLEVEL *gschem_toplevel_new(); /* a_pan.c */ -void a_pan_general(GSCHEM_TOPLEVEL *w_current, double world_cx, double world_cy, - double zoom_new, enum pan_flags flags); -void a_pan(GSCHEM_TOPLEVEL *w_current, int x, int y); -void a_pan_mouse(GSCHEM_TOPLEVEL *w_current, int diff_x, int diff_y); +void a_pan_general(GSCHEM_TOPLEVEL *w_current, PAGE *page, double world_cx, double world_cy, double zoom_new, enum pan_flags flags); +void a_pan(GSCHEM_TOPLEVEL *w_current, PAGE *page, int x, int y); +void a_pan_mouse(GSCHEM_TOPLEVEL *w_current, PAGE *page, int diff_x, int diff_y); /* a_zoom.c */ void a_zoom(GSCHEM_TOPLEVEL *w_current, PAGE *page, enum zoom_dir dir, enum zoom_from selected_from, enum pan_flags pan); void a_zoom_extents(GSCHEM_TOPLEVEL *w_current, PAGE *page, enum pan_flags pan); diff --git a/gschem/src/a_pan.c b/gschem/src/a_pan.c index 4e25fa70b..925514e2f 100644 --- a/gschem/src/a_pan.c +++ b/gschem/src/a_pan.c @@ -34,11 +34,10 @@ * \par Function Description * */ -void a_pan_general(GSCHEM_TOPLEVEL *w_current, double world_cx, double world_cy, +void a_pan_general(GSCHEM_TOPLEVEL *w_current, PAGE *page, double world_cx, double world_cy, double zoom_new, enum pan_flags flags) { TOPLEVEL *toplevel = w_current->toplevel; - PAGE *page = toplevel->page_current; /*if the borders should be ignored always, remove, outcomment or changes the flags in the function-calls*/ /* flags |= A_PAN_IGNORE_BORDERS; @@ -149,15 +148,12 @@ void a_pan_general(GSCHEM_TOPLEVEL *w_current, double world_cx, double world_cy, * \brief * \par Function Description */ -void a_pan(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y) +void a_pan(GSCHEM_TOPLEVEL *w_current, PAGE *page, int w_x, int w_y) { - TOPLEVEL *toplevel = safe_toplevel(w_current); - PAGE *page = safe_page_current(toplevel); - /* make mouse to the new world-center; attention: there are information looses because of type cast in mil_x */ - a_pan_general(w_current, w_x, w_y, page->to_screen_y_constant, A_PAN_FULL); + a_pan_general(w_current, page, w_x, w_y, page->to_screen_y_constant, A_PAN_FULL); /*! \bug FIXME? This call will trigger a motion event (x_event_motion()), * even if the user doesn't move the mouse @@ -172,10 +168,8 @@ void a_pan(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y) * \par Function Description * */ -void a_pan_mouse(GSCHEM_TOPLEVEL *w_current, int diff_x, int diff_y) +void a_pan_mouse(GSCHEM_TOPLEVEL *w_current, PAGE *page, int diff_x, int diff_y) { - TOPLEVEL *toplevel = w_current->toplevel; - PAGE *page = toplevel->page_current; double world_cx, world_cy; double page_cx, page_cy; @@ -194,6 +188,6 @@ void a_pan_mouse(GSCHEM_TOPLEVEL *w_current, int diff_x, int diff_y) world_cx, world_cy, diff_x, diff_y); } - a_pan_general(w_current, world_cx, world_cy, page->to_screen_y_constant, + a_pan_general(w_current, page, world_cx, world_cy, page->to_screen_y_constant, A_PAN_FULL); } diff --git a/gschem/src/a_zoom.c b/gschem/src/a_zoom.c index c52c1fcc4..e8ae40f07 100644 --- a/gschem/src/a_zoom.c +++ b/gschem/src/a_zoom.c @@ -80,7 +80,7 @@ void a_zoom(GSCHEM_TOPLEVEL *w_current, PAGE *page, enum zoom_dir dir, enum zoom } /* calculate new window and draw it */ - a_pan_general(w_current, world_pan_center_x, world_pan_center_y, + a_pan_general(w_current, page, world_pan_center_x, world_pan_center_y, relativ_zoom_factor * page->to_screen_y_constant, pan); /* Before warping the cursor, filter out any consecutive scroll events @@ -152,7 +152,7 @@ void a_zoom_extents(GSCHEM_TOPLEVEL *w_current, PAGE *page, enum pan_flags pan) world_pan_center_y = (double) (lbottom + ltop) /2.0; /* and create the new window*/ - a_pan_general(w_current, world_pan_center_x, world_pan_center_y, + a_pan_general(w_current, page, world_pan_center_x, world_pan_center_y, zoom_new, pan); /*! \bug FIXME? trigger a x_event_motion() call without moving the cursor @@ -193,7 +193,7 @@ void a_zoom_box(GSCHEM_TOPLEVEL *w_current, PAGE *page, enum pan_flags pan) world_pan_center_y = (w_current->first_wy + w_current->second_wy) / 2.0; /* and create the new window*/ - a_pan_general(w_current, world_pan_center_x, world_pan_center_y, + a_pan_general(w_current, page, world_pan_center_x, world_pan_center_y, relativ_zoom_factor * page->to_screen_y_constant, pan); } diff --git a/gschem/src/i_callbacks.c b/gschem/src/i_callbacks.c index 13d61e5d6..30da85768 100644 --- a/gschem/src/i_callbacks.c +++ b/gschem/src/i_callbacks.c @@ -1570,10 +1570,12 @@ DEFINE_I_CALLBACK(view_pan) DEFINE_I_CALLBACK(view_pan_left) { GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data; + TOPLEVEL *toplevel = safe_toplevel(w_current); + PAGE *page = safe_page_current(toplevel); exit_if_null(w_current); - a_pan_mouse(w_current, w_current->keyboardpan_gain, 0); + a_pan_mouse(w_current, page, w_current->keyboardpan_gain, 0); } /*! \brief Scheme callback function that moves the viewport to the right. @@ -1583,11 +1585,13 @@ DEFINE_I_CALLBACK(view_pan_left) DEFINE_I_CALLBACK(view_pan_right) { GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data; + TOPLEVEL *toplevel = safe_toplevel(w_current); + PAGE *page = safe_page_current(toplevel); exit_if_null(w_current); /* yes, that's a negative sign there */ - a_pan_mouse(w_current, -w_current->keyboardpan_gain, 0); + a_pan_mouse(w_current, page, -w_current->keyboardpan_gain, 0); } /*! \brief Scheme callback function that moves the viewport up. @@ -1597,10 +1601,12 @@ DEFINE_I_CALLBACK(view_pan_right) DEFINE_I_CALLBACK(view_pan_up) { GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data; + TOPLEVEL *toplevel = safe_toplevel(w_current); + PAGE *page = safe_page_current(toplevel); exit_if_null(w_current); - a_pan_mouse(w_current, 0, w_current->keyboardpan_gain); + a_pan_mouse(w_current, page, 0, w_current->keyboardpan_gain); } /*! \brief Scheme callback function that moves the viewport down. @@ -1610,11 +1616,13 @@ DEFINE_I_CALLBACK(view_pan_up) DEFINE_I_CALLBACK(view_pan_down) { GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data; + TOPLEVEL *toplevel = safe_toplevel(w_current); + PAGE *page = safe_page_current(toplevel); exit_if_null(w_current); /* yes, that's a negative sign there */ - a_pan_mouse(w_current, 0, -w_current->keyboardpan_gain); + a_pan_mouse(w_current, page, 0, -w_current->keyboardpan_gain); } /*! \todo Finish function documentation!!! @@ -1625,6 +1633,8 @@ DEFINE_I_CALLBACK(view_pan_down) DEFINE_I_CALLBACK(view_pan_hotkey) { GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data; + TOPLEVEL *toplevel = safe_toplevel(w_current); + PAGE *page = safe_page_current(toplevel); gint wx, wy; exit_if_null(w_current); @@ -1634,7 +1644,7 @@ DEFINE_I_CALLBACK(view_pan_hotkey) i_update_middle_button(w_current, i_callback_view_pan_hotkey, _("Pan")); - a_pan(w_current, wx, wy); + a_pan(w_current, page, wx, wy); if (w_current->undo_panzoom) { o_undo_savestate(w_current, UNDO_VIEWPORT_ONLY); diff --git a/gschem/src/o_misc.c b/gschem/src/o_misc.c index 162078d7a..6630ce991 100644 --- a/gschem/src/o_misc.c +++ b/gschem/src/o_misc.c @@ -641,7 +641,7 @@ int o_edit_find_text(GSCHEM_TOPLEVEL *w_current, OBJECT * o_list, char *stext, text_screen_height = SCREENabs(page, o_text_height(str, o_current->text->size)); } - a_pan_general(w_current, + a_pan_general(w_current, page, o_current->text->x, o_current->text->y, page->to_screen_y_constant, A_PAN_FULL); diff --git a/gschem/src/x_event.c b/gschem/src/x_event.c index 6f7234493..9cd2fe816 100644 --- a/gschem/src/x_event.c +++ b/gschem/src/x_event.c @@ -361,7 +361,7 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event, case(STARTPAN): - a_pan(w_current, w_x, w_y); + a_pan(w_current, page, w_x, w_y); i_set_state(w_current, SELECT); i_update_toolbar(w_current); break; @@ -817,7 +817,7 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event, pdiff_y = (int) event->y - start_pan_y; if (!(throttle % 5)) { - a_pan_mouse(w_current, pdiff_x*w_current->mousepan_gain, + a_pan_mouse(w_current, page, pdiff_x*w_current->mousepan_gain, pdiff_y*w_current->mousepan_gain); start_pan_x = (int) event->x; @@ -1063,7 +1063,7 @@ x_event_configure (GtkWidget *widget, cy = ((gdouble)(p_current->top + p_current->bottom)) / 2; s_toplevel_goto_page(toplevel, p_current); zoom_new = relativ_zoom_factor * p_current->to_screen_y_constant; - a_pan_general(w_current, cx, cy, zoom_new, A_PAN_DONT_REDRAW); + a_pan_general(w_current, p_current, cx, cy, zoom_new, A_PAN_DONT_REDRAW); } /* restore current page to saved value */ s_toplevel_goto_page(toplevel, old_page_current); diff --git a/gschem/src/x_preview.c b/gschem/src/x_preview.c index 8d33e73e6..33bd874b3 100644 --- a/gschem/src/x_preview.c +++ b/gschem/src/x_preview.c @@ -173,7 +173,7 @@ preview_callback_button_press (GtkWidget *widget, case 2: /* middle mouse button: pan */ if (!x_event_get_pointer_position(preview_w_current, FALSE, &wx, &wy)) return FALSE; - a_pan (preview_w_current, wx, wy); + a_pan(preview_w_current, page, wx, wy); break; case 3: /* right mouse button: zoom out */ a_zoom(preview_w_current, page, ZOOM_OUT, HOTKEY, A_PAN_DONT_REDRAW); -- 2.11.4.GIT