42#define DEFAULT_GUIDE_NAME "rules of thirds"
46 N_(
"rules of thirds"),
49 N_(
"diagonal method"),
50 N_(
"harmonious triangles"),
51 N_(
"golden sections"),
53 N_(
"golden spiral sections"),
54 N_(
"golden mean (all guides)"),
93 if(!g_strcmp0(
name, guide->
name))
return i;
98static gchar *
_conf_get_path(gchar *module_name, gchar *property_1, gchar *property_2)
106 g_snprintf(lay,
sizeof(lay),
"%d/", 0);
108 else if(g_strcmp0(cv->
module_name,
"darkroom") == 0)
142 if(guide)
return guide->
name;
147 float zoom_scale,
void *data)
150 int nbh = 3, nbv = 3, subdiv = 3;
151 gboolean loaded =
FALSE;
155 if(val && !g_strcmp0(val,
"grid"))
172 float bottom = y + h;
177 cairo_set_dash(cr, &dashes, 1, 0);
181 cairo_set_dash(cr, &dashes, 1, dashes);
186 cairo_set_dash(cr, &dashes, 1, 0);
191 cairo_set_dash(cr, &dashes, 1, dashes);
231 gtk_widget_set_tooltip_text(grid_horizontal, _(
"number of horizontal guide lines"));
232 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(grid_horizontal),
TRUE,
TRUE, 0);
241 gtk_widget_set_tooltip_text(grid_vertical, _(
"number of vertical guide lines"));
242 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(grid_vertical),
TRUE,
TRUE, 0);
246 g_signal_connect(G_OBJECT(grid_vertical),
"value-changed", G_CALLBACK(
_grid_vertical_changed), user_data);
251 gtk_widget_set_tooltip_text(grid_subdiv, _(
"number of subdivisions per grid rectangle"));
252 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(grid_subdiv),
TRUE,
TRUE, 0);
256 g_signal_connect(G_OBJECT(grid_subdiv),
"value-changed", G_CALLBACK(
_grid_subdiv_changed), user_data);
305#define PERSPECTIVE_LINES 16
309 line_length = w * w + h * h;
315 cairo_rotate(cr, -
M_PI * rotation_step *
i);
321#undef PERSPECTIVE_LINES
329 const float x_step = w / (
X_LINES - 1), y_step = h / (
Y_LINES - 1), length_short =
MIN(w, h) * 0.02,
330 length_middle = length_short * 1.5,
331 length_long = length_middle * 1.5;
334 cairo_translate(cr,
x, y);
338 cairo_translate(cr, 0, h * 0.5);
341 dt_draw_line(cr,
i * x_step, -length_short,
i * x_step, length_short);
343 dt_draw_line(cr,
i * x_step, -length_middle,
i * x_step, length_middle);
345 dt_draw_line(cr,
i * x_step, -length_long,
i * x_step, length_long);
352 cairo_translate(cr, w * 0.5, 0);
355 dt_draw_line(cr, -length_short,
i * y_step, length_short,
i * y_step);
358 else if((
i - 4) % 12 != 0)
359 dt_draw_line(cr, -length_middle,
i * y_step, length_middle,
i * y_step);
361 dt_draw_line(cr, -length_long,
i * y_step, length_long,
i * y_step);
365 const float length_cross = length_short * .5, cross_x_step = w /
CROSSES, cross_y_step = h /
CROSSES;
366 for(
int cx = 1; cx <
CROSSES; cx++)
367 for(
int cy = 1; cy <
CROSSES; cy++)
370 float _x = cx * cross_x_step, _y = cy * cross_y_step;
371 dt_draw_line(cr, _x - length_cross, _y, _x + length_cross, _y);
372 dt_draw_line(cr, _x, _y - length_cross, _x, _y + length_cross);
380#define RADIANS(degrees) ((degrees) * (M_PI / 180.))
383 gboolean goldenTriangle, gboolean goldenSpiralSection, gboolean goldenSpiral)
406 if(goldenSpiralSection)
421 cairo_new_sub_path(cr);
427 cairo_new_sub_path(cr);
433 cairo_new_sub_path(cr);
439 cairo_new_sub_path(cr);
445 cairo_new_sub_path(cr);
451 cairo_new_sub_path(cr);
457 cairo_new_sub_path(cr);
463 cairo_new_sub_path(cr);
476 const float w,
const float h,
477 const float zoom_scale,
void *user_data)
482 const float w,
const float h,
483 const float zoom_scale,
void *user_data)
488 const float w,
const float h,
489 const float zoom_scale,
void *user_data)
494 const float w,
const float h,
495 const float zoom_scale,
void *user_data)
500 const float w,
const float h,
501 const float zoom_scale,
void *user_data)
506 const float w,
const float h,
507 const float zoom_scale,
void *user_data)
512 const float w,
const float h,
513 const float zoom_scale,
void *user_data)
517 if(user_data) extra = GPOINTER_TO_INT(user_data);
530 dt_guides_q_rect(&R2, w_g - w_2, h_2 - h_g, w - w_g + 1 - (w - 2 * w_2), h_g);
539 cr, &R1, &R2, &R3, &R4, &R5, &R6, &R7, (extra ==
GOLDEN_SECTION || extra ==
GOLDEN_ALL),
FALSE,
546 void *user_data, GDestroyNotify free,
547 gboolean support_flip)
556 *list = g_list_append(*list, guide);
582 GList *guides = NULL;
605 if((guide && guide->
widget))
608 if(w) gtk_widget_destroy(w);
611 gtk_container_add(GTK_CONTAINER(gw->
g_widgets), extra);
612 gtk_widget_show_all(extra);
668 const int overlay_color =
dt_conf_get_int(
"darkroom/ui/overlay_color");
705 GtkWidget *pop = gtk_popover_new(button);
709 g_object_set_data_full(G_OBJECT(pop),
"guides-settings", gw, g_free);
713 GtkWidget *lb = gtk_label_new(_(
"global guide overlay settings"));
714 gtk_label_set_justify(GTK_LABEL(lb), GTK_JUSTIFY_CENTER);
716 gtk_box_pack_start(GTK_BOX(vbox), lb,
TRUE,
TRUE, 0);
738 gtk_box_pack_start(GTK_BOX(vbox), gtk_separator_new(GTK_ORIENTATION_HORIZONTAL),
TRUE,
TRUE, 0);
754 gtk_widget_set_tooltip_text(contrast, N_(
"set the contrast between the lightest and darkest part of the guide overlays"));
756 gtk_box_pack_start(GTK_BOX(vbox), contrast,
TRUE,
TRUE, 0);
759 gtk_container_add(GTK_CONTAINER(pop), vbox);
761 gtk_widget_show_all(vbox);
784 const float zoom_scale)
813 cairo_set_dash(cr, &dashes, 0, 0);
819 if(
flip == 1 ||
flip == 3) cairo_scale(cr, -1, 1);
821 if(
flip == 2 ||
flip == 3) cairo_scale(cr, 1, -1);
826 cairo_stroke_preserve(cr);
827 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,...)
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)
void dt_conf_set_float(const char *name, float val)
float dt_conf_get_float(const char *name)
gchar * dt_conf_get_string(const char *name)
void dt_conf_set_int(const char *name, int val)
int dt_conf_get_int(const char *name)
void dt_conf_set_string(const char *name, const char *val)
void dt_control_queue_redraw_center()
request redraw of center window. This redraws the center view within a gdk critical section to preven...
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
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)
void dt_gui_add_class(GtkWidget *widget, const gchar *class_name)
#define DT_GUI_BOX_SPACING
#define DT_PIXEL_APPLY_DPI(value)
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)
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 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)
void dt_guides_cleanup(GList *guides)
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_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)
struct _GtkWidget GtkWidget
const float const int flip
struct dt_gui_gtk_t * gui
struct dt_bauhaus_t * bauhaus
struct dt_view_manager_t * view_manager
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)