@@ -53,15 +53,14 @@ DT_MODULE_INTROSPECTION(5, dt_iop_temperature_params_t)
5353#define DT_IOP_LOWEST_TINT 0.135
5454#define DT_IOP_HIGHEST_TINT 2.326
5555
56- #define DT_IOP_NUM_OF_STD_TEMP_PRESETS 5
56+ #define DT_IOP_NUM_OF_STD_TEMP_PRESETS 4
5757
5858// If you reorder presets combo, change this consts
5959#define DT_IOP_TEMP_UNKNOWN -1
6060#define DT_IOP_TEMP_AS_SHOT 0
6161#define DT_IOP_TEMP_SPOT 1
6262#define DT_IOP_TEMP_USER 2
6363#define DT_IOP_TEMP_D65 3
64- #define DT_IOP_TEMP_D65_LATE 4
6564
6665static void _gui_sliders_update (dt_iop_module_t * self );
6766
@@ -85,9 +84,7 @@ typedef struct dt_iop_temperature_gui_data_t
8584 GtkWidget * btn_asshot ; //As Shot
8685 GtkWidget * btn_user ;
8786 GtkWidget * btn_d65 ;
88- GtkWidget * btn_d65_late ;
8987 GtkWidget * temp_label ;
90- GtkWidget * balance_label ;
9188 GtkWidget * check_late_correction ;
9289 int preset_cnt ;
9390 int preset_num [54 ];
@@ -194,11 +191,21 @@ int legacy_params(dt_iop_module_t *self,
194191 }
195192 if (old_version == 4 )
196193 {
194+ const int legacy_d65_late = 4 ;
197195 const dt_iop_temperature_params_v4_t * o = (dt_iop_temperature_params_v4_t * )old_params ;
198196 dt_iop_temperature_params_v5_t * n = malloc (sizeof (dt_iop_temperature_params_v5_t ));
199197
200198 memcpy (n , o , sizeof (dt_iop_temperature_params_v4_t ));
201- n -> late_correction = FALSE;
199+ if (o -> preset == legacy_d65_late )
200+ {
201+ n -> preset = DT_IOP_TEMP_AS_SHOT ;
202+ n -> late_correction = TRUE;
203+ }
204+ else
205+ {
206+ n -> preset = o -> preset > legacy_d65_late ? o -> preset - 1 : o -> preset ;
207+ n -> late_correction = FALSE;
208+ }
202209 * new_params = n ;
203210 * new_params_size = sizeof (dt_iop_temperature_params_v5_t );
204211 * new_version = 5 ;
@@ -742,30 +749,21 @@ void commit_params(dt_iop_module_t *self,
742749
743750 d -> preset = p -> preset ;
744751
745- gboolean effective_late_correction = FALSE;
746-
747- if (p -> preset == DT_IOP_TEMP_D65_LATE )
748- effective_late_correction = TRUE;
749- else if (p -> preset == DT_IOP_TEMP_D65 )
750- effective_late_correction = FALSE;
751- else
752- effective_late_correction = p -> late_correction ;
752+ const gboolean effective_late_correction =
753+ p -> preset == DT_IOP_TEMP_D65 ? FALSE : p -> late_correction ;
753754
754755 d -> late_correction = effective_late_correction ;
755- chr -> late_correction = effective_late_correction ;
756+ // When the WB module is disabled it applies no coefficients (wb_coeffs are
757+ // published as 1.0 above), so it makes no promise that the data is white
758+ // balanced. Do not ask colorin (or any other consumer) to "finish" a
759+ // correction that never started, otherwise disabling WB would still pull the
760+ // image to D65 via D65coeffs/1.0.
761+ chr -> late_correction = piece -> enabled ? effective_late_correction : FALSE;
756762
757- chr -> temperature = piece -> enabled ? self : NULL ;
758763 /* Make sure the chroma information stuff is valid
759764 If piece is disabled we always clear the trouble message and
760765 make sure chroma does know there is no temperature module.
761766 */
762- if (p -> preset == DT_IOP_TEMP_D65_LATE )
763- chr -> late_correction = TRUE;
764- else if (p -> preset == DT_IOP_TEMP_D65 )
765- chr -> late_correction = FALSE;
766- else
767- chr -> late_correction = p -> late_correction ;
768-
769767 chr -> temperature = piece -> enabled ? self : NULL ;
770768 if (dt_pipe_is_preview (pipe ) && !piece -> enabled )
771769 dt_iop_set_module_trouble_message (self , NULL , NULL , NULL );
@@ -1198,7 +1196,6 @@ static inline const char *_preset_to_str(const int preset)
11981196 case DT_IOP_TEMP_SPOT : return "by spot" ;
11991197 case DT_IOP_TEMP_USER : return "user defined" ;
12001198 case DT_IOP_TEMP_D65 : return "camera reference" ;
1201- case DT_IOP_TEMP_D65_LATE : return "as shot to reference" ;
12021199 default : return "other" ;
12031200 }
12041201}
@@ -1209,10 +1206,8 @@ static void _update_preset(dt_iop_module_t *self, int mode)
12091206 dt_dev_chroma_t * chr = & self -> dev -> chroma ;
12101207 dt_iop_temperature_gui_data_t * g = self -> gui_data ;
12111208
1212- const gboolean is_current_reference = (p -> preset == DT_IOP_TEMP_D65_LATE ) ||
1213- (p -> preset == DT_IOP_TEMP_D65 );
1214- const gboolean is_new_mode_manual = (mode != DT_IOP_TEMP_D65_LATE ) &&
1215- (mode != DT_IOP_TEMP_D65 );
1209+ const gboolean is_current_reference = p -> preset == DT_IOP_TEMP_D65 ;
1210+ const gboolean is_new_mode_manual = mode != DT_IOP_TEMP_D65 ;
12161211
12171212 if (is_current_reference && is_new_mode_manual )
12181213 {
@@ -1222,17 +1217,13 @@ static void _update_preset(dt_iop_module_t *self, int mode)
12221217
12231218 p -> preset = mode ;
12241219
1225- if (mode == DT_IOP_TEMP_D65_LATE )
1226- {
1227- chr -> late_correction = TRUE;
1228- }
1229- else if (mode == DT_IOP_TEMP_D65 )
1220+ if (mode == DT_IOP_TEMP_D65 )
12301221 {
12311222 chr -> late_correction = FALSE;
12321223 }
12331224 else
12341225 {
1235- // For manual modes, use the parameter
1226+ // For non-D65 modes, use the parameter
12361227 chr -> late_correction = p -> late_correction ;
12371228 }
12381229
@@ -1250,9 +1241,6 @@ void gui_update(dt_iop_module_t *self)
12501241{
12511242 dt_iop_temperature_gui_data_t * g = self -> gui_data ;
12521243 dt_iop_temperature_params_t * p = self -> params ;
1253- dt_iop_temperature_params_t * d = self -> default_params ;
1254-
1255- d -> preset = dt_is_scene_referred () ? DT_IOP_TEMP_D65_LATE : DT_IOP_TEMP_AS_SHOT ;
12561244
12571245 const gboolean true_monochrome =
12581246 dt_image_monochrome_flags (& self -> dev -> image_storage ) & DT_IMAGE_MONOCHROME ;
@@ -1285,13 +1273,7 @@ void gui_update(dt_iop_module_t *self)
12851273 gboolean found = FALSE;
12861274 const dt_dev_chroma_t * chr = & self -> dev -> chroma ;
12871275 // is this a "as shot" white balance?
1288- if (dt_dev_equal_chroma ((float * )p , chr -> as_shot ) && (p -> preset == DT_IOP_TEMP_D65_LATE ))
1289- {
1290- dt_bauhaus_combobox_set (g -> presets , DT_IOP_TEMP_D65_LATE );
1291- found = TRUE;
1292- }
1293-
1294- else if (dt_dev_equal_chroma ((float * )p , chr -> as_shot ))
1276+ if (dt_dev_equal_chroma ((float * )p , chr -> as_shot ))
12951277 {
12961278 dt_bauhaus_combobox_set (g -> presets , DT_IOP_TEMP_AS_SHOT );
12971279 p -> preset = DT_IOP_TEMP_AS_SHOT ;
@@ -1439,8 +1421,6 @@ void gui_update(dt_iop_module_t *self)
14391421 p -> preset == DT_IOP_TEMP_USER );
14401422 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g -> btn_d65 ),
14411423 p -> preset == DT_IOP_TEMP_D65 );
1442- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g -> btn_d65_late ),
1443- p -> preset == DT_IOP_TEMP_D65_LATE );
14441424
14451425 _color_temptint_sliders (self );
14461426 _color_rgb_sliders (self );
@@ -1593,8 +1573,8 @@ void reload_defaults(dt_iop_module_t *self)
15931573 dt_iop_temperature_params_t * d = self -> default_params ;
15941574 dt_iop_temperature_params_t * p = self -> params ;
15951575
1596- d -> preset = dt_is_scene_referred () ? DT_IOP_TEMP_D65_LATE : DT_IOP_TEMP_AS_SHOT ;
1597- d -> late_correction = dt_is_scene_referred ();
1576+ d -> preset = p -> preset = DT_IOP_TEMP_AS_SHOT ;
1577+ d -> late_correction = p -> late_correction = dt_is_scene_referred ();
15981578
15991579 float * dcoeffs = (float * )d ;
16001580 for_four_channels (k )
@@ -1703,7 +1683,8 @@ void reload_defaults(dt_iop_module_t *self)
17031683 {
17041684 for_four_channels (k )
17051685 dcoeffs [k ] = as_shot [k ];
1706- d -> preset = p -> preset = DT_IOP_TEMP_D65_LATE ;
1686+ d -> preset = p -> preset = DT_IOP_TEMP_AS_SHOT ;
1687+ d -> late_correction = p -> late_correction = TRUE;
17071688 }
17081689 else
17091690 {
@@ -1713,6 +1694,7 @@ void reload_defaults(dt_iop_module_t *self)
17131694 dcoeffs [2 ] = coeffs [2 ]/coeffs [1 ];
17141695 dcoeffs [3 ] = coeffs [3 ]/coeffs [1 ];
17151696 dcoeffs [1 ] = 1.0f ;
1697+ d -> late_correction = p -> late_correction = FALSE;
17161698 }
17171699 }
17181700 }
@@ -1750,7 +1732,6 @@ void reload_defaults(dt_iop_module_t *self)
17501732 dt_bauhaus_combobox_add (g -> presets , C_ ("white balance" , "user modified" ));
17511733 // old "camera neutral", reason: better matches intent
17521734 dt_bauhaus_combobox_add (g -> presets , C_ ("white balance" , "camera reference" ));
1753- dt_bauhaus_combobox_add (g -> presets , C_ ("white balance" , "as shot to reference" ));
17541735
17551736 g -> preset_cnt = DT_IOP_NUM_OF_STD_TEMP_PRESETS ;
17561737 memset (g -> preset_num , 0 , sizeof (g -> preset_num ));
@@ -1760,7 +1741,6 @@ void reload_defaults(dt_iop_module_t *self)
17601741 _gui_sliders_update (self );
17611742
17621743 dt_bauhaus_combobox_set (g -> presets , p -> preset );
1763- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g -> btn_d65_late ), p -> preset == DT_IOP_TEMP_D65_LATE );
17641744 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g -> btn_asshot ), p -> preset == DT_IOP_TEMP_AS_SHOT );
17651745 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g -> btn_user ), FALSE);
17661746 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g -> btn_d65 ), FALSE);
@@ -1836,7 +1816,6 @@ static gboolean _btn_toggled(GtkWidget *togglebutton,
18361816
18371817 const int preset = togglebutton == g -> btn_asshot ? DT_IOP_TEMP_AS_SHOT :
18381818 togglebutton == g -> btn_d65 ? DT_IOP_TEMP_D65 :
1839- togglebutton == g -> btn_d65_late ? DT_IOP_TEMP_D65_LATE :
18401819 togglebutton == g -> btn_user ? DT_IOP_TEMP_USER : 0 ;
18411820
18421821 if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (togglebutton )))
@@ -1879,8 +1858,6 @@ static void _preset_tune_callback(GtkWidget *widget, dt_iop_module_t *self)
18791858 pos == DT_IOP_TEMP_USER );
18801859 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g -> btn_d65 ),
18811860 pos == DT_IOP_TEMP_D65 );
1882- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g -> btn_d65_late ),
1883- pos == DT_IOP_TEMP_D65_LATE );
18841861
18851862 gboolean show_finetune = FALSE;
18861863 dt_dev_chroma_t * chr = & self -> dev -> chroma ;
@@ -1910,9 +1887,6 @@ static void _preset_tune_callback(GtkWidget *widget, dt_iop_module_t *self)
19101887 case DT_IOP_TEMP_D65 : // camera reference d65
19111888 _temp_params_from_array (p , chr -> D65coeffs );
19121889 break ;
1913- case DT_IOP_TEMP_D65_LATE : // as shot wb just for now
1914- _temp_params_from_array (p , chr -> as_shot );
1915- break ;
19161890 default : // camera WB presets
19171891 {
19181892 gboolean found = FALSE;
@@ -2188,21 +2162,11 @@ void gui_init(dt_iop_module_t *self)
21882162 (g -> btn_d65 ,
21892163 _ ("set white balance to camera reference point\nin most cases it should be D65" ));
21902164
2191- g -> btn_d65_late = dt_iop_togglebutton_new (self ,
2192- N_ ("settings" ),
2193- N_ ("as shot to reference" ), NULL ,
2194- G_CALLBACK (_btn_toggled ), FALSE, 0 , 0 ,
2195- dtgtk_cairo_paint_bulb_mod , NULL );
2196- gtk_widget_set_tooltip_text
2197- (g -> btn_d65_late ,
2198- _ ("set white balance to as shot and later correct to camera reference point,\nin most cases it should be D65" ));
2199-
22002165 // put buttons at top. fill later.
22012166 g -> buttonbar = dt_gui_hbox (dt_gui_expand (g -> btn_asshot ),
22022167 dt_gui_expand (g -> colorpicker ),
22032168 dt_gui_expand (g -> btn_user ),
2204- dt_gui_expand (g -> btn_d65 ),
2205- dt_gui_expand (g -> btn_d65_late ));
2169+ dt_gui_expand (g -> btn_d65 ));
22062170 dt_gui_add_class (g -> buttonbar , "dt_iop_toggle" );
22072171
22082172 g -> presets = dt_bauhaus_combobox_new (self );
@@ -2253,7 +2217,7 @@ void gui_init(dt_iop_module_t *self)
22532217
22542218 gtk_widget_set_tooltip_text (g -> check_late_correction ,
22552219 _ ("ensures the white balance coefficients are treated as a reference for the color calibration module.\n"
2256- "keep this checked if you use the modern scene-referred workflow but want to manually adjust white balance ." ));
2220+ "keep this checked for non-reference white balance in the modern scene-referred workflow." ));
22572221
22582222 GtkWidget * box_enabled = dt_gui_vbox (g -> buttonbar ,
22592223 g -> check_late_correction ,
@@ -2318,9 +2282,9 @@ void gui_cleanup(dt_iop_module_t *self)
23182282void gui_reset (dt_iop_module_t * self )
23192283{
23202284 dt_iop_temperature_gui_data_t * g = self -> gui_data ;
2321- dt_iop_temperature_params_t * d = self -> default_params ;
2285+ dt_iop_temperature_params_t * p = self -> params ;
23222286
2323- const int preset = d -> preset = dt_is_scene_referred () ? DT_IOP_TEMP_D65_LATE : DT_IOP_TEMP_AS_SHOT ;
2287+ const int preset = p -> preset ;
23242288 dt_iop_color_picker_reset (self , TRUE);
23252289
23262290 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g -> btn_asshot ),
@@ -2329,8 +2293,6 @@ void gui_reset(dt_iop_module_t *self)
23292293 preset == DT_IOP_TEMP_USER );
23302294 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g -> btn_d65 ),
23312295 preset == DT_IOP_TEMP_D65 );
2332- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g -> btn_d65_late ),
2333- preset == DT_IOP_TEMP_D65_LATE );
23342296
23352297 _color_finetuning_slider (self );
23362298 _color_rgb_sliders (self );
0 commit comments