Started converting over the sculpt header menu to the new system. Added operator...
authorNicholas Bishop <nicholasbishop@gmail.com>
Sat, 7 Feb 2009 03:21:28 +0000 (03:21 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Sat, 7 Feb 2009 03:21:28 +0000 (03:21 +0000)
source/blender/blenkernel/intern/brush.c
source/blender/editors/sculpt/sculpt.c
source/blender/editors/space_view3d/view3d_header.c

index c0882451f6ce2c5157ef31b4b22006d1b3adf83e..08a2b1dcecb482979eb344de41fea674736417fd 100644 (file)
@@ -242,10 +242,18 @@ void brush_curve_preset(Brush *b, BrushCurvePreset preset)
        if(cm->curve)
                MEM_freeN(cm->curve);
 
-       if(preset == BRUSH_PRESET_SHARP) {
-               cm->curve= MEM_callocN(3*sizeof(CurveMapPoint), "curve points");
-               cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
+       if(preset == BRUSH_PRESET_SHARP)
                cm->totpoint= 3;
+       if(preset == BRUSH_PRESET_SMOOTH)
+               cm->totpoint= 6;
+       if(preset == BRUSH_PRESET_MAX)
+               cm->totpoint= 2;
+
+
+       cm->curve= MEM_callocN(cm->totpoint*sizeof(CurveMapPoint), "curve points");
+       cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
+
+       if(preset == BRUSH_PRESET_SHARP) {
                cm->curve[0].x= 0;
                cm->curve[0].y= 1;
                cm->curve[1].x= 0.33;
@@ -254,10 +262,24 @@ void brush_curve_preset(Brush *b, BrushCurvePreset preset)
                cm->curve[2].y= 0;
        }
        else if(preset == BRUSH_PRESET_SMOOTH) {
-               // XXX: todo
+               cm->curve[0].x= 0;
+               cm->curve[0].y= 1;
+               cm->curve[1].x= 0.1;
+               cm->curve[1].y= 0.97553;
+               cm->curve[2].x= 0.3;
+               cm->curve[2].y= 0.79389;
+               cm->curve[3].x= 0.9;
+               cm->curve[3].y= 0.02447;
+               cm->curve[4].x= 0.7;
+               cm->curve[4].y= 0.20611;
+               cm->curve[5].x= 1;
+               cm->curve[5].y= 0;
        }
        else if(preset == BRUSH_PRESET_MAX) {
-               // XXX: todo
+               cm->curve[0].x= 0;
+               cm->curve[0].y= 1;
+               cm->curve[1].x= 1;
+               cm->curve[1].y= 1;
        }
 
        curvemapping_changed(b->curve, 0);
index 42ac8d7aee004c91bebc81e63e530bb4dcf266c6..f3d29989bb86460671b0d84d0ba6bd9c2f50c915 100644 (file)
@@ -1232,6 +1232,31 @@ 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", "Sharp Curve", ""},
+               {BRUSH_PRESET_SMOOTH, "SMOOTH", "Smooth Curve", ""},
+               {BRUSH_PRESET_MAX, "MAX", "Max Curve", ""},
+               {0, NULL, NULL, NULL}};
+
+       ot->name= "Preset";
+       ot->idname= "SCULPT_OT_brush_curve_preset";
+
+       ot->exec= sculpt_brush_curve_preset_exec;
+       ot->poll= sculpt_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)
 {
@@ -1696,6 +1721,7 @@ 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_brush_curve_preset);
 }
 
 void sculpt(Sculpt *sd)
index 5dbe5fb02fee004f89c9db7d9540b8a08e2673ee..b982c3e1f0e81db63b5e3634177367df18da38ea 100644 (file)
 #include "DNA_view3d_types.h"
 #include "DNA_windowmanager_types.h"
 
+#include "RNA_access.h"
+
 #include "MEM_guardedalloc.h"
 
 #include "BKE_action.h"
+#include "BKE_brush.h"
 #include "BKE_context.h"
 #include "BKE_curve.h"
 #include "BKE_depsgraph.h"
@@ -4833,22 +4836,6 @@ void do_view3d_sculptmenu(bContext *C, void *arg, int event)
                sd->brush_type= event+1;
                ED_undo_push(C, "Brush type");
                break;
-       case 7:
-               br->flag ^= SCULPT_BRUSH_AIRBRUSH;
-               ED_undo_push(C, "Airbrush");
-               break;
-       case 8:
-               sd->symm ^= SYMM_X;
-               ED_undo_push(C, "X Symmetry");
-               break;
-       case 9:
-               sd->symm ^= SYMM_Y;
-               ED_undo_push(C, "Y Symmetry");
-               break;
-       case 10:
-               sd->symm ^= SYMM_Z;
-               ED_undo_push(C, "Z Symmetry");
-               break;
        case 11:
                if(v3d)
                        v3d->pivot_last= !v3d->pivot_last;
