Mandelbrot: allow zooming in any direction

Fixes #8679.
This commit is contained in:
Adrien Destugues
2014-11-07 17:33:50 +01:00
parent 3b218d2d82
commit 27fc6a70c6
+10 -8
View File
@@ -12,6 +12,7 @@
#include <Debug.h> #include <Debug.h>
#include <Window.h> #include <Window.h>
#include <algorithm>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#include <OS.h> #include <OS.h>
@@ -517,7 +518,6 @@ char TShowBit::has_selection()
return 1; return 1;
} }
/*------------------------------------------------------------*/
void TShowBit::change_selection(long h, long v) void TShowBit::change_selection(long h, long v)
{ {
@@ -544,18 +544,20 @@ void TShowBit::change_selection(long h, long v)
v0 = (long) where.y; v0 = (long) where.y;
width = h0 - h; width = h0 - h;
height = v0 - v; height = v0 - v;
max= ((v0>v) ^ (height < width)) ? height : width;
h0 = h+max; v0 = v+max; max = std::max(std::abs(height), std::abs(width));
v0 = (v0 > v) ? (v + max) : (v - max);
h0 = (h0 > h) ? (h + max) : (h - max);
clip(&h0, &v0); clip(&h0, &v0);
new_select.right = h0; new_select.right = h0;
new_select.bottom = v0; new_select.bottom = v0;
if ((old_select.top != new_select.top) || if ((old_select.top != new_select.top)
(old_select.bottom != new_select.bottom) || || (old_select.bottom != new_select.bottom)
(old_select.right != new_select.right) || || (old_select.right != new_select.right)
(old_select.left != new_select.left)) { || (old_select.left != new_select.left)) {
tmp_rect = sort_rect(&new_select); tmp_rect = sort_rect(&new_select);
StrokeRect(tmp_rect); StrokeRect(tmp_rect);
@@ -568,7 +570,7 @@ void TShowBit::change_selection(long h, long v)
} }
snooze(20000); snooze(20000);
} while(buttons); } while (buttons);
selection = sort_rect(&new_select); selection = sort_rect(&new_select);
if (!has_selection()) { if (!has_selection()) {