[Bf-blender-cvs] [109dbab593b] blender2.8: UI: fix "Edit Source" operator

Campbell Barton noreply at git.blender.org
Wed Jun 20 11:11:06 CEST 2018


Commit: 109dbab593b183b17e474d3f92468b06c86684f2
Author: Campbell Barton
Date:   Wed Jun 20 11:10:08 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB109dbab593b183b17e474d3f92468b06c86684f2

UI: fix "Edit Source" operator

===================================================================

M	source/blender/editors/interface/interface_ops.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/makesdna/DNA_object_enums.h

===================================================================

diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 6fcede58737..aad48d13277 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -1004,6 +1004,7 @@ static int editsource_exec(bContext *C, wmOperator *op)
 		ui_editsource_active_but_set(but);
 
 		/* redraw and get active button python info */
+		ED_region_do_layout(C, ar);
 		ED_region_do_draw(C, ar);
 		ar->do_draw = false;
 
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index e4f551b0004..b23ba83408c 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -264,6 +264,24 @@ static void restrictbutton_gp_layer_flag_cb(bContext *C, void *UNUSED(poin), voi
 	WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 }
 
+static void restrictbutton_object_mode_cb(bContext *C, void *poin, void *poin2)
+{
+	eObjectMode object_mode_toggle = (eObjectMode)(intptr_t)poin;
+	Object *ob = poin2;
+	/* WEAK, restore original value! Switch is an operator. */
+	ob->mode = object_mode_toggle;
+
+	printf("HELLO %s\n", ob->id.name);
+	ViewLayer *view_layer = CTX_data_view_layer(C);
+	Base *base = BKE_view_layer_base_find(view_layer, ob);
+	if (base == NULL) {
+		return;
+	}
+
+	Scene *scene = CTX_data_scene(C);
+	outliner_object_mode_toggle(C, scene, view_layer, base);
+}
+
 static void restrictbutton_id_user_toggle(bContext *UNUSED(C), void *poin, void *UNUSED(poin2))
 {
 	ID *id = (ID *)poin;
@@ -435,7 +453,8 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
 }
 
 static void outliner_draw_restrictbuts(
-        uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, ListBase *lb)
+        uiBlock *block, Scene *scene, const Object *obact, const eObjectMode object_mode_toggle,
+        ARegion *ar, SpaceOops *soops, ListBase *lb)
 {
 	uiBut *bt;
 
@@ -544,6 +563,20 @@ static void outliner_draw_restrictbuts(
 
 				/* TODO: visibility in renders */
 			}
+			else if ((tselem->type == 0) && (te->idcode == ID_OB)) {
+				if (object_mode_toggle != OB_MODE_OBJECT) {
+					Object *ob = (Object *)tselem->id;
+					if (ob->type == obact->type) {
+						bt = uiDefIconButBitI(
+						        block, UI_BTYPE_ICON_TOGGLE, object_mode_toggle, 0, ICON_CHECKBOX_DEHLT,
+						        (int)(ar->v2d.cur.xmax - OL_TOG_OBJECT_MODE), te->ys, UI_UNIT_X,
+						        UI_UNIT_Y, &ob->mode, 0, 0, 0, 0,
+						        TIP_("Restrict/Allow editing of strokes and keyframes in this layer"));
+						UI_but_func_set(bt, restrictbutton_object_mode_cb, (void *)(intptr_t)ob->mode, ob);
+						UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
+					}
+				}
+			}
 			else if (outliner_is_collection_tree_element(te)) {
 				LayerCollection *lc = (tselem->type == TSE_LAYER_COLLECTION) ? te->directdata : NULL;
 				Collection *collection = outliner_collection_from_tree_element(te);
@@ -576,7 +609,7 @@ static void outliner_draw_restrictbuts(
 		}
 
 		if (TSELEM_OPEN(tselem, soops)) {
-			outliner_draw_restrictbuts(block, scene, ar, soops, &te->subtree);
+			outliner_draw_restrictbuts(block, scene, obact, object_mode_toggle, ar, soops, &te->subtree);
 		}
 	}
 }
@@ -1893,7 +1926,7 @@ static void outliner_draw_restrictcols(ARegion *ar)
 	unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
 	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 	immUniformThemeColorShadeAlpha(TH_BACK, -15, -200);
-	immBegin(GWN_PRIM_LINES, 6);
+	immBegin(GWN_PRIM_LINES, 8);
 
 	immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)ar->v2d.cur.ymax);
 	immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)ar->v2d.cur.ymin);
@@ -1904,6 +1937,9 @@ static void outliner_draw_restrictcols(ARegion *ar)
 	immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)ar->v2d.cur.ymax);
 	immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)ar->v2d.cur.ymin);
 
+	immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_OBJECT_MODE), (int)ar->v2d.cur.ymax);
+	immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_OBJECT_MODE), (int)ar->v2d.cur.ymin);
+
 	immEnd();
 	immUnbindProgram();
 }
@@ -1996,10 +2032,11 @@ void draw_outliner(const bContext *C)
 		outliner_draw_userbuts(block, ar, soops, &soops->tree);
 	}
 	else if (has_restrict_icons) {
+		const Object *obact = OBACT(view_layer);
+		const eObjectMode object_mode_toggle = obact ? (obact->mode & OB_MODE_ALL_MULTI) : OB_MODE_OBJECT;
 		/* draw restriction columns */
 		outliner_draw_restrictcols(ar);
-
-		outliner_draw_restrictbuts(block, scene, ar, soops, &soops->tree);
+		outliner_draw_restrictbuts(block, scene, obact, object_mode_toggle, ar, soops, &soops->tree);
 	}
 
 	/* draw edit buttons if nessecery */
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index aa3c0a52f70..ac5c5906b3b 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -151,11 +151,12 @@ typedef enum {
 /* size constants */
 #define OL_Y_OFFSET 2
 
+#define OL_TOG_OBJECT_MODE      (UI_UNIT_X * 4.0f)
 #define OL_TOG_RESTRICT_SELECTX (UI_UNIT_X * 3.0f)
 #define OL_TOG_RESTRICT_VIEWX   (UI_UNIT_X * 2.0f)
 #define OL_TOG_RESTRICT_RENDERX UI_UNIT_X
 
-#define OL_TOGW OL_TOG_RESTRICT_SELECTX
+#define OL_TOGW OL_TOG_OBJECT_MODE
 
 #define OL_RNA_COLX         (UI_UNIT_X * 15)
 #define OL_RNA_COL_SIZEX    (UI_UNIT_X * 7.5f)
diff --git a/source/blender/makesdna/DNA_object_enums.h b/source/blender/makesdna/DNA_object_enums.h
index 802ca6c7d0d..4462c939032 100644
--- a/source/blender/makesdna/DNA_object_enums.h
+++ b/source/blender/makesdna/DNA_object_enums.h
@@ -50,4 +50,8 @@ typedef enum eObjectMode {
 #define OB_MODE_ALL_MODE_DATA \
 	(OB_MODE_EDIT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_SCULPT | OB_MODE_POSE)
 
+/* Any mode that supports multiple objects at once. */
+#define OB_MODE_ALL_MULTI \
+	(OB_MODE_EDIT | OB_MODE_POSE)
+
 #endif  /* __DNA_OBJECT_ENUMS_H__ */



More information about the Bf-blender-cvs mailing list