UI: fix "Edit Source" operator
This commit is contained in:
parent
b661a4d663
commit
109dbab593
Notes:
blender-bot
2023-02-14 06:00:50 +01:00
Referenced by commit 6d21450a61
, Revert "UI: fix "Edit Source" operator"
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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__ */
|
||||
|
|
Loading…
Reference in New Issue