2.5/Paint modes:
authorNicholas Bishop <nicholasbishop@gmail.com>
Fri, 14 Aug 2009 04:45:29 +0000 (04:45 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Fri, 14 Aug 2009 04:45:29 +0000 (04:45 +0000)
* Moved brush curve preset operator out of sculpt to paint_utils
* Added a button to the curve panel to set the preset

release/ui/space_view3d_toolbar.py
source/blender/editors/sculpt_paint/paint_intern.h
source/blender/editors/sculpt_paint/paint_ops.c
source/blender/editors/sculpt_paint/paint_utils.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_view3d/view3d_header.c

index 6edf57c7f582181218968ef003f9ca01c8aad506..53534de52abb725ff37618ad6043974873d48446 100644 (file)
@@ -460,6 +460,7 @@ class VIEW3D_PT_tools_brush_curve(PaintPanel):
                layout = self.layout
 
                layout.template_curve_mapping(brush.curve)
                layout = self.layout
 
                layout.template_curve_mapping(brush.curve)
+               layout.item_menu_enumO("brush.curve_preset", property="shape")
                
 class VIEW3D_PT_sculpt_options(PaintPanel):
        __label__ = "Options"
                
 class VIEW3D_PT_sculpt_options(PaintPanel):
        __label__ = "Options"
index b630975c934f6e625b082d6d3016a3ba08664156..40423e17fe43bb7db681357c2de374e98c1c0a8d 100644 (file)
@@ -59,6 +59,7 @@ int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, int *mval, unsig
 void imapaint_pick_uv(struct Scene *scene, struct Object *ob, struct Mesh *mesh, unsigned int faceindex, int *xy, float *uv);
 
 void paint_sample_color(struct Scene *scene, struct ARegion *ar, int x, int y);
 void imapaint_pick_uv(struct Scene *scene, struct Object *ob, struct Mesh *mesh, unsigned int faceindex, int *xy, float *uv);
 
 void paint_sample_color(struct Scene *scene, struct ARegion *ar, int x, int y);
+void BRUSH_OT_curve_preset(struct wmOperatorType *ot);
 
 #endif /* ED_PAINT_INTERN_H */
 
 
 #endif /* ED_PAINT_INTERN_H */
 
index e9263ddabf0683d13f991a951fddcfbf5e4040c7..e5500960a6e8e9d217c3f2ceb8fc099f411df6e2 100644 (file)
@@ -10,6 +10,9 @@
 
 void ED_operatortypes_paint(void)
 {
 
 void ED_operatortypes_paint(void)
 {
+       /* brush */
+       WM_operatortype_append(BRUSH_OT_curve_preset);
+
        /* image */
        WM_operatortype_append(PAINT_OT_texture_paint_toggle);
        WM_operatortype_append(PAINT_OT_texture_paint_radial_control);
        /* image */
        WM_operatortype_append(PAINT_OT_texture_paint_toggle);
        WM_operatortype_append(PAINT_OT_texture_paint_radial_control);
index 85ea55331dcb416f90c45d8e38818b8c34ec29da..8120e23f5f24f5447bd4519e800d4c3fbdb72bf2 100644 (file)
@@ -5,13 +5,18 @@
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
+
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_view3d_types.h"
 
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_view3d_types.h"
 
+#include "RNA_access.h"
+#include "RNA_define.h"
+
 #include "BLI_arithb.h"
 
 #include "BKE_brush.h"
 #include "BLI_arithb.h"
 
 #include "BKE_brush.h"
+#include "BKE_context.h"
 #include "BKE_DerivedMesh.h"
 #include "BKE_global.h"
 #include "BKE_utildefines.h"
 #include "BKE_DerivedMesh.h"
 #include "BKE_global.h"
 #include "BKE_utildefines.h"
@@ -20,6 +25,9 @@
 
 #include "ED_view3d.h"
 
 
 #include "ED_view3d.h"
 
+#include "WM_api.h"
+#include "WM_types.h"
+
 #include "paint_intern.h"
 
 /* 3D Paint */
 #include "paint_intern.h"
 
 /* 3D Paint */
@@ -180,3 +188,36 @@ void paint_sample_color(Scene *scene, ARegion *ar, int x, int y)   /* frontbuf */
        }
 }
 
        }
 }
 
