[gimp] app: reset GimpFilterTool widget when resetting settings
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: reset GimpFilterTool widget when resetting settings
- Date: Sun, 18 Mar 2018 18:35:32 +0000 (UTC)
commit cada28e91ed1273b4b21d8b96aabf8c56d94773a
Author: Ell <ell_se yahoo com>
Date: Sun Mar 18 14:14:53 2018 -0400
app: reset GimpFilterTool widget when resetting settings
Add a gimp_filter_tool_reset_widget() function, which resets the
tool widget associated with the filter's controller -- i.e., it
resets those properties of the widget that aren't controlled by the
op's properties to some "default" state. For most controller types
this is a NOP; for transform-grid controllers, we move the pivot
back to the center of the drawable, w.r.t. the current transform.
Call gimp_filter_tool_reset_widget() after resetting or reloading
the tool's config.
app/tools/gimpfiltertool-widgets.c | 62 ++++++++++++++++++++++++++++++++++++
app/tools/gimpfiltertool-widgets.h | 3 ++
app/tools/gimpfiltertool.c | 6 +++
3 files changed, 71 insertions(+), 0 deletions(-)
---
diff --git a/app/tools/gimpfiltertool-widgets.c b/app/tools/gimpfiltertool-widgets.c
index acbc073..2f78286 100644
--- a/app/tools/gimpfiltertool-widgets.c
+++ b/app/tools/gimpfiltertool-widgets.c
@@ -189,6 +189,68 @@ gimp_filter_tool_create_widget (GimpFilterTool *filter_tool,
return controller->widget;
}
+void
+gimp_filter_tool_reset_widget (GimpFilterTool *filter_tool,
+ GimpToolWidget *widget)
+{
+ Controller *controller;
+
+ g_return_if_fail (GIMP_IS_FILTER_TOOL (filter_tool));
+ g_return_if_fail (GIMP_IS_TOOL_WIDGET (widget));
+
+ controller = g_object_get_data (G_OBJECT (filter_tool->widget),
+ "controller");
+
+ g_return_if_fail (controller != NULL);
+
+ switch (controller->controller_type)
+ {
+ case GIMP_CONTROLLER_TYPE_TRANSFORM_GRID:
+ {
+ GimpMatrix3 *transform;
+ gint off_x, off_y;
+ GeglRectangle area;
+ gdouble x1, y1;
+ gdouble x2, y2;
+ gdouble pivot_x, pivot_y;
+
+ g_object_get (controller->widget,
+ "transform", &transform,
+ NULL);
+
+ gimp_filter_tool_get_drawable_area (filter_tool, &off_x, &off_y, &area);
+
+ x1 = off_x + area.x;
+ y1 = off_y + area.y;
+ x2 = x1 + area.width;
+ y2 = y1 + area.height;
+
+ gimp_matrix3_transform_point (transform,
+ (x1 + x2) / 2.0, (y1 + y2) / 2.0,
+ &pivot_x, &pivot_y);
+
+ g_signal_handlers_block_by_func (controller->widget,
+ gimp_filter_tool_transform_grid_changed,
+ controller);
+
+ g_object_set (controller->widget,
+ "pivot-x", pivot_x,
+ "pivot-y", pivot_y,
+ NULL);
+
+ g_signal_handlers_unblock_by_func (controller->widget,
+ gimp_filter_tool_transform_grid_changed,
+ controller);
+
+ g_free (transform);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
/* private functions */
diff --git a/app/tools/gimpfiltertool-widgets.h b/app/tools/gimpfiltertool-widgets.h
index 91d1831..08c0de0 100644
--- a/app/tools/gimpfiltertool-widgets.h
+++ b/app/tools/gimpfiltertool-widgets.h
@@ -29,5 +29,8 @@ GimpToolWidget * gimp_filter_tool_create_widget (GimpFilterTool *filter_tool
GCallback *set_func,
gpointer *set_func_data);
+void gimp_filter_tool_reset_widget (GimpFilterTool *filter_tool,
+ GimpToolWidget *widget);
+
#endif /* __GIMP_FILTER_TOOL_WIDGETS_H__ */
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index 3b0bab6..a090c3a 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -1034,6 +1034,9 @@ gimp_filter_tool_reset (GimpFilterTool *filter_tool)
if (filter_tool->config)
g_object_thaw_notify (filter_tool->config);
+
+ if (filter_tool->widget)
+ gimp_filter_tool_reset_widget (filter_tool, filter_tool->widget);
}
static void
@@ -1453,6 +1456,9 @@ gimp_filter_tool_set_config (GimpFilterTool *filter_tool,
g_return_if_fail (GIMP_IS_SETTINGS (config));
GIMP_FILTER_TOOL_GET_CLASS (filter_tool)->set_config (filter_tool, config);
+
+ if (filter_tool->widget)
+ gimp_filter_tool_reset_widget (filter_tool, filter_tool->widget);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]