32#ifdef GDK_WINDOWING_QUARTZ
55 gboolean *field = (gboolean*)(data->
param);
57 gboolean previous = *field;
58 *field = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(togglebutton));
60 if(*field != previous)
82 size_t param_index = 0;
83 gboolean skip_label =
FALSE;
85 const size_t param_length = strlen(
param) + 1;
86 char *param_name = g_malloc(param_length);
87 char *base_name = g_malloc(param_length);
88 if(sscanf(
param,
"%[^[][%" G_GSIZE_FORMAT
"]", base_name, ¶m_index) == 2)
90 sprintf(param_name,
"%s[0]", base_name);
95 memcpy(param_name,
param, param_length);
108 const float min =
f->Float.Min;
109 const float max =
f->Float.Max;
110 offset =
f->header.offset + param_index *
sizeof(float);
111 const float defval = *(
float*)((uint8_t *)
d + offset);
114 const int digits =
MAX(2, -floorf(log10f(
top/100)+.1));
120 const int min =
f->Int.Min;
121 const int max =
f->Int.Max;
122 offset =
f->header.offset + param_index *
sizeof(int);
123 const int defval = *(
int*)((uint8_t *)
d + offset);
129 const unsigned short min =
f->UShort.Min;
130 const unsigned short max =
f->UShort.Max;
131 offset =
f->header.offset + param_index *
sizeof(
unsigned short);
132 const unsigned short defval = *(
unsigned short*)((uint8_t *)
d + offset);
145 if (*
f->header.description)
163 gchar *str = g_strdup_printf(
"'%s' is not a float/int/unsigned short/slider parameter", param_name);
197 if (*
f->header.description)
223 if(*iter->description)
230 str = g_strdup_printf(
"'%s' is not an enum/int/bool/combobox parameter",
param);
258 str = *
f->header.description
259 ? g_strdup(
f->header.description)
262 GtkWidget *label = gtk_label_new(_(str));
263 gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END);
264 button = gtk_check_button_new();
265 gtk_container_add(GTK_CONTAINER(button), label);
267 module_param->module = self;
269 g_signal_connect_data(G_OBJECT(button),
"toggled", G_CALLBACK(
_iop_toggle_callback), module_param, (GClosureNotify)g_free, 0);
273 str = g_strdup_printf(
"'%s' is not a bool/togglebutton parameter",
param);
275 button = gtk_check_button_new_with_label(str);
288 GCallback callback, gboolean local, guint accel_key, GdkModifierType mods,
292 g_signal_connect(G_OBJECT(w),
"button-press-event", callback, self);
295 gtk_widget_set_tooltip_text(w, _(label));
298 gchar *
tooltip = g_strdup_printf(_(
"%s\nctrl+click to %s"), _(label), _(ctrl_label));
299 gtk_widget_set_tooltip_text(w,
tooltip);
305 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
FALSE);
306 if(GTK_IS_BOX(box)) gtk_box_pack_end(GTK_BOX(box), w,
FALSE,
FALSE, 0);
312 const gchar *ctrl_label, GCallback callback, gboolean local,
313 guint accel_key, GdkModifierType mods,
317 g_signal_connect(G_OBJECT(w),
"button-press-event", callback, self);
320 gtk_widget_set_tooltip_text(w, _(label));
323 gchar *
tooltip = g_strdup_printf(_(
"%s\nctrl+click to %s"), _(label), _(ctrl_label));
324 gtk_widget_set_tooltip_text(w,
tooltip);
328 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
FALSE);
329 if(GTK_IS_BOX(box)) gtk_box_pack_end(GTK_BOX(box), w,
FALSE,
FALSE, 0);
335 GCallback callback, gboolean local, guint accel_key, GdkModifierType mods,
343 gtk_widget_set_tooltip_text(button, _(label));
347 button = gtk_button_new_with_label(_(label));
348 gtk_label_set_ellipsize(GTK_LABEL(gtk_bin_get_child(GTK_BIN(button))), PANGO_ELLIPSIZE_END);
352 g_signal_connect(G_OBJECT(button),
"clicked", callback, (gpointer)self);
354 if(GTK_IS_BOX(box)) gtk_box_pack_start(GTK_BOX(box), button,
TRUE,
TRUE, 0);
362 return up ? !mask_down : mask_down;
GtkWidget * dt_bauhaus_slider_new(dt_bauhaus_t *bh, dt_gui_module_t *self)
GtkWidget * dt_bauhaus_slider_new_with_range_and_feedback(dt_bauhaus_t *bh, dt_gui_module_t *self, float min, float max, float step, float defval, int digits, int feedback)
void dt_bauhaus_widget_set_field(GtkWidget *widget, gpointer field, dt_introspection_type_t field_type)
void dt_bauhaus_combobox_add_full(GtkWidget *widget, const char *text, dt_bauhaus_combobox_alignment_t align, gpointer data, void(free_func)(void *data), gboolean sensitive)
void dt_bauhaus_widget_set_label(GtkWidget *widget, const char *label)
GtkWidget * dt_bauhaus_combobox_new(dt_bauhaus_t *bh, dt_gui_module_t *self)
void dt_bauhaus_combobox_add(GtkWidget *widget, const char *text)
@ DT_BAUHAUS_COMBOBOX_ALIGN_RIGHT
#define DT_BAUHAUS_WIDGET(obj)
static const dt_aligned_pixel_simd_t const dt_adaptation_t const float p
const dt_aligned_pixel_t f
static const float const float const float min
int dt_conf_get_bool(const char *name)
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
void(* DTGTKCairoPaintIconFunc)(cairo_t *cr, gint x, gint y, gint w, gint h, gint flags, void *data)
#define DT_GUI_BOX_SPACING
void dt_iop_gui_changed(dt_iop_module_t *action, GtkWidget *widget, gpointer data)
GtkWidget * dt_iop_togglebutton_new_no_register(dt_iop_module_t *self, const char *section, const gchar *label, const gchar *ctrl_label, GCallback callback, gboolean local, guint accel_key, GdkModifierType mods, DTGTKCairoPaintIconFunc paint, GtkWidget *box)
GtkWidget * dt_iop_button_new(dt_iop_module_t *self, const gchar *label, GCallback callback, gboolean local, guint accel_key, GdkModifierType mods, DTGTKCairoPaintIconFunc paint, gint paintflags, GtkWidget *box)
static void _iop_toggle_callback(GtkWidget *togglebutton, dt_module_param_t *data)
GtkWidget * dt_iop_togglebutton_new(dt_iop_module_t *self, const char *section, const gchar *label, const gchar *ctrl_label, GCallback callback, gboolean local, guint accel_key, GdkModifierType mods, DTGTKCairoPaintIconFunc paint, GtkWidget *box)
GtkWidget * dt_bauhaus_toggle_from_params(dt_iop_module_t *self, const char *param)
GtkWidget * dt_bauhaus_slider_from_params(dt_iop_module_t *self, const char *param)
static void _add_widget_to_module_list(dt_iop_module_t *self, GtkWidget *widget)
gboolean dt_mask_scroll_increases(int up)
GtkWidget * dt_bauhaus_combobox_from_params(dt_iop_module_t *self, const char *param)
@ DT_INTROSPECTION_TYPE_BOOL
@ DT_INTROSPECTION_TYPE_ENUM
@ DT_INTROSPECTION_TYPE_FLOAT
@ DT_INTROSPECTION_TYPE_UINT
@ DT_INTROSPECTION_TYPE_USHORT
@ DT_INTROSPECTION_TYPE_INT
struct _GtkWidget GtkWidget
const float const float param
struct dt_gui_gtk_t * gui
struct dt_bauhaus_t * bauhaus
The dt_gui_module_t type is the intersection between a dt_lib_module_t and a dt_iop_module_t structur...
dt_iop_params_t * default_params
dt_iop_module_t *void * param
gchar * dt_util_str_replace(const gchar *string, const gchar *pattern, const gchar *substitute)