Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c64
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h9
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c51
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c6
5 files changed, 110 insertions, 22 deletions
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index bc556966723..6548beefd2e 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -236,7 +236,7 @@ static int group_select_flag(Group *gr)
return 0;
}
-static void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag)
+void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag)
{
Scene *scene = (Scene *)poin;
GroupObject *gob;
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index fbd5281b1d9..2b451a48748 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -218,6 +218,34 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot)
/* Rename --------------------------------------------------- */
+void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, ReportList *reports)
+{
+ /* can't rename rna datablocks entries */
+ if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))
+ ;
+ else if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS))
+ BKE_report(reports, RPT_WARNING, "Cannot edit builtin name");
+ else if(ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP))
+ BKE_report(reports, RPT_WARNING, "Cannot edit sequence name");
+ else if(tselem->id->lib) {
+ // XXX error_libdata();
+ }
+ else if(te->idcode == ID_LI && te->parent) {
+ BKE_report(reports, RPT_WARNING, "Cannot edit the path of an indirectly linked library");
+ }
+ else {
+ tselem->flag |= TSE_TEXTBUT;
+ ED_region_tag_redraw(ar);
+ }
+}
+
+void item_rename_cb(bContext *C, Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+{
+ ARegion *ar= CTX_wm_region(C);
+ ReportList *reports= CTX_wm_reports(C); // XXX
+ do_item_rename(ar, te, tselem, reports) ;
+}
+
static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, TreeElement *te, const float mval[2])
{
ReportList *reports= CTX_wm_reports(C); // XXX
@@ -228,23 +256,7 @@ static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, T
/* name and first icon */
if(mval[0]>te->xs+UI_UNIT_X && mval[0]<te->xend) {
- /* can't rename rna datablocks entries */
- if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))
- ;
- else if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS))
- BKE_report(reports, RPT_WARNING, "Cannot edit builtin name");
- else if(ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP))
- BKE_report(reports, RPT_WARNING, "Cannot edit sequence name");
- else if(tselem->id->lib) {
- // XXX error_libdata();
- }
- else if(te->idcode == ID_LI && te->parent) {
- BKE_report(reports, RPT_WARNING, "Cannot edit the path of an indirectly linked library");
- }
- else {
- tselem->flag |= TSE_TEXTBUT;
- ED_region_tag_redraw(ar);
- }
+ do_item_rename(ar, te, tselem, reports) ;
}
return 1;
}
@@ -377,6 +389,12 @@ void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, Tre
}
}
+void group_toggle_visibility_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+{
+ Group *group= (Group *)tselem->id;
+ restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_VIEW);
+}
+
static int outliner_toggle_visibility_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceOops *soops= CTX_wm_space_outliner(C);
@@ -417,6 +435,12 @@ void object_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeEleme
}
}
+void group_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+{
+ Group *group= (Group *)tselem->id;
+ restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_SELECT);
+}
+
static int outliner_toggle_selectability_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceOops *soops= CTX_wm_space_outliner(C);
@@ -457,6 +481,12 @@ void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeEleme
}
}
+void group_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+{
+ Group *group= (Group *)tselem->id;
+ restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_RENDER);
+}
+
static int outliner_toggle_renderability_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceOops *soops= CTX_wm_space_outliner(C);
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 9da09144125..61507d1ffe5 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -129,6 +129,7 @@ typedef struct TreeElement {
/* outliner_tree.c ----------------------------------------------- */
void outliner_free_tree(ListBase *lb);
+void outliner_cleanup_tree(struct SpaceOops *soops);
TreeElement *outliner_find_tse(struct SpaceOops *soops, TreeStoreElem *tse);
TreeElement *outliner_find_id(struct SpaceOops *soops, ListBase *lb, struct ID *id);
@@ -139,6 +140,7 @@ void outliner_build_tree(struct Main *mainvar, struct Scene *scene, struct Space
/* outliner_draw.c ---------------------------------------------- */
void draw_outliner(const struct bContext *C);
+void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag);
/* outliner_select.c -------------------------------------------- */
int tree_element_type_active(struct bContext *C, struct Scene *scene, struct SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, int set);
@@ -158,6 +160,13 @@ void object_toggle_visibility_cb(struct bContext *C, struct Scene *scene, TreeEl
void object_toggle_selectability_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem);
void object_toggle_renderability_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem);
+
+void group_toggle_visibility_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem);
+void group_toggle_selectability_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem);
+void group_toggle_renderability_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem);
+
+void item_rename_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem);
+
/* ...................................................... */
void OUTLINER_OT_item_activate(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 3ae158bd275..b3170f9cd1e 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -287,6 +287,8 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto
if(base==NULL)
base= object_in_scene((Object *)tselem->id, scene);
if(base) {
+ SpaceOops *soops= CTX_wm_space_outliner(C);
+
// check also library later
if(scene->obedit==base->object)
ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO);
@@ -294,6 +296,13 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto
ED_base_object_free_and_unlink(CTX_data_main(C), scene, base);
te->directdata= NULL;
tselem->id= NULL;
+
+ /* XXX: tree management normally happens from draw_outliner(), but when
+ you're clicking to fast on Delete object from context menu in
+ outliner several mouse events can be handled in one cycle without
+ handling notifiers/redraw which leads to deleting the same object twice.
+ cleanup tree here to prevent such cases. */
+ outliner_cleanup_tree(soops);
}
}
@@ -510,6 +519,7 @@ static EnumPropertyItem prop_object_op_types[] = {
{6, "TOGVIS", 0, "Toggle Visible", ""},
{7, "TOGSEL", 0, "Toggle Selectable", ""},
{8, "TOGREN", 0, "Toggle Renderable", ""},
+ {9, "RENAME", 0, "Rename", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -567,6 +577,10 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
str= "Toggle Renderability";
WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, scene);
}
+ else if(event==9) {
+ outliner_do_object_operation(C, scene, soops, &soops->tree, item_rename_cb);
+ str= "Rename Object";
+ }
ED_undo_push(C, str);
@@ -600,6 +614,7 @@ static EnumPropertyItem prop_group_op_types[] = {
{4, "TOGVIS", 0, "Toggle Visible", ""},
{5, "TOGSEL", 0, "Toggle Selectable", ""},
{6, "TOGREN", 0, "Toggle Renderable", ""},
+ {7, "RENAME", 0, "Rename", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -608,6 +623,7 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
SpaceOops *soops= CTX_wm_space_outliner(C);
int event;
+ const char *str= NULL;
/* check for invalid states */
if (soops == NULL)
@@ -617,18 +633,35 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op)
if(event==1) {
outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb);
- ED_undo_push(C, "Unlink group");
+ str= "Unlink group";
}
else if(event==2) {
outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb);
- ED_undo_push(C, "Localized Data");
+ str= "Localized Data";
}
else if(event==3) {
outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb);
- ED_undo_push(C, "Link Group Objects to Scene");
+ str= "Link Group Objects to Scene";
+ }
+ else if(event==4) {
+ outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_visibility_cb);
+ str= "Toggle Visibility";
+ }
+ else if(event==5) {
+ outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_selectability_cb);
+ str= "Toggle Selectability";
+ }
+ else if(event==6) {
+ outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_renderability_cb);
+ str= "Toggle Renderability";
+ }
+ else if(event==7) {
+ outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb);
+ str= "Rename";
}
+ ED_undo_push(C, str);
WM_event_add_notifier(C, NC_GROUP, NULL);
return OPERATOR_FINISHED;
@@ -662,7 +695,8 @@ typedef enum eOutlinerIdOpTypes {
OUTLINER_IDOP_SINGLE,
OUTLINER_IDOP_FAKE_ADD,
- OUTLINER_IDOP_FAKE_CLEAR
+ OUTLINER_IDOP_FAKE_CLEAR,
+ OUTLINER_IDOP_RENAME
} eOutlinerIdOpTypes;
// TODO: implement support for changing the ID-block used
@@ -672,6 +706,7 @@ static EnumPropertyItem prop_id_op_types[] = {
{OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""},
{OUTLINER_IDOP_FAKE_ADD, "ADD_FAKE", 0, "Add Fake User", "Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"},
{OUTLINER_IDOP_FAKE_CLEAR, "CLEAR_FAKE", 0, "Clear Fake User", ""},
+ {OUTLINER_IDOP_RENAME, "RENAME", 0, "Rename", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -765,6 +800,14 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
ED_undo_push(C, "Clear Fake User");
}
break;
+ case OUTLINER_IDOP_RENAME:
+ /* rename */
+ outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb);
+
+ WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL);
+ ED_undo_push(C, "Rename");
+
+ break;
default:
// invalid - unhandled
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 0b07c824f3e..8904dcc360f 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -222,6 +222,12 @@ void outliner_free_tree(ListBase *lb)
}
}
+void outliner_cleanup_tree(SpaceOops *soops)
+{
+ outliner_free_tree(&soops->tree);
+ outliner_storage_cleanup(soops);
+}
+
/* Find ith item from the treestore */
static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index)
{