From 763a98f4c0169f7a44b37124b88babcc0df02dc2 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 12 Feb 2009 22:12:21 +0000 Subject: 2.5: Most curve/surface editmode operators back: * Hide, Reveal * Separate, Duplicate, Delete * Set Weight, Set Radius, Set Spline Type, Set Handle Type, Set Smooth * Tilt, Clear Tilt * Smooth, Smooth Radius * De(select) First, De(select) Last, De(select) All, Select Inverse, Select Linked, Select Control Point Row, Select Next, Select Previous, Select More, Select Less, Select Random, Select Every Nth * Switch Direction, Subdivide, Make Segment, Spin, Extrude, Toggle Cyclic * Specials Menu Not working correct yet: * Add Vertex (ctrl click) * Add Menu --- source/blender/blenkernel/intern/curve.c | 2 + source/blender/editors/curve/curve_intern.h | 15 +- source/blender/editors/curve/curve_ops.c | 132 +++- source/blender/editors/curve/editcurve.c | 723 +++++++++++++-------- source/blender/editors/include/ED_curve.h | 1 - source/blender/editors/include/ED_screen.h | 2 + source/blender/editors/interface/interface.c | 2 +- source/blender/editors/object/object_edit.c | 10 +- source/blender/editors/screen/screen_ops.c | 22 +- .../blender/editors/space_view3d/view3d_header.c | 423 +++--------- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 11 +- 11 files changed, 690 insertions(+), 653 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 2e0347870cc..7d7d98095c6 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -191,6 +191,8 @@ Curve *copy_curve(Curve *cu) cun->bev.first= cun->bev.last= 0; cun->path= 0; + cun->editnurb= NULL; + #if 0 // XXX old animation system /* single user ipo too */ if(cun->ipo) cun->ipo= copy_ipo(cun->ipo); diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h index ba01c1207e7..cced4720cec 100644 --- a/source/blender/editors/curve/curve_intern.h +++ b/source/blender/editors/curve/curve_intern.h @@ -44,20 +44,21 @@ void CURVE_OT_switch_direction(struct wmOperatorType *ot); void CURVE_OT_set_weight(struct wmOperatorType *ot); void CURVE_OT_set_radius(struct wmOperatorType *ot); void CURVE_OT_smooth(struct wmOperatorType *ot); -void CURVE_OT_smooth_curve_radius(struct wmOperatorType *ot); +void CURVE_OT_smooth_radius(struct wmOperatorType *ot); void CURVE_OT_de_select_first(struct wmOperatorType *ot); void CURVE_OT_de_select_last(struct wmOperatorType *ot); void CURVE_OT_de_select_all(struct wmOperatorType *ot); void CURVE_OT_hide(struct wmOperatorType *ot); void CURVE_OT_reveal(struct wmOperatorType *ot); -void CURVE_OT_select_invert(struct wmOperatorType *ot); +void CURVE_OT_select_inverse(struct wmOperatorType *ot); void CURVE_OT_subdivide(struct wmOperatorType *ot); void CURVE_OT_set_spline_type(struct wmOperatorType *ot); +void CURVE_OT_set_handle_type(struct wmOperatorType *ot); void CURVE_OT_make_segment(struct wmOperatorType *ot); void CURVE_OT_spin(struct wmOperatorType *ot); void CURVE_OT_add_vertex(struct wmOperatorType *ot); void CURVE_OT_extrude(struct wmOperatorType *ot); -void CURVE_OT_make_cyclic(struct wmOperatorType *ot); +void CURVE_OT_toggle_cyclic(struct wmOperatorType *ot); void CURVE_OT_select_linked(struct wmOperatorType *ot); void CURVE_OT_select_row(struct wmOperatorType *ot); void CURVE_OT_select_next(struct wmOperatorType *ot); @@ -66,10 +67,16 @@ void CURVE_OT_select_more(struct wmOperatorType *ot); void CURVE_OT_select_less(struct wmOperatorType *ot); void CURVE_OT_select_random(struct wmOperatorType *ot); void CURVE_OT_select_every_nth(struct wmOperatorType *ot); -void CURVE_OT_add_duplicate(struct wmOperatorType *ot); +void CURVE_OT_duplicate(struct wmOperatorType *ot); void CURVE_OT_delete(struct wmOperatorType *ot); void CURVE_OT_set_smooth(struct wmOperatorType *ot); void CURVE_OT_clear_tilt(struct wmOperatorType *ot); +void CURVE_OT_add_surface_primitive(struct wmOperatorType *ot); +void CURVE_OT_add_curve_primitive(struct wmOperatorType *ot); + +void CURVE_OT_specials_menu(struct wmOperatorType *ot); +void CURVE_OT_add_menu(struct wmOperatorType *ot); + #endif /* ED_UTIL_INTERN_H */ diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 4455144c859..30ddb226045 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -55,35 +55,95 @@ #include "ED_screen.h" #include "ED_object.h" +#include "BIF_transform.h" + +#include "UI_interface.h" + #include "curve_intern.h" -/* ************************** registration **********************************/ +/**************************** menus *****************************/ +static int specials_menu_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + uiMenuItem *head; + + head= uiPupMenuBegin("Specials", 0); + uiMenuItemO(head, 0, "CURVE_OT_subdivide"); + uiMenuItemO(head, 0, "CURVE_OT_switch_direction"); + uiMenuItemO(head, 0, "CURVE_OT_set_weight"); + uiMenuItemO(head, 0, "CURVE_OT_set_radius"); + uiMenuItemO(head, 0, "CURVE_OT_smooth"); + uiMenuItemO(head, 0, "CURVE_OT_smooth_radius"); + uiPupMenuEnd(C, head); + + return OPERATOR_CANCELLED; +} + +void CURVE_OT_specials_menu(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Specials Menu"; + ot->idname= "CURVE_OT_specials_menu"; + + /* api clastbacks */ + ot->invoke= specials_menu_invoke; + ot->poll= ED_operator_editsurfcurve; +} + +static int add_menu_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + Object *obedit= CTX_data_edit_object(C); + uiMenuItem *head; + + head= uiPupMenuBegin("Add", 0); + if(obedit->type == OB_CURVE) + uiMenuItemsEnumO(head, "CURVE_OT_add_curve_primitive", "type"); + else + uiMenuItemsEnumO(head, "CURVE_OT_add_surface_primitive", "type"); + uiPupMenuEnd(C, head); + + return OPERATOR_CANCELLED; +} + +void CURVE_OT_add_menu(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Menu"; + ot->idname= "CURVE_OT_add_menu"; + + /* api clastbacks */ + ot->invoke= add_menu_invoke; + ot->poll= ED_operator_editsurfcurve; +} + +/************************* registration ****************************/ void ED_operatortypes_curve(void) { WM_operatortype_append(FONT_OT_textedit); + WM_operatortype_append(CURVE_OT_hide); + WM_operatortype_append(CURVE_OT_reveal); + WM_operatortype_append(CURVE_OT_separate); - WM_operatortype_append(CURVE_OT_switch_direction); + WM_operatortype_append(CURVE_OT_duplicate); + WM_operatortype_append(CURVE_OT_delete); + WM_operatortype_append(CURVE_OT_set_weight); WM_operatortype_append(CURVE_OT_set_radius); + WM_operatortype_append(CURVE_OT_set_spline_type); + WM_operatortype_append(CURVE_OT_set_handle_type); + WM_operatortype_append(CURVE_OT_set_smooth); + WM_operatortype_append(CURVE_OT_clear_tilt); + WM_operatortype_append(CURVE_OT_smooth); - WM_operatortype_append(CURVE_OT_smooth_curve_radius); + WM_operatortype_append(CURVE_OT_smooth_radius); + WM_operatortype_append(CURVE_OT_de_select_first); WM_operatortype_append(CURVE_OT_de_select_last); WM_operatortype_append(CURVE_OT_de_select_all); - WM_operatortype_append(CURVE_OT_hide); - WM_operatortype_append(CURVE_OT_reveal); - WM_operatortype_append(CURVE_OT_select_invert); - WM_operatortype_append(CURVE_OT_subdivide); - WM_operatortype_append(CURVE_OT_set_spline_type); - WM_operatortype_append(CURVE_OT_make_segment); - WM_operatortype_append(CURVE_OT_spin); - WM_operatortype_append(CURVE_OT_add_vertex); - WM_operatortype_append(CURVE_OT_extrude); - WM_operatortype_append(CURVE_OT_make_cyclic); + WM_operatortype_append(CURVE_OT_select_inverse); WM_operatortype_append(CURVE_OT_select_linked); WM_operatortype_append(CURVE_OT_select_row); WM_operatortype_append(CURVE_OT_select_next); @@ -92,10 +152,20 @@ void ED_operatortypes_curve(void) WM_operatortype_append(CURVE_OT_select_less); WM_operatortype_append(CURVE_OT_select_random); WM_operatortype_append(CURVE_OT_select_every_nth); - WM_operatortype_append(CURVE_OT_add_duplicate); - WM_operatortype_append(CURVE_OT_delete); - WM_operatortype_append(CURVE_OT_set_smooth); - WM_operatortype_append(CURVE_OT_clear_tilt); + + WM_operatortype_append(CURVE_OT_switch_direction); + WM_operatortype_append(CURVE_OT_subdivide); + WM_operatortype_append(CURVE_OT_make_segment); + WM_operatortype_append(CURVE_OT_spin); + WM_operatortype_append(CURVE_OT_add_vertex); + WM_operatortype_append(CURVE_OT_extrude); + WM_operatortype_append(CURVE_OT_toggle_cyclic); + + WM_operatortype_append(CURVE_OT_add_menu); + WM_operatortype_append(CURVE_OT_specials_menu); + + WM_operatortype_append(CURVE_OT_add_surface_primitive); + WM_operatortype_append(CURVE_OT_add_curve_primitive); } void ED_keymap_curve(wmWindowManager *wm) @@ -109,5 +179,33 @@ void ED_keymap_curve(wmWindowManager *wm) keymap= WM_keymap_listbase(wm, "Curve", 0, 0); WM_keymap_add_item(keymap, "OBJECT_OT_curve_add", AKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "CURVE_OT_add_vertex", ACTIONMOUSE, KM_PRESS, KM_CTRL, 0); + + WM_keymap_add_item(keymap, "CURVE_OT_de_select_all", AKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "CURVE_OT_select_row", RKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "CURVE_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "CURVE_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "CURVE_OT_select_linked", LKEY, KM_PRESS, 0, 0); + RNA_boolean_set(WM_keymap_add_item(keymap, "CURVE_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "deselect", 1); + + WM_keymap_add_item(keymap, "CURVE_OT_separate", PKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "CURVE_OT_extrude", EKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "CURVE_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "CURVE_OT_make_segment", FKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "CURVE_OT_toggle_cyclic", CKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "CURVE_OT_delete", XKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "CURVE_OT_delete", DELKEY, KM_PRESS, 0, 0); + + WM_keymap_add_item(keymap, "CURVE_OT_clear_tilt", TKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(WM_keymap_add_item(keymap, "TFM_OT_transform", TKEY, KM_PRESS, 0, 0)->ptr, "mode", TFM_TILT); + RNA_enum_set(WM_keymap_add_item(keymap, "CURVE_OT_set_handle_type", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", 1); + RNA_enum_set(WM_keymap_add_item(keymap, "CURVE_OT_set_handle_type", HKEY, KM_PRESS, 0, 0)->ptr, "type", 3); + RNA_enum_set(WM_keymap_add_item(keymap, "CURVE_OT_set_handle_type", VKEY, KM_PRESS, 0, 0)->ptr, "type", 2); + + WM_keymap_add_item(keymap, "CURVE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "CURVE_OT_hide", HKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); + RNA_enum_set(WM_keymap_add_item(keymap, "CURVE_OT_hide", HKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "deselected", 1); + + WM_keymap_add_item(keymap, "CURVE_OT_specials_menu", WKEY, KM_PRESS, 0, 0); } diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 281d9f407dc..848bec89a39 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -71,6 +71,7 @@ #include "WM_types.h" #include "ED_anim_api.h" +#include "ED_curve.h" #include "ED_keyframes_edit.h" #include "ED_object.h" #include "ED_screen.h" @@ -80,6 +81,8 @@ #include "UI_interface.h" +#include "BIF_transform.h" + #include "RNA_access.h" #include "RNA_define.h" @@ -89,14 +92,6 @@ /* for curve objects in editmode that can have hidden handles */ #define BEZSELECTED_HIDDENHANDLES(bezt) ((G.f & G_HIDDENHANDLES) ? (bezt)->f2 & SELECT : BEZSELECTED(bezt)) -/* XXX */ -static void BIF_undo_push() {} -static int okee() {return 0;} -static int pupmenu() {return 0;} -static void adduplicate() {} -static void error_libdata() {} -/* XXX */ - float nurbcircle[8][2]= { {0.0, -1.0}, {-1.0, -1.0}, {-1.0, 0.0}, {-1.0, 1.0}, {0.0, 1.0}, { 1.0, 1.0}, { 1.0, 0.0}, { 1.0, -1.0} @@ -116,11 +111,10 @@ void set_actNurb(Object *obedit, Nurb *nu) { Curve *cu= obedit->data; - if (nu==NULL) { + if(nu==NULL) cu->actnu = -1; - } else { + else cu->actnu = BLI_findindex(cu->editnurb, nu); - } } Nurb *get_actNurb(Object *obedit) @@ -130,7 +124,6 @@ Nurb *get_actNurb(Object *obedit) return BLI_findlink(cu->editnurb, cu->actnu); } - /* ******************* SELECTION FUNCTIONS ********************* */ #define HIDDEN 1 @@ -357,14 +350,6 @@ void make_editNurb(Object *obedit) set_actNurb(obedit, NULL); } -void remake_editNurb(Object *obedit) -{ - - if(okee("Reload original data")==0) return; - - make_editNurb(obedit); -} - void free_editNurb(Object *obedit) { Curve *cu= obedit->data; @@ -376,89 +361,63 @@ void free_editNurb(Object *obedit) } } -/******************** XXX separate operator ***********************/ +/******************** separate operator ***********************/ static int separate_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= curve_get_editcurve(obedit); - View3D *v3d= NULL; // XXX Nurb *nu, *nu1; - Object *oldob; - Base *base, *oldbase; - Curve *cu; - ListBase editnurbo; - - cu= obedit->data; - if(cu->key) { - BKE_report(op->reports, RPT_ERROR, "Can't separate a curve with vertex keys"); + Object *oldob, *newob; + Base *oldbase, *newbase; + Curve *oldcu, *newcu; + ListBase *oldedit, *newedit; + + oldbase= CTX_data_active_base(C); + oldob= oldbase->object; + oldcu= oldob->data; + oldedit= oldcu->editnurb; + + if(oldcu->key) { + BKE_report(op->reports, RPT_ERROR, "Can't separate a curve with vertex keys."); return OPERATOR_CANCELLED; } WM_cursor_wait(1); - /* we are going to trick everything as follows: - * 1. duplicate base: this is the new one, remember old pointer - * 2. set aside all NOT selected curves/nurbs - * 3. load_ebaseNurb(): this will be the new base - * 4. freelist and restore old nurbs - */ - - /* only edit-base selected */ - base= FIRSTBASE; - while(base) { - if(base->lay & v3d->lay) { - if(base->object==obedit) base->flag |= 1; - else base->flag &= ~1; - } - base= base->next; - } + /* 1. duplicate the object and data */ + newbase= ED_object_add_duplicate(scene, oldbase, 0); /* 0 = fully linked */ + ED_base_object_select(newbase, BA_DESELECT); + newob= newbase->object; - /* set aside: everything that is not selected */ - editnurbo.first= editnurbo.last= 0; - nu= editnurb->first; - while(nu) { + newcu= newob->data= copy_curve(oldcu); + newcu->editnurb= NULL; + oldcu->id.us--; /* because new curve is a copy: reduce user count */ + + /* 2. put new object in editmode and clear it */ + make_editNurb(newob); + newedit= newcu->editnurb; + freeNurblist(newedit); + + /* 3. move over parts from old object */ + for(nu= oldedit->first; nu; nu=nu1) { nu1= nu->next; - if(isNurbsel(nu)==0) { - BLI_remlink(editnurb, nu); - BLI_addtail(&editnurbo, nu); + + if(isNurbsel(nu)) { + BLI_remlink(oldedit, nu); + BLI_addtail(newedit, nu); } - nu= nu1; } - oldob= obedit; - oldbase= BASACT; + /* 4. put old object out of editmode */ + load_editNurb(newob); + free_editNurb(newob); - adduplicate(1, 0); /* no transform and zero so do get a linked dupli */ - - obedit= BASACT->object; /* basact is set in adduplicate() */ - - obedit->data= copy_curve(cu); - /* because new curve is a copy: reduce user count */ - cu->id.us--; - - load_editNurb(obedit); - - BASACT->flag &= ~SELECT; - - if(editnurb->first) freeNurblist(editnurb); - - *editnurb= editnurbo; - - obedit= 0; /* displists behave different in edit mode */ - DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); /* this is the separated one */ DAG_object_flush_update(scene, oldob, OB_RECALC_DATA); /* this is the original one */ - - obedit= oldob; - BASACT= oldbase; - BASACT->flag |= SELECT; - - set_actNurb(obedit, NULL); + DAG_object_flush_update(scene, newob, OB_RECALC_DATA); /* this is the separated one */ - WM_cursor_wait(0); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, oldob); - // XXX notifier + WM_cursor_wait(0); return OPERATOR_FINISHED; } @@ -471,7 +430,7 @@ void CURVE_OT_separate(wmOperatorType *ot) /* api callbacks */ ot->exec= separate_exec; - ot->poll= ED_operator_editcurve; + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1050,7 +1009,7 @@ static int switch_direction_exec(bContext *C, wmOperator *op) switchdirectionNurb(nu); DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA); - // XXX notifier + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); return OPERATOR_FINISHED; } @@ -1063,7 +1022,7 @@ void CURVE_OT_switch_direction(wmOperatorType *ot) /* api callbacks */ ot->exec= switch_direction_exec; - ot->poll= ED_operator_editcurve; // XXX nurb poll() + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1096,8 +1055,8 @@ static int set_weight_exec(bContext *C, wmOperator *op) } } - // XXX notifier DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); return OPERATOR_FINISHED; } @@ -1110,7 +1069,7 @@ void CURVE_OT_set_weight(wmOperatorType *ot) /* api callbacks */ ot->exec= set_weight_exec; - ot->poll= ED_operator_editcurve; // XXX nurb poll() + ot->poll= ED_operator_editsurfcurve; // XXX invoke popup? @@ -1148,6 +1107,7 @@ static int set_radius_exec(bContext *C, wmOperator *op) } } + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA); return OPERATOR_FINISHED; @@ -1161,7 +1121,7 @@ void CURVE_OT_set_radius(wmOperatorType *ot) /* api callbacks */ ot->exec= set_radius_exec; - ot->poll= ED_operator_editcurve; // XXX nurb poll() + ot->poll= ED_operator_editsurfcurve; // XXX invoke popup? @@ -1223,8 +1183,8 @@ static int smooth_exec(bContext *C, wmOperator *op) } } + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA); - // XXX notifier return OPERATOR_FINISHED; } @@ -1237,7 +1197,7 @@ void CURVE_OT_smooth(wmOperatorType *ot) /* api callbacks */ ot->exec= smooth_exec; - ot->poll= ED_operator_editcurve; // XXX nurb poll() + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1246,7 +1206,7 @@ void CURVE_OT_smooth(wmOperatorType *ot) /**************** smooth curve radius operator *************/ /* TODO, make smoothing distance based */ -static int smooth_curve_radius_exec(bContext *C, wmOperator *op) +static int smooth_radius_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); ListBase *editnurb= curve_get_editcurve(obedit); @@ -1388,21 +1348,21 @@ static int smooth_curve_radius_exec(bContext *C, wmOperator *op) } } + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA); - // XXX notifier return OPERATOR_FINISHED; } -void CURVE_OT_smooth_curve_radius(wmOperatorType *ot) +void CURVE_OT_smooth_radius(wmOperatorType *ot) { /* identifiers */ ot->name= "Smooth Curve Radius"; - ot->idname= "CURVE_OT_smooth_curve_radius"; + ot->idname= "CURVE_OT_smooth_radius"; /* api clastbacks */ - ot->exec= smooth_curve_radius_exec; - ot->poll= ED_operator_editcurve; + ot->exec= smooth_radius_exec; + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1643,7 +1603,7 @@ void CURVE_OT_de_select_all(wmOperatorType *ot) /* api callbacks */ ot->exec= de_select_all_exec; - ot->poll= ED_operator_editcurve; + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1658,7 +1618,7 @@ static int hide_exec(bContext *C, wmOperator *op) Nurb *nu; BPoint *bp; BezTriple *bezt; - int a, sel, invert= RNA_boolean_get(op->ptr, "invert"); + int a, sel, invert= RNA_boolean_get(op->ptr, "deselected"); for(nu= editnurb->first; nu; nu= nu->next) { if((nu->type & 7)==CU_BEZIER) { @@ -1666,7 +1626,11 @@ static int hide_exec(bContext *C, wmOperator *op) a= nu->pntsu; sel= 0; while(a--) { - if(BEZSELECTED_HIDDENHANDLES(bezt)) { + if(invert == 0 && BEZSELECTED_HIDDENHANDLES(bezt)) { + select_beztriple(bezt, DESELECT, 1, HIDDEN); + bezt->hide= 1; + } + else if(invert && !BEZSELECTED_HIDDENHANDLES(bezt)) { select_beztriple(bezt, DESELECT, 1, HIDDEN); bezt->hide= 1; } @@ -1709,13 +1673,13 @@ void CURVE_OT_hide(wmOperatorType *ot) /* api callbacks */ ot->exec= hide_exec; - ot->poll= ED_operator_editcurve; + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* props */ - RNA_def_boolean(ot->srna, "invert", 0, "Invert", "Hide unselected rather than selected."); + RNA_def_boolean(ot->srna, "deselected", 0, "Deselected", "Hide deselected rather than selected."); } /********************** reveal operator *********************/ @@ -1769,7 +1733,7 @@ void CURVE_OT_reveal(wmOperatorType *ot) /* api callbacks */ ot->exec= reveal_exec; - ot->poll= ED_operator_editcurve; + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1777,7 +1741,7 @@ void CURVE_OT_reveal(wmOperatorType *ot) /********************** select invert operator *********************/ -static int select_invert_exec(bContext *C, wmOperator *op) +static int select_inverse_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); ListBase *editnurb= curve_get_editcurve(obedit); @@ -1816,15 +1780,15 @@ static int select_invert_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void CURVE_OT_select_invert(wmOperatorType *ot) +void CURVE_OT_select_inverse(wmOperatorType *ot) { /* identifiers */ - ot->name= "Select Invert"; - ot->idname= "CURVE_OT_select_invert"; + ot->name= "Select Inverse"; + ot->idname= "CURVE_OT_select_inverse"; /* api callbacks */ - ot->exec= select_invert_exec; - ot->poll= ED_operator_editcurve; + ot->exec= select_inverse_exec; + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2207,9 +2171,8 @@ static int subdivide_exec(bContext *C, wmOperator *op) } /* End of 'if((nu->type & 7)==CU_NURBS)' */ } - + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA); - // XXX notifier WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); return OPERATOR_FINISHED; } @@ -2222,7 +2185,7 @@ void CURVE_OT_subdivide(wmOperatorType *ot) /* api callbacks */ ot->exec= subdivide_exec; - ot->poll= ED_operator_editcurve; + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2232,7 +2195,7 @@ void CURVE_OT_subdivide(wmOperatorType *ot) static void findnearestNurbvert__doClosest(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y) { - struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; short dist, hpoint, select, mval[2]; } *data = userData; + struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; int dist, hpoint, select, mval[2]; } *data = userData; short flag; short temp; @@ -2263,12 +2226,12 @@ static void findnearestNurbvert__doClosest(void *userData, Nurb *nu, BPoint *bp, } } -static short findnearestNurbvert(ViewContext *vc, short sel, short mval[2], Nurb **nurb, BezTriple **bezt, BPoint **bp) +static short findnearestNurbvert(ViewContext *vc, short sel, int mval[2], Nurb **nurb, BezTriple **bezt, BPoint **bp) { /* sel==1: selected gets a disadvantage */ /* in nurb and bezt or bp the nearest is written */ /* return 0 1 2: handlepunt */ - struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; short dist, hpoint, select, mval[2]; } data = {0}; + struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; int dist, hpoint, select, mval[2]; } data = {0}; data.dist = 100; data.hpoint = 0; @@ -2538,7 +2501,48 @@ void CURVE_OT_set_spline_type(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", type_items, CU_POLY, "Type", "Spline type"); } -/***************** XXX make segment operator **********************/ +/***************** set handle type operator *******************/ + +static int set_handle_type_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *obedit= CTX_data_edit_object(C); + ListBase *editnurb= curve_get_editcurve(obedit); + + sethandlesNurb(editnurb, RNA_enum_get(op->ptr, "type")); + + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); + DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); + + return OPERATOR_FINISHED; +} + +void CURVE_OT_set_handle_type(wmOperatorType *ot) +{ + static EnumPropertyItem type_items[]= { + {1, "AUTOMATIC", "Automatic", ""}, + {2, "VECTOR", "Vector", ""}, + {3, "TOGGLE_FREE_ALIGN", "Toggle Free/Align", ""}, + {5, "ALIGN", "Align", ""}, + {6, "FREE_ALIGN", "Free Align", ""}, + {0, NULL, NULL, NULL}}; + + /* identifiers */ + ot->name= "Set Handle Type"; + ot->idname= "CURVE_OT_set_handle_type"; + + /* api callbacks */ + ot->exec= set_handle_type_exec; + ot->poll= ED_operator_editcurve; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_enum(ot->srna, "type", type_items, CU_POLY, "Type", "Spline type"); +} + +/***************** make segment operator **********************/ /* ******************** SKINNING LOFTING!!! ******************** */ @@ -2862,10 +2866,8 @@ static int merge_nurb(bContext *C, wmOperator *op) set_actNurb(obedit, NULL); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA); - // XXX notifier - - // XXX BIF_undo_push("Merge"); return OPERATOR_FINISHED; } @@ -3018,8 +3020,8 @@ static int make_segment_exec(bContext *C, wmOperator *op) set_actNurb(obedit, NULL); /* for selected */ + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - // XXX notifier return OPERATOR_FINISHED; } @@ -3037,13 +3039,13 @@ void CURVE_OT_make_segment(wmOperatorType *ot) /* api callbacks */ ot->exec= make_segment_exec; - ot->poll= ED_operator_editcurve; // XXX nurb poll() + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -/***************** XXX pick select operator **********************/ +/***************** pick select from 3d view **********************/ void mouse_nurb(bContext *C, short mval[2], int extend) { @@ -3054,11 +3056,14 @@ void mouse_nurb(bContext *C, short mval[2], int extend) Nurb *nu; BezTriple *bezt=0; BPoint *bp=0; + int location[2]; short hand; view3d_set_viewcontext(C, &vc); - hand= findnearestNurbvert(&vc, 1, mval, &nu, &bezt, &bp); + location[0]= mval[0]; + location[1]= mval[1]; + hand= findnearestNurbvert(&vc, 1, location, &nu, &bezt, &bp); if(bezt || bp) { if(extend==0) { @@ -3102,33 +3107,28 @@ void mouse_nurb(bContext *C, short mval[2], int extend) WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); - if(nu!=get_actNurb(obedit)) { + if(nu!=get_actNurb(obedit)) set_actNurb(obedit, nu); - } - } -/***************** XXX spin operator **********************/ +/******************** spin operator ***********************/ /* from what I can gather, the mode==0 magic number spins and bridges the nurbs based on the * orientation of the global 3d view (yuck yuck!) mode==1 does the same, but doesn't bridge up * up the new geometry, mode==2 now does the same as 0, but aligned to world axes, not the view. */ -static int spin_nurb(Scene *scene, Object *obedit, float *dvec, short mode) +static int spin_nurb(bContext *C, Scene *scene, Object *obedit, float *dvec, short mode) { ListBase *editnurb= curve_get_editcurve(obedit); - RegionView3D *rv3d= NULL; // XXX - View3D *v3d= NULL; // XXX + View3D *v3d= CTX_wm_view3d(C); + RegionView3D *rv3d= CTX_wm_region_view3d(C); Nurb *nu; float *curs, si,phi,n[3],q[4],cmat[3][3],tmat[3][3],imat[3][3]; float cent[3],bmat[3][3], rotmat[3][3], scalemat1[3][3], scalemat2[3][3]; float persmat[3][3], persinv[3][3]; short a,ok, changed= 0; - if(obedit->type!=OB_SURF) - return changed; // XXX poll - - if (mode != 2) Mat3CpyMat4(persmat, rv3d->viewmat); + if(mode != 2 && rv3d) Mat3CpyMat4(persmat, rv3d->viewmat); else Mat3One(persmat); Mat3Inv(persinv, persmat); @@ -3136,12 +3136,17 @@ static int spin_nurb(Scene *scene, Object *obedit, float *dvec, short mode) Mat3CpyMat4(bmat, obedit->obmat); Mat3Inv(imat, bmat); - curs= give_cursor(scene, v3d); - VECCOPY(cent, curs); + if(v3d) { + curs= give_cursor(scene, v3d); + VECCOPY(cent, curs); + } + else + cent[0]= cent[1]= cent[2]= 0.0f; + VecSubf(cent, cent, obedit->obmat[3]); Mat3MulVecfl(imat,cent); - if(dvec || mode==2) { + if(dvec || mode==2 || !rv3d) { n[0]=n[1]= 0.0; n[2]= 1.0; } else { @@ -3226,13 +3231,13 @@ static int spin_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); - if(!spin_nurb(scene, obedit, 0, 0)) { + if(!spin_nurb(C, scene, obedit, 0, 0)) { BKE_report(op->reports, RPT_ERROR, "Can't spin"); return OPERATOR_CANCELLED; } + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - // XXX notifier return OPERATOR_FINISHED; } @@ -3245,26 +3250,25 @@ void CURVE_OT_spin(wmOperatorType *ot) /* api callbacks */ ot->exec= spin_exec; - ot->poll= ED_operator_editcurve; // XXX nurb poll() + ot->poll= ED_operator_editsurf; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -/***************** XXX add vertex operator **********************/ +/***************** add vertex operator **********************/ -static int addvert_Nurb(Scene *scene, Object *obedit, short mode) +static int addvert_Nurb(bContext *C, short mode) { + Scene *scene= CTX_data_scene(C); + Object *obedit= CTX_data_edit_object(C); ListBase *editnurb= curve_get_editcurve(obedit); - View3D *v3d= NULL; // XXX + View3D *v3d= CTX_wm_view3d(C); Nurb *nu; BezTriple *bezt, *newbezt = NULL; BPoint *bp, *newbp = NULL; float *curs, mat[3][3],imat[3][3], temp[3]; - if(obedit==0 || v3d == 0) return OPERATOR_CANCELLED; - if( (v3d->lay & obedit->lay)==0 ) return OPERATOR_CANCELLED; - Mat3CpyMat4(mat, obedit->obmat); Mat3Inv(imat,mat); @@ -3311,9 +3315,16 @@ static int addvert_Nurb(Scene *scene, Object *obedit, short mode) VECCOPY(newbezt->vec[2], bezt->vec[2]); } else { - curs= give_cursor(scene, v3d); - - VECCOPY(newbezt->vec[1], curs); + if(v3d) { + curs= give_cursor(scene, v3d); + VECCOPY(newbezt->vec[1], curs); + } + else { + newbezt->vec[1][0]= 0.0f; + newbezt->vec[1][1]= 0.0f; + newbezt->vec[1][2]= 0.0f; + } + VecSubf(newbezt->vec[1],newbezt->vec[1], obedit->obmat[3]); Mat3MulVecfl(imat,newbezt->vec[1]); VecSubf(temp, newbezt->vec[1],temp); @@ -3359,9 +3370,16 @@ static int addvert_Nurb(Scene *scene, Object *obedit, short mode) VECCOPY(newbp->vec, bp->vec); } else { - curs= give_cursor(scene, v3d); + if(v3d) { + curs= give_cursor(scene, v3d); + VECCOPY(newbp->vec, curs); + } + else { + newbp->vec[0]= 0.0f; + newbp->vec[1]= 0.0f; + newbp->vec[1]= 0.0f; + } - VECCOPY(newbp->vec, curs); VecSubf(newbp->vec, newbp->vec, obedit->obmat[3]); Mat3MulVecfl(imat,newbp->vec); newbp->vec[3]= 1.0; @@ -3369,35 +3387,26 @@ static int addvert_Nurb(Scene *scene, Object *obedit, short mode) } } -// XXX retopo_do_all(); + // XXX retopo_do_all(); test2DNurb(nu); - DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - if(mode=='e') { -// XXX BIF_TransformSetUndo("Extrude"); -// initTransform(TFM_TRANSLATION, CTX_NO_PET); -// Transform(); - } -// else while(get_mbut()&R_MOUSE) BIF_wait_for_statechange(); - - if(mode!='e') { - /* dependencies with other objects, should become event */ - BIF_undo_push("Add vertex"); - - } + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); + DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); return OPERATOR_FINISHED; } static int add_vertex_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - - // XXX + return addvert_Nurb(C, 0); +} - return addvert_Nurb(scene, obedit, 0); +static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + // XXX doesn't work correct, old code was in mouse_cursor + // temporarly setting cursor, adding vertex and restoring cursor + return add_vertex_exec(C, 0); } void CURVE_OT_add_vertex(wmOperatorType *ot) @@ -3408,13 +3417,14 @@ void CURVE_OT_add_vertex(wmOperatorType *ot) /* api callbacks */ ot->exec= add_vertex_exec; - ot->poll= ED_operator_editcurve; // XXX nurb poll() + ot->invoke= add_vertex_invoke; + ot->poll= ED_operator_editcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -/***************** XXX extrude operator **********************/ +/***************** extrude operator **********************/ static int extrude_exec(bContext *C, wmOperator *op) { @@ -3422,32 +3432,37 @@ static int extrude_exec(bContext *C, wmOperator *op) Object *obedit= CTX_data_edit_object(C); ListBase *editnurb= curve_get_editcurve(obedit); Nurb *nu; - int ok= 0; - - if(obedit->type!=OB_SURF) - return OPERATOR_CANCELLED; - + /* first test: curve? */ - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->pntsv==1 && isNurbsel_count(nu)==1 ) break; + for(nu= editnurb->first; nu; nu= nu->next) + if(nu->pntsv==1 && isNurbsel_count(nu)==1) + break; + + if(obedit->type==OB_CURVE || nu) { + addvert_Nurb(C, 'e'); } - if(nu) { - addvert_Nurb(scene, obedit, 'e'); - } else { - ok= extrudeflagNurb(editnurb, 1); /* '1'= flag */ - - if(ok) { + else { + if(extrudeflagNurb(editnurb, 1)) { /* '1'= flag */ + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - // XXX notifier -// XXX BIF_TransformSetUndo("Extrude"); -// initTransform(TFM_TRANSLATION, CTX_NO_PET); -// Transform(); } } return OPERATOR_FINISHED; } +static int extrude_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + if(extrude_exec(C, op) == OPERATOR_FINISHED) { + RNA_int_set(op->ptr, "mode", TFM_TRANSLATION); + WM_operator_name_call(C, "TFM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); + + return OPERATOR_FINISHED; + } + + return OPERATOR_CANCELLED; +} + void CURVE_OT_extrude(wmOperatorType *ot) { /* identifiers */ @@ -3456,15 +3471,19 @@ void CURVE_OT_extrude(wmOperatorType *ot) /* api callbacks */ ot->exec= extrude_exec; - ot->poll= ED_operator_editcurve; // XXX nurb poll() + ot->invoke= extrude_invoke; + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* to give to transform */ + RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX); } -/***************** XXX make cyclic operator **********************/ +/***************** make cyclic operator **********************/ -static int make_cyclic_exec(bContext *C, wmOperator *op) +static int toggle_cyclic_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); ListBase *editnurb= curve_get_editcurve(obedit); @@ -3472,7 +3491,7 @@ static int make_cyclic_exec(bContext *C, wmOperator *op) BezTriple *bezt; BPoint *bp; float *fp; - int a, b, cyclmode=0; + int a, b, direction= RNA_enum_get(op->ptr, "direction"); for(nu= editnurb->first; nu; nu= nu->next) { if( nu->pntsu>1 || nu->pntsv>1) { @@ -3527,16 +3546,12 @@ static int make_cyclic_exec(bContext *C, wmOperator *op) } } else if(nu->type==CU_NURBS) { - if(cyclmode==0) { - cyclmode= pupmenu("Toggle %t|cyclic U%x1|cyclic V%x2"); // XXX - if(cyclmode < 1) return OPERATOR_CANCELLED; - } a= nu->pntsu*nu->pntsv; bp= nu->bp; while(a--) { if( bp->f1 & SELECT) { - if(cyclmode==1 && nu->pntsu>1) { + if(direction==0 && nu->pntsu>1) { if(nu->flagu & CU_CYCLIC) nu->flagu &= ~CU_CYCLIC; else { nu->flagu |= CU_CYCLIC; @@ -3553,7 +3568,7 @@ static int make_cyclic_exec(bContext *C, wmOperator *op) } } } - if(cyclmode==2 && nu->pntsv>1) { + if(direction==1 && nu->pntsv>1) { if(nu->flagv & 1) nu->flagv--; else { nu->flagv++; @@ -3579,44 +3594,82 @@ static int make_cyclic_exec(bContext *C, wmOperator *op) } } + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA); return OPERATOR_FINISHED; } -void CURVE_OT_make_cyclic(wmOperatorType *ot) +static int toggle_cyclic_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + Object *obedit= CTX_data_edit_object(C); + ListBase *editnurb= curve_get_editcurve(obedit); + uiMenuItem *head; + Nurb *nu; + + for(nu= editnurb->first; nu; nu= nu->next) { + if(nu->pntsu>1 || nu->pntsv>1) { + if(nu->type==CU_NURBS) { + head= uiPupMenuBegin("Direction", 0); + uiMenuItemsEnumO(head, op->type->idname, "direction"); + uiPupMenuEnd(C, head); + return OPERATOR_CANCELLED; + } + } + } + + return toggle_cyclic_exec(C, op); +} + +void CURVE_OT_toggle_cyclic(wmOperatorType *ot) { + static EnumPropertyItem direction_items[]= { + {0, "CYCLIC_U", "Cyclic U", ""}, + {1, "CYCLIC_V", "Cyclic V", ""}, + {0, NULL, NULL, NULL}}; + /* identifiers */ - ot->name= "Make Cyclic"; - ot->idname= "CURVE_OT_make_cyclic"; + ot->name= "Toggle Cyclic"; + ot->idname= "CURVE_OT_toggle_cyclic"; /* api callbacks */ - ot->exec= make_cyclic_exec; - ot->poll= ED_operator_editcurve; // XXX nurb poll() + ot->exec= toggle_cyclic_exec; + ot->invoke= toggle_cyclic_invoke; + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", "Direction to make surface cyclic in."); } -/***************** XXX select linked operator **********************/ +/***************** select linked operator ******************/ static int select_linked_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); + RegionView3D *rv3d= CTX_wm_region_view3d(C); ViewContext vc; Nurb *nu; BezTriple *bezt; BPoint *bp; - int a; - short mval[2], shift= 0; // XXX + int a, location[2], deselect; + + if(!rv3d) + return OPERATOR_CANCELLED; + + deselect= RNA_boolean_get(op->ptr, "deselect"); + RNA_int_get_array(op->ptr, "location", location); - findnearestNurbvert(&vc, 1, mval, &nu, &bezt, &bp); + view3d_set_viewcontext(C, &vc); + findnearestNurbvert(&vc, 1, location, &nu, &bezt, &bp); if(bezt) { a= nu->pntsu; bezt= nu->bezt; while(a--) { - if(shift) select_beztriple(bezt, DESELECT, 1, VISIBLE); + if(deselect) select_beztriple(bezt, DESELECT, 1, VISIBLE); else select_beztriple(bezt, SELECT, 1, VISIBLE); bezt++; } @@ -3625,7 +3678,7 @@ static int select_linked_exec(bContext *C, wmOperator *op) a= nu->pntsu*nu->pntsv; bp= nu->bp; while(a--) { - if(shift) select_bpoint(bp, DESELECT, 1, VISIBLE); + if(deselect) select_bpoint(bp, DESELECT, 1, VISIBLE); else select_bpoint(bp, SELECT, 1, VISIBLE); bp++; } @@ -3636,6 +3689,18 @@ static int select_linked_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int select_linked_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + ARegion *ar= CTX_wm_region(C); + int location[2]; + + location[0]= event->x - ar->winrct.xmin; + location[1]= event->y - ar->winrct.ymin; + RNA_int_set_array(op->ptr, "location", location); + + return select_linked_exec(C, op); +} + void CURVE_OT_select_linked(wmOperatorType *ot) { /* identifiers */ @@ -3644,10 +3709,15 @@ void CURVE_OT_select_linked(wmOperatorType *ot) /* api callbacks */ ot->exec= select_linked_exec; - ot->poll= ED_operator_editcurve; + ot->invoke= select_linked_invoke; + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect linked control points rather than selecting them."); + RNA_def_int_vector(ot->srna, "location", 2, NULL, 0, INT_MAX, "Location", "", 0, 16384); } /***************** select row operator **********************/ @@ -3665,10 +3735,6 @@ static int select_row_exec(bContext *C, wmOperator *op) if(editnurb->first==0) return OPERATOR_CANCELLED; - - if(obedit->type!=OB_SURF) - return OPERATOR_CANCELLED; // XXX poll() - if(cu->lastselbp==NULL) return OPERATOR_CANCELLED; @@ -3723,7 +3789,7 @@ void CURVE_OT_select_row(wmOperatorType *ot) /* api callbacks */ ot->exec= select_row_exec; - ot->poll= ED_operator_editcurve; + ot->poll= ED_operator_editsurf; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3864,7 +3930,7 @@ void CURVE_OT_select_more(wmOperatorType *ot) /* api callbacks */ ot->exec= select_more_exec; - ot->poll= ED_operator_editcurve; + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -4025,7 +4091,7 @@ void CURVE_OT_select_less(wmOperatorType *ot) /* api callbacks */ ot->exec= select_less_exec; - ot->poll= ED_operator_editcurve; + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -4121,7 +4187,7 @@ void CURVE_OT_select_random(wmOperatorType *ot) /* api callbacks */ ot->exec= select_random_exec; - ot->poll= ED_operator_editcurve; + ot->poll= ED_operator_editsurfcurve; // XXX invoke popup? @@ -4156,7 +4222,7 @@ void CURVE_OT_select_every_nth(wmOperatorType *ot) /* api callbacks */ ot->exec= select_every_nth_exec; - ot->poll= ED_operator_editcurve; + ot->poll= ED_operator_editsurfcurve; // XXX invoke popup? @@ -4169,31 +4235,41 @@ void CURVE_OT_select_every_nth(wmOperatorType *ot) /********************** add duplicate operator *********************/ -static int add_duplicate_exec(bContext *C, wmOperator *op) +static int duplicate_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); adduplicateflagNurb(obedit, 1); -// XXX BIF_TransformSetUndo("Add Duplicate"); -// initTransform(TFM_TRANSLATION, CTX_NO_PET); -// Transform(); - return OPERATOR_FINISHED; } -void CURVE_OT_add_duplicate(wmOperatorType *ot) +static int duplicate_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + duplicate_exec(C, op); + + RNA_int_set(op->ptr, "mode", TFM_TRANSLATION); + WM_operator_name_call(C, "TFM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); + + return OPERATOR_FINISHED; +} + +void CURVE_OT_duplicate(wmOperatorType *ot) { /* identifiers */ - ot->name= "Add Duplicate"; - ot->idname= "CURVE_OT_add_duplicate"; + ot->name= "Duplicate"; + ot->idname= "CURVE_OT_duplicate"; /* api callbacks */ - ot->exec= add_duplicate_exec; - ot->poll= ED_operator_editcurve; + ot->exec= duplicate_exec; + ot->invoke= duplicate_invoke; + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* to give to transform */ + RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX); } /********************** delete operator *********************/ @@ -4212,7 +4288,7 @@ static int delete_exec(bContext *C, wmOperator *op) if(type==0) deleteflagNurb(C, op, 1); else freeNurblist(editnurb); - // XXX notifier + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); return OPERATOR_FINISHED; @@ -4342,11 +4418,12 @@ static int delete_exec(bContext *C, wmOperator *op) bezt2= bezt+(nu->pntsu-1); if( (bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT) ) { nu->flagu &= ~CU_CYCLIC; + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - BIF_undo_push("Delete"); } } - return OPERATOR_FINISHED; //XXX + + return OPERATOR_FINISHED; } cut= a; nu1= nu; @@ -4367,11 +4444,12 @@ static int delete_exec(bContext *C, wmOperator *op) bp2= bp+(nu->pntsu-1); if( bp2->f1 & SELECT ) { nu->flagu &= ~CU_CYCLIC; + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - BIF_undo_push("Delete"); } } - return OPERATOR_FINISHED; // XXX + + return OPERATOR_FINISHED; } cut= a; nu1= nu; @@ -4464,8 +4542,8 @@ static int delete_exec(bContext *C, wmOperator *op) else if(type==2) freeNurblist(editnurb); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - // XXX notifier return OPERATOR_FINISHED; } @@ -4477,13 +4555,13 @@ static int delete_invoke(bContext *C, wmOperator *op, wmEvent *event) if(obedit->type==OB_SURF) { head= uiPupMenuBegin("Delete", 0); - uiMenuItemEnumO(head, "", 0, op->idname, "type", 0); - uiMenuItemEnumO(head, "", 0, op->idname, "type", 2); + uiMenuItemEnumO(head, "", 0, op->type->idname, "type", 0); + uiMenuItemEnumO(head, "", 0, op->type->idname, "type", 2); uiPupMenuEnd(C, head); } else { head= uiPupMenuBegin("Delete", 0); - uiMenuItemsEnumO(head, op->idname, "type"); + uiMenuItemsEnumO(head, op->type->idname, "type"); uiPupMenuEnd(C, head); } @@ -4505,7 +4583,7 @@ void CURVE_OT_delete(wmOperatorType *ot) /* api callbacks */ ot->exec= delete_exec; ot->invoke= delete_invoke; - ot->poll= ED_operator_editcurve; + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -4521,23 +4599,20 @@ static int set_smooth_exec(bContext *C, wmOperator *op) Object *obedit= CTX_data_edit_object(C); ListBase *editnurb= curve_get_editcurve(obedit); Nurb *nu; - int disable= RNA_boolean_get(op->ptr, "disable"); + int clear= RNA_boolean_get(op->ptr, "clear"); if(obedit->type != OB_CURVE) return OPERATOR_CANCELLED; for(nu= editnurb->first; nu; nu= nu->next) { if(isNurbsel(nu)) { - if(!disable) nu->flag |= CU_SMOOTH; + if(!clear) nu->flag |= CU_SMOOTH; else nu->flag &= ~CU_SMOOTH; } } - // XXX notifier + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA); - - // XXX if(event==1) BIF_undo_push("Set Smooth"); - // XXX else if(event==0) BIF_undo_push("Set Solid"); return OPERATOR_FINISHED; } @@ -4550,22 +4625,23 @@ void CURVE_OT_set_smooth(wmOperatorType *ot) /* api callbacks */ ot->exec= set_smooth_exec; - ot->poll= ED_operator_editcurve; + ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_boolean(ot->srna, "disable", 0, "Disable", "Disable smooth shading for selection instead of enabling it."); + RNA_def_boolean(ot->srna, "clear", 0, "Clear", "Clear smooth shading to solid for selection instead of enabling it."); } -/********************* XXX join operator ***********************/ +/************** join operator, to be used externally? ****************/ -int join_curve(Scene *scene, int type) +int join_curve(bContext *C, wmOperator *op, int type) { - View3D *v3d= NULL; // XXX + View3D *v3d= CTX_wm_view3d(C); + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_edit_object(C); Base *base, *nextb; - Object *ob; Curve *cu; Nurb *nu, *newnu; BezTriple *bezt; @@ -4573,24 +4649,26 @@ int join_curve(Scene *scene, int type) ListBase tempbase; float imat[4][4], cmat[4][4]; int a; + + // XXX not integrated yet, to be called by object/ module? */ - ob= OBACT; - if (object_data_is_libdata(ob)) { - error_libdata(); - return 0; + if(object_data_is_libdata(ob)) { + BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); + return OPERATOR_CANCELLED; } - if(!v3d || ob->type!=type) return 0; - if(ob->lay & v3d->lay); else return 0; + if(ob->type!=type) + return 0; + tempbase.first= tempbase.last= 0; /* trasnform all selected curves inverse in obact */ Mat4Invert(imat, ob->obmat); - base= FIRSTBASE; - while(base) { + for(base= FIRSTBASE; base; base=nextb) { nextb= base->next; - if (TESTBASE(v3d, base)) { + + if(TESTBASE(v3d, base)) { if(base->object->type==type) { if(base->object != ob) { @@ -4629,7 +4707,6 @@ int join_curve(Scene *scene, int type) } } } - base= nextb; } cu= ob->data; @@ -4637,15 +4714,15 @@ int join_curve(Scene *scene, int type) DAG_scene_sort(scene); // because we removed object(s), call before editmode! - // XXX Context - ED_object_enter_editmode(NULL, EM_WAITCURSOR); - ED_object_exit_editmode(NULL, EM_FREEDATA|EM_WAITCURSOR); + ED_object_enter_editmode(C, EM_WAITCURSOR); + ED_object_exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR); - BIF_undo_push("Join"); - return 1; + // BIF_undo_push("Join"); + + return OPERATOR_FINISHED; } -/***************** XXX add primitive operator ********************/ +/************ add primitive, internal + external ****************/ Nurb *addNurbprim(bContext *C, int type, int newname) { @@ -4672,16 +4749,23 @@ Nurb *addNurbprim(bContext *C, int type, int newname) if(obedit) { Mat3CpyMat4(mat, obedit->obmat); - curs= give_cursor(scene, v3d); - VECCOPY(cent, curs); + if(v3d) { + curs= give_cursor(scene, v3d); + VECCOPY(cent, curs); + } + else + cent[0]= cent[1]= cent[2]= 0.0f; + cent[0]-= obedit->obmat[3][0]; cent[1]-= obedit->obmat[3][1]; cent[2]-= obedit->obmat[3][2]; - if (rv3d) { - if ( !(newname) || U.flag & USER_ADD_VIEWALIGNED) + if(rv3d) { + if (!(newname) || U.flag & USER_ADD_VIEWALIGNED || !rv3d) Mat3CpyMat4(imat, rv3d->viewmat); - else Mat3One(imat); + else + Mat3One(imat); + Mat3MulVecfl(imat, cent); Mat3MulMat3(cmat, imat, mat); Mat3Inv(imat, cmat); @@ -4994,9 +5078,9 @@ Nurb *addNurbprim(bContext *C, int type, int newname) BLI_addtail(editnurb, nu); /* temporal for spin */ if(newname && (U.flag & USER_ADD_VIEWALIGNED) == 0) - spin_nurb(scene, obedit, 0, 2); + spin_nurb(C, scene, obedit, 0, 2); else - spin_nurb(scene, obedit, 0, 0); + spin_nurb(C, scene, obedit, 0, 0); makeknots(nu, 2, nu->flagv>>1); @@ -5024,9 +5108,9 @@ Nurb *addNurbprim(bContext *C, int type, int newname) nu->flag= CU_SMOOTH; BLI_addtail(editnurb, nu); /* temporal for extrude and translate */ if(newname && (U.flag & USER_ADD_VIEWALIGNED) == 0) - spin_nurb(scene, obedit, 0, 2); + spin_nurb(C, scene, obedit, 0, 2); else - spin_nurb(scene, obedit, 0, 0); + spin_nurb(C, scene, obedit, 0, 0); BLI_remlink(editnurb, nu); @@ -5049,6 +5133,87 @@ Nurb *addNurbprim(bContext *C, int type, int newname) return nu; } +/***************** add curve primitive operator ********************/ + +static int add_curve_primitive_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *obedit= CTX_data_edit_object(C); + + addNurbprim(C, RNA_enum_get(op->ptr, "type"), 0); + + DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); + + return OPERATOR_FINISHED; +} + +void CURVE_OT_add_curve_primitive(wmOperatorType *ot) +{ + static EnumPropertyItem type_items[]= { + {CU_PRIM_CURVE|CU_2D|CU_BEZIER, "BEZIER_CURVE", "Bezier Curve", ""}, + {CU_PRIM_CIRCLE|CU_2D|CU_BEZIER, "BEZIER_CIRCLE", "Bezier Circle", ""}, + {CU_PRIM_CURVE|CU_2D|CU_NURBS, "NURBS_CURVE", "NURBS Curve", ""}, + {CU_PRIM_CIRCLE|CU_2D|CU_NURBS, "NURBS_CIRCLE", "NURBS Circle", ""}, + {CU_PRIM_PATH|CU_2D|CU_NURBS, "PATH", "Path", ""}, + {0, NULL, NULL, NULL}}; + + /* identifiers */ + ot->name= "Add Curve Primitive"; + ot->idname= "CURVE_OT_add_curve_primitive"; + + /* api callbacks */ + ot->exec= add_curve_primitive_exec; + ot->poll= ED_operator_editcurve; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_enum(ot->srna, "type", type_items, CU_PRIM_CURVE|CU_2D|CU_BEZIER, "Type", "Type of primitive to add."); +} + +/***************** add surface primitive operator ********************/ + +static int add_surface_primitive_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *obedit= CTX_data_edit_object(C); + + addNurbprim(C, RNA_enum_get(op->ptr, "type"), 0); + + DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); + + return OPERATOR_FINISHED; +} + +void CURVE_OT_add_surface_primitive(wmOperatorType *ot) +{ + static EnumPropertyItem type_items[]= { + {CU_PRIM_CURVE|CU_NURBS, "NURBS_CURVE", "NURBS Curve", ""}, + {CU_PRIM_CIRCLE|CU_NURBS, "NURBS_CIRCLE", "NURBS Circle", ""}, + {CU_PRIM_PATCH|CU_NURBS, "NURBS_SURFACE", "NURBS Surface", ""}, + {CU_PRIM_TUBE|CU_NURBS, "NURBS_TUBE", "NURBS Tube", ""}, + {CU_PRIM_SPHERE|CU_NURBS, "NURBS_SPHERE", "NURBS Sphere", ""}, + {CU_PRIM_DONUT|CU_NURBS, "NURBS_DONUT", "NURBS Donut", ""}, + {0, NULL, NULL, NULL}}; + + /* identifiers */ + ot->name= "Add Surface Primitive"; + ot->idname= "CURVE_OT_add_surface_primitive"; + + /* api callbacks */ + ot->exec= add_surface_primitive_exec; + ot->poll= ED_operator_editsurf; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_enum(ot->srna, "type", type_items, CU_PRIM_CURVE|CU_NURBS, "Type", "Type of primitive to add."); +} + /***************** clear tilt operator ********************/ static int clear_tilt_exec(bContext *C, wmOperator *op) @@ -5079,7 +5244,7 @@ static int clear_tilt_exec(bContext *C, wmOperator *op) } } - // XXX notifier WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_TRANSFORM, obedit); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA); return OPERATOR_FINISHED; diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h index 29411e2cc91..3d428dbf754 100644 --- a/source/blender/editors/include/ED_curve.h +++ b/source/blender/editors/include/ED_curve.h @@ -45,7 +45,6 @@ ListBase *curve_get_editcurve(struct Object *ob); void load_editNurb (struct Object *obedit); void make_editNurb (struct Object *obedit); -void remake_editNurb (struct Object *obedit); void free_editNurb (struct Object *obedit); void mouse_nurb (struct bContext *C, short mval[2], int extend); diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index b5e2558c893..3ec472a9085 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -117,6 +117,8 @@ int ED_operator_object_active(struct bContext *C); int ED_operator_editmesh(struct bContext *C); int ED_operator_editarmature(struct bContext *C); int ED_operator_editcurve(struct bContext *C); +int ED_operator_editsurf(struct bContext *C); +int ED_operator_editsurfcurve(struct bContext *C); int ED_operator_uvedit(struct bContext *C); int ED_operator_uvmap(struct bContext *C); int ED_operator_posemode(struct bContext *C); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index c4bd05f8076..8f96732a911 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2309,7 +2309,7 @@ uiBut *ui_def_but_operator(uiBlock *block, int type, char *opname, int opcontext else str= opname; } - if ((!tip || tip[0]=='\0') && ot->description) { + if ((!tip || tip[0]=='\0') && ot && ot->description) { tip= ot->description; } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 59566fcfe7d..aeddff72539 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -422,10 +422,10 @@ void OBJECT_OT_mesh_add(wmOperatorType *ot) } static EnumPropertyItem prop_curve_types[] = { - {CU_BEZIER|CU_2D|CU_PRIM_CURVE, "BEZCURVE", "Bezier Curve", ""}, - {CU_BEZIER|CU_2D|CU_PRIM_CIRCLE, "BEZCIRCLE", "Bezier Circle", ""}, - {CU_NURBS|CU_2D|CU_PRIM_CURVE, "NURBSCUVE", "NURBS Curve", ""}, - {CU_NURBS|CU_2D|CU_PRIM_CIRCLE, "NURBSCIRCLE", "NURBS Circle", ""}, + {CU_BEZIER|CU_2D|CU_PRIM_CURVE, "BEZIER_CURVE", "Bezier Curve", ""}, + {CU_BEZIER|CU_2D|CU_PRIM_CIRCLE, "BEZIER_CIRCLE", "Bezier Circle", ""}, + {CU_NURBS|CU_2D|CU_PRIM_CURVE, "NURBS_CURVE", "NURBS Curve", ""}, + {CU_NURBS|CU_2D|CU_PRIM_CIRCLE, "NURBS_CIRCLE", "NURBS Circle", ""}, {CU_NURBS|CU_2D|CU_PRIM_PATH, "PATH", "Path", ""}, {0, NULL, NULL, NULL} }; @@ -5991,7 +5991,6 @@ static int add_duplicate_exec(bContext *C, wmOperator *op) static int add_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *event) { - add_duplicate_exec(C, op); RNA_int_set(op->ptr, "mode", TFM_TRANSLATION); @@ -6020,7 +6019,6 @@ void OBJECT_OT_add_duplicate(wmOperatorType *ot) RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX); } - /* ********************** */ void image_aspect(Scene *scene, View3D *v3d) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 2225be4eda8..04e66995b2e 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -232,11 +232,11 @@ int ED_operator_uvmap(bContext *C) return 0; } -int ED_operator_editcurve(bContext *C) +int ED_operator_editsurfcurve(bContext *C) { Object *obedit= CTX_data_edit_object(C); - if(obedit && obedit->type==OB_CURVE) - return NULL != ((Mesh *)obedit->data)->edit_mesh; + if(obedit && ELEM(obedit->type, OB_CURVE, OB_SURF)) + return NULL != ((Curve *)obedit->data)->editnurb; return 0; // XXX this test was in many tools, still needed? @@ -244,6 +244,22 @@ int ED_operator_editcurve(bContext *C) } +int ED_operator_editcurve(bContext *C) +{ + Object *obedit= CTX_data_edit_object(C); + if(obedit && obedit->type==OB_CURVE) + return NULL != ((Curve *)obedit->data)->editnurb; + return 0; +} + +int ED_operator_editsurf(bContext *C) +{ + Object *obedit= CTX_data_edit_object(C); + if(obedit && obedit->type==OB_SURF) + return NULL != ((Curve *)obedit->data)->editnurb; + return 0; +} + /* *************************** action zone operator ************************** */ /* operator state vars used: diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 20a6f15e057..7131bf65495 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -1152,109 +1152,46 @@ static uiBlock *view3d_select_meshmenu(bContext *C, ARegion *ar, void *arg_unuse return block; } -void do_view3d_select_curvemenu(bContext *C, void *arg, int event) +static void view3d_select_curvemenu(bContext *C, uiMenuItem *head, void *arg_unused) { -#if 0 -/* extern void borderselect(void);*/ + Object *obedit= CTX_data_edit_object(C); - switch(event) { - case 0: /* border select */ - borderselect(); - break; - case 2: /* Select/Deselect all */ - deselectall_nurb(); - break; - case 3: /* Inverse */ - selectswapNurb(); - break; - /* select connected control points */ - /*case 4: - G.qual |= LR_CTRLKEY; - select_connected_nurb(); - G.qual &= ~LR_CTRLKEY; - break;*/ - case 5: /* select row (nurb) */ - selectrow_nurb(); - break; - case 7: /* select/deselect first */ - selectend_nurb(FIRST, 1, DESELECT); - break; - case 8: /* select/deselect last */ - selectend_nurb(LAST, 1, DESELECT); - break; - case 9: /* select more */ - select_more_nurb(); - break; - case 10: /* select less */ - select_less_nurb(); - break; - case 11: /* select next */ - select_next_nurb(); - break; - case 12: /* select previous */ - select_prev_nurb(); - break; - case 13: /* select random */ - select_random_nurb(); - break; - case 14: /* select every nth */ - select_every_nth_nurb(); - break; - } - allqueue(REDRAWVIEW3D, 0); -#endif -} + uiMenuItemO(head, 0, "VIEW3D_OT_borderselect"); + uiMenuItemO(head, 0, "VIEW3D_OT_circle_select"); + uiMenuSeparator(head); -static uiBlock *view3d_select_curvemenu(bContext *C, ARegion *ar, void *arg_unused) -{ - Scene *scene= CTX_data_scene(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "view3d_select_curvemenu", UI_EMBOSSP, UI_HELV); - uiBlockSetButmFunc(block, do_view3d_select_curvemenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Border Select|B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Inverse", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Random...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Every Nth", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 14, ""); - - if (OBACT->type == OB_SURF) { - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Control Point Row|Shift R", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); + uiMenuItemO(head, 0, "CURVE_OT_de_select_all"); + uiMenuItemO(head, 0, "CURVE_OT_select_inverse"); + uiMenuItemO(head, 0, "CURVE_OT_select_random"); // Random... + uiMenuItemO(head, 0, "CURVE_OT_select_every_nth"); // Every Nth.. + + uiMenuSeparator(head); + + if(obedit->type == OB_SURF) { + uiMenuItemO(head, 0, "CURVE_OT_select_row"); } else { - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect First", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect Last", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Next", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Previous", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, ""); + uiMenuItemO(head, 0, "CURVE_OT_de_select_first"); + uiMenuItemO(head, 0, "CURVE_OT_de_select_last"); + uiMenuItemO(head, 0, "CURVE_OT_select_next"); + uiMenuItemO(head, 0, "CURVE_OT_select_previous"); } - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "More|Ctrl NumPad +", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Less|Ctrl NumPad -", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, ""); - + + uiMenuSeparator(head); + + uiMenuItemO(head, 0, "CURVE_OT_select_more"); + uiMenuItemO(head, 0, "CURVE_OT_select_less"); + /* commented out because it seems to only like the LKEY method - based on mouse pointer position :( */ - /*uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Connected Control Points|Ctrl L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");*/ - - if(ar->alignment==RGN_ALIGN_TOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - return block; + /* uiMenuItemO(head, 0, "CURVE_OT_select_linked"); */ + +#if 0 + G.qual |= LR_CTRLKEY; + select_connected_nurb(); + G.qual &= ~LR_CTRLKEY; + break;*/ +#endif } void do_view3d_select_metaballmenu(bContext *C, void *arg, int event) @@ -3327,262 +3264,85 @@ static uiBlock *view3d_edit_meshmenu(bContext *C, ARegion *ar, void *arg_unused) return block; } -static void do_view3d_edit_curve_controlpointsmenu(bContext *C, void *arg, int event) +static void view3d_edit_curve_controlpointsmenu(bContext *C, uiMenuItem *head, void *arg_unused) { -#if 0 - Scene *scene= CTX_data_scene(C); - - switch(event) { - case 0: /* tilt */ - initTransform(TFM_TILT, CTX_NONE); - Transform(); - break; - case 1: /* clear tilt */ - clear_tilt(); - break; - case 2: /* Free */ - sethandlesNurb(editnurb, 3); - DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - break; - case 3: /* vector */ - sethandlesNurb(editnurb, 2); - DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - break; - case 4: /* smooth */ - sethandlesNurb(editnurb, 1); - DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - break; - case 5: /* make vertex parent */ - make_parent(); - break; - case 6: /* add hook */ - add_hook_menu(); - break; - case 7: - separate_nurb(); - break; - } - allqueue(REDRAWVIEW3D, 0); -#endif -} + Object *obedit= CTX_data_edit_object(C); -static uiBlock *view3d_edit_curve_controlpointsmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - Scene *scene= CTX_data_scene(C); - uiBlock *block; - short yco = 20, menuwidth = 120; - - block= uiBeginBlock(C, ar, "view3d_edit_curve_controlpointsmenu", UI_EMBOSSP, UI_HELV); - uiBlockSetButmFunc(block, do_view3d_edit_curve_controlpointsmenu, NULL); - - if (OBACT->type == OB_CURVE) { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Tilt|T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Clear Tilt|Alt T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Separate|P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + if(obedit->type == OB_CURVE) { + uiMenuItemEnumO(head, "", 0, "TFM_OT_transform", "mode", TFM_TILT); + uiMenuItemO(head, 0, "CURVE_OT_clear_tilt"); + uiMenuItemO(head, 0, "CURVE_OT_separate"); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Automatic|Shift H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Toggle Free/Aligned|H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector|V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); + uiMenuSeparator(head); + + uiMenuItemEnumO(head, "", 0, "CURVE_OT_set_handle_type", "type", 1); + uiMenuItemEnumO(head, "", 0, "CURVE_OT_set_handle_type", "type", 3); + uiMenuItemEnumO(head, "", 0, "CURVE_OT_set_handle_type", "type", 2); - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + uiMenuSeparator(head); } - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make Vertex Parent|Ctrl P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add Hook|Ctrl H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - return block; -} -void do_view3d_edit_curve_segmentsmenu(bContext *C, void *arg, int event) -{ -#if 0 - switch(event) { - case 0: /* subdivide */ - subdivideNurb(); - break; - case 1: /* switch direction */ - switchdirectionNurb2(); - break; - } - allqueue(REDRAWVIEW3D, 0); -#endif + // XXX uiMenuItemO(head, 0, "OBJECT_OT_make_vertex_parent"); Make VertexParent|Ctrl P + // make_parent() + // XXX uiMenuItemO(head, 0, "OBJECT_OT_add_hook"); Add Hook| Ctrl H + // add_hook_menu() } -static uiBlock *view3d_edit_curve_segmentsmenu(bContext *C, ARegion *ar, void *arg_unused) +static void view3d_edit_curve_segmentsmenu(bContext *C, uiMenuItem *head, void *arg_unused) { - uiBlock *block; - short yco = 20, menuwidth = 120; - - block= uiBeginBlock(C, ar, "view3d_edit_curve_segmentsmenu", UI_EMBOSSP, UI_HELV); - uiBlockSetButmFunc(block, do_view3d_edit_curve_segmentsmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Subdivide", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Switch Direction", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - return block; + uiMenuItemO(head, 0, "CURVE_OT_subdivide"); + uiMenuItemO(head, 0, "CURVE_OT_switch_direction"); } -void do_view3d_edit_curve_showhidemenu(bContext *C, void *arg, int event) +static void view3d_edit_curve_showhidemenu(bContext *C, uiMenuItem *head, void *arg_unused) { -#if 0 - switch(event) { - case 10: /* show hidden control points */ - revealNurb(); - break; - case 11: /* hide selected control points */ - hideNurb(0); - break; - case 12: /* hide deselected control points */ - hideNurb(1); - break; - } - allqueue(REDRAWVIEW3D, 0); -#endif + uiMenuItemO(head, 0, "CURVE_OT_reveal"); + uiMenuItemO(head, 0, "CURVE_OT_hide"); + uiMenuItemBooleanO(head, "Hide Deselected", 0, "CURVE_OT_hide", "deselected", 1); } -static uiBlock *view3d_edit_curve_showhidemenu(bContext *C, ARegion *ar, void *arg_unused) +static void view3d_edit_curvemenu(bContext *C, uiMenuItem *head, void *arg_unused) { + PointerRNA sceneptr; Scene *scene= CTX_data_scene(C); - uiBlock *block; - short yco = 20, menuwidth = 120; - block= uiBeginBlock(C, ar, "view3d_edit_curve_showhidemenu", UI_EMBOSSP, UI_HELV); - uiBlockSetButmFunc(block, do_view3d_edit_curve_showhidemenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Hidden|Alt H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Hide Selected|Alt Ctrl H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, ""); - if (OBACT->type == OB_SURF) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Hide Deselected Control Points|Alt Shift H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, ""); - + RNA_id_pointer_create(&scene->id, &sceneptr); - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - return block; -} -static void do_view3d_edit_curvemenu(bContext *C, void *arg, int event) -{ #if 0 - switch(event) { - - case 0: /* Undo Editing */ - remake_editNurb(ob); - break; - case 1: /* transformation properties */ -// XXX mainqenter(NKEY, 1); - break; - case 2: /* insert keyframe */ - common_insertkey(); - break; - case 4: /* extrude */ - if (OBACT->type == OB_CURVE) { - addvert_Nurb('e'); - } else if (OBACT->type == OB_SURF) { - extrude_nurb(); - } - break; - case 5: /* duplicate */ - duplicate_context_selected(); - break; - case 6: /* make segment */ - addsegment_nurb(); - break; - case 7: /* toggle cyclic */ - makecyclicNurb(); - DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - break; - case 8: /* delete */ - delete_context_selected(); - break; - case 9: /* proportional edit (toggle) */ - if(scene->proportional) scene->proportional= 0; - else scene->proportional= 1; - break; - case 13: /* Shear */ - initTransform(TFM_SHEAR, CTX_NONE); - Transform(); - break; - case 14: /* Warp */ - initTransform(TFM_WARP, CTX_NONE); - Transform(); - break; - case 15: - uv_autocalc_tface(); - break; - case 16: /* delete keyframe */ - common_deletekey(); - break; - } - allqueue(REDRAWVIEW3D, 0); -#endif -} - -static uiBlock *view3d_edit_curvemenu(bContext *C, ARegion *ar, void *arg_unused) -{ - Scene *scene= CTX_data_scene(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "view3d_edit_curvemenu", UI_EMBOSSP, UI_HELV); - uiBlockSetButmFunc(block, do_view3d_edit_curvemenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reload Original|U", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Transform Properties...|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, ""); uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, ""); uiDefIconTextBlockBut(block, view3d_edit_snapmenu, NULL, ICON_RIGHTARROW_THIN, "Snap", 0, yco-=20, 120, 19, ""); - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Insert Keyframe|I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Keyframe|Alt I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "UV Unwrap|U", 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, ICON_BLANK1, "Extrude|E", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Duplicate|Shift D", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make Segment|F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Toggle Cyclic|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete...|X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBlockBut(block, view3d_edit_curve_controlpointsmenu, NULL, ICON_RIGHTARROW_THIN, "Control Points", 0, yco-=20, menuwidth, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_curve_segmentsmenu, NULL, ICON_RIGHTARROW_THIN, "Segments", 0, yco-=20, menuwidth, 19, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(scene->proportional) { - uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Proportional Editing|O", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, ""); - } else { - uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Proportional Editing|O", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, ""); - } - uiDefIconTextBlockBut(block, view3d_edit_propfalloffmenu, NULL, ICON_RIGHTARROW_THIN, "Proportional Falloff", 0, yco-=20, menuwidth, 19, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBlockBut(block, view3d_edit_curve_showhidemenu, NULL, ICON_RIGHTARROW_THIN, "Show/Hide Control Points", 0, yco-=20, menuwidth, 19, ""); + uiMenuSeparator(head); +#endif - if(ar->alignment==RGN_ALIGN_TOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } + // XXX uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Insert Keyframe|I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); + // common_insertkey(); + // XXX uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Keyframe|Alt I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, ""); + // common_deletekey(); - uiTextBoundsBlock(block, 50); - return block; + + uiMenuItemO(head, 0, "CURVE_OT_extrude"); + uiMenuItemO(head, 0, "CURVE_OT_duplicate"); + uiMenuItemO(head, 0, "CURVE_OT_separate"); + uiMenuItemO(head, 0, "CURVE_OT_make_segment"); + uiMenuItemO(head, 0, "CURVE_OT_toggle_cyclic"); + uiMenuItemO(head, 0, "CURVE_OT_delete"); // Delete... + + uiMenuSeparator(head); + + uiMenuLevel(head, "Control Points", view3d_edit_curve_controlpointsmenu); + uiMenuLevel(head, "Segments", view3d_edit_curve_segmentsmenu); + + uiMenuSeparator(head); + + uiMenuItemBooleanR(head, &sceneptr, "proportional_editing"); // |O + uiMenuLevelEnumR(head, &sceneptr, "proportional_editing_falloff"); + + uiMenuSeparator(head); + + uiMenuLevel(head, "Show/Hide Control Points", view3d_edit_curve_showhidemenu); } static void do_view3d_edit_mball_showhidemenu(bContext *C, void *arg, int event) @@ -3650,9 +3410,6 @@ static void do_view3d_edit_metaballmenu(bContext *C, void *arg, int event) case 7: /* Transform Properties */ add_blockhandler(sa, VIEW3D_HANDLER_OBJECT, 0); break; - case 8: - uv_autocalc_tface(); - break; } allqueue(REDRAWVIEW3D, 0); #endif @@ -3679,10 +3436,6 @@ static uiBlock *view3d_edit_metaballmenu(bContext *C, ARegion *ar, void *arg_unu uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "UV Unwrap|U", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Duplicate|Shift D", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete...|X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); @@ -5648,7 +5401,7 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o if (ob && ob->type == OB_MESH) { uiDefPulldownBut(block, view3d_select_meshmenu, NULL, "Select", xco,yco-2, xmax-3, 24, ""); } else if (ob && (ob->type == OB_CURVE || ob->type == OB_SURF)) { - uiDefPulldownBut(block, view3d_select_curvemenu, NULL, "Select", xco,yco-2, xmax-3, 24, ""); + uiDefMenuBut(block, view3d_select_curvemenu, NULL, "Select", xco, yco-2, xmax-3, 24, ""); } else if (ob && ob->type == OB_FONT) { uiDefPulldownBut(block, view3d_select_meshmenu, NULL, "Select", xco, yco-2, xmax-3, 24, ""); } else if (ob && ob->type == OB_MBALL) { @@ -5682,11 +5435,11 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o xco+= xmax; } else if (ob && ob->type == OB_CURVE) { xmax= GetButStringLength("Curve"); - uiDefPulldownBut(block, view3d_edit_curvemenu, NULL, "Curve", xco,yco-2, xmax-3, 24, ""); + uiDefMenuBut(block, view3d_edit_curvemenu, NULL, "Curve", xco, yco-2, xmax-3, 24, ""); xco+= xmax; } else if (ob && ob->type == OB_SURF) { xmax= GetButStringLength("Surface"); - uiDefPulldownBut(block, view3d_edit_curvemenu, NULL, "Surface", xco,yco-2, xmax-3, 24, ""); + uiDefMenuBut(block, view3d_edit_curvemenu, NULL, "Surface", xco, yco-2, xmax-3, 24, ""); xco+= xmax; } else if (ob && ob->type == OB_FONT) { xmax= GetButStringLength("Text"); diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index ccad3acfd56..d8b1dd66325 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -596,10 +596,8 @@ static void uv_map_transform(bContext *C, wmOperator *op, float center[3], float Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); EditMesh *em= ((Mesh*)obedit->data)->edit_mesh; - SpaceLink *sl= CTX_wm_space_data(C); - View3D *v3d= (sl->spacetype == SPACE_VIEW3D)? (View3D*)sl: NULL; - ARegion *ar= CTX_wm_region(C); - RegionView3D *rv3d= (v3d && ar->regiontype == RGN_TYPE_WINDOW)? ar->regiondata: NULL; + View3D *v3d= CTX_wm_view3d(C); + RegionView3D *rv3d= CTX_wm_region_view3d(C); /* common operator properties */ int align= RNA_enum_get(op->ptr, "align"); int direction= RNA_enum_get(op->ptr, "direction"); @@ -935,13 +933,12 @@ static int from_view_exec(bContext *C, wmOperator *op) static int from_view_poll(bContext *C) { - SpaceLink *sl= CTX_wm_space_data(C); - ARegion *ar= CTX_wm_region(C); + RegionView3D *rv3d= CTX_wm_region_view3d(C) if(!ED_operator_uvmap(C)) return 0; - return (sl->spacetype == SPACE_VIEW3D && ar->regiontype == RGN_TYPE_WINDOW); + return (rv3d != NULL); } void UV_OT_from_view(wmOperatorType *ot) -- cgit v1.2.3