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:
authorNicholas Bishop <nicholasbishop@gmail.com>2009-01-26 00:02:52 +0300
committerNicholas Bishop <nicholasbishop@gmail.com>2009-01-26 00:02:52 +0300
commit3d39996f0fb6dcde3ad91cf7556b8175b0effbd9 (patch)
tree76927db6a28411e7157cd80e5af9b1e8b6c74575 /source/blender/editors
parent3c088f3434f7900d430b01d2e210a0aa529c93bc (diff)
Added radial control support to vpaint and wpaint. Added undo pushes as well.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/sculpt/sculpt.c6
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h2
-rw-r--r--source/blender/editors/space_view3d/view3d_ops.c16
-rw-r--r--source/blender/editors/space_view3d/vpaint.c248
4 files changed, 205 insertions, 67 deletions
diff --git a/source/blender/editors/sculpt/sculpt.c b/source/blender/editors/sculpt/sculpt.c
index 01a09e4162a..d617fde065a 100644
--- a/source/blender/editors/sculpt/sculpt.c
+++ b/source/blender/editors/sculpt/sculpt.c
@@ -1255,7 +1255,11 @@ static int sculpt_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve
static int sculpt_radial_control_exec(bContext *C, wmOperator *op)
{
- return brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->sculpt->brush);
+ int ret = brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->sculpt->brush);
+ char str[256];
+ WM_radial_control_string(op, str, 256);
+ ED_undo_push(C, str);
+ return ret;
}
static void SCULPT_OT_radial_control(wmOperatorType *ot)
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index e5233349ac0..d9b45e19a59 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -107,6 +107,8 @@ void VIEW3D_OT_borderselect(struct wmOperatorType *ot);
void VIEW3D_OT_lasso_select(struct wmOperatorType *ot);
/* vpaint.c */
+void VIEW3D_OT_vpaint_radial_control(struct wmOperatorType *ot);
+void VIEW3D_OT_wpaint_radial_control(struct wmOperatorType *ot);
void VIEW3D_OT_vpaint_toggle(struct wmOperatorType *ot);
void VIEW3D_OT_vpaint(struct wmOperatorType *ot);
void VIEW3D_OT_wpaint_toggle(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index 6d4319a495d..795d29ccde1 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -80,6 +80,8 @@ void view3d_operatortypes(void)
WM_operatortype_append(VIEW3D_OT_lasso_select);
WM_operatortype_append(VIEW3D_OT_setcameratoview);
WM_operatortype_append(VIEW3D_OT_drawtype);
+ WM_operatortype_append(VIEW3D_OT_vpaint_radial_control);
+ WM_operatortype_append(VIEW3D_OT_wpaint_radial_control);
WM_operatortype_append(VIEW3D_OT_vpaint_toggle);
WM_operatortype_append(VIEW3D_OT_wpaint_toggle);
WM_operatortype_append(VIEW3D_OT_vpaint);
@@ -98,10 +100,6 @@ void view3d_keymap(wmWindowManager *wm)
WM_keymap_verify_item(keymap, "VIEW3D_OT_wpaint", LEFTMOUSE, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0);
-
- RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
- RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
- RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", WM_RADIALCONTROL_ANGLE);
WM_keymap_verify_item(keymap, "VIEW3D_OT_cursor3d", ACTIONMOUSE, KM_PRESS, 0, 0);
@@ -168,6 +166,16 @@ void view3d_keymap(wmWindowManager *wm)
WM_keymap_add_item(keymap, "VIEW3D_OT_vpaint_toggle", VKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_wpaint_toggle", TABKEY, KM_PRESS, KM_CTRL, 0);
+ /* radial control */
+ RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
+ RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
+ RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", WM_RADIALCONTROL_ANGLE);
+
+ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_vpaint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
+ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_wpaint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
+ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_vpaint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
+ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_wpaint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
+
/* TODO - this is just while we have no way to load a text datablock */
km = WM_keymap_add_item(keymap, "SCRIPT_OT_run_pyfile", PKEY, KM_PRESS, 0, 0);
RNA_string_set(km->ptr, "filename", "test.py");
diff --git a/source/blender/editors/space_view3d/vpaint.c b/source/blender/editors/space_view3d/vpaint.c
index 568c64572b1..b4b16432245 100644
--- a/source/blender/editors/space_view3d/vpaint.c
+++ b/source/blender/editors/space_view3d/vpaint.c
@@ -61,6 +61,8 @@
#include "DNA_view3d_types.h"
#include "DNA_userdef_types.h"
+#include "RNA_access.h"
+
#include "BKE_armature.h"
#include "BKE_DerivedMesh.h"
#include "BKE_cloth.h"
@@ -105,6 +107,84 @@
static void BIF_undo_push() {}
static void error() {}
+/* polling - retrieve whether cursor should be set or operator should be done */
+
+static int vp_poll(bContext *C)
+{
+ if(G.f & G_VERTEXPAINT) {
+ ScrArea *sa= CTX_wm_area(C);
+ if(sa->spacetype==SPACE_VIEW3D) {
+ ARegion *ar= CTX_wm_region(C);
+ if(ar->regiontype==RGN_TYPE_WINDOW)
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int wp_poll(bContext *C)
+{
+ if(G.f & G_WEIGHTPAINT) {
+ ScrArea *sa= CTX_wm_area(C);
+ if(sa->spacetype==SPACE_VIEW3D) {
+ ARegion *ar= CTX_wm_region(C);
+ if(ar->regiontype==RGN_TYPE_WINDOW)
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
+/* Cursors */
+static void vp_drawcursor(bContext *C, int x, int y, void *customdata)
+{
+ ToolSettings *ts= CTX_data_tool_settings(C);
+
+ glTranslatef((float)x, (float)y, 0.0f);
+
+ glColor4ub(255, 255, 255, 128);
+ glEnable( GL_LINE_SMOOTH );
+ glEnable(GL_BLEND);
+ glutil_draw_lined_arc(0.0, M_PI*2.0, ts->vpaint->size, 40);
+ glDisable(GL_BLEND);
+ glDisable( GL_LINE_SMOOTH );
+
+ glTranslatef((float)-x, (float)-y, 0.0f);
+}
+
+static void wp_drawcursor(bContext *C, int x, int y, void *customdata)
+{
+ ToolSettings *ts= CTX_data_tool_settings(C);
+
+ glTranslatef((float)x, (float)y, 0.0f);
+
+ glColor4ub(200, 200, 255, 128);
+ glEnable( GL_LINE_SMOOTH );
+ glEnable(GL_BLEND);
+ glutil_draw_lined_arc(0.0, M_PI*2.0, ts->wpaint->size, 40);
+ glDisable(GL_BLEND);
+ glDisable( GL_LINE_SMOOTH );
+
+ glTranslatef((float)-x, (float)-y, 0.0f);
+}
+
+static void toggle_paint_cursor(bContext *C, int wpaint)
+{
+ ToolSettings *ts = CTX_data_scene(C)->toolsettings;
+ VPaint *vp = wpaint ? ts->wpaint : ts->vpaint;
+
+ if(vp->paintcursor) {
+ WM_paint_cursor_end(CTX_wm_manager(C), vp->paintcursor);
+ vp->paintcursor = NULL;
+ }
+ else {
+ vp->paintcursor = wpaint ?
+ WM_paint_cursor_activate(CTX_wm_manager(C), wp_poll, wp_drawcursor, NULL) :
+ WM_paint_cursor_activate(CTX_wm_manager(C), vp_poll, vp_drawcursor, NULL);
+ }
+}
+
static VPaint *new_vpaint(int wpaint)
{
VPaint *vp= MEM_callocN(sizeof(VPaint), "VPaint");
@@ -1055,35 +1135,6 @@ static void do_weight_paint_vertex(VPaint *wp, Object *ob, int index, int alpha,
/* *************** set wpaint operator ****************** */
-/* retrieve whether cursor should be set or operator should be done */
-static int wp_poll(bContext *C)
-{
- if(G.f & G_WEIGHTPAINT) {
- ScrArea *sa= CTX_wm_area(C);
- if(sa->spacetype==SPACE_VIEW3D) {
- ARegion *ar= CTX_wm_region(C);
- if(ar->regiontype==RGN_TYPE_WINDOW)
- return 1;
- }
- }
- return 0;
-}
-
-static void wp_drawcursor(bContext *C, int x, int y, void *customdata)
-{
- ToolSettings *ts= CTX_data_tool_settings(C);
-
- glTranslatef((float)x, (float)y, 0.0f);
-
- glColor4ub(200, 200, 255, 128);
- glEnable( GL_LINE_SMOOTH );
- glEnable(GL_BLEND);
- glutil_draw_lined_arc(0.0, M_PI*2.0, ts->wpaint->size, 40);
- glDisable(GL_BLEND);
- glDisable( GL_LINE_SMOOTH );
-
- glTranslatef((float)-x, (float)-y, 0.0f);
-}
static int set_wpaint(bContext *C, wmOperator *op) /* toggle */
{
@@ -1118,7 +1169,7 @@ static int set_wpaint(bContext *C, wmOperator *op) /* toggle */
if(wp==NULL)
wp= scene->toolsettings->wpaint= new_vpaint(1);
- wp->paintcursor = WM_paint_cursor_activate(CTX_wm_manager(C), wp_poll, wp_drawcursor, NULL);
+ toggle_paint_cursor(C, 1);
mesh_octree_table(ob, NULL, NULL, 's');
@@ -1135,7 +1186,7 @@ static int set_wpaint(bContext *C, wmOperator *op) /* toggle */
}
else {
if(wp)
- WM_paint_cursor_end(CTX_wm_manager(C), wp->paintcursor);
+ toggle_paint_cursor(C, 1);
mesh_octree_table(ob, NULL, NULL, 'e');
}
@@ -1158,6 +1209,108 @@ void VIEW3D_OT_wpaint_toggle(wmOperatorType *ot)
}
+/* ************ paint radial controls *************/
+
+void paint_radial_control_invoke(wmOperator *op, VPaint *vp)
+{
+ int mode = RNA_int_get(op->ptr, "mode");
+ float original_value;
+
+ if(mode == WM_RADIALCONTROL_SIZE)
+ original_value = vp->size;
+ else if(mode == WM_RADIALCONTROL_STRENGTH)
+ original_value = vp->a;
+
+ RNA_float_set(op->ptr, "initial_value", original_value);
+}
+
+static int paint_radial_control_exec(wmOperator *op, VPaint *vp)
+{
+ int mode = RNA_int_get(op->ptr, "mode");
+ float new_value = RNA_float_get(op->ptr, "new_value");
+
+ if(mode == WM_RADIALCONTROL_SIZE)
+ vp->size = new_value;
+ else if(mode == WM_RADIALCONTROL_STRENGTH)
+ vp->a = new_value;
+
+ return OPERATOR_FINISHED;
+}
+
+static int vpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ toggle_paint_cursor(C, 0);
+ paint_radial_control_invoke(op, CTX_data_scene(C)->toolsettings->vpaint);
+ return WM_radial_control_invoke(C, op, event);
+}
+
+static int vpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+ int ret = WM_radial_control_modal(C, op, event);
+ if(ret != OPERATOR_RUNNING_MODAL)
+ toggle_paint_cursor(C, 0);
+ return ret;
+}
+
+static int vpaint_radial_control_exec(bContext *C, wmOperator *op)
+{
+ int ret = paint_radial_control_exec(op, CTX_data_scene(C)->toolsettings->vpaint);
+ char str[256];
+ WM_radial_control_string(op, str, 256);
+ ED_undo_push(C, str);
+ return ret;
+}
+
+static int wpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ toggle_paint_cursor(C, 1);
+ paint_radial_control_invoke(op, CTX_data_scene(C)->toolsettings->wpaint);
+ return WM_radial_control_invoke(C, op, event);
+}
+
+static int wpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+ int ret = WM_radial_control_modal(C, op, event);
+ if(ret != OPERATOR_RUNNING_MODAL)
+ toggle_paint_cursor(C, 1);
+ return ret;
+}
+
+static int wpaint_radial_control_exec(bContext *C, wmOperator *op)
+{
+ int ret = paint_radial_control_exec(op, CTX_data_scene(C)->toolsettings->wpaint);
+ char str[256];
+ WM_radial_control_string(op, str, 256);
+ ED_undo_push(C, str);
+ return ret;
+}
+
+void VIEW3D_OT_wpaint_radial_control(wmOperatorType *ot)
+{
+ WM_OT_radial_control_partial(ot);
+
+ ot->name= "Weight Paint Radial Control";
+ ot->idname= "VIEW3D_OT_wpaint_radial_control";
+
+ ot->invoke= wpaint_radial_control_invoke;
+ ot->modal= wpaint_radial_control_modal;
+ ot->exec= wpaint_radial_control_exec;
+ ot->poll= wp_poll;
+}
+
+void VIEW3D_OT_vpaint_radial_control(wmOperatorType *ot)
+{
+ WM_OT_radial_control_partial(ot);
+
+ ot->name= "Vertex Paint Radial Control";
+ ot->idname= "VIEW3D_OT_vpaint_radial_control";
+
+ ot->invoke= vpaint_radial_control_invoke;
+ ot->modal= vpaint_radial_control_modal;
+ ot->exec= vpaint_radial_control_exec;
+ ot->poll= vp_poll;
+}
+
/* ************ weight paint operator ********** */
struct WPaintData {
@@ -1487,35 +1640,6 @@ void VIEW3D_OT_wpaint(wmOperatorType *ot)
/* ************ set / clear vertex paint mode ********** */
-/* retrieve whether cursor should be set or operator should be done */
-static int vp_poll(bContext *C)
-{
- if(G.f & G_VERTEXPAINT) {
- ScrArea *sa= CTX_wm_area(C);
- if(sa->spacetype==SPACE_VIEW3D) {
- ARegion *ar= CTX_wm_region(C);
- if(ar->regiontype==RGN_TYPE_WINDOW)
- return 1;
- }
- }
- return 0;
-}
-
-static void vp_drawcursor(bContext *C, int x, int y, void *customdata)
-{
- ToolSettings *ts= CTX_data_tool_settings(C);
-
- glTranslatef((float)x, (float)y, 0.0f);
-
- glColor4ub(255, 255, 255, 128);
- glEnable( GL_LINE_SMOOTH );
- glEnable(GL_BLEND);
- glutil_draw_lined_arc(0.0, M_PI*2.0, ts->vpaint->size, 40);
- glDisable(GL_BLEND);
- glDisable( GL_LINE_SMOOTH );
-
- glTranslatef((float)-x, (float)-y, 0.0f);
-}
static int set_vpaint(bContext *C, wmOperator *op) /* toggle */
{
@@ -1545,7 +1669,7 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */
G.f &= ~G_VERTEXPAINT;
if(vp) {
- WM_paint_cursor_end(CTX_wm_manager(C), vp->paintcursor);
+ toggle_paint_cursor(C, 0);
vp->paintcursor= NULL;
}
}
@@ -1559,7 +1683,7 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */
if(vp==NULL)
vp= scene->toolsettings->vpaint= new_vpaint(0);
- vp->paintcursor = WM_paint_cursor_activate(CTX_wm_manager(C), vp_poll, vp_drawcursor, NULL);
+ toggle_paint_cursor(C, 0);
}
if (me)