Skip to content

Commit 5752362

Browse files
committed
region resize snaps as well
1 parent e7c4b06 commit 5752362

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

TODO

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
- add snap for region resize and arrow end move
2-
3-
- during region move or resze, the cursor changes back to a pointer
4-
51
- row range select breaks after "duplicate"
62

73
shift and ctrl click stop affecting select

src/imageui.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,6 @@ typedef struct {
504504
static void *
505505
imageui_snap_sub(Regionview *regionview, ImageuiSnap *snap, gboolean *snapped)
506506
{
507-
Imageui *imageui = snap->imageui;
508-
509507
/* Only static h/v guides.
510508
*/
511509
if (regionview->type != REGIONVIEW_HGUIDE &&

src/regionview.c

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,11 +767,11 @@ regionview_resize(Regionview *regionview, guint modifiers,
767767
VipsRect *our_area = &regionview->our_area;
768768
VipsRect *start_area = &regionview->start_area;
769769

770+
// move dependent edges
770771
switch (regionview->resize) {
771772
case REGIONVIEW_RESIZE_MOVE:
772773
our_area->left = x + start_area->left;
773774
our_area->top = y + start_area->top;
774-
imageui_snap_rect(imageui, our_area, our_area);
775775
break;
776776

777777
case REGIONVIEW_RESIZE_TOPLEFT:
@@ -814,9 +814,56 @@ regionview_resize(Regionview *regionview, guint modifiers,
814814
break;
815815
}
816816

817+
// apply any snapping
818+
int right;
819+
int bottom;
820+
switch (regionview->resize) {
821+
case REGIONVIEW_RESIZE_MOVE:
822+
imageui_snap_rect(imageui, our_area, our_area);
823+
break;
824+
825+
case REGIONVIEW_RESIZE_LEFT:
826+
case REGIONVIEW_RESIZE_TOPLEFT:
827+
case REGIONVIEW_RESIZE_TOP:
828+
imageui_snap_point(imageui,
829+
our_area->left, our_area->top, &our_area->left, &our_area->top);
830+
break;
831+
832+
case REGIONVIEW_RESIZE_RIGHT:
833+
case REGIONVIEW_RESIZE_BOTTOMRIGHT:
834+
case REGIONVIEW_RESIZE_BOTTOM:
835+
right = VIPS_RECT_RIGHT(our_area);
836+
bottom = VIPS_RECT_BOTTOM(our_area);
837+
imageui_snap_point(imageui,
838+
right, bottom, &right, &bottom);
839+
our_area->width = right - our_area->left;
840+
our_area->height = bottom - our_area->top;
841+
break;
842+
843+
case REGIONVIEW_RESIZE_TOPRIGHT:
844+
right = VIPS_RECT_RIGHT(our_area);
845+
imageui_snap_point(imageui,
846+
right, our_area->top, &right, &our_area->top);
847+
our_area->width = right - our_area->left;
848+
break;
849+
850+
case REGIONVIEW_RESIZE_BOTTOMLEFT:
851+
bottom = VIPS_RECT_BOTTOM(our_area);
852+
imageui_snap_point(imageui,
853+
our_area->left, bottom, &our_area->left, &bottom);
854+
our_area->height = bottom - our_area->top;
855+
856+
break;
857+
858+
default:
859+
break;
860+
}
861+
862+
817863
if (!regionview->frozen)
818864
regionview_pick_type(regionview);
819865

866+
// constrain
820867
switch (regionview->type) {
821868
case REGIONVIEW_REGION:
822869
case REGIONVIEW_MARK:
@@ -897,7 +944,6 @@ regionview_resize(Regionview *regionview, guint modifiers,
897944
default:
898945
break;
899946
}
900-
901947
}
902948

903949
static void

0 commit comments

Comments
 (0)