55#define DEFAULT_GUIDE_NAME "rules of thirds"
59 N_(
"rules of thirds"),
62 N_(
"diagonal method"),
63 N_(
"harmonious triangles"),
64 N_(
"golden sections"),
66 N_(
"golden spiral sections"),
67 N_(
"golden mean (all guides)"),
106 if(!g_strcmp0(
name, guide->
name))
return i;
111static gchar *
_conf_get_path(gchar *module_name, gchar *property_1, gchar *property_2)
120 g_snprintf(lay,
sizeof(lay),
"%d/", 0);
122 else if(g_strcmp0(cv->
module_name,
"darkroom") == 0)
156 if(guide)
return guide->
name;
161 float zoom_scale,
void *data)
164 int nbh = 3, nbv = 3, subdiv = 3;
165 gboolean loaded =
FALSE;
169 if(val && !g_strcmp0(val,
"grid"))
186 float bottom = y + h;
191 cairo_set_dash(cr, &dashes, 1, 0);
195 cairo_set_dash(cr, &dashes, 1, dashes);
200 cairo_set_dash(cr, &dashes, 1, 0);
205 cairo_set_dash(cr, &dashes, 1, dashes);
245 gtk_widget_set_tooltip_text(grid_horizontal, _(
"number of horizontal guide lines"));
246 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(grid_horizontal),
TRUE,
TRUE, 0);
255 gtk_widget_set_tooltip_text(grid_vertical, _(
"number of vertical guide lines"));
256 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(grid_vertical),
TRUE,
TRUE, 0);
260 g_signal_connect(G_OBJECT(grid_vertical),
"value-changed", G_CALLBACK(
_grid_vertical_changed), user_data);
265 gtk_widget_set_tooltip_text(grid_subdiv, _(
"number of subdivisions per grid rectangle"));
266 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(grid_subdiv),
TRUE,
TRUE, 0);
270 g_signal_connect(G_OBJECT(grid_subdiv),
"value-changed", G_CALLBACK(
_grid_subdiv_changed), user_data);
319#define PERSPECTIVE_LINES 16
323 line_length = w * w + h * h;
329 cairo_rotate(cr, -
M_PI * rotation_step *
i);
335#undef PERSPECTIVE_LINES
343 const float x_step = w / (
X_LINES - 1), y_step = h / (
Y_LINES - 1), length_short =
MIN(w, h) * 0.02,
344 length_middle = length_short * 1.5,
345 length_long = length_middle * 1.5;
348 cairo_translate(cr,
x, y);
352 cairo_translate(cr, 0, h * 0.5);
355 dt_draw_line(cr,
i * x_step, -length_short,
i * x_step, length_short);
357 dt_draw_line(cr,
i * x_step, -length_middle,
i * x_step, length_middle);
359 dt_draw_line(cr,
i * x_step, -length_long,
i * x_step, length_long);
366 cairo_translate(cr, w * 0.5, 0);
369 dt_draw_line(cr, -length_short,
i * y_step, length_short,
i * y_step);
372 else if((
i - 4) % 12 != 0)
373 dt_draw_line(cr, -length_middle,
i * y_step, length_middle,
i * y_step);
375 dt_draw_line(cr, -length_long,
i * y_step, length_long,
i * y_step);
379 const float length_cross = length_short * .5, cross_x_step = w /
CROSSES, cross_y_step = h /
CROSSES;
380 for(
int cx = 1; cx <
CROSSES; cx++)
381 for(
int cy = 1; cy <
CROSSES; cy++)
384 float _x = cx * cross_x_step, _y = cy * cross_y_step;
385 dt_draw_line(cr, _x - length_cross, _y, _x + length_cross, _y);
386 dt_draw_line(cr, _x, _y - length_cross, _x, _y + length_cross);
394#define RADIANS(degrees) ((degrees) * (M_PI / 180.))
397 gboolean goldenTriangle, gboolean goldenSpiralSection, gboolean goldenSpiral)
420 if(goldenSpiralSection)
435 cairo_new_sub_path(cr);
441 cairo_new_sub_path(cr);
447 cairo_new_sub_path(cr);
453 cairo_new_sub_path(cr);
459 cairo_new_sub_path(cr);
465 cairo_new_sub_path(cr);
471 cairo_new_sub_path(cr);
477 cairo_new_sub_path(cr);
490 const float w,
const float h,
491 const float zoom_scale,
void *user_data)
496 const float w,
const float h,
497 const float zoom_scale,
void *user_data)
502 const float w,
const float h,
503 const float zoom_scale,
void *user_data)
508 const float w,
const float h,
509 const float zoom_scale,
void *user_data)
514 const float w,
const float h,
515 const float zoom_scale,
void *user_data)
520 const float w,
const float h,
521 const float zoom_scale,
void *user_data)
526 const float w,
const float h,
527 const float zoom_scale,
void *user_data)
531 if(user_data) extra = GPOINTER_TO_INT(user_data);
544 dt_guides_q_rect(&R2, w_g - w_2, h_2 - h_g, w - w_g + 1 - (w - 2 * w_2), h_g);
553 cr, &R1, &R2, &R3, &R4, &R5, &R6, &R7, (extra ==
GOLDEN_SECTION || extra ==
GOLDEN_ALL),
FALSE,
560 void *user_data, GDestroyNotify free,
561 gboolean support_flip)
570 *list = g_list_append(*list, guide);
596 GList *guides = NULL;
619 if((guide && guide->
widget))
622 if(w) gtk_widget_destroy(w);
625 gtk_container_add(GTK_CONTAINER(gw->
g_widgets), extra);
626 gtk_widget_show_all(extra);
682 const int overlay_color =
dt_conf_get_int(
"darkroom/ui/overlay_color");
685 double red = 0.0, green = 0.0, blue = 0.0;
688 red = green = blue = 1.0;
720 GtkWidget *pop = gtk_popover_new(button);
724 g_object_set_data_full(G_OBJECT(pop),
"guides-settings", gw, g_free);
728 GtkWidget *lb = gtk_label_new(_(
"global guide overlay settings"));
729 gtk_label_set_justify(GTK_LABEL(lb), GTK_JUSTIFY_CENTER);
731 gtk_box_pack_start(GTK_BOX(vbox), lb,
TRUE,
TRUE, 0);
754 gtk_box_pack_start(GTK_BOX(vbox), gtk_separator_new(GTK_ORIENTATION_HORIZONTAL),
TRUE,
TRUE, 0);
770 gtk_widget_set_tooltip_text(contrast, N_(
"set the contrast between the lightest and darkest part of the guide overlays"));
772 gtk_box_pack_start(GTK_BOX(vbox), contrast,
TRUE,
TRUE, 0);
775 gtk_container_add(GTK_CONTAINER(pop), vbox);
777 gtk_widget_show_all(vbox);
801 const float zoom_scale)
830 cairo_set_dash(cr, &dashes, 0, 0);
836 if(
flip == 1 ||
flip == 3) cairo_scale(cr, -1, 1);
838 if(
flip == 2 ||
flip == 3) cairo_scale(cr, 1, -1);
843 cairo_stroke_preserve(cr);
844 cairo_set_dash(cr, &dashes, 1, 0);
GtkWidget * dt_bauhaus_combobox_new_full(dt_bauhaus_t *bh, dt_gui_module_t *self, const char *label, const char *tip, int pos, GtkCallback callback, gpointer data, const char **texts)
void dt_bauhaus_slider_set_hard_max(GtkWidget *widget, float val)
float dt_bauhaus_slider_get(GtkWidget *widget)
int dt_bauhaus_combobox_get(GtkWidget *widget)
void dt_bauhaus_slider_set(GtkWidget *widget, float pos)
void dt_bauhaus_combobox_set(GtkWidget *widget, const int pos)
void dt_bauhaus_widget_set_label(GtkWidget *widget, const char *label)
GtkWidget * dt_bauhaus_slider_new_with_range(dt_bauhaus_t *bh, dt_gui_module_t *self, float min, float max, float step, float defval, int digits)
void dt_bauhaus_combobox_add(GtkWidget *widget, const char *text)
#define DT_BAUHAUS_COMBOBOX_NEW_FULL(bauhaus, widget, action, label, tip, pos, callback, data,...)
struct _GtkWidget GtkWidget
GtkWidget, opaque, spelled exactly as GTK spells it.
void dt_conf_set_bool(const char *name, int val)
int dt_conf_get_bool(const char *name)
int dt_conf_key_exists(const char *key)
Does key have a value?
void dt_conf_set_float(const char *name, float val)
float dt_conf_get_float(const char *name)
Float for name, clamped to its declared bounds.
gchar * dt_conf_get_string(const char *name)
Read the stored string for name as a private copy.
void dt_conf_set_int(const char *name, int val)
int dt_conf_get_int(const char *name)
Integer for name, clamped to the bounds declared in the XML.
void dt_conf_set_string(const char *name, const char *val)
void dt_control_queue_redraw_center()
Request a redraw of the centre view.
struct dt_view_manager_t * dt_view_manager_get_global(void)
struct dt_bauhaus_t * dt_bauhaus_get_global(void)
GHashTable * names
GtkWidget* -> the name the application knows it by.
static void dt_draw_horizontal_lines(cairo_t *cr, const int num, const int left, const int top, const int right, const int bottom)
static void dt_draw_set_color_overlay(cairo_t *cr, gboolean bright, double alpha)
static void dt_draw_line(cairo_t *cr, float left, float top, float right, float bottom)
static void dt_draw_vertical_lines(cairo_t *cr, const int num, const int left, const int top, const int right, const int bottom)
static void _grid_subdiv_changed(GtkWidget *w, void *data)
static void _guides_draw_perspective(cairo_t *cr, const float x, const float y, const float w, const float h, const float zoom_scale, void *user_data)
static dt_guides_t * _conf_get_guide(gchar *module_name)
void dt_guides_draw(cairo_t *cr, const float left, const float top, const float width, const float height, const float zoom_scale)
static void _guides_draw_harmonious_triangles(cairo_t *cr, const float x, const float y, const float w, const float h, const float zoom_scale, void *user_data)
void dt_guides_add_guide(const char *name, dt_guides_draw_callback draw, dt_guides_widget_callback widget, void *user_data, GDestroyNotify free)
void dt_guides_init(void)
static void _grid_horizontal_changed(GtkWidget *w, void *data)
static gchar * _conf_get_path(gchar *module_name, gchar *property_1, gchar *property_2)
static gchar * _conf_get_guide_name(gchar *module_name)
static void _guides_draw_metering(cairo_t *cr, const float x, const float y, const float w, const float h, const float zoom_scale, void *user_data)
static void free_guide(void *data)
static void dt_guides_draw_harmonious_triangles(cairo_t *cr, const float left, const float top, const float width, const float height)
void dt_guides_update_popover_values()
static GtkWidget * _guides_gui_grid(dt_iop_module_t *self, void *user_data)
static void _settings_flip_changed(GtkWidget *w, _guides_settings_t *gw)
static void _grid_vertical_changed(GtkWidget *w, void *data)
static void dt_guides_draw_rules_of_thirds(cairo_t *cr, const float left, const float top, const float width, const float height)
void dt_guides_set_overlay_colors()
static void _settings_colors_changed(GtkWidget *combo, _guides_settings_t *gw)
static void _settings_update_visibility(_guides_settings_t *gw)
static void _guides_draw_grid(cairo_t *cr, const float x, const float y, const float w, const float h, const float zoom_scale, void *user_data)
#define PERSPECTIVE_LINES
static void _guides_draw_golden_mean(cairo_t *cr, const float x, const float y, const float w, const float h, const float zoom_scale, void *user_data)
static void _guides_add_guide(GList **list, const char *name, dt_guides_draw_callback draw, dt_guides_widget_callback widget, void *user_data, GDestroyNotify free, gboolean support_flip)
static void dt_guides_q_rect(dt_QRect_t *R1, float left, float top, float width, float height)
static GList * dt_guides_get_list(void)
static void dt_guides_draw_grid(cairo_t *cr, const float x, const float y, const float w, const float h, float zoom_scale, void *data)
static void dt_guides_draw_metering(cairo_t *cr, const float x, const float y, const float w, const float h)
static void dt_guides_draw_diagonal_method(cairo_t *cr, const float x, const float y, const float w, const float h)
static void dt_guides_draw_golden_mean(cairo_t *cr, dt_QRect_t *R1, dt_QRect_t *R2, dt_QRect_t *R3, dt_QRect_t *R4, dt_QRect_t *R5, dt_QRect_t *R6, dt_QRect_t *R7, gboolean goldenSection, gboolean goldenTriangle, gboolean goldenSpiralSection, gboolean goldenSpiral)
static const char * _guide_names[]
GtkWidget * dt_guides_popover(dt_view_t *self, GtkWidget *button)
void dt_guides_cleanup(void)
void dt_guides_button_toggled(gboolean active)
static void dt_guides_draw_perspective(cairo_t *cr, const float x, const float y, const float w, const float h)
static void _settings_contrast_changed(GtkWidget *slider, _guides_settings_t *gw)
void dt_guides_update_button_state()
static void _guides_draw_rules_of_thirds(cairo_t *cr, const float x, const float y, const float w, const float h, const float zoom_scale, void *user_data)
static void _settings_guides_changed(GtkWidget *w, _guides_settings_t *gw)
static int _guides_get_value(gchar *name)
static void _guides_draw_diagonal_method(cairo_t *cr, const float x, const float y, const float w, const float h, const float zoom_scale, void *user_data)
#define DEFAULT_GUIDE_NAME
static void _settings_flip_update(_guides_settings_t *gw)
void(* dt_guides_draw_callback)(cairo_t *cr, const float x, const float y, const float w, const float h, const float zoom_scale, void *user_data)
GtkWidget *(* dt_guides_widget_callback)(dt_iop_module_t *self, void *user_data)
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
Asking the interface to repaint itself.
const float const int flip
dt_guides_draw_callback draw
dt_guides_widget_callback widget
GtkWidget * guides_colors
GtkWidget * guides_toggle
GtkWidget * guides_contrast
gchar * dt_util_dstrcat(gchar *str, const gchar *format,...)
dt_darkroom_layout_t dt_view_darkroom_get_layout(dt_view_manager_t *vm)
const dt_view_t * dt_view_manager_get_current_view(dt_view_manager_t *vm)