diff --git a/src/libs/history.c b/src/libs/history.c index b0f572ea4aea..8103e63ef291 100644 --- a/src/libs/history.c +++ b/src/libs/history.c @@ -32,6 +32,7 @@ #include "libs/lib_api.h" #include "common/history.h" #include +#include "bauhaus/bauhaus.h" #ifdef GDK_WINDOWING_QUARTZ #include "osx/osx.h" @@ -713,13 +714,42 @@ static void _lib_history_will_change_callback(gpointer instance, gpointer user_d } } +static gchar *_lib_history_bauhaus_text(gpointer bhfield, + const char *d, + dt_iop_module_t *module, + float oval, + float pval) +{ + for(GSList *w = module->widget_list_bh; w; w = g_slist_next(w)) + { + GtkWidget *widget = ((dt_action_target_t *)w->data)->target; + if(DT_BAUHAUS_WIDGET(widget)->field == bhfield) + { + gchar *old_text = dt_bauhaus_slider_get_text(widget, oval); + gchar *new_text = dt_bauhaus_slider_get_text(widget, pval); + gchar *ret_text = g_strdup_printf("%s\t%s\t\u2192\t%s", d, old_text, new_text); + g_free(old_text); + g_free(new_text); + return ret_text; + } + } + return NULL; +} + static gchar *_lib_history_change_text(dt_introspection_field_t *field, const char *d, + dt_iop_module_t *module, gpointer params, gpointer oldpar) { - dt_iop_params_t *p = (dt_iop_params_t *)((uint8_t *)params + field->header.offset); - dt_iop_params_t *o = (dt_iop_params_t *)((uint8_t *)oldpar + field->header.offset); + void *p = (void*)params + field->header.offset; + void *o = (void*)oldpar + field->header.offset; + +#define CHANGE_TEXT_BAUHAUS(format, fieldtype) \ + _lib_history_bauhaus_text((void*)module->params + field->header.offset, \ + d, module, *(fieldtype*)o, *(fieldtype*)p) \ + ?: g_strdup_printf("%s\t" format "\t\u2192\t" format, \ + d, *(fieldtype*)o, *(fieldtype*)p) switch(field->header.type) { @@ -740,7 +770,7 @@ static gchar *_lib_history_change_text(dt_introspection_field_t *field, if(d) description = g_strdup_printf("%s.%s", d, description); gchar *part, *sect = NULL; - if((part = _lib_history_change_text(entry, description, params, oldpar))) + if((part = _lib_history_change_text(entry, description, module, params, oldpar))) { GHashTable *sections = field->header.so->get_introspection()->sections; if(sections @@ -786,7 +816,7 @@ static gchar *_lib_history_change_text(dt_introspection_field_t *field, { char *description = g_strdup_printf("%s[%d]", d, i); char *element_text = - _lib_history_change_text(field->Array.field, description, + _lib_history_change_text(field->Array.field, description, module, (uint8_t *)params + item_offset, (uint8_t *)oldpar + item_offset); g_free(description); @@ -810,29 +840,27 @@ static gchar *_lib_history_change_text(dt_introspection_field_t *field, break; case DT_INTROSPECTION_TYPE_FLOAT: if(*(float*)o != *(float*)p && (dt_isfinite(*(float*)o) || dt_isfinite(*(float*)p))) - return g_strdup_printf("%s\t%.4f\t\u2192\t%.4f", d, *(float*)o, *(float*)p); + return CHANGE_TEXT_BAUHAUS("%.4f", float); break; case DT_INTROSPECTION_TYPE_INT: if(*(int*)o != *(int*)p) - return g_strdup_printf("%s\t%d\t\u2192\t%d", d, *(int*)o, *(int*)p); + return CHANGE_TEXT_BAUHAUS("%d", int); break; case DT_INTROSPECTION_TYPE_UINT: if(*(unsigned int*)o != *(unsigned int*)p) - return g_strdup_printf("%s\t%u\t\u2192\t%u", d, *(unsigned int*)o, - *(unsigned int*)p); + return CHANGE_TEXT_BAUHAUS("%u", unsigned int); break; case DT_INTROSPECTION_TYPE_USHORT: if(*(unsigned short int*)o != *(unsigned short int*)p) - return g_strdup_printf("%s\t%hu\t\u2192\t%hu", d, *(unsigned short int*)o, - *(unsigned short int*)p); + return CHANGE_TEXT_BAUHAUS("%hu", unsigned short int); break; case DT_INTROSPECTION_TYPE_INT8: if(*(uint8_t*)o != *(uint8_t*)p) - return g_strdup_printf("%s\t%d\t\u2192\t%d", d, *(uint8_t*)o, *(uint8_t*)p); + return CHANGE_TEXT_BAUHAUS("%d", uint8_t); break; case DT_INTROSPECTION_TYPE_CHAR: if(*(char*)o != *(char*)p) - return g_strdup_printf("%s\t'%c'\t\u2192\t'%c'", d, *(char *)o, *(char *)p); + return CHANGE_TEXT_BAUHAUS("'%c'", char); break; case DT_INTROSPECTION_TYPE_FLOATCOMPLEX: if(*(float complex*)o != *(float complex*)p) @@ -912,7 +940,7 @@ static gboolean _changes_tooltip_callback(GtkWidget *widget, if(hitem->module->have_introspection) change_parts[0] = _lib_history_change_text(hitem->module->get_introspection()->field, - NULL, + NULL, hitem->module, hitem->params, old_params); int num_parts = change_parts[0] ? 1 : 0; @@ -922,8 +950,12 @@ static gboolean _changes_tooltip_callback(GtkWidget *widget, if((hitem->blend_params->field) != (old_blend->field)) \ { \ gchar *full_format = g_strconcat("%s\t", format, "\t\u2192\t", format, NULL); \ - change_parts[num_parts++] = g_strdup_printf(full_format, label, \ - (old_blend->field), (hitem->blend_params->field)); \ + change_parts[num_parts++] = \ + _lib_history_bauhaus_text(&hitem->module->blend_params->field, \ + label, hitem->module, \ + old_blend->field, hitem->blend_params->field) \ + ?: g_strdup_printf(full_format, label, \ + old_blend->field, hitem->blend_params->field); \ g_free(full_format); \ } @@ -969,9 +1001,11 @@ static gboolean _changes_tooltip_callback(GtkWidget *widget, add_blend_history_change_enum(raster_mask_invert, _("invert mask"), dt_develop_invert_mask_names); - add_blend_history_change(mask_combine & DEVELOP_COMBINE_MASKS_POS - ? '-' - : '+', "%c", _("drawn mask polarity")); + const char old_combine = old_blend->mask_combine & DEVELOP_COMBINE_MASKS_POS ? '+' : '-'; + const char new_combine = hitem->blend_params->mask_combine & DEVELOP_COMBINE_MASKS_POS ? '+' : '-'; + if(new_combine != old_combine) + change_parts[num_parts++] = g_strdup_printf("%s\t%c\t\u2192\t%c", _("drawn mask polarity"), + old_combine, new_combine); if(hitem->blend_params->mask_id != old_blend->mask_id) change_parts[num_parts++] = old_blend->mask_id == 0