2017-08-01 09:18:50 -04:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gegl.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
|
2017-08-03 01:05:44 -04:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2017-08-01 14:04:28 -04:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2017-08-01 09:18:50 -04:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "tools-types.h"
|
|
|
|
|
|
|
|
#include "operations/gimp-operation-config.h"
|
|
|
|
|
|
|
|
#include "core/gimpdata.h"
|
|
|
|
#include "core/gimpgradient.h"
|
|
|
|
#include "core/gimp-gradients.h"
|
2017-08-03 01:05:44 -04:00
|
|
|
#include "core/gimpimage.h"
|
2017-08-01 09:18:50 -04:00
|
|
|
|
2017-08-03 01:05:44 -04:00
|
|
|
#include "widgets/gimpcolorpanel.h"
|
|
|
|
#include "widgets/gimpeditor.h"
|
2017-08-01 09:18:50 -04:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
|
|
|
|
|
|
|
#include "display/gimpdisplay.h"
|
2017-08-03 01:05:44 -04:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2017-08-02 16:31:10 -04:00
|
|
|
#include "display/gimptoolgui.h"
|
2017-08-01 09:18:50 -04:00
|
|
|
#include "display/gimptoolline.h"
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
#include "gimpgradientoptions.h"
|
|
|
|
#include "gimpgradienttool.h"
|
|
|
|
#include "gimpgradienttool-editor.h"
|
2017-08-01 09:18:50 -04:00
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2017-08-01 14:04:28 -04:00
|
|
|
#define EPSILON 2e-10
|
|
|
|
|
|
|
|
|
2017-08-03 01:05:44 -04:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
DIRECTION_NONE,
|
|
|
|
DIRECTION_LEFT,
|
|
|
|
DIRECTION_RIGHT
|
|
|
|
} Direction;
|
|
|
|
|
|
|
|
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/* line endpoints at the beginning of the operation */
|
|
|
|
gdouble start_x;
|
|
|
|
gdouble start_y;
|
|
|
|
gdouble end_x;
|
|
|
|
gdouble end_y;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
/* copy of the gradient at the beginning of the operation, owned by the gradient
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
* info, or NULL, if the gradient isn't affected
|
|
|
|
*/
|
|
|
|
GimpGradient *gradient;
|
|
|
|
|
|
|
|
/* handle added by the operation, or HANDLE_NONE */
|
|
|
|
gint added_handle;
|
|
|
|
/* handle removed by the operation, or HANDLE_NONE */
|
|
|
|
gint removed_handle;
|
|
|
|
/* selected handle at the end of the operation, or HANDLE_NONE */
|
|
|
|
gint selected_handle;
|
2018-04-14 00:52:20 +02:00
|
|
|
} GradientInfo;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
|
|
|
|
2017-08-01 09:18:50 -04:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
static gboolean gimp_gradient_tool_editor_line_can_add_slider (GimpToolLine *line,
|
|
|
|
gdouble value,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
static gint gimp_gradient_tool_editor_line_add_slider (GimpToolLine *line,
|
|
|
|
gdouble value,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
static void gimp_gradient_tool_editor_line_prepare_to_remove_slider (GimpToolLine *line,
|
|
|
|
gint slider,
|
|
|
|
gboolean remove,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
static void gimp_gradient_tool_editor_line_remove_slider (GimpToolLine *line,
|
|
|
|
gint slider,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
static void gimp_gradient_tool_editor_line_selection_changed (GimpToolLine *line,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
static gboolean gimp_gradient_tool_editor_line_handle_clicked (GimpToolLine *line,
|
|
|
|
gint handle,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonPressType press_type,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static void gimp_gradient_tool_editor_gui_response (GimpToolGui *gui,
|
|
|
|
gint response_id,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static void gimp_gradient_tool_editor_color_entry_color_clicked (GimpColorButton *button,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
static void gimp_gradient_tool_editor_color_entry_color_changed (GimpColorButton *button,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
static void gimp_gradient_tool_editor_color_entry_color_response (GimpColorButton *button,
|
|
|
|
GimpColorDialogState state,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static void gimp_gradient_tool_editor_color_entry_type_changed (GtkComboBox *combo,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static void gimp_gradient_tool_editor_endpoint_se_value_changed (GimpSizeEntry *se,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static void gimp_gradient_tool_editor_stop_se_value_changed (GimpSizeEntry *se,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static void gimp_gradient_tool_editor_stop_delete_clicked (GtkWidget *button,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static void gimp_gradient_tool_editor_midpoint_se_value_changed (GimpSizeEntry *se,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static void gimp_gradient_tool_editor_midpoint_type_changed (GtkComboBox *combo,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static void gimp_gradient_tool_editor_midpoint_color_changed (GtkComboBox *combo,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static void gimp_gradient_tool_editor_midpoint_new_stop_clicked (GtkWidget *button,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
static void gimp_gradient_tool_editor_midpoint_center_clicked (GtkWidget *button,
|
|
|
|
GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static gboolean gimp_gradient_tool_editor_flush_idle (GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static gboolean gimp_gradient_tool_editor_is_gradient_editable (GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static gboolean gimp_gradient_tool_editor_handle_is_endpoint (GimpGradientTool *gradient_tool,
|
|
|
|
gint handle);
|
|
|
|
static gboolean gimp_gradient_tool_editor_handle_is_stop (GimpGradientTool *gradient_tool,
|
|
|
|
gint handle);
|
|
|
|
static gboolean gimp_gradient_tool_editor_handle_is_midpoint (GimpGradientTool *gradient_tool,
|
|
|
|
gint handle);
|
|
|
|
static GimpGradientSegment * gimp_gradient_tool_editor_handle_get_segment (GimpGradientTool *gradient_tool,
|
|
|
|
gint handle);
|
|
|
|
|
|
|
|
static void gimp_gradient_tool_editor_block_handlers (GimpGradientTool *gradient_tool);
|
|
|
|
static void gimp_gradient_tool_editor_unblock_handlers (GimpGradientTool *gradient_tool);
|
|
|
|
static gboolean gimp_gradient_tool_editor_are_handlers_blocked (GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static void gimp_gradient_tool_editor_freeze_gradient (GimpGradientTool *gradient_tool);
|
|
|
|
static void gimp_gradient_tool_editor_thaw_gradient (GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static gint gimp_gradient_tool_editor_add_stop (GimpGradientTool *gradient_tool,
|
|
|
|
gdouble value);
|
|
|
|
static void gimp_gradient_tool_editor_delete_stop (GimpGradientTool *gradient_tool,
|
|
|
|
gint slider);
|
|
|
|
static gint gimp_gradient_tool_editor_midpoint_to_stop (GimpGradientTool *gradient_tool,
|
|
|
|
gint slider);
|
|
|
|
|
|
|
|
static void gimp_gradient_tool_editor_update_sliders (GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static void gimp_gradient_tool_editor_purge_gradient_history (GSList **stack);
|
|
|
|
static void gimp_gradient_tool_editor_purge_gradient (GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static GtkWidget * gimp_gradient_tool_editor_color_entry_new (GimpGradientTool *gradient_tool,
|
|
|
|
const gchar *title,
|
|
|
|
Direction direction,
|
|
|
|
GtkWidget *chain_button,
|
|
|
|
GtkWidget **color_panel,
|
|
|
|
GtkWidget **type_combo);
|
|
|
|
static void gimp_gradient_tool_editor_init_endpoint_gui (GimpGradientTool *gradient_tool);
|
|
|
|
static void gimp_gradient_tool_editor_init_stop_gui (GimpGradientTool *gradient_tool);
|
|
|
|
static void gimp_gradient_tool_editor_init_midpoint_gui (GimpGradientTool *gradient_tool);
|
|
|
|
static void gimp_gradient_tool_editor_update_endpoint_gui (GimpGradientTool *gradient_tool,
|
|
|
|
gint selection);
|
|
|
|
static void gimp_gradient_tool_editor_update_stop_gui (GimpGradientTool *gradient_tool,
|
|
|
|
gint selection);
|
|
|
|
static void gimp_gradient_tool_editor_update_midpoint_gui (GimpGradientTool *gradient_tool,
|
|
|
|
gint selection);
|
|
|
|
static void gimp_gradient_tool_editor_update_gui (GimpGradientTool *gradient_tool);
|
|
|
|
|
|
|
|
static GradientInfo * gimp_gradient_tool_editor_gradient_info_new (GimpGradientTool *gradient_tool);
|
|
|
|
static void gimp_gradient_tool_editor_gradient_info_free (GradientInfo *info);
|
|
|
|
static void gimp_gradient_tool_editor_gradient_info_apply (GimpGradientTool *gradient_tool,
|
|
|
|
const GradientInfo *info,
|
|
|
|
gboolean set_selection);
|
|
|
|
static gboolean gimp_gradient_tool_editor_gradient_info_is_trivial (GimpGradientTool *gradient_tool,
|
|
|
|
const GradientInfo *info);
|
2017-08-02 16:31:10 -04:00
|
|
|
|
2017-08-01 09:18:50 -04:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
|
2017-08-01 16:58:13 -04:00
|
|
|
static gboolean
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_line_can_add_slider (GimpToolLine *line,
|
|
|
|
gdouble value,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-08-01 16:58:13 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpGradientOptions *options = GIMP_GRADIENT_TOOL_GET_OPTIONS (gradient_tool);
|
|
|
|
gdouble offset = options->offset / 100.0;
|
2017-08-01 16:58:13 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
return gimp_gradient_tool_editor_is_gradient_editable (gradient_tool) &&
|
2017-08-01 16:58:13 -04:00
|
|
|
value >= offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_line_add_slider (GimpToolLine *line,
|
|
|
|
gdouble value,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-08-01 16:58:13 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpGradientOptions *options = GIMP_GRADIENT_TOOL_GET_OPTIONS (gradient_tool);
|
|
|
|
GimpPaintOptions *paint_options = GIMP_PAINT_OPTIONS (options);
|
|
|
|
gdouble offset = options->offset / 100.0;
|
2017-08-01 16:58:13 -04:00
|
|
|
|
|
|
|
/* adjust slider value according to the offset */
|
|
|
|
value = (value - offset) / (1.0 - offset);
|
|
|
|
|
|
|
|
/* flip the slider value, if necessary */
|
|
|
|
if (paint_options->gradient_options->gradient_reverse)
|
|
|
|
value = 1.0 - value;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
return gimp_gradient_tool_editor_add_stop (gradient_tool, value);
|
2017-08-01 16:58:13 -04:00
|
|
|
}
|
|
|
|
|
2017-10-06 12:11:45 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_line_prepare_to_remove_slider (GimpToolLine *line,
|
|
|
|
gint slider,
|
|
|
|
gboolean remove,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-10-06 12:11:45 -04:00
|
|
|
{
|
|
|
|
if (remove)
|
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GradientInfo *info;
|
2017-11-16 11:47:03 -05:00
|
|
|
GimpGradient *tentative_gradient;
|
2017-10-06 12:11:45 -04:00
|
|
|
|
2017-11-16 11:47:03 -05:00
|
|
|
/* show a tentative gradient, demonstrating the result of actually
|
|
|
|
* removing the slider
|
|
|
|
*/
|
2017-10-06 12:11:45 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
info = gradient_tool->undo_stack->data;
|
2017-10-06 12:11:45 -04:00
|
|
|
|
2017-11-16 11:47:03 -05:00
|
|
|
if (info->added_handle == slider)
|
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
/* see comment in gimp_gradient_tool_editor_delete_stop() */
|
2017-10-06 12:11:45 -04:00
|
|
|
|
2018-02-11 22:23:10 +01:00
|
|
|
gimp_assert (info->gradient != NULL);
|
2017-10-06 12:11:45 -04:00
|
|
|
|
2017-11-16 11:47:03 -05:00
|
|
|
tentative_gradient = g_object_ref (info->gradient);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GimpGradientSegment *seg;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
tentative_gradient =
|
2018-04-14 00:52:20 +02:00
|
|
|
GIMP_GRADIENT (gimp_data_duplicate (GIMP_DATA (gradient_tool->gradient)));
|
2017-11-16 11:47:03 -05:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
seg = gimp_gradient_tool_editor_handle_get_segment (gradient_tool, slider);
|
2017-11-16 11:47:03 -05:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
i = gimp_gradient_segment_range_get_n_segments (gradient_tool->gradient,
|
|
|
|
gradient_tool->gradient->segments,
|
2017-11-16 11:47:03 -05:00
|
|
|
seg) - 1;
|
|
|
|
|
|
|
|
seg = gimp_gradient_segment_get_nth (tentative_gradient->segments, i);
|
|
|
|
|
|
|
|
gimp_gradient_segment_range_merge (tentative_gradient,
|
|
|
|
seg, seg->next, NULL, NULL);
|
|
|
|
}
|
2017-10-06 12:11:45 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_set_tentative_gradient (gradient_tool, tentative_gradient);
|
2017-10-18 14:25:26 -04:00
|
|
|
|
|
|
|
g_object_unref (tentative_gradient);
|
2017-10-06 12:11:45 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_set_tentative_gradient (gradient_tool, NULL);
|
2017-10-06 12:11:45 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-01 17:34:31 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_line_remove_slider (GimpToolLine *line,
|
|
|
|
gint slider,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-08-01 17:34:31 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_delete_stop (gradient_tool, slider);
|
|
|
|
gimp_gradient_tool_set_tentative_gradient (gradient_tool, NULL);
|
2017-08-01 17:34:31 -04:00
|
|
|
}
|
|
|
|
|
2017-08-02 16:31:10 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_line_selection_changed (GimpToolLine *line,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-08-02 16:31:10 -04:00
|
|
|
{
|
2017-08-03 09:15:43 -04:00
|
|
|
gint selection;
|
|
|
|
|
|
|
|
selection =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_selection (GIMP_TOOL_LINE (gradient_tool->widget));
|
2017-08-03 09:15:43 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gradient_tool->gui)
|
2017-08-03 01:05:44 -04:00
|
|
|
{
|
|
|
|
/* hide all color dialogs */
|
|
|
|
gimp_color_panel_dialog_response (
|
2018-04-14 00:52:20 +02:00
|
|
|
GIMP_COLOR_PANEL (gradient_tool->endpoint_color_panel),
|
2017-08-03 01:05:44 -04:00
|
|
|
GIMP_COLOR_DIALOG_OK);
|
2017-08-03 09:15:43 -04:00
|
|
|
gimp_color_panel_dialog_response (
|
2018-04-14 00:52:20 +02:00
|
|
|
GIMP_COLOR_PANEL (gradient_tool->stop_left_color_panel),
|
2017-08-03 09:15:43 -04:00
|
|
|
GIMP_COLOR_DIALOG_OK);
|
|
|
|
gimp_color_panel_dialog_response (
|
2018-04-14 00:52:20 +02:00
|
|
|
GIMP_COLOR_PANEL (gradient_tool->stop_right_color_panel),
|
2017-08-03 09:15:43 -04:00
|
|
|
GIMP_COLOR_DIALOG_OK);
|
|
|
|
|
|
|
|
/* reset the stop colors chain button */
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gimp_gradient_tool_editor_handle_is_stop (gradient_tool, selection))
|
2017-08-03 09:15:43 -04:00
|
|
|
{
|
|
|
|
const GimpGradientSegment *seg;
|
|
|
|
gboolean homogeneous;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
seg = gimp_gradient_tool_editor_handle_get_segment (gradient_tool,
|
|
|
|
selection);
|
2017-08-03 09:15:43 -04:00
|
|
|
|
|
|
|
homogeneous = seg->right_color.r == seg->next->left_color.r &&
|
|
|
|
seg->right_color.g == seg->next->left_color.g &&
|
|
|
|
seg->right_color.b == seg->next->left_color.b &&
|
|
|
|
seg->right_color.a == seg->next->left_color.a &&
|
|
|
|
seg->right_color_type == seg->next->left_color_type;
|
|
|
|
|
|
|
|
gimp_chain_button_set_active (
|
2018-04-14 00:52:20 +02:00
|
|
|
GIMP_CHAIN_BUTTON (gradient_tool->stop_chain_button), homogeneous);
|
2017-08-03 09:15:43 -04:00
|
|
|
}
|
2017-08-03 01:05:44 -04:00
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_update_gui (gradient_tool);
|
2017-08-02 16:31:10 -04:00
|
|
|
}
|
|
|
|
|
2017-08-01 18:45:13 -04:00
|
|
|
static gboolean
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_line_handle_clicked (GimpToolLine *line,
|
|
|
|
gint handle,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonPressType press_type,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-08-01 18:45:13 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gimp_gradient_tool_editor_handle_is_midpoint (gradient_tool, handle))
|
2017-08-01 18:45:13 -04:00
|
|
|
{
|
|
|
|
if (press_type == GIMP_BUTTON_PRESS_DOUBLE &&
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_is_gradient_editable (gradient_tool))
|
2017-08-01 18:45:13 -04:00
|
|
|
{
|
2017-08-03 13:42:09 -04:00
|
|
|
gint stop;
|
2017-08-01 18:45:13 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
stop = gimp_gradient_tool_editor_midpoint_to_stop (gradient_tool, handle);
|
2017-08-01 18:45:13 -04:00
|
|
|
|
2017-08-03 13:42:09 -04:00
|
|
|
gimp_tool_line_set_selection (line, stop);
|
2017-08-01 18:45:13 -04:00
|
|
|
|
|
|
|
/* return FALSE, so that the new slider can be dragged immediately */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2017-08-02 16:31:10 -04:00
|
|
|
|
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_gui_response (GimpToolGui *gui,
|
|
|
|
gint response_id,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-08-02 16:31:10 -04:00
|
|
|
{
|
|
|
|
switch (response_id)
|
|
|
|
{
|
|
|
|
default:
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_set_selection (GIMP_TOOL_LINE (gradient_tool->widget),
|
2017-08-02 16:31:10 -04:00
|
|
|
GIMP_TOOL_LINE_HANDLE_NONE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_color_entry_color_clicked (GimpColorButton *button,
|
|
|
|
GimpGradientTool *gradient_tool)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_start_edit (gradient_tool);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
|
|
|
|
2017-08-03 01:05:44 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_color_entry_color_changed (GimpColorButton *button,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-08-03 01:05:44 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpGradientOptions *options = GIMP_GRADIENT_TOOL_GET_OPTIONS (gradient_tool);
|
2017-08-03 01:05:44 -04:00
|
|
|
GimpPaintOptions *paint_options = GIMP_PAINT_OPTIONS (options);
|
|
|
|
gint selection;
|
|
|
|
GimpRGB color;
|
|
|
|
Direction direction;
|
|
|
|
GtkWidget *chain_button;
|
|
|
|
GimpGradientSegment *seg;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gimp_gradient_tool_editor_are_handlers_blocked (gradient_tool))
|
2017-08-03 01:05:44 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
selection =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_selection (GIMP_TOOL_LINE (gradient_tool->widget));
|
2017-08-03 01:05:44 -04:00
|
|
|
|
|
|
|
gimp_color_button_get_color (button, &color);
|
|
|
|
|
|
|
|
direction =
|
|
|
|
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button),
|
2018-04-14 00:52:20 +02:00
|
|
|
"gimp-gradient-tool-editor-direction"));
|
2017-08-03 01:05:44 -04:00
|
|
|
chain_button = g_object_get_data (G_OBJECT (button),
|
2018-04-14 00:52:20 +02:00
|
|
|
"gimp-gradient-tool-editor-chain-button");
|
2017-08-03 01:05:44 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_start_edit (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_freeze_gradient (gradient_tool);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
|
|
|
/* swap the endpoint handles, if necessary */
|
|
|
|
if (paint_options->gradient_options->gradient_reverse)
|
|
|
|
{
|
|
|
|
switch (selection)
|
|
|
|
{
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_START:
|
|
|
|
selection = GIMP_TOOL_LINE_HANDLE_END;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_END:
|
|
|
|
selection = GIMP_TOOL_LINE_HANDLE_START;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
seg = gimp_gradient_tool_editor_handle_get_segment (gradient_tool, selection);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
|
|
|
switch (selection)
|
|
|
|
{
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_START:
|
|
|
|
seg->left_color = color;
|
|
|
|
seg->left_color_type = GIMP_GRADIENT_COLOR_FIXED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_END:
|
|
|
|
seg->right_color = color;
|
|
|
|
seg->right_color_type = GIMP_GRADIENT_COLOR_FIXED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (direction == DIRECTION_LEFT ||
|
|
|
|
(chain_button &&
|
|
|
|
gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (chain_button))))
|
|
|
|
{
|
|
|
|
seg->right_color = color;
|
|
|
|
seg->right_color_type = GIMP_GRADIENT_COLOR_FIXED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (direction == DIRECTION_RIGHT ||
|
|
|
|
(chain_button &&
|
|
|
|
gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (chain_button))))
|
|
|
|
{
|
|
|
|
seg->next->left_color = color;
|
|
|
|
seg->next->left_color_type = GIMP_GRADIENT_COLOR_FIXED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_thaw_gradient (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_end_edit (gradient_tool, FALSE);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_color_entry_color_response (GimpColorButton *button,
|
|
|
|
GimpColorDialogState state,
|
|
|
|
GimpGradientTool *gradient_tool)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_end_edit (gradient_tool, FALSE);
|
2017-08-03 01:05:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_color_entry_type_changed (GtkComboBox *combo,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-08-03 01:05:44 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpGradientOptions *options = GIMP_GRADIENT_TOOL_GET_OPTIONS (gradient_tool);
|
2017-08-03 01:05:44 -04:00
|
|
|
GimpPaintOptions *paint_options = GIMP_PAINT_OPTIONS (options);
|
|
|
|
gint selection;
|
|
|
|
gint color_type;
|
|
|
|
Direction direction;
|
|
|
|
GtkWidget *chain_button;
|
|
|
|
GimpGradientSegment *seg;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gimp_gradient_tool_editor_are_handlers_blocked (gradient_tool))
|
2017-08-03 01:05:44 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
selection =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_selection (GIMP_TOOL_LINE (gradient_tool->widget));
|
2017-08-03 01:05:44 -04:00
|
|
|
|
|
|
|
if (! gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (combo), &color_type))
|
|
|
|
return;
|
|
|
|
|
|
|
|
direction =
|
|
|
|
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (combo),
|
2018-04-14 00:52:20 +02:00
|
|
|
"gimp-gradient-tool-editor-direction"));
|
2017-08-03 01:05:44 -04:00
|
|
|
chain_button = g_object_get_data (G_OBJECT (combo),
|
2018-04-14 00:52:20 +02:00
|
|
|
"gimp-gradient-tool-editor-chain-button");
|
2017-08-03 01:05:44 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_start_edit (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_freeze_gradient (gradient_tool);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
|
|
|
/* swap the endpoint handles, if necessary */
|
|
|
|
if (paint_options->gradient_options->gradient_reverse)
|
|
|
|
{
|
|
|
|
switch (selection)
|
|
|
|
{
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_START:
|
|
|
|
selection = GIMP_TOOL_LINE_HANDLE_END;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_END:
|
|
|
|
selection = GIMP_TOOL_LINE_HANDLE_START;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
seg = gimp_gradient_tool_editor_handle_get_segment (gradient_tool, selection);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
|
|
|
switch (selection)
|
|
|
|
{
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_START:
|
|
|
|
seg->left_color_type = color_type;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_END:
|
|
|
|
seg->right_color_type = color_type;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (direction == DIRECTION_LEFT ||
|
|
|
|
(chain_button &&
|
|
|
|
gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (chain_button))))
|
|
|
|
{
|
|
|
|
seg->right_color_type = color_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (direction == DIRECTION_RIGHT ||
|
|
|
|
(chain_button &&
|
|
|
|
gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (chain_button))))
|
|
|
|
{
|
|
|
|
seg->next->left_color_type = color_type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_thaw_gradient (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_end_edit (gradient_tool, FALSE);
|
2017-08-03 01:05:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_endpoint_se_value_changed (GimpSizeEntry *se,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-08-03 01:05:44 -04:00
|
|
|
{
|
|
|
|
gint selection;
|
|
|
|
gdouble x;
|
|
|
|
gdouble y;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gimp_gradient_tool_editor_are_handlers_blocked (gradient_tool))
|
2017-08-03 01:05:44 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
selection =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_selection (GIMP_TOOL_LINE (gradient_tool->widget));
|
2017-08-03 01:05:44 -04:00
|
|
|
|
2018-05-08 11:34:43 -04:00
|
|
|
if (selection == GIMP_TOOL_LINE_HANDLE_NONE)
|
|
|
|
return;
|
|
|
|
|
2017-08-03 01:05:44 -04:00
|
|
|
x = gimp_size_entry_get_refval (se, 0);
|
|
|
|
y = gimp_size_entry_get_refval (se, 1);
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_start_edit (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_block_handlers (gradient_tool);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
|
|
|
switch (selection)
|
|
|
|
{
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_START:
|
2018-04-14 00:52:20 +02:00
|
|
|
g_object_set (gradient_tool->widget,
|
2017-08-03 01:05:44 -04:00
|
|
|
"x1", x,
|
|
|
|
"y1", y,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_END:
|
2018-04-14 00:52:20 +02:00
|
|
|
g_object_set (gradient_tool->widget,
|
2017-08-03 01:05:44 -04:00
|
|
|
"x2", x,
|
|
|
|
"y2", y,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-02-11 22:23:10 +01:00
|
|
|
gimp_assert_not_reached ();
|
2017-08-03 01:05:44 -04:00
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_unblock_handlers (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_end_edit (gradient_tool, FALSE);
|
2017-08-03 01:05:44 -04:00
|
|
|
}
|
|
|
|
|
2017-08-03 09:15:43 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_stop_se_value_changed (GimpSizeEntry *se,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-08-03 09:15:43 -04:00
|
|
|
{
|
|
|
|
gint selection;
|
|
|
|
gdouble value;
|
|
|
|
GimpGradientSegment *seg;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gimp_gradient_tool_editor_are_handlers_blocked (gradient_tool))
|
2017-08-03 09:15:43 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
selection =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_selection (GIMP_TOOL_LINE (gradient_tool->widget));
|
2017-08-03 09:15:43 -04:00
|
|
|
|
|
|
|
if (selection == GIMP_TOOL_LINE_HANDLE_NONE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
value = gimp_size_entry_get_refval (se, 0) / 100.0;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_start_edit (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_freeze_gradient (gradient_tool);
|
2017-08-03 09:15:43 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
seg = gimp_gradient_tool_editor_handle_get_segment (gradient_tool, selection);
|
2017-08-03 09:15:43 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_segment_range_compress (gradient_tool->gradient,
|
2017-08-03 09:15:43 -04:00
|
|
|
seg, seg,
|
|
|
|
seg->left, value);
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_segment_range_compress (gradient_tool->gradient,
|
2017-08-03 09:15:43 -04:00
|
|
|
seg->next, seg->next,
|
|
|
|
value, seg->next->right);
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_thaw_gradient (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_end_edit (gradient_tool, FALSE);
|
2017-08-03 09:15:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_stop_delete_clicked (GtkWidget *button,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-08-03 09:15:43 -04:00
|
|
|
{
|
|
|
|
gint selection;
|
|
|
|
|
|
|
|
selection =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_selection (GIMP_TOOL_LINE (gradient_tool->widget));
|
2017-08-03 09:15:43 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_delete_stop (gradient_tool, selection);
|
2017-08-03 09:15:43 -04:00
|
|
|
}
|
|
|
|
|
2017-08-03 13:42:09 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_midpoint_se_value_changed (GimpSizeEntry *se,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-08-03 13:42:09 -04:00
|
|
|
{
|
|
|
|
gint selection;
|
|
|
|
gdouble value;
|
|
|
|
GimpGradientSegment *seg;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gimp_gradient_tool_editor_are_handlers_blocked (gradient_tool))
|
2017-08-03 13:42:09 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
selection =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_selection (GIMP_TOOL_LINE (gradient_tool->widget));
|
2017-08-03 13:42:09 -04:00
|
|
|
|
|
|
|
if (selection == GIMP_TOOL_LINE_HANDLE_NONE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
value = gimp_size_entry_get_refval (se, 0) / 100.0;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_start_edit (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_freeze_gradient (gradient_tool);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
seg = gimp_gradient_tool_editor_handle_get_segment (gradient_tool, selection);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
|
|
|
seg->middle = value;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_thaw_gradient (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_end_edit (gradient_tool, FALSE);
|
2017-08-03 13:42:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_midpoint_type_changed (GtkComboBox *combo,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-08-03 13:42:09 -04:00
|
|
|
{
|
|
|
|
gint selection;
|
|
|
|
gint type;
|
|
|
|
GimpGradientSegment *seg;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gimp_gradient_tool_editor_are_handlers_blocked (gradient_tool))
|
2017-08-03 13:42:09 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
selection =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_selection (GIMP_TOOL_LINE (gradient_tool->widget));
|
2017-08-03 13:42:09 -04:00
|
|
|
|
|
|
|
if (! gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (combo), &type))
|
|
|
|
return;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_start_edit (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_freeze_gradient (gradient_tool);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
seg = gimp_gradient_tool_editor_handle_get_segment (gradient_tool, selection);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
|
|
|
seg->type = type;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_thaw_gradient (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_end_edit (gradient_tool, FALSE);
|
2017-08-03 13:42:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_midpoint_color_changed (GtkComboBox *combo,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-08-03 13:42:09 -04:00
|
|
|
{
|
|
|
|
gint selection;
|
|
|
|
gint color;
|
|
|
|
GimpGradientSegment *seg;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gimp_gradient_tool_editor_are_handlers_blocked (gradient_tool))
|
2017-08-03 13:42:09 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
selection =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_selection (GIMP_TOOL_LINE (gradient_tool->widget));
|
2017-08-03 13:42:09 -04:00
|
|
|
|
|
|
|
if (! gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (combo), &color))
|
|
|
|
return;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_start_edit (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_freeze_gradient (gradient_tool);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
seg = gimp_gradient_tool_editor_handle_get_segment (gradient_tool, selection);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
|
|
|
seg->color = color;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_thaw_gradient (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_end_edit (gradient_tool, FALSE);
|
2017-08-03 13:42:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_midpoint_new_stop_clicked (GtkWidget *button,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-08-03 13:42:09 -04:00
|
|
|
{
|
|
|
|
gint selection;
|
|
|
|
gint stop;
|
|
|
|
|
|
|
|
selection =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_selection (GIMP_TOOL_LINE (gradient_tool->widget));
|
2017-08-03 13:42:09 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
stop = gimp_gradient_tool_editor_midpoint_to_stop (gradient_tool, selection);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_set_selection (GIMP_TOOL_LINE (gradient_tool->widget), stop);
|
2017-08-03 13:42:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_midpoint_center_clicked (GtkWidget *button,
|
|
|
|
GimpGradientTool *gradient_tool)
|
2017-08-03 13:42:09 -04:00
|
|
|
{
|
|
|
|
gint selection;
|
|
|
|
GimpGradientSegment *seg;
|
|
|
|
|
|
|
|
selection =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_selection (GIMP_TOOL_LINE (gradient_tool->widget));
|
2017-08-03 13:42:09 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_start_edit (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_freeze_gradient (gradient_tool);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
seg = gimp_gradient_tool_editor_handle_get_segment (gradient_tool, selection);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_segment_range_recenter_handles (gradient_tool->gradient, seg, seg);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_thaw_gradient (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_end_edit (gradient_tool, FALSE);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_flush_idle (GimpGradientTool *gradient_tool)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpDisplay *display = GIMP_TOOL (gradient_tool)->display;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
|
|
|
gimp_image_flush (gimp_display_get_image (display));
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->flush_idle_id = 0;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
|
|
|
return G_SOURCE_REMOVE;
|
2017-08-03 13:42:09 -04:00
|
|
|
}
|
|
|
|
|
2017-08-01 09:18:50 -04:00
|
|
|
static gboolean
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_is_gradient_editable (GimpGradientTool *gradient_tool)
|
2017-08-01 09:18:50 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpGradientOptions *options = GIMP_GRADIENT_TOOL_GET_OPTIONS (gradient_tool);
|
2017-08-01 09:18:50 -04:00
|
|
|
|
|
|
|
return ! options->modify_active ||
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_data_is_writable (GIMP_DATA (gradient_tool->gradient));
|
2017-08-01 09:18:50 -04:00
|
|
|
}
|
|
|
|
|
2017-08-01 18:45:13 -04:00
|
|
|
static gboolean
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_handle_is_endpoint (GimpGradientTool *gradient_tool,
|
|
|
|
gint handle)
|
2017-08-01 18:45:13 -04:00
|
|
|
{
|
|
|
|
return handle == GIMP_TOOL_LINE_HANDLE_START ||
|
|
|
|
handle == GIMP_TOOL_LINE_HANDLE_END;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_handle_is_stop (GimpGradientTool *gradient_tool,
|
|
|
|
gint handle)
|
2017-08-01 18:45:13 -04:00
|
|
|
{
|
|
|
|
gint n_sliders;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_sliders (GIMP_TOOL_LINE (gradient_tool->widget), &n_sliders);
|
2017-08-01 18:45:13 -04:00
|
|
|
|
|
|
|
return handle >= 0 && handle < n_sliders / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_handle_is_midpoint (GimpGradientTool *gradient_tool,
|
|
|
|
gint handle)
|
2017-08-01 18:45:13 -04:00
|
|
|
{
|
|
|
|
gint n_sliders;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_sliders (GIMP_TOOL_LINE (gradient_tool->widget), &n_sliders);
|
2017-08-01 18:45:13 -04:00
|
|
|
|
|
|
|
return handle >= n_sliders / 2;
|
|
|
|
}
|
|
|
|
|
2017-08-01 14:04:28 -04:00
|
|
|
static GimpGradientSegment *
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_handle_get_segment (GimpGradientTool *gradient_tool,
|
|
|
|
gint handle)
|
2017-08-01 14:04:28 -04:00
|
|
|
{
|
|
|
|
switch (handle)
|
|
|
|
{
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_START:
|
2018-04-14 00:52:20 +02:00
|
|
|
return gradient_tool->gradient->segments;
|
2017-08-01 14:04:28 -04:00
|
|
|
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_END:
|
2018-04-14 00:52:20 +02:00
|
|
|
return gimp_gradient_segment_get_last (gradient_tool->gradient->segments);
|
2017-08-01 14:04:28 -04:00
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
const GimpControllerSlider *sliders;
|
|
|
|
gint n_sliders;
|
|
|
|
gint seg_i;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
sliders = gimp_tool_line_get_sliders (GIMP_TOOL_LINE (gradient_tool->widget),
|
2017-08-01 14:04:28 -04:00
|
|
|
&n_sliders);
|
|
|
|
|
2018-02-11 22:23:10 +01:00
|
|
|
gimp_assert (handle >= 0 && handle < n_sliders);
|
2017-08-01 14:04:28 -04:00
|
|
|
|
|
|
|
seg_i = GPOINTER_TO_INT (sliders[handle].data);
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
return gimp_gradient_segment_get_nth (gradient_tool->gradient->segments,
|
2017-08-01 14:04:28 -04:00
|
|
|
seg_i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-01 09:18:50 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_block_handlers (GimpGradientTool *gradient_tool)
|
2017-08-01 09:18:50 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->block_handlers_count++;
|
2017-08-01 09:18:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_unblock_handlers (GimpGradientTool *gradient_tool)
|
2017-08-01 09:18:50 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_assert (gradient_tool->block_handlers_count > 0);
|
2017-08-01 09:18:50 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->block_handlers_count--;
|
2017-08-01 09:18:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_are_handlers_blocked (GimpGradientTool *gradient_tool)
|
2017-08-01 09:18:50 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
return gradient_tool->block_handlers_count > 0;
|
2017-08-01 09:18:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_freeze_gradient (GimpGradientTool *gradient_tool)
|
2017-08-01 09:18:50 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpGradientOptions *options = GIMP_GRADIENT_TOOL_GET_OPTIONS (gradient_tool);
|
|
|
|
GimpGradient *custom;
|
|
|
|
GradientInfo *info;
|
2017-08-01 09:18:50 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_block_handlers (gradient_tool);
|
2017-08-01 09:18:50 -04:00
|
|
|
|
|
|
|
custom = gimp_gradients_get_custom (GIMP_CONTEXT (options)->gimp);
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gradient_tool->gradient == custom || options->modify_active)
|
2017-08-01 09:18:50 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_assert (gimp_gradient_tool_editor_is_gradient_editable (gradient_tool));
|
2017-08-01 09:18:50 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_data_freeze (GIMP_DATA (gradient_tool->gradient));
|
2017-08-01 09:18:50 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* copy the active gradient to the custom gradient, and make the custom
|
|
|
|
* gradient active.
|
|
|
|
*/
|
|
|
|
gimp_data_freeze (GIMP_DATA (custom));
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_data_copy (GIMP_DATA (custom), GIMP_DATA (gradient_tool->gradient));
|
2017-08-01 09:18:50 -04:00
|
|
|
|
|
|
|
gimp_context_set_gradient (GIMP_CONTEXT (options), custom);
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_assert (gradient_tool->gradient == custom);
|
|
|
|
gimp_assert (gimp_gradient_tool_editor_is_gradient_editable (gradient_tool));
|
2017-08-01 09:18:50 -04:00
|
|
|
}
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gradient_tool->edit_count > 0)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
info = gradient_tool->undo_stack->data;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
|
|
|
if (! info->gradient)
|
|
|
|
{
|
|
|
|
info->gradient =
|
2018-04-14 00:52:20 +02:00
|
|
|
GIMP_GRADIENT (gimp_data_duplicate (GIMP_DATA (gradient_tool->gradient)));
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
|
|
|
}
|
2017-08-01 09:18:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_thaw_gradient (GimpGradientTool *gradient_tool)
|
2017-08-01 09:18:50 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_data_thaw (GIMP_DATA (gradient_tool->gradient));
|
2017-08-01 09:18:50 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_update_sliders (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_update_gui (gradient_tool);
|
2017-08-01 11:33:36 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_unblock_handlers (gradient_tool);
|
2017-08-01 09:18:50 -04:00
|
|
|
}
|
|
|
|
|
2017-08-01 18:45:13 -04:00
|
|
|
static gint
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_add_stop (GimpGradientTool *gradient_tool,
|
|
|
|
gdouble value)
|
2017-08-01 18:45:13 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpGradientOptions *options = GIMP_GRADIENT_TOOL_GET_OPTIONS (gradient_tool);
|
2018-04-13 22:33:16 +02:00
|
|
|
GimpPaintOptions *paint_options = GIMP_PAINT_OPTIONS (options);
|
2017-08-01 18:45:13 -04:00
|
|
|
GimpGradientSegment *seg;
|
|
|
|
gint stop;
|
2018-04-14 00:52:20 +02:00
|
|
|
GradientInfo *info;
|
2017-08-01 18:45:13 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_start_edit (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_freeze_gradient (gradient_tool);
|
2017-08-01 18:45:13 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_split_at (gradient_tool->gradient,
|
2018-04-13 22:33:16 +02:00
|
|
|
GIMP_CONTEXT (options), NULL, value,
|
|
|
|
paint_options->gradient_options->gradient_blend_color_space,
|
|
|
|
&seg, NULL);
|
2017-08-01 18:45:13 -04:00
|
|
|
|
|
|
|
stop =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_segment_range_get_n_segments (gradient_tool->gradient,
|
|
|
|
gradient_tool->gradient->segments,
|
2017-08-01 18:45:13 -04:00
|
|
|
seg) - 1;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
info = gradient_tool->undo_stack->data;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
info->added_handle = stop;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_thaw_gradient (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_end_edit (gradient_tool, FALSE);
|
2017-08-01 18:45:13 -04:00
|
|
|
|
|
|
|
return stop;
|
|
|
|
}
|
|
|
|
|
2017-08-03 09:15:43 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_delete_stop (GimpGradientTool *gradient_tool,
|
|
|
|
gint slider)
|
2017-08-03 09:15:43 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GradientInfo *info;
|
2017-08-03 09:15:43 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_assert (gimp_gradient_tool_editor_handle_is_stop (gradient_tool, slider));
|
2017-10-09 17:05:14 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_start_edit (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_freeze_gradient (gradient_tool);
|
2017-08-03 09:15:43 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
info = gradient_tool->undo_stack->data;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
|
|
|
if (info->added_handle == slider)
|
2017-11-16 11:47:03 -05:00
|
|
|
{
|
|
|
|
/* when removing a stop that was added as part of the current action,
|
|
|
|
* restore the original gradient at the beginning of the action, rather
|
|
|
|
* than deleting the stop from the current gradient, so that the affected
|
|
|
|
* midpoint returns to its state at the beginning of the action, instead
|
|
|
|
* of being reset.
|
|
|
|
*
|
|
|
|
* note that this assumes that the gradient hasn't changed in any other
|
|
|
|
* way during the action, which is ugly, but currently always true.
|
|
|
|
*/
|
|
|
|
|
2018-02-11 22:23:10 +01:00
|
|
|
gimp_assert (info->gradient != NULL);
|
2017-11-16 11:47:03 -05:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_data_copy (GIMP_DATA (gradient_tool->gradient),
|
2017-11-16 11:47:03 -05:00
|
|
|
GIMP_DATA (info->gradient));
|
|
|
|
|
|
|
|
g_clear_object (&info->gradient);
|
|
|
|
|
|
|
|
info->added_handle = GIMP_TOOL_LINE_HANDLE_NONE;
|
|
|
|
}
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
else
|
2017-11-16 11:47:03 -05:00
|
|
|
{
|
|
|
|
GimpGradientSegment *seg;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
seg = gimp_gradient_tool_editor_handle_get_segment (gradient_tool, slider);
|
2017-11-16 11:47:03 -05:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_segment_range_merge (gradient_tool->gradient,
|
2017-11-16 11:47:03 -05:00
|
|
|
seg, seg->next, NULL, NULL);
|
|
|
|
|
|
|
|
info->removed_handle = slider;
|
|
|
|
}
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_thaw_gradient (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_end_edit (gradient_tool, FALSE);
|
2017-08-03 09:15:43 -04:00
|
|
|
}
|
|
|
|
|
2017-08-03 13:42:09 -04:00
|
|
|
static gint
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_midpoint_to_stop (GimpGradientTool *gradient_tool,
|
|
|
|
gint slider)
|
2017-08-03 13:42:09 -04:00
|
|
|
{
|
|
|
|
const GimpControllerSlider *sliders;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_assert (gimp_gradient_tool_editor_handle_is_midpoint (gradient_tool, slider));
|
2017-10-09 17:05:14 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
sliders = gimp_tool_line_get_sliders (GIMP_TOOL_LINE (gradient_tool->widget),
|
2017-08-03 13:42:09 -04:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (sliders[slider].value > sliders[slider].min + EPSILON &&
|
|
|
|
sliders[slider].value < sliders[slider].max - EPSILON)
|
|
|
|
{
|
2017-10-09 17:05:14 -04:00
|
|
|
const GimpGradientSegment *seg;
|
|
|
|
gint stop;
|
2018-04-14 00:52:20 +02:00
|
|
|
GradientInfo *info;
|
2017-10-09 17:05:14 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
seg = gimp_gradient_tool_editor_handle_get_segment (gradient_tool, slider);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
stop = gimp_gradient_tool_editor_add_stop (gradient_tool, seg->middle);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
info = gradient_tool->undo_stack->data;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
info->removed_handle = slider;
|
|
|
|
|
|
|
|
slider = stop;
|
2017-08-03 13:42:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return slider;
|
|
|
|
}
|
|
|
|
|
2017-08-01 11:33:36 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_update_sliders (GimpGradientTool *gradient_tool)
|
2017-08-01 11:33:36 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpGradientOptions *options = GIMP_GRADIENT_TOOL_GET_OPTIONS (gradient_tool);
|
2017-08-01 11:33:36 -04:00
|
|
|
GimpPaintOptions *paint_options = GIMP_PAINT_OPTIONS (options);
|
|
|
|
gdouble offset = options->offset / 100.0;
|
|
|
|
gboolean editable;
|
|
|
|
GimpControllerSlider *sliders;
|
|
|
|
gint n_sliders;
|
|
|
|
gint n_segments;
|
|
|
|
GimpGradientSegment *seg;
|
|
|
|
GimpControllerSlider *slider;
|
|
|
|
gint i;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (! gradient_tool->widget || options->instant)
|
2017-08-01 11:33:36 -04:00
|
|
|
return;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
editable = gimp_gradient_tool_editor_is_gradient_editable (gradient_tool);
|
2017-08-01 11:33:36 -04:00
|
|
|
|
|
|
|
n_segments = gimp_gradient_segment_range_get_n_segments (
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->gradient, gradient_tool->gradient->segments, NULL);
|
2017-08-01 11:33:36 -04:00
|
|
|
|
|
|
|
n_sliders = (n_segments - 1) + /* gradient stops, between each adjacent
|
|
|
|
* pair of segments */
|
|
|
|
(n_segments); /* midpoints, inside each segment */
|
|
|
|
|
|
|
|
sliders = g_new (GimpControllerSlider, n_sliders);
|
|
|
|
|
|
|
|
slider = sliders;
|
|
|
|
|
|
|
|
/* initialize the gradient-stop sliders */
|
2018-04-14 00:52:20 +02:00
|
|
|
for (seg = gradient_tool->gradient->segments, i = 0;
|
2017-08-01 11:33:36 -04:00
|
|
|
seg->next;
|
|
|
|
seg = seg->next, i++)
|
|
|
|
{
|
|
|
|
*slider = GIMP_CONTROLLER_SLIDER_DEFAULT;
|
|
|
|
|
2017-08-01 17:34:31 -04:00
|
|
|
slider->value = seg->right;
|
|
|
|
slider->min = seg->left;
|
|
|
|
slider->max = seg->next->right;
|
2017-08-01 11:33:36 -04:00
|
|
|
|
2017-08-01 17:34:31 -04:00
|
|
|
slider->movable = editable;
|
|
|
|
slider->removable = editable;
|
2017-08-01 11:33:36 -04:00
|
|
|
|
2017-08-01 17:34:31 -04:00
|
|
|
slider->data = GINT_TO_POINTER (i);
|
2017-08-01 11:33:36 -04:00
|
|
|
|
|
|
|
slider++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize the midpoint sliders */
|
2018-04-14 00:52:20 +02:00
|
|
|
for (seg = gradient_tool->gradient->segments, i = 0;
|
2017-08-01 11:33:36 -04:00
|
|
|
seg;
|
|
|
|
seg = seg->next, i++)
|
|
|
|
{
|
|
|
|
*slider = GIMP_CONTROLLER_SLIDER_DEFAULT;
|
|
|
|
|
|
|
|
slider->value = seg->middle;
|
|
|
|
slider->min = seg->left;
|
|
|
|
slider->max = seg->right;
|
|
|
|
|
|
|
|
/* hide midpoints of zero-length segments, since they'd otherwise
|
|
|
|
* prevent the segment's endpoints from being selected
|
|
|
|
*/
|
|
|
|
slider->visible = fabs (slider->max - slider->min) > EPSILON;
|
|
|
|
slider->movable = editable;
|
|
|
|
|
|
|
|
slider->autohide = TRUE;
|
|
|
|
slider->type = GIMP_HANDLE_FILLED_CIRCLE;
|
|
|
|
slider->size = 0.6;
|
|
|
|
|
|
|
|
slider->data = GINT_TO_POINTER (i);
|
|
|
|
|
|
|
|
slider++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* flip the slider limits and values, if necessary */
|
|
|
|
if (paint_options->gradient_options->gradient_reverse)
|
|
|
|
{
|
|
|
|
for (i = 0; i < n_sliders; i++)
|
|
|
|
{
|
|
|
|
gdouble temp;
|
|
|
|
|
|
|
|
sliders[i].value = 1.0 - sliders[i].value;
|
|
|
|
temp = sliders[i].min;
|
|
|
|
sliders[i].min = 1.0 - sliders[i].max;
|
|
|
|
sliders[i].max = 1.0 - temp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* adjust the sliders according to the offset */
|
|
|
|
for (i = 0; i < n_sliders; i++)
|
|
|
|
{
|
|
|
|
sliders[i].value = (1.0 - offset) * sliders[i].value + offset;
|
|
|
|
sliders[i].min = (1.0 - offset) * sliders[i].min + offset;
|
|
|
|
sliders[i].max = (1.0 - offset) * sliders[i].max + offset;
|
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
/* avoid updating the gradient in gimp_gradient_tool_editor_line_changed() */
|
|
|
|
gimp_gradient_tool_editor_block_handlers (gradient_tool);
|
2017-08-01 14:04:28 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_set_sliders (GIMP_TOOL_LINE (gradient_tool->widget),
|
2017-08-01 11:33:36 -04:00
|
|
|
sliders, n_sliders);
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_unblock_handlers (gradient_tool);
|
2017-08-01 14:04:28 -04:00
|
|
|
|
2017-08-01 11:33:36 -04:00
|
|
|
g_free (sliders);
|
|
|
|
}
|
|
|
|
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_purge_gradient_history (GSList **stack)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
|
|
|
GSList *link;
|
|
|
|
|
|
|
|
/* eliminate all history steps that modify the gradient */
|
|
|
|
while ((link = *stack))
|
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GradientInfo *info = link->data;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
|
|
|
if (info->gradient)
|
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_gradient_info_free (info);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
|
|
|
*stack = g_slist_delete_link (*stack, link);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
stack = &link->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_purge_gradient (GimpGradientTool *gradient_tool)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gradient_tool->widget)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_update_sliders (gradient_tool);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_set_selection (GIMP_TOOL_LINE (gradient_tool->widget),
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
GIMP_TOOL_LINE_HANDLE_NONE);
|
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_purge_gradient_history (&gradient_tool->undo_stack);
|
|
|
|
gimp_gradient_tool_editor_purge_gradient_history (&gradient_tool->redo_stack);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
|
|
|
|
2017-08-03 01:05:44 -04:00
|
|
|
static GtkWidget *
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_color_entry_new (GimpGradientTool *gradient_tool,
|
|
|
|
const gchar *title,
|
|
|
|
Direction direction,
|
|
|
|
GtkWidget *chain_button,
|
|
|
|
GtkWidget **color_panel,
|
|
|
|
GtkWidget **type_combo)
|
2017-08-03 01:05:44 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpContext *context = GIMP_CONTEXT (GIMP_GRADIENT_TOOL_GET_OPTIONS (gradient_tool));
|
2017-08-03 01:05:44 -04:00
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *combo;
|
|
|
|
GimpRGB color = {};
|
|
|
|
|
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
|
|
|
|
|
|
|
/* the color panel */
|
|
|
|
*color_panel = button = gimp_color_panel_new (title, &color,
|
|
|
|
GIMP_COLOR_AREA_SMALL_CHECKS,
|
|
|
|
24, 24);
|
|
|
|
gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE);
|
|
|
|
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), context);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (button),
|
2018-04-14 00:52:20 +02:00
|
|
|
"gimp-gradient-tool-editor-direction",
|
2017-08-03 01:05:44 -04:00
|
|
|
GINT_TO_POINTER (direction));
|
|
|
|
g_object_set_data (G_OBJECT (button),
|
2018-04-14 00:52:20 +02:00
|
|
|
"gimp-gradient-tool-editor-chain-button",
|
2017-08-03 01:05:44 -04:00
|
|
|
chain_button);
|
|
|
|
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
g_signal_connect (button, "clicked",
|
2018-04-14 00:52:20 +02:00
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_color_entry_color_clicked),
|
|
|
|
gradient_tool);
|
2017-08-03 01:05:44 -04:00
|
|
|
g_signal_connect (button, "color-changed",
|
2018-04-14 00:52:20 +02:00
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_color_entry_color_changed),
|
|
|
|
gradient_tool);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
g_signal_connect (button, "response",
|
2018-04-14 00:52:20 +02:00
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_color_entry_color_response),
|
|
|
|
gradient_tool);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
|
|
|
/* the color type combo */
|
|
|
|
*type_combo = combo = gimp_enum_combo_box_new (GIMP_TYPE_GRADIENT_COLOR);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show (combo);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (combo),
|
2018-04-14 00:52:20 +02:00
|
|
|
"gimp-gradient-tool-editor-direction",
|
2017-08-03 01:05:44 -04:00
|
|
|
GINT_TO_POINTER (direction));
|
|
|
|
g_object_set_data (G_OBJECT (combo),
|
2018-04-14 00:52:20 +02:00
|
|
|
"gimp-gradient-tool-editor-chain-button",
|
2017-08-03 01:05:44 -04:00
|
|
|
chain_button);
|
|
|
|
|
|
|
|
g_signal_connect (combo, "changed",
|
2018-04-14 00:52:20 +02:00
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_color_entry_type_changed),
|
|
|
|
gradient_tool);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
|
|
|
return hbox;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_init_endpoint_gui (GimpGradientTool *gradient_tool)
|
2017-08-03 01:05:44 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpDisplay *display = GIMP_TOOL (gradient_tool)->display;
|
2017-08-03 01:05:44 -04:00
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
gdouble xres;
|
|
|
|
gdouble yres;
|
|
|
|
GtkWidget *editor;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkWidget *se;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
gint row = 0;
|
|
|
|
|
|
|
|
gimp_image_get_resolution (image, &xres, &yres);
|
|
|
|
|
|
|
|
/* the endpoint editor */
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->endpoint_editor =
|
|
|
|
editor = gimp_editor_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (gradient_tool->gui)),
|
2017-08-03 01:05:44 -04:00
|
|
|
editor, FALSE, TRUE, 0);
|
|
|
|
|
|
|
|
/* the main table */
|
|
|
|
table = gtk_table_new (1, 2, FALSE);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (editor), table, FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
/* the position labels */
|
|
|
|
label = gtk_label_new (_("X:"));
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
label = gtk_label_new (_("Y:"));
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row + 1, row + 2,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
/* the position size entry */
|
|
|
|
spinbutton = gtk_spin_button_new_with_range (0.0, 0.0, 1.0);
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 6);
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->endpoint_se =
|
|
|
|
se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a",
|
|
|
|
TRUE, TRUE, FALSE, 6,
|
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
2017-08-03 01:05:44 -04:00
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (se), 4);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (se), 2);
|
|
|
|
|
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (se),
|
|
|
|
GTK_SPIN_BUTTON (spinbutton), NULL);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (se), spinbutton, 1, 2, 0, 1);
|
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
|
|
|
gtk_table_attach (GTK_TABLE (table), se, 1, 2, row, row + 2,
|
|
|
|
GTK_SHRINK | GTK_FILL | GTK_EXPAND,
|
|
|
|
GTK_SHRINK | GTK_FILL,
|
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (se);
|
|
|
|
|
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (se), shell->unit);
|
|
|
|
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (se), 0, xres, FALSE);
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (se), 1, yres, FALSE);
|
|
|
|
|
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (se), 0,
|
|
|
|
-GIMP_MAX_IMAGE_SIZE,
|
|
|
|
GIMP_MAX_IMAGE_SIZE);
|
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (se), 1,
|
|
|
|
-GIMP_MAX_IMAGE_SIZE,
|
|
|
|
GIMP_MAX_IMAGE_SIZE);
|
|
|
|
|
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (se), 0,
|
|
|
|
0, gimp_image_get_width (image));
|
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (se), 1,
|
|
|
|
0, gimp_image_get_height (image));
|
|
|
|
|
|
|
|
g_signal_connect (se, "value-changed",
|
2018-04-14 00:52:20 +02:00
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_endpoint_se_value_changed),
|
|
|
|
gradient_tool);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
|
|
|
row += 2;
|
|
|
|
|
|
|
|
/* the color label */
|
|
|
|
label = gtk_label_new (_("Color:"));
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
/* the color entry */
|
2018-04-14 00:52:20 +02:00
|
|
|
hbox = gimp_gradient_tool_editor_color_entry_new (
|
|
|
|
gradient_tool, _("Change Endpoint Color"), DIRECTION_NONE, NULL,
|
|
|
|
&gradient_tool->endpoint_color_panel, &gradient_tool->endpoint_type_combo);
|
2017-08-03 01:05:44 -04:00
|
|
|
gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, row, row + 1,
|
|
|
|
GTK_SHRINK | GTK_FILL | GTK_EXPAND,
|
|
|
|
GTK_SHRINK | GTK_FILL,
|
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
row++;
|
|
|
|
}
|
|
|
|
|
2017-08-03 09:15:43 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_init_stop_gui (GimpGradientTool *gradient_tool)
|
2017-08-03 09:15:43 -04:00
|
|
|
{
|
|
|
|
GtkWidget *editor;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *se;
|
|
|
|
GtkWidget *table2;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *separator;
|
|
|
|
gint row = 0;
|
|
|
|
|
|
|
|
/* the stop editor */
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->stop_editor =
|
|
|
|
editor = gimp_editor_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (gradient_tool->gui)),
|
2017-08-03 09:15:43 -04:00
|
|
|
editor, FALSE, TRUE, 0);
|
|
|
|
|
|
|
|
/* the main table */
|
|
|
|
table = gtk_table_new (1, 2, FALSE);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (editor), table, FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
/* the position label */
|
|
|
|
label = gtk_label_new (_("Position:"));
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
/* the position size entry */
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->stop_se =
|
|
|
|
se = gimp_size_entry_new (1, GIMP_UNIT_PERCENT, "%a",
|
|
|
|
FALSE, TRUE, FALSE, 6,
|
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
2017-08-03 09:15:43 -04:00
|
|
|
gimp_size_entry_show_unit_menu (GIMP_SIZE_ENTRY (se), FALSE);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), se, 1, 2, row, row + 1,
|
|
|
|
GTK_SHRINK | GTK_FILL | GTK_EXPAND,
|
|
|
|
GTK_SHRINK | GTK_FILL,
|
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (se);
|
|
|
|
|
|
|
|
g_signal_connect (se, "value-changed",
|
2018-04-14 00:52:20 +02:00
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_stop_se_value_changed),
|
|
|
|
gradient_tool);
|
2017-08-03 09:15:43 -04:00
|
|
|
|
|
|
|
row++;
|
|
|
|
|
|
|
|
/* the color labels */
|
|
|
|
label = gtk_label_new (_("Left color:"));
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
label = gtk_label_new (_("Right color:"));
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row + 1, row + 2,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
/* the color entries table */
|
|
|
|
table2 = gtk_table_new (1, 2, FALSE);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table2), 4);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table2), 2);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), table2, 1, 2, row, row + 2,
|
|
|
|
GTK_SHRINK | GTK_FILL | GTK_EXPAND,
|
|
|
|
GTK_SHRINK | GTK_FILL,
|
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (table2);
|
|
|
|
|
|
|
|
/* the color entries chain button */
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->stop_chain_button =
|
|
|
|
button = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
|
2017-08-03 09:15:43 -04:00
|
|
|
gtk_table_attach (GTK_TABLE (table2), button, 1, 2, 0, 2,
|
|
|
|
GTK_SHRINK | GTK_FILL,
|
|
|
|
GTK_SHRINK | GTK_FILL | GTK_EXPAND,
|
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
/* the color entries */
|
2018-04-14 00:52:20 +02:00
|
|
|
hbox = gimp_gradient_tool_editor_color_entry_new (
|
|
|
|
gradient_tool, _("Change Stop Color"), DIRECTION_LEFT, button,
|
|
|
|
&gradient_tool->stop_left_color_panel, &gradient_tool->stop_left_type_combo);
|
2017-08-03 09:15:43 -04:00
|
|
|
gtk_table_attach (GTK_TABLE (table2), hbox, 0, 1, 0, 1,
|
|
|
|
GTK_SHRINK | GTK_FILL | GTK_EXPAND,
|
|
|
|
GTK_SHRINK | GTK_FILL,
|
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
hbox = gimp_gradient_tool_editor_color_entry_new (
|
|
|
|
gradient_tool, _("Change Stop Color"), DIRECTION_RIGHT, button,
|
|
|
|
&gradient_tool->stop_right_color_panel, &gradient_tool->stop_right_type_combo);
|
2017-08-03 09:15:43 -04:00
|
|
|
gtk_table_attach (GTK_TABLE (table2), hbox, 0, 1, 1, 2,
|
|
|
|
GTK_SHRINK | GTK_FILL | GTK_EXPAND,
|
|
|
|
GTK_SHRINK | GTK_FILL,
|
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
row += 2;
|
|
|
|
|
|
|
|
/* the action buttons separator */
|
2018-04-29 17:33:42 +02:00
|
|
|
separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
|
2017-08-03 09:15:43 -04:00
|
|
|
gtk_table_attach (GTK_TABLE (table), separator, 0, 2, row, row + 1,
|
|
|
|
GTK_SHRINK | GTK_FILL | GTK_EXPAND,
|
|
|
|
GTK_SHRINK | GTK_FILL,
|
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (separator);
|
|
|
|
|
|
|
|
row++;
|
|
|
|
|
|
|
|
/* the delete button */
|
|
|
|
gimp_editor_add_button (GIMP_EDITOR (editor),
|
|
|
|
GIMP_ICON_EDIT_DELETE, _("Delete stop"),
|
|
|
|
NULL,
|
2018-04-14 00:52:20 +02:00
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_stop_delete_clicked),
|
|
|
|
NULL, gradient_tool);
|
2017-08-03 09:15:43 -04:00
|
|
|
}
|
|
|
|
|
2017-08-03 13:42:09 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_init_midpoint_gui (GimpGradientTool *gradient_tool)
|
2017-08-03 13:42:09 -04:00
|
|
|
{
|
|
|
|
GtkWidget *editor;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *se;
|
|
|
|
GtkWidget *combo;
|
|
|
|
GtkWidget *separator;
|
|
|
|
gint row = 0;
|
|
|
|
|
|
|
|
/* the stop editor */
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->midpoint_editor =
|
|
|
|
editor = gimp_editor_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (gradient_tool->gui)),
|
2017-08-03 13:42:09 -04:00
|
|
|
editor, FALSE, TRUE, 0);
|
|
|
|
|
|
|
|
/* the main table */
|
|
|
|
table = gtk_table_new (1, 2, FALSE);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (editor), table, FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
/* the position label */
|
|
|
|
label = gtk_label_new (_("Position:"));
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
/* the position size entry */
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->midpoint_se =
|
|
|
|
se = gimp_size_entry_new (1, GIMP_UNIT_PERCENT, "%a",
|
|
|
|
FALSE, TRUE, FALSE, 6,
|
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
2017-08-03 13:42:09 -04:00
|
|
|
gimp_size_entry_show_unit_menu (GIMP_SIZE_ENTRY (se), FALSE);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), se, 1, 2, row, row + 1,
|
|
|
|
GTK_SHRINK | GTK_FILL | GTK_EXPAND,
|
|
|
|
GTK_SHRINK | GTK_FILL,
|
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (se);
|
|
|
|
|
|
|
|
g_signal_connect (se, "value-changed",
|
2018-04-14 00:52:20 +02:00
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_midpoint_se_value_changed),
|
|
|
|
gradient_tool);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
|
|
|
row++;
|
|
|
|
|
|
|
|
/* the type label */
|
|
|
|
label = gtk_label_new (_("Blending:"));
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
/* the type combo */
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->midpoint_type_combo =
|
|
|
|
combo = gimp_enum_combo_box_new (GIMP_TYPE_GRADIENT_SEGMENT_TYPE);
|
2017-08-03 13:42:09 -04:00
|
|
|
gtk_table_attach (GTK_TABLE (table), combo, 1, 2, row, row + 1,
|
|
|
|
GTK_SHRINK | GTK_FILL | GTK_EXPAND,
|
|
|
|
GTK_SHRINK | GTK_FILL,
|
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (combo);
|
|
|
|
|
|
|
|
g_signal_connect (combo, "changed",
|
2018-04-14 00:52:20 +02:00
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_midpoint_type_changed),
|
|
|
|
gradient_tool);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
|
|
|
row++;
|
|
|
|
|
|
|
|
/* the color label */
|
|
|
|
label = gtk_label_new (_("Coloring:"));
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
/* the color combo */
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->midpoint_color_combo =
|
|
|
|
combo = gimp_enum_combo_box_new (GIMP_TYPE_GRADIENT_SEGMENT_COLOR);
|
2017-08-03 13:42:09 -04:00
|
|
|
gtk_table_attach (GTK_TABLE (table), combo, 1, 2, row, row + 1,
|
|
|
|
GTK_SHRINK | GTK_FILL | GTK_EXPAND,
|
|
|
|
GTK_SHRINK | GTK_FILL,
|
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (combo);
|
|
|
|
|
|
|
|
g_signal_connect (combo, "changed",
|
2018-04-14 00:52:20 +02:00
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_midpoint_color_changed),
|
|
|
|
gradient_tool);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
|
|
|
row++;
|
|
|
|
|
|
|
|
/* the action buttons separator */
|
2018-04-29 17:33:42 +02:00
|
|
|
separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
|
2017-08-03 13:42:09 -04:00
|
|
|
gtk_table_attach (GTK_TABLE (table), separator, 0, 2, row, row + 1,
|
|
|
|
GTK_SHRINK | GTK_FILL | GTK_EXPAND,
|
|
|
|
GTK_SHRINK | GTK_FILL,
|
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (separator);
|
|
|
|
|
|
|
|
row++;
|
|
|
|
|
|
|
|
/* the new stop button */
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->midpoint_new_stop_button =
|
2017-08-03 13:42:09 -04:00
|
|
|
gimp_editor_add_button (GIMP_EDITOR (editor),
|
|
|
|
GIMP_ICON_DOCUMENT_NEW, _("New stop at midpoint"),
|
|
|
|
NULL,
|
2018-04-14 00:52:20 +02:00
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_midpoint_new_stop_clicked),
|
|
|
|
NULL, gradient_tool);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
|
|
|
/* the center button */
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->midpoint_center_button =
|
2017-08-03 13:42:09 -04:00
|
|
|
gimp_editor_add_button (GIMP_EDITOR (editor),
|
|
|
|
GIMP_ICON_CENTER_HORIZONTAL, _("Center midpoint"),
|
|
|
|
NULL,
|
2018-04-14 00:52:20 +02:00
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_midpoint_center_clicked),
|
|
|
|
NULL, gradient_tool);
|
2017-08-03 13:42:09 -04:00
|
|
|
}
|
|
|
|
|
2017-08-03 01:05:44 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_update_endpoint_gui (GimpGradientTool *gradient_tool,
|
|
|
|
gint selection)
|
2017-08-03 01:05:44 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpGradientOptions *options = GIMP_GRADIENT_TOOL_GET_OPTIONS (gradient_tool);
|
2017-08-03 01:05:44 -04:00
|
|
|
GimpPaintOptions *paint_options = GIMP_PAINT_OPTIONS (options);
|
|
|
|
GimpContext *context = GIMP_CONTEXT (options);
|
|
|
|
gboolean editable;
|
|
|
|
GimpGradientSegment *seg;
|
|
|
|
const gchar *title;
|
|
|
|
gdouble x;
|
|
|
|
gdouble y;
|
|
|
|
GimpRGB color;
|
|
|
|
GimpGradientColor color_type;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
editable = gimp_gradient_tool_editor_is_gradient_editable (gradient_tool);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
|
|
|
switch (selection)
|
|
|
|
{
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_START:
|
2018-04-14 00:52:20 +02:00
|
|
|
g_object_get (gradient_tool->widget,
|
2017-08-03 01:05:44 -04:00
|
|
|
"x1", &x,
|
|
|
|
"y1", &y,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_END:
|
2018-04-14 00:52:20 +02:00
|
|
|
g_object_get (gradient_tool->widget,
|
2017-08-03 01:05:44 -04:00
|
|
|
"x2", &x,
|
|
|
|
"y2", &y,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-02-11 22:23:10 +01:00
|
|
|
gimp_assert_not_reached ();
|
2017-08-03 01:05:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* swap the endpoint handles, if necessary */
|
|
|
|
if (paint_options->gradient_options->gradient_reverse)
|
|
|
|
{
|
|
|
|
switch (selection)
|
|
|
|
{
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_START:
|
|
|
|
selection = GIMP_TOOL_LINE_HANDLE_END;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_END:
|
|
|
|
selection = GIMP_TOOL_LINE_HANDLE_START;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
seg = gimp_gradient_tool_editor_handle_get_segment (gradient_tool, selection);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
|
|
|
switch (selection)
|
|
|
|
{
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_START:
|
|
|
|
title = _("Start Endpoint");
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_segment_get_left_flat_color (gradient_tool->gradient, context,
|
2017-08-03 01:05:44 -04:00
|
|
|
seg, &color);
|
|
|
|
color_type = seg->left_color_type;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_END:
|
|
|
|
title = _("End Endpoint");
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_segment_get_right_flat_color (gradient_tool->gradient, context,
|
2017-08-03 01:05:44 -04:00
|
|
|
seg, &color);
|
|
|
|
color_type = seg->right_color_type;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-02-11 22:23:10 +01:00
|
|
|
gimp_assert_not_reached ();
|
2017-08-03 01:05:44 -04:00
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_gui_set_title (gradient_tool->gui, title);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (gradient_tool->endpoint_se), 0, x);
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (gradient_tool->endpoint_se), 1, y);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
|
|
|
gimp_color_button_set_color (
|
2018-04-14 00:52:20 +02:00
|
|
|
GIMP_COLOR_BUTTON (gradient_tool->endpoint_color_panel), &color);
|
2017-08-03 01:05:44 -04:00
|
|
|
gimp_int_combo_box_set_active (
|
2018-04-14 00:52:20 +02:00
|
|
|
GIMP_INT_COMBO_BOX (gradient_tool->endpoint_type_combo), color_type);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gtk_widget_set_sensitive (gradient_tool->endpoint_color_panel, editable);
|
|
|
|
gtk_widget_set_sensitive (gradient_tool->endpoint_type_combo, editable);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gtk_widget_show (gradient_tool->endpoint_editor);
|
2017-08-03 01:05:44 -04:00
|
|
|
}
|
|
|
|
|
2017-08-03 09:15:43 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_update_stop_gui (GimpGradientTool *gradient_tool,
|
|
|
|
gint selection)
|
2017-08-03 09:15:43 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpGradientOptions *options = GIMP_GRADIENT_TOOL_GET_OPTIONS (gradient_tool);
|
2017-08-03 09:15:43 -04:00
|
|
|
GimpContext *context = GIMP_CONTEXT (options);
|
|
|
|
gboolean editable;
|
|
|
|
GimpGradientSegment *seg;
|
|
|
|
gint index;
|
|
|
|
gchar *title;
|
|
|
|
gdouble min;
|
|
|
|
gdouble max;
|
|
|
|
gdouble value;
|
|
|
|
GimpRGB left_color;
|
|
|
|
GimpGradientColor left_color_type;
|
|
|
|
GimpRGB right_color;
|
|
|
|
GimpGradientColor right_color_type;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
editable = gimp_gradient_tool_editor_is_gradient_editable (gradient_tool);
|
2017-08-03 09:15:43 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
seg = gimp_gradient_tool_editor_handle_get_segment (gradient_tool, selection);
|
2017-08-03 09:15:43 -04:00
|
|
|
|
|
|
|
index = GPOINTER_TO_INT (
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_sliders (GIMP_TOOL_LINE (gradient_tool->widget),
|
2017-08-03 09:15:43 -04:00
|
|
|
NULL)[selection].data);
|
|
|
|
|
|
|
|
title = g_strdup_printf (_("Stop %d"), index + 1);
|
|
|
|
|
|
|
|
min = seg->left;
|
|
|
|
max = seg->next->right;
|
|
|
|
value = seg->right;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_segment_get_right_flat_color (gradient_tool->gradient, context,
|
2017-08-03 09:15:43 -04:00
|
|
|
seg, &left_color);
|
|
|
|
left_color_type = seg->right_color_type;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_segment_get_left_flat_color (gradient_tool->gradient, context,
|
2017-08-03 09:15:43 -04:00
|
|
|
seg->next, &right_color);
|
|
|
|
right_color_type = seg->next->left_color_type;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_gui_set_title (gradient_tool->gui, title);
|
2017-08-03 09:15:43 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (gradient_tool->stop_se),
|
2017-08-03 09:15:43 -04:00
|
|
|
0, 100.0 * min, 100.0 * max);
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (gradient_tool->stop_se),
|
2017-08-03 09:15:43 -04:00
|
|
|
0, 100.0 * value);
|
|
|
|
|
|
|
|
gimp_color_button_set_color (
|
2018-04-14 00:52:20 +02:00
|
|
|
GIMP_COLOR_BUTTON (gradient_tool->stop_left_color_panel), &left_color);
|
2017-08-03 09:15:43 -04:00
|
|
|
gimp_int_combo_box_set_active (
|
2018-04-14 00:52:20 +02:00
|
|
|
GIMP_INT_COMBO_BOX (gradient_tool->stop_left_type_combo), left_color_type);
|
2017-08-03 09:15:43 -04:00
|
|
|
|
|
|
|
gimp_color_button_set_color (
|
2018-04-14 00:52:20 +02:00
|
|
|
GIMP_COLOR_BUTTON (gradient_tool->stop_right_color_panel), &right_color);
|
2017-08-03 09:15:43 -04:00
|
|
|
gimp_int_combo_box_set_active (
|
2018-04-14 00:52:20 +02:00
|
|
|
GIMP_INT_COMBO_BOX (gradient_tool->stop_right_type_combo), right_color_type);
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (gradient_tool->stop_se, editable);
|
|
|
|
gtk_widget_set_sensitive (gradient_tool->stop_left_color_panel, editable);
|
|
|
|
gtk_widget_set_sensitive (gradient_tool->stop_left_type_combo, editable);
|
|
|
|
gtk_widget_set_sensitive (gradient_tool->stop_right_color_panel, editable);
|
|
|
|
gtk_widget_set_sensitive (gradient_tool->stop_right_type_combo, editable);
|
|
|
|
gtk_widget_set_sensitive (gradient_tool->stop_chain_button, editable);
|
2017-08-03 09:15:43 -04:00
|
|
|
gtk_widget_set_sensitive (
|
2018-04-14 00:52:20 +02:00
|
|
|
GTK_WIDGET (gimp_editor_get_button_box (GIMP_EDITOR (gradient_tool->stop_editor))),
|
2017-08-03 09:15:43 -04:00
|
|
|
editable);
|
|
|
|
|
|
|
|
g_free (title);
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gtk_widget_show (gradient_tool->stop_editor);
|
2017-08-03 09:15:43 -04:00
|
|
|
}
|
|
|
|
|
2017-08-03 13:42:09 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_update_midpoint_gui (GimpGradientTool *gradient_tool,
|
|
|
|
gint selection)
|
2017-08-03 13:42:09 -04:00
|
|
|
{
|
|
|
|
gboolean editable;
|
|
|
|
const GimpGradientSegment *seg;
|
|
|
|
gint index;
|
|
|
|
gchar *title;
|
|
|
|
gdouble min;
|
|
|
|
gdouble max;
|
|
|
|
gdouble value;
|
|
|
|
GimpGradientSegmentType type;
|
|
|
|
GimpGradientSegmentColor color;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
editable = gimp_gradient_tool_editor_is_gradient_editable (gradient_tool);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
seg = gimp_gradient_tool_editor_handle_get_segment (gradient_tool, selection);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
|
|
|
index = GPOINTER_TO_INT (
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_sliders (GIMP_TOOL_LINE (gradient_tool->widget),
|
2017-08-03 13:42:09 -04:00
|
|
|
NULL)[selection].data);
|
|
|
|
|
|
|
|
title = g_strdup_printf (_("Midpoint %d"), index + 1);
|
|
|
|
|
|
|
|
min = seg->left;
|
|
|
|
max = seg->right;
|
|
|
|
value = seg->middle;
|
|
|
|
type = seg->type;
|
|
|
|
color = seg->color;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_gui_set_title (gradient_tool->gui, title);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (gradient_tool->midpoint_se),
|
2017-08-03 13:42:09 -04:00
|
|
|
0, 100.0 * min, 100.0 * max);
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (gradient_tool->midpoint_se),
|
2017-08-03 13:42:09 -04:00
|
|
|
0, 100.0 * value);
|
|
|
|
|
|
|
|
gimp_int_combo_box_set_active (
|
2018-04-14 00:52:20 +02:00
|
|
|
GIMP_INT_COMBO_BOX (gradient_tool->midpoint_type_combo), type);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
|
|
|
gimp_int_combo_box_set_active (
|
2018-04-14 00:52:20 +02:00
|
|
|
GIMP_INT_COMBO_BOX (gradient_tool->midpoint_color_combo), color);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gtk_widget_set_sensitive (gradient_tool->midpoint_new_stop_button,
|
2017-08-03 13:42:09 -04:00
|
|
|
value > min + EPSILON && value < max - EPSILON);
|
2018-04-14 00:52:20 +02:00
|
|
|
gtk_widget_set_sensitive (gradient_tool->midpoint_center_button,
|
2017-08-03 13:42:09 -04:00
|
|
|
fabs (value - (min + max) / 2.0) > EPSILON);
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gtk_widget_set_sensitive (gradient_tool->midpoint_se, editable);
|
|
|
|
gtk_widget_set_sensitive (gradient_tool->midpoint_type_combo, editable);
|
|
|
|
gtk_widget_set_sensitive (gradient_tool->midpoint_color_combo, editable);
|
2017-08-03 13:42:09 -04:00
|
|
|
gtk_widget_set_sensitive (
|
2018-04-14 00:52:20 +02:00
|
|
|
GTK_WIDGET (gimp_editor_get_button_box (GIMP_EDITOR (gradient_tool->midpoint_editor))),
|
2017-08-03 13:42:09 -04:00
|
|
|
editable);
|
|
|
|
|
|
|
|
g_free (title);
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gtk_widget_show (gradient_tool->midpoint_editor);
|
2017-08-03 13:42:09 -04:00
|
|
|
}
|
|
|
|
|
2017-08-02 16:31:10 -04:00
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_update_gui (GimpGradientTool *gradient_tool)
|
2017-08-02 16:31:10 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpGradientOptions *options = GIMP_GRADIENT_TOOL_GET_OPTIONS (gradient_tool);
|
2017-08-02 16:31:10 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gradient_tool->gradient && gradient_tool->widget && ! options->instant)
|
2017-08-02 16:31:10 -04:00
|
|
|
{
|
|
|
|
gint selection;
|
|
|
|
|
|
|
|
selection =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_selection (GIMP_TOOL_LINE (gradient_tool->widget));
|
2017-08-02 16:31:10 -04:00
|
|
|
|
|
|
|
if (selection != GIMP_TOOL_LINE_HANDLE_NONE)
|
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
if (! gradient_tool->gui)
|
2017-08-02 16:31:10 -04:00
|
|
|
{
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
shell = gimp_tool_widget_get_shell (gradient_tool->widget);
|
2017-08-02 16:31:10 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->gui =
|
|
|
|
gimp_tool_gui_new (GIMP_TOOL (gradient_tool)->tool_info,
|
2017-08-02 16:31:10 -04:00
|
|
|
NULL, NULL, NULL, NULL,
|
|
|
|
gimp_widget_get_monitor (GTK_WIDGET (shell)),
|
|
|
|
TRUE,
|
|
|
|
|
|
|
|
_("_Close"), GTK_RESPONSE_CLOSE,
|
|
|
|
|
|
|
|
NULL);
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_gui_set_shell (gradient_tool->gui, shell);
|
|
|
|
gimp_tool_gui_set_viewable (gradient_tool->gui,
|
|
|
|
GIMP_VIEWABLE (gradient_tool->gradient));
|
|
|
|
gimp_tool_gui_set_auto_overlay (gradient_tool->gui, TRUE);
|
2017-08-02 16:31:10 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
g_signal_connect (gradient_tool->gui, "response",
|
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_gui_response),
|
|
|
|
gradient_tool);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_init_endpoint_gui (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_init_stop_gui (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_init_midpoint_gui (gradient_tool);
|
2017-08-02 16:31:10 -04:00
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_block_handlers (gradient_tool);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gimp_gradient_tool_editor_handle_is_endpoint (gradient_tool, selection))
|
|
|
|
gimp_gradient_tool_editor_update_endpoint_gui (gradient_tool, selection);
|
2017-08-03 01:05:44 -04:00
|
|
|
else
|
2018-04-14 00:52:20 +02:00
|
|
|
gtk_widget_hide (gradient_tool->endpoint_editor);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gimp_gradient_tool_editor_handle_is_stop (gradient_tool, selection))
|
|
|
|
gimp_gradient_tool_editor_update_stop_gui (gradient_tool, selection);
|
2017-08-03 09:15:43 -04:00
|
|
|
else
|
2018-04-14 00:52:20 +02:00
|
|
|
gtk_widget_hide (gradient_tool->stop_editor);
|
2017-08-03 09:15:43 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gimp_gradient_tool_editor_handle_is_midpoint (gradient_tool, selection))
|
|
|
|
gimp_gradient_tool_editor_update_midpoint_gui (gradient_tool, selection);
|
2017-08-03 13:42:09 -04:00
|
|
|
else
|
2018-04-14 00:52:20 +02:00
|
|
|
gtk_widget_hide (gradient_tool->midpoint_editor);
|
2017-08-03 13:42:09 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_unblock_handlers (gradient_tool);
|
2017-08-03 01:05:44 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_gui_show (gradient_tool->gui);
|
2017-08-02 16:31:10 -04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gradient_tool->gui)
|
|
|
|
gimp_tool_gui_hide (gradient_tool->gui);
|
2017-08-02 16:31:10 -04:00
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
static GradientInfo *
|
|
|
|
gimp_gradient_tool_editor_gradient_info_new (GimpGradientTool *gradient_tool)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GradientInfo *info = g_slice_new (GradientInfo);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
info->start_x = gradient_tool->start_x;
|
|
|
|
info->start_y = gradient_tool->start_y;
|
|
|
|
info->end_x = gradient_tool->end_x;
|
|
|
|
info->end_y = gradient_tool->end_y;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
|
|
|
info->gradient = NULL;
|
|
|
|
|
|
|
|
info->added_handle = GIMP_TOOL_LINE_HANDLE_NONE;
|
|
|
|
info->removed_handle = GIMP_TOOL_LINE_HANDLE_NONE;
|
|
|
|
info->selected_handle = GIMP_TOOL_LINE_HANDLE_NONE;
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_gradient_info_free (GradientInfo *info)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
|
|
|
if (info->gradient)
|
|
|
|
g_object_unref (info->gradient);
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
g_slice_free (GradientInfo, info);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_gradient_info_apply (GimpGradientTool *gradient_tool,
|
|
|
|
const GradientInfo *info,
|
|
|
|
gboolean set_selection)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
|
|
|
gint selection;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_assert (gradient_tool->widget != NULL);
|
|
|
|
gimp_assert (gradient_tool->gradient != NULL);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
|
|
|
/* pick the handle to select */
|
|
|
|
if (info->gradient)
|
|
|
|
{
|
|
|
|
if (info->removed_handle != GIMP_TOOL_LINE_HANDLE_NONE)
|
|
|
|
{
|
|
|
|
/* we're undoing a stop-deletion or midpoint-to-stop operation;
|
|
|
|
* select the removed handle
|
|
|
|
*/
|
|
|
|
selection = info->removed_handle;
|
|
|
|
}
|
|
|
|
else if (info->added_handle != GIMP_TOOL_LINE_HANDLE_NONE)
|
|
|
|
{
|
|
|
|
/* we're undoing a stop addition operation */
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_assert (gimp_gradient_tool_editor_handle_is_stop (gradient_tool,
|
|
|
|
info->added_handle));
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
|
|
|
selection =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_selection (GIMP_TOOL_LINE (gradient_tool->widget));
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
|
|
|
/* if the selected handle is a stop... */
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gimp_gradient_tool_editor_handle_is_stop (gradient_tool, selection))
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
|
|
|
/* if the added handle is selected, clear the selection */
|
|
|
|
if (selection == info->added_handle)
|
|
|
|
selection = GIMP_TOOL_LINE_HANDLE_NONE;
|
|
|
|
/* otherwise, keep the currently selected stop, possibly
|
|
|
|
* adjusting its handle index
|
|
|
|
*/
|
|
|
|
else if (selection > info->added_handle)
|
|
|
|
selection--;
|
|
|
|
}
|
|
|
|
/* otherwise, if the selected handle is a midpoint... */
|
2018-04-14 00:52:20 +02:00
|
|
|
else if (gimp_gradient_tool_editor_handle_is_midpoint (gradient_tool, selection))
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
|
|
|
const GimpControllerSlider *sliders;
|
|
|
|
gint seg_i;
|
|
|
|
|
|
|
|
sliders =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_sliders (GIMP_TOOL_LINE (gradient_tool->widget),
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
seg_i = GPOINTER_TO_INT (sliders[selection].data);
|
|
|
|
|
|
|
|
/* if the midpoint belongs to one of the two segments incident to
|
|
|
|
* the added stop, clear the selection
|
|
|
|
*/
|
|
|
|
if (seg_i == info->added_handle ||
|
|
|
|
seg_i == info->added_handle + 1)
|
|
|
|
{
|
|
|
|
selection = GIMP_TOOL_LINE_HANDLE_NONE;
|
|
|
|
}
|
|
|
|
/* otherwise, keep the currently selected stop, adjusting its
|
|
|
|
* handle index
|
|
|
|
*/
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* midpoint handles follow stop handles; since we removed a
|
|
|
|
* stop, we must decrement the handle index
|
|
|
|
*/
|
|
|
|
selection--;
|
|
|
|
|
|
|
|
if (seg_i > info->added_handle)
|
|
|
|
selection--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* otherwise, don't change the selection */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
set_selection = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (info->selected_handle != GIMP_TOOL_LINE_HANDLE_NONE)
|
|
|
|
{
|
|
|
|
/* we're undoing a property change operation; select the handle
|
|
|
|
* corresponding to the affected object
|
|
|
|
*/
|
|
|
|
selection = info->selected_handle;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-11-16 11:47:03 -05:00
|
|
|
/* something went wrong... */
|
|
|
|
g_warn_if_reached ();
|
|
|
|
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
set_selection = FALSE;
|
|
|
|
}
|
|
|
|
}
|
2018-04-14 00:52:20 +02:00
|
|
|
else if ((info->start_x != gradient_tool->start_x ||
|
|
|
|
info->start_y != gradient_tool->start_y) &&
|
|
|
|
(info->end_x == gradient_tool->end_x &&
|
|
|
|
info->end_y == gradient_tool->end_y))
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
|
|
|
/* we're undoing a start-endpoint move operation; select the start
|
|
|
|
* endpoint
|
|
|
|
*/
|
|
|
|
selection = GIMP_TOOL_LINE_HANDLE_START;
|
|
|
|
}
|
2018-04-14 00:52:20 +02:00
|
|
|
else if ((info->end_x != gradient_tool->end_x ||
|
|
|
|
info->end_y != gradient_tool->end_y) &&
|
|
|
|
(info->start_x == gradient_tool->start_x &&
|
|
|
|
info->start_y == gradient_tool->start_y))
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
|
|
|
{
|
|
|
|
/* we're undoing am end-endpoint move operation; select the end
|
|
|
|
* endpoint
|
|
|
|
*/
|
|
|
|
selection = GIMP_TOOL_LINE_HANDLE_END;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* we're undoing a line move operation; don't change the selection */
|
|
|
|
set_selection = FALSE;
|
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_block_handlers (gradient_tool);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
g_object_set (gradient_tool->widget,
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
"x1", info->start_x,
|
|
|
|
"y1", info->start_y,
|
|
|
|
"x2", info->end_x,
|
|
|
|
"y2", info->end_y,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (info->gradient)
|
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_freeze_gradient (gradient_tool);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_data_copy (GIMP_DATA (gradient_tool->gradient),
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
GIMP_DATA (info->gradient));
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_thaw_gradient (gradient_tool);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (set_selection)
|
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_set_selection (GIMP_TOOL_LINE (gradient_tool->widget),
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
selection);
|
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_update_gui (gradient_tool);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_unblock_handlers (gradient_tool);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
|
|
|
|
2017-11-16 11:08:15 -05:00
|
|
|
static gboolean
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_gradient_info_is_trivial (GimpGradientTool *gradient_tool,
|
|
|
|
const GradientInfo *info)
|
2017-11-16 11:08:15 -05:00
|
|
|
{
|
|
|
|
const GimpGradientSegment *seg1;
|
|
|
|
const GimpGradientSegment *seg2;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (info->start_x != gradient_tool->start_x ||
|
|
|
|
info->start_y != gradient_tool->start_y ||
|
|
|
|
info->end_x != gradient_tool->end_x ||
|
|
|
|
info->end_y != gradient_tool->end_y)
|
2017-11-16 11:08:15 -05:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->gradient)
|
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
for (seg1 = info->gradient->segments, seg2 = gradient_tool->gradient->segments;
|
2017-11-16 11:08:15 -05:00
|
|
|
seg1 && seg2;
|
|
|
|
seg1 = seg1->next, seg2 = seg2->next)
|
|
|
|
{
|
|
|
|
if (memcmp (seg1, seg2, G_STRUCT_OFFSET (GimpGradientSegment, prev)))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seg1 || seg2)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2017-08-01 09:18:50 -04:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2017-08-01 11:33:36 -04:00
|
|
|
void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_options_notify (GimpGradientTool *gradient_tool,
|
|
|
|
GimpToolOptions *options,
|
|
|
|
const GParamSpec *pspec)
|
2017-08-01 11:33:36 -04:00
|
|
|
{
|
|
|
|
if (! strcmp (pspec->name, "modify-active"))
|
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_update_sliders (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_update_gui (gradient_tool);
|
2017-08-01 11:33:36 -04:00
|
|
|
}
|
|
|
|
else if (! strcmp (pspec->name, "gradient-reverse"))
|
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_update_sliders (gradient_tool);
|
2017-08-01 11:33:36 -04:00
|
|
|
|
|
|
|
/* if an endpoint is selected, swap the selected endpoint */
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gradient_tool->widget)
|
2017-08-01 11:33:36 -04:00
|
|
|
{
|
|
|
|
gint selection;
|
|
|
|
|
|
|
|
selection =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_selection (GIMP_TOOL_LINE (gradient_tool->widget));
|
2017-08-01 11:33:36 -04:00
|
|
|
|
|
|
|
switch (selection)
|
|
|
|
{
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_START:
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_set_selection (GIMP_TOOL_LINE (gradient_tool->widget),
|
2017-08-01 11:33:36 -04:00
|
|
|
GIMP_TOOL_LINE_HANDLE_END);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_LINE_HANDLE_END:
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_set_selection (GIMP_TOOL_LINE (gradient_tool->widget),
|
2017-08-01 11:33:36 -04:00
|
|
|
GIMP_TOOL_LINE_HANDLE_START);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-14 00:52:20 +02:00
|
|
|
else if (gradient_tool->render_node &&
|
|
|
|
gegl_node_find_property (gradient_tool->render_node, pspec->name))
|
2017-08-01 11:33:36 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_update_sliders (gradient_tool);
|
2017-08-01 11:33:36 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-01 16:58:13 -04:00
|
|
|
void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_start (GimpGradientTool *gradient_tool)
|
2017-08-01 16:58:13 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
g_signal_connect (gradient_tool->widget, "can-add-slider",
|
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_line_can_add_slider),
|
|
|
|
gradient_tool);
|
|
|
|
g_signal_connect (gradient_tool->widget, "add-slider",
|
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_line_add_slider),
|
|
|
|
gradient_tool);
|
|
|
|
g_signal_connect (gradient_tool->widget, "prepare-to-remove-slider",
|
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_line_prepare_to_remove_slider),
|
|
|
|
gradient_tool);
|
|
|
|
g_signal_connect (gradient_tool->widget, "remove-slider",
|
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_line_remove_slider),
|
|
|
|
gradient_tool);
|
|
|
|
g_signal_connect (gradient_tool->widget, "selection-changed",
|
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_line_selection_changed),
|
|
|
|
gradient_tool);
|
|
|
|
g_signal_connect (gradient_tool->widget, "handle-clicked",
|
|
|
|
G_CALLBACK (gimp_gradient_tool_editor_line_handle_clicked),
|
|
|
|
gradient_tool);
|
2017-08-01 16:58:13 -04:00
|
|
|
}
|
|
|
|
|
2017-08-02 16:31:10 -04:00
|
|
|
void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_halt (GimpGradientTool *gradient_tool)
|
2017-08-02 16:31:10 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
g_clear_object (&gradient_tool->gui);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->edit_count = 0;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gradient_tool->undo_stack)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
g_slist_free_full (gradient_tool->undo_stack,
|
|
|
|
(GDestroyNotify) gimp_gradient_tool_editor_gradient_info_free);
|
|
|
|
gradient_tool->undo_stack = NULL;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gradient_tool->redo_stack)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
g_slist_free_full (gradient_tool->redo_stack,
|
|
|
|
(GDestroyNotify) gimp_gradient_tool_editor_gradient_info_free);
|
|
|
|
gradient_tool->redo_stack = NULL;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gradient_tool->flush_idle_id)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
g_source_remove (gradient_tool->flush_idle_id);
|
|
|
|
gradient_tool->flush_idle_id = 0;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
2017-08-02 16:31:10 -04:00
|
|
|
}
|
|
|
|
|
2017-08-12 11:25:22 -04:00
|
|
|
gboolean
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_line_changed (GimpGradientTool *gradient_tool)
|
2017-08-01 14:04:28 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpGradientOptions *options = GIMP_GRADIENT_TOOL_GET_OPTIONS (gradient_tool);
|
2017-08-01 14:04:28 -04:00
|
|
|
GimpPaintOptions *paint_options = GIMP_PAINT_OPTIONS (options);
|
|
|
|
gdouble offset = options->offset / 100.0;
|
|
|
|
const GimpControllerSlider *sliders;
|
|
|
|
gint n_sliders;
|
|
|
|
gint i;
|
|
|
|
GimpGradientSegment *seg;
|
|
|
|
gboolean changed = FALSE;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gimp_gradient_tool_editor_are_handlers_blocked (gradient_tool))
|
2017-08-12 11:25:22 -04:00
|
|
|
return FALSE;
|
2017-08-01 14:04:28 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (! gradient_tool->gradient || offset == 1.0)
|
2017-08-12 11:25:22 -04:00
|
|
|
return FALSE;
|
2017-08-01 14:04:28 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
sliders = gimp_tool_line_get_sliders (GIMP_TOOL_LINE (gradient_tool->widget),
|
2017-08-01 14:04:28 -04:00
|
|
|
&n_sliders);
|
|
|
|
|
|
|
|
if (n_sliders == 0)
|
2017-08-12 11:25:22 -04:00
|
|
|
return FALSE;
|
2017-08-01 14:04:28 -04:00
|
|
|
|
|
|
|
/* update the midpoints first, since moving the gradient stops may change the
|
|
|
|
* gradient's midpoints w.r.t. the sliders, but not the other way around.
|
|
|
|
*/
|
2018-04-14 00:52:20 +02:00
|
|
|
for (seg = gradient_tool->gradient->segments, i = n_sliders / 2;
|
2017-08-01 14:04:28 -04:00
|
|
|
seg;
|
|
|
|
seg = seg->next, i++)
|
|
|
|
{
|
|
|
|
gdouble value;
|
|
|
|
|
|
|
|
value = sliders[i].value;
|
|
|
|
|
|
|
|
/* adjust slider value according to the offset */
|
|
|
|
value = (value - offset) / (1.0 - offset);
|
|
|
|
|
|
|
|
/* flip the slider value, if necessary */
|
|
|
|
if (paint_options->gradient_options->gradient_reverse)
|
|
|
|
value = 1.0 - value;
|
|
|
|
|
|
|
|
if (fabs (value - seg->middle) > EPSILON)
|
|
|
|
{
|
|
|
|
if (! changed)
|
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_start_edit (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_freeze_gradient (gradient_tool);
|
2017-08-01 14:04:28 -04:00
|
|
|
|
|
|
|
/* refetch the segment, since the gradient might have changed */
|
2018-04-14 00:52:20 +02:00
|
|
|
seg = gimp_gradient_tool_editor_handle_get_segment (gradient_tool, i);
|
2017-08-01 14:04:28 -04:00
|
|
|
|
|
|
|
changed = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
seg->middle = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* update the gradient stops */
|
2018-04-14 00:52:20 +02:00
|
|
|
for (seg = gradient_tool->gradient->segments, i = 0;
|
2017-08-01 14:04:28 -04:00
|
|
|
seg->next;
|
|
|
|
seg = seg->next, i++)
|
|
|
|
{
|
|
|
|
gdouble value;
|
|
|
|
|
|
|
|
value = sliders[i].value;
|
|
|
|
|
|
|
|
/* adjust slider value according to the offset */
|
|
|
|
value = (value - offset) / (1.0 - offset);
|
|
|
|
|
|
|
|
/* flip the slider value, if necessary */
|
|
|
|
if (paint_options->gradient_options->gradient_reverse)
|
|
|
|
value = 1.0 - value;
|
|
|
|
|
|
|
|
if (fabs (value - seg->right) > EPSILON)
|
|
|
|
{
|
|
|
|
if (! changed)
|
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_start_edit (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_freeze_gradient (gradient_tool);
|
2017-08-01 14:04:28 -04:00
|
|
|
|
|
|
|
/* refetch the segment, since the gradient might have changed */
|
2018-04-14 00:52:20 +02:00
|
|
|
seg = gimp_gradient_tool_editor_handle_get_segment (gradient_tool, i);
|
2017-08-01 14:04:28 -04:00
|
|
|
|
|
|
|
changed = TRUE;
|
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_segment_range_compress (gradient_tool->gradient,
|
2017-08-01 14:04:28 -04:00
|
|
|
seg, seg,
|
|
|
|
seg->left, value);
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_segment_range_compress (gradient_tool->gradient,
|
2017-08-01 14:04:28 -04:00
|
|
|
seg->next, seg->next,
|
|
|
|
value, seg->next->right);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_thaw_gradient (gradient_tool);
|
|
|
|
gimp_gradient_tool_editor_end_edit (gradient_tool, FALSE);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
2017-08-02 16:31:10 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_update_gui (gradient_tool);
|
2017-08-12 11:25:22 -04:00
|
|
|
|
|
|
|
return changed;
|
2017-08-01 14:04:28 -04:00
|
|
|
}
|
|
|
|
|
2017-08-04 08:44:32 -04:00
|
|
|
void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_fg_bg_changed (GimpGradientTool *gradient_tool)
|
2017-08-04 08:44:32 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_update_gui (gradient_tool);
|
2017-08-04 08:44:32 -04:00
|
|
|
}
|
|
|
|
|
2017-08-01 11:33:36 -04:00
|
|
|
void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_gradient_dirty (GimpGradientTool *gradient_tool)
|
2017-08-01 11:33:36 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gimp_gradient_tool_editor_are_handlers_blocked (gradient_tool))
|
2017-08-01 11:33:36 -04:00
|
|
|
return;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_purge_gradient (gradient_tool);
|
2017-08-01 11:33:36 -04:00
|
|
|
}
|
|
|
|
|
2017-08-01 09:18:50 -04:00
|
|
|
void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_gradient_changed (GimpGradientTool *gradient_tool)
|
2017-08-01 09:18:50 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpGradientOptions *options = GIMP_GRADIENT_TOOL_GET_OPTIONS (gradient_tool);
|
|
|
|
GimpContext *context = GIMP_CONTEXT (options);
|
2017-08-01 09:18:50 -04:00
|
|
|
|
|
|
|
if (options->modify_active_frame)
|
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive (options->modify_active_frame,
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->gradient !=
|
2017-08-01 09:18:50 -04:00
|
|
|
gimp_gradients_get_custom (context->gimp));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options->modify_active_hint)
|
|
|
|
{
|
|
|
|
gtk_widget_set_visible (options->modify_active_hint,
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->gradient &&
|
|
|
|
! gimp_data_is_writable (GIMP_DATA (gradient_tool->gradient)));
|
2017-08-01 09:18:50 -04:00
|
|
|
}
|
2017-08-01 11:33:36 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gimp_gradient_tool_editor_are_handlers_blocked (gradient_tool))
|
2017-08-01 11:33:36 -04:00
|
|
|
return;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_purge_gradient (gradient_tool);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
const gchar *
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_can_undo (GimpGradientTool *gradient_tool)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
if (! gradient_tool->undo_stack || gradient_tool->edit_count > 0)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
return NULL;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
return _("Gradient Step");
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
const gchar *
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_can_redo (GimpGradientTool *gradient_tool)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
if (! gradient_tool->redo_stack || gradient_tool->edit_count > 0)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
return NULL;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
return _("Gradient Step");
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_undo (GimpGradientTool *gradient_tool)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GimpTool *tool = GIMP_TOOL (gradient_tool);
|
|
|
|
GradientInfo *info;
|
|
|
|
GradientInfo *new_info;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_assert (gradient_tool->undo_stack != NULL);
|
|
|
|
gimp_assert (gradient_tool->edit_count == 0);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
info = gradient_tool->undo_stack->data;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
new_info = gimp_gradient_tool_editor_gradient_info_new (gradient_tool);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
|
|
|
if (info->gradient)
|
2017-08-01 11:33:36 -04:00
|
|
|
{
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
new_info->gradient =
|
2018-04-14 00:52:20 +02:00
|
|
|
GIMP_GRADIENT (gimp_data_duplicate (GIMP_DATA (gradient_tool->gradient)));
|
2017-08-01 11:33:36 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
/* swap the added and removed handles, so that gradient_info_apply() does
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
* the right thing on redo
|
|
|
|
*/
|
|
|
|
new_info->added_handle = info->removed_handle;
|
|
|
|
new_info->removed_handle = info->added_handle;
|
|
|
|
new_info->selected_handle = info->selected_handle;
|
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->undo_stack = g_slist_remove (gradient_tool->undo_stack, info);
|
|
|
|
gradient_tool->redo_stack = g_slist_prepend (gradient_tool->redo_stack, new_info);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_gradient_info_apply (gradient_tool, info, TRUE);
|
|
|
|
gimp_gradient_tool_editor_gradient_info_free (info);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
/* the initial state of the gradient tool is not useful; we might as well halt */
|
|
|
|
if (! gradient_tool->undo_stack)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, tool->display);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_redo (GimpGradientTool *gradient_tool)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GradientInfo *info;
|
|
|
|
GradientInfo *new_info;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_assert (gradient_tool->redo_stack != NULL);
|
|
|
|
gimp_assert (gradient_tool->edit_count == 0);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
info = gradient_tool->redo_stack->data;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
new_info = gimp_gradient_tool_editor_gradient_info_new (gradient_tool);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
|
|
|
if (info->gradient)
|
|
|
|
{
|
|
|
|
new_info->gradient =
|
2018-04-14 00:52:20 +02:00
|
|
|
GIMP_GRADIENT (gimp_data_duplicate (GIMP_DATA (gradient_tool->gradient)));
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
/* swap the added and removed handles, so that gradient_info_apply() does
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
* the right thing on undo
|
|
|
|
*/
|
|
|
|
new_info->added_handle = info->removed_handle;
|
|
|
|
new_info->removed_handle = info->added_handle;
|
|
|
|
new_info->selected_handle = info->selected_handle;
|
|
|
|
}
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->redo_stack = g_slist_remove (gradient_tool->redo_stack, info);
|
|
|
|
gradient_tool->undo_stack = g_slist_prepend (gradient_tool->undo_stack, new_info);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_gradient_info_apply (gradient_tool, info, TRUE);
|
|
|
|
gimp_gradient_tool_editor_gradient_info_free (info);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_start_edit (GimpGradientTool *gradient_tool)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gradient_tool->edit_count++ == 0)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GradientInfo *info;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
info = gimp_gradient_tool_editor_gradient_info_new (gradient_tool);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->undo_stack = g_slist_prepend (gradient_tool->undo_stack, info);
|
2017-11-16 11:03:00 -05:00
|
|
|
|
|
|
|
/* update the undo actions / menu items */
|
2018-04-14 00:52:20 +02:00
|
|
|
if (! gradient_tool->flush_idle_id)
|
2017-11-16 11:03:00 -05:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->flush_idle_id =
|
|
|
|
g_idle_add ((GSourceFunc) gimp_gradient_tool_editor_flush_idle,
|
|
|
|
gradient_tool);
|
2017-11-16 11:03:00 -05:00
|
|
|
}
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_end_edit (GimpGradientTool *gradient_tool,
|
|
|
|
gboolean cancel)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
|
|
|
/* can happen when halting using esc */
|
2018-04-14 00:52:20 +02:00
|
|
|
if (gradient_tool->edit_count == 0)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
return;
|
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
if (--gradient_tool->edit_count == 0)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
GradientInfo *info = gradient_tool->undo_stack->data;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
|
|
|
info->selected_handle =
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_tool_line_get_selection (GIMP_TOOL_LINE (gradient_tool->widget));
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2017-11-16 11:08:15 -05:00
|
|
|
if (cancel ||
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_gradient_info_is_trivial (gradient_tool, info))
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
|
|
|
/* if the edit is canceled, or if nothing changed, undo the last
|
|
|
|
* step
|
|
|
|
*/
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_gradient_info_apply (gradient_tool, info, FALSE);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->undo_stack = g_slist_remove (gradient_tool->undo_stack,
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
info);
|
2018-04-14 00:52:20 +02:00
|
|
|
gimp_gradient_tool_editor_gradient_info_free (info);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* otherwise, blow the redo stack */
|
2018-04-14 00:52:20 +02:00
|
|
|
g_slist_free_full (gradient_tool->redo_stack,
|
|
|
|
(GDestroyNotify) gimp_gradient_tool_editor_gradient_info_free);
|
|
|
|
gradient_tool->redo_stack = NULL;
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* update the undo actions / menu items */
|
2018-04-14 00:52:20 +02:00
|
|
|
if (! gradient_tool->flush_idle_id)
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
{
|
2018-04-14 00:52:20 +02:00
|
|
|
gradient_tool->flush_idle_id =
|
|
|
|
g_idle_add ((GSourceFunc) gimp_gradient_tool_editor_flush_idle,
|
|
|
|
gradient_tool);
|
app: implement tool undo for gradient editing in the blend tool
Move the tool undo functionality of the blend tool to the editor,
and add support for undoing gradient edit operations. Each undo
step that affects the gradient holds, in addition to the line
endpoint poisitions, a copy of the gradient at the beginning of the
operation, as well as necessary information to allow the selection
to "follow" undo. When undoing the operation, the saved gradient
is copied back to the active gradient.
To avoid all kinds of complex scenarios, when the active gradient
changes, or when the gradient is modified externally (e.g., by the
(old) gradient editor), all undo steps that affect the gradient are
deleted from the history, while those that affect only the endpoint
positions are kept.
2017-08-03 19:59:21 -04:00
|
|
|
}
|
2017-08-01 11:33:36 -04:00
|
|
|
}
|
2017-08-01 09:18:50 -04:00
|
|
|
}
|