[gimp] app: correct outline calculation to match mypaint and add fallback
- From: Alexia Death <alexiade src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: correct outline calculation to match mypaint and add fallback
- Date: Tue, 29 Dec 2015 17:38:10 +0000 (UTC)
commit ee9e0da72d9703efb6f4bc6b786f3c083c6e64ce
Author: Alexia Death <alexiadeath gmail com>
Date: Tue Dec 29 19:30:44 2015 +0200
app: correct outline calculation to match mypaint and add fallback
app/tools/gimpmybrushtool.c | 43 ++++++++++++++++++++++++++++++++++++++++---
app/tools/gimpmybrushtool.h | 5 +++++
2 files changed, 45 insertions(+), 3 deletions(-)
---
diff --git a/app/tools/gimpmybrushtool.c b/app/tools/gimpmybrushtool.c
index a929551..20cf552 100644
--- a/app/tools/gimpmybrushtool.c
+++ b/app/tools/gimpmybrushtool.c
@@ -27,6 +27,10 @@
#include "paint/gimpmybrushoptions.h"
+#include "display/gimpdisplay.h"
+#include "display/gimpdisplayshell.h"
+#include "display/gimpcanvasarc.h"
+
#include "core/gimp.h"
#include "widgets/gimphelp-ids.h"
@@ -37,7 +41,6 @@
#include "gimp-intl.h"
-
G_DEFINE_TYPE (GimpMybrushTool, gimp_mybrush_tool, GIMP_TYPE_PAINT_TOOL)
#define parent_class gimp_mybrush_tool_parent_class
@@ -119,9 +122,43 @@ gimp_mybrush_tool_get_outline (GimpPaintTool *paint_tool,
gdouble y)
{
GimpMybrushOptions *options = GIMP_MYBRUSH_TOOL_GET_OPTIONS (paint_tool);
+ GimpCanvasItem *item = NULL;
+ GimpDisplayShell *shell = gimp_display_get_shell (display);
+
+ gdouble radius = MAX (MAX (4 / shell->scale_x, 4 / shell->scale_y), exp (options->radius) +
options->radius * 2);
+
+ item = gimp_mybrush_tool_create_cursor (paint_tool, display, x, y, radius);
+
+ if (! item)
+ {
+ gimp_paint_tool_set_draw_fallback (paint_tool,
+ TRUE, radius);
+ }
+
+ return item;
+}
+
+GimpCanvasItem *
+gimp_mybrush_tool_create_cursor (GimpPaintTool *paint_tool,
+ GimpDisplay *display,
+ gdouble x,
+ gdouble y,
+ gdouble radius)
+{
+
+ GimpDisplayShell *shell;
- gimp_paint_tool_set_draw_circle (paint_tool, TRUE,
- exp (options->radius));
+ g_return_val_if_fail (GIMP_IS_PAINT_TOOL (paint_tool), NULL);
+ g_return_val_if_fail (GIMP_IS_DISPLAY (display), NULL);
+
+ shell = gimp_display_get_shell (display);
+
+ /* don't draw the boundary if it becomes too small */
+ if (SCALEX (shell, radius) > 4 &&
+ SCALEY (shell, radius) > 4)
+ {
+ return gimp_canvas_arc_new(shell, x, y, radius, radius, 0.0, 2 * G_PI, FALSE);
+ }
return NULL;
}
diff --git a/app/tools/gimpmybrushtool.h b/app/tools/gimpmybrushtool.h
index 15ed40f..544834e 100644
--- a/app/tools/gimpmybrushtool.h
+++ b/app/tools/gimpmybrushtool.h
@@ -51,5 +51,10 @@ void gimp_mybrush_tool_register (GimpToolRegisterCallback callback,
GType gimp_mybrush_tool_get_type (void) G_GNUC_CONST;
+GimpCanvasItem * gimp_mybrush_tool_create_cursor (GimpPaintTool *paint_tool,
+ GimpDisplay *display,
+ gdouble x,
+ gdouble y,
+ gdouble radius);
#endif /* __GIMP_MYBRUSH_TOOL_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]