Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/modules/bpy_types.py
| Show First 20 Lines • Show All 539 Lines • ▼ Show 20 Lines | def factory(self): | ||||
| import aud | import aud | ||||
| return aud._sound_from_pointer(self.as_pointer()) | return aud._sound_from_pointer(self.as_pointer()) | ||||
| class RNAMeta(type): | class RNAMeta(type): | ||||
| def __new__(cls, name, bases, classdict, **args): | def __new__(cls, name, bases, classdict, **args): | ||||
| result = type.__new__(cls, name, bases, classdict) | result = type.__new__(cls, name, bases, classdict) | ||||
| # BEGIN TEST | |||||
| # | |||||
| # This will be removed, it just avoids having to patch all add-ons. | |||||
| import _bpy as _hack_module | |||||
| addon = getattr(_hack_module, "_addon_current_hack", None) | |||||
| if addon is not None: | |||||
| result.bl_origin = addon | |||||
| # END TEST | |||||
| if bases and bases[0] is not StructRNA: | if bases and bases[0] is not StructRNA: | ||||
| from _weakref import ref as ref | from _weakref import ref as ref | ||||
| module = result.__module__ | module = result.__module__ | ||||
| # first part of packages only | # first part of packages only | ||||
| if "." in module: | if "." in module: | ||||
| module = module[:module.index(".")] | module = module[:module.index(".")] | ||||
| ▲ Show 20 Lines • Show All 221 Lines • ▼ Show 20 Lines | def _dyn_ui_initialize(cls): | ||||
| self.layout.operator_context = operator_context_default | self.layout.operator_context = operator_context_default | ||||
| draw_funcs = draw_ls._draw_funcs = [cls.draw] | draw_funcs = draw_ls._draw_funcs = [cls.draw] | ||||
| cls.draw = draw_ls | cls.draw = draw_ls | ||||
| return draw_funcs | return draw_funcs | ||||
| @staticmethod | |||||
| def _dyn_bl_origin_test(draw_func): | |||||
| import _bpy as _hack_module | |||||
| addon = getattr(_hack_module, "_addon_current_hack", None) | |||||
| if addon is None: | |||||
| return draw_func | |||||
| def draw_func_wrapper(self, context): | |||||
| workspace = context.workspace | |||||
| if workspace.use_bl_origins: | |||||
| bl_origin = draw_func_wrapper.bl_origin | |||||
| if not any(True for bl_origin in workspace.bl_origins if bl_origin == bl_origin.name): | |||||
| return | |||||
| draw_func_wrapper._draw_func_real(self, context) | |||||
| draw_func_wrapper.bl_origin = addon | |||||
| draw_func_wrapper._draw_func_real = draw_func | |||||
| return draw_func_wrapper | |||||
| @classmethod | @classmethod | ||||
| def is_extended(cls): | def is_extended(cls): | ||||
| return bool(getattr(cls.draw, "_draw_funcs", None)) | return bool(getattr(cls.draw, "_draw_funcs", None)) | ||||
| @classmethod | @classmethod | ||||
| def append(cls, draw_func): | def append(cls, draw_func): | ||||
| """ | """ | ||||
| Append a draw function to this menu, | Append a draw function to this menu, | ||||
| takes the same arguments as the menus draw function | takes the same arguments as the menus draw function | ||||
| """ | """ | ||||
| draw_funcs = cls._dyn_ui_initialize() | draw_funcs = cls._dyn_ui_initialize() | ||||
| draw_func = cls._dyn_bl_origin_test(draw_func) | |||||
| draw_funcs.append(draw_func) | draw_funcs.append(draw_func) | ||||
| @classmethod | @classmethod | ||||
| def prepend(cls, draw_func): | def prepend(cls, draw_func): | ||||
| """ | """ | ||||
| Prepend a draw function to this menu, takes the same arguments as | Prepend a draw function to this menu, takes the same arguments as | ||||
| the menus draw function | the menus draw function | ||||
| """ | """ | ||||
| ▲ Show 20 Lines • Show All 178 Lines • Show Last 20 Lines | |||||