[Bf-blender-cvs] [fc7c19c9ab7] soc-2020-outliner: Outliner: Add buttons to set active camera
Nathan Craddock
noreply at git.blender.org
Sat Jun 6 00:47:03 CEST 2020
Commit: fc7c19c9ab7fdbecf656bda41846f8c98f37868d
Author: Nathan Craddock
Date: Fri Jun 5 16:44:39 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rBfc7c19c9ab7fdbecf656bda41846f8c98f37868d
Outliner: Add buttons to set active camera
Add buttons to the left column to set the active camera. The active
camera currently shows a check, and other cameras draw a dot.
For some reason the dot doesn't have a proper hitbox area.
Right now the function to set the camera is done from button callbacks,
but this could also easily be done from outliner_select.c.
===================================================================
M source/blender/editors/space_outliner/outliner_draw.c
M source/blender/editors/space_outliner/outliner_intern.h
M source/blender/editors/space_outliner/outliner_select.c
===================================================================
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index e6c1ebd98c4..a1006c667bd 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1902,6 +1902,75 @@ static void outliner_buttons(const bContext *C,
}
}
+static void outliner_set_active_data_fn(struct bContext *C, void *te_poin, void *UNUSED(arg2))
+{
+ Scene *scene = CTX_data_scene(C);
+ TreeElement *te = (TreeElement *)te_poin;
+
+ outliner_set_active_camera(C, scene, te);
+}
+
+static void outliner_draw_left_column(uiBlock *block,
+ TreeViewContext *tvc,
+ SpaceOutliner *soops,
+ ListBase *tree)
+{
+ TreeStoreElem *tselem;
+ uiBut *but;
+
+ LISTBASE_FOREACH (TreeElement *, te, tree) {
+ tselem = TREESTORE(te);
+
+ if (tselem->type == 0 && te->idcode == ID_OB) {
+ Object *ob = (Object *)tselem->id;
+
+ if (ob->type == OB_CAMERA) {
+ if (tvc->scene->camera == ob) {
+ /* Draw check for active camera */
+ but = uiDefIconBut(block,
+ UI_BTYPE_ICON_TOGGLE,
+ 0,
+ ICON_CHECKMARK,
+ 0,
+ te->ys,
+ UI_UNIT_X,
+ UI_UNIT_Y,
+ NULL,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ TIP_(""));
+ UI_but_flag_enable(but, UI_BUT_DRAG_LOCK);
+ }
+ else {
+ /* Draw empty icon to set active camera */
+ but = uiDefIconBut(block,
+ UI_BTYPE_ICON_TOGGLE,
+ 0,
+ ICON_DOT,
+ 0,
+ te->ys,
+ UI_UNIT_X,
+ UI_UNIT_Y,
+ NULL,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ TIP_("Set active camera"));
+ UI_but_flag_enable(but, UI_BUT_DRAG_LOCK);
+ UI_but_func_set(but, outliner_set_active_data_fn, te, NULL);
+ }
+ }
+ }
+
+ if (TSELEM_OPEN(tselem, soops)) {
+ outliner_draw_left_column(block, tvc, soops, &te->subtree);
+ }
+ }
+}
+
/* ****************************************************** */
/* Normal Drawing... */
@@ -3729,6 +3798,11 @@ void draw_outliner(const bContext *C)
block, tvc.scene, tvc.view_layer, region, soops, &soops->tree, props_active);
}
+ /* Draw mode toggle and activation icons */
+ if (use_left_column) {
+ outliner_draw_left_column(block, &tvc, soops, &soops->tree);
+ }
+
UI_block_emboss_set(block, UI_EMBOSS);
/* Draw edit buttons if necessary. */
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index f2b64bc2a4b..612d9cfcbfe 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -284,6 +284,9 @@ void outliner_element_activate(struct SpaceOutliner *soops, struct TreeStoreElem
bool outliner_item_is_co_over_name_icons(const TreeElement *te, float view_co_x);
bool outliner_item_is_co_within_close_toggle(const TreeElement *te, float view_co_x);
+/* TODO: Temporary while testing */
+void outliner_set_active_camera(struct bContext *C, Scene *scene, TreeElement *te);
+
/* outliner_edit.c ---------------------------------------------- */
typedef void (*outliner_operation_cb)(struct bContext *C,
struct ReportList *,
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index fa8422573ab..619195ddeff 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -494,6 +494,22 @@ static eOLDrawState tree_element_active_camera(bContext *C,
}
}
+/* TODO: Temporary while testing */
+void outliner_set_active_camera(bContext *C, Scene *scene, TreeElement *te)
+{
+ TreeStoreElem *tselem = TREESTORE(te);
+ Object *ob = (Object *)tselem->id;
+
+ scene->camera = ob;
+ Main *bmain = CTX_data_main(C);
+ wmWindowManager *wm = bmain->wm.first;
+
+ WM_windows_scene_data_sync(&wm->windows, scene);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_relations_tag_update(bmain);
+ WM_event_add_notifier(C, NC_SCENE | NA_EDITED, NULL);
+}
+
static eOLDrawState tree_element_active_world(bContext *C,
Scene *scene,
ViewLayer *UNUSED(sl),
@@ -1372,6 +1388,9 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
if (outliner_is_co_within_restrict_columns(soops, region, view_mval[0])) {
return OPERATOR_CANCELLED;
}
+ if (soops->flag & SO_LEFT_COLUMN && mval[0] < UI_UNIT_X) {
+ return OPERATOR_CANCELLED;
+ }
if (!(te = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]))) {
if (deselect_all) {
More information about the Bf-blender-cvs
mailing list