From cd154da9732962870339952898499ed1b1c32d93 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sun, 29 Nov 2009 22:16:29 +0000 Subject: 1. Extend option for 3d view border select now does something (default True to keep same behavior) 2. Add action parameter to Select_All_Toggle operators, rename to Select_All. Options are Toggle (default), Select, Deselect, Invert (same as select swap). This makes it possible to map separate hotkeys for select all and deselect all. NOTE for Aligorith: I didn't change animation operators for select_all which already had an Invert operator. These should be fixed eventually. --- source/blender/editors/curve/curve_intern.h | 2 +- source/blender/editors/curve/curve_ops.c | 4 +- source/blender/editors/curve/editcurve.c | 82 +++++++++++++++++++++++++---- 3 files changed, 76 insertions(+), 12 deletions(-) (limited to 'source/blender/editors/curve') diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h index ad3e9427861..6c477bd011a 100644 --- a/source/blender/editors/curve/curve_intern.h +++ b/source/blender/editors/curve/curve_intern.h @@ -84,7 +84,7 @@ 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_select_all_toggle(struct wmOperatorType *ot); +void CURVE_OT_select_all(struct wmOperatorType *ot); void CURVE_OT_select_inverse(struct wmOperatorType *ot); void CURVE_OT_select_linked(struct wmOperatorType *ot); void CURVE_OT_select_row(struct wmOperatorType *ot); diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 15ff971b9cf..c54739902d0 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -139,7 +139,7 @@ void ED_operatortypes_curve(void) WM_operatortype_append(CURVE_OT_de_select_first); WM_operatortype_append(CURVE_OT_de_select_last); - WM_operatortype_append(CURVE_OT_select_all_toggle); + WM_operatortype_append(CURVE_OT_select_all); WM_operatortype_append(CURVE_OT_select_inverse); WM_operatortype_append(CURVE_OT_select_linked); WM_operatortype_append(CURVE_OT_select_row); @@ -222,7 +222,7 @@ void ED_keymap_curve(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OBJECT_OT_curve_add", AKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "CURVE_OT_vertex_add", LEFTMOUSE, KM_CLICK, KM_CTRL, 0); - WM_keymap_add_item(keymap, "CURVE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "CURVE_OT_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); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index e53b419c6ea..a65e1164a27 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -83,6 +83,9 @@ #include "RNA_access.h" #include "RNA_define.h" +void selectend_nurb(Object *obedit, short selfirst, short doswap, short selstatus); +static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short selstatus); + /* still need to eradicate a few :( */ #define callocstructN(x,y,name) (x*)MEM_callocN((y)* sizeof(x),name) @@ -363,6 +366,26 @@ void free_editNurb(Object *obedit) } } +void CU_deselect_all(Object *obedit) +{ + ListBase *editnurb= curve_get_editcurve(obedit); + + if (editnurb) { + selectend_nurb(obedit, FIRST, 0, DESELECT); /* set first control points as unselected */ + select_adjacent_cp(editnurb, 1, 1, DESELECT); /* cascade selection */ + } +} + +void CU_select_all(Object *obedit) +{ + ListBase *editnurb= curve_get_editcurve(obedit); + + if (editnurb) { + selectend_nurb(obedit, FIRST, 0, DESELECT); /* set first control points as unselected */ + select_adjacent_cp(editnurb, 1, 1, DESELECT); /* cascade selection */ + } +} + /******************** separate operator ***********************/ static int separate_exec(bContext *C, wmOperator *op) @@ -1580,26 +1603,67 @@ static int de_select_all_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); ListBase *editnurb= curve_get_editcurve(obedit); + int action = RNA_enum_get(op->ptr, "action"); - if(nurb_has_selected_cps(editnurb)) { /* deselect all */ - selectend_nurb(obedit, FIRST, 0, DESELECT); /* set first control points as unselected */ - select_adjacent_cp(editnurb, 1, 1, DESELECT); /* cascade selection */ + if (action == SEL_TOGGLE) { + action = SEL_SELECT; + if(nurb_has_selected_cps(editnurb)) + action = SEL_DESELECT; + } + + switch (action) { + case SEL_SELECT: + CU_select_all(obedit); + break; + case SEL_DESELECT: + CU_deselect_all(obedit); + break; + case SEL_INVERT: + { + Curve *cu= obedit->data; + Nurb *nu; + BPoint *bp; + BezTriple *bezt; + int a; + + for(nu= editnurb->first; nu; nu= nu->next) { + if(nu->type == CU_BEZIER) { + bezt= nu->bezt; + a= nu->pntsu; + while(a--) { + if(bezt->hide==0) { + bezt->f2 ^= SELECT; /* always do the center point */ + if((cu->drawflag & CU_HIDE_HANDLES)==0) { + bezt->f1 ^= SELECT; + bezt->f3 ^= SELECT; + } + } + bezt++; + } + } + else { + bp= nu->bp; + a= nu->pntsu*nu->pntsv; + while(a--) { + swap_selection_bpoint(bp); + bp++; + } + } + } + break; + } } - else { /* select all */ - selectend_nurb(obedit, FIRST, 0, SELECT); /* set first control points as selected */ - select_adjacent_cp(editnurb, 1, 1, SELECT); /* cascade selection */ - } WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); return OPERATOR_FINISHED; } -void CURVE_OT_select_all_toggle(wmOperatorType *ot) +void CURVE_OT_select_all(wmOperatorType *ot) { /* identifiers */ ot->name= "Select or Deselect All"; - ot->idname= "CURVE_OT_select_all_toggle"; + ot->idname= "CURVE_OT_select_all"; /* api callbacks */ ot->exec= de_select_all_exec; -- cgit v1.2.3