[gimp] app: add new function gimp_filter_tool_get_drawable_area()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add new function gimp_filter_tool_get_drawable_area()
- Date: Sun, 2 Jul 2017 22:46:35 +0000 (UTC)
commit a2c331011dd6c70f426667bab400b2040c931572
Author: Michael Natterer <mitch gimp org>
Date: Mon Jul 3 00:24:09 2017 +0200
app: add new function gimp_filter_tool_get_drawable_area()
which return's the used drawable's offsets and a GeglRectangle
where the filter is applied according to GimpFilterOptions::region
(either the selection or the whole drawable).
app/tools/gimpfiltertool.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
app/tools/gimpfiltertool.h | 7 ++++++
2 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index 6dd7dd5..837879c 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -1779,3 +1779,55 @@ gimp_filter_tool_set_widget (GimpFilterTool *filter_tool,
GIMP_TOOL (filter_tool)->display);
}
}
+
+gboolean
+gimp_filter_tool_get_drawable_area (GimpFilterTool *filter_tool,
+ gint *drawable_offset_x,
+ gint *drawable_offset_y,
+ GeglRectangle *drawable_area)
+{
+ GimpDrawable *drawable;
+
+ g_return_val_if_fail (GIMP_IS_FILTER_TOOL (filter_tool), FALSE);
+ g_return_val_if_fail (drawable_offset_x != NULL, FALSE);
+ g_return_val_if_fail (drawable_offset_y != NULL, FALSE);
+ g_return_val_if_fail (drawable_area != NULL, FALSE);
+
+ *drawable_offset_x = 0;
+ *drawable_offset_y = 0;
+
+ drawable_area->x = 0;
+ drawable_area->y = 0;
+ drawable_area->width = 1;
+ drawable_area->height = 1;
+
+ drawable = filter_tool->drawable;
+
+ if (drawable)
+ {
+ GimpFilterOptions *options = GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool);
+
+ gimp_item_get_offset (GIMP_ITEM (drawable),
+ drawable_offset_x, drawable_offset_y);
+
+ switch (options->region)
+ {
+ case GIMP_FILTER_REGION_SELECTION:
+ gimp_item_mask_intersect (GIMP_ITEM (drawable),
+ &drawable_area->x,
+ &drawable_area->y,
+ &drawable_area->width,
+ &drawable_area->height);
+ break;
+
+ case GIMP_FILTER_REGION_DRAWABLE:
+ drawable_area->width = gimp_item_get_width (GIMP_ITEM (drawable));
+ drawable_area->height = gimp_item_get_height (GIMP_ITEM (drawable));
+ break;
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/app/tools/gimpfiltertool.h b/app/tools/gimpfiltertool.h
index b3671a0..37f0720 100644
--- a/app/tools/gimpfiltertool.h
+++ b/app/tools/gimpfiltertool.h
@@ -136,13 +136,20 @@ void gimp_filter_tool_enable_color_picking (GimpFilterTool *filter_too
gpointer identifier,
gboolean pick_abyss);
void gimp_filter_tool_disable_color_picking (GimpFilterTool *filter_tool);
+
GtkWidget * gimp_filter_tool_add_color_picker (GimpFilterTool *filter_tool,
gpointer identifier,
const gchar *icon_name,
const gchar *tooltip,
gboolean pick_abyss);
+
void gimp_filter_tool_set_widget (GimpFilterTool *filter_tool,
GimpToolWidget *widget);
+gboolean gimp_filter_tool_get_drawable_area (GimpFilterTool *filter_tool,
+ gint *drawable_offset_x,
+ gint *drawable_offset_y,
+ GeglRectangle *drawable_area);
+
#endif /* __GIMP_FILTER_TOOL_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]