@@ -4873,14 +4860,6 @@ void do_view3d_sculptmenu(bContext *C, void *arg, int event)
        case 17:
                sculpt_radialcontrol_start(RADIALCONTROL_SIZE);
                break;
-       case 18:
-               br->dir= br->dir==1 ? 2 : 1;
-               ED_undo_push(C, "Add/Sub");
-               break;
-       }
-
-       allqueue(REDRAWBUTSEDIT, 0);
-       allqueue(REDRAWVIEW3D, 0);
 #endif
 }
 
@@ -4902,6 +4881,40 @@ uiBlock *view3d_sculpt_inputmenu(bContext *C, ARegion *ar, void *arg_unused)
        return block;
 }
 
+static void view3d_sculpt_menu(bContext *C, uiMenuItem *head, void *arg_unused)
+{
+       bScreen *sc= CTX_wm_screen(C);
+       Sculpt *s = CTX_data_tool_settings(C)->sculpt;
+       PointerRNA rna;
+
+       RNA_pointer_create(&sc->id, &RNA_Sculpt, s, &rna);
+
+       uiMenuItemBooleanR(head, &rna, "symmetry_x");
+       uiMenuItemBooleanR(head, &rna, "symmetry_y");
+       uiMenuItemBooleanR(head, &rna, "symmetry_z");
+       uiMenuItemBooleanR(head, &rna, "lock_x");
+       uiMenuItemBooleanR(head, &rna, "lock_y");
+       uiMenuItemBooleanR(head, &rna, "lock_z");
+
+       /* Brush settings */
+       RNA_pointer_create(&sc->id, &RNA_Brush, s->brush, &rna);
+
+       /* Curve */
+       uiMenuSeparator(head);
+       uiMenuItemEnumO(head, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SHARP);
+       uiMenuItemEnumO(head, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SMOOTH);
+       uiMenuItemEnumO(head, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_MAX);
+
+       uiMenuSeparator(head);
+
+       uiMenuItemBooleanR(head, &rna, "airbrush");
+       uiMenuItemBooleanR(head, &rna, "rake");
+       uiMenuItemBooleanR(head, &rna, "anchored");
+       uiMenuItemBooleanR(head, &rna, "space");
+
+       uiMenuItemBooleanR(head, &rna, "flip_direction");       
+}
+
 uiBlock *view3d_sculptmenu(bContext *C, ARegion *ar, void *arg_unused)
 {
        ScrArea *sa= CTX_wm_area(C);
@@ -4929,19 +4942,6 @@ uiBlock *view3d_sculptmenu(bContext *C, ARegion *ar, void *arg_unused)
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Strengthen Brush|Shift F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, "");
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Rotate Brush|Ctrl F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, "");
        
-       uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-       uiDefIconTextBut(block, BUTM, 1, (sd->flags & SCULPT_SYMM_Z ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Z Symmetry|Z", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
-       uiDefIconTextBut(block, BUTM, 1, (sd->flags & SCULPT_SYMM_Y ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Y Symmetry|Y", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, "");
-       uiDefIconTextBut(block, BUTM, 1, (sd->flags & SCULPT_SYMM_X ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "X Symmetry|X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, "");
-       
-       /* XXX if(sd->brush_type!=GRAB_BRUSH) {
-               uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-               uiDefIconTextBut(block, BUTM, 1, (br->flag & SCULPT_BRUSH_AIRBRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Airbrush|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
-               
-               if(sd->brush_type!=SMOOTH_BRUSH && sd->brush_type!=FLATTEN_BRUSH) {
-                       uiDefIconTextBut(block, BUTM, 1, (br->dir==1 ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Add|V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 18, "");
-               }
-       }*/
        uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
        /* XXX uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==FLATTEN_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Flatten|T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
        uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==LAYER_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Layer|L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
@@ -5727,7 +5727,7 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o
        }
        else if( G.f & G_SCULPTMODE) {
                xmax= GetButStringLength("Sculpt");
-               uiDefPulldownBut(block, view3d_sculptmenu, NULL, "Sculpt", xco, yco-2, xmax-3, 24, "");
+               uiDefMenuBut(block, view3d_sculpt_menu, NULL, "Sculpt", xco, yco-2, xmax-3, 24, "");
                xco+= xmax;
        }
        else if (FACESEL_PAINT_TEST) {