+static int brush_curve_preset_exec(bContext *C, wmOperator *op)
+{
+       Brush *br = *current_brush_source(CTX_data_scene(C));
+       brush_curve_preset(br, RNA_enum_get(op->ptr, "shape"));
+
+       return OPERATOR_FINISHED;
+}
+
+static int brush_curve_preset_poll(bContext *C)
+{
+       Brush **br = current_brush_source(CTX_data_scene(C));
+
+       return br && *br && (*br)->curve;
+}
+
+void BRUSH_OT_curve_preset(wmOperatorType *ot)
+{
+       static EnumPropertyItem prop_shape_items[] = {
+               {BRUSH_PRESET_SHARP, "SHARP", 0, "Sharp", ""},
+               {BRUSH_PRESET_SMOOTH, "SMOOTH", 0, "Smooth", ""},
+               {BRUSH_PRESET_MAX, "MAX", 0, "Max", ""},
+               {0, NULL, 0, NULL, NULL}};
+
+       ot->name= "Preset";
+       ot->idname= "BRUSH_OT_curve_preset";
+
+       ot->exec= brush_curve_preset_exec;
+       ot->poll= brush_curve_preset_poll;
+
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+       RNA_def_enum(ot->srna, "shape", prop_shape_items, BRUSH_PRESET_SHARP, "Mode", "");
+}
index 8fac4b83b13820b4da7e0e938496a931fc3a6db2..bf05490b631f79838bb6b498c1146f6eead20951 100644 (file)
@@ -1118,31 +1118,6 @@ static void sculpt_undo_push(bContext *C, Sculpt *sd)
        }
 }
 
        }
 }
 
-static int sculpt_brush_curve_preset_exec(bContext *C, wmOperator *op)
-{
-       brush_curve_preset(CTX_data_scene(C)->toolsettings->sculpt->brush, RNA_enum_get(op->ptr, "mode"));
-       return OPERATOR_FINISHED;
-}
-
-static void SCULPT_OT_brush_curve_preset(wmOperatorType *ot)
-{
-       static EnumPropertyItem prop_mode_items[] = {
-               {BRUSH_PRESET_SHARP, "SHARP", 0, "Sharp Curve", ""},
-               {BRUSH_PRESET_SMOOTH, "SMOOTH", 0, "Smooth Curve", ""},
-               {BRUSH_PRESET_MAX, "MAX", 0, "Max Curve", ""},
-               {0, NULL, 0, NULL, NULL}};
-
-       ot->name= "Preset";
-       ot->idname= "SCULPT_OT_brush_curve_preset";
-
-       ot->exec= sculpt_brush_curve_preset_exec;
-       ot->poll= sculpt_mode_poll;
-
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
-       RNA_def_enum(ot->srna, "mode", prop_mode_items, BRUSH_PRESET_SHARP, "Mode", "");
-}
-
 /**** Radial control ****/
 static int sculpt_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
 /**** Radial control ****/
 static int sculpt_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
@@ -1732,6 +1707,5 @@ void ED_operatortypes_sculpt()
        WM_operatortype_append(SCULPT_OT_radial_control);
        WM_operatortype_append(SCULPT_OT_brush_stroke);
        WM_operatortype_append(SCULPT_OT_sculptmode_toggle);
        WM_operatortype_append(SCULPT_OT_radial_control);
        WM_operatortype_append(SCULPT_OT_brush_stroke);
        WM_operatortype_append(SCULPT_OT_sculptmode_toggle);
-       WM_operatortype_append(SCULPT_OT_brush_curve_preset);
        WM_operatortype_append(SCULPT_OT_set_persistent_base);
 }
        WM_operatortype_append(SCULPT_OT_set_persistent_base);
 }
index 26ca5a07973a345fe22213f47b697850c905822a..2e0172f4238c7d261926d7d51f987174dcb2c524 100644 (file)
@@ -3173,9 +3173,9 @@ static void view3d_sculpt_menu(bContext *C, uiLayout *layout, void *arg_unused)
 
        /* Curve */
        uiItemS(layout);
 
        /* Curve */
        uiItemS(layout);
-       uiItemEnumO(layout, NULL, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SHARP);
-       uiItemEnumO(layout, NULL, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SMOOTH);
-       uiItemEnumO(layout, NULL, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_MAX);
+       uiItemEnumO(layout, NULL, 0, "BRUSH_OT_curve_preset", "shape", BRUSH_PRESET_SHARP);
+       uiItemEnumO(layout, NULL, 0, "BRUSH_OT_curve_preset", "shape", BRUSH_PRESET_SMOOTH);
+       uiItemEnumO(layout, NULL, 0, "BRUSH_OT_curve_preset", "shape", BRUSH_PRESET_MAX);
 
        uiItemS(layout);
 
 
        uiItemS(layout);