diff options
Diffstat (limited to 'source/blender/editors/space_outliner/outliner.c')
-rw-r--r-- | source/blender/editors/space_outliner/outliner.c | 724 |
1 files changed, 406 insertions, 318 deletions
diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 175eb8c78ed..3007cfc4cb4 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -51,6 +51,7 @@ #include "DNA_object_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #if defined WIN32 && !defined _LIBC # include "BLI_fnmatch.h" /* use fnmatch included in blenlib */ @@ -120,7 +121,7 @@ /* ************* XXX **************** */ -static void error(const char *dummy, ...) {} +static void error(const char *UNUSED(arg), ...) {} /* ********************************** */ @@ -187,7 +188,7 @@ static void check_persistant(SpaceOops *soops, TreeElement *te, ID *id, short ty /* case 1; no TreeStore */ if(soops->treestore==NULL) { - ts= soops->treestore= MEM_callocN(sizeof(TreeStore), "treestore"); + soops->treestore= MEM_callocN(sizeof(TreeStore), "treestore"); } ts= soops->treestore; @@ -240,7 +241,7 @@ void outliner_free_tree(ListBase *lb) outliner_free_tree(&te->subtree); BLI_remlink(lb, te); - if(te->flag & TE_FREE_NAME) MEM_freeN(te->name); + if(te->flag & TE_FREE_NAME) MEM_freeN((void *)te->name); MEM_freeN(te); } } @@ -324,7 +325,7 @@ static ID *outliner_search_back(SpaceOops *soops, TreeElement *te, short idcode) struct treesort { TreeElement *te; ID *id; - char *name; + const char *name; short idcode; }; @@ -340,7 +341,7 @@ static int treesort_alpha(const void *v1, const void *v2) if(comp==1) return 1; else if(comp==2) return -1; else if(comp==3) { - int comp= strcmp(x1->name, x2->name); + comp= strcmp(x1->name, x2->name); if( comp>0 ) return 1; else if( comp<0) return -1; @@ -1112,8 +1113,8 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i c= RNA_property_array_item_char(prop, index); te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName"); - if(c) sprintf(te->name, " %c", c); - else sprintf(te->name, " %d", index+1); + if(c) sprintf((char *)te->name, " %c", c); + else sprintf((char *)te->name, " %d", index+1); te->flag |= TE_FREE_NAME; } } @@ -1243,7 +1244,7 @@ void add_seq_dup(SpaceOops *soops, Sequence *seq, TreeElement *te, short index) } } -static int outliner_filter_has_name(TreeElement *te, char *name, int flags) +static int outliner_filter_has_name(TreeElement *te, const char *name, int flags) { #if 0 int found= 0; @@ -1308,7 +1309,7 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) outliner_free_tree(&te->subtree); BLI_remlink(lb, te); - if(te->flag & TE_FREE_NAME) MEM_freeN(te->name); + if(te->flag & TE_FREE_NAME) MEM_freeN((void *)te->name); MEM_freeN(te); } } @@ -1408,7 +1409,6 @@ static void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) for(group= mainvar->group.first; group; group= group->id.next) { if(group->gobject.first) { te= outliner_add_element(soops, &soops->tree, group, NULL, 0, 0); - tselem= TREESTORE(te); for(go= group->gobject.first; go; go= go->next) { ten= outliner_add_element(soops, &te->subtree, go->ob, te, 0, 0); @@ -1509,6 +1509,42 @@ static void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) /* **************** INTERACTIVE ************* */ + +static int outliner_scroll_page_exec(bContext *C, wmOperator *op) +{ + ARegion *ar= CTX_wm_region(C); + int dy= ar->v2d.mask.ymax - ar->v2d.mask.ymin; + int up= 0; + + if(RNA_boolean_get(op->ptr, "up")) + up= 1; + + if(up == 0) dy= -dy; + ar->v2d.cur.ymin+= dy; + ar->v2d.cur.ymax+= dy; + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + + +void OUTLINER_OT_scroll_page(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Scroll Page"; + ot->idname= "OUTLINER_OT_scroll_page"; + ot->description= "Scroll page up or down"; + + /* callbacks */ + ot->exec= outliner_scroll_page_exec; + ot->poll= ED_operator_outliner_active; + + /* properties */ + RNA_def_boolean(ot->srna, "up", 0, "Up", "Scroll up one page."); +} + + static int outliner_count_levels(SpaceOops *soops, ListBase *lb, int curlevel) { TreeElement *te; @@ -1553,17 +1589,44 @@ static void outliner_set_flag(SpaceOops *soops, ListBase *lb, short flag, short /* --- */ -void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) +/* same check needed for both object operation and restrict column button func + * return 0 when in edit mode (cannot restrict view or select) + * otherwise return 1 */ +static int common_restrict_check(bContext *C, Object *ob) +{ + /* Don't allow hide an object in edit mode, + * check the bug #22153 and #21609, #23977 + */ + Object *obedit= CTX_data_edit_object(C); + if (obedit && obedit == ob) { + /* found object is hidden, reset */ + if (ob->restrictflag & OB_RESTRICT_VIEW) + ob->restrictflag &= ~OB_RESTRICT_VIEW; + /* found object is unselectable, reset */ + if (ob->restrictflag & OB_RESTRICT_SELECT) + ob->restrictflag &= ~OB_RESTRICT_SELECT; + return 0; + } + + return 1; +} + +void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { Base *base= (Base *)te->directdata; - if(base || (base= object_in_scene((Object *)tselem->id, scene))) { + Object *ob = (Object *)tselem->id; + + /* add check for edit mode */ + if(!common_restrict_check(C, ob)) return; + + if(base || (base= object_in_scene(ob, scene))) { if((base->object->restrictflag ^= OB_RESTRICT_VIEW)) { ED_base_object_select(base, BA_DESELECT); } } } -static int outliner_toggle_visibility_exec(bContext *C, wmOperator *op) +static int outliner_toggle_visibility_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *soops= CTX_wm_space_outliner(C); Scene *scene= CTX_data_scene(C); @@ -1586,14 +1649,14 @@ void OUTLINER_OT_visibility_toggle(wmOperatorType *ot) /* callbacks */ ot->exec= outliner_toggle_visibility_exec; - ot->poll= ED_operator_outliner_active; + ot->poll= ED_operator_outliner_active_no_editobject; ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } /* --- */ -static void object_toggle_selectability_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) +static void object_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { Base *base= (Base *)te->directdata; @@ -1603,7 +1666,7 @@ static void object_toggle_selectability_cb(bContext *C, Scene *scene, TreeElemen } } -static int outliner_toggle_selectability_exec(bContext *C, wmOperator *op) +static int outliner_toggle_selectability_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *soops= CTX_wm_space_outliner(C); Scene *scene= CTX_data_scene(C); @@ -1626,12 +1689,12 @@ void OUTLINER_OT_selectability_toggle(wmOperatorType *ot) /* callbacks */ ot->exec= outliner_toggle_selectability_exec; - ot->poll= ED_operator_outliner_active; + ot->poll= ED_operator_outliner_active_no_editobject; ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -void object_toggle_renderability_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) +void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { Base *base= (Base *)te->directdata; @@ -1641,7 +1704,7 @@ void object_toggle_renderability_cb(bContext *C, Scene *scene, TreeElement *te, } } -static int outliner_toggle_renderability_exec(bContext *C, wmOperator *op) +static int outliner_toggle_renderability_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *soops= CTX_wm_space_outliner(C); Scene *scene= CTX_data_scene(C); @@ -1670,7 +1733,7 @@ void OUTLINER_OT_renderability_toggle(wmOperatorType *ot) /* --- */ -static int outliner_toggle_expanded_exec(bContext *C, wmOperator *op) +static int outliner_toggle_expanded_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *soops= CTX_wm_space_outliner(C); ARegion *ar= CTX_wm_region(C); @@ -1701,7 +1764,7 @@ void OUTLINER_OT_expanded_toggle(wmOperatorType *ot) /* --- */ -static int outliner_toggle_selected_exec(bContext *C, wmOperator *op) +static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *soops= CTX_wm_space_outliner(C); ARegion *ar= CTX_wm_region(C); @@ -1782,6 +1845,7 @@ void OUTLINER_OT_show_one_level(wmOperatorType *ot) /* identifiers */ ot->name= "Show/Hide One Level"; ot->idname= "OUTLINER_OT_show_one_level"; + ot->description= "Expand/collapse all entries by one level"; /* callbacks */ ot->exec= outliner_one_level_exec; @@ -1793,6 +1857,8 @@ void OUTLINER_OT_show_one_level(wmOperatorType *ot) RNA_def_boolean(ot->srna, "open", 1, "Open", "Expand all entries one level deep."); } +/* This is not used anywhere at the moment */ +#if 0 /* return 1 when levels were opened */ static int outliner_open_back(SpaceOops *soops, TreeElement *te) { @@ -1809,8 +1875,6 @@ static int outliner_open_back(SpaceOops *soops, TreeElement *te) return retval; } -/* This is not used anywhere at the moment */ -#if 0 static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *teFind, int *found) { TreeElement *te; @@ -1836,7 +1900,7 @@ static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *te #endif // XXX just use View2D ops for this? -void outliner_page_up_down(Scene *scene, ARegion *ar, SpaceOops *soops, int up) +void outliner_page_up_down(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int up) { int dy= ar->v2d.mask.ymax-ar->v2d.mask.ymin; @@ -1904,15 +1968,14 @@ static void tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops scene_deselect_all(scene); ED_base_object_select(base, BA_SELECT); } - if(C) + if(C) { ED_base_object_activate(C, base); /* adds notifier */ + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + } } if(ob!=scene->obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); - - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); - } static int tree_element_active_material(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) @@ -1959,13 +2022,13 @@ static int tree_element_active_material(bContext *C, Scene *scene, SpaceOops *so static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) { TreeElement *tep; - TreeStoreElem *tselem, *tselemp; + TreeStoreElem /* *tselem,*/ *tselemp; Object *ob=OBACT; SpaceButs *sbuts=NULL; if(ob==NULL) return 0; // no active object - tselem= TREESTORE(te); + /*tselem= TREESTORE(te);*/ /*UNUSED*/ /* find buttons area (note, this is undefined really still, needs recode in blender) */ /* XXX removed finding sbuts */ @@ -2023,12 +2086,14 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo } } - WM_event_add_notifier(C, NC_TEXTURE, NULL); + if(set) + WM_event_add_notifier(C, NC_TEXTURE, NULL); + return 0; } -static int tree_element_active_lamp(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) +static int tree_element_active_lamp(bContext *UNUSED(C), Scene *scene, SpaceOops *soops, TreeElement *te, int set) { Object *ob; @@ -2081,7 +2146,7 @@ static int tree_element_active_defgroup(bContext *C, Scene *scene, TreeElement * ob= (Object *)tselem->id; if(set) { ob->actdef= te->index+1; - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); } else { @@ -2123,8 +2188,6 @@ static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElemen if(set==2 && (pchan->bone->flag & BONE_SELECTED)) { pchan->bone->flag &= ~BONE_SELECTED; - if(arm->act_bone==pchan->bone) - arm->act_bone= NULL; } else { pchan->bone->flag |= BONE_SELECTED; arm->act_bone= pchan->bone; @@ -2154,8 +2217,6 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, if(set==2 && (bone->flag & BONE_SELECTED)) { bone->flag &= ~BONE_SELECTED; - if(arm->act_bone==bone) - arm->act_bone= NULL; } else { bone->flag |= BONE_SELECTED; arm->act_bone= bone; @@ -2176,32 +2237,54 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, /* ebones only draw in editmode armature */ -static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) +static void tree_element_active_ebone__sel(bContext *C, Scene *scene, bArmature *arm, EditBone *ebone, short sel) { - EditBone *ebone= te->directdata; - - if(set) { - if(!(ebone->flag & BONE_HIDDEN_A)) { - bArmature *arm= scene->obedit->data; - if(set==2) ED_armature_deselectall(scene->obedit, 2); // only clear active tag - else ED_armature_deselectall(scene->obedit, 0); // deselect + if(sel) { + ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL; + arm->act_edbone= ebone; + // flush to parent? + if(ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL; + } + else { + ebone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL); + // flush to parent? + if(ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag &= ~BONE_TIPSEL; + } - ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL; - arm->act_edbone= ebone; + WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, scene->obedit); +} +static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) +{ + bArmature *arm= scene->obedit->data; + EditBone *ebone= te->directdata; - // flush to parent? - if(ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL; - - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, scene->obedit); + if(set==1) { + if(!(ebone->flag & BONE_HIDDEN_A)) { + ED_armature_deselect_all(scene->obedit, 0); // deselect + tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); + return 1; } } - else { - if (ebone->flag & BONE_SELECTED) return 1; + else if (set==2) { + if(!(ebone->flag & BONE_HIDDEN_A)) { + if(!(ebone->flag & BONE_SELECTED)) { + tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); + return 1; + } + else { + /* entirely selected, so de-select */ + tree_element_active_ebone__sel(C, scene, arm, ebone, FALSE); + return 0; + } + } + } + else if (ebone->flag & BONE_SELECTED) { + return 1; } return 0; } -static int tree_element_active_modifier(bContext *C, TreeElement *te, TreeStoreElem *tselem, int set) +static int tree_element_active_modifier(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { if(set) { Object *ob= (Object *)tselem->id; @@ -2214,7 +2297,7 @@ static int tree_element_active_modifier(bContext *C, TreeElement *te, TreeStoreE return 0; } -static int tree_element_active_psys(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) +static int tree_element_active_psys(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { if(set) { Object *ob= (Object *)tselem->id; @@ -2227,7 +2310,7 @@ static int tree_element_active_psys(bContext *C, Scene *scene, TreeElement *te, return 0; } -static int tree_element_active_constraint(bContext *C, TreeElement *te, TreeStoreElem *tselem, int set) +static int tree_element_active_constraint(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { if(set) { Object *ob= (Object *)tselem->id; @@ -2239,7 +2322,7 @@ static int tree_element_active_constraint(bContext *C, TreeElement *te, TreeStor return 0; } -static int tree_element_active_text(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) +static int tree_element_active_text(bContext *UNUSED(C), Scene *UNUSED(scene), SpaceOops *UNUSED(soops), TreeElement *UNUSED(te), int UNUSED(set)) { // XXX removed return 0; @@ -2264,7 +2347,7 @@ static int tree_element_active(bContext *C, Scene *scene, SpaceOops *soops, Tree return 0; } -static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) +static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { Object *ob= (Object *)tselem->id; Base *base= object_in_scene(ob, scene); @@ -2284,7 +2367,7 @@ static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *te, return 0; } -static int tree_element_active_sequence(bContext *C, TreeElement *te, TreeStoreElem *tselem, int set) +static int tree_element_active_sequence(TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) { Sequence *seq= (Sequence*) te->directdata; @@ -2298,7 +2381,7 @@ static int tree_element_active_sequence(bContext *C, TreeElement *te, TreeStoreE return(0); } -static int tree_element_active_sequence_dup(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) +static int tree_element_active_sequence_dup(Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) { Sequence *seq, *p; Editing *ed= seq_give_editing(scene, FALSE); @@ -2325,7 +2408,7 @@ static int tree_element_active_sequence_dup(bContext *C, Scene *scene, TreeEleme return(0); } -static int tree_element_active_keymap_item(bContext *C, TreeElement *te, TreeStoreElem *tselem, int set) +static int tree_element_active_keymap_item(bContext *UNUSED(C), TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) { wmKeyMapItem *kmi= te->directdata; @@ -2370,9 +2453,9 @@ static int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, case TSE_POSEGRP: return tree_element_active_posegroup(C, scene, te, tselem, set); case TSE_SEQUENCE: - return tree_element_active_sequence(C, te, tselem, set); + return tree_element_active_sequence(te, tselem, set); case TSE_SEQUENCE_DUP: - return tree_element_active_sequence_dup(C, scene, te, tselem, set); + return tree_element_active_sequence_dup(scene, te, tselem, set); case TSE_KEYMAP_ITEM: return tree_element_active_keymap_item(C, te, tselem, set); @@ -2450,19 +2533,7 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } else if(ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) { - Object *obedit= CTX_data_edit_object(C); - if(obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); - else { - Object *ob= CTX_data_active_object(C); - - /* Don't allow edit mode if the object is hide! - * check the bug #22153 and #21609 - */ - if (ob && (!(ob->restrictflag & OB_RESTRICT_VIEW))) - ED_object_enter_editmode(C, EM_WAITCURSOR); - // XXX extern_set_butspace(F9KEY, 0); - } + WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL); } else { // rest of types tree_element_active(C, scene, soops, te, 1); } @@ -2489,9 +2560,12 @@ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) TreeElement *te; float fmval[2]; int extend= RNA_boolean_get(op->ptr, "extend"); - + UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, fmval, fmval+1); - + + if(!ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && !(soops->flag & SO_HIDE_RESTRICTCOLS) && fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX) + return OPERATOR_CANCELLED; + for(te= soops->tree.first; te; te= te->next) { if(do_outliner_item_activate(C, scene, ar, soops, te, extend, fmval)) break; } @@ -2524,6 +2598,7 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot) { ot->name= "Activate Item"; ot->idname= "OUTLINER_OT_item_activate"; + ot->description= "Handle mouse clicks to activate/select items"; ot->invoke= outliner_item_activate; @@ -2586,6 +2661,7 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot) { ot->name= "Open/Close Item"; ot->idname= "OUTLINER_OT_item_openclose"; + ot->description= "Toggle whether item under cursor is enabled or closed"; ot->invoke= outliner_item_openclose; @@ -2616,9 +2692,11 @@ static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, T error("Cannot edit sequence name"); else if(tselem->id->lib) { // XXX error_libdata(); - } else if(te->idcode == ID_LI && te->parent) { + } + else if(te->idcode == ID_LI && te->parent) { error("Cannot edit the path of an indirectly linked library"); - } else { + } + else { tselem->flag |= TSE_TEXTBUT; ED_region_tag_redraw(ar); } @@ -2632,7 +2710,7 @@ static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, T return 0; } -static int outliner_item_rename(bContext *C, wmOperator *op, wmEvent *event) +static int outliner_item_rename(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { ARegion *ar= CTX_wm_region(C); SpaceOops *soops= CTX_wm_space_outliner(C); @@ -2653,45 +2731,13 @@ void OUTLINER_OT_item_rename(wmOperatorType *ot) { ot->name= "Rename Item"; ot->idname= "OUTLINER_OT_item_rename"; + ot->description= "Rename item under cursor"; ot->invoke= outliner_item_rename; ot->poll= ED_operator_outliner_active; } - - -/* recursive helper for function below */ -static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te, int startx, int *starty) -{ - TreeStoreElem *tselem= TREESTORE(te); - - /* store coord and continue, we need coordinates for elements outside view too */ - te->xs= (float)startx; - te->ys= (float)(*starty); - *starty-= OL_H; - - if((tselem->flag & TSE_CLOSED)==0) { - TreeElement *ten; - for(ten= te->subtree.first; ten; ten= ten->next) { - outliner_set_coordinates_element(soops, ten, startx+OL_X, starty); - } - } - -} - -/* to retrieve coordinates with redrawing the entire tree */ -static void outliner_set_coordinates(ARegion *ar, SpaceOops *soops) -{ - TreeElement *te; - int starty= (int)(ar->v2d.tot.ymax)-OL_H; - int startx= 0; - - for(te= soops->tree.first; te; te= te->next) { - outliner_set_coordinates_element(soops, te, startx, &starty); - } -} - static TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id) { TreeElement *te, *tes; @@ -2702,7 +2748,7 @@ static TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id) if(tselem->type==0) { if(tselem->id==id) return te; /* only deeper on scene or object */ - if( te->idcode==ID_OB || te->idcode==ID_SCE) { + if( te->idcode==ID_OB || te->idcode==ID_SCE || (soops->outlinevis == SO_GROUPS && te->idcode==ID_GR)) { tes= outliner_find_id(soops, &te->subtree, id); if(tes) return tes; } @@ -2711,7 +2757,7 @@ static TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id) return NULL; } -static int outliner_show_active_exec(bContext *C, wmOperator *op) +static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *so= CTX_wm_space_outliner(C); Scene *scene= CTX_data_scene(C); @@ -2757,8 +2803,66 @@ void OUTLINER_OT_show_active(wmOperatorType *ot) /* callbacks */ ot->exec= outliner_show_active_exec; ot->poll= ED_operator_outliner_active; +} + +/* tse is not in the treestore, we use its contents to find a match */ +static TreeElement *outliner_find_tse(SpaceOops *soops, TreeStoreElem *tse) +{ + TreeStore *ts= soops->treestore; + TreeStoreElem *tselem; + int a; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + if(tse->id==NULL) return NULL; + + /* check if 'tse' is in treestore */ + tselem= ts->data; + for(a=0; a<ts->usedelem; a++, tselem++) { + if((tse->type==0 && tselem->type==0) || (tselem->type==tse->type && tselem->nr==tse->nr)) { + if(tselem->id==tse->id) { + break; + } + } + } + if(tselem) + return outliner_find_tree_element(&soops->tree, a); + + return NULL; +} + + +/* Called to find an item based on name. + */ +#if 0 + +/* recursive helper for function below */ +static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te, int startx, int *starty) +{ + TreeStoreElem *tselem= TREESTORE(te); + + /* store coord and continue, we need coordinates for elements outside view too */ + te->xs= (float)startx; + te->ys= (float)(*starty); + *starty-= OL_H; + + if((tselem->flag & TSE_CLOSED)==0) { + TreeElement *ten; + for(ten= te->subtree.first; ten; ten= ten->next) { + outliner_set_coordinates_element(soops, ten, startx+OL_X, starty); + } + } + +} + +/* to retrieve coordinates with redrawing the entire tree */ +static void outliner_set_coordinates(ARegion *ar, SpaceOops *soops) +{ + TreeElement *te; + int starty= (int)(ar->v2d.tot.ymax)-OL_H; + int startx= 0; + + for(te= soops->tree.first; te; te= te->next) { + outliner_set_coordinates_element(soops, te, startx, &starty); + } } /* find next element that has this name */ @@ -2790,34 +2894,7 @@ static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *na return NULL; } -/* tse is not in the treestore, we use its contents to find a match */ -static TreeElement *outliner_find_tse(SpaceOops *soops, TreeStoreElem *tse) -{ - TreeStore *ts= soops->treestore; - TreeStoreElem *tselem; - int a; - - if(tse->id==NULL) return NULL; - - /* check if 'tse' is in treestore */ - tselem= ts->data; - for(a=0; a<ts->usedelem; a++, tselem++) { - if((tse->type==0 && tselem->type==0) || (tselem->type==tse->type && tselem->nr==tse->nr)) { - if(tselem->id==tse->id) { - break; - } - } - } - if(tselem) - return outliner_find_tree_element(&soops->tree, a); - - return NULL; -} - - -/* Called to find an item based on name. - */ -void outliner_find_panel(Scene *scene, ARegion *ar, SpaceOops *soops, int again, int flags) +static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int again, int flags) { TreeElement *te= NULL; TreeElement *last_find; @@ -2889,6 +2966,7 @@ void outliner_find_panel(Scene *scene, ARegion *ar, SpaceOops *soops, int again, error("Not found: %s", name); } } +#endif /* helper function for tree_element_shwo_hierarchy() - recursively checks whether subtrees have any objects*/ static int subtree_has_objects(SpaceOops *soops, ListBase *lb) @@ -2931,7 +3009,7 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase } /* show entire object level hierarchy */ -static int outliner_show_hierarchy_exec(bContext *C, wmOperator *op) +static int outliner_show_hierarchy_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *soops= CTX_wm_space_outliner(C); ARegion *ar= CTX_wm_region(C); @@ -3049,7 +3127,7 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb, } } -static void unlink_material_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) +static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem)) { Material **matar=NULL; int a, totcol=0; @@ -3083,7 +3161,7 @@ static void unlink_material_cb(bContext *C, Scene *scene, TreeElement *te, TreeS } } -static void unlink_texture_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) +static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem)) { MTex **mtex= NULL; int a; @@ -3112,7 +3190,7 @@ static void unlink_texture_cb(bContext *C, Scene *scene, TreeElement *te, TreeSt } } -static void unlink_group_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) +static void unlink_group_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *tselem) { Group *group= (Group *)tselem->id; @@ -3149,7 +3227,7 @@ static void outliner_do_libdata_operation(bContext *C, Scene *scene, SpaceOops * /* */ -static void object_select_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) +static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { Base *base= (Base *)te->directdata; @@ -3160,7 +3238,7 @@ static void object_select_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto } } -static void object_deselect_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) +static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { Base *base= (Base *)te->directdata; @@ -3171,7 +3249,7 @@ static void object_deselect_cb(bContext *C, Scene *scene, TreeElement *te, TreeS } } -static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) +static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { Base *base= (Base *)te->directdata; @@ -3189,7 +3267,7 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto } -static void id_local_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) +static void id_local_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { if(tselem->id->lib && (tselem->id->flag & LIB_EXTERN)) { tselem->id->lib= NULL; @@ -3198,7 +3276,7 @@ static void id_local_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreEle } } -static void group_linkobs2scene_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) +static void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { Group *group= (Group *)tselem->id; GroupObject *gob; @@ -3251,7 +3329,7 @@ static void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOop /* ******************************************** */ -static void pchan_cb(int event, TreeElement *te, TreeStoreElem *tselem) +static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) { bPoseChannel *pchan= (bPoseChannel *)te->directdata; @@ -3267,7 +3345,7 @@ static void pchan_cb(int event, TreeElement *te, TreeStoreElem *tselem) pchan->bone->flag &= ~BONE_HIDDEN_P; } -static void bone_cb(int event, TreeElement *te, TreeStoreElem *tselem) +static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) { Bone *bone= (Bone *)te->directdata; @@ -3283,7 +3361,7 @@ static void bone_cb(int event, TreeElement *te, TreeStoreElem *tselem) bone->flag &= ~BONE_HIDDEN_P; } -static void ebone_cb(int event, TreeElement *te, TreeStoreElem *tselem) +static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) { EditBone *ebone= (EditBone *)te->directdata; @@ -3299,7 +3377,7 @@ static void ebone_cb(int event, TreeElement *te, TreeStoreElem *tselem) ebone->flag &= ~BONE_HIDDEN_A; } -static void sequence_cb(int event, TreeElement *te, TreeStoreElem *tselem) +static void sequence_cb(int event, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tselem)) { // Sequence *seq= (Sequence*) te->directdata; if(event==1) { @@ -3326,7 +3404,7 @@ static void outliner_do_data_operation(SpaceOops *soops, int type, int event, Li } } -void outliner_del(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops) +void outliner_del(bContext *C, Scene *scene, ARegion *UNUSED(ar), SpaceOops *soops) { if(soops->outlinevis==SO_SEQUENCE) @@ -3357,7 +3435,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); SpaceOops *soops= CTX_wm_space_outliner(C); int event; - char *str= NULL; + const char *str= NULL; /* check for invalid states */ if (soops == NULL) @@ -3403,6 +3481,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) else if(event==8) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb); str= "Toggle Renderability"; + WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, scene); } ED_undo_push(C, str); @@ -3685,7 +3764,7 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S } -static int outliner_operation(bContext *C, wmOperator *op, wmEvent *event) +static int outliner_operation(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { Scene *scene= CTX_data_scene(C); ARegion *ar= CTX_wm_region(C); @@ -3707,6 +3786,7 @@ void OUTLINER_OT_operation(wmOperatorType *ot) { ot->name= "Execute Operation"; ot->idname= "OUTLINER_OT_operation"; + ot->description= "Context menu for item operations"; ot->invoke= outliner_operation; @@ -3735,7 +3815,7 @@ static int ed_operator_outliner_datablocks_active(bContext *C) * this function does not do that yet */ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, - ID **id, char **path, int *array_index, short *flag, short *groupmode) + ID **id, char **path, int *array_index, short *flag, short *UNUSED(groupmode)) { ListBase hierarchy = {NULL, NULL}; LinkData *ld; @@ -3878,7 +3958,7 @@ enum { /* Utilities ---------------------------------- */ /* Recursively iterate over tree, finding and working on selected items */ -static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, short mode) +static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportList *reports, short mode) { TreeElement *te; TreeStoreElem *tselem; @@ -3903,6 +3983,7 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, short m /* only if ID and path were set, should we perform any actions */ if (id && path) { + short dflags = CREATEDRIVER_WITH_DEFAULT_DVAR; int arraylen = 1; /* array checks */ @@ -3924,13 +4005,13 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, short m case DRIVERS_EDITMODE_ADD: { /* add a new driver with the information obtained (only if valid) */ - ANIM_add_driver(id, path, array_index, flag, DRIVER_TYPE_PYTHON); + ANIM_add_driver(reports, id, path, array_index, dflags, DRIVER_TYPE_PYTHON); } break; case DRIVERS_EDITMODE_REMOVE: { /* remove driver matching the information obtained (only if valid) */ - ANIM_remove_driver(id, path, array_index, flag); + ANIM_remove_driver(reports, id, path, array_index, dflags); } break; } @@ -3945,7 +4026,7 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, short m /* go over sub-tree */ if ((tselem->flag & TSE_CLOSED)==0) - do_outliner_drivers_editop(soops, &te->subtree, mode); + do_outliner_drivers_editop(soops, &te->subtree, reports, mode); } } @@ -3960,10 +4041,10 @@ static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* recursively go into tree, adding selected items */ - do_outliner_drivers_editop(soutliner, &soutliner->tree, DRIVERS_EDITMODE_ADD); + do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_ADD); /* send notifiers */ - WM_event_add_notifier(C, ND_KEYS, NULL); // XXX + WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX return OPERATOR_FINISHED; } @@ -3980,7 +4061,7 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot) ot->poll= ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -3995,7 +4076,7 @@ static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* recursively go into tree, adding selected items */ - do_outliner_drivers_editop(soutliner, &soutliner->tree, DRIVERS_EDITMODE_REMOVE); + do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_REMOVE); /* send notifiers */ WM_event_add_notifier(C, ND_KEYS, NULL); // XXX @@ -4015,7 +4096,7 @@ void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot) ot->poll= ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } /* ***************** KEYINGSET OPERATIONS *************** */ @@ -4097,12 +4178,9 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa if (ksp) { /* free path's data */ - // TODO: we probably need an API method for this - if (ksp->rna_path) MEM_freeN(ksp->rna_path); + BKE_keyingset_free_path(ks, ksp); + ks->active_path= 0; - - /* remove path from set */ - BLI_freelinkN(&ks->paths, ksp); } } break; @@ -4148,20 +4226,21 @@ void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot) { /* identifiers */ ot->idname= "OUTLINER_OT_keyingset_add_selected"; - ot->name= "Keyingset Add Selected"; + ot->name= "Keying Set Add Selected"; + ot->description= "Add selected items (blue-grey rows) to active Keying Set"; /* api callbacks */ ot->exec= outliner_keyingset_additems_exec; ot->poll= ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } /* Remove Operator ---------------------------------- */ -static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *op) +static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *soutliner= CTX_wm_space_outliner(C); Scene *scene= CTX_data_scene(C); @@ -4184,14 +4263,15 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) { /* identifiers */ ot->idname= "OUTLINER_OT_keyingset_remove_selected"; - ot->name= "Keyingset Remove Selected"; + ot->name= "Keying Set Remove Selected"; + ot->description = "Remove selected items (blue-grey rows) from active Keying Set"; /* api callbacks */ ot->exec= outliner_keyingset_removeitems_exec; ot->poll= ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } /* ***************** DRAW *************** */ @@ -4482,7 +4562,6 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa if(level<1 || (tselem->type==0 && te->idcode==ID_OB)) { /* active blocks get white circle */ - active= 0; if(tselem->type==0) { if(te->idcode==ID_OB) active= (OBACT==(Object *)tselem->id); else if(scene->obedit && scene->obedit->data==tselem->id) active= 1; // XXX use context? @@ -4513,6 +4592,21 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa } +/* closed tree element */ +static void outliner_set_coord_tree_element(SpaceOops *soops, TreeElement *te, int startx, int *starty) +{ + TreeElement *ten; + + /* store coord and continue, we need coordinates for elements outside view too */ + te->xs= (float)startx; + te->ys= (float)(*starty); + + for(ten= te->subtree.first; ten; ten= ten->next) { + outliner_set_coord_tree_element(soops, ten, startx+OL_X, starty); + } +} + + static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int startx, int *starty) { TreeElement *ten; @@ -4667,13 +4761,18 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene te->ys= (float)*starty; te->xend= startx+offsx; - *starty-= OL_H; - if((tselem->flag & TSE_CLOSED)==0) { - for(ten= te->subtree.first; ten; ten= ten->next) { + *starty-= OL_H; + + for(ten= te->subtree.first; ten; ten= ten->next) outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx+OL_X, starty); - } } + else { + for(ten= te->subtree.first; ten; ten= ten->next) + outliner_set_coord_tree_element(soops, te, startx, starty); + + *starty-= OL_H; + } } static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx, int *starty) @@ -4787,7 +4886,7 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio } -static void outliner_back(ARegion *ar, SpaceOops *soops) +static void outliner_back(ARegion *ar) { int ystart; @@ -4801,7 +4900,7 @@ static void outliner_back(ARegion *ar, SpaceOops *soops) } } -static void outliner_draw_restrictcols(ARegion *ar, SpaceOops *soops) +static void outliner_draw_restrictcols(ARegion *ar) { int ystart; @@ -4843,16 +4942,8 @@ static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2) { Scene *scene = (Scene *)poin; Object *ob = (Object *)poin2; - Object *obedit= CTX_data_edit_object(C); - /* Don't allow hide an objet in edit mode, - * check the bug #22153 and #21609 - */ - if (obedit && obedit == ob) { - if (ob->restrictflag & OB_RESTRICT_VIEW) - ob->restrictflag &= ~OB_RESTRICT_VIEW; - return; - } + if(!common_restrict_check(C, ob)) return; /* deselect objects that are invisible */ if (ob->restrictflag & OB_RESTRICT_VIEW) { @@ -4869,6 +4960,8 @@ static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2) Scene *scene = (Scene *)poin; Object *ob = (Object *)poin2; + if(!common_restrict_check(C, ob)) return; + /* if select restriction has just been turned on */ if (ob->restrictflag & OB_RESTRICT_SELECT) { /* Ouch! There is no backwards pointer from Object to Base, @@ -4879,26 +4972,26 @@ static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2) } -static void restrictbutton_rend_cb(bContext *C, void *poin, void *poin2) +static void restrictbutton_rend_cb(bContext *C, void *poin, void *UNUSED(poin2)) { - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, poin); + WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, poin); } -static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *poin2) +static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *UNUSED(poin2)) { WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, poin); } -static void restrictbutton_modifier_cb(bContext *C, void *poin, void *poin2) +static void restrictbutton_modifier_cb(bContext *C, void *UNUSED(poin), void *poin2) { Object *ob = (Object *)poin2; - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); } -static void restrictbutton_bone_cb(bContext *C, void *poin, void *poin2) +static void restrictbutton_bone_cb(bContext *C, void *UNUSED(poin), void *poin2) { Bone *bone= (Bone *)poin2; if(bone && (bone->flag & BONE_HIDDEN_P)) @@ -4906,7 +4999,7 @@ static void restrictbutton_bone_cb(bContext *C, void *poin, void *poin2) WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); } -static void restrictbutton_ebone_cb(bContext *C, void *poin, void *poin2) +static void restrictbutton_ebone_cb(bContext *C, void *UNUSED(poin), void *poin2) { EditBone *ebone= (EditBone *)poin2; if(ebone && (ebone->flag & BONE_HIDDEN_A)) @@ -4938,7 +5031,7 @@ static int group_select_flag(Group *gr) return 0; } -static void restrictbutton_gr_restrict_flag(bContext *C, void *poin, void *poin2, int flag) +static void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) { Scene *scene = (Scene *)poin; GroupObject *gob; @@ -4955,28 +5048,31 @@ static void restrictbutton_gr_restrict_flag(bContext *C, void *poin, void *poin2 } else { for(gob= gr->gobject.first; gob; gob= gob->next) { - gob->ob->restrictflag |= flag; + /* not in editmode */ + if(scene->obedit!=gob->ob) { + gob->ob->restrictflag |= flag; - if(flag==OB_RESTRICT_VIEW) - if((gob->ob->flag & SELECT) == 0) - ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT); + if(flag==OB_RESTRICT_VIEW) + if((gob->ob->flag & SELECT) == 0) + ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT); + } } } } static void restrictbutton_gr_restrict_view(bContext *C, void *poin, void *poin2) { - restrictbutton_gr_restrict_flag(C, poin, poin2, OB_RESTRICT_VIEW); + restrictbutton_gr_restrict_flag(poin, poin2, OB_RESTRICT_VIEW); WM_event_add_notifier(C, NC_GROUP, NULL); } static void restrictbutton_gr_restrict_select(bContext *C, void *poin, void *poin2) { - restrictbutton_gr_restrict_flag(C, poin, poin2, OB_RESTRICT_SELECT); + restrictbutton_gr_restrict_flag(poin, poin2, OB_RESTRICT_SELECT); WM_event_add_notifier(C, NC_GROUP, NULL); } static void restrictbutton_gr_restrict_render(bContext *C, void *poin, void *poin2) { - restrictbutton_gr_restrict_flag(C, poin, poin2, OB_RESTRICT_RENDER); + restrictbutton_gr_restrict_flag(poin, poin2, OB_RESTRICT_RENDER); WM_event_add_notifier(C, NC_GROUP, NULL); } @@ -5011,7 +5107,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) if (te->idcode == ID_LI) { char expanded[FILE_MAXDIR + FILE_MAXFILE]; BLI_strncpy(expanded, ((Library *)tselem->id)->name, FILE_MAXDIR + FILE_MAXFILE); - BLI_path_abs(expanded, G.sce); + BLI_path_abs(expanded, G.main->name); if (!BLI_exists(expanded)) { error("This path does not exist, correct this before saving"); } @@ -5030,11 +5126,11 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) bArmature *arm= (bArmature *)tselem->id; if(arm->edbo) { EditBone *ebone= te->directdata; - char newname[32]; + char newname[sizeof(ebone->name)]; /* restore bone name */ - BLI_strncpy(newname, ebone->name, 32); - BLI_strncpy(ebone->name, oldname, 32); + BLI_strncpy(newname, ebone->name, sizeof(ebone->name)); + BLI_strncpy(ebone->name, oldname, sizeof(ebone->name)); ED_armature_bone_rename(obedit->data, oldname, newname); WM_event_add_notifier(C, NC_OBJECT|ND_POSE, OBACT); } @@ -5045,15 +5141,15 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) { Bone *bone= te->directdata; Object *ob; - char newname[32]; + char newname[sizeof(bone->name)]; // always make current object active tree_element_set_active_object(C, scene, soops, te, 1); ob= OBACT; /* restore bone name */ - BLI_strncpy(newname, bone->name, 32); - BLI_strncpy(bone->name, oldname, 32); + BLI_strncpy(newname, bone->name, sizeof(bone->name)); + BLI_strncpy(bone->name, oldname, sizeof(bone->name)); ED_armature_bone_rename(ob->data, oldname, newname); WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); } @@ -5062,15 +5158,15 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) { bPoseChannel *pchan= te->directdata; Object *ob; - char newname[32]; + char newname[sizeof(pchan->name)]; // always make current object active tree_element_set_active_object(C, scene, soops, te, 1); ob= OBACT; /* restore bone name */ - BLI_strncpy(newname, pchan->name, 32); - BLI_strncpy(pchan->name, oldname, 32); + BLI_strncpy(newname, pchan->name, sizeof(pchan->name)); + BLI_strncpy(pchan->name, oldname, sizeof(pchan->name)); ED_armature_bone_rename(ob->data, oldname, newname); WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); } @@ -5112,17 +5208,17 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSSN); bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, 17, OL_H-1, &ptr, "hide", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_view_cb, scene, ob); bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, 17, OL_H-1, &ptr, "hide_select", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_sel_cb, scene, ob); bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (short)te->ys, 17, OL_H-1, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, 17, OL_H-1, &ptr, "hide_render", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_rend_cb, scene, ob); @@ -5136,15 +5232,15 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSSN); restrict_bool= group_restrict_flag(gr, OB_RESTRICT_VIEW); - bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, 0, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, 17, OL_H-1, 0, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_view, scene, gr); restrict_bool= group_restrict_flag(gr, OB_RESTRICT_SELECT); - bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, 0, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, 17, OL_H-1, 0, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_select, scene, gr); restrict_bool= group_restrict_flag(gr, OB_RESTRICT_RENDER); - bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (short)te->ys, 17, OL_H-1, 0, 0, 0, 0, 0, "Restrict/Allow renderability"); + bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, 17, OL_H-1, 0, 0, 0, 0, 0, "Restrict/Allow renderability"); uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr); uiBlockSetEmboss(block, UI_EMBOSS); @@ -5154,7 +5250,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSSN); bt= uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, 0, ICON_CHECKBOX_HLT-1, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, te->directdata, 0, 0, 0, 0, "Render this RenderLayer"); + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, 17, OL_H-1, te->directdata, 0, 0, 0, 0, "Render this RenderLayer"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); uiBlockSetEmboss(block, UI_EMBOSS); @@ -5167,13 +5263,13 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar bt= uiDefIconButBitI(block, ICONTOG, passflag, 0, ICON_CHECKBOX_HLT-1, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, layflag, 0, 0, 0, 0, "Render this Pass"); + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, 17, OL_H-1, layflag, 0, 0, 0, 0, "Render this Pass"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); layflag++; /* is lay_xor */ if(ELEM8(passflag, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT, SCE_PASS_INDIRECT, SCE_PASS_EMIT, SCE_PASS_ENVIRONMENT)) bt= uiDefIconButBitI(block, TOG, passflag, 0, (*layflag & passflag)?ICON_DOT:ICON_BLANK1, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined"); + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, 17, OL_H-1, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); uiBlockSetEmboss(block, UI_EMBOSS); @@ -5184,11 +5280,11 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSSN); bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Realtime, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, 17, OL_H-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob); bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (short)te->ys, 17, OL_H-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability"); + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, 17, OL_H-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability"); uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob); } else if(tselem->type==TSE_POSE_CHANNEL) { @@ -5197,11 +5293,11 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSSN); bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, 17, OL_H-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_bone_cb, NULL, bone); bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, 17, OL_H-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL); } else if(tselem->type==TSE_EBONE) { @@ -5209,11 +5305,11 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSSN); bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, 17, OL_H-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, ebone); bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, 17, OL_H-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, NULL); } } @@ -5222,7 +5318,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar } } -static void outliner_draw_rnacols(ARegion *ar, SpaceOops *soops, int sizex) +static void outliner_draw_rnacols(ARegion *ar, int sizex) { View2D *v2d= &ar->v2d; @@ -5260,13 +5356,13 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa prop= te->directdata; if(!(RNA_property_type(prop) == PROP_POINTER && (tselem->flag & TSE_CLOSED)==0)) - uiDefAutoButR(block, ptr, prop, -1, "", 0, sizex, (int)te->ys, OL_RNA_COL_SIZEX, OL_H-1); + uiDefAutoButR(block, ptr, prop, -1, "", ICON_NULL, sizex, (int)te->ys, OL_RNA_COL_SIZEX, OL_H-1); } else if(tselem->type == TSE_RNA_ARRAY_ELEM) { ptr= &te->rnaptr; prop= te->directdata; - uiDefAutoButR(block, ptr, prop, te->index, "", 0, sizex, (int)te->ys, OL_RNA_COL_SIZEX, OL_H-1); + uiDefAutoButR(block, ptr, prop, te->index, "", ICON_NULL, sizex, (int)te->ys, OL_RNA_COL_SIZEX, OL_H-1); } } @@ -5274,7 +5370,7 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa } } -static void operator_call_cb(struct bContext *C, void *arg_kmi, void *arg2) +static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *arg2) { wmOperatorType *ot= arg2; wmKeyMapItem *kmi= arg_kmi; @@ -5283,7 +5379,7 @@ static void operator_call_cb(struct bContext *C, void *arg_kmi, void *arg2) BLI_strncpy(kmi->idname, ot->idname, OP_MAX_TYPENAME); } -static void operator_search_cb(const struct bContext *C, void *arg_kmi, char *str, uiSearchItems *items) +static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(arg_kmi), const char *str, uiSearchItems *items) { wmOperatorType *ot = WM_operatortype_first(); @@ -5352,89 +5448,79 @@ static short keymap_menu_type(short type) return 0; } -static char *keymap_type_menu(void) +static const char *keymap_type_menu(void) { - static char string[500]; - static char formatstr[] = "|%s %%x%d"; - char *str= string; - - str += sprintf(str, "Event Type %%t"); - - str += sprintf(str, formatstr, "Keyboard", OL_KM_KEYBOARD); - str += sprintf(str, formatstr, "Mouse", OL_KM_MOUSE); - str += sprintf(str, formatstr, "Tweak", OL_KM_TWEAK); -// str += sprintf(str, formatstr, "Specials", OL_KM_SPECIALS); - + static const char string[]= + "Event Type%t" + "|Keyboard%x" STRINGIFY(OL_KM_KEYBOARD) + "|Mouse%x" STRINGIFY(OL_KM_MOUSE) + "|Tweak%x" STRINGIFY(OL_KM_TWEAK) +// "|Specials%x" STRINGIFY(OL_KM_SPECIALS) + ; + return string; -} - -static char *keymap_mouse_menu(void) -{ - static char string[500]; - static char formatstr[] = "|%s %%x%d"; - char *str= string; - - str += sprintf(str, "Mouse Event %%t"); - - str += sprintf(str, formatstr, "Left Mouse", LEFTMOUSE); - str += sprintf(str, formatstr, "Middle Mouse", MIDDLEMOUSE); - str += sprintf(str, formatstr, "Right Mouse", RIGHTMOUSE); - str += sprintf(str, formatstr, "Button4 Mouse ", BUTTON4MOUSE); - str += sprintf(str, formatstr, "Button5 Mouse ", BUTTON5MOUSE); - str += sprintf(str, formatstr, "Action Mouse", ACTIONMOUSE); - str += sprintf(str, formatstr, "Select Mouse", SELECTMOUSE); - str += sprintf(str, formatstr, "Mouse Move", MOUSEMOVE); - str += sprintf(str, formatstr, "Wheel Up", WHEELUPMOUSE); - str += sprintf(str, formatstr, "Wheel Down", WHEELDOWNMOUSE); - str += sprintf(str, formatstr, "Wheel In", WHEELINMOUSE); - str += sprintf(str, formatstr, "Wheel Out", WHEELOUTMOUSE); - str += sprintf(str, formatstr, "Mouse/Trackpad Pan", MOUSEPAN); - str += sprintf(str, formatstr, "Mouse/Trackpad Zoom", MOUSEZOOM); - str += sprintf(str, formatstr, "Mouse/Trackpad Rotate", MOUSEROTATE); - +} + +static const char *keymap_mouse_menu(void) +{ + static const char string[]= + "Mouse Event%t" + "|Left Mouse%x" STRINGIFY(LEFTMOUSE) + "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) + "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) + "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) + "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) + "|Button4 Mouse%x" STRINGIFY(BUTTON4MOUSE) + "|Button5 Mouse%x" STRINGIFY(BUTTON5MOUSE) + "|Action Mouse%x" STRINGIFY(ACTIONMOUSE) + "|Select Mouse%x" STRINGIFY(SELECTMOUSE) + "|Mouse Move%x" STRINGIFY(MOUSEMOVE) + "|Wheel Up%x" STRINGIFY(WHEELUPMOUSE) + "|Wheel Down%x" STRINGIFY(WHEELDOWNMOUSE) + "|Wheel In%x" STRINGIFY(WHEELINMOUSE) + "|Wheel Out%x" STRINGIFY(WHEELOUTMOUSE) + "|Mouse/Trackpad Pan%x" STRINGIFY(MOUSEPAN) + "|Mouse/Trackpad Zoom%x" STRINGIFY(MOUSEZOOM) + "|Mouse/Trackpad Rotate%x" STRINGIFY(MOUSEROTATE) + ; + return string; } -static char *keymap_tweak_menu(void) +static const char *keymap_tweak_menu(void) { - static char string[500]; - static char formatstr[] = "|%s %%x%d"; - char *str= string; - - str += sprintf(str, "Tweak Event %%t"); - - str += sprintf(str, formatstr, "Left Mouse", EVT_TWEAK_L); - str += sprintf(str, formatstr, "Middle Mouse", EVT_TWEAK_M); - str += sprintf(str, formatstr, "Right Mouse", EVT_TWEAK_R); - str += sprintf(str, formatstr, "Action Mouse", EVT_TWEAK_A); - str += sprintf(str, formatstr, "Select Mouse", EVT_TWEAK_S); - + static const char string[]= + "Tweak Event%t" + "|Left Mouse%x" STRINGIFY(EVT_TWEAK_L) + "|Middle Mouse%x" STRINGIFY(EVT_TWEAK_M) + "|Right Mouse%x" STRINGIFY(EVT_TWEAK_R) + "|Action Mouse%x" STRINGIFY(EVT_TWEAK_A) + "|Select Mouse%x" STRINGIFY(EVT_TWEAK_S) + ; + return string; } -static char *keymap_tweak_dir_menu(void) +static const char *keymap_tweak_dir_menu(void) { - static char string[500]; - static char formatstr[] = "|%s %%x%d"; - char *str= string; - - str += sprintf(str, "Tweak Direction %%t"); - - str += sprintf(str, formatstr, "Any", KM_ANY); - str += sprintf(str, formatstr, "North", EVT_GESTURE_N); - str += sprintf(str, formatstr, "North-East", EVT_GESTURE_NE); - str += sprintf(str, formatstr, "East", EVT_GESTURE_E); - str += sprintf(str, formatstr, "Sout-East", EVT_GESTURE_SE); - str += sprintf(str, formatstr, "South", EVT_GESTURE_S); - str += sprintf(str, formatstr, "South-West", EVT_GESTURE_SW); - str += sprintf(str, formatstr, "West", EVT_GESTURE_W); - str += sprintf(str, formatstr, "North-West", EVT_GESTURE_NW); - + static const char string[]= + "Tweak Direction%t" + "|Any%x" STRINGIFY(KM_ANY) + "|North%x" STRINGIFY(EVT_GESTURE_N) + "|North-East%x" STRINGIFY(EVT_GESTURE_NE) + "|East%x" STRINGIFY(EVT_GESTURE_E) + "|Sout-East%x" STRINGIFY(EVT_GESTURE_SE) + "|South%x" STRINGIFY(EVT_GESTURE_S) + "|South-West%x" STRINGIFY(EVT_GESTURE_SW) + "|West%x" STRINGIFY(EVT_GESTURE_W) + "|North-West%x" STRINGIFY(EVT_GESTURE_NW) + ; + return string; } -static void keymap_type_cb(bContext *C, void *kmi_v, void *unused_v) +static void keymap_type_cb(bContext *C, void *kmi_v, void *UNUSED(arg_v)) { wmKeyMapItem *kmi= kmi_v; short maptype= keymap_menu_type(kmi->type); @@ -5472,7 +5558,7 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo tselem= TREESTORE(te); if(te->ys+2*OL_H >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { uiBut *but; - char *str; + const char *str; int xstart= 240; int butw1= 20; /* operator */ int butw2= 90; /* event type, menus */ @@ -5521,7 +5607,7 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo uiDefButS(block, OPTION, 0, "Shift", xstart, (int)te->ys+1, butw3+5, OL_H-1, &kmi->shift, 0, 0, 0, 0, "Modifier"); xstart+= butw3+5; uiDefButS(block, OPTION, 0, "Ctrl", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->ctrl, 0, 0, 0, 0, "Modifier"); xstart+= butw3; uiDefButS(block, OPTION, 0, "Alt", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->alt, 0, 0, 0, 0, "Modifier"); xstart+= butw3; - uiDefButS(block, OPTION, 0, "Cmd", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->oskey, 0, 0, 0, 0, "Modifier"); xstart+= butw3; + uiDefButS(block, OPTION, 0, "OS", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->oskey, 0, 0, 0, 0, "Modifier"); xstart+= butw3; xstart+= 5; uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->keymodifier, "Key Modifier code"); xstart+= butw3+5; @@ -5568,7 +5654,7 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Spa spx=te->xs+2*OL_X-4; if(spx+dx+10>ar->v2d.cur.xmax) dx = ar->v2d.cur.xmax-spx-10; - bt= uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, (short)te->ys, dx+10, OL_H-1, te->name, 1.0, (float)len-1, 0, 0, ""); + bt= uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, (int)te->ys, dx+10, OL_H-1, (void *)te->name, 1.0, (float)len, 0, 0, ""); uiButSetRenameFunc(bt, namebutton_cb, tselem); /* returns false if button got removed */ @@ -5635,17 +5721,19 @@ void draw_outliner(const bContext *C) /* update size of tot-rect (extents of data/viewable area) */ UI_view2d_totRect_set(v2d, sizex, sizey); + /* force display to pixel coords */ + v2d->flag |= (V2D_PIXELOFS_X|V2D_PIXELOFS_Y); /* set matrix for 2d-view controls */ - UI_view2d_view_ortho(C, v2d); + UI_view2d_view_ortho(v2d); /* draw outliner stuff (background, hierachy lines and names) */ - outliner_back(ar, soops); + outliner_back(ar); block= uiBeginBlock(C, ar, "outliner buttons", UI_EMBOSS); outliner_draw_tree((bContext *)C, block, scene, ar, soops); if(ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { /* draw rna buttons */ - outliner_draw_rnacols(ar, soops, sizex_rna); + outliner_draw_rnacols(ar, sizex_rna); outliner_draw_rnabuts(block, scene, ar, soops, sizex_rna, &soops->tree); } else if(soops->outlinevis == SO_KEYMAP) { @@ -5653,7 +5741,7 @@ void draw_outliner(const bContext *C) } else if (!(soops->flag & SO_HIDE_RESTRICTCOLS)) { /* draw restriction columns */ - outliner_draw_restrictcols(ar, soops); + outliner_draw_restrictcols(ar); outliner_draw_restrictbuts(block, scene, ar, soops, &soops->tree); } |