summaryrefslogtreecommitdiff
path: root/meme/gui.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2014-09-13 17:07:26 (GMT)
committerWerner Almesberger <werner@almesberger.net>2014-09-13 17:07:26 (GMT)
commit492744de8451ba08aab4da19b1bb1fd2d040afa2 (patch)
tree6e9ce02f256f9c7a53c27a271e99545d88ad2feb /meme/gui.c
parent8c78d2c26c365014a58cafd17acd9242a35311db (diff)
downloadmisc-492744de8451ba08aab4da19b1bb1fd2d040afa2.zip
misc-492744de8451ba08aab4da19b1bb1fd2d040afa2.tar.gz
misc-492744de8451ba08aab4da19b1bb1fd2d040afa2.tar.bz2
meme/gui.c: auto-scale (maximize zoom to 90% of window width/height) at start
Diffstat (limited to 'meme/gui.c')
-rw-r--r--meme/gui.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/meme/gui.c b/meme/gui.c
index ed03133..63fdefd 100644
--- a/meme/gui.c
+++ b/meme/gui.c
@@ -545,6 +545,19 @@ static void set_marker(const struct vertex *v)
}
+/* ----- Scaling ----------------------------------------------------------- */
+
+
+static void auto_scale(void)
+{
+ x_orig = (x_min+x_max) >> 1;
+ y_orig = (y_min+y_max) >> 1;
+
+ for (zoom = 0; (x_max-x_min) >> zoom > xres*0.9 ||
+ (y_max-y_min) >> zoom > yres*0.9; zoom++);
+}
+
+
/* ----- Event handling ---------------------------------------------------- */
@@ -831,9 +844,7 @@ void gui(void)
yres = surf->h;
extrema();
- x_orig = (x_min+x_max) >> 1;
- y_orig = (y_min+y_max) >> 1;
- zoom = 7;
+ auto_scale();
while (1) {
struct time t;