Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_image.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c55
1 files changed, 33 insertions, 22 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index feff02fa121..a5d4ff98b4b 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -792,6 +792,7 @@ static void toggle_paint_cursor(bContext *C, int enable)
if (settings->imapaint.paintcursor && !enable) {
WM_paint_cursor_end(wm, settings->imapaint.paintcursor);
settings->imapaint.paintcursor = NULL;
+ paint_cursor_delete_textures();
}
else if (enable)
paint_cursor_start(C, image_paint_poll);
@@ -820,6 +821,9 @@ void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings)
paint_cursor_start_explicit(&imapaint->paint, wm, image_paint_poll);
}
+ else {
+ paint_cursor_delete_textures();
+ }
}
/************************ grab clone operator ************************/
@@ -922,9 +926,15 @@ void PAINT_OT_grab_clone(wmOperatorType *ot)
}
/******************** 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);
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ Brush *brush = BKE_paint_brush(paint);
ARegion *ar = CTX_wm_region(C);
int location[2];
@@ -938,11 +948,17 @@ static int sample_color_exec(bContext *C, wmOperator *op)
static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ 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 = data;
+ paint->flags &= ~PAINT_SHOW_BRUSH;
+
RNA_int_set_array(op->ptr, "location", event->mval);
sample_color_exec(C, op);
- op->customdata = SET_INT_IN_POINTER(event->type);
-
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
@@ -950,8 +966,18 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event
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 = BKE_paint_get_active_from_context(C);
+
+ if(data->show_cursor) {
+ paint->flags |= PAINT_SHOW_BRUSH;
+ }
+
+ MEM_freeN(data);
return OPERATOR_FINISHED;
+ }
switch (event->type) {
case MOUSEMOVE:
@@ -963,24 +989,9 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-/* same as image_paint_poll but fail when face mask mode is enabled */
-static int image_paint_sample_color_poll(bContext *C)
+static int 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;
+ return (image_paint_poll(C) || vertex_paint_poll(C));
}
void PAINT_OT_sample_color(wmOperatorType *ot)
@@ -994,7 +1005,7 @@ void PAINT_OT_sample_color(wmOperatorType *ot)
ot->exec = sample_color_exec;
ot->invoke = sample_color_invoke;
ot->modal = sample_color_modal;
- ot->poll = image_paint_sample_color_poll;
+ ot->poll = sample_color_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;