[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57552] branches/soc-2013-paint: Secondary color support in the paint editors, and associated
Antony Riakiotakis
kalast at gmail.com
Tue Jun 18 18:13:29 CEST 2013
Revision: 57552
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57552
Author: psy-fi
Date: 2013-06-18 16:13:28 +0000 (Tue, 18 Jun 2013)
Log Message:
-----------
Secondary color support in the paint editors, and associated
operators:
* X key swaps secondary and primary colour
* Ctrl-lclick painting uses the secondary colour
* Shift-S samples colour for the secondary colour
This can obviously be used for background/foreground palettes it will
obviously be used for gradient effects later on.
Modified Paths:
--------------
branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py
branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py
branches/soc-2013-paint/source/blender/blenkernel/intern/brush.c
branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c
branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_2d.c
branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c
branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h
branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_ops.c
branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_utils.c
branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h
branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c
Modified: branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py
===================================================================
--- branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py 2013-06-18 15:30:51 UTC (rev 57551)
+++ branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py 2013-06-18 16:13:28 UTC (rev 57552)
@@ -700,6 +700,7 @@
if brush.image_tool == 'DRAW' and brush.blend not in ('ERASE_ALPHA', 'ADD_ALPHA'):
col.template_color_picker(brush, "color", value_slider=True)
col.prop(brush, "color", text="")
+ col.prop(brush, "secondary_color", text="")
row = col.row(align=True)
self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
Modified: branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2013-06-18 15:30:51 UTC (rev 57551)
+++ branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2013-06-18 16:13:28 UTC (rev 57552)
@@ -695,6 +695,7 @@
if brush.image_tool == 'DRAW' and brush.blend not in ('ERASE_ALPHA', 'ADD_ALPHA'):
col.template_color_picker(brush, "color", value_slider=True)
col.prop(brush, "color", text="")
+ col.prop(brush, "secondary_color", text="")
row = col.row(align=True)
self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
Modified: branches/soc-2013-paint/source/blender/blenkernel/intern/brush.c
===================================================================
--- branches/soc-2013-paint/source/blender/blenkernel/intern/brush.c 2013-06-18 15:30:51 UTC (rev 57551)
+++ branches/soc-2013-paint/source/blender/blenkernel/intern/brush.c 2013-06-18 16:13:28 UTC (rev 57552)
@@ -95,6 +95,10 @@
brush->rgb[1] = 1.0f;
brush->rgb[2] = 1.0f;
+ brush->secondary_rgb[0] = 0.0f;
+ brush->secondary_rgb[1] = 0.0f;
+ brush->secondary_rgb[2] = 0.0f;
+
/* BRUSH STROKE SETTINGS */
brush->flag |= (BRUSH_SPACE | BRUSH_SPACE_ATTEN);
brush->spacing = 10; /* how far each brush dot should be spaced as a percentage of brush diameter */
Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c 2013-06-18 15:30:51 UTC (rev 57551)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c 2013-06-18 16:13:28 UTC (rev 57552)
@@ -496,7 +496,7 @@
}
else {
pop->mode = PAINT_MODE_2D;
- pop->custom_paint = paint_2d_new_stroke(C, op);
+ pop->custom_paint = paint_2d_new_stroke(C, op, mode);
}
if (!pop->custom_paint) {
@@ -926,9 +926,9 @@
Brush *brush = image_paint_brush(C);
ARegion *ar = CTX_wm_region(C);
int location[2];
-
+ bool foreground = RNA_boolean_get(op->ptr, "foreground");
RNA_int_get_array(op->ptr, "location", location);
- paint_sample_color(C, ar, location[0], location[1]);
+ paint_sample_color(C, ar, location[0], location[1], foreground);
WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
@@ -1000,6 +1000,7 @@
/* properties */
RNA_def_int_vector(ot->srna, "location", 2, NULL, 0, INT_MAX, "Location", "Cursor location in region coordinates", 0, 16384);
+ RNA_def_boolean(ot->srna, "foreground", true, "Foreground", "Sample for the foreground color");
}
/******************** texture paint toggle operator ********************/
@@ -1081,6 +1082,42 @@
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+
+static int texture_colors_flip_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Brush *br = image_paint_brush(C);
+ swap_v3_v3(br->rgb, br->secondary_rgb);
+
+ return OPERATOR_FINISHED;
+}
+
+static int texture_colors_flip_poll(bContext *C)
+{
+ if (image_paint_poll(C)) {
+ Brush *br = image_paint_brush(C);
+ if(br->imagepaint_tool == PAINT_TOOL_DRAW)
+ return 1;
+ }
+
+ return 0;
+}
+
+void PAINT_OT_texture_colors_flip(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Texture Colors Flip";
+ ot->idname = "PAINT_OT_texture_colors_flip";
+ ot->description = "Toggle foreground and background texture paint colors";
+
+ /* api callbacks */
+ ot->exec = texture_colors_flip_exec;
+ ot->poll = texture_colors_flip_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+
static int texture_paint_poll(bContext *C)
{
if (texture_paint_toggle_poll(C))
@@ -1109,4 +1146,3 @@
{
return paint_facesel_test(CTX_data_active_object(C)) || paint_vertsel_test(CTX_data_active_object(C));
}
-
Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_2d.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_2d.c 2013-06-18 15:30:51 UTC (rev 57551)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_2d.c 2013-06-18 16:13:28 UTC (rev 57552)
@@ -75,6 +75,7 @@
bool use_float; /* need float imbuf? */
bool use_color_correction; /* use color correction for float */
bool use_masking; /* use masking? */
+ bool invert_color;
bool is_texbrush;
bool is_maskbrush;
@@ -140,7 +141,7 @@
} ImagePaintState;
-static BrushPainter *brush_painter_2d_new(Scene *scene, Brush *brush)
+static BrushPainter *brush_painter_2d_new(Scene *scene, Brush *brush, bool invert)
{
BrushPainter *painter = MEM_callocN(sizeof(BrushPainter), "BrushPainter");
@@ -148,6 +149,7 @@
painter->scene = scene;
painter->firsttouch = 1;
painter->cache.lastsize = -1; /* force ibuf create in refresh */
+ painter->cache.invert_color = invert;
return painter;
}
@@ -255,7 +257,10 @@
/* get brush color */
if (brush->imagepaint_tool == PAINT_TOOL_DRAW) {
- copy_v3_v3(brush_rgb, brush->rgb);
+ if (painter->cache.invert_color)
+ copy_v3_v3(brush_rgb, brush->secondary_rgb);
+ else
+ copy_v3_v3(brush_rgb, brush->rgb);
if (use_color_correction)
srgb_to_linearrgb_v3_v3(brush_rgb, brush_rgb);
@@ -1058,7 +1063,7 @@
BKE_image_release_ibuf(s->image, ibuf, NULL);
}
-void *paint_2d_new_stroke(bContext *C, wmOperator *op)
+void *paint_2d_new_stroke(bContext *C, wmOperator *op, int mode)
{
Scene *scene = CTX_data_scene(C);
ToolSettings *settings = scene->toolsettings;
@@ -1090,7 +1095,7 @@
paint_brush_init_tex(s->brush);
/* create painter */
- s->painter = brush_painter_2d_new(scene, s->brush);
+ s->painter = brush_painter_2d_new(scene, s->brush, mode == BRUSH_STROKE_INVERT);
return s;
}
Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c 2013-06-18 15:30:51 UTC (rev 57551)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c 2013-06-18 16:13:28 UTC (rev 57552)
@@ -187,6 +187,9 @@
Scene *scene;
int source; /* PROJ_SRC_**** */
+ /* the paint color. It can change depending of interted mode or not */
+ float paint_color[3];
+
Brush *brush;
short tool, blend, mode;
int orig_brush_size;
@@ -3664,7 +3667,7 @@
float rgb[3];
unsigned char rgba_ub[4];
- copy_v3_v3(rgb, ps->brush->rgb);
+ copy_v3_v3(rgb, ps->paint_color);
if (ps->is_texbrush) {
/* XXX actually should convert texrgb from linear to srgb here */
@@ -3686,7 +3689,7 @@
{
float rgba[4];
- srgb_to_linearrgb_v3_v3(rgba, ps->brush->rgb);
+ srgb_to_linearrgb_v3_v3(rgba, ps->paint_color);
if (ps->is_texbrush)
mul_v3_v3(rgba, texrgb);
@@ -4177,6 +4180,12 @@
if (ps->normal_angle_range <= 0.0f)
ps->do_mask_normal = FALSE; /* no need to do blending */
+ if (ps->tool == PAINT_TOOL_DRAW) {
+ if (mode == BRUSH_STROKE_INVERT)
+ copy_v3_v3(ps->paint_color, ps->brush->secondary_rgb);
+ else
+ copy_v3_v3(ps->paint_color, ps->brush->rgb);
+ }
return;
}
Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h 2013-06-18 15:30:51 UTC (rev 57551)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h 2013-06-18 16:13:28 UTC (rev 57552)
@@ -138,7 +138,7 @@
void imapaint_dirty_region(struct Image *ima, struct ImBuf *ibuf, int x, int y, int w, int h);
void imapaint_region_tiles(struct ImBuf *ibuf, int x, int y, int w, int h, int *tx, int *ty, int *tw, int *th);
int get_imapaint_zoom(struct bContext *C, float *zoomx, float *zoomy);
-void *paint_2d_new_stroke(struct bContext *, struct wmOperator *);
+void *paint_2d_new_stroke(struct bContext *, struct wmOperator *, int mode);
void paint_2d_redraw(const bContext *C, void *ps, bool final);
void paint_2d_stroke_done(void *ps);
void paint_2d_stroke(void *ps, const float prev_mval[2], const float mval[2], int eraser);
@@ -151,6 +151,7 @@
void PAINT_OT_grab_clone(struct wmOperatorType *ot);
void PAINT_OT_sample_color(struct wmOperatorType *ot);
+void PAINT_OT_texture_colors_flip(struct wmOperatorType *ot);
void PAINT_OT_texture_paint_toggle(struct wmOperatorType *ot);
void PAINT_OT_project_image(struct wmOperatorType *ot);
void PAINT_OT_image_from_view(struct wmOperatorType *ot);
@@ -191,7 +192,7 @@
void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]);
void brush_drawcursor_texpaint_uvsculpt(struct bContext *C, int x, int y, void *customdata);
-void paint_sample_color(const struct bContext *C, struct ARegion *ar, int x, int y);
+void paint_sample_color(const struct bContext *C, struct ARegion *ar, int x, int y, bool foreground);
void BRUSH_OT_curve_preset(struct wmOperatorType *ot);
void PAINT_OT_face_select_linked(struct wmOperatorType *ot);
Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_ops.c 2013-06-18 15:30:51 UTC (rev 57551)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_ops.c 2013-06-18 16:13:28 UTC (rev 57552)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list