Skip to content

Commit

Permalink
Conf : new timeout setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiyone committed Jan 12, 2025
1 parent c15d92a commit 1fc25a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
7 changes: 7 additions & 0 deletions data/anselconfig.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@
<default>16</default>
<shortdescription>Number of image processing states to cache</shortdescription>
<longdescription>Module outputs are cached for improved performance, until the cache is full. For modules which parameters did not change between two pipeline recomputations, we can then fetch the cached output instead of recomputing it.\nThe actual size of each cache entry depends on what module is cached (some use the full-resolution image, some only the part that is visible on screen).\n Increase with care and monitor your RAM use.</longdescription>
</dtconfig>
<dtconfig prefs="processing" section="cpugpu" restart="true">
<name>timeout</name>
<type min="0">int</type>
<default>100</default>
<shortdescription>Pipe recompute timeout (milliseconds)</shortdescription>
<longdescription>Timeout preventing intermediate setting steps (e.g. while scrolling) to recompute the pipeline too often. Set to 0 to recompute immediately on module change.</longdescription>
</dtconfig>
<dtconfig prefs="processing" section="cpugpu">
<name>cache_disk_backend</name>
Expand Down
23 changes: 12 additions & 11 deletions src/bauhaus/bauhaus.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ static void show_pango_text(struct dt_bauhaus_widget_t *w, GtkStyleContext *cont
g_object_unref(layout);
}

static void dt_bauhaus_slider_set_normalized(struct dt_bauhaus_widget_t *w, float pos, gboolean raise, gboolean timeout);
static void dt_bauhaus_slider_set_normalized(struct dt_bauhaus_widget_t *w, float pos, gboolean raise, int timeout);

static double get_slider_line_offset(const double pos, const double scale, const double x, double y, const double line_height)
{
Expand Down Expand Up @@ -654,7 +654,7 @@ static gboolean dt_bauhaus_popup_motion_notify(GtkWidget *widget, GdkEventMotion
if(d->is_dragging)
{
// On dragging (when holding a click), we commit intermediate values to pipeline for "realtime" preview
dt_bauhaus_slider_set_normalized(w, d->oldpos + mouse_off, TRUE, TRUE);
dt_bauhaus_slider_set_normalized(w, d->oldpos + mouse_off, TRUE, dt_conf_get_int("processing/timeout") );
}
else
{
Expand Down Expand Up @@ -738,7 +738,7 @@ static gboolean dt_bauhaus_popup_button_press(GtkWidget *widget, GdkEventButton
// d->pos is used for uncommitted drawings.
const float value = d->pos;
d->pos = d->oldpos;
dt_bauhaus_slider_set_normalized(w, value, TRUE, FALSE);
dt_bauhaus_slider_set_normalized(w, value, TRUE, 0);
}
else
{
Expand Down Expand Up @@ -1967,7 +1967,7 @@ static void dt_bauhaus_widget_reject(struct dt_bauhaus_widget_t *w)
case DT_BAUHAUS_SLIDER:
{
dt_bauhaus_slider_data_t *d = &w->data.slider;
dt_bauhaus_slider_set_normalized(w, d->oldpos, TRUE, FALSE);
dt_bauhaus_slider_set_normalized(w, d->oldpos, TRUE, 0);
}
break;
default:
Expand Down Expand Up @@ -2045,7 +2045,8 @@ static void dt_bauhaus_widget_accept(struct dt_bauhaus_widget_t *w, gboolean tim
// with value-changed signal through dt_bauhaus_slider_set_normalized()
const float value = d->pos;
d->pos = d->oldpos;
dt_bauhaus_slider_set_normalized(w, value, TRUE, timeout);
int timeout_slider = timeout ? dt_conf_get_int("processing/timeout") : 0;
dt_bauhaus_slider_set_normalized(w, value, TRUE, timeout_slider);
break;
}
default:
Expand Down Expand Up @@ -2676,7 +2677,7 @@ void dt_bauhaus_slider_set(GtkWidget *widget, float pos)
const float rpos = CLAMP(pos, d->hard_min, d->hard_max);
d->min = MIN(d->min, rpos);
d->max = MAX(d->max, rpos);
dt_bauhaus_slider_set_normalized(w, (rpos - d->min) / (d->max - d->min), TRUE, FALSE);
dt_bauhaus_slider_set_normalized(w, (rpos - d->min) / (d->max - d->min), TRUE, 0);
}

void dt_bauhaus_slider_set_val(GtkWidget *widget, float val)
Expand Down Expand Up @@ -2854,7 +2855,7 @@ static gboolean _delayed_slider_commit(gpointer data)
* value-changed signal and commit to pipeline too often. FALSE to set immediately, when there is no ambiguity
* on the final setting (e.g. at init time and on click). Doesn't change anything if raise is FALSE.
*/
static void dt_bauhaus_slider_set_normalized(struct dt_bauhaus_widget_t *w, float pos, gboolean raise, gboolean timeout)
static void dt_bauhaus_slider_set_normalized(struct dt_bauhaus_widget_t *w, float pos, gboolean raise, int timeout)
{
dt_bauhaus_slider_data_t *d = &w->data.slider;
const float old_pos = d->pos;
Expand Down Expand Up @@ -2888,7 +2889,7 @@ static void dt_bauhaus_slider_set_normalized(struct dt_bauhaus_widget_t *w, floa
d->timeout_handle = 0;
}
// TODO: map the timeout to an user config ? Arguably, that value will be higher for senior citizen
d->timeout_handle = g_timeout_add(350, _delayed_slider_commit, w);
d->timeout_handle = g_timeout_add(timeout, _delayed_slider_commit, w);
}
}
}
Expand Down Expand Up @@ -3056,7 +3057,7 @@ static gboolean dt_bauhaus_slider_button_press(GtkWidget *widget, GdkEventButton
{
// single left click on slider bar : set new value
d->is_dragging = 1;
dt_bauhaus_slider_set_normalized(w, event_x / main_width, FALSE, FALSE);
dt_bauhaus_slider_set_normalized(w, event_x / main_width, FALSE, 0);
}
}
}
Expand Down Expand Up @@ -3095,7 +3096,7 @@ static gboolean dt_bauhaus_slider_button_release(GtkWidget *widget, GdkEventButt

if(event->button == 1)
{
dt_bauhaus_slider_set_normalized(w, darktable.bauhaus->mouse_x / _widget_get_main_width(w, NULL, NULL), TRUE, FALSE);
dt_bauhaus_slider_set_normalized(w, darktable.bauhaus->mouse_x / _widget_get_main_width(w, NULL, NULL), TRUE, 0);
return TRUE;
}
}
Expand All @@ -3117,7 +3118,7 @@ static gboolean dt_bauhaus_slider_motion_notify(GtkWidget *widget, GdkEventMotio

darktable.bauhaus->mouse_x = event_x;
darktable.bauhaus->mouse_y = event_y;
dt_bauhaus_slider_set_normalized(w, event_x / main_width, FALSE, FALSE);
dt_bauhaus_slider_set_normalized(w, event_x / main_width, FALSE, 0);
}

return activated;
Expand Down

0 comments on commit 1fc25a5

Please sign in to comment.