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')
-rw-r--r--source/blender/editors/gpencil/gpencil_mesh.c5
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c33
-rw-r--r--source/blender/editors/include/UI_interface_icons.h1
-rw-r--r--source/blender/editors/interface/interface_icons.c30
-rw-r--r--source/blender/editors/interface/interface_layout.c6
-rw-r--r--source/blender/editors/object/object_add.c26
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c3
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_boundary.c4
-rw-r--r--source/blender/editors/space_outliner/outliner_dragdrop.c3
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c136
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c58
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h12
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c225
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c416
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c2
15 files changed, 479 insertions, 481 deletions
diff --git a/source/blender/editors/gpencil/gpencil_mesh.c b/source/blender/editors/gpencil/gpencil_mesh.c
index f4e40c2670f..e4862617d12 100644
--- a/source/blender/editors/gpencil/gpencil_mesh.c
+++ b/source/blender/editors/gpencil/gpencil_mesh.c
@@ -162,7 +162,7 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op)
Object *ob_gpencil = NULL;
ListBase list = {NULL, NULL};
- const bool simple_material = gpencil_bake_ob_list(C, depsgraph, scene, &list);
+ gpencil_bake_ob_list(C, depsgraph, scene, &list);
/* Cannot check this in poll because the active object changes. */
if (list.first == NULL) {
@@ -264,8 +264,7 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op)
ob_eval->obmat,
frame_offset,
use_seams,
- use_faces,
- simple_material);
+ use_faces);
/* Reproject all untaged created strokes. */
if (project_type != GP_REPROJECT_KEEP) {
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 6748211a1bc..fdab3649b13 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1525,6 +1525,9 @@ static void gpencil_stroke_eraser_dostroke(tGPsdata *p,
pt1 = gps->points + i;
pt2 = gps->points + i + 1;
+ float inf1 = 0.0f;
+ float inf2 = 0.0f;
+
/* only process if it hasn't been masked out... */
if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT)) {
continue;
@@ -1603,22 +1606,36 @@ static void gpencil_stroke_eraser_dostroke(tGPsdata *p,
pt2->flag |= GP_SPOINT_TAG;
do_cull = true;
}
+
+ inf1 = 1.0f;
+ inf2 = 1.0f;
}
else {
- pt1->pressure -= gpencil_stroke_eraser_calc_influence(p, mval, radius, pc1) *
- strength;
- pt2->pressure -= gpencil_stroke_eraser_calc_influence(p, mval, radius, pc2) *
- strength * 0.5f;
+ /* Erase point. Only erase if the eraser is on top of the point. */
+ inf1 = gpencil_stroke_eraser_calc_influence(p, mval, radius, pc1);
+ if (inf1 > 0.0f) {
+ pt1->pressure = 0.0f;
+ pt1->flag |= GP_SPOINT_TAG;
+ do_cull = true;
+ }
+ inf2 = gpencil_stroke_eraser_calc_influence(p, mval, radius, pc2);
+ if (inf2 > 0.0f) {
+ pt2->pressure = 0.0f;
+ pt2->flag |= GP_SPOINT_TAG;
+ do_cull = true;
+ }
}
/* 2) Tag any point with overly low influence for removal in the next pass */
- if ((pt1->pressure < cull_thresh) || (p->flags & GP_PAINTFLAG_HARD_ERASER) ||
- (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_HARD)) {
+ if ((inf1 > 0.0f) &&
+ (((pt1->pressure < cull_thresh) || (p->flags & GP_PAINTFLAG_HARD_ERASER) ||
+ (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_HARD)))) {
pt1->flag |= GP_SPOINT_TAG;
do_cull = true;
}
- if ((pt2->pressure < cull_thresh) || (p->flags & GP_PAINTFLAG_HARD_ERASER) ||
- (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_HARD)) {
+ if ((inf1 > 2.0f) &&
+ (((pt2->pressure < cull_thresh) || (p->flags & GP_PAINTFLAG_HARD_ERASER) ||
+ (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_HARD)))) {
pt2->flag |= GP_SPOINT_TAG;
do_cull = true;
}
diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h
index 7b59d45b203..bbe66f7fd73 100644
--- a/source/blender/editors/include/UI_interface_icons.h
+++ b/source/blender/editors/include/UI_interface_icons.h
@@ -106,6 +106,7 @@ struct PreviewImage *UI_icon_to_preview(int icon_id);
int UI_rnaptr_icon_get(struct bContext *C, struct PointerRNA *ptr, int rnaicon, const bool big);
int UI_idcode_icon_get(const int idcode);
int UI_library_icon_get(const struct ID *id);
+int UI_mode_icon_get(const int mode);
#ifdef __cplusplus
}
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index b5f902adfb5..c91b4d826a7 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -2294,6 +2294,36 @@ int UI_idcode_icon_get(const int idcode)
}
}
+int UI_mode_icon_get(const int mode)
+{
+ switch (mode) {
+ case OB_MODE_OBJECT:
+ return ICON_OBJECT_DATAMODE;
+ case OB_MODE_EDIT:
+ case OB_MODE_EDIT_GPENCIL:
+ return ICON_EDITMODE_HLT;
+ case OB_MODE_SCULPT:
+ case OB_MODE_SCULPT_GPENCIL:
+ return ICON_SCULPTMODE_HLT;
+ case OB_MODE_VERTEX_PAINT:
+ case OB_MODE_VERTEX_GPENCIL:
+ return ICON_VPAINT_HLT;
+ case OB_MODE_WEIGHT_PAINT:
+ case OB_MODE_WEIGHT_GPENCIL:
+ return ICON_WPAINT_HLT;
+ case OB_MODE_TEXTURE_PAINT:
+ return ICON_TPAINT_HLT;
+ case OB_MODE_PARTICLE_EDIT:
+ return ICON_PARTICLEMODE;
+ case OB_MODE_POSE:
+ return ICON_POSE_HLT;
+ case OB_MODE_PAINT_GPENCIL:
+ return ICON_GREASEPENCIL;
+ default:
+ return ICON_NONE;
+ }
+}
+
/* draws icon with dpi scale factor */
void UI_icon_draw(float x, float y, int icon_id)
{
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index b4c2ad5d677..d46bca0ba48 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -642,7 +642,7 @@ static void ui_item_array(uiLayout *layout,
uiButNumber *number_but = (uiButNumber *)but;
but->a1 = number_but->step_size;
- ui_but_change_type(but, UI_BTYPE_NUM_SLIDER);
+ but = ui_but_change_type(but, UI_BTYPE_NUM_SLIDER);
}
}
}
@@ -716,7 +716,7 @@ static void ui_item_array(uiLayout *layout,
uiButNumber *number_but = (uiButNumber *)but;
but->a1 = number_but->step_size;
- ui_but_change_type(but, UI_BTYPE_NUM_SLIDER);
+ but = ui_but_change_type(but, UI_BTYPE_NUM_SLIDER);
}
if ((toggle == 1) && but->type == UI_BTYPE_CHECKBOX) {
but->type = UI_BTYPE_TOGGLE;
@@ -2374,7 +2374,7 @@ void uiItemFullR(uiLayout *layout,
uiButNumber *num_but = (uiButNumber *)but;
but->a1 = num_but->step_size;
- ui_but_change_type(but, UI_BTYPE_NUM_SLIDER);
+ but = ui_but_change_type(but, UI_BTYPE_NUM_SLIDER);
}
if (flag & UI_ITEM_R_CHECKBOX_INVERT) {
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 482ae4019c3..4de48fba494 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -2596,20 +2596,18 @@ static int object_convert_exec(bContext *C, wmOperator *op)
bGPdata *gpd = (bGPdata *)ob_gpencil->data;
gpd->draw_mode = GP_DRAWMODE_3D;
- BKE_gpencil_convert_mesh(bmain,
- depsgraph,
- scene,
- ob_gpencil,
- ob,
- angle,
- thickness,
- offset,
- matrix,
- 0,
- use_seams,
- use_faces,
- false);
- gpencilConverted = true;
+ gpencilConverted |= BKE_gpencil_convert_mesh(bmain,
+ depsgraph,
+ scene,
+ ob_gpencil,
+ ob,
+ angle,
+ thickness,
+ offset,
+ matrix,
+ 0,
+ use_seams,
+ use_faces);
/* Remove unused materials. */
int actcol = ob_gpencil->actcol;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 5070709cb6d..e6ea79a771a 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1920,6 +1920,9 @@ static void calc_area_normal_and_center_task_cb(void *__restrict userdata,
if (ELEM(data->brush->sculpt_tool, SCULPT_TOOL_SCRAPE, SCULPT_TOOL_FILL) &&
data->brush->area_radius_factor > 0.0f) {
test_radius *= data->brush->area_radius_factor;
+ if (ss->cache && data->brush->flag2 & BRUSH_AREA_RADIUS_PRESSURE) {
+ test_radius *= ss->cache->pressure;
+ }
}
else {
test_radius *= data->brush->normal_radius_factor;
diff --git a/source/blender/editors/sculpt_paint/sculpt_boundary.c b/source/blender/editors/sculpt_paint/sculpt_boundary.c
index 3051413a405..b07dd18b6fc 100644
--- a/source/blender/editors/sculpt_paint/sculpt_boundary.c
+++ b/source/blender/editors/sculpt_paint/sculpt_boundary.c
@@ -501,6 +501,10 @@ SculptBoundary *SCULPT_boundary_data_init(Object *object,
{
SculptSession *ss = object->sculpt;
+ if (initial_vertex == BOUNDARY_VERTEX_NONE) {
+ return NULL;
+ }
+
SCULPT_vertex_random_access_ensure(ss);
SCULPT_boundary_info_ensure(object);
diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c
index 94052223e39..46a5f90f6c2 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.c
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.c
@@ -893,6 +893,9 @@ static int outliner_item_drag_drop_invoke(bContext *C,
if (outliner_item_is_co_within_close_toggle(te, view_mval[0])) {
return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
}
+ if (outliner_is_co_within_mode_column(space_outliner, view_mval)) {
+ return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
+ }
/* Scroll the view when dragging near edges, but not
* when the drag goes too far outside the region. */
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index fbef3aa07d7..3de786ddd4d 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -53,6 +53,7 @@
#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
+#include "BKE_particle.h"
#include "BKE_report.h"
#include "BKE_scene.h"
@@ -1884,6 +1885,109 @@ static void outliner_buttons(const bContext *C,
}
}
+static void outliner_mode_toggle_fn(bContext *C, void *tselem_poin, void *UNUSED(arg2))
+{
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
+ TreeStoreElem *tselem = (TreeStoreElem *)tselem_poin;
+ TreeViewContext tvc;
+ outliner_viewcontext_init(C, &tvc);
+
+ TreeElement *te = outliner_find_tree_element(&space_outliner->tree, tselem);
+ if (!te) {
+ return;
+ }
+
+ wmWindow *win = CTX_wm_window(C);
+ const bool do_extend = win->eventstate->ctrl != 0;
+ outliner_item_mode_toggle(C, &tvc, te, do_extend);
+}
+
+/* Draw icons for adding and removing objects from the current interation mode. */
+static void outliner_draw_mode_column_toggle(uiBlock *block,
+ TreeViewContext *tvc,
+ TreeElement *te,
+ TreeStoreElem *tselem,
+ const bool lock_object_modes)
+{
+ const int active_mode = tvc->obact->mode;
+ bool draw_active_icon = true;
+
+ if (tselem->type == 0 && te->idcode == ID_OB) {
+ Object *ob = (Object *)tselem->id;
+
+ /* When not locking object modes, objects can remain in non-object modes. For modes that do not
+ * allow multi-object editing, these other objects should still show be viewed as not in the
+ * mode. Otherwise multiple objects show the same mode icon in the outliner even though only
+ * one object is actually editable in the mode. */
+ if (!lock_object_modes && ob != tvc->obact && !(tvc->ob_edit || tvc->ob_pose)) {
+ draw_active_icon = false;
+ }
+
+ if (ob->type == tvc->obact->type) {
+ int icon;
+ const char *tip;
+
+ if (draw_active_icon && ob->mode == tvc->obact->mode) {
+ icon = UI_mode_icon_get(active_mode);
+ tip = TIP_("Remove from the current mode");
+ }
+ else {
+ /* Not all objects support particle systems */
+ if (active_mode == OB_MODE_PARTICLE_EDIT && !psys_get_current(ob)) {
+ return;
+ }
+ icon = ICON_DOT;
+ tip = TIP_(
+ "Change the object in the current mode\n"
+ "* Ctrl to add to the current mode");
+ }
+
+ uiBut *but = uiDefIconBut(block,
+ UI_BTYPE_ICON_TOGGLE,
+ 0,
+ icon,
+ 0,
+ te->ys,
+ UI_UNIT_X,
+ UI_UNIT_Y,
+ NULL,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ tip);
+ UI_but_func_set(but, outliner_mode_toggle_fn, tselem, NULL);
+ UI_but_flag_enable(but, UI_BUT_DRAG_LOCK);
+
+ if (ID_IS_LINKED(&ob->id)) {
+ UI_but_disable(but, TIP_("Can't edit external library data"));
+ }
+ }
+ }
+}
+
+static void outliner_draw_mode_column(const bContext *C,
+ uiBlock *block,
+ TreeViewContext *tvc,
+ SpaceOutliner *space_outliner,
+ ListBase *tree)
+{
+ TreeStoreElem *tselem;
+ const bool lock_object_modes = tvc->scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK;
+
+ LISTBASE_FOREACH (TreeElement *, te, tree) {
+ tselem = TREESTORE(te);
+
+ if (tvc->obact && tvc->obact->mode != OB_MODE_OBJECT) {
+ outliner_draw_mode_column_toggle(block, tvc, te, tselem, lock_object_modes);
+ }
+
+ if (TSELEM_OPEN(tselem, space_outliner)) {
+ outliner_draw_mode_column(C, block, tvc, space_outliner, &te->subtree);
+ }
+ }
+}
+
/* ****************************************************** */
/* Normal Drawing... */
@@ -3500,11 +3604,20 @@ static void outliner_draw_tree(bContext *C,
ARegion *region,
SpaceOutliner *space_outliner,
const float restrict_column_width,
+ const bool use_mode_column,
TreeElement **te_edit)
{
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
int starty, startx;
+ /* Move the tree a unit left in view layer mode */
+ short mode_column_offset = (use_mode_column && (space_outliner->outlinevis == SO_SCENES)) ?
+ UI_UNIT_X :
+ 0;
+ if (!use_mode_column && (space_outliner->outlinevis == SO_VIEW_LAYER)) {
+ mode_column_offset -= UI_UNIT_X;
+ }
+
GPU_blend(GPU_BLEND_ALPHA); /* Only once. */
if (space_outliner->outlinevis == SO_DATA_API) {
@@ -3530,12 +3643,12 @@ static void outliner_draw_tree(bContext *C,
/* Gray hierarchy lines. */
starty = (int)region->v2d.tot.ymax - UI_UNIT_Y / 2 - OL_Y_OFFSET;
- startx = UI_UNIT_X / 2 - (U.pixelsize + 1) / 2;
+ startx = mode_column_offset + UI_UNIT_X / 2 - (U.pixelsize + 1) / 2;
outliner_draw_hierarchy_lines(space_outliner, &space_outliner->tree, startx, &starty);
/* Items themselves. */
starty = (int)region->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET;
- startx = 0;
+ startx = mode_column_offset;
LISTBASE_FOREACH (TreeElement *, te, &space_outliner->tree) {
outliner_draw_tree_element(C,
block,
@@ -3658,12 +3771,22 @@ void draw_outliner(const bContext *C)
/* set matrix for 2d-view controls */
UI_view2d_view_ortho(v2d);
+ /* Only show mode column in View Layers and Scenes view */
+ const bool use_mode_column = (space_outliner->flag & SO_MODE_COLUMN) &&
+ (ELEM(space_outliner->outlinevis, SO_VIEW_LAYER, SO_SCENES));
+
/* draw outliner stuff (background, hierarchy lines and names) */
const float restrict_column_width = outliner_restrict_columns_width(space_outliner);
outliner_back(region);
block = UI_block_begin(C, region, __func__, UI_EMBOSS);
- outliner_draw_tree(
- (bContext *)C, block, &tvc, region, space_outliner, restrict_column_width, &te_edit);
+ outliner_draw_tree((bContext *)C,
+ block,
+ &tvc,
+ region,
+ space_outliner,
+ restrict_column_width,
+ use_mode_column,
+ &te_edit);
/* Compute outliner dimensions after it has been drawn. */
int tree_width, tree_height;
@@ -3698,6 +3821,11 @@ void draw_outliner(const bContext *C)
props_active);
}
+ /* Draw mode icons */
+ if (use_mode_column) {
+ outliner_draw_mode_column(C, block, &tvc, space_outliner, &space_outliner->tree);
+ }
+
UI_block_emboss_set(block, UI_EMBOSS);
/* Draw edit buttons if necessary. */
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index ad7346a5651..dea67a8678d 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -286,61 +286,6 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Object Mode Enter/Exit Utilities
- * \{ */
-
-static void item_object_mode_enter_exit(bContext *C, ReportList *reports, Object *ob, bool enter)
-{
- ViewLayer *view_layer = CTX_data_view_layer(C);
- Object *obact = OBACT(view_layer);
-
- if ((ob->type != obact->type) || ID_IS_LINKED(ob->data)) {
- return;
- }
- if (((ob->mode & obact->mode) != 0) == enter) {
- return;
- }
-
- if (ob == obact) {
- BKE_report(reports, RPT_WARNING, "Active object mode not changed");
- return;
- }
-
- 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);
-}
-
-void item_object_mode_enter_fn(bContext *C,
- ReportList *reports,
- Scene *UNUSED(scene),
- TreeElement *UNUSED(te),
- TreeStoreElem *UNUSED(tsep),
- TreeStoreElem *tselem,
- void *UNUSED(user_data))
-{
- Object *ob = (Object *)tselem->id;
- item_object_mode_enter_exit(C, reports, ob, true);
-}
-
-void item_object_mode_exit_fn(bContext *C,
- ReportList *reports,
- Scene *UNUSED(scene),
- TreeElement *UNUSED(te),
- TreeStoreElem *UNUSED(tsep),
- TreeStoreElem *tselem,
- void *UNUSED(user_data))
-{
- Object *ob = (Object *)tselem->id;
- item_object_mode_enter_exit(C, reports, ob, false);
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
/** \name Rename Operator
* \{ */
@@ -492,7 +437,8 @@ static void id_delete(bContext *C, ReportList *reports, TreeElement *te, TreeSto
Main *bmain = CTX_data_main(C);
ID *id = tselem->id;
- BLI_assert(te->idcode != 0 && id != NULL);
+ BLI_assert(id != NULL);
+ BLI_assert((tselem->type == 0 && te->idcode != 0) || tselem->type == TSE_LAYER_COLLECTION);
UNUSED_VARS_NDEBUG(te);
if (te->idcode == ID_LI && ((Library *)id)->parent != NULL) {
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 7e7fdf4bab2..88080218e7f 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -222,7 +222,6 @@ typedef enum TreeItemSelectAction {
OL_ITEM_ACTIVATE = (1 << 2), /* Activate the item */
OL_ITEM_EXTEND = (1 << 3), /* Extend the current selection */
OL_ITEM_RECURSIVE = (1 << 4), /* Select recursively */
- OL_ITEM_TOGGLE_MODE = (1 << 5) /* Temporary */
} TreeItemSelectAction;
/* outliner_tree.c ----------------------------------------------- */
@@ -282,13 +281,14 @@ void outliner_item_select(struct bContext *C,
struct TreeElement *te,
const short select_flag);
-void outliner_object_mode_toggle(struct bContext *C,
- Scene *scene,
- ViewLayer *view_layer,
- Base *base);
-
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);
+bool outliner_is_co_within_mode_column(SpaceOutliner *space_outliner, const float view_mval[2]);
+
+void outliner_item_mode_toggle(struct bContext *C,
+ TreeViewContext *tvc,
+ TreeElement *te,
+ const bool do_extend);
/* outliner_edit.c ---------------------------------------------- */
typedef void (*outliner_operation_fn)(struct bContext *C,
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 266ea293d43..61228e24ed9 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -64,6 +64,7 @@
#include "ED_undo.h"
#include "WM_api.h"
+#include "WM_toolsystem.h"
#include "WM_types.h"
#include "UI_interface.h"
@@ -74,187 +75,91 @@
#include "outliner_intern.h"
-static bool do_outliner_activate_common(bContext *C,
- Main *bmain,
- Depsgraph *depsgraph,
- Scene *scene,
- ViewLayer *view_layer,
- Base *base,
- const bool extend,
- const bool do_exit)
+static void do_outliner_item_editmode_toggle(bContext *C, Scene *scene, Base *base)
{
- bool use_all = false;
-
- if (do_exit) {
- FOREACH_OBJECT_BEGIN (view_layer, ob_iter) {
- ED_object_mode_generic_exit(bmain, depsgraph, scene, ob_iter);
- }
- FOREACH_OBJECT_END;
- }
-
- /* Just like clicking in the object changes the active object,
- * clicking on the object data should change it as well. */
- ED_object_base_activate(C, base);
+ Main *bmain = CTX_data_main(C);
+ Object *ob = base->object;
- if (extend) {
- use_all = true;
+ if (BKE_object_is_in_editmode(ob)) {
+ ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA);
+ WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
}
else {
- ED_object_base_deselect_all(view_layer, NULL, SEL_DESELECT);
+ ED_object_editmode_enter_ex(CTX_data_main(C), scene, ob, EM_NO_CONTEXT);
+ WM_event_add_notifier(C, NC_SCENE | ND_MODE, NULL);
}
-
- return use_all;
}
-/**
- * Bring the newly selected object into edit mode.
- *
- * If extend is used, we try to have the other compatible selected objects in the new mode as well.
- * Otherwise only the new object will be active, selected and in the edit mode.
- */
-static void do_outliner_item_editmode_toggle(
- bContext *C, Scene *scene, ViewLayer *view_layer, Base *base, const bool extend)
+static void do_outliner_item_posemode_toggle(bContext *C, Base *base)
{
Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- Object *obact = OBACT(view_layer);
Object *ob = base->object;
- bool use_all = false;
- if (obact == NULL) {
- ED_object_base_activate(C, base);
- DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
- WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
- obact = ob;
- use_all = true;
- }
- else if (obact->data == ob->data) {
- use_all = true;
+ if (ID_IS_LINKED(ob)) {
+ BKE_report(CTX_wm_reports(C), RPT_WARNING, "Cannot pose libdata");
}
- else if (obact->mode == OB_MODE_OBJECT) {
- use_all = do_outliner_activate_common(
- C, bmain, depsgraph, scene, view_layer, base, extend, false);
- }
- else if ((ob->type != obact->type) || ((obact->mode & OB_MODE_EDIT) == 0) ||
- ((obact->mode & OB_MODE_POSE) && ELEM(OB_ARMATURE, ob->type, obact->type)) || !extend) {
- use_all = do_outliner_activate_common(
- C, bmain, depsgraph, scene, view_layer, base, extend, true);
- }
-
- if (use_all) {
- WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL);
+ else if (ob->mode & OB_MODE_POSE) {
+ ED_object_posemode_exit_ex(bmain, ob);
+ WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
}
else {
- bool ok;
- if (BKE_object_is_in_editmode(ob)) {
- ok = ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA);
- }
- else {
- ok = ED_object_editmode_enter_ex(CTX_data_main(C), scene, ob, EM_NO_CONTEXT);
- }
- if (ok) {
- ED_object_base_select(base, (ob->mode & OB_MODE_EDIT) ? BA_SELECT : BA_DESELECT);
- DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
- WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
- }
+ ED_object_posemode_enter_ex(bmain, ob);
+ WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_POSE, NULL);
}
}
-static void do_outliner_item_posemode_toggle(
- bContext *C, Scene *scene, ViewLayer *view_layer, Base *base, const bool extend)
+/* Swap the current active object from the interaction mode with the given base. */
+static void do_outliner_item_mode_toggle_generic(bContext *C, TreeViewContext *tvc, Base *base)
{
Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- Object *obact = OBACT(view_layer);
- Object *ob = base->object;
- bool use_all = false;
-
- if (obact == NULL) {
- ED_object_base_activate(C, base);
- DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
- WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
- obact = ob;
- use_all = true;
- }
- else if (obact->data == ob->data) {
- use_all = true;
- }
- else if (obact->mode == OB_MODE_OBJECT) {
- use_all = do_outliner_activate_common(
- C, bmain, depsgraph, scene, view_layer, base, extend, false);
- }
- else if ((!ELEM(ob->type, obact->type)) ||
- ((obact->mode & OB_MODE_EDIT) && ELEM(OB_ARMATURE, ob->type, obact->type))) {
- use_all = do_outliner_activate_common(
- C, bmain, depsgraph, scene, view_layer, base, extend, true);
- }
+ const int active_mode = tvc->obact->mode;
- if (use_all) {
- WM_operator_name_call(C, "OBJECT_OT_posemode_toggle", WM_OP_INVOKE_REGION_WIN, NULL);
+ /* Return all objects to object mode. */
+ FOREACH_OBJECT_BEGIN (tvc->view_layer, ob_iter) {
+ ED_object_mode_generic_exit(bmain, depsgraph, tvc->scene, ob_iter);
}
- else {
- bool ok = false;
-
- if (ID_IS_LINKED(ob)) {
- BKE_report(CTX_wm_reports(C), RPT_WARNING, "Cannot pose libdata");
- }
- else if (ob->mode & OB_MODE_POSE) {
- ok = ED_object_posemode_exit_ex(bmain, ob);
- }
- else {
- ok = ED_object_posemode_enter_ex(bmain, ob);
- }
+ FOREACH_OBJECT_END;
+ WM_toolsystem_update_from_context_view3d(C);
- if (ok) {
- ED_object_base_select(base, (ob->mode & OB_MODE_POSE) ? BA_SELECT : BA_DESELECT);
-
- DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
- WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
- WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
- }
- }
-}
+ Base *base_active = BKE_view_layer_base_find(tvc->view_layer, tvc->obact);
+ if (base_active != base) {
+ ED_object_base_select(base_active, BA_DESELECT);
+ ED_object_base_activate(C, base);
+ ED_object_base_select(base, BA_SELECT);
-/* For draw callback to run mode switching */
-void outliner_object_mode_toggle(bContext *C, Scene *scene, ViewLayer *view_layer, Base *base)
-{
- Object *obact = OBACT(view_layer);
- if (obact->mode & OB_MODE_EDIT) {
- do_outliner_item_editmode_toggle(C, scene, view_layer, base, true);
- }
- else if (obact->mode & OB_MODE_POSE) {
- do_outliner_item_posemode_toggle(C, scene, view_layer, base, true);
+ /* XXX: Must add undo step between activation and setting mode to prevent an assert. */
+ ED_undo_push(C, "outliner mode toggle");
+ ED_object_mode_set(C, active_mode);
+ ED_outliner_select_sync_from_object_tag(C);
}
}
/* Toggle the item's interaction mode if supported */
-static void outliner_item_mode_toggle(bContext *C,
- TreeViewContext *tvc,
- TreeElement *te,
- const bool extend)
+void outliner_item_mode_toggle(bContext *C,
+ TreeViewContext *tvc,
+ TreeElement *te,
+ const bool do_extend)
{
TreeStoreElem *tselem = TREESTORE(te);
- if (tselem->type == 0) {
- if (OB_DATA_SUPPORT_EDITMODE(te->idcode)) {
- Object *ob = (Object *)outliner_search_back(te, ID_OB);
- if ((ob != NULL) && (ob->data == tselem->id)) {
- Base *base = BKE_view_layer_base_find(tvc->view_layer, ob);
- if ((base != NULL) && (base->flag & BASE_VISIBLE_DEPSGRAPH)) {
- do_outliner_item_editmode_toggle(C, tvc->scene, tvc->view_layer, base, extend);
- }
- }
- }
- else if (ELEM(te->idcode, ID_GD)) {
- /* set grease pencil to object mode */
- WM_operator_name_call(C, "GPENCIL_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL);
- }
- }
- else if (tselem->type == TSE_POSE_BASE) {
+ if (tselem->type == 0 && te->idcode == ID_OB) {
Object *ob = (Object *)tselem->id;
Base *base = BKE_view_layer_base_find(tvc->view_layer, ob);
- if (base != NULL) {
- do_outliner_item_posemode_toggle(C, tvc->scene, tvc->view_layer, base, extend);
+
+ /* Hidden objects can be removed from the mode. */
+ if (!base || (!(base->flag & BASE_VISIBLE_DEPSGRAPH) && (ob->mode != tvc->obact->mode))) {
+ return;
+ }
+
+ if (!do_extend) {
+ do_outliner_item_mode_toggle_generic(C, tvc, base);
+ }
+ else if (tvc->ob_edit && OB_TYPE_SUPPORT_EDITMODE(ob->type)) {
+ do_outliner_item_editmode_toggle(C, tvc->scene, base);
+ }
+ else if (tvc->ob_pose && ob->type == OB_ARMATURE) {
+ do_outliner_item_posemode_toggle(C, base);
}
}
}
@@ -1272,11 +1177,6 @@ void outliner_item_select(bContext *C,
extend,
select_flag & OL_ITEM_RECURSIVE,
activate_data || space_outliner->flag & SO_SYNC_SELECT);
-
- /* Mode toggle on data activate for now, but move later */
- if (select_flag & OL_ITEM_TOGGLE_MODE) {
- outliner_item_mode_toggle(C, &tvc, te, extend);
- }
}
}
@@ -1353,6 +1253,16 @@ static bool outliner_is_co_within_restrict_columns(const SpaceOutliner *space_ou
return (view_co_x > region->v2d.cur.xmax - outliner_restrict_columns_width(space_outliner));
}
+bool outliner_is_co_within_mode_column(SpaceOutliner *space_outliner, const float view_mval[2])
+{
+ /* Mode toggles only show in View Layer and Scenes modes. */
+ if (!ELEM(space_outliner->outlinevis, SO_VIEW_LAYER, SO_SCENES)) {
+ return false;
+ }
+
+ return space_outliner->flag & SO_MODE_COLUMN && view_mval[0] < UI_UNIT_X;
+}
+
/**
* Action to run when clicking in the outliner,
*
@@ -1375,6 +1285,9 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
if (outliner_is_co_within_restrict_columns(space_outliner, region, view_mval[0])) {
return OPERATOR_CANCELLED;
}
+ if (outliner_is_co_within_mode_column(space_outliner, view_mval)) {
+ return OPERATOR_CANCELLED;
+ }
if (!(te = outliner_find_item_at_y(space_outliner, &space_outliner->tree, view_mval[1]))) {
if (deselect_all) {
@@ -1413,7 +1326,7 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
const short select_flag = OL_ITEM_ACTIVATE | (select ? OL_ITEM_SELECT : OL_ITEM_DESELECT) |
(is_over_name_icons ? OL_ITEM_SELECT_DATA : 0) |
- (extend ? OL_ITEM_EXTEND : 0) | OL_ITEM_TOGGLE_MODE;
+ (extend ? OL_ITEM_EXTEND : 0);
outliner_item_select(C, space_outliner, activate_te, select_flag);
}
@@ -1542,6 +1455,10 @@ static int outliner_box_select_invoke(bContext *C, wmOperator *op, const wmEvent
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
}
+ if (outliner_is_co_within_mode_column(space_outliner, view_mval)) {
+ return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
+ }
+
return WM_gesture_box_invoke(C, op, event);
}
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 01b6e636ded..0743e841794 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -95,110 +95,105 @@
/** \name ID/Library/Data Set/Un-link Utilities
* \{ */
-static void set_operation_types(SpaceOutliner *space_outliner,
- ListBase *lb,
- int *scenelevel,
- int *objectlevel,
- int *idlevel,
- int *datalevel)
+static void get_element_operation_type(
+ TreeElement *te, int *scenelevel, int *objectlevel, int *idlevel, int *datalevel)
{
- TreeElement *te;
- TreeStoreElem *tselem;
+ TreeStoreElem *tselem = TREESTORE(te);
+ if (tselem->flag & TSE_SELECTED) {
+ /* Layer collection points to collection ID. */
+ if (!ELEM(tselem->type, 0, TSE_LAYER_COLLECTION)) {
+ if (*datalevel == 0) {
+ *datalevel = tselem->type;
+ }
+ else if (*datalevel != tselem->type) {
+ *datalevel = -1;
+ }
+ }
+ else {
+ const int idcode = (int)GS(tselem->id->name);
+ bool is_standard_id = false;
+ switch ((ID_Type)idcode) {
+ case ID_SCE:
+ *scenelevel = 1;
+ break;
+ case ID_OB:
+ *objectlevel = 1;
+ break;
- for (te = lb->first; te; te = te->next) {
- tselem = TREESTORE(te);
- if (tselem->flag & TSE_SELECTED) {
- /* Layer collection points to collection ID. */
- if (!ELEM(tselem->type, 0, TSE_LAYER_COLLECTION)) {
- if (*datalevel == 0) {
- *datalevel = tselem->type;
- }
- else if (*datalevel != tselem->type) {
- *datalevel = -1;
- }
+ case ID_ME:
+ case ID_CU:
+ case ID_MB:
+ case ID_LT:
+ case ID_LA:
+ case ID_AR:
+ case ID_CA:
+ case ID_SPK:
+ case ID_MA:
+ case ID_TE:
+ case ID_IP:
+ case ID_IM:
+ case ID_SO:
+ case ID_KE:
+ case ID_WO:
+ case ID_AC:
+ case ID_TXT:
+ case ID_GR:
+ case ID_LS:
+ case ID_LI:
+ case ID_VF:
+ case ID_NT:
+ case ID_BR:
+ case ID_PA:
+ case ID_GD:
+ case ID_MC:
+ case ID_MSK:
+ case ID_PAL:
+ case ID_PC:
+ case ID_CF:
+ case ID_WS:
+ case ID_LP:
+ case ID_HA:
+ case ID_PT:
+ case ID_VO:
+ case ID_SIM:
+ is_standard_id = true;
+ break;
+ case ID_WM:
+ case ID_SCR:
+ /* Those are ignored here. */
+ /* Note: while Screens should be manageable here, deleting a screen used by a workspace
+ * will cause crashes when trying to use that workspace, so for now let's play minimal,
+ * safe change. */
+ break;
+ }
+ if (idcode == ID_NLA) {
+ /* Fake one, not an actual ID type... */
+ is_standard_id = true;
}
- else {
- const int idcode = (int)GS(tselem->id->name);
- bool is_standard_id = false;
- switch ((ID_Type)idcode) {
- case ID_SCE:
- *scenelevel = 1;
- break;
- case ID_OB:
- *objectlevel = 1;
- break;
- case ID_ME:
- case ID_CU:
- case ID_MB:
- case ID_LT:
- case ID_LA:
- case ID_AR:
- case ID_CA:
- case ID_SPK:
- case ID_MA:
- case ID_TE:
- case ID_IP:
- case ID_IM:
- case ID_SO:
- case ID_KE:
- case ID_WO:
- case ID_AC:
- case ID_TXT:
- case ID_GR:
- case ID_LS:
- case ID_LI:
- case ID_VF:
- case ID_NT:
- case ID_BR:
- case ID_PA:
- case ID_GD:
- case ID_MC:
- case ID_MSK:
- case ID_PAL:
- case ID_PC:
- case ID_CF:
- case ID_WS:
- case ID_LP:
- case ID_HA:
- case ID_PT:
- case ID_VO:
- case ID_SIM:
- is_standard_id = true;
- break;
- case ID_WM:
- case ID_SCR:
- /* Those are ignored here. */
- /* Note: while Screens should be manageable here, deleting a screen used by a workspace
- * will cause crashes when trying to use that workspace, so for now let's play minimal,
- * safe change. */
- break;
+ if (is_standard_id) {
+ if (*idlevel == 0) {
+ *idlevel = idcode;
}
- if (idcode == ID_NLA) {
- /* Fake one, not an actual ID type... */
- is_standard_id = true;
+ else if (*idlevel != idcode) {
+ *idlevel = -1;
}
-
- if (is_standard_id) {
- if (*idlevel == 0) {
- *idlevel = idcode;
- }
- else if (*idlevel != idcode) {
- *idlevel = -1;
- }
- if (ELEM(*datalevel, TSE_VIEW_COLLECTION_BASE, TSE_SCENE_COLLECTION_BASE)) {
- *datalevel = 0;
- }
+ if (ELEM(*datalevel, TSE_VIEW_COLLECTION_BASE, TSE_SCENE_COLLECTION_BASE)) {
+ *datalevel = 0;
}
}
}
- if (TSELEM_OPEN(tselem, space_outliner)) {
- set_operation_types(
- space_outliner, &te->subtree, scenelevel, objectlevel, idlevel, datalevel);
- }
}
}
+static TreeElement *get_target_element(SpaceOutliner *space_outliner)
+{
+ TreeElement *te = outliner_find_element_with_flag(&space_outliner->tree, TSE_ACTIVE);
+ BLI_assert(te);
+
+ return te;
+}
+
static void unlink_action_fn(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
@@ -405,7 +400,7 @@ static void outliner_do_libdata_operation(bContext *C,
for (te = lb->first; te; te = te->next) {
tselem = TREESTORE(te);
if (tselem->flag & TSE_SELECTED) {
- if (ELEM(tselem->type, 0, TSE_LAYER_COLLECTION)) {
+ if ((tselem->type == 0 && te->idcode != 0) || tselem->type == TSE_LAYER_COLLECTION) {
TreeStoreElem *tsep = te->parent ? TREESTORE(te->parent) : NULL;
operation_fn(C, reports, scene, te, tsep, tselem, user_data);
}
@@ -1492,16 +1487,6 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
C, op->reports, scene, space_outliner, &space_outliner->tree, item_rename_fn);
str = "Rename Object";
}
- else if (event == OL_OP_OBJECT_MODE_ENTER) {
- outliner_do_object_operation(
- C, op->reports, scene, space_outliner, &space_outliner->tree, item_object_mode_enter_fn);
- str = "Enter Current Mode";
- }
- else if (event == OL_OP_OBJECT_MODE_EXIT) {
- outliner_do_object_operation(
- C, op->reports, scene, space_outliner, &space_outliner->tree, item_object_mode_exit_fn);
- str = "Exit Current Mode";
- }
else {
BLI_assert(0);
return OPERATOR_CANCELLED;
@@ -1806,18 +1791,16 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
- eOutlinerIdOpTypes event;
/* check for invalid states */
if (space_outliner == NULL) {
return OPERATOR_CANCELLED;
}
- set_operation_types(
- space_outliner, &space_outliner->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
-
- event = RNA_enum_get(op->ptr, "type");
+ TreeElement *te = get_target_element(space_outliner);
+ get_element_operation_type(te, &scenelevel, &objectlevel, &idlevel, &datalevel);
+ eOutlinerIdOpTypes event = RNA_enum_get(op->ptr, "type");
switch (event) {
case OUTLINER_IDOP_UNLINK: {
/* unlink datablock from its parent */
@@ -2138,18 +2121,16 @@ static int outliner_lib_operation_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
- eOutlinerLibOpTypes event;
/* check for invalid states */
if (space_outliner == NULL) {
return OPERATOR_CANCELLED;
}
- set_operation_types(
- space_outliner, &space_outliner->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
-
- event = RNA_enum_get(op->ptr, "type");
+ TreeElement *te = get_target_element(space_outliner);
+ get_element_operation_type(te, &scenelevel, &objectlevel, &idlevel, &datalevel);
+ eOutlinerLibOpTypes event = RNA_enum_get(op->ptr, "type");
switch (event) {
case OL_LIB_RENAME: {
outliner_do_libdata_operation(
@@ -2271,8 +2252,9 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op)
if (space_outliner == NULL) {
return OPERATOR_CANCELLED;
}
- set_operation_types(
- space_outliner, &space_outliner->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
+
+ TreeElement *te = get_target_element(space_outliner);
+ get_element_operation_type(te, &scenelevel, &objectlevel, &idlevel, &datalevel);
/* get action to use */
act = BLI_findlink(&bmain->actions, RNA_enum_get(op->ptr, "action"));
@@ -2379,22 +2361,21 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op)
wmWindowManager *wm = CTX_wm_manager(C);
SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
- eOutliner_AnimDataOps event;
/* check for invalid states */
if (space_outliner == NULL) {
return OPERATOR_CANCELLED;
}
- event = RNA_enum_get(op->ptr, "type");
- set_operation_types(
- space_outliner, &space_outliner->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
+ TreeElement *te = get_target_element(space_outliner);
+ get_element_operation_type(te, &scenelevel, &objectlevel, &idlevel, &datalevel);
if (datalevel != TSE_ANIM_DATA) {
return OPERATOR_CANCELLED;
}
/* perform the core operation */
+ eOutliner_AnimDataOps event = RNA_enum_get(op->ptr, "type");
switch (event) {
case OUTLINER_ANIMOP_CLEAR_ADT:
/* Remove Animation Data - this may remove the active action, in some cases... */
@@ -2484,15 +2465,10 @@ static const EnumPropertyItem prop_constraint_op_types[] = {
static int outliner_constraint_operation_exec(bContext *C, wmOperator *op)
{
SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
- int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
- eOutliner_PropConstraintOps event;
-
- event = RNA_enum_get(op->ptr, "type");
- set_operation_types(
- space_outliner, &space_outliner->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
+ eOutliner_PropConstraintOps event = RNA_enum_get(op->ptr, "type");
outliner_do_data_operation(
- space_outliner, datalevel, event, &space_outliner->tree, constraint_fn, C);
+ space_outliner, TSE_CONSTRAINT, event, &space_outliner->tree, constraint_fn, C);
if (event == OL_CONSTRAINTOP_DELETE) {
outliner_cleanup_tree(space_outliner);
@@ -2536,15 +2512,10 @@ static const EnumPropertyItem prop_modifier_op_types[] = {
static int outliner_modifier_operation_exec(bContext *C, wmOperator *op)
{
SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
- int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
- eOutliner_PropModifierOps event;
-
- event = RNA_enum_get(op->ptr, "type");
- set_operation_types(
- space_outliner, &space_outliner->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
+ eOutliner_PropModifierOps event = RNA_enum_get(op->ptr, "type");
outliner_do_data_operation(
- space_outliner, datalevel, event, &space_outliner->tree, modifier_fn, C);
+ space_outliner, TSE_MODIFIER, event, &space_outliner->tree, modifier_fn, C);
if (event == OL_MODIFIER_OP_DELETE) {
outliner_cleanup_tree(space_outliner);
@@ -2591,17 +2562,16 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op)
{
SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
- eOutliner_PropDataOps event;
/* check for invalid states */
if (space_outliner == NULL) {
return OPERATOR_CANCELLED;
}
- event = RNA_enum_get(op->ptr, "type");
- set_operation_types(
- space_outliner, &space_outliner->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
+ TreeElement *te = get_target_element(space_outliner);
+ get_element_operation_type(te, &scenelevel, &objectlevel, &idlevel, &datalevel);
+ eOutliner_PropDataOps event = RNA_enum_get(op->ptr, "type");
switch (datalevel) {
case TSE_POSE_CHANNEL: {
outliner_do_data_operation(
@@ -2700,134 +2670,116 @@ static int outliner_operator_menu(bContext *C, const char *opname)
}
static int do_outliner_operation_event(bContext *C,
+ ReportList *reports,
ARegion *region,
SpaceOutliner *space_outliner,
- TreeElement *te,
- const float mval[2])
+ TreeElement *te)
{
- ReportList *reports = CTX_wm_reports(C); /* XXX... */
+ int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
+ TreeStoreElem *tselem = TREESTORE(te);
- if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) {
- int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
- TreeStoreElem *tselem = TREESTORE(te);
+ int select_flag = OL_ITEM_ACTIVATE | OL_ITEM_SELECT;
+ if (tselem->flag & TSE_SELECTED) {
+ select_flag |= OL_ITEM_EXTEND;
+ }
- /* select object that's clicked on and popup context menu */
- if (!(tselem->flag & TSE_SELECTED)) {
+ outliner_item_select(C, space_outliner, te, select_flag);
- if (outliner_flag_is_any_test(&space_outliner->tree, TSE_SELECTED, 1)) {
- outliner_flag_set(&space_outliner->tree, TSE_SELECTED, 0);
- }
+ /* Only redraw, don't rebuild here because TreeElement pointers will
+ * become invalid and operations will crash. */
+ ED_region_tag_redraw_no_rebuild(region);
+ ED_outliner_select_sync_from_outliner(C, space_outliner);
- tselem->flag |= TSE_SELECTED;
+ get_element_operation_type(te, &scenelevel, &objectlevel, &idlevel, &datalevel);
- /* Only redraw, don't rebuild here because TreeElement pointers will
- * become invalid and operations will crash. */
- ED_region_tag_redraw_no_rebuild(region);
- ED_outliner_select_sync_from_outliner(C, space_outliner);
+ if (scenelevel) {
+ if (objectlevel || datalevel || idlevel) {
+ BKE_report(reports, RPT_WARNING, "Mixed selection");
+ return OPERATOR_CANCELLED;
}
-
- set_operation_types(
- space_outliner, &space_outliner->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
-
- if (scenelevel) {
- if (objectlevel || datalevel || idlevel) {
- BKE_report(reports, RPT_WARNING, "Mixed selection");
- return OPERATOR_CANCELLED;
- }
- return outliner_operator_menu(C, "OUTLINER_OT_scene_operation");
- }
- if (objectlevel) {
- WM_menu_name_call(C, "OUTLINER_MT_object", WM_OP_INVOKE_REGION_WIN);
- return OPERATOR_FINISHED;
+ return outliner_operator_menu(C, "OUTLINER_OT_scene_operation");
+ }
+ if (objectlevel) {
+ WM_menu_name_call(C, "OUTLINER_MT_object", WM_OP_INVOKE_REGION_WIN);
+ return OPERATOR_FINISHED;
+ }
+ if (idlevel) {
+ if (idlevel == -1 || datalevel) {
+ BKE_report(reports, RPT_WARNING, "Mixed selection");
+ return OPERATOR_CANCELLED;
}
- if (idlevel) {
- if (idlevel == -1 || datalevel) {
- BKE_report(reports, RPT_WARNING, "Mixed selection");
- return OPERATOR_CANCELLED;
- }
- switch (idlevel) {
- case ID_GR:
- WM_menu_name_call(C, "OUTLINER_MT_collection", WM_OP_INVOKE_REGION_WIN);
- return OPERATOR_FINISHED;
- break;
- case ID_LI:
- return outliner_operator_menu(C, "OUTLINER_OT_lib_operation");
- break;
- default:
- return outliner_operator_menu(C, "OUTLINER_OT_id_operation");
- break;
- }
- }
- else if (datalevel) {
- if (datalevel == -1) {
- BKE_report(reports, RPT_WARNING, "Mixed selection");
- return OPERATOR_CANCELLED;
- }
- if (datalevel == TSE_ANIM_DATA) {
- return outliner_operator_menu(C, "OUTLINER_OT_animdata_operation");
- }
- if (datalevel == TSE_DRIVER_BASE) {
- /* do nothing... no special ops needed yet */
- return OPERATOR_CANCELLED;
- }
- if (datalevel == TSE_LAYER_COLLECTION) {
+ switch (idlevel) {
+ case ID_GR:
WM_menu_name_call(C, "OUTLINER_MT_collection", WM_OP_INVOKE_REGION_WIN);
return OPERATOR_FINISHED;
- }
- if (ELEM(datalevel, TSE_SCENE_COLLECTION_BASE, TSE_VIEW_COLLECTION_BASE)) {
- WM_menu_name_call(C, "OUTLINER_MT_collection_new", WM_OP_INVOKE_REGION_WIN);
- return OPERATOR_FINISHED;
- }
- if (datalevel == TSE_ID_BASE) {
- /* do nothing... there are no ops needed here yet */
- return 0;
- }
- if (datalevel == TSE_CONSTRAINT) {
- return outliner_operator_menu(C, "OUTLINER_OT_constraint_operation");
- }
- if (datalevel == TSE_MODIFIER) {
- return outliner_operator_menu(C, "OUTLINER_OT_modifier_operation");
- }
- return outliner_operator_menu(C, "OUTLINER_OT_data_operation");
+ break;
+ case ID_LI:
+ return outliner_operator_menu(C, "OUTLINER_OT_lib_operation");
+ break;
+ default:
+ return outliner_operator_menu(C, "OUTLINER_OT_id_operation");
+ break;
}
-
- return 0;
}
-
- for (te = te->subtree.first; te; te = te->next) {
- int retval = do_outliner_operation_event(C, region, space_outliner, te, mval);
- if (retval) {
- return retval;
+ else if (datalevel) {
+ if (datalevel == -1) {
+ BKE_report(reports, RPT_WARNING, "Mixed selection");
+ return OPERATOR_CANCELLED;
+ }
+ if (datalevel == TSE_ANIM_DATA) {
+ return outliner_operator_menu(C, "OUTLINER_OT_animdata_operation");
+ }
+ if (datalevel == TSE_DRIVER_BASE) {
+ /* do nothing... no special ops needed yet */
+ return OPERATOR_CANCELLED;
}
+ if (datalevel == TSE_LAYER_COLLECTION) {
+ WM_menu_name_call(C, "OUTLINER_MT_collection", WM_OP_INVOKE_REGION_WIN);
+ return OPERATOR_FINISHED;
+ }
+ if (ELEM(datalevel, TSE_SCENE_COLLECTION_BASE, TSE_VIEW_COLLECTION_BASE)) {
+ WM_menu_name_call(C, "OUTLINER_MT_collection_new", WM_OP_INVOKE_REGION_WIN);
+ return OPERATOR_FINISHED;
+ }
+ if (datalevel == TSE_ID_BASE) {
+ /* do nothing... there are no ops needed here yet */
+ return 0;
+ }
+ if (datalevel == TSE_CONSTRAINT) {
+ return outliner_operator_menu(C, "OUTLINER_OT_constraint_operation");
+ }
+ if (datalevel == TSE_MODIFIER) {
+ return outliner_operator_menu(C, "OUTLINER_OT_modifier_operation");
+ }
+ return outliner_operator_menu(C, "OUTLINER_OT_data_operation");
}
return 0;
}
-static int outliner_operation(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
+static int outliner_operation(bContext *C, wmOperator *op, const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
uiBut *but = UI_context_active_but_get(C);
- TreeElement *te;
- float fmval[2];
+ float view_mval[2];
if (but) {
UI_but_tooltip_timer_remove(C, but);
}
- UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
+ UI_view2d_region_to_view(
+ &region->v2d, event->mval[0], event->mval[1], &view_mval[0], &view_mval[1]);
- for (te = space_outliner->tree.first; te; te = te->next) {
- int retval = do_outliner_operation_event(C, region, space_outliner, te, fmval);
- if (retval) {
- return retval;
- }
+ TreeElement *hovered_te = outliner_find_item_at_y(
+ space_outliner, &space_outliner->tree, view_mval[1]);
+ if (!hovered_te) {
+ /* Let this fall through to 'OUTLINER_MT_context_menu'. */
+ return OPERATOR_PASS_THROUGH;
}
- /* Let this fall through to 'OUTLINER_MT_context_menu'. */
- return OPERATOR_PASS_THROUGH;
+ return do_outliner_operation_event(C, op->reports, region, space_outliner, hovered_te);
}
/* Menu only! Calls other operators */
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 6a63c3c65c3..2ed834a15dd 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -314,7 +314,7 @@ static SpaceLink *outliner_create(const ScrArea *UNUSED(area), const Scene *UNUS
space_outliner->show_restrict_flags = SO_RESTRICT_ENABLE | SO_RESTRICT_HIDE;
space_outliner->outlinevis = SO_VIEW_LAYER;
space_outliner->sync_select_dirty |= WM_OUTLINER_SYNC_SELECT_FROM_ALL;
- space_outliner->flag |= SO_SYNC_SELECT;
+ space_outliner->flag = SO_SYNC_SELECT | SO_MODE_COLUMN;
/* header */
region = MEM_callocN(sizeof(ARegion), "header for outliner");