[gimp/soc-2009-siox-drb] alter 'key' to 'button'
- From: Jie Ding <jieding src gnome org>
- To: svn-commits-list gnome org
- Subject: [gimp/soc-2009-siox-drb] alter 'key' to 'button'
- Date: Wed, 15 Jul 2009 17:54:49 +0000 (UTC)
commit 44069e345bc17afb6e3fccdbd53ad56e7ab956f3
Author: Jie Ding <jieding src gnome org>
Date: Thu Jul 16 01:53:02 2009 +0800
alter 'key' to 'button'
app/base/base-enums.h | 11 ++++-
app/base/siox.c | 50 +++++++++++-------------
app/base/siox.h | 2 +-
app/core/gimpdrawable-foreground-extract.c | 10 +++-
app/tools/gimpforegroundselectoptions.c | 23 ++++++++++-
app/tools/gimpforegroundselectoptions.h | 1 +
app/tools/gimpforegroundselecttool.c | 59 +++++++++++++++-------------
7 files changed, 95 insertions(+), 61 deletions(-)
---
diff --git a/app/base/base-enums.h b/app/base/base-enums.h
index 34c532c..e135838 100644
--- a/app/base/base-enums.h
+++ b/app/base/base-enums.h
@@ -141,7 +141,14 @@ typedef enum /*< pdb-skip, skip >*///(new)
SIOX_DRB_CHANGE_SENSITIVITY = (1 << 3),
SIOX_DRB_CHANGE_SMOOTHNESS = (1 << 4),
SIOX_DRB_RECALCULATE = 0xFF
-} SioxDRBType;
-
+} SioxDRBType;/*
+typedef enum /*< pdb-skip, skip >///(new)
+{
+ SIOX_DRB_ADD = 0,
+ SIOX_DRB_SUBTRACT = 1,
+ SIOX_DRB_NO_CHANGE = (1 << 1),
+ // SIOX_DRB_CHANGE_THRESHOLD = (1 << 2),/* threshold /
+ SIOX_DRB_RECALCULATE = 0xFF
+} SioxDRBType;*/
#endif /* __BASE_ENUMS_H__ */
diff --git a/app/base/siox.c b/app/base/siox.c
index c6b83c3..8e42064 100644
--- a/app/base/siox.c
+++ b/app/base/siox.c
@@ -1289,50 +1289,45 @@ siox_drb (SioxState *state,
gint x,
gint y,
gint brush_radius,
- SioxDRBType optionsrefinement,\
+ gint brush_mode,
gfloat threshold)
{
PixelRegion srcPR;
PixelRegion mapPR;
gpointer pr;
gint row, col;
- gint brush_mode;//
+
g_return_if_fail (state != NULL);
g_return_if_fail (mask != NULL && tile_manager_bpp (mask) == 1);
-/*
- if (optionsrefinement & SIOX_DRB_ADD)
- g_hash_table_foreach_remove(state->cache,siox_cache_remove_bg,NULL);
- if (optionsrefinement & SIOX_DRB_SUBTRACT)
- g_hash_table_foreach_remove(state->cache,siox_cache_remove_fg,NULL);
- if (optionsrefinement & SIOX_DRB_CHANGE_THRESHOLD)
- optionsrefinement = SIOX_DRB_RECALCULATE;
-
+
+
+
+
/*pixel_region_init (&srcPR, state->pixels,
x - brush_radius, y - brush_radius, brush_radius * 2,
brush_radius * 2, FALSE);
pixel_region_init (&mapPR, mask, x - brush_radius, y - brush_radius,
brush_radius * 2, brush_radius * 2, TRUE);
-*/
- /* pixel_region_init (&srcPR, state->pixels,
- x , y , state->width, state->height, FALSE);
+
+ pixel_region_init (&srcPR, state->pixels,
+ x , y , brush_radius * 2, brush_radius * 2, FALSE);
pixel_region_init (&mapPR, mask, x, y,
- brush_radius * 2,
+ brush_radius * 2,
brush_radius * 2, TRUE);
-*/
+*/
+
pixel_region_init (&srcPR, state->pixels,
- x , y , state->width, state->height, FALSE);
+ x , y , brush_radius * 2,brush_radius * 2, FALSE);
pixel_region_init (&mapPR, mask, x, y,
- brush_radius * 2,
+ brush_radius * 2,
brush_radius * 2, TRUE);
-/*
-
-*/
+
for (pr = pixel_regions_register (2, &srcPR, &mapPR);
pr != NULL;
pr = pixel_regions_process (pr))
- {
+ {printf("pr\n");
const guchar *src = srcPR.data;
guchar *map = mapPR.data;
@@ -1342,7 +1337,7 @@ siox_drb (SioxState *state,
guchar *m = map;
for (col = 0; col < srcPR.w; col++, m++, s += state->bpp)
- {
+ {printf("m = %d,col =%d \n",m,col);
gint key;
classresult *cr;
gfloat mindistbg;
@@ -1359,8 +1354,8 @@ siox_drb (SioxState *state,
mindistbg = (gfloat) sqrt (cr->bgdist);
mindistfg = (gfloat) sqrt (cr->fgdist);
- if (optionsrefinement & SIOX_DRB_ADD)
- {printf("siox_drb SIOX_DRB_ADD \n");
+ if (brush_mode == 0)
+ {printf("SIOX_DRB_ADD \n");
if (*m > SIOX_HIGH)
continue;
@@ -1375,7 +1370,7 @@ siox_drb (SioxState *state,
alpha = MIN (d, 1.0);
}
}
- else if (optionsrefinement & SIOX_DRB_SUBTRACT) /*if (brush_mode == SIOX_DRB_SUBTRACT)*/
+ else if (brush_mode == 1) /*if (brush_mode == SIOX_DRB_SUBTRACT)*/
{
if (*m < SIOX_HIGH)
continue;
@@ -1403,12 +1398,13 @@ siox_drb (SioxState *state,
{
*m = (gint) (255.999 * alpha);
}
- }
-
+
+ }
src += srcPR.rowstride;
map += mapPR.rowstride;
}
}
+
}
/**
diff --git a/app/base/siox.h b/app/base/siox.h
index 78f3df9..5be96d1 100644
--- a/app/base/siox.h
+++ b/app/base/siox.h
@@ -77,7 +77,7 @@ void siox_drb (SioxState *state,
gint x,
gint y,
gint brush_radius,
- SioxDRBType optionsrefinement,
+ gint brush_mode,
gfloat threshold);
diff --git a/app/core/gimpdrawable-foreground-extract.c b/app/core/gimpdrawable-foreground-extract.c
index d12a12c..d2dbc34 100644
--- a/app/core/gimpdrawable-foreground-extract.c
+++ b/app/core/gimpdrawable-foreground-extract.c
@@ -194,13 +194,17 @@ gimp_drawable_foreground_extract_siox_drb (TileManager *mask,
{
gint x = (state->x);
gint y = (state->y);
+ gint brush_mode;
+ if (optionsrefinement == SIOX_DRB_ADD)
+ brush_mode = 0;
+ else if(optionsrefinement == SIOX_DRB_SUBTRACT)
+ brush_mode = 1;
siox_drb (state,
mask,
x,y,
radius,
- optionsrefinement,
- optionsthreshold,
- progress);
+ brush_mode,
+ optionsthreshold);
}
diff --git a/app/tools/gimpforegroundselectoptions.c b/app/tools/gimpforegroundselectoptions.c
index 5059f6c..2abc0fe 100644
--- a/app/tools/gimpforegroundselectoptions.c
+++ b/app/tools/gimpforegroundselectoptions.c
@@ -40,6 +40,7 @@ enum
PROP_ANTIALIAS,
PROP_CONTIGUOUS,
PROP_BACKGROUND,
+ PROP_DRB,
PROP_REFINEMENT,
PROP_STROKE_WIDTH,
PROP_SMOOTHNESS,
@@ -92,6 +93,12 @@ gimp_foreground_select_options_class_init (GimpForegroundSelectOptionsClass *kla
FALSE,
GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_DRB,
+ "drb",
+ _("drb can use"),
+ FALSE,
+ GIMP_PARAM_STATIC_STRINGS);
+
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_REFINEMENT,
"refinement", NULL,
FALSE,
@@ -175,6 +182,10 @@ gimp_foreground_select_options_set_property (GObject *object,
options->background = g_value_get_boolean (value);
break;
+ case PROP_DRB:
+ options->drb = g_value_get_boolean (value);
+ break;
+
case PROP_REFINEMENT:
options->refinement = g_value_get_boolean (value);
break;
@@ -238,7 +249,11 @@ gimp_foreground_select_options_get_property (GObject *object,
case PROP_BACKGROUND:
g_value_set_boolean (value, options->background);
break;
-
+
+ case PROP_DRB:
+ g_value_set_boolean (value, options->drb);
+ break;
+
case PROP_REFINEMENT:
g_value_set_boolean (value, options->refinement);
break;
@@ -289,6 +304,7 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
GtkWidget *hbox;
GtkWidget *button;
GtkWidget *frame;
+ GObject *drb = G_OBJECT (tool_options);
GtkWidget *frame_drb;
GtkWidget *scale;
GtkWidget *scale_t;
@@ -321,6 +337,11 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
+ /* drb */
+ button = gimp_prop_check_button_new (drb, "drb", _("DRB"));
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_widget_show (button);
+
/* add / subtract */
title = g_strdup_printf (_("Detail Refinement Brush (%s)"),
gimp_get_mod_string (GDK_CONTROL_MASK));
diff --git a/app/tools/gimpforegroundselectoptions.h b/app/tools/gimpforegroundselectoptions.h
index 47e8c89..a7af190 100644
--- a/app/tools/gimpforegroundselectoptions.h
+++ b/app/tools/gimpforegroundselectoptions.h
@@ -39,6 +39,7 @@ struct _GimpForegroundSelectOptions
gboolean contiguous;
gboolean background;
+ gboolean drb;
gboolean refinement;
gint stroke_width;
gint smoothness;
diff --git a/app/tools/gimpforegroundselecttool.c b/app/tools/gimpforegroundselecttool.c
index 55e1421..30d048d 100644
--- a/app/tools/gimpforegroundselecttool.c
+++ b/app/tools/gimpforegroundselecttool.c
@@ -58,6 +58,7 @@ typedef struct
{
gint width;
gboolean background;
+ gboolean drbrefinement;
gint num_points;
GimpVector2 *points;
} FgSelectStroke;
@@ -280,12 +281,12 @@ gimp_foreground_select_tool_control (GimpTool *tool,
g_slice_free (FgSelectStroke, stroke);
}
for (drblist = fg_select->drbsignals; drblist; drblist = drblist->next)
- {
- FgSelectStroke *drbsignal = drblist->data;
+ {
+ FgSelectStroke *drbsignal = drblist->data;
- g_free (drbsignal->points);
- g_slice_free (FgSelectStroke, drbsignal);
- }
+ g_free (drbsignal->points);
+ g_slice_free (FgSelectStroke, drbsignal);
+ }
g_list_free (fg_select->strokes);
fg_select->strokes = NULL;
@@ -338,7 +339,7 @@ gimp_foreground_select_tool_oper_update (GimpTool *tool,
if (fg_select->strokes)
{
if(!fg_select->drbsignal)
- status = _("Add more strokes or press Up to drb");
+ status = _("Add more strokes or click buttondrb to drb");
else
status = _("Add more drb or press Enter to accept the selection");
}
@@ -433,13 +434,7 @@ gimp_foreground_select_tool_key_press (GimpTool *tool,
if (fg_select->state)
{
switch (kevent->keyval)
- {
- case GDK_Up:
- mark_drb = TRUE;
- printf("click Up\n");
- G_CALLBACK (gimp_foreground_select_options_notify);
- return TRUE;
-
+ {
case GDK_Return:
case GDK_KP_Enter:
case GDK_ISO_Enter:
@@ -667,7 +662,7 @@ gimp_foreground_select_tool_draw (GimpDrawTool *draw_tool)
fg_select->drbsignal->len,
GIMP_CONTEXT (options),
(options->refinement ?
- GIMP_ACTIVE_COLOR_BACKGROUND :
+ GIMP_ACTIVE_COLOR_FOREGROUND :
GIMP_ACTIVE_COLOR_BACKGROUND),
options->stroke_width);
}
@@ -726,6 +721,8 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
fg_select = GIMP_FOREGROUND_SELECT_TOOL (free_sel);
options = GIMP_FOREGROUND_SELECT_TOOL_GET_OPTIONS (free_sel);
printf("mark_drb = %d\n",mark_drb);
+ printf(" fg_select->refinement\n", fg_select->refinement);
+ printf("options->refinement\n", options->refinement);
if (fg_select->idle_id)
{
g_source_remove (fg_select->idle_id);
@@ -734,7 +731,10 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
if (! drawable)
return;
-
+ if (options->drb)
+ mark_drb = TRUE;
+ else
+ mark_drb = FALSE;
scan_convert = gimp_scan_convert_new ();
gimp_free_select_tool_get_points (free_sel,
@@ -755,7 +755,7 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
0, 0, 128);
gimp_scan_convert_free (scan_convert);
-
+printf(" fg_select->refinement\n", fg_select->refinement);
if (fg_select->strokes)
{
GList *list;
@@ -780,8 +780,8 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
fg_select->drbrefinement,
options->sensitivity,
! options->contiguous,
- mark_drb,
- options->stroke_width,
+ options->drb,
+ options->stroke_width/2,
GIMP_PROGRESS (display));
fg_select->refinement = SIOX_REFINEMENT_NO_CHANGE;
@@ -917,9 +917,14 @@ gimp_foreground_select_tool_stroke (GimpChannel *mask,
stroke->width,
GIMP_JOIN_ROUND, GIMP_CAP_ROUND, 10.0,
0.0, NULL);
- gimp_scan_convert_compose_value (scan_convert,
- gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
- 0, 0, stroke->background ? 0 : 255);
+ if (!mark_drb)
+ gimp_scan_convert_compose_value (scan_convert,
+ gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
+ 0, 0, stroke->background ? 0 : 255);
+ if (mark_drb)
+ gimp_scan_convert_compose_value (scan_convert,
+ gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
+ 0, 0, stroke->drbrefinement ? 0 : 255);
gimp_scan_convert_free (scan_convert);
}
@@ -949,13 +954,13 @@ if (!mark_drb)
SIOX_REFINEMENT_ADD_BACKGROUND :
SIOX_REFINEMENT_ADD_FOREGROUND);
}
-else
+else if (mark_drb)
{
g_return_if_fail (fg_select->drbsignal != NULL);
stroke = g_slice_new (FgSelectStroke);
- stroke->background = options->refinement;
+ stroke->drbrefinement = options->refinement;
stroke->width = ROUND ((gdouble) options->stroke_width / shell->scale_y);
stroke->num_points = fg_select->drbsignal->len;
stroke->points = (GimpVector2 *) g_array_free (fg_select->drbsignal, FALSE);
@@ -964,9 +969,9 @@ else
fg_select->drbsignals = g_list_append (fg_select->drbsignals, stroke);
- fg_select->drbrefinement |= (stroke->background?
- SIOX_DRB_ADD :
- SIOX_DRB_SUBTRACT);
+ fg_select->drbrefinement |= (stroke->drbrefinement?
+ SIOX_DRB_SUBTRACT :
+ SIOX_DRB_ADD);
}
}
@@ -1042,7 +1047,7 @@ gimp_foreground_select_options_notify (GimpForegroundSelectOptions *options,
(GSourceFunc) gimp_foreground_select_tool_idle_select,
fg_select, NULL);
}
- if (g_str_has_prefix (pspec->name, "mask-color"))
+ if (g_str_has_prefix (pspec->name, "mask-color"))
{
GimpTool *tool = GIMP_TOOL (fg_select);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]