[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: pcb.git: branch: master updated (bf22e47db5134b5f70548a98779e36a530387467)
The branch, master has been updated
via bf22e47db5134b5f70548a98779e36a530387467 (commit)
via 6352ae63bc408c6453e5760c523a67d3abd7a9c0 (commit)
from 8d1d20e9ccc256edbaceec81696eb6496f4c0ac5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
=========
Summary
=========
src/hid/gtk/gtkhid-main.c | 16 ++++++++++---
src/hid/gtk/gui-output-events.c | 46 ---------------------------------------
src/hid/gtk/gui.h | 1 -
3 files changed, 12 insertions(+), 51 deletions(-)
=================
Commit Messages
=================
commit bf22e47db5134b5f70548a98779e36a530387467
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
hid/gtk: Introduce a zoom_fit() function, remove duplicated code.
Several places in the code invoke a "zoom_fit" type function by calling
zoom_to() or ghid_port_ranges_zoom() with bogus parameters.
Implement a specific function which restricts this to one location, then
remove the now redundant ghid_port_ranges_zoom(), which basically just
duplicated the code from zoom_by() with an added check for a 0.0 zoom
factor to trigger the zoom-to-fit feature.
:100644 100644 9cab107... a92937f... M src/hid/gtk/gtkhid-main.c
:100644 100644 951a001... bc47214... M src/hid/gtk/gui-output-events.c
:100644 100644 e825b75... 930df19... M src/hid/gtk/gui.h
commit 6352ae63bc408c6453e5760c523a67d3abd7a9c0
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
hid/gtk: Add missing static parameter to zoom_by() function.
:100644 100644 c71e70b... 9cab107... M src/hid/gtk/gtkhid-main.c
=========
Changes
=========
commit bf22e47db5134b5f70548a98779e36a530387467
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
hid/gtk: Introduce a zoom_fit() function, remove duplicated code.
Several places in the code invoke a "zoom_fit" type function by calling
zoom_to() or ghid_port_ranges_zoom() with bogus parameters.
Implement a specific function which restricts this to one location, then
remove the now redundant ghid_port_ranges_zoom(), which basically just
duplicated the code from zoom_by() with an added check for a 0.0 zoom
factor to trigger the zoom-to-fit feature.
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index 9cab107..a92937f 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -31,6 +31,7 @@ RCSID ("$Id$");
static void zoom_to (double factor, int x, int y);
static void zoom_by (double factor, int x, int y);
+static void zoom_fit (void);
int ghid_flip_x = 0, ghid_flip_y = 0;
@@ -64,7 +65,7 @@ ghid_pan_fixup ()
if (gport->view_width > PCB->MaxWidth &&
gport->view_height > PCB->MaxHeight)
{
- zoom_by (1, 0, 0);
+ zoom_fit ();
return;
}
@@ -147,7 +148,7 @@ Zoom (int argc, char **argv, int x, int y)
if (argc < 1)
{
- zoom_to (1000000, 0, 0);
+ zoom_fit ();
return 0;
}
@@ -228,6 +229,13 @@ zoom_by (double factor, int x, int y)
zoom_to (gport->zoom * factor, x, y);
}
+static void
+zoom_fit (void)
+{
+ zoom_to (MAX (PCB->MaxWidth / gport->width,
+ PCB->MaxHeight / gport->height), 0, 0);
+}
+
/* ------------------------------------------------------------ */
void
@@ -1181,7 +1189,7 @@ PCBChanged (int argc, char **argv, int x, int y)
RouteStylesChanged (0, NULL, 0, 0);
ghid_port_ranges_scale (TRUE);
ghid_port_ranges_pan (0, 0, FALSE);
- ghid_port_ranges_zoom (0);
+ zoom_fit ();
ghid_port_ranges_changed ();
ghid_sync_with_new_layout ();
return 0;
diff --git a/src/hid/gtk/gui-output-events.c b/src/hid/gtk/gui-output-events.c
index 951a001..bc47214 100644
--- a/src/hid/gtk/gui-output-events.c
+++ b/src/hid/gtk/gui-output-events.c
@@ -147,52 +147,6 @@ ghid_port_ranges_scale (gboolean emit_changed)
gtk_signal_emit_by_name (GTK_OBJECT (adj), "changed");
}
-void
-ghid_port_ranges_zoom (gdouble zoom)
-{
- gdouble xtmp, ytmp;
- gint x0, y0;
-
- /* figure out zoom values in that would just make the width fit and
- * that would just make the height fit
- */
- xtmp = (gdouble) PCB->MaxWidth / gport->width;
- ytmp = (gdouble) PCB->MaxHeight / gport->height;
-
- /* if we've tried to zoom further out than what would make the
- * entire board fit or we passed 0, then pick a zoom that just makes
- * the board fit.
- */
- if ((zoom > xtmp && zoom > ytmp) || zoom == 0.0)
- zoom = (xtmp > ytmp) ? xtmp : ytmp;
-
- xtmp = (SIDE_X (gport->pcb_x) - gport->view_x0) /
- (gdouble) gport->view_width;
- ytmp = (SIDE_Y (gport->pcb_y) - gport->view_y0) /
- (gdouble) gport->view_height;
-
- gport->zoom = zoom;
- pixel_slop = zoom;
- ghid_port_ranges_scale(FALSE);
-
- x0 = SIDE_X (gport->pcb_x) - xtmp * gport->view_width;
- if (x0 < 0)
- x0 = 0;
- gport->view_x0 = x0;
-
- y0 = SIDE_Y (gport->pcb_y) - ytmp * gport->view_height;
- if (y0 < 0)
- y0 = 0;
- gport->view_y0 = y0;
-
- ghidgui->adjustment_changed_holdoff = TRUE;
- gtk_range_set_value (GTK_RANGE (ghidgui->h_range), gport->view_x0);
- gtk_range_set_value (GTK_RANGE (ghidgui->v_range), gport->view_y0);
- ghidgui->adjustment_changed_holdoff = FALSE;
-
- ghid_port_ranges_changed();
-}
-
/* ----------------------------------------------------------------------
* handles all events from PCB drawing area
diff --git a/src/hid/gtk/gui.h b/src/hid/gtk/gui.h
index e825b75..930df19 100644
--- a/src/hid/gtk/gui.h
+++ b/src/hid/gtk/gui.h
@@ -276,7 +276,6 @@ void ghid_get_pointer (gint *, gint *);
/* gui-output-events.c function prototypes.
*/
void ghid_port_ranges_changed (void);
-void ghid_port_ranges_zoom (gdouble zoom);
gboolean ghid_port_ranges_pan (gdouble x, gdouble y, gboolean relative);
void ghid_port_ranges_scale (gboolean emit_changed);
void ghid_port_ranges_update_ranges (void);
commit 6352ae63bc408c6453e5760c523a67d3abd7a9c0
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
hid/gtk: Add missing static parameter to zoom_by() function.
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index c71e70b..9cab107 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -222,7 +222,7 @@ zoom_to (double new_zoom, int x, int y)
ghid_set_status_line_label ();
}
-void
+static void
zoom_by (double factor, int x, int y)
{
zoom_to (gport->zoom * factor, x, y);
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs