@@ -96,7 +96,8 @@ regionview_get_model(Regionview *regionview)
9696 return model_area ;
9797}
9898
99- /* Type we display for each of the classes. Order is important!
99+ /* Type we display for each of the classes. Order is important! Most derived
100+ * classes first.
100101 */
101102typedef struct {
102103 const char * name ;
@@ -106,7 +107,9 @@ typedef struct {
106107static RegionviewDisplay regionview_display_table [] = {
107108 { CLASS_MARK , REGIONVIEW_MARK },
108109 { CLASS_REGION , REGIONVIEW_REGION },
109- { CLASS_ARROW , REGIONVIEW_ARROW }
110+ { CLASS_HGUIDE , REGIONVIEW_HGUIDE },
111+ { CLASS_VGUIDE , REGIONVIEW_VGUIDE },
112+ { CLASS_ARROW , REGIONVIEW_ARROW },
110113};
111114
112115/* Look at the class we are drawing, set the display type.
@@ -117,7 +120,8 @@ regionview_set_type(Regionview *regionview, PElement *root)
117120 gboolean result ;
118121 int i ;
119122
120- if (heap_is_class (root , & result ) && result )
123+ if (heap_is_class (root , & result ) &&
124+ result )
121125 for (i = 0 ; i < VIPS_NUMBER (regionview_display_table ); i ++ ) {
122126 const char * name = regionview_display_table [i ].name ;
123127
@@ -541,6 +545,31 @@ regionview_draw_arrow(Regionview *regionview, GtkSnapshot *snapshot)
541545 regionview_draw_line (regionview , snapshot , & regionview -> frame );
542546}
543547
548+ static void
549+ regionview_draw_guide (Regionview * regionview , GtkSnapshot * snapshot )
550+ {
551+ Imageui * imageui = regionview -> imageui ;
552+ double zoom = imageui_get_zoom (imageui );
553+
554+ // two points to mark
555+ double left ;
556+ double top ;
557+ imageui_image_to_gtk (imageui ,
558+ regionview -> draw_area .left , regionview -> draw_area .top , & left , & top );
559+ regionview -> frame .left = left ;
560+ regionview -> frame .top = top ;
561+ regionview -> frame .width = regionview -> draw_area .width * zoom ;
562+ regionview -> frame .height = regionview -> draw_area .height * zoom ;
563+
564+ regionview_draw_init_region_label (regionview );
565+
566+ regionview_draw_label_shadow (regionview , snapshot );
567+
568+ regionview_draw_label (regionview , snapshot );
569+
570+ regionview_draw_line (regionview , snapshot , & regionview -> frame );
571+ }
572+
544573// called from imageui for "snapshot" on imagedisplay
545574void
546575regionview_draw (Regionview * regionview , GtkSnapshot * snapshot )
@@ -563,9 +592,15 @@ regionview_draw(Regionview *regionview, GtkSnapshot *snapshot)
563592 regionview_draw_arrow (regionview , snapshot );
564593 break ;
565594
595+ case REGIONVIEW_HGUIDE :
596+ regionview_draw_guide (regionview , snapshot );
597+ break ;
598+
599+ case REGIONVIEW_VGUIDE :
600+ regionview_draw_guide (regionview , snapshot );
601+ break ;
602+
566603 /*
567- REGIONVIEW_HGUIDE, // width == image width, height == 0
568- REGIONVIEW_VGUIDE, // width == 0, height == image height
569604 REGIONVIEW_LINE, // floating dashed line for paintbox
570605 REGIONVIEW_BOX // floating dashed box for paintbox
571606 */
@@ -661,6 +696,14 @@ regionview_hit(Regionview *regionview, int x, int y)
661696
662697 break ;
663698
699+ case REGIONVIEW_HGUIDE :
700+ case REGIONVIEW_VGUIDE :
701+ corner = regionview -> frame ;
702+ vips_rect_marginadjust (& corner , 10 );
703+ if (vips_rect_includespoint (& corner , x , y ))
704+ return REGIONVIEW_RESIZE_MOVE ;
705+ break ;
706+
664707 default :
665708 g_assert_not_reached ();
666709 }
@@ -693,6 +736,8 @@ regionview_hit(Regionview *regionview, int x, int y)
693736
694737 case REGIONVIEW_MARK :
695738 case REGIONVIEW_ARROW :
739+ case REGIONVIEW_HGUIDE :
740+ case REGIONVIEW_VGUIDE :
696741 break ;
697742
698743 default :
@@ -763,6 +808,8 @@ regionview_resize(Regionview *regionview, guint modifiers,
763808 switch (regionview -> type ) {
764809 case REGIONVIEW_REGION :
765810 case REGIONVIEW_MARK :
811+ case REGIONVIEW_HGUIDE :
812+ case REGIONVIEW_VGUIDE :
766813 switch (regionview -> resize ) {
767814 case REGIONVIEW_RESIZE_MOVE :
768815 our_area -> left =
0 commit comments