[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57883] branches/soc-2013-paint/source/ blender/editors/sculpt_paint/paint_image.c: Fix sample color operator sampling brush colour.
Antony Riakiotakis
kalast at gmail.com
Sun Jun 30 13:07:20 CEST 2013
Revision: 57883
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57883
Author: psy-fi
Date: 2013-06-30 11:07:20 +0000 (Sun, 30 Jun 2013)
Log Message:
-----------
Fix sample color operator sampling brush colour. Temporarily turn brush
display off while the operator is running.
Modified Paths:
--------------
branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c
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-30 09:55:29 UTC (rev 57882)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c 2013-06-30 11:07:20 UTC (rev 57883)
@@ -963,6 +963,11 @@
}
/******************** sample color operator ********************/
+typedef struct {
+ bool show_cursor;
+ short event_type;
+} SampleColorData;
+
static int sample_color_exec(bContext *C, wmOperator *op)
{
Brush *brush = image_paint_brush(C);
@@ -979,20 +984,34 @@
static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- RNA_int_set_array(op->ptr, "location", event->mval);
- sample_color_exec(C, op);
+ Paint *paint = &(CTX_data_tool_settings(C)->imapaint.paint);
+ SampleColorData *data = MEM_mallocN(sizeof(SampleColorData), "sample color custom data");
+ data->event_type = event->type;
+ data->show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0);
- op->customdata = SET_INT_IN_POINTER(event->type);
+ op->customdata = data;
+ paint->flags &= ~PAINT_SHOW_BRUSH;
WM_event_add_modal_handler(C, op);
+ RNA_int_set_array(op->ptr, "location", event->mval);
+
+ sample_color_exec(C, op);
+
return OPERATOR_RUNNING_MODAL;
}
static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (event->type == (intptr_t)(op->customdata) && event->val == KM_RELEASE)
+ SampleColorData *data = op->customdata;
+ if ((event->type == data->event_type) && (event->val == KM_RELEASE)) {
+ Paint *paint = &(CTX_data_tool_settings(C)->imapaint.paint);
+ if(data->show_cursor) {
+ paint->flags |= PAINT_SHOW_BRUSH;
+ }
+ MEM_freeN(data);
return OPERATOR_FINISHED;
+ }
switch (event->type) {
case MOUSEMOVE:
@@ -1004,28 +1023,6 @@
return OPERATOR_RUNNING_MODAL;
}
-#if 0
-/* same as image_paint_poll but fail when face mask mode is enabled */
-static int image_paint_sample_color_poll(bContext *C)
-{
- if (image_paint_poll(C)) {
- if (CTX_wm_view3d(C)) {
- Object *obact = CTX_data_active_object(C);
- if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) {
- Mesh *me = BKE_mesh_from_object(obact);
- if (me) {
- return !(me->editflag & ME_EDIT_PAINT_FACE_SEL);
- }
- }
- }
-
- return 1;
- }
-
- return 0;
-}
-#endif
-
void PAINT_OT_sample_color(wmOperatorType *ot)
{
/* identifiers */
More information about the Bf-blender-cvs
mailing list