[gnome-photos/wip/rishi/shadhi: 3/3] tool-colors: Add gegl:shadows-highlights
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/shadhi: 3/3] tool-colors: Add gegl:shadows-highlights
- Date: Mon, 30 Oct 2017 06:39:13 +0000 (UTC)
commit cb6db4827590c8d8afb0fb0d430e7b6290914d2e
Author: Umang Jain <mailumangjain gmail com>
Date: Wed Oct 25 18:12:37 2017 +0530
tool-colors: Add gegl:shadows-highlights
https://bugzilla.gnome.org/show_bug.cgi?id=788201
src/photos-tool-colors.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 113 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-tool-colors.c b/src/photos-tool-colors.c
index d2b37f7..573bd29 100644
--- a/src/photos-tool-colors.c
+++ b/src/photos-tool-colors.c
@@ -1,6 +1,7 @@
/*
* Photos - access, organize and share your photos on GNOME
* Copyright © 2015 – 2017 Red Hat, Inc.
+ * Copyright © 2017 Umang Jain
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -40,15 +41,19 @@ struct _PhotosToolColors
GAction *blacks_exposure;
GAction *brightness_contrast;
GAction *saturation;
+ GAction *shadows_highlights;
GtkWidget *blacks_scale;
GtkWidget *brightness_scale;
GtkWidget *contrast_scale;
GtkWidget *exposure_scale;
GtkWidget *grid;
+ GtkWidget *highlights_scale;
GtkWidget *saturation_scale;
+ GtkWidget *shadows_scale;
guint blacks_exposure_value_changed_id;
guint brightness_contrast_value_changed_id;
guint saturation_value_changed_id;
+ guint shadows_highlights_value_changed_id;
};
@@ -76,10 +81,18 @@ static const gdouble EXPOSURE_DEFAULT = 0.0;
static const gdouble EXPOSURE_MAXIMUM = 3.0;
static const gdouble EXPOSURE_MINIMUM = -3.0;
static const gdouble EXPOSURE_STEP = 0.3;
+static const gdouble HIGHLIGHTS_DEFAULT = 0.0;
+static const gdouble HIGHLIGHTS_MAXIMUM = 60.0;
+static const gdouble HIGHLIGHTS_MINIMUM = -60.0;
+static const gdouble HIGHLIGHTS_STEP = 2.0;
static const gdouble SATURATION_DEFAULT = 1.0;
static const gdouble SATURATION_MAXIMUM = 2.0;
static const gdouble SATURATION_MINIMUM = 0.0;
static const gdouble SATURATION_STEP = 0.1;
+static const gdouble SHADOWS_DEFAULT = 0.0;
+static const gdouble SHADOWS_MAXIMUM = 60.0;
+static const gdouble SHADOWS_MINIMUM = -60.0;
+static const gdouble SHADOWS_STEP = 2.0;
static gboolean
@@ -107,6 +120,30 @@ photos_tool_colors_blacks_exposure_value_changed_timeout (gpointer user_data)
static gboolean
+photos_tool_colors_shadows_highlights_value_changed_timeout (gpointer user_data)
+{
+ PhotosToolColors *self = PHOTOS_TOOL_COLORS (user_data);
+ GVariantBuilder parameter;
+ GVariantType *parameter_type;
+ gdouble shadows;
+ gdouble highlights;
+
+ shadows = gtk_range_get_value (GTK_RANGE (self->shadows_scale));
+ highlights = gtk_range_get_value (GTK_RANGE (self->highlights_scale));
+
+ parameter_type = g_variant_type_new ("a{sd}");
+ g_variant_builder_init (¶meter, parameter_type);
+ g_variant_builder_add (¶meter, "{sd}", "shadows", shadows);
+ g_variant_builder_add (¶meter, "{sd}", "highlights", highlights);
+ g_action_activate (self->shadows_highlights, g_variant_builder_end (¶meter));
+
+ g_variant_type_free (parameter_type);
+ self->shadows_highlights_value_changed_id = 0;
+ return G_SOURCE_REMOVE;
+}
+
+
+static gboolean
photos_tool_colors_brightness_contrast_value_changed_timeout (gpointer user_data)
{
PhotosToolColors *self = PHOTOS_TOOL_COLORS (user_data);
@@ -186,6 +223,19 @@ photos_tool_colors_saturation_value_changed (PhotosToolColors *self)
static void
+photos_tool_colors_shadows_highlights_value_changed (PhotosToolColors *self)
+{
+ if (self->shadows_highlights_value_changed_id != 0)
+ g_source_remove (self->shadows_highlights_value_changed_id);
+
+ self->shadows_highlights_value_changed_id
+ = g_timeout_add (150,
+ photos_tool_colors_shadows_highlights_value_changed_timeout,
+ self);
+}
+
+
+static void
photos_tool_colors_activate (PhotosTool *tool, PhotosBaseItem *item, PhotosImageView *view)
{
PhotosToolColors *self = PHOTOS_TOOL_COLORS (tool);
@@ -194,7 +244,9 @@ photos_tool_colors_activate (PhotosTool *tool, PhotosBaseItem *item, PhotosImage
gdouble contrast;
gdouble contrast_real;
gdouble exposure;
+ gdouble highlights;
gdouble saturation;
+ gdouble shadows;
if (photos_base_item_operation_get (item,
"gegl:brightness-contrast",
@@ -219,11 +271,23 @@ photos_tool_colors_activate (PhotosTool *tool, PhotosBaseItem *item, PhotosImage
if (!photos_base_item_operation_get (item, "photos:saturation", "scale", &saturation, NULL))
saturation = SATURATION_DEFAULT;
+ if (!photos_base_item_operation_get (item,
+ "gegl:shadows-highlights",
+ "shadows", &shadows,
+ "highlights", &highlights,
+ NULL))
+ {
+ shadows = SHADOWS_DEFAULT;
+ highlights = HIGHLIGHTS_DEFAULT;
+ }
+
blacks = CLAMP (blacks, BLACKS_MINIMUM, BLACKS_MAXIMUM);
brightness = CLAMP (brightness, BRIGHTNESS_MINIMUM, BRIGHTNESS_MAXIMUM);
contrast = CLAMP (contrast, CONTRAST_MINIMUM, CONTRAST_MAXIMUM);
exposure = CLAMP (exposure, EXPOSURE_MINIMUM, EXPOSURE_MAXIMUM);
+ highlights = CLAMP (highlights, HIGHLIGHTS_MINIMUM, HIGHLIGHTS_MAXIMUM);
saturation = CLAMP (saturation, SATURATION_MINIMUM, SATURATION_MAXIMUM);
+ shadows = CLAMP (shadows, SHADOWS_MINIMUM, SHADOWS_MAXIMUM);
g_signal_handlers_block_by_func (self->blacks_scale, photos_tool_colors_blacks_exposure_value_changed,
self);
g_signal_handlers_block_by_func (self->brightness_scale,
@@ -233,12 +297,16 @@ photos_tool_colors_activate (PhotosTool *tool, PhotosBaseItem *item, PhotosImage
photos_tool_colors_brightness_contrast_value_changed,
self);
g_signal_handlers_block_by_func (self->exposure_scale, photos_tool_colors_blacks_exposure_value_changed,
self);
+ g_signal_handlers_block_by_func (self->highlights_scale,
photos_tool_colors_shadows_highlights_value_changed, self);
g_signal_handlers_block_by_func (self->saturation_scale, photos_tool_colors_saturation_value_changed,
self);
+ g_signal_handlers_block_by_func (self->shadows_scale, photos_tool_colors_shadows_highlights_value_changed,
self);
gtk_range_set_value (GTK_RANGE (self->blacks_scale), blacks);
gtk_range_set_value (GTK_RANGE (self->brightness_scale), brightness);
gtk_range_set_value (GTK_RANGE (self->contrast_scale), contrast);
gtk_range_set_value (GTK_RANGE (self->exposure_scale), exposure);
+ gtk_range_set_value (GTK_RANGE (self->highlights_scale), highlights);
gtk_range_set_value (GTK_RANGE (self->saturation_scale), saturation);
+ gtk_range_set_value (GTK_RANGE (self->shadows_scale), shadows);
g_signal_handlers_unblock_by_func (self->blacks_scale, photos_tool_colors_blacks_exposure_value_changed,
self);
g_signal_handlers_unblock_by_func (self->brightness_scale,
photos_tool_colors_brightness_contrast_value_changed,
@@ -247,7 +315,9 @@ photos_tool_colors_activate (PhotosTool *tool, PhotosBaseItem *item, PhotosImage
photos_tool_colors_brightness_contrast_value_changed,
self);
g_signal_handlers_unblock_by_func (self->exposure_scale, photos_tool_colors_blacks_exposure_value_changed,
self);
+ g_signal_handlers_unblock_by_func (self->highlights_scale,
photos_tool_colors_shadows_highlights_value_changed, self);
g_signal_handlers_unblock_by_func (self->saturation_scale, photos_tool_colors_saturation_value_changed,
self);
+ g_signal_handlers_unblock_by_func (self->shadows_scale,
photos_tool_colors_shadows_highlights_value_changed, self);
g_signal_emit_by_name (self, "activated");
}
@@ -286,6 +356,9 @@ photos_tool_colors_finalize (GObject *object)
if (self->saturation_value_changed_id != 0)
g_source_remove (self->saturation_value_changed_id);
+ if (self->shadows_highlights_value_changed_id != 0)
+ g_source_remove (self->shadows_highlights_value_changed_id);
+
G_OBJECT_CLASS (photos_tool_colors_parent_class)->dispose (object);
}
@@ -302,6 +375,7 @@ photos_tool_colors_init (PhotosToolColors *self)
self->blacks_exposure = g_action_map_lookup_action (G_ACTION_MAP (app), "blacks-exposure-current");
self->brightness_contrast = g_action_map_lookup_action (G_ACTION_MAP (app), "brightness-contrast-current");
self->saturation = g_action_map_lookup_action (G_ACTION_MAP (app), "saturation-current");
+ self->shadows_highlights = g_action_map_lookup_action (G_ACTION_MAP (app), "shadows-highlights-current");
self->grid = g_object_ref_sink (gtk_grid_new ());
gtk_orientable_set_orientation (GTK_ORIENTABLE (self->grid), GTK_ORIENTATION_VERTICAL);
@@ -413,6 +487,45 @@ photos_tool_colors_init (PhotosToolColors *self)
"value-changed",
G_CALLBACK (photos_tool_colors_saturation_value_changed),
self);
+
+ label = gtk_label_new (_("Shadows"));
+ gtk_widget_set_halign (label, GTK_ALIGN_START);
+ context = gtk_widget_get_style_context (label);
+ gtk_style_context_add_class (context, "dim-label");
+ gtk_container_add (GTK_CONTAINER (box), label);
+
+ self->shadows_scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
+ SHADOWS_MINIMUM,
+ SHADOWS_MAXIMUM,
+ SHADOWS_STEP);
+ gtk_widget_set_hexpand (self->shadows_scale, TRUE);
+ gtk_scale_add_mark (GTK_SCALE (self->shadows_scale), SHADOWS_DEFAULT, GTK_POS_BOTTOM, NULL);
+ gtk_scale_set_draw_value (GTK_SCALE (self->shadows_scale), FALSE);
+ gtk_container_add (GTK_CONTAINER (box), self->shadows_scale);
+ g_signal_connect_swapped (self->shadows_scale,
+ "value-changed",
+ G_CALLBACK (photos_tool_colors_shadows_highlights_value_changed),
+ self);
+
+ label = gtk_label_new (_("Highlights"));
+ gtk_widget_set_halign (label, GTK_ALIGN_START);
+ context = gtk_widget_get_style_context (label);
+ gtk_style_context_add_class (context, "dim-label");
+ gtk_container_add (GTK_CONTAINER (box), label);
+
+ self->highlights_scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
+ HIGHLIGHTS_MINIMUM,
+ HIGHLIGHTS_MAXIMUM,
+ HIGHLIGHTS_STEP);
+ gtk_widget_set_hexpand (self->highlights_scale, TRUE);
+ gtk_scale_add_mark (GTK_SCALE (self->highlights_scale), SHADOWS_DEFAULT, GTK_POS_BOTTOM, NULL);
+ gtk_scale_set_draw_value (GTK_SCALE (self->highlights_scale), FALSE);
+ gtk_container_add (GTK_CONTAINER (box), self->highlights_scale);
+ g_signal_connect_swapped (self->highlights_scale,
+ "value-changed",
+ G_CALLBACK (photos_tool_colors_shadows_highlights_value_changed),
+ self);
+
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]