2011-03-21 12:35:49 +00:00
|
|
|
# ##### 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 #####
|
|
|
|
|
|
|
|
# <pep8 compliant>
|
|
|
|
|
|
|
|
# note, properties_animviz is a helper module only.
|
|
|
|
|
2016-03-03 19:14:02 +00:00
|
|
|
# support reloading sub-modules
|
2011-03-21 12:35:49 +00:00
|
|
|
if "bpy" in locals():
|
2015-01-23 01:37:58 +00:00
|
|
|
from importlib import reload
|
2017-03-29 01:35:00 +00:00
|
|
|
_modules_loaded[:] = [reload(val) for val in _modules_loaded]
|
2015-01-23 01:37:58 +00:00
|
|
|
del reload
|
2016-03-02 19:31:11 +00:00
|
|
|
|
2013-03-21 23:25:18 +00:00
|
|
|
_modules = [
|
2011-03-21 12:35:49 +00:00
|
|
|
"properties_animviz",
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 09:18:38 +00:00
|
|
|
"properties_collection",
|
2013-03-11 01:59:48 +00:00
|
|
|
"properties_constraint",
|
2011-03-21 12:35:49 +00:00
|
|
|
"properties_data_armature",
|
|
|
|
"properties_data_bone",
|
|
|
|
"properties_data_camera",
|
|
|
|
"properties_data_curve",
|
|
|
|
"properties_data_empty",
|
|
|
|
"properties_data_lamp",
|
|
|
|
"properties_data_lattice",
|
|
|
|
"properties_data_mesh",
|
|
|
|
"properties_data_metaball",
|
|
|
|
"properties_data_modifier",
|
2017-06-12 10:59:54 +00:00
|
|
|
"properties_data_lightprobe",
|
2011-08-01 11:44:20 +00:00
|
|
|
"properties_data_speaker",
|
2017-10-16 19:15:03 +00:00
|
|
|
"properties_data_workspace",
|
2011-03-21 12:35:49 +00:00
|
|
|
"properties_game",
|
2012-07-25 13:09:12 +00:00
|
|
|
"properties_mask_common",
|
2011-03-21 12:35:49 +00:00
|
|
|
"properties_material",
|
|
|
|
"properties_object",
|
2013-08-30 11:46:19 +00:00
|
|
|
"properties_paint_common",
|
2014-02-13 17:49:26 +00:00
|
|
|
"properties_grease_pencil_common",
|
2016-12-28 16:30:58 +00:00
|
|
|
"properties_particle",
|
2011-03-21 12:35:49 +00:00
|
|
|
"properties_physics_cloth",
|
|
|
|
"properties_physics_common",
|
2011-05-24 07:08:58 +00:00
|
|
|
"properties_physics_dynamicpaint",
|
2011-03-21 12:35:49 +00:00
|
|
|
"properties_physics_field",
|
|
|
|
"properties_physics_fluid",
|
2013-01-23 05:56:44 +00:00
|
|
|
"properties_physics_rigidbody",
|
2013-01-23 05:56:56 +00:00
|
|
|
"properties_physics_rigidbody_constraint",
|
2011-03-21 12:35:49 +00:00
|
|
|
"properties_physics_smoke",
|
|
|
|
"properties_physics_softbody",
|
|
|
|
"properties_render",
|
2012-10-28 16:09:51 +00:00
|
|
|
"properties_render_layer",
|
2011-03-21 12:35:49 +00:00
|
|
|
"properties_scene",
|
|
|
|
"properties_texture",
|
|
|
|
"properties_world",
|
2011-11-07 12:55:18 +00:00
|
|
|
"space_clip",
|
2011-03-21 12:35:49 +00:00
|
|
|
"space_console",
|
|
|
|
"space_dopesheet",
|
|
|
|
"space_filebrowser",
|
|
|
|
"space_graph",
|
|
|
|
"space_image",
|
|
|
|
"space_info",
|
|
|
|
"space_logic",
|
|
|
|
"space_nla",
|
|
|
|
"space_node",
|
|
|
|
"space_outliner",
|
2013-06-19 19:37:17 +00:00
|
|
|
"space_properties",
|
2011-03-21 12:35:49 +00:00
|
|
|
"space_sequencer",
|
|
|
|
"space_text",
|
|
|
|
"space_time",
|
|
|
|
"space_userpref",
|
|
|
|
"space_view3d",
|
|
|
|
"space_view3d_toolbar",
|
2016-03-02 19:31:11 +00:00
|
|
|
]
|
2013-03-21 23:25:18 +00:00
|
|
|
|
|
|
|
import bpy
|
|
|
|
|
|
|
|
if bpy.app.build_options.freestyle:
|
|
|
|
_modules.append("properties_freestyle")
|
2016-03-02 19:31:11 +00:00
|
|
|
|
2011-03-21 12:35:49 +00:00
|
|
|
__import__(name=__name__, fromlist=_modules)
|
|
|
|
_namespace = globals()
|
2016-03-02 19:31:11 +00:00
|
|
|
_modules_loaded = [_namespace[name] for name in _modules]
|
2011-03-21 12:35:49 +00:00
|
|
|
del _namespace
|
|
|
|
|
|
|
|
|
|
|
|
def register():
|
2017-03-18 09:03:24 +00:00
|
|
|
from bpy.utils import register_class
|
|
|
|
for mod in _modules_loaded:
|
|
|
|
for cls in mod.classes:
|
|
|
|
register_class(cls)
|
2011-03-21 12:35:49 +00:00
|
|
|
|
|
|
|
# space_userprefs.py
|
|
|
|
from bpy.props import StringProperty, EnumProperty
|
2012-01-18 06:11:56 +00:00
|
|
|
from bpy.types import WindowManager
|
2011-03-21 12:35:49 +00:00
|
|
|
|
2011-05-26 18:11:59 +00:00
|
|
|
def addon_filter_items(self, context):
|
|
|
|
import addon_utils
|
|
|
|
|
2014-11-14 11:17:25 +00:00
|
|
|
items = [('All', "All", "All Add-ons"),
|
|
|
|
('User', "User", "All Add-ons Installed by User"),
|
|
|
|
('Enabled', "Enabled", "All Enabled Add-ons"),
|
|
|
|
('Disabled', "Disabled", "All Disabled Add-ons"),
|
2012-10-08 08:28:05 +00:00
|
|
|
]
|
2011-05-26 18:11:59 +00:00
|
|
|
|
|
|
|
items_unique = set()
|
|
|
|
|
2013-08-28 06:36:54 +00:00
|
|
|
for mod in addon_utils.modules(refresh=False):
|
2011-05-26 18:11:59 +00:00
|
|
|
info = addon_utils.module_bl_info(mod)
|
|
|
|
items_unique.add(info["category"])
|
|
|
|
|
|
|
|
items.extend([(cat, cat, "") for cat in sorted(items_unique)])
|
|
|
|
return items
|
|
|
|
|
2011-08-19 19:25:20 +00:00
|
|
|
WindowManager.addon_search = StringProperty(
|
|
|
|
name="Search",
|
|
|
|
description="Search within the selected filter",
|
2014-12-25 11:53:13 +00:00
|
|
|
options={'TEXTEDIT_UPDATE'},
|
2011-08-19 19:25:20 +00:00
|
|
|
)
|
2011-03-21 12:35:49 +00:00
|
|
|
WindowManager.addon_filter = EnumProperty(
|
2011-05-26 18:11:59 +00:00
|
|
|
items=addon_filter_items,
|
2011-03-21 12:35:49 +00:00
|
|
|
name="Category",
|
2016-06-01 18:38:30 +00:00
|
|
|
description="Filter add-ons by category",
|
2011-03-21 12:35:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
WindowManager.addon_support = EnumProperty(
|
2011-11-17 20:11:20 +00:00
|
|
|
items=[('OFFICIAL', "Official", "Officially supported"),
|
|
|
|
('COMMUNITY', "Community", "Maintained by community developers"),
|
2012-10-13 10:33:09 +00:00
|
|
|
('TESTING', "Testing", "Newly contributed scripts (excluded from release builds)")
|
2012-10-08 08:28:05 +00:00
|
|
|
],
|
2011-03-21 12:35:49 +00:00
|
|
|
name="Support",
|
2011-11-17 20:11:20 +00:00
|
|
|
description="Display support level",
|
|
|
|
default={'OFFICIAL', 'COMMUNITY'},
|
|
|
|
options={'ENUM_FLAG'},
|
|
|
|
)
|
2011-03-21 12:35:49 +00:00
|
|
|
# done...
|
|
|
|
|
|
|
|
|
|
|
|
def unregister():
|
2017-03-18 09:03:24 +00:00
|
|
|
from bpy.utils import unregister_class
|
|
|
|
for mod in reversed(_modules_loaded):
|
|
|
|
for cls in reversed(mod.classes):
|
2017-03-29 01:35:00 +00:00
|
|
|
if cls.is_registered:
|
|
|
|
unregister_class(cls)
|
2013-01-15 23:15:32 +00:00
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
# Define a default UIList, when a list does not need any custom drawing...
|
2013-02-18 14:03:26 +00:00
|
|
|
# Keep in sync with its #defined name in UI_interface.h
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
class UI_UL_list(bpy.types.UIList):
|
2013-08-29 12:55:31 +00:00
|
|
|
# These are common filtering or ordering operations (same as the default C ones!).
|
|
|
|
@staticmethod
|
|
|
|
def filter_items_by_name(pattern, bitflag, items, propname="name", flags=None, reverse=False):
|
|
|
|
"""
|
|
|
|
Set FILTER_ITEM for items which name matches filter_name one (case-insensitive).
|
|
|
|
pattern is the filtering pattern.
|
|
|
|
propname is the name of the string property to use for filtering.
|
|
|
|
flags must be a list of integers the same length as items, or None!
|
|
|
|
return a list of flags (based on given flags if not None),
|
2013-09-18 05:20:43 +00:00
|
|
|
or an empty list if no flags were given and no filtering has been done.
|
2013-08-29 12:55:31 +00:00
|
|
|
"""
|
|
|
|
import fnmatch
|
|
|
|
|
2013-08-29 14:37:46 +00:00
|
|
|
if not pattern or not items: # Empty pattern or list = no filtering!
|
2013-08-29 12:55:31 +00:00
|
|
|
return flags or []
|
|
|
|
|
|
|
|
if flags is None:
|
|
|
|
flags = [0] * len(items)
|
2013-08-29 14:37:46 +00:00
|
|
|
|
|
|
|
# Implicitly add heading/trailing wildcards.
|
|
|
|
pattern = "*" + pattern + "*"
|
|
|
|
|
|
|
|
for i, item in enumerate(items):
|
|
|
|
name = getattr(item, propname, None)
|
2013-08-29 12:55:31 +00:00
|
|
|
# This is similar to a logical xor
|
2013-08-29 14:37:46 +00:00
|
|
|
if bool(name and fnmatch.fnmatchcase(name, pattern)) is not bool(reverse):
|
|
|
|
flags[i] |= bitflag
|
2013-08-29 12:55:31 +00:00
|
|
|
return flags
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def sort_items_helper(sort_data, key, reverse=False):
|
|
|
|
"""
|
|
|
|
Common sorting utility. Returns a neworder list mapping org_idx -> new_idx.
|
|
|
|
sort_data must be an (unordered) list of tuples [(org_idx, ...), (org_idx, ...), ...].
|
|
|
|
key must be the same kind of callable you would use for sorted() builtin function.
|
|
|
|
reverse will reverse the sorting!
|
|
|
|
"""
|
|
|
|
sort_data.sort(key=key, reverse=reverse)
|
|
|
|
neworder = [None] * len(sort_data)
|
|
|
|
for newidx, (orgidx, *_) in enumerate(sort_data):
|
|
|
|
neworder[orgidx] = newidx
|
|
|
|
return neworder
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def sort_items_by_name(cls, items, propname="name"):
|
|
|
|
"""
|
|
|
|
Re-order items using their names (case-insensitive).
|
|
|
|
propname is the name of the string property to use for sorting.
|
|
|
|
return a list mapping org_idx -> new_idx,
|
|
|
|
or an empty list if no sorting has been done.
|
|
|
|
"""
|
|
|
|
_sort = [(idx, getattr(it, propname, "")) for idx, it in enumerate(items)]
|
|
|
|
return cls.sort_items_helper(_sort, lambda e: e[1].lower())
|
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
|
|
|
bpy.utils.register_class(UI_UL_list)
|