diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-01-31 16:03:00 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-01-31 16:03:00 +0300 |
commit | 481785f1536a944b64febe7cfc1dbe5bb437eb40 (patch) | |
tree | dd7a7c7ce215743df4a93b17a25c228d632368df /source/blender | |
parent | 581b0c9a4f80bb56e25622da3e526e7be24ea68a (diff) | |
parent | a6191d0e2713bd26fc34eb9a5d0f492eb9eed7a4 (diff) |
Merge branch 'render-layers' of git.blender.org:blender into clay-engine
Diffstat (limited to 'source/blender')
38 files changed, 890 insertions, 19 deletions
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index 649d142d1cd..2fd11746fb0 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -40,6 +40,7 @@ extern "C" { struct ARegion; struct bScreen; struct CacheFile; +struct LayerCollection; struct ListBase; struct Main; struct Object; @@ -169,6 +170,7 @@ struct SpaceAction *CTX_wm_space_action(const bContext *C); struct SpaceInfo *CTX_wm_space_info(const bContext *C); struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C); struct SpaceClip *CTX_wm_space_clip(const bContext *C); +struct SpaceCollections *CTX_wm_space_collections(const bContext *C); void CTX_wm_manager_set(bContext *C, struct wmWindowManager *wm); void CTX_wm_window_set(bContext *C, struct wmWindow *win); @@ -242,6 +244,7 @@ int ctx_data_list_count(const bContext *C, int (*func)(const bContext *, ListBas struct Main *CTX_data_main(const bContext *C); struct Scene *CTX_data_scene(const bContext *C); +struct LayerCollection *CTX_data_layer_collection(const bContext *C); struct SceneCollection *CTX_data_scene_collection(const bContext *C); struct SceneLayer *CTX_data_scene_layer(const bContext *C); struct ToolSettings *CTX_data_tool_settings(const bContext *C); diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h index ff5b16f2081..48e1f9e24c6 100644 --- a/source/blender/blenkernel/BKE_layer.h +++ b/source/blender/blenkernel/BKE_layer.h @@ -38,6 +38,7 @@ extern "C" { #define TODO_LAYER_OVERRIDE /* CollectionOverride */ #define TODO_LAYER_CONTEXT /* get/set current (context) SceneLayer */ #define TODO_LAYER_BASE /* Base to ObjectBase related TODO */ +#define TODO_LAYER_OPERATORS /* collection mamanger and property panel operators */ #define TODO_LAYER /* generic todo */ struct LayerCollection; diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index c7ff70e4047..f374ebd1e53 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -50,8 +50,16 @@ */ SceneCollection *BKE_collection_add(Scene *scene, SceneCollection *sc_parent, const char *name) { - SceneCollection *sc = MEM_callocN(sizeof(SceneCollection), "New Collection"); SceneCollection *sc_master = BKE_collection_master(scene); + SceneCollection *sc = MEM_callocN(sizeof(SceneCollection), "New Collection"); + + if (!name) { + name = DATA_("New Collection"); + } + + if (!sc_parent) { + sc_parent = sc_master; + } BLI_strncpy(sc->name, name, sizeof(sc->name)); BLI_uniquename(&sc_master->scene_collections, sc, DATA_("Collection"), '.', offsetof(SceneCollection, name), sizeof(sc->name)); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 8025732efe5..afc4a397d07 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -815,6 +815,14 @@ struct SpaceClip *CTX_wm_space_clip(const bContext *C) return NULL; } +struct SpaceCollections *CTX_wm_space_collections(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype == SPACE_COLLECTIONS) + return sa->spacedata.first; + return NULL; +} + void CTX_wm_manager_set(bContext *C, wmWindowManager *wm) { C->wm.manager = wm; @@ -920,20 +928,38 @@ SceneLayer *CTX_data_scene_layer(const bContext *C) * If the scene_collection is linked to the SceneLayer we use it. * Otherwise we fallback to the active one of the SceneLayer. */ -SceneCollection *CTX_data_scene_collection(const bContext *C) +LayerCollection *CTX_data_layer_collection(const bContext *C) { SceneLayer *sl = CTX_data_scene_layer(C); - SceneCollection *sc; + LayerCollection *lc; + + if (ctx_data_pointer_verify(C, "layer_collection", (void *)&lc)) { + if (BKE_scene_layer_has_collection(sl, lc->scene_collection)) { + return lc; + } + } + /* fallback */ + return BKE_layer_collection_active(sl); +} + +SceneCollection *CTX_data_scene_collection(const bContext *C) +{ + SceneCollection *sc; if (ctx_data_pointer_verify(C, "scene_collection", (void *)&sc)) { - if (BKE_scene_layer_has_collection(sl, sc)) { + if (BKE_scene_layer_has_collection(CTX_data_scene_layer(C), sc)) { return sc; } } + LayerCollection *lc = CTX_data_layer_collection(C); + if (lc) { + return lc->scene_collection; + } + /* fallback */ - LayerCollection *lc = BKE_layer_collection_active(sl); - return lc->scene_collection; + Scene *scene = CTX_data_scene(C); + return BKE_collection_master(scene); } int CTX_data_mode_enum(const bContext *C) diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index bb013b4aa46..39b00531222 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -30,6 +30,7 @@ #include "BLI_string_utils.h" #include "BLT_translation.h" +#include "BKE_layer.h" #include "BKE_collection.h" #include "BKE_layer.h" #include "BKE_main.h" @@ -395,6 +396,7 @@ int BKE_layer_collection_findindex(SceneLayer *sl, LayerCollection *lc) LayerCollection *BKE_collection_link(SceneLayer *sl, SceneCollection *sc) { LayerCollection *lc = layer_collection_add(sl, &sl->layer_collections, sc); + sl->active_collection = BKE_layer_collection_findindex(sl, lc); return lc; } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 51c28fed11a..134ce910dcf 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -103,6 +103,8 @@ #include "DNA_movieclip_types.h" #include "DNA_mask_types.h" +#include "RNA_access.h" + #include "MEM_guardedalloc.h" #include "BLI_endian_switch.h" @@ -6567,6 +6569,10 @@ static void lib_link_screen(FileData *fd, Main *main) slogic->gpd = newlibadr_us(fd, sc->id.lib, slogic->gpd); } + else if (sl->spacetype == SPACE_COLLECTIONS) { + SpaceCollections *slayer = (SpaceCollections *)sl; + slayer->flag |= SC_COLLECTION_DATA_REFRESH; + } } } sc->id.tag &= ~LIB_TAG_NEED_LINK; @@ -6952,6 +6958,10 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc slogic->gpd = restore_pointer_by_name(id_map, (ID *)slogic->gpd, USER_REAL); } + else if (sl->spacetype == SPACE_COLLECTIONS) { + SpaceCollections *slayer = (SpaceCollections *)sl; + slayer->flag |= SC_COLLECTION_DATA_REFRESH; + } } } } @@ -7346,6 +7356,10 @@ static bool direct_link_screen(FileData *fd, bScreen *sc) sclip->scopes.track_preview = NULL; sclip->scopes.ok = 0; } + else if (sl->spacetype == SPACE_COLLECTIONS) { + SpaceCollections *slayer = (SpaceCollections *)sl; + slayer->flag |= SC_COLLECTION_DATA_REFRESH; + } } BLI_listbase_clear(&sa->actionzones); diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 2df7fb3becd..e20e6a1f94f 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3235,6 +3235,9 @@ static void write_screens(WriteData *wd, ListBase *scrbase) else if (sl->spacetype == SPACE_INFO) { writestruct(wd, DATA, SpaceInfo, 1, sl); } + else if (sl->spacetype == SPACE_COLLECTIONS) { + writestruct(wd, DATA, SpaceCollections, 1, sl); + } sl = sl->next; } diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index 1559512d713..7e804a5bbfc 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -47,6 +47,7 @@ if(WITH_BLENDER) add_subdirectory(space_graph) add_subdirectory(space_image) add_subdirectory(space_info) + add_subdirectory(space_collections) add_subdirectory(space_logic) add_subdirectory(space_nla) add_subdirectory(space_node) diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index 35d38bf4ca1..96532f748e4 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -49,6 +49,7 @@ struct ColorManagedDisplaySettings; void fdrawline(float x1, float y1, float x2, float y2); /* DEPRECATED */ void fdrawbox(float x1, float y1, float x2, float y2); /* DEPRECATED */ +void fdrawbox_filled(float x1, float y1, float x2, float y2); void sdrawline(int x1, int y1, int x2, int y2); /* DEPRECATED */ void sdrawbox(int x1, int y1, int x2, int y2); /* DEPRECATED */ diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 40112bc20fc..c1c0463ee5a 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -55,6 +55,7 @@ struct wmOperatorType; struct PointerRNA; struct PropertyRNA; struct EnumPropertyItem; +struct LayerTree; /* object_edit.c */ struct Object *ED_object_context(struct bContext *C); /* context.object */ diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index f5f66a07aea..01be63919be 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -162,6 +162,7 @@ int ED_operator_image_active(struct bContext *C); int ED_operator_nla_active(struct bContext *C); int ED_operator_logic_active(struct bContext *C); int ED_operator_info_active(struct bContext *C); +int ED_operator_collections_active(struct bContext *C); int ED_operator_console_active(struct bContext *C); diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h index d268c578cf2..b754e1ba20f 100644 --- a/source/blender/editors/include/ED_space_api.h +++ b/source/blender/editors/include/ED_space_api.h @@ -58,6 +58,7 @@ void ED_spacetype_logic(void); void ED_spacetype_console(void); void ED_spacetype_userpref(void); void ED_spacetype_clip(void); +void ED_spacetype_collections(void); /* calls for instancing and freeing spacetype static data * called in WM_init_exit */ diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index d48cfbee413..55f11b94eb2 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -212,6 +212,9 @@ enum { UI_BUT_ALIGN_STITCH_TOP = (1 << 18), UI_BUT_ALIGN_STITCH_LEFT = (1 << 19), UI_BUT_ALIGN_ALL = (UI_BUT_ALIGN | UI_BUT_ALIGN_STITCH_TOP | UI_BUT_ALIGN_STITCH_LEFT), + + /* Another hack, in some rare cases we don't want any text margin */ + UI_BUT_TEXT_NO_MARGIN = (1 << 20), }; /* scale fixed button widths by this to account for DPI */ diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h index 945ac1b6db9..f08c46af8a6 100644 --- a/source/blender/editors/include/UI_interface_icons.h +++ b/source/blender/editors/include/UI_interface_icons.h @@ -83,5 +83,6 @@ 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_colorset_icon_get(const int set_idx); #endif /* __UI_INTERFACE_ICONS_H__ */ diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 0573e8d9c94..70bfd30c2d8 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -1385,6 +1385,14 @@ int UI_idcode_icon_get(const int idcode) } } +/** + * \param set_idx: A value from #rna_enum_color_sets_items. + */ +int UI_colorset_icon_get(const int set_idx) +{ + return (set_idx < 1) ? ICON_NONE : VICO_COLORSET_01_VEC - 1 + set_idx; +} + static void icon_draw_at_size( float x, float y, int icon_id, float aspect, float alpha, enum eIconSizes size, const bool nocreate) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index b75ecf68136..9dd6c670da8 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1575,7 +1575,10 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB } } - if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) { + if (but->drawflag & UI_BUT_TEXT_NO_MARGIN) { + /* skip */ + } + else if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) { rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; } else if ((but->drawflag & UI_BUT_TEXT_RIGHT)) { diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 999556025db..ea72a4aa25b 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -165,6 +165,9 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo case SPACE_CLIP: ts = &btheme->tclip; break; + case SPACE_COLLECTIONS: + ts = &btheme->tcollections; + break; default: ts = &btheme->tv3d; break; @@ -1206,6 +1209,11 @@ void ui_theme_init_default(void) rgba_char_args_set(btheme->tclip.strip_select, 0xff, 0x8c, 0x00, 0xff); btheme->tclip.handle_vertex_size = 5; ui_theme_space_init_handles_color(&btheme->tclip); + + /* space collection manager */ + btheme->tcollections = btheme->tv3d; + rgba_char_args_set_fl(btheme->tcollections.back, 0.42, 0.42, 0.42, 1.0); + rgba_char_args_set(btheme->tcollections.hilite, 255, 140, 25, 255); /* selected files */ } void ui_style_init_default(void) @@ -2834,7 +2842,11 @@ void init_userdef_do_versions(void) * (keep this block even if it becomes empty). */ { - + for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { + btheme->tcollections = btheme->tv3d; + rgba_char_args_set_fl(btheme->tcollections.back, 0.42, 0.42, 0.42, 1.0); + rgba_char_args_set(btheme->tcollections.hilite, 255, 140, 25, 255); /* selected files */ + } } if (U.pixelsize == 0.0f) diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index ef514dd5e84..f2933cfa935 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -75,6 +75,18 @@ void fdrawbox(float x1, float y1, float x2, float y2) glEnd(); } +void fdrawbox_filled(float x1, float y1, float x2, float y2) +{ + glBegin(GL_POLYGON); + + glVertex2f(x1, y1); + glVertex2f(x1, y2); + glVertex2f(x2, y2); + glVertex2f(x2, y1); + + glEnd(); +} + void fdrawcheckerboard(float x1, float y1, float x2, float y2) /* DEPRECATED */ { unsigned char col1[4] = {40, 40, 40}, col2[4] = {50, 50, 50}; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 32b63aca34c..a55d6c2143f 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -321,6 +321,10 @@ int ED_operator_info_active(bContext *C) return ed_spacetype_test(C, SPACE_INFO); } +int ED_operator_collections_active(bContext *C) +{ + return ed_spacetype_test(C, SPACE_COLLECTIONS); +} int ED_operator_console_active(bContext *C) { diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 5ff1d758563..8c278c0b3ae 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -96,6 +96,7 @@ void ED_spacetypes_init(void) ED_spacetype_console(); ED_spacetype_userpref(); ED_spacetype_clip(); + ED_spacetype_collections(); // ... /* register operator types for screen and all spaces */ diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index da3364d872d..8106e0cfddf 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -49,6 +49,7 @@ #include "BKE_context.h" #include "BKE_action.h" +#include "BKE_layer.h" #include "BKE_material.h" #include "BKE_modifier.h" #include "BKE_paint.h" @@ -553,6 +554,28 @@ static bool buttons_context_linestyle_pinnable(const bContext *C) } #endif +static int buttons_context_path_collection(const bContext *C, ButsContextPath *path) +{ + PointerRNA *ptr = &path->ptr[path->len - 1]; + + /* if we already have a (pinned) Collection, we're done */ + if (RNA_struct_is_a(ptr->type, &RNA_LayerCollection)) { + return 1; + } + + SceneLayer *sl = CTX_data_scene_layer(C); + LayerCollection *sc = BKE_layer_collection_active(sl); + + if (sc) { + RNA_pointer_create(NULL, &RNA_LayerCollection, sc, &path->ptr[path->len]); + path->len++; + return 1; + } + + /* no path to a collection possible */ + return 0; +} + static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag) { SpaceButs *sbuts = CTX_wm_space_buts(C); @@ -627,7 +650,10 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma case BCONTEXT_BONE_CONSTRAINT: found = buttons_context_path_pose_bone(path); break; - default: + case BCONTEXT_COLLECTION: + found = buttons_context_path_collection(C, path); + break; + default: found = 0; break; } @@ -744,7 +770,7 @@ const char *buttons_context_dir[] = { "texture", "texture_user", "texture_user_property", "bone", "edit_bone", "pose_bone", "particle_system", "particle_system_editable", "particle_settings", "cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint", - "line_style", NULL + "line_style", "collection", NULL }; int buttons_context(const bContext *C, const char *member, bContextDataResult *result) @@ -1064,6 +1090,10 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r set_pointer_type(path, result, &RNA_FreestyleLineStyle); return 1; } + else if (CTX_data_equals(member, "collection")) { + set_pointer_type(path, result, &RNA_LayerCollection); + return 1; + } else { return 0; /* not found */ } diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index e4c23ad74f8..608287939bd 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -171,6 +171,8 @@ static void buttons_main_region_draw(const bContext *C, ARegion *ar) ED_region_panels(C, ar, "constraint", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_BONE_CONSTRAINT) ED_region_panels(C, ar, "bone_constraint", sbuts->mainb, vertical); + else if (sbuts->mainb == BCONTEXT_COLLECTION) + ED_region_panels(C, ar, "collection", sbuts->mainb, vertical); sbuts->re_align = 0; sbuts->mainbo = sbuts->mainb; diff --git a/source/blender/editors/space_collections/CMakeLists.txt b/source/blender/editors/space_collections/CMakeLists.txt new file mode 100644 index 00000000000..1cc4a40d657 --- /dev/null +++ b/source/blender/editors/space_collections/CMakeLists.txt @@ -0,0 +1,45 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributor(s): Jacques Beaurain. +# +# ***** END GPL LICENSE BLOCK ***** + +set(INC + ../include + ../../blenkernel + ../../blenlib + ../../blentranslation + ../../gpu + ../../makesdna + ../../makesrna + ../../windowmanager + ../../../../intern/guardedalloc + ../../../../intern/glew-mx +) + +set(INC_SYS + ${GLEW_INCLUDE_PATH} +) + +set(SRC + collections_ops.c + space_collections.c + + collections_intern.h +) + +blender_add_lib(bf_editor_space_collections "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_collections/collections_intern.h b/source/blender/editors/space_collections/collections_intern.h new file mode 100644 index 00000000000..866f59659c3 --- /dev/null +++ b/source/blender/editors/space_collections/collections_intern.h @@ -0,0 +1,35 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_collections/collections_intern.h + * \ingroup spcollections + */ + +#ifndef __COLLECTIONS_INTERN_H__ +#define __COLLECTIONS_INTERN_H__ + +struct wmKeyConfig; + +/* collections_ops.c */ +void collections_operatortypes(void); +void collections_keymap(struct wmKeyConfig *keyconf); + +#endif /* __COLLECTIONS_INTERN_H__ */ + diff --git a/source/blender/editors/space_collections/collections_ops.c b/source/blender/editors/space_collections/collections_ops.c new file mode 100644 index 00000000000..7e1bf8091b0 --- /dev/null +++ b/source/blender/editors/space_collections/collections_ops.c @@ -0,0 +1,340 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_collections/collections_ops.c + * \ingroup spcollections + */ + +#include "BKE_context.h" +#include "BKE_layer.h" +#include "BKE_report.h" + +#include "ED_screen.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "collections_intern.h" /* own include */ + +/* -------------------------------------------------------------------- */ +/* polls */ + +static SceneCollection *collection_manager_collection_active(bContext *C) +{ + TODO_LAYER_OPERATORS; + /* consider that we may have overrides active + * leading to no active collections */ + return CTX_data_scene_collection(C); +} + +static int operator_not_master_collection_active(bContext *C) +{ + SceneCollection *sc = collection_manager_collection_active(C); + if (sc == NULL) { + return 1; + } + + return (sc == BKE_collection_master(CTX_data_scene(C))) ? 0 : 1; +} + +static int operator_top_collection_active(bContext *C) +{ + SceneCollection *sc = collection_manager_collection_active(C); + if (sc == NULL) { + return 0; + } + + TODO_LAYER_OPERATORS; + /* see if it's a top collection */ + return 1; +} + +static int operator_collection_active(bContext *C) +{ + return collection_manager_collection_active(C) ? 1 : 0; +} + +/* -------------------------------------------------------------------- */ +/* collection manager operators */ + +static int collection_link_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event)) +{ + TODO_LAYER_OPERATORS; + BKE_report(op->reports, RPT_ERROR, "COLLECTIONS_OT_collection_link not implemented yet"); + return OPERATOR_CANCELLED; +} + +static void COLLECTIONS_OT_collection_link(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Add Collection"; + ot->idname = "COLLECTIONS_OT_collection_link"; + ot->description = "Link a new collection to the active layer"; + + /* api callbacks */ + ot->invoke = collection_link_invoke; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +static int collection_unlink_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event)) +{ + TODO_LAYER_OPERATORS; + BKE_report(op->reports, RPT_ERROR, "COLLECTIONS_OT_collection_unlink not implemented yet"); + return OPERATOR_CANCELLED; +} + +static void COLLECTIONS_OT_collection_unlink(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Add Collection"; + ot->idname = "COLLECTIONS_OT_collection_unlink"; + ot->description = "Link a new collection to the active layer"; + + /* api callbacks */ + ot->invoke = collection_unlink_invoke; + ot->poll = operator_top_collection_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +static int collection_new_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + SceneLayer *sl = CTX_data_scene_layer(C); + + SceneCollection *sc = BKE_collection_add(scene, NULL, NULL); + BKE_collection_link(sl, sc); + + WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); + return OPERATOR_FINISHED; +} + +static void COLLECTIONS_OT_collection_new(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "New Collection"; + ot->idname = "COLLECTIONS_OT_collection_new"; + ot->description = "Add a new collection to the scene, and link it to the active layer"; + + /* api callbacks */ + ot->exec = collection_new_exec; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +static int override_new_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event)) +{ + TODO_LAYER_OPERATORS; + TODO_LAYER_OVERRIDE; + BKE_report(op->reports, RPT_ERROR, "COLLECTIONS_OT_override_new not implemented yet"); + return OPERATOR_CANCELLED; +} + +static void COLLECTIONS_OT_override_new(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "New Override"; + ot->idname = "COLLECTIONS_OT_override_new"; + ot->description = "Add a new override to the active collection"; + + /* api callbacks */ + ot->invoke = override_new_invoke; + ot->poll = operator_collection_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +static int delete_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event)) +{ + TODO_LAYER_OPERATORS; + BKE_report(op->reports, RPT_ERROR, "COLLECTIONS_OT_delete not implemented yet"); + return OPERATOR_CANCELLED; +} + +static void COLLECTIONS_OT_delete(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Delete"; + ot->idname = "COLLECTIONS_OT_delete"; + ot->description = "Delete active override or collection"; + + /* api callbacks */ + ot->invoke = delete_invoke; + ot->poll = operator_not_master_collection_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +static int select_exec(bContext *C, wmOperator *op) +{ + SceneLayer *sl = CTX_data_scene_layer(C); + const int collection_index = RNA_int_get(op->ptr, "collection_index"); + sl->active_collection = collection_index; + WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); + return OPERATOR_FINISHED; +} + +static void COLLECTIONS_OT_select(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select"; + ot->idname = "COLLECTIONS_OT_select"; + ot->description = "Change active collection or override"; + + /* api callbacks */ + ot->exec = select_exec; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_int(ot->srna, "collection_index", 0, 0, INT_MAX, "Index", + "Index of collection to select", 0, INT_MAX); +} + +static int rename_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event)) +{ + TODO_LAYER_OPERATORS; + BKE_report(op->reports, RPT_ERROR, "COLLECTIONS_rename not implemented yet"); + return OPERATOR_CANCELLED; +} + +static void COLLECTIONS_OT_rename(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Rename"; + ot->idname = "COLLECTIONS_OT_rename"; + ot->description = "Rename active collection or override"; + + /* api callbacks */ + ot->invoke = rename_invoke; + ot->poll = operator_not_master_collection_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +/* -------------------------------------------------------------------- */ +/* property editor operators */ + +static int stubs_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event)) +{ + TODO_LAYER_OPERATORS; + BKE_report(op->reports, RPT_ERROR, "Operator not implemented yet"); + return OPERATOR_CANCELLED; +} + +static void COLLECTIONS_OT_objects_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Add Objects"; + ot->idname = "COLLECTIONS_OT_objects_add"; + ot->description = "Add selected objects to collection"; + + /* api callbacks */ + ot->invoke = stubs_invoke; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +static void COLLECTIONS_OT_objects_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Remove Object"; + ot->idname = "COLLECTIONS_OT_objects_remove"; + ot->description = "Remove object from collection"; + + /* api callbacks */ + ot->invoke = stubs_invoke; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +static void COLLECTIONS_OT_objects_select(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select Objects"; + ot->idname = "COLLECTIONS_OT_objects_select"; + ot->description = "Selected collection objects"; + + /* api callbacks */ + ot->invoke = stubs_invoke; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +static void COLLECTIONS_OT_objects_deselect(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Deselect Objects"; + ot->idname = "COLLECTIONS_OT_objects_deselect"; + ot->description = "Deselected collection objects"; + + /* api callbacks */ + ot->invoke = stubs_invoke; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +/* ************************** registration - operator types **********************************/ + +void collections_operatortypes(void) +{ + WM_operatortype_append(COLLECTIONS_OT_delete); + WM_operatortype_append(COLLECTIONS_OT_select); + WM_operatortype_append(COLLECTIONS_OT_rename); + WM_operatortype_append(COLLECTIONS_OT_collection_link); + WM_operatortype_append(COLLECTIONS_OT_collection_unlink); + WM_operatortype_append(COLLECTIONS_OT_collection_new); + WM_operatortype_append(COLLECTIONS_OT_override_new); + + WM_operatortype_append(COLLECTIONS_OT_objects_add); + WM_operatortype_append(COLLECTIONS_OT_objects_remove); + WM_operatortype_append(COLLECTIONS_OT_objects_select); + WM_operatortype_append(COLLECTIONS_OT_objects_deselect); +} + +void collections_keymap(wmKeyConfig *keyconf) +{ + wmKeyMap *keymap = WM_keymap_find(keyconf, "Collections Manager", SPACE_COLLECTIONS, 0); + + /* selection */ + WM_keymap_add_item(keymap, "COLLECTIONS_OT_select", LEFTMOUSE, KM_CLICK, 0, 0); + + WM_keymap_add_item(keymap, "COLLECTIONS_OT_rename", LEFTMOUSE, KM_DBL_CLICK, 0, 0); + WM_keymap_add_item(keymap, "COLLECTIONS_OT_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); + + WM_keymap_add_item(keymap, "COLLECTIONS_OT_collection_new", NKEY, KM_PRESS, KM_CTRL, 0); + + WM_keymap_add_item(keymap, "COLLECTIONS_OT_delete", XKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "COLLECTIONS_OT_delete", DELKEY, KM_PRESS, 0, 0); +} diff --git a/source/blender/editors/space_collections/space_collections.c b/source/blender/editors/space_collections/space_collections.c new file mode 100644 index 00000000000..7dd50e5cbac --- /dev/null +++ b/source/blender/editors/space_collections/space_collections.c @@ -0,0 +1,182 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_collections/space_collections.c + * \ingroup spcollections + */ + +#include <string.h> + +#include "MEM_guardedalloc.h" + +#include "BIF_gl.h" + +#include "BKE_context.h" +#include "BKE_screen.h" + +#include "BLI_ghash.h" +#include "BLI_listbase.h" + +#include "ED_screen.h" +#include "ED_space_api.h" + +#include "UI_resources.h" +#include "UI_view2d.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "collections_intern.h" /* own include */ + +/* ******************** default callbacks for collection manager space ***************** */ + +static SpaceLink *collections_new(const bContext *UNUSED(C)) +{ + ARegion *ar; + SpaceCollections *scollection; /* hmm, that's actually a good band name... */ + + scollection = MEM_callocN(sizeof(SpaceCollections), __func__); + scollection->spacetype = SPACE_COLLECTIONS; + + /* header */ + ar = MEM_callocN(sizeof(ARegion), "header for collection manager"); + BLI_addtail(&scollection->regionbase, ar); + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; + + /* main region */ + ar = MEM_callocN(sizeof(ARegion), "main region for collection manager"); + BLI_addtail(&scollection->regionbase, ar); + ar->regiontype = RGN_TYPE_WINDOW; + ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM | V2D_SCROLL_HORIZONTAL_HIDE | V2D_SCROLL_VERTICAL_HIDE); + ar->v2d.align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y); + + return (SpaceLink *)scollection; +} + +static void collections_free(SpaceLink *UNUSED(sl)) +{ +} + +static SpaceLink *collections_duplicate(SpaceLink *sl) +{ + SpaceCollections *scollection = MEM_dupallocN(sl); + + /* clear or remove stuff from old */ + + return (SpaceLink *)scollection; +} + +/* add handlers, stuff you only do once or on area/region changes */ +static void collection_main_region_init(wmWindowManager *wm, ARegion *ar) +{ + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); + ar->v2d.scroll |= (V2D_SCROLL_VERTICAL_FULLR | V2D_SCROLL_HORIZONTAL_FULLR); + + /* own keymap */ + wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Layer Manager", SPACE_COLLECTIONS, 0); + WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); +} + +static void collections_main_region_draw(const bContext *C, ARegion *ar) +{ + SpaceCollections *spc = CTX_wm_space_collections(C); + View2D *v2d = &ar->v2d; + + if (spc->flag & SC_COLLECTION_DATA_REFRESH) { + } + + /* v2d has initialized flag, so this call will only set the mask correct */ + UI_view2d_region_reinit(v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); + + UI_ThemeClearColor(TH_BACK); + glClear(GL_COLOR_BUFFER_BIT); + + /* reset view matrix */ + UI_view2d_view_restore(C); + + /* scrollers */ + View2DScrollers *scrollers; + scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + UI_view2d_scrollers_draw(C, v2d, scrollers); + UI_view2d_scrollers_free(scrollers); +} + +/* add handlers, stuff you only do once or on area/region changes */ +static void collections_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar) +{ + ED_region_header_init(ar); +} + +static void collections_header_region_draw(const bContext *C, ARegion *ar) +{ + ED_region_header(C, ar); +} + +static void collections_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) +{ + switch (wmn->category) { + case NC_SCENE: + if (wmn->data == ND_LAYER) { + ED_region_tag_redraw(ar); + } + break; + case NC_SPACE: + if (wmn->data == ND_SPACE_COLLECTIONS) { + ED_region_tag_redraw(ar); + } + } +} + +/* only called once, from space/spacetypes.c */ +void ED_spacetype_collections(void) +{ + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype collections"); + ARegionType *art; + + st->spaceid = SPACE_COLLECTIONS; + strncpy(st->name, "LayerManager", BKE_ST_MAXNAME); + + st->new = collections_new; + st->free = collections_free; + st->duplicate = collections_duplicate; + st->operatortypes = collections_operatortypes; + st->keymap = collections_keymap; + + /* regions: main window */ + art = MEM_callocN(sizeof(ARegionType), "spacetype collections region"); + art->regionid = RGN_TYPE_WINDOW; + art->init = collection_main_region_init; + art->draw = collections_main_region_draw; + art->listener = collections_main_region_listener; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; + BLI_addhead(&st->regiontypes, art); + + /* regions: header */ + art = MEM_callocN(sizeof(ARegionType), "spacetype collections header"); + art->regionid = RGN_TYPE_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; + art->init = collections_header_region_init; + art->draw = collections_header_region_draw; + BLI_addhead(&st->regiontypes, art); + + BKE_spacetype_register(st); +} diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 67e258669d6..cdb9900ee4d 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -373,11 +373,6 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) } if (obedit == NULL && v3d->localvd == NULL) { - unsigned int ob_lay = ob ? ob->lay : 0; - - /* Layers */ - uiTemplateLayers(layout, v3d->scenelock ? &sceneptr : &v3dptr, "layers", &v3dptr, "layers_used", ob_lay); - /* Scene lock */ uiItemR(layout, &v3dptr, "lock_camera_and_layers", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); } diff --git a/source/blender/makesdna/DNA_layer_types.h b/source/blender/makesdna/DNA_layer_types.h index d45334a227f..d725a56d826 100644 --- a/source/blender/makesdna/DNA_layer_types.h +++ b/source/blender/makesdna/DNA_layer_types.h @@ -73,6 +73,8 @@ typedef struct SceneCollection { struct SceneCollection *next, *prev; char name[64]; /* MAX_NAME */ char filter[64]; /* MAX_NAME */ + int active_object_index; /* for UI */ + int pad; ListBase objects; /* (Object *)LinkData->data */ ListBase filter_objects; /* (Object *)LinkData->data */ ListBase scene_collections; /* nested collections */ diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 5e015544dc9..14eb93e7f23 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -181,7 +181,8 @@ typedef enum eSpaceButtons_Context { BCONTEXT_CONSTRAINT = 11, BCONTEXT_BONE_CONSTRAINT = 12, BCONTEXT_RENDER_LAYER = 13, - + BCONTEXT_COLLECTION = 14, + /* always as last... */ BCONTEXT_TOT } eSpaceButtons_Context; @@ -1343,6 +1344,20 @@ typedef enum eSpaceClip_GPencil_Source { SC_GPENCIL_SRC_TRACK = 1, } eSpaceClip_GPencil_Source; +/* Collection Manager ======================================= */ + +typedef struct SpaceCollections { + SpaceLink *next, *prev; + ListBase regionbase; /* storage of regions for inactive spaces */ + int spacetype; + int flag; /* eSpaceCollections_Flag */ +} SpaceCollections; + +/* SpaceClip->flag */ +typedef enum eSpaceCollections_Flag { + SC_COLLECTION_DATA_REFRESH = (1 << 0), /* recreate/update SpaceCollections layer data, needed for undo/read/write */ +} eSpaceCollections_Flag; + /* **************** SPACE DEFINES ********************* */ /* space types, moved from DNA_screen_types.h */ @@ -1372,8 +1387,9 @@ typedef enum eSpace_Type { SPACE_CONSOLE = 18, SPACE_USERPREF = 19, SPACE_CLIP = 20, - - SPACEICONMAX = SPACE_CLIP + SPACE_COLLECTIONS = 21, + + SPACEICONMAX = SPACE_COLLECTIONS } eSpace_Type; /* use for function args */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 1dc6c7ab578..6cc24f74cee 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -390,7 +390,8 @@ typedef struct bTheme { ThemeSpace tuserpref; ThemeSpace tconsole; ThemeSpace tclip; - + ThemeSpace tcollections; + /* 20 sets of bone colors for this theme */ ThemeWireColor tarm[20]; /*ThemeWireColor tobj[20];*/ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 92c3c17cd96..d3b4c350487 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -317,6 +317,8 @@ extern StructRNA RNA_LaplacianSmoothModifier; extern StructRNA RNA_Lattice; extern StructRNA RNA_LatticeModifier; extern StructRNA RNA_LatticePoint; +extern StructRNA RNA_LayerCollection; +extern StructRNA RNA_LayerCollectionOverride; extern StructRNA RNA_Library; extern StructRNA RNA_LimitDistanceConstraint; extern StructRNA RNA_LimitLocationConstraint; @@ -578,6 +580,7 @@ extern StructRNA RNA_SpaceFileBrowser; extern StructRNA RNA_SpaceGraphEditor; extern StructRNA RNA_SpaceImageEditor; extern StructRNA RNA_SpaceInfo; +extern StructRNA RNA_SpaceCollectionManager; extern StructRNA RNA_SpaceLogicEditor; extern StructRNA RNA_SpaceNLA; extern StructRNA RNA_SpaceNodeEditor; @@ -646,6 +649,7 @@ extern StructRNA RNA_ThemeFontStyle; extern StructRNA RNA_ThemeGraphEditor; extern StructRNA RNA_ThemeImageEditor; extern StructRNA RNA_ThemeInfo; +extern StructRNA RNA_ThemeCollectionManager; extern StructRNA RNA_ThemeLogicEditor; extern StructRNA RNA_ThemeNLAEditor; extern StructRNA RNA_ThemeNodeEditor; diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index 9270cda0d2b..27e88f592ab 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -120,6 +120,13 @@ static PointerRNA rna_Context_scene_collection_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_SceneCollection, CTX_data_scene_collection(C)); } +static PointerRNA rna_Context_layer_collection_get(PointerRNA *ptr) +{ + bContext *C = (bContext *)ptr->data; + ptr->id.data = CTX_data_scene(C); + return rna_pointer_inherit_refine(ptr, &RNA_LayerCollection, CTX_data_layer_collection(C)); +} + static PointerRNA rna_Context_tool_settings_get(PointerRNA *ptr) { bContext *C = (bContext *)ptr->data; @@ -226,6 +233,11 @@ void RNA_def_context(BlenderRNA *brna) RNA_def_property_struct_type(prop, "SceneCollection"); RNA_def_property_pointer_funcs(prop, "rna_Context_scene_collection_get", NULL, NULL, NULL); + prop = RNA_def_property(srna, "layer_collection", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "LayerCollection"); + RNA_def_property_pointer_funcs(prop, "rna_Context_layer_collection_get", NULL, NULL, NULL); + prop = RNA_def_property(srna, "tool_settings", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "ToolSettings"); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index b18fd6dcbbd..b9ca9ea277b 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2295,6 +2295,26 @@ static void rna_SceneCollection_remove( WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); } +static int rna_SceneCollection_objects_active_index_get(PointerRNA *ptr) +{ + SceneCollection *sc = (SceneCollection *)ptr->data; + return sc->active_object_index; +} + +static void rna_SceneCollection_objects_active_index_set(PointerRNA *ptr, int value) +{ + SceneCollection *sc = (SceneCollection *)ptr->data; + sc->active_object_index = value; +} + +static void rna_SceneCollection_objects_active_index_range( + PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax)) +{ + SceneCollection *sc = (SceneCollection *)ptr->data; + *min = 0; + *max = max_ii(0, BLI_listbase_count(&sc->objects) - 1); +} + void rna_SceneCollection_object_link( ID *id, SceneCollection *sc, Main *bmain, ReportList *reports, Object *ob) { @@ -5542,12 +5562,20 @@ static void rna_def_collection_objects(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "CollectionObjects"); srna = RNA_def_struct(brna, "CollectionObjects", NULL); RNA_def_struct_sdna(srna, "SceneCollection"); RNA_def_struct_ui_text(srna, "Collection Objects", "Objects of a collection"); + prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_funcs(prop, "rna_SceneCollection_objects_active_index_get", + "rna_SceneCollection_objects_active_index_set", + "rna_SceneCollection_objects_active_index_range"); + RNA_def_property_ui_text(prop, "Active Object Index", "Active index in collection objects array"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL); + func = RNA_def_function(srna, "link", "rna_SceneCollection_object_link"); RNA_def_function_ui_description(func, "Link an object to collection"); RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS); @@ -5600,6 +5628,21 @@ static void rna_def_scene_collection(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Filter Objects", "All the objects dynamically added to this collection via the filter"); } +static void rna_def_layer_collection_override(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "LayerCollectionOverride", NULL); + RNA_def_struct_sdna(srna, "CollectionOverride"); + RNA_def_struct_ui_text(srna, "Collection Override", "Collection Override"); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Name", "Collection name"); + RNA_def_struct_name_property(srna, prop); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL); +} + static void rna_def_layer_collection(BlenderRNA *brna) { StructRNA *srna; @@ -5631,6 +5674,11 @@ static void rna_def_layer_collection(BlenderRNA *brna) RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_LayerCollection_objects_get", NULL, NULL, NULL, NULL); RNA_def_property_ui_text(prop, "Objects", "All the objects directly or indirectly added to this collection (not including sub-collection objects)"); + prop = RNA_def_property(srna, "overrides", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "overrides", NULL); + RNA_def_property_struct_type(prop, "LayerCollectionOverride"); + RNA_def_property_ui_text(prop, "Collection Overrides", ""); + /* Flags */ prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_VISIBLE); @@ -8329,6 +8377,7 @@ void RNA_def_scene(BlenderRNA *brna) rna_def_display_safe_areas(brna); rna_def_scene_collection(brna); rna_def_layer_collection(brna); + rna_def_layer_collection_override(brna); rna_def_scene_layer(brna); rna_def_object_base(brna); RNA_define_animate_sdna(true); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index af4fb9d0d8a..9bfe70a7faa 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -79,6 +79,7 @@ EnumPropertyItem rna_enum_space_type_items[] = { {0, "", ICON_NONE, NULL, NULL}, {SPACE_BUTS, "PROPERTIES", ICON_BUTS, "Properties", "Edit properties of active object and related data-blocks"}, {SPACE_OUTLINER, "OUTLINER", ICON_OOPS, "Outliner", "Overview of scene graph and all available data-blocks"}, + {SPACE_COLLECTIONS, "COLLECTION_MANAGER", ICON_COLLAPSEMENU, "Collections", "Edit collections of active render layer"}, {SPACE_USERPREF, "USER_PREFERENCES", ICON_PREFERENCES, "User Preferences", "Edit persistent configuration settings"}, {SPACE_INFO, "INFO", ICON_INFO, "Info", "Main menu bar and list of error messages (drag down to expand and display)"}, {0, "", ICON_NONE, NULL, NULL}, @@ -208,6 +209,7 @@ static EnumPropertyItem buttons_context_items[] = { {BCONTEXT_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture"}, {BCONTEXT_PARTICLE, "PARTICLES", ICON_PARTICLES, "Particles", "Particle"}, {BCONTEXT_PHYSICS, "PHYSICS", ICON_PHYSICS, "Physics", "Physics"}, + {BCONTEXT_COLLECTION, "COLLECTION", ICON_COLLAPSEMENU, "Collection", "Collection"}, {0, NULL, 0, NULL, NULL} }; @@ -315,6 +317,8 @@ static StructRNA *rna_Space_refine(struct PointerRNA *ptr) return &RNA_SpaceUserPreferences; case SPACE_CLIP: return &RNA_SpaceClipEditor; + case SPACE_COLLECTIONS: + return &RNA_SpaceCollectionManager; default: return &RNA_Space; } @@ -1076,6 +1080,10 @@ static EnumPropertyItem *rna_SpaceProperties_context_itemf(bContext *UNUSED(C), RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_SCENE); } + if (sbuts->pathflag & (1 << BCONTEXT_COLLECTION)) { + RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_COLLECTION); + } + if (sbuts->pathflag & (1 << BCONTEXT_WORLD)) { RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_WORLD); } @@ -4812,6 +4820,15 @@ static void rna_def_space_clip(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL); } +static void rna_def_space_collections(BlenderRNA *brna) +{ + StructRNA *srna; + + srna = RNA_def_struct(brna, "SpaceCollectionManager", "Space"); + RNA_def_struct_sdna(srna, "SpaceCollections"); + RNA_def_struct_ui_text(srna, "Space Collection Manager", "Layer Collection space data"); +} + void RNA_def_space(BlenderRNA *brna) { @@ -4838,6 +4855,7 @@ void RNA_def_space(BlenderRNA *brna) rna_def_space_node(brna); rna_def_space_logic(brna); rna_def_space_clip(brna); + rna_def_space_collections(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 0eab38faca8..dbf6e636c65 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2956,6 +2956,26 @@ static void rna_def_userdef_theme_space_clip(BlenderRNA *brna) rna_def_userdef_theme_spaces_curves(srna, false, false, false, true); } +static void rna_def_userdef_theme_space_collections(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ThemeCollectionManager", NULL); + RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); + RNA_def_struct_ui_text(srna, "Theme Collection Manager", "Theme settings for the Collection Manager"); + + rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_list_main(srna); + + prop = RNA_def_property(srna, "selected_collection", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "hilite"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Selected Collection", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); +} + static void rna_def_userdef_themes(BlenderRNA *brna) { StructRNA *srna; @@ -2982,6 +3002,7 @@ static void rna_def_userdef_themes(BlenderRNA *brna) {16, "FILE_BROWSER", ICON_FILESEL, "File Browser", ""}, {17, "CONSOLE", ICON_CONSOLE, "Python Console", ""}, {20, "CLIP_EDITOR", ICON_CLIP, "Movie Clip Editor", ""}, + {21, "COLLECTION_MANAGER", ICON_COLLAPSEMENU, "Collection Manager", ""}, {0, NULL, 0, NULL, NULL} }; @@ -3115,6 +3136,12 @@ static void rna_def_userdef_themes(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "tclip"); RNA_def_property_struct_type(prop, "ThemeClipEditor"); RNA_def_property_ui_text(prop, "Clip Editor", ""); + + prop = RNA_def_property(srna, "collection_manager", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "tcollections"); + RNA_def_property_struct_type(prop, "ThemeCollectionManager"); + RNA_def_property_ui_text(prop, "Collection Manager", ""); } static void rna_def_userdef_addon(BlenderRNA *brna) @@ -3205,6 +3232,7 @@ static void rna_def_userdef_dothemes(BlenderRNA *brna) rna_def_userdef_theme_space_console(brna); rna_def_userdef_theme_space_logic(brna); rna_def_userdef_theme_space_clip(brna); + rna_def_userdef_theme_space_collections(brna); rna_def_userdef_theme_colorset(brna); rna_def_userdef_themes(brna); } diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c index df1c4155a6d..b8c9b3ff9e9 100644 --- a/source/blender/python/intern/bpy_rna_callback.c +++ b/source/blender/python/intern/bpy_rna_callback.c @@ -174,6 +174,7 @@ static eSpace_Type rna_Space_refine_reverse(StructRNA *srna) if (srna == &RNA_SpaceConsole) return SPACE_CONSOLE; if (srna == &RNA_SpaceUserPreferences) return SPACE_USERPREF; if (srna == &RNA_SpaceClipEditor) return SPACE_CLIP; + if (srna == &RNA_SpaceCollectionManager) return SPACE_COLLECTIONS; return SPACE_EMPTY; } diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 3bed4dac2cf..49e70b4f200 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -364,6 +364,7 @@ typedef struct wmNotifier { #define ND_SPACE_CHANGED (18<<16) /*sent to a new editor type after it's replaced an old one*/ #define ND_SPACE_CLIP (19<<16) #define ND_SPACE_FILE_PREVIEW (20<<16) +#define ND_SPACE_COLLECTIONS (21<<16) /* subtype, 256 entries too */ #define NOTE_SUBTYPE 0x0000FF00 diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index e201fa433d4..4179ac7f993 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -1861,6 +1861,10 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) else if (STRPREFIX(opname, "OUTLINER_OT")) { km = WM_keymap_find_all(C, "Outliner", sl->spacetype, 0); } + /* Layer Manager */ + else if (STRPREFIX(opname, "COLLECTIONS_OT")) { + km = WM_keymap_find_all(C, "Collection Manager", sl->spacetype, 0); + } /* Transform */ else if (STRPREFIX(opname, "TRANSFORM_OT")) { /* check for relevant editor */ |