2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * The Original Code is Copyright (C) 2008 Blender Foundation.
17 * All rights reserved.
25 #ifndef __OUTLINER_INTERN_H__
26 #define __OUTLINER_INTERN_H__
28 #include "RNA_types.h"
30 /* internal exports only */
46 struct wmOperatorType;
48 typedef enum TreeElementInsertType {
52 } TreeElementInsertType;
54 typedef enum TreeTraversalAction {
55 /* Continue traversal regularly, don't skip children. */
56 TRAVERSE_CONTINUE = 0,
59 /* Continue traversal, but skip childs of traversed element */
61 } TreeTraversalAction;
63 typedef TreeTraversalAction (*TreeTraversalFunc)(struct TreeElement *te, void *customdata);
66 typedef struct TreeElement {
67 struct TreeElement *next, *prev, *parent;
69 int xs, ys; // do selection
70 TreeStoreElem *store_elem; // element in tree store
71 short flag; // flag for non-saved stuff
72 short index; // index for data arrays
73 short idcode; // from TreeStore id
74 short xend; // width of item display, for select
76 void *directdata; // Armature Bones, Base, Sequence, Strip...
77 PointerRNA rnaptr; // RNA Pointer
80 typedef struct TreeElementIcon {
81 struct ID *drag_id, *drag_parent;
85 #define TREESTORE_ID_TYPE(_id) \
86 (ELEM(GS((_id)->name), ID_SCE, ID_LI, ID_OB, ID_ME, ID_CU, ID_MB, ID_NT, ID_MA, ID_TE, ID_IM, ID_LT, ID_LA, ID_CA) || \
87 ELEM(GS((_id)->name), ID_KE, ID_WO, ID_SPK, ID_GR, ID_AR, ID_AC, ID_BR, ID_PA, ID_GD, ID_LS, ID_LP) || \
88 /* Only in 'blendfile' mode ... :/ */ \
89 ELEM(GS((_id)->name), ID_SCR, ID_WM, ID_TXT, ID_VF, ID_SO, ID_CF, ID_PAL, ID_MC, ID_WS, ID_MSK))
91 /* TreeElement->flag */
94 /* Closed items display their children as icon within the row. TE_ICONROW is for
95 * these child-items that are visible but only within the row of the closed parent. */
96 TE_ICONROW = (1 << 1),
97 TE_LAZY_CLOSED = (1 << 2),
98 TE_FREE_NAME = (1 << 3),
99 TE_DISABLED = (1 << 4),
100 TE_DRAGGING = (1 << 5),
104 #define OL_NAMEBUTTON 1
107 OL_DRAWSEL_NONE = 0, /* inactive (regular black text) */
108 OL_DRAWSEL_NORMAL = 1, /* active object (draws white text) */
109 OL_DRAWSEL_ACTIVE = 2, /* active obdata (draws a circle around the icon) */
113 OL_SETSEL_NONE = 0, /* don't change the selection state */
114 OL_SETSEL_NORMAL = 1, /* select the item */
115 OL_SETSEL_EXTEND = 2, /* select the item and extend (also toggles selection) */
118 /* get TreeStoreElem associated with a TreeElement
119 * < a: (TreeElement) tree element to find stored element for
121 #define TREESTORE(a) ((a)->store_elem)
124 #define OL_Y_OFFSET 2
126 #define OL_TOG_RESTRICT_SELECTX (UI_UNIT_X * 3.0f + V2D_SCROLL_WIDTH)
127 #define OL_TOG_RESTRICT_VIEWX (UI_UNIT_X * 2.0f + V2D_SCROLL_WIDTH)
128 #define OL_TOG_RESTRICT_RENDERX (UI_UNIT_X + V2D_SCROLL_WIDTH)
130 #define OL_TOGW OL_TOG_RESTRICT_SELECTX
132 #define OL_RNA_COLX (UI_UNIT_X * 15)
133 #define OL_RNA_COL_SIZEX (UI_UNIT_X * 7.5f)
134 #define OL_RNA_COL_SPACEX (UI_UNIT_X * 2.5f)
136 /* The outliner display modes that support the filter system.
137 * Note: keep it synced with space_outliner.py */
138 #define SUPPORT_FILTER_OUTLINER(soops_) (ELEM((soops_)->outlinevis, SO_VIEW_LAYER))
140 /* Outliner Searching --
142 * Are we looking for something in the outliner?
143 * If so finding matches in child items makes it more useful
145 * - We want to flag parents to act as being open to filter child matches
146 * - and also flag matches so we can highlight them
147 * - Flags are stored in TreeStoreElem->flag
148 * - Flag options defined in DNA_outliner_types.h
149 * - SO_SEARCH_RECURSIVE defined in DNA_space_types.h
151 * - NOT in datablocks view - searching all datablocks takes way too long
153 * - not searching into RNA items helps but isn't the complete solution
156 #define SEARCHING_OUTLINER(sov) (sov->search_flags & SO_SEARCH_RECURSIVE)
158 /* is the current element open? if so we also show children */
159 #define TSELEM_OPEN(telm, sv) ( (telm->flag & TSE_CLOSED) == 0 || (SEARCHING_OUTLINER(sv) && (telm->flag & TSE_CHILDSEARCH)) )
161 /* outliner_tree.c ----------------------------------------------- */
163 void outliner_free_tree(ListBase *tree);
164 void outliner_cleanup_tree(struct SpaceOutliner *soops);
165 void outliner_free_tree_element(TreeElement *element, ListBase *parent_subtree);
167 void outliner_build_tree(
168 struct Main *mainvar,
169 struct Scene *scene, struct ViewLayer *view_layer,
170 struct SpaceOutliner *soops, struct ARegion *ar);
172 typedef struct IDsSelectedData {
173 struct ListBase selected_array;
176 TreeTraversalAction outliner_find_selected_collections(struct TreeElement *te, void *customdata);
177 TreeTraversalAction outliner_find_selected_objects(struct TreeElement *te, void *customdata);
179 /* outliner_draw.c ---------------------------------------------- */
181 void draw_outliner(const struct bContext *C);
183 TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te);
185 /* outliner_select.c -------------------------------------------- */
186 eOLDrawState tree_element_type_active(
187 struct bContext *C, struct Scene *scene, struct ViewLayer *view_layer, struct SpaceOutliner *soops,
188 TreeElement *te, TreeStoreElem *tselem, const eOLSetState set, bool recursive);
189 eOLDrawState tree_element_active(struct bContext *C, struct Scene *scene, struct ViewLayer *view_layer, SpaceOutliner *soops,
190 TreeElement *te, const eOLSetState set, const bool handle_all_types);
192 void outliner_item_do_activate_from_tree_element(
193 struct bContext *C, TreeElement *te, TreeStoreElem *tselem,
194 bool extend, bool recursive);
195 int outliner_item_do_activate_from_cursor(
196 struct bContext *C, const int mval[2],
197 bool extend, bool recursive);
199 void outliner_item_select(
200 struct SpaceOutliner *soops, const struct TreeElement *te,
201 const bool extend, const bool toggle);
203 void outliner_object_mode_toggle(
204 struct bContext *C, Scene *scene, ViewLayer *view_layer,
207 /* outliner_edit.c ---------------------------------------------- */
208 typedef void (*outliner_operation_cb)(
209 struct bContext *C, struct ReportList *, struct Scene *scene,
210 struct TreeElement *, struct TreeStoreElem *, TreeStoreElem *, void *);
212 void outliner_do_object_operation_ex(
213 struct bContext *C, struct ReportList *reports, struct Scene *scene, struct SpaceOutliner *soops,
214 struct ListBase *lb, outliner_operation_cb operation_cb, void *user_data, bool recurse_selected);
215 void outliner_do_object_operation(
216 struct bContext *C, struct ReportList *reports, struct Scene *scene, struct SpaceOutliner *soops,
217 struct ListBase *lb, outliner_operation_cb operation_cb);
219 int common_restrict_check(struct bContext *C, struct Object *ob);
221 int outliner_flag_is_any_test(ListBase *lb, short flag, const int curlevel);
222 bool outliner_flag_set(ListBase *lb, short flag, short set);
223 bool outliner_flag_flip(ListBase *lb, short flag);
226 struct bContext *C, struct ReportList *reports, struct Scene *scene,
227 TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem, void *user_data);
228 void lib_relocate_cb(
229 struct bContext *C, struct ReportList *reports, struct Scene *scene, struct TreeElement *te,
230 struct TreeStoreElem *tsep, struct TreeStoreElem *tselem, void *user_data);
232 struct bContext *C, struct ReportList *reports, struct Scene *scene, struct TreeElement *te,
233 struct TreeStoreElem *tsep, struct TreeStoreElem *tselem, void *user_data);
236 struct bContext *C, struct ReportList *reports, struct Scene *scene, struct TreeElement *te,
237 struct TreeStoreElem *tsep, struct TreeStoreElem *tselem, void *user_data);
239 struct bContext *C, struct ReportList *reports, struct Scene *scene, struct TreeElement *te,
240 struct TreeStoreElem *tsep, struct TreeStoreElem *tselem, void *user_data);
242 void item_object_mode_enter_cb(
243 struct bContext *C, struct ReportList *reports, struct Scene *scene,
244 TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem, void *user_data);
245 void item_object_mode_exit_cb(
246 struct bContext *C, struct ReportList *reports, struct Scene *scene,
247 TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem, void *user_data);
249 void outliner_set_coordinates(struct ARegion *ar, struct SpaceOutliner *soops);
251 /* outliner_dragdrop.c */
252 void outliner_dropboxes(void);
254 void OUTLINER_OT_item_drag_drop(struct wmOperatorType *ot);
255 void OUTLINER_OT_parent_drop(struct wmOperatorType *ot);
256 void OUTLINER_OT_parent_clear(struct wmOperatorType *ot);
257 void OUTLINER_OT_scene_drop(struct wmOperatorType *ot);
258 void OUTLINER_OT_material_drop(struct wmOperatorType *ot);
259 void OUTLINER_OT_collection_drop(struct wmOperatorType *ot);
261 /* ...................................................... */
263 void OUTLINER_OT_highlight_update(struct wmOperatorType *ot);
265 void OUTLINER_OT_item_activate(struct wmOperatorType *ot);
266 void OUTLINER_OT_item_openclose(struct wmOperatorType *ot);
267 void OUTLINER_OT_item_rename(struct wmOperatorType *ot);
268 void OUTLINER_OT_lib_relocate(struct wmOperatorType *ot);
269 void OUTLINER_OT_lib_reload(struct wmOperatorType *ot);
271 void OUTLINER_OT_id_delete(struct wmOperatorType *ot);
273 void OUTLINER_OT_show_one_level(struct wmOperatorType *ot);
274 void OUTLINER_OT_show_active(struct wmOperatorType *ot);
275 void OUTLINER_OT_show_hierarchy(struct wmOperatorType *ot);
277 void OUTLINER_OT_select_box(struct wmOperatorType *ot);
279 void OUTLINER_OT_select_all(struct wmOperatorType *ot);
280 void OUTLINER_OT_expanded_toggle(struct wmOperatorType *ot);
282 void OUTLINER_OT_scroll_page(struct wmOperatorType *ot);
284 void OUTLINER_OT_keyingset_add_selected(struct wmOperatorType *ot);
285 void OUTLINER_OT_keyingset_remove_selected(struct wmOperatorType *ot);
287 void OUTLINER_OT_drivers_add_selected(struct wmOperatorType *ot);
288 void OUTLINER_OT_drivers_delete_selected(struct wmOperatorType *ot);
290 void OUTLINER_OT_orphans_purge(struct wmOperatorType *ot);
292 /* outliner_tools.c ---------------------------------------------- */
294 void OUTLINER_OT_operation(struct wmOperatorType *ot);
295 void OUTLINER_OT_scene_operation(struct wmOperatorType *ot);
296 void OUTLINER_OT_object_operation(struct wmOperatorType *ot);
297 void OUTLINER_OT_lib_operation(struct wmOperatorType *ot);
298 void OUTLINER_OT_id_operation(struct wmOperatorType *ot);
299 void OUTLINER_OT_id_remap(struct wmOperatorType *ot);
300 void OUTLINER_OT_data_operation(struct wmOperatorType *ot);
301 void OUTLINER_OT_animdata_operation(struct wmOperatorType *ot);
302 void OUTLINER_OT_action_set(struct wmOperatorType *ot);
303 void OUTLINER_OT_constraint_operation(struct wmOperatorType *ot);
304 void OUTLINER_OT_modifier_operation(struct wmOperatorType *ot);
306 /* ---------------------------------------------------------------- */
309 void outliner_operatortypes(void);
310 void outliner_keymap(struct wmKeyConfig *keyconf);
312 /* outliner_collections.c */
314 bool outliner_is_collection_tree_element(const TreeElement *te);
315 struct Collection *outliner_collection_from_tree_element(const TreeElement *te);
317 void OUTLINER_OT_collection_new(struct wmOperatorType *ot);
318 void OUTLINER_OT_collection_duplicate(struct wmOperatorType *ot);
319 void OUTLINER_OT_collection_delete(struct wmOperatorType *ot);
320 void OUTLINER_OT_collection_objects_select(struct wmOperatorType *ot);
321 void OUTLINER_OT_collection_objects_deselect(struct wmOperatorType *ot);
322 void OUTLINER_OT_collection_link(struct wmOperatorType *ot);
323 void OUTLINER_OT_collection_instance(struct wmOperatorType *ot);
324 void OUTLINER_OT_collection_exclude_set(struct wmOperatorType *ot);
325 void OUTLINER_OT_collection_exclude_clear(struct wmOperatorType *ot);
326 void OUTLINER_OT_collection_holdout_set(struct wmOperatorType *ot);
327 void OUTLINER_OT_collection_holdout_clear(struct wmOperatorType *ot);
328 void OUTLINER_OT_collection_indirect_only_set(struct wmOperatorType *ot);
329 void OUTLINER_OT_collection_indirect_only_clear(struct wmOperatorType *ot);
331 void OUTLINER_OT_collection_isolate(struct wmOperatorType *ot);
332 void OUTLINER_OT_collection_show(struct wmOperatorType *ot);
333 void OUTLINER_OT_collection_hide(struct wmOperatorType *ot);
334 void OUTLINER_OT_collection_show_inside(struct wmOperatorType *ot);
335 void OUTLINER_OT_collection_hide_inside(struct wmOperatorType *ot);
336 void OUTLINER_OT_collection_enable(struct wmOperatorType *ot);
337 void OUTLINER_OT_collection_disable(struct wmOperatorType *ot);
338 void OUTLINER_OT_collection_enable_render(struct wmOperatorType *ot);
339 void OUTLINER_OT_collection_disable_render(struct wmOperatorType *ot);
340 void OUTLINER_OT_hide(struct wmOperatorType *ot);
341 void OUTLINER_OT_unhide_all(struct wmOperatorType *ot);
343 /* outliner_utils.c ---------------------------------------------- */
345 TreeElement *outliner_find_item_at_y(const SpaceOutliner *soops, const ListBase *tree, float view_co_y);
346 TreeElement *outliner_find_item_at_x_in_row(const SpaceOutliner *soops, const TreeElement *parent_te, float view_co_x);
347 TreeElement *outliner_find_tse(struct SpaceOutliner *soops, const TreeStoreElem *tse);
348 TreeElement *outliner_find_tree_element(ListBase *lb, const TreeStoreElem *store_elem);
349 TreeElement *outliner_find_parent_element(ListBase *lb, TreeElement *parent_te, const TreeElement *child_te);
350 TreeElement *outliner_find_id(struct SpaceOutliner *soops, ListBase *lb, const struct ID *id);
351 TreeElement *outliner_find_posechannel(ListBase *lb, const struct bPoseChannel *pchan);
352 TreeElement *outliner_find_editbone(ListBase *lb, const struct EditBone *ebone);
353 struct ID *outliner_search_back(SpaceOutliner *soops, TreeElement *te, short idcode);
354 bool outliner_tree_traverse(const SpaceOutliner *soops, ListBase *tree, int filter_te_flag, int filter_tselem_flag,
355 TreeTraversalFunc func, void *customdata);
358 #endif /* __OUTLINER_INTERN_H__ */