@@ -102,7 +102,7 @@ typedef struct dt_iop_crop_gui_data_t
102
102
float clip_max_x , clip_max_y , clip_max_w , clip_max_h ;
103
103
dt_hash_t clip_max_pipe_hash ;
104
104
105
- int cropping ;
105
+ _grab_region_t cropping ;
106
106
gboolean shift_hold ;
107
107
gboolean ctrl_hold ;
108
108
gboolean preview_ready ;
@@ -179,7 +179,7 @@ static void _commit_box(dt_iop_module_t *self,
179
179
if (darktable .gui -> reset ) return ;
180
180
if (self -> dev -> preview_pipe -> status != DT_DEV_PIXELPIPE_VALID ) return ;
181
181
182
- g -> cropping = 0 ;
182
+ g -> cropping = GRAB_CENTER ;
183
183
const dt_boundingbox_t old = { p -> cx , p -> cy , p -> cw , p -> ch };
184
184
const float eps = 1e-6f ; // threshold to avoid rounding errors
185
185
if (!self -> enabled )
@@ -952,6 +952,18 @@ static void _event_aspect_presets_changed(GtkWidget *combo, dt_iop_module_t *sel
952
952
-- darktable .gui -> reset ;
953
953
}
954
954
955
+ static void _update_sliders_and_limit (dt_iop_crop_gui_data_t * g )
956
+ {
957
+ dt_bauhaus_slider_set (g -> cx , g -> clip_x );
958
+ dt_bauhaus_slider_set (g -> cy , g -> clip_y );
959
+ dt_bauhaus_slider_set (g -> cw , g -> clip_x + g -> clip_w );
960
+ dt_bauhaus_slider_set (g -> ch , g -> clip_y + g -> clip_h );
961
+ dt_bauhaus_slider_set_soft_max (g -> cx , g -> clip_x + g -> clip_w - 0.1f );
962
+ dt_bauhaus_slider_set_soft_max (g -> cy , g -> clip_y + g -> clip_h - 0.1f );
963
+ dt_bauhaus_slider_set_soft_min (g -> ch , g -> clip_y + 0.1f );
964
+ dt_bauhaus_slider_set_soft_min (g -> cw , g -> clip_x + 0.1f );
965
+ }
966
+
955
967
void gui_changed (dt_iop_module_t * self , GtkWidget * w , void * previous )
956
968
{
957
969
dt_iop_crop_gui_data_t * g = self -> gui_data ;
@@ -983,14 +995,7 @@ void gui_changed(dt_iop_module_t *self, GtkWidget *w, void *previous)
983
995
}
984
996
985
997
// update all sliders, as their values may have change to keep aspect ratio
986
- dt_bauhaus_slider_set (g -> cx , g -> clip_x );
987
- dt_bauhaus_slider_set_soft_min (g -> cw , g -> clip_x + 0.10 );
988
- dt_bauhaus_slider_set (g -> cy , g -> clip_y );
989
- dt_bauhaus_slider_set_soft_min (g -> ch , g -> clip_y + 0.10 );
990
- dt_bauhaus_slider_set (g -> cw , g -> clip_x + g -> clip_w );
991
- dt_bauhaus_slider_set_soft_max (g -> cx , g -> clip_x + g -> clip_w - 0.10 );
992
- dt_bauhaus_slider_set (g -> ch , g -> clip_y + g -> clip_h );
993
- dt_bauhaus_slider_set_soft_max (g -> cy , g -> clip_y + g -> clip_h - 0.10 );
998
+ _update_sliders_and_limit (g );
994
999
995
1000
-- darktable .gui -> reset ;
996
1001
@@ -1058,6 +1063,7 @@ void gui_update(dt_iop_module_t *self)
1058
1063
g -> clip_h = p -> ch - p -> cy ;
1059
1064
1060
1065
dt_gui_update_collapsible_section (& g -> cs );
1066
+ gui_changed (self , NULL , NULL );
1061
1067
}
1062
1068
1063
1069
static void _event_key_swap (dt_iop_module_t * self )
@@ -1454,8 +1460,7 @@ void gui_post_expose(dt_iop_module_t *self,
1454
1460
}
1455
1461
1456
1462
cairo_set_line_width (cr , DT_PIXEL_APPLY_DPI (2.0 ) / zoom_scale );
1457
- const double alpha =
1458
- CLAMP (1.0 - (g_get_monotonic_time () - g -> focus_time ) / 2e6f , 0.0 , 1.0 );
1463
+ const double alpha = CLIP (1.0 - (g_get_monotonic_time () - g -> focus_time ) / 2e6f );
1459
1464
dt_draw_set_color_overlay (cr , TRUE, alpha );
1460
1465
const double border = DT_PIXEL_APPLY_DPI (MIN (30.0 , MIN (wd , ht ) / 3.0 )) / zoom_scale ;
1461
1466
@@ -1640,16 +1645,7 @@ int mouse_moved(dt_iop_module_t *self,
1640
1645
// clipping parameters get set from the sliders when the iop loses
1641
1646
// focus, at which time the final selected crop is applied.
1642
1647
++ darktable .gui -> reset ;
1643
-
1644
- dt_bauhaus_slider_set (g -> cx , g -> clip_x );
1645
- dt_bauhaus_slider_set_soft_min (g -> cw , g -> clip_x + 0.10 );
1646
- dt_bauhaus_slider_set (g -> cy , g -> clip_y );
1647
- dt_bauhaus_slider_set_soft_min (g -> ch , g -> clip_y + 0.10 );
1648
- dt_bauhaus_slider_set (g -> cw , g -> clip_x + g -> clip_w );
1649
- dt_bauhaus_slider_set_soft_max (g -> cx , g -> clip_x + g -> clip_w - 0.10 );
1650
- dt_bauhaus_slider_set (g -> ch , g -> clip_y + g -> clip_h );
1651
- dt_bauhaus_slider_set_soft_max (g -> cy , g -> clip_y + g -> clip_h - 0.10 );
1652
-
1648
+ _update_sliders_and_limit (g );
1653
1649
-- darktable .gui -> reset ;
1654
1650
1655
1651
dt_control_queue_redraw_center ();
0 commit comments