diff options
152 files changed, 8431 insertions, 7152 deletions
diff --git a/SConstruct b/SConstruct index 7b25f744103..81c12c7c318 100644 --- a/SConstruct +++ b/SConstruct @@ -268,7 +268,8 @@ if env['OURPLATFORM']=='darwin': if env['WITH_BF_3DMOUSE'] == 1 and not os.path.exists('/Library/Frameworks/3DconnexionClient.framework'): print "3D_CONNEXION_CLIENT_LIBRARY not found, disabling WITH_BF_3DMOUSE" # avoid build errors ! env['WITH_BF_3DMOUSE'] = 0 - env['FOUND_NDOF_DRIVERS'] = 0 + else: + env.Append(LINKFLAGS=['-weak_framework','3DconnexionClient']) if env['WITH_BF_OPENMP'] == 1: diff --git a/build_files/buildbot/master.cfg b/build_files/buildbot/master.cfg index 1e70ec5e13e..5aa5a43abf7 100644 --- a/build_files/buildbot/master.cfg +++ b/build_files/buildbot/master.cfg @@ -116,7 +116,7 @@ add_builder(c, 'linux_x86_64_scons', '', generic_builder) add_builder(c, 'salad_linux_x86_64_scons', '', generic_builder, 'soc-2011-salad') add_builder(c, 'win32_scons', 'windows', generic_builder) add_builder(c, 'salad_win32_scons', 'windows', generic_builder, 'soc-2011-salad') -add_builder(c, 'win64_scons', 'windows', generic_builder) +add_builder(c, 'win64_scons', 'win64', generic_builder) #add_builder(c, 'freebsd_i386_cmake', '', generic_builder) #add_builder(c, 'freebsd_x86_64_cmake', '', generic_builder) diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index 29695896921..ec6a3b082b8 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -284,7 +284,7 @@ if MACOSX_ARCHITECTURE == 'i386': elif MACOSX_ARCHITECTURE == 'x86_64': BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-msse2'] -# SpaceNavigator and related 3D mice +# SpaceNavigator and related 3D mice, driver must be 3DxWare 10 Beta 4 (Mac OS X) or later ! WITH_BF_3DMOUSE = True ############################################################################# @@ -315,9 +315,6 @@ if WITH_BF_QUICKTIME: else: PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QuickTime'] -if FOUND_NDOF_DRIVERS: - PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS + ['-weak_framework','3DconnexionClient'] - #note to build succesfully on 10.3.9 SDK you need to patch 10.3.9 by adding the SystemStubs.a lib from 10.4 LLIBS = ['stdc++', 'SystemStubs'] diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index aac16555df9..25e0582c536 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -136,7 +136,7 @@ def validate_arguments(args, bc): 'BF_NO_ELBEEM', 'WITH_BF_CXX_GUARDEDALLOC', 'WITH_BF_JEMALLOC', 'WITH_BF_STATICJEMALLOC', 'BF_JEMALLOC', 'BF_JEMALLOC_INC', 'BF_JEMALLOC_LIBPATH', 'BF_JEMALLOC_LIB', 'BF_JEMALLOC_LIB_STATIC', - 'BUILDBOT_BRANCH', 'WITH_BF_3DMOUSE', 'FOUND_NDOF_DRIVERS', 'WITH_BF_STATIC3DMOUSE', 'BF_3DMOUSE', 'BF_3DMOUSE_INC', 'BF_3DMOUSE_LIB', 'BF_3DMOUSE_LIBPATH', 'BF_3DMOUSE_LIB_STATIC' + 'BUILDBOT_BRANCH', 'WITH_BF_3DMOUSE', 'WITH_BF_STATIC3DMOUSE', 'BF_3DMOUSE', 'BF_3DMOUSE_INC', 'BF_3DMOUSE_LIB', 'BF_3DMOUSE_LIBPATH', 'BF_3DMOUSE_LIB_STATIC' ] # Have options here that scons expects to be lists @@ -439,7 +439,6 @@ def read_opts(env, cfg, args): (BoolVariable('WITH_BF_NOBLENDER', 'Do not build blender if true', False)), (BoolVariable('WITH_BF_3DMOUSE', 'Build blender with support of 3D mouses', False)), - (BoolVariable('FOUND_NDOF_DRIVERS', 'We detected NDOF libs or framework', False)), (BoolVariable('WITH_BF_STATIC3DMOUSE', 'Staticly link to 3d mouse library', False)), ('BF_3DMOUSE', '3d mouse library base path', ''), ('BF_3DMOUSE_INC', '3d mouse library include path', ''), diff --git a/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm b/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm index 1d90b6daa68..409ed953134 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm +++ b/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm @@ -159,18 +159,22 @@ GHOST_NDOFManagerCocoa::GHOST_NDOFManagerCocoa(GHOST_System& sys) GHOST_NDOFManagerCocoa::~GHOST_NDOFManagerCocoa() { - UnregisterConnexionClient(m_clientID); - CleanupConnexionHandlers(); - ghost_system = NULL; - ndof_manager = NULL; + if (available()) + { + UnregisterConnexionClient(m_clientID); + CleanupConnexionHandlers(); + ghost_system = NULL; + ndof_manager = NULL; + } } - -bool GHOST_NDOFManagerCocoa::available() -{ - // extern OSErr InstallConnexionHandlers() __attribute__((weak_import)); - // ^^ not needed since the entire framework is weak-linked - return InstallConnexionHandlers != NULL; - // this means that the driver is installed and dynamically linked to blender +extern "C" { + bool GHOST_NDOFManagerCocoa::available() + { + extern OSErr InstallConnexionHandlers() __attribute__((weak_import)); + // Make the linker happy for the framework check (see link below for more info) + // http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html + return InstallConnexionHandlers != NULL; + // this means that the driver is installed and dynamically linked to blender + } } - #endif // WITH_INPUT_NDOF diff --git a/release/scripts/modules/bpy/__init__.py b/release/scripts/modules/bpy/__init__.py index a43b42e49a1..5c371fd750a 100644 --- a/release/scripts/modules/bpy/__init__.py +++ b/release/scripts/modules/bpy/__init__.py @@ -44,14 +44,18 @@ from . import utils, path, ops ops = ops.ops_fake_module -def _main(): - import sys as _sys +def main(): + import sys # Possibly temp. addons path from os.path import join, dirname, normpath - _sys.path.append(normpath(join(dirname(__file__), + sys.path.append(normpath(join(dirname(__file__), "..", "..", "addons", "modules"))) + # fake module to allow: + # from bpy.types import Panel + sys.modules["bpy.types"] = types + # if "-d" in sys.argv: # Enable this to measure startup speed if 0: import cProfile @@ -65,6 +69,6 @@ def _main(): utils.load_scripts() -_main() +main() -del _main +del main diff --git a/release/scripts/startup/bl_operators/add_mesh_torus.py b/release/scripts/startup/bl_operators/add_mesh_torus.py index 27a6d21d519..1c4518c4feb 100644 --- a/release/scripts/startup/bl_operators/add_mesh_torus.py +++ b/release/scripts/startup/bl_operators/add_mesh_torus.py @@ -18,6 +18,7 @@ # <pep8-80 compliant> import bpy +from bpy.types import Operator import mathutils @@ -81,7 +82,7 @@ from bpy.props import (FloatProperty, ) -class AddTorus(bpy.types.Operator): +class AddTorus(Operator): '''Add a torus mesh''' bl_idname = "mesh.primitive_torus_add" bl_label = "Add Torus" diff --git a/release/scripts/startup/bl_operators/animsys_update.py b/release/scripts/startup/bl_operators/animsys_update.py index 63d438a5066..3710c57ac16 100644 --- a/release/scripts/startup/bl_operators/animsys_update.py +++ b/release/scripts/startup/bl_operators/animsys_update.py @@ -686,9 +686,10 @@ data_path_update = [ import bpy +from bpy.types import Operator -class UpdateAnimData(bpy.types.Operator): +class UpdateAnimData(Operator): """Update data paths from 2.56 and previous versions, modifying data paths of drivers and fcurves""" bl_idname = "anim.update_data_paths" bl_label = "Update Animation Data" diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py index aca9b581b97..9226cbed51b 100644 --- a/release/scripts/startup/bl_operators/image.py +++ b/release/scripts/startup/bl_operators/image.py @@ -19,10 +19,11 @@ # <pep8-80 compliant> import bpy +from bpy.types import Operator from bpy.props import StringProperty -class EditExternally(bpy.types.Operator): +class EditExternally(Operator): '''Edit image in an external application''' bl_idname = "image.external_edit" bl_label = "Image Edit Externally" @@ -106,7 +107,7 @@ class EditExternally(bpy.types.Operator): return {'FINISHED'} -class SaveDirty(bpy.types.Operator): +class SaveDirty(Operator): """Save all modified textures""" bl_idname = "image.save_dirty" bl_label = "Save Dirty" @@ -129,7 +130,7 @@ class SaveDirty(bpy.types.Operator): return {'FINISHED'} -class ProjectEdit(bpy.types.Operator): +class ProjectEdit(Operator): """Edit a snapshot of the viewport in an external image editor""" bl_idname = "image.project_edit" bl_label = "Project Edit" @@ -196,7 +197,7 @@ class ProjectEdit(bpy.types.Operator): return {'FINISHED'} -class ProjectApply(bpy.types.Operator): +class ProjectApply(Operator): """Project edited image back onto the object""" bl_idname = "image.project_apply" bl_label = "Project Apply" diff --git a/release/scripts/startup/bl_operators/mesh.py b/release/scripts/startup/bl_operators/mesh.py index 344b238709f..4114381f3dc 100644 --- a/release/scripts/startup/bl_operators/mesh.py +++ b/release/scripts/startup/bl_operators/mesh.py @@ -19,11 +19,12 @@ # <pep8-80 compliant> import bpy +from bpy.types import Operator from bpy.props import EnumProperty -class MeshSelectInteriorFaces(bpy.types.Operator): +class MeshSelectInteriorFaces(Operator): '''Select faces where all edges have more then 2 face users.''' bl_idname = "mesh.faces_select_interior" @@ -67,7 +68,7 @@ class MeshSelectInteriorFaces(bpy.types.Operator): return {'FINISHED'} -class MeshMirrorUV(bpy.types.Operator): +class MeshMirrorUV(Operator): '''Copy mirror UV coordinates on the X axis based on a mirrored mesh''' bl_idname = "mesh.faces_mirror_uv" bl_label = "Copy Mirrored UV coords" diff --git a/release/scripts/startup/bl_operators/nla.py b/release/scripts/startup/bl_operators/nla.py index 469e9015e62..44ed846e530 100644 --- a/release/scripts/startup/bl_operators/nla.py +++ b/release/scripts/startup/bl_operators/nla.py @@ -19,6 +19,7 @@ # <pep8-80 compliant> import bpy +from bpy.types import Operator def pose_frame_info(obj): @@ -191,7 +192,7 @@ def bake(frame_start, from bpy.props import IntProperty, BoolProperty, EnumProperty -class BakeAction(bpy.types.Operator): +class BakeAction(Operator): '''Bake animation to an Action''' bl_idname = "nla.bake" bl_label = "Bake Action" diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py index 627a1530fe1..79f57990f37 100644 --- a/release/scripts/startup/bl_operators/object.py +++ b/release/scripts/startup/bl_operators/object.py @@ -19,10 +19,11 @@ # <pep8-80 compliant> import bpy +from bpy.types import Operator from bpy.props import StringProperty, BoolProperty, EnumProperty, IntProperty -class SelectPattern(bpy.types.Operator): +class SelectPattern(Operator): '''Select object matching a naming pattern''' bl_idname = "object.select_pattern" bl_label = "Select Pattern" @@ -99,7 +100,7 @@ class SelectPattern(bpy.types.Operator): row.prop(self, "extend") -class SelectCamera(bpy.types.Operator): +class SelectCamera(Operator): '''Select object matching a naming pattern''' bl_idname = "object.select_camera" bl_label = "Select Camera" @@ -120,7 +121,7 @@ class SelectCamera(bpy.types.Operator): return {'FINISHED'} -class SelectHierarchy(bpy.types.Operator): +class SelectHierarchy(Operator): '''Select object relative to the active objects position''' \ '''in the hierarchy''' bl_idname = "object.select_hierarchy" @@ -187,7 +188,7 @@ class SelectHierarchy(bpy.types.Operator): return {'CANCELLED'} -class SubdivisionSet(bpy.types.Operator): +class SubdivisionSet(Operator): '''Sets a Subdivision Surface Level (1-5)''' bl_idname = "object.subdivision_set" @@ -263,7 +264,7 @@ class SubdivisionSet(bpy.types.Operator): return {'FINISHED'} -class ShapeTransfer(bpy.types.Operator): +class ShapeTransfer(Operator): '''Copy another selected objects active shape to this one by ''' \ '''applying the relative offsets''' @@ -507,7 +508,7 @@ class ShapeTransfer(bpy.types.Operator): return self._main(ob_act, objects, self.mode, self.use_clamp) -class JoinUVs(bpy.types.Operator): +class JoinUVs(Operator): '''Copy UV Layout to objects with matching geometry''' bl_idname = "object.join_uvs" bl_label = "Join as UVs" @@ -575,7 +576,7 @@ class JoinUVs(bpy.types.Operator): return {'FINISHED'} -class MakeDupliFace(bpy.types.Operator): +class MakeDupliFace(Operator): '''Make linked objects into dupli-faces''' bl_idname = "object.make_dupli_face" bl_label = "Make Dupli-Face" @@ -649,7 +650,7 @@ class MakeDupliFace(bpy.types.Operator): return {'FINISHED'} -class IsolateTypeRender(bpy.types.Operator): +class IsolateTypeRender(Operator): '''Hide unselected render objects of same type as active ''' \ '''by setting the hide render flag''' bl_idname = "object.isolate_type_render" @@ -670,7 +671,7 @@ class IsolateTypeRender(bpy.types.Operator): return {'FINISHED'} -class ClearAllRestrictRender(bpy.types.Operator): +class ClearAllRestrictRender(Operator): '''Reveal all render objects by setting the hide render flag''' bl_idname = "object.hide_render_clear_all" bl_label = "Clear All Restrict Render" diff --git a/release/scripts/startup/bl_operators/object_align.py b/release/scripts/startup/bl_operators/object_align.py index 7fd769c40c9..d4a3d826f2f 100644 --- a/release/scripts/startup/bl_operators/object_align.py +++ b/release/scripts/startup/bl_operators/object_align.py @@ -19,6 +19,7 @@ # <pep8-80 compliant> import bpy +from bpy.types import Operator from mathutils import Vector @@ -339,7 +340,7 @@ def align_objects(align_x, from bpy.props import EnumProperty, BoolProperty -class AlignObjects(bpy.types.Operator): +class AlignObjects(Operator): '''Align Objects''' bl_idname = "object.align" bl_label = "Align Objects" diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py index ef10bfd737d..cd206da3a8e 100644 --- a/release/scripts/startup/bl_operators/object_quick_effects.py +++ b/release/scripts/startup/bl_operators/object_quick_effects.py @@ -20,6 +20,7 @@ from mathutils import Vector import bpy +from bpy.types import Operator from bpy.props import (BoolProperty, EnumProperty, IntProperty, @@ -45,7 +46,7 @@ def object_ensure_material(obj, mat_name): return mat -class QuickFur(bpy.types.Operator): +class QuickFur(Operator): bl_idname = "object.quick_fur" bl_label = "Quick Fur" bl_options = {'REGISTER', 'UNDO'} @@ -104,7 +105,7 @@ class QuickFur(bpy.types.Operator): return {'FINISHED'} -class QuickExplode(bpy.types.Operator): +class QuickExplode(Operator): bl_idname = "object.quick_explode" bl_label = "Quick Explode" bl_options = {'REGISTER', 'UNDO'} @@ -265,7 +266,7 @@ def obj_bb_minmax(obj, min_co, max_co): max_co[2] = max(bb_vec[2], max_co[2]) -class QuickSmoke(bpy.types.Operator): +class QuickSmoke(Operator): bl_idname = "object.quick_smoke" bl_label = "Quick Smoke" bl_options = {'REGISTER', 'UNDO'} @@ -383,7 +384,7 @@ class QuickSmoke(bpy.types.Operator): return {'FINISHED'} -class QuickFluid(bpy.types.Operator): +class QuickFluid(Operator): bl_idname = "object.quick_fluid" bl_label = "Quick Fluid" bl_options = {'REGISTER', 'UNDO'} diff --git a/release/scripts/startup/bl_operators/object_randomize_transform.py b/release/scripts/startup/bl_operators/object_randomize_transform.py index b94c4f06cd3..f65e3d27d83 100644 --- a/release/scripts/startup/bl_operators/object_randomize_transform.py +++ b/release/scripts/startup/bl_operators/object_randomize_transform.py @@ -19,6 +19,7 @@ # <pep8-80 compliant> import bpy +from bpy.types import Operator def randomize_selected(seed, delta, loc, rot, scale, scale_even): @@ -87,7 +88,7 @@ def randomize_selected(seed, delta, loc, rot, scale, scale_even): from bpy.props import IntProperty, BoolProperty, FloatVectorProperty -class RandomizeLocRotSize(bpy.types.Operator): +class RandomizeLocRotSize(Operator): '''Randomize objects loc/rot/scale''' bl_idname = "object.randomize_transform" bl_label = "Randomize Transform" diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index fbcc327c3bd..2fd0c4a9e12 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -19,6 +19,7 @@ # <pep8-80 compliant> import bpy +from bpy.types import Menu, Operator class AddPresetBase(): @@ -140,7 +141,7 @@ class AddPresetBase(): return self.execute(context) -class ExecutePreset(bpy.types.Operator): +class ExecutePreset(Operator): ''' Executes a preset ''' bl_idname = "script.execute_preset" bl_label = "Execute a Python Preset" @@ -168,7 +169,7 @@ class ExecutePreset(bpy.types.Operator): return {'FINISHED'} -class AddPresetRender(AddPresetBase, bpy.types.Operator): +class AddPresetRender(AddPresetBase, Operator): '''Add a Render Preset''' bl_idname = "render.preset_add" bl_label = "Add Render Preset" @@ -194,7 +195,7 @@ class AddPresetRender(AddPresetBase, bpy.types.Operator): preset_subdir = "render" -class AddPresetSSS(AddPresetBase, bpy.types.Operator): +class AddPresetSSS(AddPresetBase, Operator): '''Add a Subsurface Scattering Preset''' bl_idname = "material.sss_preset_add" bl_label = "Add SSS Preset" @@ -222,7 +223,7 @@ class AddPresetSSS(AddPresetBase, bpy.types.Operator): preset_subdir = "sss" -class AddPresetCloth(AddPresetBase, bpy.types.Operator): +class AddPresetCloth(AddPresetBase, Operator): '''Add a Cloth Preset''' bl_idname = "cloth.preset_add" bl_label = "Add Cloth Preset" @@ -244,7 +245,7 @@ class AddPresetCloth(AddPresetBase, bpy.types.Operator): preset_subdir = "cloth" -class AddPresetSunSky(AddPresetBase, bpy.types.Operator): +class AddPresetSunSky(AddPresetBase, Operator): '''Add a Sky & Atmosphere Preset''' bl_idname = "lamp.sunsky_preset_add" bl_label = "Add Sunsky Preset" @@ -273,7 +274,7 @@ class AddPresetSunSky(AddPresetBase, bpy.types.Operator): preset_subdir = "sunsky" -class AddPresetInteraction(AddPresetBase, bpy.types.Operator): +class AddPresetInteraction(AddPresetBase, Operator): '''Add an Application Interaction Preset''' bl_idname = "wm.interaction_preset_add" bl_label = "Add Interaction Preset" @@ -299,7 +300,7 @@ class AddPresetInteraction(AddPresetBase, bpy.types.Operator): preset_subdir = "interaction" -class AddPresetKeyconfig(AddPresetBase, bpy.types.Operator): +class AddPresetKeyconfig(AddPresetBase, Operator): '''Add a Keyconfig Preset''' bl_idname = "wm.keyconfig_preset_add" bl_label = "Add Keyconfig Preset" @@ -322,7 +323,7 @@ class AddPresetKeyconfig(AddPresetBase, bpy.types.Operator): keyconfigs.remove(keyconfigs.active) -class AddPresetOperator(AddPresetBase, bpy.types.Operator): +class AddPresetOperator(AddPresetBase, Operator): '''Add an Application Interaction Preset''' bl_idname = "wm.operator_preset_add" bl_label = "Operator Preset" @@ -345,7 +346,7 @@ class AddPresetOperator(AddPresetBase, bpy.types.Operator): @property def preset_values(self): - properties_blacklist = bpy.types.Operator.bl_rna.properties.keys() + properties_blacklist = Operator.bl_rna.properties.keys() prefix, suffix = self.operator.split("_OT_", 1) op = getattr(getattr(bpy.ops, prefix.lower()), suffix) @@ -367,12 +368,12 @@ class AddPresetOperator(AddPresetBase, bpy.types.Operator): return os.path.join("operator", "%s.%s" % (prefix.lower(), suffix)) -class WM_MT_operator_presets(bpy.types.Menu): +class WM_MT_operator_presets(Menu): bl_label = "Operator Presets" def draw(self, context): self.operator = context.space_data.operator.bl_idname - bpy.types.Menu.draw_preset(self, context) + Menu.draw_preset(self, context) @property def preset_subdir(self): diff --git a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py index a38d817d738..c2a09d6a4ae 100644 --- a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py +++ b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py @@ -21,6 +21,7 @@ # Originally written by Matt Ebb import bpy +from bpy.types import Operator import os @@ -64,7 +65,7 @@ def guess_player_path(preset): return player_path -class PlayRenderedAnim(bpy.types.Operator): +class PlayRenderedAnim(Operator): '''Plays back rendered frames/movies using an external player.''' bl_idname = "render.play_rendered_anim" bl_label = "Play Rendered Animation" diff --git a/release/scripts/startup/bl_operators/sequencer.py b/release/scripts/startup/bl_operators/sequencer.py index 16b72406c49..d2f85c8d7c7 100644 --- a/release/scripts/startup/bl_operators/sequencer.py +++ b/release/scripts/startup/bl_operators/sequencer.py @@ -19,11 +19,12 @@ # <pep8 compliant> import bpy +from bpy.types import Operator from bpy.props import IntProperty -class SequencerCrossfadeSounds(bpy.types.Operator): +class SequencerCrossfadeSounds(Operator): '''Do crossfading volume animation of two selected sound strips.''' bl_idname = "sequencer.crossfade_sounds" @@ -74,7 +75,7 @@ class SequencerCrossfadeSounds(bpy.types.Operator): return {'CANCELLED'} -class SequencerCutMulticam(bpy.types.Operator): +class SequencerCutMulticam(Operator): '''Cut multicam strip and select camera.''' bl_idname = "sequencer.cut_multicam" @@ -112,7 +113,7 @@ class SequencerCutMulticam(bpy.types.Operator): return {'FINISHED'} -class SequencerDeinterlaceSelectedMovies(bpy.types.Operator): +class SequencerDeinterlaceSelectedMovies(Operator): '''Deinterlace all selected movie sources.''' bl_idname = "sequencer.deinterlace_selected_movies" diff --git a/release/scripts/startup/bl_operators/uvcalc_follow_active.py b/release/scripts/startup/bl_operators/uvcalc_follow_active.py index 43ca9af59ba..6c258d094e8 100644 --- a/release/scripts/startup/bl_operators/uvcalc_follow_active.py +++ b/release/scripts/startup/bl_operators/uvcalc_follow_active.py @@ -22,6 +22,7 @@ # http://mediawiki.blender.org/index.php/Scripts/Manual/UV_Calculate/Follow_active_quads import bpy +from bpy.types import Operator def extend(obj, operator, EXTEND_MODE): @@ -226,7 +227,7 @@ def main(context, operator): extend(obj, operator, operator.properties.mode) -class FollowActiveQuads(bpy.types.Operator): +class FollowActiveQuads(Operator): '''Follow UVs from active quads along continuous face loops''' bl_idname = "uv.follow_active_quads" bl_label = "Follow Active Quads" diff --git a/release/scripts/startup/bl_operators/uvcalc_lightmap.py b/release/scripts/startup/bl_operators/uvcalc_lightmap.py index d2371b0316a..6b1c6e1be98 100644 --- a/release/scripts/startup/bl_operators/uvcalc_lightmap.py +++ b/release/scripts/startup/bl_operators/uvcalc_lightmap.py @@ -19,6 +19,7 @@ # <pep8 compliant> import bpy +from bpy.types import Operator import mathutils @@ -543,7 +544,7 @@ def unwrap(operator, context, **kwargs): from bpy.props import BoolProperty, FloatProperty, IntProperty -class LightMapPack(bpy.types.Operator): +class LightMapPack(Operator): '''Follow UVs from active quads along continuous face loops''' bl_idname = "uv.lightmap_pack" bl_label = "Lightmap Pack" diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py index 851f33bde11..67c2f5d001b 100644 --- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py +++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py @@ -20,6 +20,7 @@ from mathutils import Matrix, Vector, geometry import bpy +from bpy.types import Operator DEG_TO_RAD = 0.017453292519943295 # pi/180.0 SMALL_NUM = 0.000000001 @@ -1116,7 +1117,7 @@ def main(context, from bpy.props import FloatProperty -class SmartProject(bpy.types.Operator): +class SmartProject(Operator): '''This script projection unwraps the selected faces of a mesh. it operates on all selected mesh objects, and can be used unwrap selected faces, or all faces.''' bl_idname = "uv.smart_project" bl_label = "Smart UV Project" diff --git a/release/scripts/startup/bl_operators/vertexpaint_dirt.py b/release/scripts/startup/bl_operators/vertexpaint_dirt.py index 672db71e361..facde82f812 100644 --- a/release/scripts/startup/bl_operators/vertexpaint_dirt.py +++ b/release/scripts/startup/bl_operators/vertexpaint_dirt.py @@ -142,10 +142,11 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, import bpy +from bpy.types import Operator from bpy.props import FloatProperty, IntProperty, BoolProperty -class VertexPaintDirt(bpy.types.Operator): +class VertexPaintDirt(Operator): bl_idname = "paint.vertex_color_dirt" bl_label = "Dirty Vertex Colors" bl_options = {'REGISTER', 'UNDO'} diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index f9327aa6c40..fe75c54e60e 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -19,13 +19,14 @@ # <pep8 compliant> import bpy +from bpy.types import Menu, Operator from bpy.props import StringProperty, BoolProperty, IntProperty, \ FloatProperty, EnumProperty from rna_prop_ui import rna_idprop_ui_prop_get, rna_idprop_ui_prop_clear -class MESH_OT_delete_edgeloop(bpy.types.Operator): +class MESH_OT_delete_edgeloop(Operator): '''Delete an edge loop by merging the faces on each side to a single face loop''' bl_idname = "mesh.delete_edgeloop" bl_label = "Delete Edge Loop" @@ -76,7 +77,7 @@ def execute_context_assign(self, context): return {'FINISHED'} -class BRUSH_OT_active_index_set(bpy.types.Operator): +class BRUSH_OT_active_index_set(Operator): '''Set active sculpt/paint brush from it's number''' bl_idname = "brush.active_index_set" bl_label = "Set Brush Number" @@ -104,7 +105,7 @@ class BRUSH_OT_active_index_set(bpy.types.Operator): return {'CANCELLED'} -class WM_OT_context_set_boolean(bpy.types.Operator): +class WM_OT_context_set_boolean(Operator): '''Set a context value.''' bl_idname = "wm.context_set_boolean" bl_label = "Context Set Boolean" @@ -117,7 +118,7 @@ class WM_OT_context_set_boolean(bpy.types.Operator): execute = execute_context_assign -class WM_OT_context_set_int(bpy.types.Operator): # same as enum +class WM_OT_context_set_int(Operator): # same as enum '''Set a context value.''' bl_idname = "wm.context_set_int" bl_label = "Context Set" @@ -130,7 +131,7 @@ class WM_OT_context_set_int(bpy.types.Operator): # same as enum execute = execute_context_assign -class WM_OT_context_scale_int(bpy.types.Operator): +class WM_OT_context_scale_int(Operator): '''Scale an int context value.''' bl_idname = "wm.context_scale_int" bl_label = "Context Set" @@ -166,7 +167,7 @@ class WM_OT_context_scale_int(bpy.types.Operator): return {'FINISHED'} -class WM_OT_context_set_float(bpy.types.Operator): # same as enum +class WM_OT_context_set_float(Operator): # same as enum '''Set a context value.''' bl_idname = "wm.context_set_float" bl_label = "Context Set Float" @@ -180,7 +181,7 @@ class WM_OT_context_set_float(bpy.types.Operator): # same as enum execute = execute_context_assign -class WM_OT_context_set_string(bpy.types.Operator): # same as enum +class WM_OT_context_set_string(Operator): # same as enum '''Set a context value.''' bl_idname = "wm.context_set_string" bl_label = "Context Set String" @@ -193,7 +194,7 @@ class WM_OT_context_set_string(bpy.types.Operator): # same as enum execute = execute_context_assign -class WM_OT_context_set_enum(bpy.types.Operator): +class WM_OT_context_set_enum(Operator): '''Set a context value.''' bl_idname = "wm.context_set_enum" bl_label = "Context Set Enum" @@ -207,7 +208,7 @@ class WM_OT_context_set_enum(bpy.types.Operator): execute = execute_context_assign -class WM_OT_context_set_value(bpy.types.Operator): +class WM_OT_context_set_value(Operator): '''Set a context value.''' bl_idname = "wm.context_set_value" bl_label = "Context Set Value" @@ -225,7 +226,7 @@ class WM_OT_context_set_value(bpy.types.Operator): return {'FINISHED'} -class WM_OT_context_toggle(bpy.types.Operator): +class WM_OT_context_toggle(Operator): '''Toggle a context value.''' bl_idname = "wm.context_toggle" bl_label = "Context Toggle" @@ -244,7 +245,7 @@ class WM_OT_context_toggle(bpy.types.Operator): return {'FINISHED'} -class WM_OT_context_toggle_enum(bpy.types.Operator): +class WM_OT_context_toggle_enum(Operator): '''Toggle a context value.''' bl_idname = "wm.context_toggle_enum" bl_label = "Context Toggle Values" @@ -270,7 +271,7 @@ class WM_OT_context_toggle_enum(bpy.types.Operator): return {'FINISHED'} -class WM_OT_context_cycle_int(bpy.types.Operator): +class WM_OT_context_cycle_int(Operator): '''Set a context value. Useful for cycling active material, ''' '''vertex keys, groups' etc.''' bl_idname = "wm.context_cycle_int" @@ -305,7 +306,7 @@ class WM_OT_context_cycle_int(bpy.types.Operator): return {'FINISHED'} -class WM_OT_context_cycle_enum(bpy.types.Operator): +class WM_OT_context_cycle_enum(Operator): '''Toggle a context value.''' bl_idname = "wm.context_cycle_enum" bl_label = "Context Enum Cycle" @@ -357,7 +358,7 @@ class WM_OT_context_cycle_enum(bpy.types.Operator): return {'FINISHED'} -class WM_OT_context_cycle_array(bpy.types.Operator): +class WM_OT_context_cycle_array(Operator): '''Set a context array value. Useful for cycling the active mesh edit mode.''' bl_idname = "wm.context_cycle_array" @@ -385,7 +386,7 @@ class WM_OT_context_cycle_array(bpy.types.Operator): return {'FINISHED'} -class WM_MT_context_menu_enum(bpy.types.Menu): +class WM_MT_context_menu_enum(Menu): bl_label = "" data_path = "" # BAD DESIGN, set from operator below. @@ -405,7 +406,7 @@ class WM_MT_context_menu_enum(bpy.types.Menu): prop.value = identifier -class WM_OT_context_menu_enum(bpy.types.Operator): +class WM_OT_context_menu_enum(Operator): bl_idname = "wm.context_menu_enum" bl_label = "Context Enum Menu" bl_options = {'UNDO', 'INTERNAL'} @@ -418,7 +419,7 @@ class WM_OT_context_menu_enum(bpy.types.Operator): return {'PASS_THROUGH'} -class WM_OT_context_set_id(bpy.types.Operator): +class WM_OT_context_set_id(Operator): '''Toggle a context value.''' bl_idname = "wm.context_set_id" bl_label = "Set Library ID" @@ -466,7 +467,7 @@ data_path_item = StringProperty( description="The data path from each iterable to the value (int or float)") -class WM_OT_context_collection_boolean_set(bpy.types.Operator): +class WM_OT_context_collection_boolean_set(Operator): '''Set boolean values for a collection of items''' bl_idname = "wm.context_collection_boolean_set" bl_label = "Context Collection Boolean Set" @@ -520,7 +521,7 @@ class WM_OT_context_collection_boolean_set(bpy.types.Operator): return {'FINISHED'} -class WM_OT_context_modal_mouse(bpy.types.Operator): +class WM_OT_context_modal_mouse(Operator): '''Adjust arbitrary values with mouse input''' bl_idname = "wm.context_modal_mouse" bl_label = "Context Modal Mouse" @@ -607,7 +608,7 @@ class WM_OT_context_modal_mouse(bpy.types.Operator): return {'RUNNING_MODAL'} -class WM_OT_url_open(bpy.types.Operator): +class WM_OT_url_open(Operator): "Open a website in the Webbrowser" bl_idname = "wm.url_open" bl_label = "" @@ -621,7 +622,7 @@ class WM_OT_url_open(bpy.types.Operator): return {'FINISHED'} -class WM_OT_path_open(bpy.types.Operator): +class WM_OT_path_open(Operator): "Open a path in a file browser" bl_idname = "wm.path_open" bl_label = "" @@ -654,7 +655,7 @@ class WM_OT_path_open(bpy.types.Operator): return {'FINISHED'} -class WM_OT_doc_view(bpy.types.Operator): +class WM_OT_doc_view(Operator): '''Load online reference docs''' bl_idname = "wm.doc_view" bl_label = "View Documentation" @@ -708,7 +709,7 @@ class WM_OT_doc_view(bpy.types.Operator): return {'FINISHED'} -class WM_OT_doc_edit(bpy.types.Operator): +class WM_OT_doc_edit(Operator): '''Load online reference docs''' bl_idname = "wm.doc_edit" bl_label = "Edit Documentation" @@ -792,7 +793,7 @@ rna_min = FloatProperty(name="Min", default=0.0, precision=3) rna_max = FloatProperty(name="Max", default=1.0, precision=3) -class WM_OT_properties_edit(bpy.types.Operator): +class WM_OT_properties_edit(Operator): '''Internal use (edit a property data_path)''' bl_idname = "wm.properties_edit" bl_label = "Edit Property" @@ -876,7 +877,7 @@ class WM_OT_properties_edit(bpy.types.Operator): return wm.invoke_props_dialog(self) -class WM_OT_properties_add(bpy.types.Operator): +class WM_OT_properties_add(Operator): '''Internal use (edit a property data_path)''' bl_idname = "wm.properties_add" bl_label = "Add Property" @@ -902,7 +903,7 @@ class WM_OT_properties_add(bpy.types.Operator): return {'FINISHED'} -class WM_OT_properties_context_change(bpy.types.Operator): +class WM_OT_properties_context_change(Operator): "Change the context tab in a Properties Window" bl_idname = "wm.properties_context_change" bl_label = "" @@ -914,7 +915,7 @@ class WM_OT_properties_context_change(bpy.types.Operator): return {'FINISHED'} -class WM_OT_properties_remove(bpy.types.Operator): +class WM_OT_properties_remove(Operator): '''Internal use (edit a property data_path)''' bl_idname = "wm.properties_remove" bl_label = "Remove Property" @@ -928,7 +929,7 @@ class WM_OT_properties_remove(bpy.types.Operator): return {'FINISHED'} -class WM_OT_keyconfig_activate(bpy.types.Operator): +class WM_OT_keyconfig_activate(Operator): bl_idname = "wm.keyconfig_activate" bl_label = "Activate Keyconfig" @@ -939,7 +940,7 @@ class WM_OT_keyconfig_activate(bpy.types.Operator): return {'FINISHED'} -class WM_OT_appconfig_default(bpy.types.Operator): +class WM_OT_appconfig_default(Operator): bl_idname = "wm.appconfig_default" bl_label = "Default Application Configuration" @@ -956,7 +957,7 @@ class WM_OT_appconfig_default(bpy.types.Operator): return {'FINISHED'} -class WM_OT_appconfig_activate(bpy.types.Operator): +class WM_OT_appconfig_activate(Operator): bl_idname = "wm.appconfig_activate" bl_label = "Activate Application Configuration" @@ -974,7 +975,7 @@ class WM_OT_appconfig_activate(bpy.types.Operator): return {'FINISHED'} -class WM_OT_sysinfo(bpy.types.Operator): +class WM_OT_sysinfo(Operator): '''Generate System Info''' bl_idname = "wm.sysinfo" bl_label = "System Info" @@ -985,7 +986,7 @@ class WM_OT_sysinfo(bpy.types.Operator): return {'FINISHED'} -class WM_OT_copy_prev_settings(bpy.types.Operator): +class WM_OT_copy_prev_settings(Operator): '''Copy settings from previous version''' bl_idname = "wm.copy_prev_settings" bl_label = "Copy Previous Settings" diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py index f2a3bac2373..94c40d11141 100644 --- a/release/scripts/startup/bl_ui/properties_data_armature.py +++ b/release/scripts/startup/bl_ui/properties_data_armature.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel from rna_prop_ui import PropertyPanel @@ -31,7 +32,7 @@ class ArmatureButtonsPanel(): return context.armature -class DATA_PT_context_arm(ArmatureButtonsPanel, bpy.types.Panel): +class DATA_PT_context_arm(ArmatureButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} @@ -48,7 +49,7 @@ class DATA_PT_context_arm(ArmatureButtonsPanel, bpy.types.Panel): layout.template_ID(space, "pin_id") -class DATA_PT_skeleton(ArmatureButtonsPanel, bpy.types.Panel): +class DATA_PT_skeleton(ArmatureButtonsPanel, Panel): bl_label = "Skeleton" def draw(self, context): @@ -71,7 +72,7 @@ class DATA_PT_skeleton(ArmatureButtonsPanel, bpy.types.Panel): flow.prop(arm, "use_deform_preserve_volume", text="Quaternion") -class DATA_PT_display(ArmatureButtonsPanel, bpy.types.Panel): +class DATA_PT_display(ArmatureButtonsPanel, Panel): bl_label = "Display" def draw(self, context): @@ -96,7 +97,7 @@ class DATA_PT_display(ArmatureButtonsPanel, bpy.types.Panel): col.prop(arm, "use_deform_delay", text="Delay Refresh") -class DATA_PT_bone_groups(ArmatureButtonsPanel, bpy.types.Panel): +class DATA_PT_bone_groups(ArmatureButtonsPanel, Panel): bl_label = "Bone Groups" @classmethod @@ -147,7 +148,7 @@ class DATA_PT_bone_groups(ArmatureButtonsPanel, bpy.types.Panel): sub.operator("pose.group_deselect", text="Deselect") -class DATA_PT_pose_library(ArmatureButtonsPanel, bpy.types.Panel): +class DATA_PT_pose_library(ArmatureButtonsPanel, Panel): bl_label = "Pose Library" bl_options = {'DEFAULT_CLOSED'} @@ -186,7 +187,7 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, bpy.types.Panel): # TODO: this panel will soon be depreceated too -class DATA_PT_ghost(ArmatureButtonsPanel, bpy.types.Panel): +class DATA_PT_ghost(ArmatureButtonsPanel, Panel): bl_label = "Ghost" def draw(self, context): @@ -213,7 +214,7 @@ class DATA_PT_ghost(ArmatureButtonsPanel, bpy.types.Panel): col.prop(arm, "show_only_ghost_selected", text="Selected Only") -class DATA_PT_iksolver_itasc(ArmatureButtonsPanel, bpy.types.Panel): +class DATA_PT_iksolver_itasc(ArmatureButtonsPanel, Panel): bl_label = "iTaSC parameters" bl_options = {'DEFAULT_CLOSED'} @@ -266,7 +267,7 @@ from bl_ui.properties_animviz import ( ) -class DATA_PT_motion_paths(MotionPathButtonsPanel, bpy.types.Panel): +class DATA_PT_motion_paths(MotionPathButtonsPanel, Panel): #bl_label = "Bones Motion Paths" bl_context = "data" @@ -289,7 +290,7 @@ class DATA_PT_motion_paths(MotionPathButtonsPanel, bpy.types.Panel): split.operator("pose.paths_clear", text="Clear Paths") -class DATA_PT_onion_skinning(OnionSkinButtonsPanel): # , bpy.types.Panel): # inherit from panel when ready +class DATA_PT_onion_skinning(OnionSkinButtonsPanel): # , Panel): # inherit from panel when ready #bl_label = "Bones Onion Skinning" bl_context = "data" @@ -303,7 +304,7 @@ class DATA_PT_onion_skinning(OnionSkinButtonsPanel): # , bpy.types.Panel): # in self.draw_settings(context, ob.pose.animation_visualisation, bones=True) -class DATA_PT_custom_props_arm(ArmatureButtonsPanel, PropertyPanel, bpy.types.Panel): +class DATA_PT_custom_props_arm(ArmatureButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "object.data" _property_type = bpy.types.Armature diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py b/release/scripts/startup/bl_ui/properties_data_bone.py index 9fc055e9343..b3eaf88d5bf 100644 --- a/release/scripts/startup/bl_ui/properties_data_bone.py +++ b/release/scripts/startup/bl_ui/properties_data_bone.py @@ -19,6 +19,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel from rna_prop_ui import PropertyPanel @@ -32,7 +33,7 @@ class BoneButtonsPanel(): return (context.bone or context.edit_bone) -class BONE_PT_context_bone(BoneButtonsPanel, bpy.types.Panel): +class BONE_PT_context_bone(BoneButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} @@ -48,7 +49,7 @@ class BONE_PT_context_bone(BoneButtonsPanel, bpy.types.Panel): row.prop(bone, "name", text="") -class BONE_PT_transform(BoneButtonsPanel, bpy.types.Panel): +class BONE_PT_transform(BoneButtonsPanel, Panel): bl_label = "Transform" @classmethod @@ -102,7 +103,7 @@ class BONE_PT_transform(BoneButtonsPanel, bpy.types.Panel): sub.prop(bone, "lock") -class BONE_PT_transform_locks(BoneButtonsPanel, bpy.types.Panel): +class BONE_PT_transform_locks(BoneButtonsPanel, Panel): bl_label = "Transform Locks" bl_options = {'DEFAULT_CLOSED'} @@ -135,7 +136,7 @@ class BONE_PT_transform_locks(BoneButtonsPanel, bpy.types.Panel): row.column().prop(pchan, "lock_scale") -class BONE_PT_relations(BoneButtonsPanel, bpy.types.Panel): +class BONE_PT_relations(BoneButtonsPanel, Panel): bl_label = "Relations" def draw(self, context): @@ -180,7 +181,7 @@ class BONE_PT_relations(BoneButtonsPanel, bpy.types.Panel): sub.prop(bone, "use_local_location", text="Local Location") -class BONE_PT_display(BoneButtonsPanel, bpy.types.Panel): +class BONE_PT_display(BoneButtonsPanel, Panel): bl_label = "Display" @classmethod @@ -217,7 +218,7 @@ class BONE_PT_display(BoneButtonsPanel, bpy.types.Panel): col.prop_search(pchan, "custom_shape_transform", ob.pose, "bones", text="At") -class BONE_PT_inverse_kinematics(BoneButtonsPanel, bpy.types.Panel): +class BONE_PT_inverse_kinematics(BoneButtonsPanel, Panel): bl_label = "Inverse Kinematics" bl_options = {'DEFAULT_CLOSED'} @@ -308,7 +309,7 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel, bpy.types.Panel): #row.prop(pchan, "ik_linear_weight", text="Weight", slider=True) -class BONE_PT_deform(BoneButtonsPanel, bpy.types.Panel): +class BONE_PT_deform(BoneButtonsPanel, Panel): bl_label = "Deform" bl_options = {'DEFAULT_CLOSED'} @@ -357,7 +358,7 @@ class BONE_PT_deform(BoneButtonsPanel, bpy.types.Panel): col.prop(bone, "use_cyclic_offset") -class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel, bpy.types.Panel): +class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _property_type = bpy.types.Bone, bpy.types.EditBone, bpy.types.PoseBone diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py index 80cd5227fca..f484d7b59e1 100644 --- a/release/scripts/startup/bl_ui/properties_data_camera.py +++ b/release/scripts/startup/bl_ui/properties_data_camera.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel from rna_prop_ui import PropertyPanel @@ -32,7 +33,7 @@ class CameraButtonsPanel(): return context.camera and (engine in cls.COMPAT_ENGINES) -class DATA_PT_context_camera(CameraButtonsPanel, bpy.types.Panel): +class DATA_PT_context_camera(CameraButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -53,7 +54,7 @@ class DATA_PT_context_camera(CameraButtonsPanel, bpy.types.Panel): split.separator() -class DATA_PT_camera(CameraButtonsPanel, bpy.types.Panel): +class DATA_PT_camera(CameraButtonsPanel, Panel): bl_label = "Lens" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -111,7 +112,7 @@ class DATA_PT_camera(CameraButtonsPanel, bpy.types.Panel): col.prop(cam, "dof_distance", text="Distance") -class DATA_PT_camera_display(CameraButtonsPanel, bpy.types.Panel): +class DATA_PT_camera_display(CameraButtonsPanel, Panel): bl_label = "Display" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -138,7 +139,7 @@ class DATA_PT_camera_display(CameraButtonsPanel, bpy.types.Panel): sub.prop(cam, "passepartout_alpha", text="Alpha", slider=True) -class DATA_PT_custom_props_camera(CameraButtonsPanel, PropertyPanel, bpy.types.Panel): +class DATA_PT_custom_props_camera(CameraButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "object.data" _property_type = bpy.types.Camera diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py index a0aacc4cec8..7bc136c8ce0 100644 --- a/release/scripts/startup/bl_ui/properties_data_curve.py +++ b/release/scripts/startup/bl_ui/properties_data_curve.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel from rna_prop_ui import PropertyPanel @@ -48,7 +49,7 @@ class CurveButtonsPanelActive(CurveButtonsPanel): return (curve and type(curve) is not bpy.types.TextCurve and curve.splines.active) -class DATA_PT_context_curve(CurveButtonsPanel, bpy.types.Panel): +class DATA_PT_context_curve(CurveButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} @@ -65,7 +66,7 @@ class DATA_PT_context_curve(CurveButtonsPanel, bpy.types.Panel): layout.template_ID(space, "pin_id") # XXX: broken -class DATA_PT_shape_curve(CurveButtonsPanel, bpy.types.Panel): +class DATA_PT_shape_curve(CurveButtonsPanel, Panel): bl_label = "Shape" def draw(self, context): @@ -114,7 +115,7 @@ class DATA_PT_shape_curve(CurveButtonsPanel, bpy.types.Panel): col.prop(curve, "use_fill_deform", text="Fill Deformed") -class DATA_PT_curve_texture_space(CurveButtonsPanel, bpy.types.Panel): +class DATA_PT_curve_texture_space(CurveButtonsPanel, Panel): bl_label = "Texture Space" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -133,7 +134,7 @@ class DATA_PT_curve_texture_space(CurveButtonsPanel, bpy.types.Panel): row.column().prop(curve, "texspace_size", text="Size") -class DATA_PT_geometry_curve(CurveButtonsPanel, bpy.types.Panel): +class DATA_PT_geometry_curve(CurveButtonsPanel, Panel): bl_label = "Geometry" @classmethod @@ -166,7 +167,7 @@ class DATA_PT_geometry_curve(CurveButtonsPanel, bpy.types.Panel): col.prop(curve, "bevel_object", text="") -class DATA_PT_pathanim(CurveButtonsPanelCurve, bpy.types.Panel): +class DATA_PT_pathanim(CurveButtonsPanelCurve, Panel): bl_label = "Path Animation" def draw_header(self, context): @@ -197,7 +198,7 @@ class DATA_PT_pathanim(CurveButtonsPanelCurve, bpy.types.Panel): col.prop(curve, "use_time_offset", text="Offset Children") -class DATA_PT_active_spline(CurveButtonsPanelActive, bpy.types.Panel): +class DATA_PT_active_spline(CurveButtonsPanelActive, Panel): bl_label = "Active Spline" def draw(self, context): @@ -268,7 +269,7 @@ class DATA_PT_active_spline(CurveButtonsPanelActive, bpy.types.Panel): layout.prop(act_spline, "use_smooth") -class DATA_PT_font(CurveButtonsPanel, bpy.types.Panel): +class DATA_PT_font(CurveButtonsPanel, Panel): bl_label = "Font" @classmethod @@ -332,7 +333,7 @@ class DATA_PT_font(CurveButtonsPanel, bpy.types.Panel): row.prop(char, "use_small_caps") -class DATA_PT_paragraph(CurveButtonsPanel, bpy.types.Panel): +class DATA_PT_paragraph(CurveButtonsPanel, Panel): bl_label = "Paragraph" @classmethod @@ -361,7 +362,7 @@ class DATA_PT_paragraph(CurveButtonsPanel, bpy.types.Panel): col.prop(text, "offset_y", text="Y") -class DATA_PT_text_boxes(CurveButtonsPanel, bpy.types.Panel): +class DATA_PT_text_boxes(CurveButtonsPanel, Panel): bl_label = "Text Boxes" @classmethod @@ -401,7 +402,7 @@ class DATA_PT_text_boxes(CurveButtonsPanel, bpy.types.Panel): row.operator("font.textbox_remove", text='', icon='X', emboss=False).index = i -class DATA_PT_custom_props_curve(CurveButtonsPanel, PropertyPanel, bpy.types.Panel): +class DATA_PT_custom_props_curve(CurveButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "object.data" _property_type = bpy.types.Curve diff --git a/release/scripts/startup/bl_ui/properties_data_empty.py b/release/scripts/startup/bl_ui/properties_data_empty.py index 42b0af7eaf5..c781873e16c 100644 --- a/release/scripts/startup/bl_ui/properties_data_empty.py +++ b/release/scripts/startup/bl_ui/properties_data_empty.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel class DataButtonsPanel(): @@ -30,7 +31,7 @@ class DataButtonsPanel(): return (context.object and context.object.type == 'EMPTY') -class DATA_PT_empty(DataButtonsPanel, bpy.types.Panel): +class DATA_PT_empty(DataButtonsPanel, Panel): bl_label = "Empty" def draw(self, context): diff --git a/release/scripts/startup/bl_ui/properties_data_lamp.py b/release/scripts/startup/bl_ui/properties_data_lamp.py index 36010c8b511..4ff180f74fb 100644 --- a/release/scripts/startup/bl_ui/properties_data_lamp.py +++ b/release/scripts/startup/bl_ui/properties_data_lamp.py @@ -18,15 +18,16 @@ # <pep8 compliant> import bpy +from bpy.types import Menu, Panel from rna_prop_ui import PropertyPanel -class LAMP_MT_sunsky_presets(bpy.types.Menu): +class LAMP_MT_sunsky_presets(Menu): bl_label = "Sun & Sky Presets" preset_subdir = "sunsky" preset_operator = "script.execute_preset" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - draw = bpy.types.Menu.draw_preset + draw = Menu.draw_preset class DataButtonsPanel(): @@ -40,7 +41,7 @@ class DataButtonsPanel(): return context.lamp and (engine in cls.COMPAT_ENGINES) -class DATA_PT_context_lamp(DataButtonsPanel, bpy.types.Panel): +class DATA_PT_context_lamp(DataButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -65,7 +66,7 @@ class DATA_PT_context_lamp(DataButtonsPanel, bpy.types.Panel): split.label(text=str(texture_count), icon='TEXTURE') -class DATA_PT_preview(DataButtonsPanel, bpy.types.Panel): +class DATA_PT_preview(DataButtonsPanel, Panel): bl_label = "Preview" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -73,7 +74,7 @@ class DATA_PT_preview(DataButtonsPanel, bpy.types.Panel): self.layout.template_preview(context.lamp) -class DATA_PT_lamp(DataButtonsPanel, bpy.types.Panel): +class DATA_PT_lamp(DataButtonsPanel, Panel): bl_label = "Lamp" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -115,7 +116,7 @@ class DATA_PT_lamp(DataButtonsPanel, bpy.types.Panel): col.prop(lamp, "use_diffuse") -class DATA_PT_sunsky(DataButtonsPanel, bpy.types.Panel): +class DATA_PT_sunsky(DataButtonsPanel, Panel): bl_label = "Sky & Atmosphere" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -187,7 +188,7 @@ class DATA_PT_sunsky(DataButtonsPanel, bpy.types.Panel): sub.prop(lamp, "atmosphere_extinction", slider=True, text="Extinction") -class DATA_PT_shadow(DataButtonsPanel, bpy.types.Panel): +class DATA_PT_shadow(DataButtonsPanel, Panel): bl_label = "Shadow" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -302,7 +303,7 @@ class DATA_PT_shadow(DataButtonsPanel, bpy.types.Panel): sub.prop(lamp, "shadow_buffer_clip_end", text=" Clip End") -class DATA_PT_area(DataButtonsPanel, bpy.types.Panel): +class DATA_PT_area(DataButtonsPanel, Panel): bl_label = "Area Shape" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -328,7 +329,7 @@ class DATA_PT_area(DataButtonsPanel, bpy.types.Panel): sub.prop(lamp, "size_y", text="Size Y") -class DATA_PT_spot(DataButtonsPanel, bpy.types.Panel): +class DATA_PT_spot(DataButtonsPanel, Panel): bl_label = "Spot Shape" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -362,7 +363,7 @@ class DATA_PT_spot(DataButtonsPanel, bpy.types.Panel): sub.prop(lamp, "halo_step", text="Step") -class DATA_PT_falloff_curve(DataButtonsPanel, bpy.types.Panel): +class DATA_PT_falloff_curve(DataButtonsPanel, Panel): bl_label = "Falloff Curve" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -380,7 +381,7 @@ class DATA_PT_falloff_curve(DataButtonsPanel, bpy.types.Panel): self.layout.template_curve_mapping(lamp, "falloff_curve") -class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel, bpy.types.Panel): +class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "object.data" _property_type = bpy.types.Lamp diff --git a/release/scripts/startup/bl_ui/properties_data_lattice.py b/release/scripts/startup/bl_ui/properties_data_lattice.py index cd719b6fe84..14d6ea66894 100644 --- a/release/scripts/startup/bl_ui/properties_data_lattice.py +++ b/release/scripts/startup/bl_ui/properties_data_lattice.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel from rna_prop_ui import PropertyPanel @@ -31,7 +32,7 @@ class DataButtonsPanel(): return context.lattice -class DATA_PT_context_lattice(DataButtonsPanel, bpy.types.Panel): +class DATA_PT_context_lattice(DataButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} @@ -51,7 +52,7 @@ class DATA_PT_context_lattice(DataButtonsPanel, bpy.types.Panel): split.separator() -class DATA_PT_lattice(DataButtonsPanel, bpy.types.Panel): +class DATA_PT_lattice(DataButtonsPanel, Panel): bl_label = "Lattice" def draw(self, context): @@ -76,7 +77,7 @@ class DATA_PT_lattice(DataButtonsPanel, bpy.types.Panel): row.prop_search(lat, "vertex_group", context.object, "vertex_groups", text="") -class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel, bpy.types.Panel): +class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "object.data" _property_type = bpy.types.Lattice diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index 618a88f0879..896b76c59f6 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -18,10 +18,11 @@ # <pep8 compliant> import bpy +from bpy.types import Menu, Panel from rna_prop_ui import PropertyPanel -class MESH_MT_vertex_group_specials(bpy.types.Menu): +class MESH_MT_vertex_group_specials(Menu): bl_label = "Vertex Group Specials" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -36,7 +37,7 @@ class MESH_MT_vertex_group_specials(bpy.types.Menu): layout.operator("object.vertex_group_remove", icon='X', text="Delete All").all = True -class MESH_MT_shape_key_specials(bpy.types.Menu): +class MESH_MT_shape_key_specials(Menu): bl_label = "Shape Key Specials" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -61,7 +62,7 @@ class MeshButtonsPanel(): return context.mesh and (engine in cls.COMPAT_ENGINES) -class DATA_PT_context_mesh(MeshButtonsPanel, bpy.types.Panel): +class DATA_PT_context_mesh(MeshButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -72,14 +73,14 @@ class DATA_PT_context_mesh(MeshButtonsPanel, bpy.types.Panel): ob = context.object mesh = context.mesh space = context.space_data - + layout.prop(context.scene.tool_settings, "mesh_select_mode", index=0, text="Vertex") if ob: layout.template_ID(ob, "data") elif mesh: layout.template_ID(space, "pin_id") -class DATA_PT_normals(MeshButtonsPanel, bpy.types.Panel): +class DATA_PT_normals(MeshButtonsPanel, Panel): bl_label = "Normals" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -99,7 +100,7 @@ class DATA_PT_normals(MeshButtonsPanel, bpy.types.Panel): split.prop(mesh, "show_double_sided") -class DATA_PT_texture_space(MeshButtonsPanel, bpy.types.Panel): +class DATA_PT_texture_space(MeshButtonsPanel, Panel): bl_label = "Texture Space" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -119,7 +120,7 @@ class DATA_PT_texture_space(MeshButtonsPanel, bpy.types.Panel): row.column().prop(mesh, "texspace_size", text="Size") -class DATA_PT_vertex_groups(MeshButtonsPanel, bpy.types.Panel): +class DATA_PT_vertex_groups(MeshButtonsPanel, Panel): bl_label = "Vertex Groups" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -168,7 +169,7 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, bpy.types.Panel): layout.prop(context.tool_settings, "vertex_group_weight", text="Weight") -class DATA_PT_shape_keys(MeshButtonsPanel, bpy.types.Panel): +class DATA_PT_shape_keys(MeshButtonsPanel, Panel): bl_label = "Shape Keys" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -261,7 +262,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, bpy.types.Panel): row.prop(key, "slurph") -class DATA_PT_uv_texture(MeshButtonsPanel, bpy.types.Panel): +class DATA_PT_uv_texture(MeshButtonsPanel, Panel): bl_label = "UV Texture" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -284,7 +285,7 @@ class DATA_PT_uv_texture(MeshButtonsPanel, bpy.types.Panel): layout.prop(lay, "name") -class DATA_PT_texface(MeshButtonsPanel, bpy.types.Panel): +class DATA_PT_texface(MeshButtonsPanel, Panel): bl_label = "Texture Face" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -331,7 +332,7 @@ class DATA_PT_texface(MeshButtonsPanel, bpy.types.Panel): col.label(text="No UV Texture") -class DATA_PT_vertex_colors(MeshButtonsPanel, bpy.types.Panel): +class DATA_PT_vertex_colors(MeshButtonsPanel, Panel): bl_label = "Vertex Colors" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -354,7 +355,7 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, bpy.types.Panel): layout.prop(lay, "name") -class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, bpy.types.Panel): +class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "object.data" _property_type = bpy.types.Mesh diff --git a/release/scripts/startup/bl_ui/properties_data_metaball.py b/release/scripts/startup/bl_ui/properties_data_metaball.py index 6dda99bc37f..cd894e60dbb 100644 --- a/release/scripts/startup/bl_ui/properties_data_metaball.py +++ b/release/scripts/startup/bl_ui/properties_data_metaball.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel from rna_prop_ui import PropertyPanel @@ -31,7 +32,7 @@ class DataButtonsPanel(): return context.meta_ball -class DATA_PT_context_metaball(DataButtonsPanel, bpy.types.Panel): +class DATA_PT_context_metaball(DataButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} @@ -48,7 +49,7 @@ class DATA_PT_context_metaball(DataButtonsPanel, bpy.types.Panel): layout.template_ID(space, "pin_id") -class DATA_PT_metaball(DataButtonsPanel, bpy.types.Panel): +class DATA_PT_metaball(DataButtonsPanel, Panel): bl_label = "Metaball" def draw(self, context): @@ -72,7 +73,7 @@ class DATA_PT_metaball(DataButtonsPanel, bpy.types.Panel): layout.prop(mball, "update_method", expand=True) -class DATA_PT_mball_texture_space(DataButtonsPanel, bpy.types.Panel): +class DATA_PT_mball_texture_space(DataButtonsPanel, Panel): bl_label = "Texture Space" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -89,7 +90,7 @@ class DATA_PT_mball_texture_space(DataButtonsPanel, bpy.types.Panel): row.column().prop(mball, "texspace_size", text="Size") -class DATA_PT_metaball_element(DataButtonsPanel, bpy.types.Panel): +class DATA_PT_metaball_element(DataButtonsPanel, Panel): bl_label = "Active Element" @classmethod @@ -129,7 +130,7 @@ class DATA_PT_metaball_element(DataButtonsPanel, bpy.types.Panel): col.prop(metaelem, "size_y", text="Y") -class DATA_PT_custom_props_metaball(DataButtonsPanel, PropertyPanel, bpy.types.Panel): +class DATA_PT_custom_props_metaball(DataButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "object.data" _property_type = bpy.types.MetaBall diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index d48aa61146a..a24fc10e984 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel class ModifierButtonsPanel(): @@ -26,7 +27,7 @@ class ModifierButtonsPanel(): bl_context = "modifier" -class DATA_PT_modifiers(ModifierButtonsPanel, bpy.types.Panel): +class DATA_PT_modifiers(ModifierButtonsPanel, Panel): bl_label = "Modifiers" def draw(self, context): @@ -580,13 +581,13 @@ class DATA_PT_modifiers(ModifierButtonsPanel, bpy.types.Panel): sub = col.column() sub.active = bool(md.vertex_group) sub.prop(md, "invert_vertex_group", text="Invert") + sub.prop(md, "thickness_vertex_group", text="Factor") col.prop(md, "use_even_offset") col.prop(md, "use_quality_normals") col.prop(md, "use_rim") sub = col.column() - sub.label() row = sub.split(align=True, percentage=0.4) row.prop(md, "material_offset", text="") row = row.row() diff --git a/release/scripts/startup/bl_ui/properties_game.py b/release/scripts/startup/bl_ui/properties_game.py index 0c07451b3b2..f8be32e6c07 100644 --- a/release/scripts/startup/bl_ui/properties_game.py +++ b/release/scripts/startup/bl_ui/properties_game.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel class PhysicsButtonsPanel(): @@ -26,7 +27,7 @@ class PhysicsButtonsPanel(): bl_context = "physics" -class PHYSICS_PT_game_physics(PhysicsButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_game_physics(PhysicsButtonsPanel, Panel): bl_label = "Physics" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -167,7 +168,7 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel, bpy.types.Panel): layout.prop(ob, "hide_render", text="Invisible") -class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel, Panel): bl_label = "Collision Bounds" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -206,7 +207,7 @@ class RenderButtonsPanel(): return (rd.engine in cls.COMPAT_ENGINES) -class RENDER_PT_game(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_game(RenderButtonsPanel, Panel): bl_label = "Game" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -218,7 +219,7 @@ class RENDER_PT_game(RenderButtonsPanel, bpy.types.Panel): row.label() -class RENDER_PT_game_player(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_game_player(RenderButtonsPanel, Panel): bl_label = "Standalone Player" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -251,7 +252,7 @@ class RENDER_PT_game_player(RenderButtonsPanel, bpy.types.Panel): col.prop(gs, "frame_color", text="") -class RENDER_PT_game_stereo(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_game_stereo(RenderButtonsPanel, Panel): bl_label = "Stereo" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -305,7 +306,7 @@ class RENDER_PT_game_stereo(RenderButtonsPanel, bpy.types.Panel): layout.prop(gs, "dome_text") -class RENDER_PT_game_shading(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_game_shading(RenderButtonsPanel, Panel): bl_label = "Shading" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -331,7 +332,7 @@ class RENDER_PT_game_shading(RenderButtonsPanel, bpy.types.Panel): col.prop(gs, "use_glsl_extra_textures", text="Extra Textures") -class RENDER_PT_game_performance(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_game_performance(RenderButtonsPanel, Panel): bl_label = "Performance" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -344,7 +345,7 @@ class RENDER_PT_game_performance(RenderButtonsPanel, bpy.types.Panel): row.prop(gs, "use_display_lists") -class RENDER_PT_game_display(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_game_display(RenderButtonsPanel, Panel): bl_label = "Display" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -360,7 +361,7 @@ class RENDER_PT_game_display(RenderButtonsPanel, bpy.types.Panel): flow.prop(gs, "show_mouse", text="Mouse Cursor") -class RENDER_PT_game_sound(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_game_sound(RenderButtonsPanel, Panel): bl_label = "Sound" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -381,7 +382,7 @@ class WorldButtonsPanel(): bl_context = "world" -class WORLD_PT_game_context_world(WorldButtonsPanel, bpy.types.Panel): +class WORLD_PT_game_context_world(WorldButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} COMPAT_ENGINES = {'BLENDER_GAME'} @@ -405,7 +406,7 @@ class WORLD_PT_game_context_world(WorldButtonsPanel, bpy.types.Panel): split.template_ID(space, "pin_id") -class WORLD_PT_game_world(WorldButtonsPanel, bpy.types.Panel): +class WORLD_PT_game_world(WorldButtonsPanel, Panel): bl_label = "World" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -424,7 +425,7 @@ class WORLD_PT_game_world(WorldButtonsPanel, bpy.types.Panel): row.column().prop(world, "ambient_color") -class WORLD_PT_game_mist(WorldButtonsPanel, bpy.types.Panel): +class WORLD_PT_game_mist(WorldButtonsPanel, Panel): bl_label = "Mist" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -450,7 +451,7 @@ class WORLD_PT_game_mist(WorldButtonsPanel, bpy.types.Panel): row.prop(world.mist_settings, "depth") -class WORLD_PT_game_physics(WorldButtonsPanel, bpy.types.Panel): +class WORLD_PT_game_physics(WorldButtonsPanel, Panel): bl_label = "Physics" COMPAT_ENGINES = {'BLENDER_GAME'} diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index 296c05d78f5..13ce92f084c 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Menu, Panel from rna_prop_ui import PropertyPanel @@ -50,14 +51,14 @@ def simple_material(mat): return False -class MATERIAL_MT_sss_presets(bpy.types.Menu): +class MATERIAL_MT_sss_presets(Menu): bl_label = "SSS Presets" preset_subdir = "sss" preset_operator = "script.execute_preset" - draw = bpy.types.Menu.draw_preset + draw = Menu.draw_preset -class MATERIAL_MT_specials(bpy.types.Menu): +class MATERIAL_MT_specials(Menu): bl_label = "Material Specials" def draw(self, context): @@ -79,7 +80,7 @@ class MaterialButtonsPanel(): return context.material and (context.scene.render.engine in cls.COMPAT_ENGINES) -class MATERIAL_PT_context_material(MaterialButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_context_material(MaterialButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -144,7 +145,7 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel, bpy.types.Panel): row.label(text="No material node selected") -class MATERIAL_PT_preview(MaterialButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_preview(MaterialButtonsPanel, Panel): bl_label = "Preview" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -152,7 +153,7 @@ class MATERIAL_PT_preview(MaterialButtonsPanel, bpy.types.Panel): self.layout.template_preview(context.material) -class MATERIAL_PT_pipeline(MaterialButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_pipeline(MaterialButtonsPanel, Panel): bl_label = "Render Pipeline Options" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -203,7 +204,7 @@ class MATERIAL_PT_pipeline(MaterialButtonsPanel, bpy.types.Panel): col.prop(mat, "pass_index") -class MATERIAL_PT_diffuse(MaterialButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_diffuse(MaterialButtonsPanel, Panel): bl_label = "Diffuse" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -260,7 +261,7 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel, bpy.types.Panel): col.prop(mat, "diffuse_ramp_factor", text="Factor") -class MATERIAL_PT_specular(MaterialButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_specular(MaterialButtonsPanel, Panel): bl_label = "Specular" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -313,7 +314,7 @@ class MATERIAL_PT_specular(MaterialButtonsPanel, bpy.types.Panel): layout.prop(mat, "specular_ramp_factor", text="Factor") -class MATERIAL_PT_shading(MaterialButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_shading(MaterialButtonsPanel, Panel): bl_label = "Shading" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -347,7 +348,7 @@ class MATERIAL_PT_shading(MaterialButtonsPanel, bpy.types.Panel): sub.prop(mat, "use_cubic") -class MATERIAL_PT_transp(MaterialButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_transp(MaterialButtonsPanel, Panel): bl_label = "Transparency" # bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -413,7 +414,7 @@ class MATERIAL_PT_transp(MaterialButtonsPanel, bpy.types.Panel): sub.prop(rayt, "gloss_samples", text="Samples") -class MATERIAL_PT_mirror(MaterialButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_mirror(MaterialButtonsPanel, Panel): bl_label = "Mirror" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -471,7 +472,7 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel, bpy.types.Panel): sub.prop(raym, "gloss_anisotropic", text="Anisotropic") -class MATERIAL_PT_sss(MaterialButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_sss(MaterialButtonsPanel, Panel): bl_label = "Subsurface Scattering" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -523,7 +524,7 @@ class MATERIAL_PT_sss(MaterialButtonsPanel, bpy.types.Panel): col.prop(sss, "error_threshold", text="Error") -class MATERIAL_PT_halo(MaterialButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_halo(MaterialButtonsPanel, Panel): bl_label = "Halo" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -576,7 +577,7 @@ class MATERIAL_PT_halo(MaterialButtonsPanel, bpy.types.Panel): number_but(col, "use_star", "star_tip_count", "Star tips", "") -class MATERIAL_PT_flare(MaterialButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_flare(MaterialButtonsPanel, Panel): bl_label = "Flare" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -611,7 +612,7 @@ class MATERIAL_PT_flare(MaterialButtonsPanel, bpy.types.Panel): col.prop(halo, "flare_subflare_size", text="Subsize") -class MATERIAL_PT_physics(MaterialButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_physics(MaterialButtonsPanel, Panel): bl_label = "Physics" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -641,7 +642,7 @@ class MATERIAL_PT_physics(MaterialButtonsPanel, bpy.types.Panel): row.prop(phys, "use_fh_normal") -class MATERIAL_PT_strand(MaterialButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_strand(MaterialButtonsPanel, Panel): bl_label = "Strand" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -688,7 +689,7 @@ class MATERIAL_PT_strand(MaterialButtonsPanel, bpy.types.Panel): sub.prop(tan, "blend_distance", text="Distance") -class MATERIAL_PT_options(MaterialButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_options(MaterialButtonsPanel, Panel): bl_label = "Options" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -737,7 +738,7 @@ class MATERIAL_PT_options(MaterialButtonsPanel, bpy.types.Panel): col.prop(mat, "pass_index") -class MATERIAL_PT_shadow(MaterialButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_shadow(MaterialButtonsPanel, Panel): bl_label = "Shadow" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -781,7 +782,7 @@ class MATERIAL_PT_shadow(MaterialButtonsPanel, bpy.types.Panel): col.prop(mat, "use_cast_approximate") -class MATERIAL_PT_transp_game(MaterialButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_transp_game(MaterialButtonsPanel, Panel): bl_label = "Transparency" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_GAME'} @@ -824,7 +825,7 @@ class VolumeButtonsPanel(): return mat and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES) -class MATERIAL_PT_volume_density(VolumeButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_volume_density(VolumeButtonsPanel, Panel): bl_label = "Density" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -838,7 +839,7 @@ class MATERIAL_PT_volume_density(VolumeButtonsPanel, bpy.types.Panel): row.prop(vol, "density_scale") -class MATERIAL_PT_volume_shading(VolumeButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_volume_shading(VolumeButtonsPanel, Panel): bl_label = "Shading" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -863,7 +864,7 @@ class MATERIAL_PT_volume_shading(VolumeButtonsPanel, bpy.types.Panel): sub.prop(vol, "reflection_color", text="") -class MATERIAL_PT_volume_lighting(VolumeButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_volume_lighting(VolumeButtonsPanel, Panel): bl_label = "Lighting" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -898,7 +899,7 @@ class MATERIAL_PT_volume_lighting(VolumeButtonsPanel, bpy.types.Panel): sub.prop(vol, "ms_intensity") -class MATERIAL_PT_volume_transp(VolumeButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_volume_transp(VolumeButtonsPanel, Panel): bl_label = "Transparency" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -916,7 +917,7 @@ class MATERIAL_PT_volume_transp(VolumeButtonsPanel, bpy.types.Panel): layout.prop(mat, "transparency_method", expand=True) -class MATERIAL_PT_volume_integration(VolumeButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_volume_integration(VolumeButtonsPanel, Panel): bl_label = "Integration" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -938,7 +939,7 @@ class MATERIAL_PT_volume_integration(VolumeButtonsPanel, bpy.types.Panel): col.prop(vol, "depth_threshold") -class MATERIAL_PT_volume_options(VolumeButtonsPanel, bpy.types.Panel): +class MATERIAL_PT_volume_options(VolumeButtonsPanel, Panel): bl_label = "Options" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} bl_options = {'DEFAULT_CLOSED'} @@ -970,7 +971,7 @@ class MATERIAL_PT_volume_options(VolumeButtonsPanel, bpy.types.Panel): row.prop(mat, "use_light_group_exclusive", text="Exclusive") -class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel, bpy.types.Panel): +class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "material" _property_type = bpy.types.Material diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py index cdbcf2cf533..0779debb102 100644 --- a/release/scripts/startup/bl_ui/properties_object.py +++ b/release/scripts/startup/bl_ui/properties_object.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel from rna_prop_ui import PropertyPanel @@ -27,7 +28,7 @@ class ObjectButtonsPanel(): bl_context = "object" -class OBJECT_PT_context_object(ObjectButtonsPanel, bpy.types.Panel): +class OBJECT_PT_context_object(ObjectButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} @@ -42,7 +43,7 @@ class OBJECT_PT_context_object(ObjectButtonsPanel, bpy.types.Panel): row.template_ID(context.scene.objects, "active") -class OBJECT_PT_transform(ObjectButtonsPanel, bpy.types.Panel): +class OBJECT_PT_transform(ObjectButtonsPanel, Panel): bl_label = "Transform" def draw(self, context): @@ -68,7 +69,7 @@ class OBJECT_PT_transform(ObjectButtonsPanel, bpy.types.Panel): layout.prop(ob, "rotation_mode") -class OBJECT_PT_delta_transform(ObjectButtonsPanel, bpy.types.Panel): +class OBJECT_PT_delta_transform(ObjectButtonsPanel, Panel): bl_label = "Delta Transform" bl_options = {'DEFAULT_CLOSED'} @@ -94,7 +95,7 @@ class OBJECT_PT_delta_transform(ObjectButtonsPanel, bpy.types.Panel): row.column().prop(ob, "delta_scale") -class OBJECT_PT_transform_locks(ObjectButtonsPanel, bpy.types.Panel): +class OBJECT_PT_transform_locks(ObjectButtonsPanel, Panel): bl_label = "Transform Locks" bl_options = {'DEFAULT_CLOSED'} @@ -120,7 +121,7 @@ class OBJECT_PT_transform_locks(ObjectButtonsPanel, bpy.types.Panel): row.column().prop(ob, "lock_scale", text="Scale") -class OBJECT_PT_relations(ObjectButtonsPanel, bpy.types.Panel): +class OBJECT_PT_relations(ObjectButtonsPanel, Panel): bl_label = "Relations" def draw(self, context): @@ -147,7 +148,7 @@ class OBJECT_PT_relations(ObjectButtonsPanel, bpy.types.Panel): sub.active = (parent is not None) -class OBJECT_PT_groups(ObjectButtonsPanel, bpy.types.Panel): +class OBJECT_PT_groups(ObjectButtonsPanel, Panel): bl_label = "Groups" def draw(self, context): @@ -186,7 +187,7 @@ class OBJECT_PT_groups(ObjectButtonsPanel, bpy.types.Panel): index += 1 -class OBJECT_PT_display(ObjectButtonsPanel, bpy.types.Panel): +class OBJECT_PT_display(ObjectButtonsPanel, Panel): bl_label = "Display" def draw(self, context): @@ -220,7 +221,7 @@ class OBJECT_PT_display(ObjectButtonsPanel, bpy.types.Panel): col.prop(ob, "show_transparent", text="Transparency") -class OBJECT_PT_duplication(ObjectButtonsPanel, bpy.types.Panel): +class OBJECT_PT_duplication(ObjectButtonsPanel, Panel): bl_label = "Duplication" def draw(self, context): @@ -258,7 +259,7 @@ class OBJECT_PT_duplication(ObjectButtonsPanel, bpy.types.Panel): # XXX: the following options are all quite buggy, ancient hacks that should be dropped -class OBJECT_PT_animation(ObjectButtonsPanel, bpy.types.Panel): +class OBJECT_PT_animation(ObjectButtonsPanel, Panel): bl_label = "Animation Hacks" bl_options = {'DEFAULT_CLOSED'} @@ -293,7 +294,7 @@ from bl_ui.properties_animviz import ( ) -class OBJECT_PT_motion_paths(MotionPathButtonsPanel, bpy.types.Panel): +class OBJECT_PT_motion_paths(MotionPathButtonsPanel, Panel): #bl_label = "Object Motion Paths" bl_context = "object" @@ -315,7 +316,7 @@ class OBJECT_PT_motion_paths(MotionPathButtonsPanel, bpy.types.Panel): row.operator("object.paths_clear", text="Clear Paths") -class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel): # , bpy.types.Panel): # inherit from panel when ready +class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel): # , Panel): # inherit from panel when ready #bl_label = "Object Onion Skinning" bl_context = "object" @@ -329,7 +330,7 @@ class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel): # , bpy.types.Panel): # self.draw_settings(context, ob.animation_visualisation) -class OBJECT_PT_custom_props(ObjectButtonsPanel, PropertyPanel, bpy.types.Panel): +class OBJECT_PT_custom_props(ObjectButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "object" _property_type = bpy.types.Object diff --git a/release/scripts/startup/bl_ui/properties_object_constraint.py b/release/scripts/startup/bl_ui/properties_object_constraint.py index 5f79dd3127a..867abe4dd5d 100644 --- a/release/scripts/startup/bl_ui/properties_object_constraint.py +++ b/release/scripts/startup/bl_ui/properties_object_constraint.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel class ConstraintButtonsPanel(): @@ -755,7 +756,7 @@ class ConstraintButtonsPanel(): layout.label("Blender 2.5 has no py-constraints") -class OBJECT_PT_constraints(ConstraintButtonsPanel, bpy.types.Panel): +class OBJECT_PT_constraints(ConstraintButtonsPanel, Panel): bl_label = "Object Constraints" bl_context = "constraint" @@ -779,7 +780,7 @@ class OBJECT_PT_constraints(ConstraintButtonsPanel, bpy.types.Panel): self.draw_constraint(context, con) -class BONE_PT_constraints(ConstraintButtonsPanel, bpy.types.Panel): +class BONE_PT_constraints(ConstraintButtonsPanel, Panel): bl_label = "Bone Constraints" bl_context = "bone_constraint" diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 2870aab75ef..03243d1153b 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel from rna_prop_ui import PropertyPanel from bl_ui.properties_physics_common import ( @@ -72,7 +73,7 @@ class ParticleButtonsPanel(): return particle_panel_poll(cls, context) -class PARTICLE_PT_context_particles(ParticleButtonsPanel, bpy.types.Panel): +class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -176,7 +177,7 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, bpy.types.Panel): split.prop(psys, "reactor_target_particle_system", text="Particle System") -class PARTICLE_PT_emission(ParticleButtonsPanel, bpy.types.Panel): +class PARTICLE_PT_emission(ParticleButtonsPanel, Panel): bl_label = "Emission" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -245,7 +246,7 @@ class PARTICLE_PT_emission(ParticleButtonsPanel, bpy.types.Panel): row.prop(part, "grid_random", text="Random", slider=True) -class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, bpy.types.Panel): +class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel): bl_label = "Hair dynamics" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -301,7 +302,7 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, bpy.types.Panel): col.prop(cloth, "quality", text="Steps", slider=True) -class PARTICLE_PT_cache(ParticleButtonsPanel, bpy.types.Panel): +class PARTICLE_PT_cache(ParticleButtonsPanel, Panel): bl_label = "Cache" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -327,7 +328,7 @@ class PARTICLE_PT_cache(ParticleButtonsPanel, bpy.types.Panel): point_cache_ui(self, context, psys.point_cache, True, 'HAIR' if (psys.settings.type == 'HAIR') else 'PSYS') -class PARTICLE_PT_velocity(ParticleButtonsPanel, bpy.types.Panel): +class PARTICLE_PT_velocity(ParticleButtonsPanel, Panel): bl_label = "Velocity" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -377,7 +378,7 @@ class PARTICLE_PT_velocity(ParticleButtonsPanel, bpy.types.Panel): # sub.prop(part, "reaction_shape", slider=True) -class PARTICLE_PT_rotation(ParticleButtonsPanel, bpy.types.Panel): +class PARTICLE_PT_rotation(ParticleButtonsPanel, Panel): bl_label = "Rotation" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -426,7 +427,7 @@ class PARTICLE_PT_rotation(ParticleButtonsPanel, bpy.types.Panel): col.prop(part, "angular_velocity_factor", text="") -class PARTICLE_PT_physics(ParticleButtonsPanel, bpy.types.Panel): +class PARTICLE_PT_physics(ParticleButtonsPanel, Panel): bl_label = "Physics" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -641,7 +642,7 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, bpy.types.Panel): sub.prop(key, "system", text="System") -class PARTICLE_PT_boidbrain(ParticleButtonsPanel, bpy.types.Panel): +class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel): bl_label = "Boid Brain" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -742,7 +743,7 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel, bpy.types.Panel): row.prop(rule, "flee_distance") -class PARTICLE_PT_render(ParticleButtonsPanel, bpy.types.Panel): +class PARTICLE_PT_render(ParticleButtonsPanel, Panel): bl_label = "Render" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -927,7 +928,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, bpy.types.Panel): row.prop(part, "size_random", slider=True) -class PARTICLE_PT_draw(ParticleButtonsPanel, bpy.types.Panel): +class PARTICLE_PT_draw(ParticleButtonsPanel, Panel): bl_label = "Display" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -989,7 +990,7 @@ class PARTICLE_PT_draw(ParticleButtonsPanel, bpy.types.Panel): col.prop(part, "draw_step") -class PARTICLE_PT_children(ParticleButtonsPanel, bpy.types.Panel): +class PARTICLE_PT_children(ParticleButtonsPanel, Panel): bl_label = "Children" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -1089,7 +1090,7 @@ class PARTICLE_PT_children(ParticleButtonsPanel, bpy.types.Panel): sub.prop(part, "kink_shape", slider=True) -class PARTICLE_PT_field_weights(ParticleButtonsPanel, bpy.types.Panel): +class PARTICLE_PT_field_weights(ParticleButtonsPanel, Panel): bl_label = "Field Weights" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -1110,7 +1111,7 @@ class PARTICLE_PT_field_weights(ParticleButtonsPanel, bpy.types.Panel): row.prop(part, "effect_hair", slider=True) -class PARTICLE_PT_force_fields(ParticleButtonsPanel, bpy.types.Panel): +class PARTICLE_PT_force_fields(ParticleButtonsPanel, Panel): bl_label = "Force Field Settings" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -1144,7 +1145,7 @@ class PARTICLE_PT_force_fields(ParticleButtonsPanel, bpy.types.Panel): basic_force_field_falloff_ui(self, context, part.force_field_2) -class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, bpy.types.Panel): +class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel): bl_label = "Vertexgroups" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -1215,7 +1216,7 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, bpy.types.Panel): # row.prop(psys, "invert_vertex_group_field", text="") -class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel, bpy.types.Panel): +class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER'} _context_path = "particle_system.settings" _property_type = bpy.types.ParticleSettings diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py index bce6ab993a7..d5427d8bae8 100644 --- a/release/scripts/startup/bl_ui/properties_physics_cloth.py +++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Menu, Panel from bl_ui.properties_physics_common import ( @@ -30,14 +31,14 @@ def cloth_panel_enabled(md): return md.point_cache.is_baked is False -class CLOTH_MT_presets(bpy.types.Menu): +class CLOTH_MT_presets(Menu): ''' Creates the menu items by scanning scripts/templates ''' bl_label = "Cloth Presets" preset_subdir = "cloth" preset_operator = "script.execute_preset" - draw = bpy.types.Menu.draw_preset + draw = Menu.draw_preset class PhysicButtonsPanel(): @@ -52,7 +53,7 @@ class PhysicButtonsPanel(): return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.cloth) -class PHYSICS_PT_cloth(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel): bl_label = "Cloth" def draw(self, context): @@ -117,7 +118,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, bpy.types.Panel): col.prop_search(cloth, "rest_shape_key", key, "key_blocks", text="") -class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel): bl_label = "Cloth Cache" bl_options = {'DEFAULT_CLOSED'} @@ -130,7 +131,7 @@ class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, bpy.types.Panel): point_cache_ui(self, context, md.point_cache, cloth_panel_enabled(md), 'CLOTH') -class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel): bl_label = "Cloth Collision" bl_options = {'DEFAULT_CLOSED'} @@ -171,7 +172,7 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, bpy.types.Panel): layout.prop(cloth, "group") -class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel): bl_label = "Cloth Stiffness Scaling" bl_options = {'DEFAULT_CLOSED'} @@ -207,7 +208,7 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, bpy.types.Panel): col.prop(cloth, "bending_stiffness_max", text="Max") -class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, Panel): bl_label = "Cloth Field Weights" bl_options = {'DEFAULT_CLOSED'} diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py index f7cf8da1840..204e25d9f01 100644 --- a/release/scripts/startup/bl_ui/properties_physics_common.py +++ b/release/scripts/startup/bl_ui/properties_physics_common.py @@ -19,6 +19,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel class PhysicButtonsPanel(): @@ -44,7 +45,7 @@ def physics_add(self, layout, md, name, type, typeicon, toggles): sub.operator("object.modifier_add", text=name, icon=typeicon).type = type -class PHYSICS_PT_add(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_add(PhysicButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} diff --git a/release/scripts/startup/bl_ui/properties_physics_field.py b/release/scripts/startup/bl_ui/properties_physics_field.py index 9f96f0a5b9f..e1dc4d04378 100644 --- a/release/scripts/startup/bl_ui/properties_physics_field.py +++ b/release/scripts/startup/bl_ui/properties_physics_field.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel from bl_ui.properties_physics_common import ( @@ -37,7 +38,7 @@ class PhysicButtonsPanel(): return (context.object) and (not rd.use_game_engine) -class PHYSICS_PT_field(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_field(PhysicButtonsPanel, Panel): bl_label = "Force Fields" @classmethod @@ -164,7 +165,7 @@ class PHYSICS_PT_field(PhysicButtonsPanel, bpy.types.Panel): sub.prop(field, "radial_max", text="Distance") -class PHYSICS_PT_collision(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_collision(PhysicButtonsPanel, Panel): bl_label = "Collision" #bl_options = {'DEFAULT_CLOSED'} diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py index c7e3a9e7220..46893af3582 100644 --- a/release/scripts/startup/bl_ui/properties_physics_fluid.py +++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel class PhysicButtonsPanel(): @@ -32,7 +33,7 @@ class PhysicButtonsPanel(): return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.fluid) -class PHYSICS_PT_fluid(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel): bl_label = "Fluid" def draw(self, context): @@ -186,7 +187,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel, bpy.types.Panel): sub.prop(fluid, "velocity_radius", text="Radius") -class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, Panel): bl_label = "Domain World" bl_options = {'DEFAULT_CLOSED'} @@ -236,7 +237,7 @@ class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, bpy.types.Panel): col.prop(fluid, "compressibility", slider=True) -class PHYSICS_PT_domain_boundary(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_domain_boundary(PhysicButtonsPanel, Panel): bl_label = "Domain Boundary" bl_options = {'DEFAULT_CLOSED'} @@ -265,7 +266,7 @@ class PHYSICS_PT_domain_boundary(PhysicButtonsPanel, bpy.types.Panel): col.prop(fluid, "surface_subdivisions", text="Subdivisions") -class PHYSICS_PT_domain_particles(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_domain_particles(PhysicButtonsPanel, Panel): bl_label = "Domain Particles" bl_options = {'DEFAULT_CLOSED'} diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py index 61d8d2e3825..771a778380d 100644 --- a/release/scripts/startup/bl_ui/properties_physics_smoke.py +++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel from bl_ui.properties_physics_common import ( @@ -38,7 +39,7 @@ class PhysicButtonsPanel(): return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.smoke) -class PHYSICS_PT_smoke(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel): bl_label = "Smoke" def draw(self, context): @@ -103,7 +104,7 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel, bpy.types.Panel): sub.prop(flow, "temperature") -class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, Panel): bl_label = "Smoke Groups" bl_options = {'DEFAULT_CLOSED'} @@ -131,7 +132,7 @@ class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, bpy.types.Panel): col.prop(group, "collision_group", text="") -class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, Panel): bl_label = "Smoke High Resolution" bl_options = {'DEFAULT_CLOSED'} @@ -168,7 +169,7 @@ class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, bpy.types.Panel): layout.prop(md, "show_high_resolution") -class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, Panel): bl_label = "Smoke Cache" bl_options = {'DEFAULT_CLOSED'} @@ -189,7 +190,7 @@ class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, bpy.types.Panel): point_cache_ui(self, context, cache, (cache.is_baked is False), 'SMOKE') -class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, Panel): bl_label = "Smoke Field Weights" bl_options = {'DEFAULT_CLOSED'} diff --git a/release/scripts/startup/bl_ui/properties_physics_softbody.py b/release/scripts/startup/bl_ui/properties_physics_softbody.py index 61115a0590e..0b55ccf9516 100644 --- a/release/scripts/startup/bl_ui/properties_physics_softbody.py +++ b/release/scripts/startup/bl_ui/properties_physics_softbody.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel from bl_ui.properties_physics_common import ( @@ -44,7 +45,7 @@ class PhysicButtonsPanel(): return (ob and (ob.type == 'MESH' or ob.type == 'LATTICE'or ob.type == 'CURVE')) and (not rd.use_game_engine) and (context.soft_body) -class PHYSICS_PT_softbody(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel): bl_label = "Soft Body" def draw(self, context): @@ -71,7 +72,7 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel, bpy.types.Panel): col.prop(softbody, "speed") -class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, Panel): bl_label = "Soft Body Cache" bl_options = {'DEFAULT_CLOSED'} @@ -84,7 +85,7 @@ class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, bpy.types.Panel): point_cache_ui(self, context, md.point_cache, softbody_panel_enabled(md), 'SOFTBODY') -class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, Panel): bl_label = "Soft Body Goal" bl_options = {'DEFAULT_CLOSED'} @@ -127,7 +128,7 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, bpy.types.Panel): layout.prop_search(softbody, "vertex_group_goal", ob, "vertex_groups", text="Vertex Group") -class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, Panel): bl_label = "Soft Body Edges" bl_options = {'DEFAULT_CLOSED'} @@ -180,7 +181,7 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, bpy.types.Panel): col.prop(softbody, "use_face_collision", text="Face") -class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, Panel): bl_label = "Soft Body Self Collision" bl_options = {'DEFAULT_CLOSED'} @@ -212,7 +213,7 @@ class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, bpy.types.Panel): col.prop(softbody, "ball_damp", text="Dampening") -class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, Panel): bl_label = "Soft Body Solver" bl_options = {'DEFAULT_CLOSED'} @@ -248,7 +249,7 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, bpy.types.Panel): layout.prop(softbody, "use_estimate_matrix") -class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel, bpy.types.Panel): +class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel, Panel): bl_label = "Soft Body Field Weights" bl_options = {'DEFAULT_CLOSED'} diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 6d36db29a6c..fb14372ebea 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -18,27 +18,28 @@ # <pep8 compliant> import bpy +from bpy.types import Menu, Panel -class RENDER_MT_presets(bpy.types.Menu): +class RENDER_MT_presets(Menu): bl_label = "Render Presets" preset_subdir = "render" preset_operator = "script.execute_preset" - draw = bpy.types.Menu.draw_preset + draw = Menu.draw_preset -class RENDER_MT_ffmpeg_presets(bpy.types.Menu): +class RENDER_MT_ffmpeg_presets(Menu): bl_label = "FFMPEG Presets" preset_subdir = "ffmpeg" preset_operator = "script.python_file_run" - draw = bpy.types.Menu.draw_preset + draw = Menu.draw_preset -class RENDER_MT_framerate_presets(bpy.types.Menu): +class RENDER_MT_framerate_presets(Menu): bl_label = "Frame Rate Presets" preset_subdir = "framerate" preset_operator = "script.execute_preset" - draw = bpy.types.Menu.draw_preset + draw = Menu.draw_preset class RenderButtonsPanel(): @@ -53,7 +54,7 @@ class RenderButtonsPanel(): return (context.scene and rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES) -class RENDER_PT_render(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_render(RenderButtonsPanel, Panel): bl_label = "Render" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -69,7 +70,7 @@ class RENDER_PT_render(RenderButtonsPanel, bpy.types.Panel): layout.prop(rd, "display_mode", text="Display") -class RENDER_PT_layers(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_layers(RenderButtonsPanel, Panel): bl_label = "Layers" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -173,7 +174,7 @@ class RENDER_PT_layers(RenderButtonsPanel, bpy.types.Panel): row.prop(rl, "exclude_refraction", text="") -class RENDER_PT_dimensions(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_dimensions(RenderButtonsPanel, Panel): bl_label = "Dimensions" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -240,7 +241,7 @@ class RENDER_PT_dimensions(RenderButtonsPanel, bpy.types.Panel): subrow.prop(rd, "frame_map_new", text="New") -class RENDER_PT_antialiasing(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_antialiasing(RenderButtonsPanel, Panel): bl_label = "Anti-Aliasing" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -268,7 +269,7 @@ class RENDER_PT_antialiasing(RenderButtonsPanel, bpy.types.Panel): col.prop(rd, "filter_size", text="Size") -class RENDER_PT_motion_blur(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_motion_blur(RenderButtonsPanel, Panel): bl_label = "Sampled Motion Blur" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -294,7 +295,7 @@ class RENDER_PT_motion_blur(RenderButtonsPanel, bpy.types.Panel): row.prop(rd, "motion_blur_shutter") -class RENDER_PT_shading(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_shading(RenderButtonsPanel, Panel): bl_label = "Shading" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -318,7 +319,7 @@ class RENDER_PT_shading(RenderButtonsPanel, bpy.types.Panel): col.prop(rd, "alpha_mode", text="Alpha") -class RENDER_PT_performance(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_performance(RenderButtonsPanel, Panel): bl_label = "Performance" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -361,7 +362,7 @@ class RENDER_PT_performance(RenderButtonsPanel, bpy.types.Panel): sub.prop(rd, "use_local_coords", text="Local Coordinates") -class RENDER_PT_post_processing(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_post_processing(RenderButtonsPanel, Panel): bl_label = "Post Processing" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -398,7 +399,7 @@ class RENDER_PT_post_processing(RenderButtonsPanel, bpy.types.Panel): sub.prop(rd, "edge_color", text="") -class RENDER_PT_stamp(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_stamp(RenderButtonsPanel, Panel): bl_label = "Stamp" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -443,7 +444,7 @@ class RENDER_PT_stamp(RenderButtonsPanel, bpy.types.Panel): sub.prop(rd, "stamp_note_text", text="") -class RENDER_PT_output(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_output(RenderButtonsPanel, Panel): bl_label = "Output" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -543,7 +544,7 @@ class RENDER_PT_output(RenderButtonsPanel, bpy.types.Panel): col.prop(rd, "quicktime_audio_resampling_hq") -class RENDER_PT_encoding(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_encoding(RenderButtonsPanel, Panel): bl_label = "Encoding" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -600,7 +601,7 @@ class RENDER_PT_encoding(RenderButtonsPanel, bpy.types.Panel): split.prop(rd, "ffmpeg_audio_volume", slider=True) -class RENDER_PT_bake(RenderButtonsPanel, bpy.types.Panel): +class RENDER_PT_bake(RenderButtonsPanel, Panel): bl_label = "Bake" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index 7725f661693..6e96e1228e7 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Operator, Panel from rna_prop_ui import PropertyPanel @@ -31,7 +32,7 @@ class SceneButtonsPanel(): return context.scene -class SCENE_PT_scene(SceneButtonsPanel, bpy.types.Panel): +class SCENE_PT_scene(SceneButtonsPanel, Panel): bl_label = "Scene" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -43,7 +44,7 @@ class SCENE_PT_scene(SceneButtonsPanel, bpy.types.Panel): layout.prop(scene, "background_set", text="Background") -class SCENE_PT_unit(SceneButtonsPanel, bpy.types.Panel): +class SCENE_PT_unit(SceneButtonsPanel, Panel): bl_label = "Units" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -61,7 +62,7 @@ class SCENE_PT_unit(SceneButtonsPanel, bpy.types.Panel): row.prop(unit, "use_separate") -class SCENE_PT_keying_sets(SceneButtonsPanel, bpy.types.Panel): +class SCENE_PT_keying_sets(SceneButtonsPanel, Panel): bl_label = "Keying Sets" def draw(self, context): @@ -94,7 +95,7 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, bpy.types.Panel): col.prop(ks, "bl_options") -class SCENE_PT_keying_set_paths(SceneButtonsPanel, bpy.types.Panel): +class SCENE_PT_keying_set_paths(SceneButtonsPanel, Panel): bl_label = "Active Keying Set" @classmethod @@ -144,7 +145,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel, bpy.types.Panel): col.prop(ksp, "bl_options") -class SCENE_PT_physics(SceneButtonsPanel, bpy.types.Panel): +class SCENE_PT_physics(SceneButtonsPanel, Panel): bl_label = "Gravity" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -161,7 +162,7 @@ class SCENE_PT_physics(SceneButtonsPanel, bpy.types.Panel): layout.prop(scene, "gravity", text="") -class SCENE_PT_simplify(SceneButtonsPanel, bpy.types.Panel): +class SCENE_PT_simplify(SceneButtonsPanel, Panel): bl_label = "Simplify" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -190,7 +191,7 @@ class SCENE_PT_simplify(SceneButtonsPanel, bpy.types.Panel): col.prop(rd, "simplify_ao_sss", text="AO and SSS") -class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, bpy.types.Panel): +class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "scene" _property_type = bpy.types.Scene @@ -198,7 +199,7 @@ class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, bpy.types.Panel): # XXX, move operator to op/ dir -class ANIM_OT_keying_set_export(bpy.types.Operator): +class ANIM_OT_keying_set_export(Operator): "Export Keying Set to a python script." bl_idname = "anim.keying_set_export" bl_label = "Export Keying Set..." diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index 7ca8818cbd2..ead65b92c3f 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -18,10 +18,11 @@ # <pep8 compliant> import bpy +from bpy.types import Menu, Panel from rna_prop_ui import PropertyPanel -class TEXTURE_MT_specials(bpy.types.Menu): +class TEXTURE_MT_specials(Menu): bl_label = "Texture Specials" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -32,7 +33,7 @@ class TEXTURE_MT_specials(bpy.types.Menu): layout.operator("texture.slot_paste", icon='PASTEDOWN') -class TEXTURE_MT_envmap_specials(bpy.types.Menu): +class TEXTURE_MT_envmap_specials(Menu): bl_label = "Environment Map Specials" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -80,7 +81,7 @@ class TextureButtonsPanel(): return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.scene.render.engine in cls.COMPAT_ENGINES) -class TEXTURE_PT_context_texture(TextureButtonsPanel, bpy.types.Panel): +class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -150,7 +151,7 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, bpy.types.Panel): split.prop(tex, "type", text="") -class TEXTURE_PT_preview(TextureButtonsPanel, bpy.types.Panel): +class TEXTURE_PT_preview(TextureButtonsPanel, Panel): bl_label = "Preview" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -167,7 +168,7 @@ class TEXTURE_PT_preview(TextureButtonsPanel, bpy.types.Panel): layout.template_preview(tex, slot=slot) -class TEXTURE_PT_colors(TextureButtonsPanel, bpy.types.Panel): +class TEXTURE_PT_colors(TextureButtonsPanel, Panel): bl_label = "Colors" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -223,7 +224,7 @@ class TextureTypePanel(TextureButtonsPanel): return tex and ((tex.type == cls.tex_type and not tex.use_nodes) and (engine in cls.COMPAT_ENGINES)) -class TEXTURE_PT_clouds(TextureTypePanel, bpy.types.Panel): +class TEXTURE_PT_clouds(TextureTypePanel, Panel): bl_label = "Clouds" tex_type = 'CLOUDS' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -247,7 +248,7 @@ class TEXTURE_PT_clouds(TextureTypePanel, bpy.types.Panel): split.prop(tex, "nabla", text="Nabla") -class TEXTURE_PT_wood(TextureTypePanel, bpy.types.Panel): +class TEXTURE_PT_wood(TextureTypePanel, Panel): bl_label = "Wood" tex_type = 'WOOD' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -276,7 +277,7 @@ class TEXTURE_PT_wood(TextureTypePanel, bpy.types.Panel): split.prop(tex, "nabla") -class TEXTURE_PT_marble(TextureTypePanel, bpy.types.Panel): +class TEXTURE_PT_marble(TextureTypePanel, Panel): bl_label = "Marble" tex_type = 'MARBLE' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -303,7 +304,7 @@ class TEXTURE_PT_marble(TextureTypePanel, bpy.types.Panel): col.prop(tex, "nabla") -class TEXTURE_PT_magic(TextureTypePanel, bpy.types.Panel): +class TEXTURE_PT_magic(TextureTypePanel, Panel): bl_label = "Magic" tex_type = 'MAGIC' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -318,7 +319,7 @@ class TEXTURE_PT_magic(TextureTypePanel, bpy.types.Panel): row.prop(tex, "turbulence") -class TEXTURE_PT_blend(TextureTypePanel, bpy.types.Panel): +class TEXTURE_PT_blend(TextureTypePanel, Panel): bl_label = "Blend" tex_type = 'BLEND' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -336,7 +337,7 @@ class TEXTURE_PT_blend(TextureTypePanel, bpy.types.Panel): sub.prop(tex, "use_flip_axis", expand=True) -class TEXTURE_PT_stucci(TextureTypePanel, bpy.types.Panel): +class TEXTURE_PT_stucci(TextureTypePanel, Panel): bl_label = "Stucci" tex_type = 'STUCCI' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -356,7 +357,7 @@ class TEXTURE_PT_stucci(TextureTypePanel, bpy.types.Panel): row.prop(tex, "turbulence") -class TEXTURE_PT_image(TextureTypePanel, bpy.types.Panel): +class TEXTURE_PT_image(TextureTypePanel, Panel): bl_label = "Image" tex_type = 'IMAGE' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -382,7 +383,7 @@ def texture_filter_common(tex, layout): layout.prop(tex, "use_filter_size_min") -class TEXTURE_PT_image_sampling(TextureTypePanel, bpy.types.Panel): +class TEXTURE_PT_image_sampling(TextureTypePanel, Panel): bl_label = "Image Sampling" bl_options = {'DEFAULT_CLOSED'} tex_type = 'IMAGE' @@ -423,7 +424,7 @@ class TEXTURE_PT_image_sampling(TextureTypePanel, bpy.types.Panel): texture_filter_common(tex, col) -class TEXTURE_PT_image_mapping(TextureTypePanel, bpy.types.Panel): +class TEXTURE_PT_image_mapping(TextureTypePanel, Panel): bl_label = "Image Mapping" bl_options = {'DEFAULT_CLOSED'} tex_type = 'IMAGE' @@ -479,7 +480,7 @@ class TEXTURE_PT_image_mapping(TextureTypePanel, bpy.types.Panel): col.prop(tex, "crop_max_y", text="Y") -class TEXTURE_PT_envmap(TextureTypePanel, bpy.types.Panel): +class TEXTURE_PT_envmap(TextureTypePanel, Panel): bl_label = "Environment Map" tex_type = 'ENVIRONMENT_MAP' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -517,7 +518,7 @@ class TEXTURE_PT_envmap(TextureTypePanel, bpy.types.Panel): col.prop(env, "clip_end", text="End") -class TEXTURE_PT_envmap_sampling(TextureTypePanel, bpy.types.Panel): +class TEXTURE_PT_envmap_sampling(TextureTypePanel, Panel): bl_label = "Environment Map Sampling" bl_options = {'DEFAULT_CLOSED'} tex_type = 'ENVIRONMENT_MAP' @@ -531,7 +532,7 @@ class TEXTURE_PT_envmap_sampling(TextureTypePanel, bpy.types.Panel): texture_filter_common(tex, layout) -class TEXTURE_PT_musgrave(TextureTypePanel, bpy.types.Panel): +class TEXTURE_PT_musgrave(TextureTypePanel, Panel): bl_label = "Musgrave" tex_type = 'MUSGRAVE' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -568,7 +569,7 @@ class TEXTURE_PT_musgrave(TextureTypePanel, bpy.types.Panel): row.prop(tex, "nabla") -class TEXTURE_PT_voronoi(TextureTypePanel, bpy.types.Panel): +class TEXTURE_PT_voronoi(TextureTypePanel, Panel): bl_label = "Voronoi" tex_type = 'VORONOI' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -604,7 +605,7 @@ class TEXTURE_PT_voronoi(TextureTypePanel, bpy.types.Panel): row.prop(tex, "nabla") -class TEXTURE_PT_distortednoise(TextureTypePanel, bpy.types.Panel): +class TEXTURE_PT_distortednoise(TextureTypePanel, Panel): bl_label = "Distorted Noise" tex_type = 'DISTORTED_NOISE' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -626,7 +627,7 @@ class TEXTURE_PT_distortednoise(TextureTypePanel, bpy.types.Panel): split.prop(tex, "nabla") -class TEXTURE_PT_voxeldata(TextureButtonsPanel, bpy.types.Panel): +class TEXTURE_PT_voxeldata(TextureButtonsPanel, Panel): bl_label = "Voxel Data" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -666,7 +667,7 @@ class TEXTURE_PT_voxeldata(TextureButtonsPanel, bpy.types.Panel): layout.prop(vd, "intensity") -class TEXTURE_PT_pointdensity(TextureButtonsPanel, bpy.types.Panel): +class TEXTURE_PT_pointdensity(TextureButtonsPanel, Panel): bl_label = "Point Density" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -732,7 +733,7 @@ class TEXTURE_PT_pointdensity(TextureButtonsPanel, bpy.types.Panel): col.template_curve_mapping(pd, "falloff_curve", brush=False) -class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel, bpy.types.Panel): +class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel, Panel): bl_label = "Turbulence" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -769,7 +770,7 @@ class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel, bpy.types.Panel): col.prop(pd, "turbulence_strength") -class TEXTURE_PT_mapping(TextureSlotPanel, bpy.types.Panel): +class TEXTURE_PT_mapping(TextureSlotPanel, Panel): bl_label = "Mapping" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -857,7 +858,7 @@ class TEXTURE_PT_mapping(TextureSlotPanel, bpy.types.Panel): row.column().prop(tex, "scale") -class TEXTURE_PT_influence(TextureSlotPanel, bpy.types.Panel): +class TEXTURE_PT_influence(TextureSlotPanel, Panel): bl_label = "Influence" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -1033,7 +1034,7 @@ class TEXTURE_PT_influence(TextureSlotPanel, bpy.types.Panel): sub.prop(tex, "bump_objectspace", text="Space") -class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, bpy.types.Panel): +class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "texture" _property_type = bpy.types.Texture diff --git a/release/scripts/startup/bl_ui/properties_world.py b/release/scripts/startup/bl_ui/properties_world.py index c577af01374..71ee03296a0 100644 --- a/release/scripts/startup/bl_ui/properties_world.py +++ b/release/scripts/startup/bl_ui/properties_world.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Panel from rna_prop_ui import PropertyPanel @@ -32,7 +33,7 @@ class WorldButtonsPanel(): return (context.world and context.scene.render.engine in cls.COMPAT_ENGINES) -class WORLD_PT_context_world(WorldButtonsPanel, bpy.types.Panel): +class WORLD_PT_context_world(WorldButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -61,7 +62,7 @@ class WORLD_PT_context_world(WorldButtonsPanel, bpy.types.Panel): split.label(text=str(texture_count), icon='TEXTURE') -class WORLD_PT_preview(WorldButtonsPanel, bpy.types.Panel): +class WORLD_PT_preview(WorldButtonsPanel, Panel): bl_label = "Preview" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -74,7 +75,7 @@ class WORLD_PT_preview(WorldButtonsPanel, bpy.types.Panel): self.layout.template_preview(context.world) -class WORLD_PT_world(WorldButtonsPanel, bpy.types.Panel): +class WORLD_PT_world(WorldButtonsPanel, Panel): bl_label = "World" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -99,7 +100,7 @@ class WORLD_PT_world(WorldButtonsPanel, bpy.types.Panel): row.prop(world, "color_range") -class WORLD_PT_ambient_occlusion(WorldButtonsPanel, bpy.types.Panel): +class WORLD_PT_ambient_occlusion(WorldButtonsPanel, Panel): bl_label = "Ambient Occlusion" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -118,7 +119,7 @@ class WORLD_PT_ambient_occlusion(WorldButtonsPanel, bpy.types.Panel): split.prop(light, "ao_blend_type", text="") -class WORLD_PT_environment_lighting(WorldButtonsPanel, bpy.types.Panel): +class WORLD_PT_environment_lighting(WorldButtonsPanel, Panel): bl_label = "Environment Lighting" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -137,7 +138,7 @@ class WORLD_PT_environment_lighting(WorldButtonsPanel, bpy.types.Panel): split.prop(light, "environment_color", text="") -class WORLD_PT_indirect_lighting(WorldButtonsPanel, bpy.types.Panel): +class WORLD_PT_indirect_lighting(WorldButtonsPanel, Panel): bl_label = "Indirect Lighting" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -159,7 +160,7 @@ class WORLD_PT_indirect_lighting(WorldButtonsPanel, bpy.types.Panel): layout.label(text="Only works with Approximate gather method") -class WORLD_PT_gather(WorldButtonsPanel, bpy.types.Panel): +class WORLD_PT_gather(WorldButtonsPanel, Panel): bl_label = "Gather" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -207,7 +208,7 @@ class WORLD_PT_gather(WorldButtonsPanel, bpy.types.Panel): col.prop(light, "correction") -class WORLD_PT_mist(WorldButtonsPanel, bpy.types.Panel): +class WORLD_PT_mist(WorldButtonsPanel, Panel): bl_label = "Mist" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -236,7 +237,7 @@ class WORLD_PT_mist(WorldButtonsPanel, bpy.types.Panel): layout.prop(world.mist_settings, "falloff") -class WORLD_PT_stars(WorldButtonsPanel, bpy.types.Panel): +class WORLD_PT_stars(WorldButtonsPanel, Panel): bl_label = "Stars" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -263,7 +264,7 @@ class WORLD_PT_stars(WorldButtonsPanel, bpy.types.Panel): col.prop(world.star_settings, "average_separation", text="Separation") -class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel, bpy.types.Panel): +class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "world" _property_type = bpy.types.World diff --git a/release/scripts/startup/bl_ui/space_console.py b/release/scripts/startup/bl_ui/space_console.py index da6c102100b..d457a66def8 100644 --- a/release/scripts/startup/bl_ui/space_console.py +++ b/release/scripts/startup/bl_ui/space_console.py @@ -18,32 +18,30 @@ # <pep8 compliant> import bpy +from bpy.types import Header, Menu, Operator from bpy.props import StringProperty -class CONSOLE_HT_header(bpy.types.Header): +class CONSOLE_HT_header(Header): bl_space_type = 'CONSOLE' def draw(self, context): - layout = self.layout + layout = self.layout.row(align=True) - row = layout.row(align=True) - row.template_header() + layout.template_header() if context.area.show_menus: - sub = row.row(align=True) - sub.menu("CONSOLE_MT_console") + layout.menu("CONSOLE_MT_console") - row = layout.row(align=True) - row.operator("console.autocomplete", text="Autocomplete") + layout.operator("console.autocomplete", text="Autocomplete") -class CONSOLE_MT_console(bpy.types.Menu): +class CONSOLE_MT_console(Menu): bl_label = "Console" def draw(self, context): layout = self.layout - layout.column() + layout.operator("console.clear") layout.operator("console.copy") layout.operator("console.paste") @@ -55,7 +53,7 @@ class CONSOLE_MT_console(bpy.types.Menu): layout.operator("screen.screen_full_area") -class CONSOLE_MT_language(bpy.types.Menu): +class CONSOLE_MT_language(Menu): bl_label = "Languages..." def draw(self, context): @@ -82,7 +80,7 @@ def add_scrollback(text, text_type): type=text_type) -class ConsoleExec(bpy.types.Operator): +class ConsoleExec(Operator): '''Execute the current console line as a python expression''' bl_idname = "console.execute" bl_label = "Console Execute" @@ -100,7 +98,7 @@ class ConsoleExec(bpy.types.Operator): return {'FINISHED'} -class ConsoleAutocomplete(bpy.types.Operator): +class ConsoleAutocomplete(Operator): '''Evaluate the namespace up until the cursor and give a list of options or complete the name if there is only one''' bl_idname = "console.autocomplete" bl_label = "Console Autocomplete" @@ -117,7 +115,7 @@ class ConsoleAutocomplete(bpy.types.Operator): return {'FINISHED'} -class ConsoleBanner(bpy.types.Operator): +class ConsoleBanner(Operator): '''Print a message whem the terminal initializes''' bl_idname = "console.banner" bl_label = "Console Banner" @@ -139,7 +137,7 @@ class ConsoleBanner(bpy.types.Operator): return {'FINISHED'} -class ConsoleLanguage(bpy.types.Operator): +class ConsoleLanguage(Operator): '''Set the current language for this console''' bl_idname = "console.language" bl_label = "Console Language" diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index 930a2029d32..dfbd7b3ae14 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -19,6 +19,7 @@ # <pep8 compliant> import bpy +from bpy.types import Header, Menu ####################################### @@ -84,7 +85,7 @@ def dopesheet_filter(layout, context, genericFiltersOnly=False): ####################################### # DopeSheet Editor - General/Standard UI -class DOPESHEET_HT_header(bpy.types.Header): +class DOPESHEET_HT_header(Header): bl_space_type = 'DOPESHEET_EDITOR' def draw(self, context): @@ -96,21 +97,19 @@ class DOPESHEET_HT_header(bpy.types.Header): row.template_header() if context.area.show_menus: - sub = row.row(align=True) - - sub.menu("DOPESHEET_MT_view") - sub.menu("DOPESHEET_MT_select") - sub.menu("DOPESHEET_MT_marker") + row.menu("DOPESHEET_MT_view") + row.menu("DOPESHEET_MT_select") + row.menu("DOPESHEET_MT_marker") if st.mode == 'DOPESHEET' or (st.mode == 'ACTION' and st.action != None): - sub.menu("DOPESHEET_MT_channel") + row.menu("DOPESHEET_MT_channel") elif st.mode == 'GPENCIL': - sub.menu("DOPESHEET_MT_gpencil_channel") + row.menu("DOPESHEET_MT_gpencil_channel") if st.mode != 'GPENCIL': - sub.menu("DOPESHEET_MT_key") + row.menu("DOPESHEET_MT_key") else: - sub.menu("DOPESHEET_MT_gpencil_frame") + row.menu("DOPESHEET_MT_gpencil_frame") layout.prop(st, "mode", text="") layout.prop(st.dopesheet, "show_summary", text="Summary") @@ -134,7 +133,7 @@ class DOPESHEET_HT_header(bpy.types.Header): row.operator("action.paste", text="", icon='PASTEDOWN') -class DOPESHEET_MT_view(bpy.types.Menu): +class DOPESHEET_MT_view(Menu): bl_label = "View" def draw(self, context): @@ -142,8 +141,6 @@ class DOPESHEET_MT_view(bpy.types.Menu): st = context.space_data - layout.column() - layout.prop(st, "use_realtime_update") layout.prop(st, "show_frame_indicator") layout.prop(st, "show_sliders") @@ -170,13 +167,12 @@ class DOPESHEET_MT_view(bpy.types.Menu): layout.operator("screen.screen_full_area") -class DOPESHEET_MT_select(bpy.types.Menu): +class DOPESHEET_MT_select(Menu): bl_label = "Select" def draw(self, context): layout = self.layout - layout.column() # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None layout.operator("action.select_all_toggle") layout.operator("action.select_all_toggle", text="Invert Selection").invert = True @@ -206,7 +202,7 @@ class DOPESHEET_MT_select(bpy.types.Menu): layout.operator("action.select_linked") -class DOPESHEET_MT_marker(bpy.types.Menu): +class DOPESHEET_MT_marker(Menu): bl_label = "Marker" def draw(self, context): @@ -216,7 +212,6 @@ class DOPESHEET_MT_marker(bpy.types.Menu): #layout.operator_context = 'EXEC_REGION_WIN' - layout.column() layout.operator("marker.add", "Add Marker") layout.operator("marker.duplicate", text="Duplicate Marker") layout.operator("marker.delete", text="Delete Marker") @@ -237,7 +232,7 @@ class DOPESHEET_MT_marker(bpy.types.Menu): ####################################### # Keyframe Editing -class DOPESHEET_MT_channel(bpy.types.Menu): +class DOPESHEET_MT_channel(Menu): bl_label = "Channel" def draw(self, context): @@ -245,7 +240,6 @@ class DOPESHEET_MT_channel(bpy.types.Menu): layout.operator_context = 'INVOKE_REGION_CHANNELS' - layout.column() layout.operator("anim.channels_delete") layout.separator() @@ -268,13 +262,12 @@ class DOPESHEET_MT_channel(bpy.types.Menu): layout.operator("anim.channels_fcurves_enable") -class DOPESHEET_MT_key(bpy.types.Menu): +class DOPESHEET_MT_key(Menu): bl_label = "Key" def draw(self, context): layout = self.layout - layout.column() layout.menu("DOPESHEET_MT_key_transform", text="Transform") layout.operator_menu_enum("action.snap", "type", text="Snap") @@ -301,13 +294,12 @@ class DOPESHEET_MT_key(bpy.types.Menu): layout.operator("action.paste") -class DOPESHEET_MT_key_transform(bpy.types.Menu): +class DOPESHEET_MT_key_transform(Menu): bl_label = "Transform" def draw(self, context): layout = self.layout - layout.column() layout.operator("transform.transform", text="Grab/Move").mode = 'TIME_TRANSLATE' layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND' layout.operator("transform.transform", text="Slide").mode = 'TIME_SLIDE' @@ -317,7 +309,7 @@ class DOPESHEET_MT_key_transform(bpy.types.Menu): ####################################### # Grease Pencil Editing -class DOPESHEET_MT_gpencil_channel(bpy.types.Menu): +class DOPESHEET_MT_gpencil_channel(Menu): bl_label = "Channel" def draw(self, context): @@ -325,7 +317,6 @@ class DOPESHEET_MT_gpencil_channel(bpy.types.Menu): layout.operator_context = 'INVOKE_REGION_CHANNELS' - layout.column() layout.operator("anim.channels_delete") layout.separator() @@ -345,13 +336,12 @@ class DOPESHEET_MT_gpencil_channel(bpy.types.Menu): #layout.operator_menu_enum("anim.channels_move", "direction", text="Move...") -class DOPESHEET_MT_gpencil_frame(bpy.types.Menu): +class DOPESHEET_MT_gpencil_frame(Menu): bl_label = "Frame" def draw(self, context): layout = self.layout - layout.column() layout.menu("DOPESHEET_MT_key_transform", text="Transform") #layout.operator_menu_enum("action.snap", "type", text="Snap") diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py index 73fe1a97252..cf0d10c5844 100644 --- a/release/scripts/startup/bl_ui/space_filebrowser.py +++ b/release/scripts/startup/bl_ui/space_filebrowser.py @@ -18,9 +18,10 @@ # <pep8 compliant> import bpy +from bpy.types import Header -class FILEBROWSER_HT_header(bpy.types.Header): +class FILEBROWSER_HT_header(Header): bl_space_type = 'FILE_BROWSER' def draw(self, context): diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py index bfc1a0e3a23..c379ea95ea2 100644 --- a/release/scripts/startup/bl_ui/space_graph.py +++ b/release/scripts/startup/bl_ui/space_graph.py @@ -19,9 +19,10 @@ # <pep8 compliant> import bpy +from bpy.types import Header, Menu -class GRAPH_HT_header(bpy.types.Header): +class GRAPH_HT_header(Header): bl_space_type = 'GRAPH_EDITOR' def draw(self, context): @@ -35,13 +36,11 @@ class GRAPH_HT_header(bpy.types.Header): row.template_header() if context.area.show_menus: - sub = row.row(align=True) - - sub.menu("GRAPH_MT_view") - sub.menu("GRAPH_MT_select") - sub.menu("GRAPH_MT_marker") - sub.menu("GRAPH_MT_channel") - sub.menu("GRAPH_MT_key") + row.menu("GRAPH_MT_view") + row.menu("GRAPH_MT_select") + row.menu("GRAPH_MT_marker") + row.menu("GRAPH_MT_channel") + row.menu("GRAPH_MT_key") layout.prop(st, "mode", text="") @@ -61,7 +60,7 @@ class GRAPH_HT_header(bpy.types.Header): row.operator("graph.ghost_curves_create", text="", icon='GHOST_ENABLED') -class GRAPH_MT_view(bpy.types.Menu): +class GRAPH_MT_view(Menu): bl_label = "View" def draw(self, context): @@ -69,8 +68,6 @@ class GRAPH_MT_view(bpy.types.Menu): st = context.space_data - layout.column() - layout.operator("graph.properties", icon='MENU_PANEL') layout.separator() @@ -107,13 +104,12 @@ class GRAPH_MT_view(bpy.types.Menu): layout.operator("screen.screen_full_area") -class GRAPH_MT_select(bpy.types.Menu): +class GRAPH_MT_select(Menu): bl_label = "Select" def draw(self, context): layout = self.layout - layout.column() # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None layout.operator("graph.select_all_toggle") layout.operator("graph.select_all_toggle", text="Invert Selection").invert = True @@ -142,7 +138,7 @@ class GRAPH_MT_select(bpy.types.Menu): layout.operator("graph.select_linked") -class GRAPH_MT_marker(bpy.types.Menu): +class GRAPH_MT_marker(Menu): bl_label = "Marker" def draw(self, context): @@ -150,7 +146,6 @@ class GRAPH_MT_marker(bpy.types.Menu): #layout.operator_context = 'EXEC_REGION_WIN' - layout.column() layout.operator("marker.add", "Add Marker") layout.operator("marker.duplicate", text="Duplicate Marker") layout.operator("marker.delete", text="Delete Marker") @@ -163,7 +158,7 @@ class GRAPH_MT_marker(bpy.types.Menu): # TODO: pose markers for action edit mode only? -class GRAPH_MT_channel(bpy.types.Menu): +class GRAPH_MT_channel(Menu): bl_label = "Channel" def draw(self, context): @@ -171,7 +166,6 @@ class GRAPH_MT_channel(bpy.types.Menu): layout.operator_context = 'INVOKE_REGION_CHANNELS' - layout.column() layout.operator("anim.channels_delete") layout.separator() @@ -195,13 +189,12 @@ class GRAPH_MT_channel(bpy.types.Menu): layout.operator("anim.channels_fcurves_enable") -class GRAPH_MT_key(bpy.types.Menu): +class GRAPH_MT_key(Menu): bl_label = "Key" def draw(self, context): layout = self.layout - layout.column() layout.menu("GRAPH_MT_key_transform", text="Transform") layout.operator_menu_enum("graph.snap", "type", text="Snap") @@ -234,13 +227,12 @@ class GRAPH_MT_key(bpy.types.Menu): layout.operator("graph.euler_filter", text="Discontinuity (Euler) Filter") -class GRAPH_MT_key_transform(bpy.types.Menu): +class GRAPH_MT_key_transform(Menu): bl_label = "Transform" def draw(self, context): layout = self.layout - layout.column() layout.operator("transform.translate", text="Grab/Move") layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND' layout.operator("transform.rotate", text="Rotate") diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index fa5579ea2e0..5d72482ce9c 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Header, Menu, Panel class BrushButtonsPanel(): @@ -31,7 +32,7 @@ class BrushButtonsPanel(): return sima.show_paint and toolsettings.brush -class IMAGE_MT_view(bpy.types.Menu): +class IMAGE_MT_view(Menu): bl_label = "View" def draw(self, context): @@ -79,7 +80,7 @@ class IMAGE_MT_view(bpy.types.Menu): layout.operator("screen.screen_full_area") -class IMAGE_MT_select(bpy.types.Menu): +class IMAGE_MT_select(Menu): bl_label = "Select" def draw(self, context): @@ -100,7 +101,7 @@ class IMAGE_MT_select(bpy.types.Menu): layout.operator("uv.select_linked") -class IMAGE_MT_image(bpy.types.Menu): +class IMAGE_MT_image(Menu): bl_label = "Image" def draw(self, context): @@ -151,7 +152,7 @@ class IMAGE_MT_image(bpy.types.Menu): layout.prop(sima, "use_image_paint") -class IMAGE_MT_image_invert(bpy.types.Menu): +class IMAGE_MT_image_invert(Menu): bl_label = "Invert" def draw(self, context): @@ -177,7 +178,7 @@ class IMAGE_MT_image_invert(bpy.types.Menu): op.invert_a = True -class IMAGE_MT_uvs_showhide(bpy.types.Menu): +class IMAGE_MT_uvs_showhide(Menu): bl_label = "Show/Hide Faces" def draw(self, context): @@ -188,7 +189,7 @@ class IMAGE_MT_uvs_showhide(bpy.types.Menu): layout.operator("uv.hide", text="Hide Unselected").unselected = True -class IMAGE_MT_uvs_transform(bpy.types.Menu): +class IMAGE_MT_uvs_transform(Menu): bl_label = "Transform" def draw(self, context): @@ -203,7 +204,7 @@ class IMAGE_MT_uvs_transform(bpy.types.Menu): layout.operator("transform.shear") -class IMAGE_MT_uvs_snap(bpy.types.Menu): +class IMAGE_MT_uvs_snap(Menu): bl_label = "Snap" def draw(self, context): @@ -220,7 +221,7 @@ class IMAGE_MT_uvs_snap(bpy.types.Menu): layout.operator("uv.snap_cursor", text="Cursor to Selected").target = 'SELECTED' -class IMAGE_MT_uvs_mirror(bpy.types.Menu): +class IMAGE_MT_uvs_mirror(Menu): bl_label = "Mirror" def draw(self, context): @@ -231,7 +232,7 @@ class IMAGE_MT_uvs_mirror(bpy.types.Menu): layout.operator("transform.mirror", text="Y Axis").constraint_axis[1] = True -class IMAGE_MT_uvs_weldalign(bpy.types.Menu): +class IMAGE_MT_uvs_weldalign(Menu): bl_label = "Weld/Align" def draw(self, context): @@ -241,7 +242,7 @@ class IMAGE_MT_uvs_weldalign(bpy.types.Menu): layout.operator_enum("uv.align", "axis") # W, 2/3/4 -class IMAGE_MT_uvs(bpy.types.Menu): +class IMAGE_MT_uvs(Menu): bl_label = "UVs" def draw(self, context): @@ -286,7 +287,7 @@ class IMAGE_MT_uvs(bpy.types.Menu): layout.menu("IMAGE_MT_uvs_showhide") -class IMAGE_MT_uvs_select_mode(bpy.types.Menu): +class IMAGE_MT_uvs_select_mode(Menu): bl_label = "UV Select Mode" def draw(self, context): @@ -328,7 +329,7 @@ class IMAGE_MT_uvs_select_mode(bpy.types.Menu): prop.data_path = "tool_settings.uv_select_mode" -class IMAGE_HT_header(bpy.types.Header): +class IMAGE_HT_header(Header): bl_space_type = 'IMAGE_EDITOR' def draw(self, context): @@ -412,7 +413,7 @@ class IMAGE_HT_header(bpy.types.Header): layout.prop(sima, "use_realtime_update", text="", icon_only=True, icon='LOCKED') -class IMAGE_PT_image_properties(bpy.types.Panel): +class IMAGE_PT_image_properties(Panel): bl_space_type = 'IMAGE_EDITOR' bl_region_type = 'UI' bl_label = "Image" @@ -431,7 +432,7 @@ class IMAGE_PT_image_properties(bpy.types.Panel): layout.template_image(sima, "image", iuser) -class IMAGE_PT_game_properties(bpy.types.Panel): +class IMAGE_PT_game_properties(Panel): bl_space_type = 'IMAGE_EDITOR' bl_region_type = 'UI' bl_label = "Game Properties" @@ -451,15 +452,13 @@ class IMAGE_PT_game_properties(bpy.types.Panel): split = layout.split() col = split.column() - + + col.prop(ima, "use_animation") sub = col.column(align=True) - sub.prop(ima, "use_animation") - - subsub = sub.column() - subsub.active = ima.use_animation - subsub.prop(ima, "frame_start", text="Start") - subsub.prop(ima, "frame_end", text="End") - subsub.prop(ima, "fps", text="Speed") + sub.active = ima.use_animation + sub.prop(ima, "frame_start", text="Start") + sub.prop(ima, "frame_end", text="End") + sub.prop(ima, "fps", text="Speed") col.prop(ima, "use_tiles") sub = col.column(align=True) @@ -475,7 +474,7 @@ class IMAGE_PT_game_properties(bpy.types.Panel): col.prop(ima, "mapping", expand=True) -class IMAGE_PT_view_histogram(bpy.types.Panel): +class IMAGE_PT_view_histogram(Panel): bl_space_type = 'IMAGE_EDITOR' bl_region_type = 'PREVIEW' bl_label = "Histogram" @@ -494,7 +493,7 @@ class IMAGE_PT_view_histogram(bpy.types.Panel): layout.prop(sima.scopes.histogram, "mode", icon_only=True) -class IMAGE_PT_view_waveform(bpy.types.Panel): +class IMAGE_PT_view_waveform(Panel): bl_space_type = 'IMAGE_EDITOR' bl_region_type = 'PREVIEW' bl_label = "Waveform" @@ -508,13 +507,14 @@ class IMAGE_PT_view_waveform(bpy.types.Panel): layout = self.layout sima = context.space_data + layout.template_waveform(sima, "scopes") - sub = layout.row().split(percentage=0.75) - sub.prop(sima.scopes, "waveform_alpha") - sub.prop(sima.scopes, "waveform_mode", text="", icon_only=True) + row = layout.split(percentage=0.75) + row.prop(sima.scopes, "waveform_alpha") + row.prop(sima.scopes, "waveform_mode", text="", icon_only=True) -class IMAGE_PT_view_vectorscope(bpy.types.Panel): +class IMAGE_PT_view_vectorscope(Panel): bl_space_type = 'IMAGE_EDITOR' bl_region_type = 'PREVIEW' bl_label = "Vectorscope" @@ -532,7 +532,7 @@ class IMAGE_PT_view_vectorscope(bpy.types.Panel): layout.prop(sima.scopes, "vectorscope_alpha") -class IMAGE_PT_sample_line(bpy.types.Panel): +class IMAGE_PT_sample_line(Panel): bl_space_type = 'IMAGE_EDITOR' bl_region_type = 'PREVIEW' bl_label = "Sample Line" @@ -544,13 +544,15 @@ class IMAGE_PT_sample_line(bpy.types.Panel): def draw(self, context): layout = self.layout - layout.operator("image.sample_line") + sima = context.space_data + + layout.operator("image.sample_line") layout.template_histogram(sima, "sample_histogram") layout.prop(sima.sample_histogram, "mode") -class IMAGE_PT_scope_sample(bpy.types.Panel): +class IMAGE_PT_scope_sample(Panel): bl_space_type = 'IMAGE_EDITOR' bl_region_type = 'PREVIEW' bl_label = "Scope Samples" @@ -562,16 +564,17 @@ class IMAGE_PT_scope_sample(bpy.types.Panel): def draw(self, context): layout = self.layout + sima = context.space_data - split = layout.split() - row = split.row() + + row = layout.row() row.prop(sima.scopes, "use_full_resolution") - row = split.row() - row.active = not sima.scopes.use_full_resolution - row.prop(sima.scopes, "accuracy") + sub = row.row() + sub.active = not sima.scopes.use_full_resolution + sub.prop(sima.scopes, "accuracy") -class IMAGE_PT_view_properties(bpy.types.Panel): +class IMAGE_PT_view_properties(Panel): bl_space_type = 'IMAGE_EDITOR' bl_region_type = 'UI' bl_label = "Display" @@ -608,16 +611,16 @@ class IMAGE_PT_view_properties(bpy.types.Panel): if show_uvedit: col = layout.column() - col.label("Cursor Location") - row = col.row() - row.prop(uvedit, "cursor_location", text="") - - col = layout.column() + col.label("Cursor Location:") + col.row().prop(uvedit, "cursor_location", text="") + + col.separator() + col.label(text="UVs:") - row = col.row() - row.prop(uvedit, "edge_draw_type", expand=True) + col.row().prop(uvedit, "edge_draw_type", expand=True) split = layout.split() + col = split.column() col.prop(uvedit, "show_faces") col.prop(uvedit, "show_smooth_edges", text="Smooth") @@ -630,7 +633,7 @@ class IMAGE_PT_view_properties(bpy.types.Panel): sub.row().prop(uvedit, "draw_stretch_type", expand=True) -class IMAGE_PT_paint(bpy.types.Panel): +class IMAGE_PT_paint(Panel): bl_space_type = 'IMAGE_EDITOR' bl_region_type = 'UI' bl_label = "Paint" @@ -646,9 +649,8 @@ class IMAGE_PT_paint(bpy.types.Panel): toolsettings = context.tool_settings.image_paint brush = toolsettings.brush - col = layout.split().column() - row = col.row() - col.template_ID_preview(toolsettings, "brush", new="brush.add", rows=3, cols=8) + col = layout.column() + col.template_ID_preview(toolsettings, "brush", new="brush.add", rows=2, cols=6) if brush: col = layout.column() @@ -675,7 +677,7 @@ class IMAGE_PT_paint(bpy.types.Panel): col.prop(brush, "clone_alpha", text="Alpha") -class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, bpy.types.Panel): +class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel): bl_label = "Texture" bl_options = {'DEFAULT_CLOSED'} @@ -690,7 +692,7 @@ class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, bpy.types.Panel): col.prop(brush, "use_fixed_texture") -class IMAGE_PT_tools_brush_tool(BrushButtonsPanel, bpy.types.Panel): +class IMAGE_PT_tools_brush_tool(BrushButtonsPanel, Panel): bl_label = "Tool" bl_options = {'DEFAULT_CLOSED'} @@ -699,9 +701,7 @@ class IMAGE_PT_tools_brush_tool(BrushButtonsPanel, bpy.types.Panel): settings = context.tool_settings.image_paint brush = settings.brush - col = layout.column(align=True) - - col.prop(brush, "image_tool", expand=False, text="") + layout.prop(brush, "image_tool", text="") row = layout.row(align=True) row.prop(brush, "use_paint_sculpt", text="", icon='SCULPTMODE_HLT') @@ -710,7 +710,7 @@ class IMAGE_PT_tools_brush_tool(BrushButtonsPanel, bpy.types.Panel): row.prop(brush, "use_paint_image", text="", icon='TPAINT_HLT') -class IMAGE_PT_paint_stroke(BrushButtonsPanel, bpy.types.Panel): +class IMAGE_PT_paint_stroke(BrushButtonsPanel, Panel): bl_label = "Paint Stroke" bl_options = {'DEFAULT_CLOSED'} @@ -721,9 +721,9 @@ class IMAGE_PT_paint_stroke(BrushButtonsPanel, bpy.types.Panel): brush = toolsettings.brush layout.prop(brush, "use_airbrush") - col = layout.column() - col.active = brush.use_airbrush - col.prop(brush, "rate", slider=True) + row = layout.row() + row.active = brush.use_airbrush + row.prop(brush, "rate", slider=True) layout.prop(brush, "use_space") row = layout.row(align=True) @@ -734,7 +734,7 @@ class IMAGE_PT_paint_stroke(BrushButtonsPanel, bpy.types.Panel): layout.prop(brush, "use_wrap") -class IMAGE_PT_paint_curve(BrushButtonsPanel, bpy.types.Panel): +class IMAGE_PT_paint_curve(BrushButtonsPanel, Panel): bl_label = "Paint Curve" bl_options = {'DEFAULT_CLOSED'} diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index 0f8173ae4af..4a65c1ee2d0 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -18,9 +18,10 @@ # <pep8 compliant> import bpy +from bpy.types import Header, Menu, Operator -class INFO_HT_header(bpy.types.Header): +class INFO_HT_header(Header): bl_space_type = 'INFO' def draw(self, context): @@ -86,19 +87,19 @@ class INFO_HT_header(bpy.types.Header): """ -class INFO_MT_report(bpy.types.Menu): +class INFO_MT_report(Menu): bl_label = "Report" def draw(self, context): layout = self.layout - layout.column() + layout.operator("console.select_all_toggle") layout.operator("console.select_border") layout.operator("console.report_delete") layout.operator("console.report_copy") -class INFO_MT_file(bpy.types.Menu): +class INFO_MT_file(Menu): bl_label = "File" def draw(self, context): @@ -152,7 +153,7 @@ class INFO_MT_file(bpy.types.Menu): layout.operator("wm.quit_blender", text="Quit", icon='QUIT') -class INFO_MT_file_import(bpy.types.Menu): +class INFO_MT_file_import(Menu): bl_idname = "INFO_MT_file_import" bl_label = "Import" @@ -160,8 +161,10 @@ class INFO_MT_file_import(bpy.types.Menu): if hasattr(bpy.types, "WM_OT_collada_import"): self.layout.operator("wm.collada_import", text="COLLADA (.dae)") + self.layout.operator("export_mesh.wavefront", text="Wavefront (.obj), BMesh") + -class INFO_MT_file_export(bpy.types.Menu): +class INFO_MT_file_export(Menu): bl_idname = "INFO_MT_file_export" bl_label = "Export" @@ -169,10 +172,8 @@ class INFO_MT_file_export(bpy.types.Menu): if hasattr(bpy.types, "WM_OT_collada_export"): self.layout.operator("wm.collada_export", text="COLLADA (.dae)") - self.layout.operator("export_mesh.wavefront", text="Wavefront (.obj), BMesh") - -class INFO_MT_file_external_data(bpy.types.Menu): +class INFO_MT_file_external_data(Menu): bl_label = "External Data" def draw(self, context): @@ -189,12 +190,13 @@ class INFO_MT_file_external_data(bpy.types.Menu): layout.operator("file.find_missing_files") -class INFO_MT_mesh_add(bpy.types.Menu): +class INFO_MT_mesh_add(Menu): bl_idname = "INFO_MT_mesh_add" bl_label = "Mesh" def draw(self, context): layout = self.layout + layout.operator_context = 'INVOKE_REGION_WIN' layout.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text="Plane") layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube") @@ -209,12 +211,13 @@ class INFO_MT_mesh_add(bpy.types.Menu): layout.operator("mesh.primitive_torus_add", text="Torus", icon='MESH_TORUS') -class INFO_MT_curve_add(bpy.types.Menu): +class INFO_MT_curve_add(Menu): bl_idname = "INFO_MT_curve_add" bl_label = "Curve" def draw(self, context): layout = self.layout + layout.operator_context = 'INVOKE_REGION_WIN' layout.operator("curve.primitive_bezier_curve_add", icon='CURVE_BEZCURVE', text="Bezier") layout.operator("curve.primitive_bezier_circle_add", icon='CURVE_BEZCIRCLE', text="Circle") @@ -223,7 +226,7 @@ class INFO_MT_curve_add(bpy.types.Menu): layout.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH', text="Path") -class INFO_MT_edit_curve_add(bpy.types.Menu): +class INFO_MT_edit_curve_add(Menu): bl_idname = "INFO_MT_edit_curve_add" bl_label = "Add" @@ -239,12 +242,13 @@ class INFO_MT_edit_curve_add(bpy.types.Menu): INFO_MT_curve_add.draw(self, context) -class INFO_MT_surface_add(bpy.types.Menu): +class INFO_MT_surface_add(Menu): bl_idname = "INFO_MT_surface_add" bl_label = "Surface" def draw(self, context): layout = self.layout + layout.operator_context = 'INVOKE_REGION_WIN' layout.operator("surface.primitive_nurbs_surface_curve_add", icon='SURFACE_NCURVE', text="NURBS Curve") layout.operator("surface.primitive_nurbs_surface_circle_add", icon='SURFACE_NCIRCLE', text="NURBS Circle") @@ -254,17 +258,18 @@ class INFO_MT_surface_add(bpy.types.Menu): layout.operator("surface.primitive_nurbs_surface_torus_add", icon='SURFACE_NTORUS', text="NURBS Torus") -class INFO_MT_armature_add(bpy.types.Menu): +class INFO_MT_armature_add(Menu): bl_idname = "INFO_MT_armature_add" bl_label = "Armature" def draw(self, context): layout = self.layout + layout.operator_context = 'INVOKE_REGION_WIN' layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA') -class INFO_MT_add(bpy.types.Menu): +class INFO_MT_add(Menu): bl_label = "Add" def draw(self, context): @@ -304,7 +309,7 @@ class INFO_MT_add(bpy.types.Menu): layout.operator_menu_enum("object.group_instance_add", "group", text="Group Instance", icon='OUTLINER_OB_EMPTY') -class INFO_MT_game(bpy.types.Menu): +class INFO_MT_game(Menu): bl_label = "Game" def draw(self, context): @@ -325,7 +330,7 @@ class INFO_MT_game(bpy.types.Menu): layout.prop(gs, "use_auto_start") -class INFO_MT_render(bpy.types.Menu): +class INFO_MT_render(Menu): bl_label = "Render" def draw(self, context): @@ -345,7 +350,7 @@ class INFO_MT_render(bpy.types.Menu): layout.operator("render.play_rendered_anim") -class INFO_MT_help(bpy.types.Menu): +class INFO_MT_help(Menu): bl_label = "Help" def draw(self, context): @@ -381,7 +386,7 @@ class INFO_MT_help(bpy.types.Menu): # Help operators -class HELP_OT_operator_cheat_sheet(bpy.types.Operator): +class HELP_OT_operator_cheat_sheet(Operator): bl_idname = "help.operator_cheat_sheet" bl_label = "Operator Cheat Sheet" diff --git a/release/scripts/startup/bl_ui/space_logic.py b/release/scripts/startup/bl_ui/space_logic.py index 7f7aba71a46..869a91124d3 100644 --- a/release/scripts/startup/bl_ui/space_logic.py +++ b/release/scripts/startup/bl_ui/space_logic.py @@ -18,9 +18,10 @@ # <pep8 compliant> import bpy +from bpy.types import Header, Menu, Panel -class LOGIC_PT_properties(bpy.types.Panel): +class LOGIC_PT_properties(Panel): bl_space_type = 'LOGIC_EDITOR' bl_region_type = 'UI' bl_label = "Properties" @@ -49,7 +50,7 @@ class LOGIC_PT_properties(bpy.types.Panel): row.operator("object.game_property_remove", text="", icon='X', emboss=False).index = i -class LOGIC_MT_logicbricks_add(bpy.types.Menu): +class LOGIC_MT_logicbricks_add(Menu): bl_label = "Add" def draw(self, context): @@ -60,30 +61,24 @@ class LOGIC_MT_logicbricks_add(bpy.types.Menu): layout.operator_menu_enum("logic.actuator_add", "type", text="Actuator") -class LOGIC_HT_header(bpy.types.Header): +class LOGIC_HT_header(Header): bl_space_type = 'LOGIC_EDITOR' def draw(self, context): - layout = self.layout + layout = self.layout.row(align=True) - row = layout.row(align=True) - row.template_header() + layout.template_header() if context.area.show_menus: - sub = row.row(align=True) - sub.menu("LOGIC_MT_view") - #sub.menu("LOGIC_MT_select") - #sub.menu("LOGIC_MT_add") + layout.menu("LOGIC_MT_view") -class LOGIC_MT_view(bpy.types.Menu): +class LOGIC_MT_view(Menu): bl_label = "View" def draw(self, context): layout = self.layout - layout.column() - layout.operator("logic.properties", icon='MENU_PANEL') if __name__ == "__main__": # only for live edit. diff --git a/release/scripts/startup/bl_ui/space_nla.py b/release/scripts/startup/bl_ui/space_nla.py index 717adb3baa8..c69af2c9a60 100644 --- a/release/scripts/startup/bl_ui/space_nla.py +++ b/release/scripts/startup/bl_ui/space_nla.py @@ -19,9 +19,10 @@ # <pep8 compliant> import bpy +from bpy.types import Header, Menu -class NLA_HT_header(bpy.types.Header): +class NLA_HT_header(Header): bl_space_type = 'NLA_EDITOR' def draw(self, context): @@ -35,20 +36,18 @@ class NLA_HT_header(bpy.types.Header): row.template_header() if context.area.show_menus: - sub = row.row(align=True) - - sub.menu("NLA_MT_view") - sub.menu("NLA_MT_select") - sub.menu("NLA_MT_marker") - sub.menu("NLA_MT_edit") - sub.menu("NLA_MT_add") + row.menu("NLA_MT_view") + row.menu("NLA_MT_select") + row.menu("NLA_MT_marker") + row.menu("NLA_MT_edit") + row.menu("NLA_MT_add") dopesheet_filter(layout, context) layout.prop(st, "auto_snap", text="") -class NLA_MT_view(bpy.types.Menu): +class NLA_MT_view(Menu): bl_label = "View" def draw(self, context): @@ -56,8 +55,6 @@ class NLA_MT_view(bpy.types.Menu): st = context.space_data - layout.column() - layout.operator("nla.properties", icon='MENU_PANEL') layout.separator() @@ -78,13 +75,12 @@ class NLA_MT_view(bpy.types.Menu): layout.operator("screen.screen_full_area") -class NLA_MT_select(bpy.types.Menu): +class NLA_MT_select(Menu): bl_label = "Select" def draw(self, context): layout = self.layout - layout.column() # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None layout.operator("nla.select_all_toggle") layout.operator("nla.select_all_toggle", text="Invert Selection").invert = True @@ -98,7 +94,7 @@ class NLA_MT_select(bpy.types.Menu): layout.operator("nla.select_leftright", text="After Current Frame").mode = 'RIGHT' -class NLA_MT_marker(bpy.types.Menu): +class NLA_MT_marker(Menu): bl_label = "Marker" def draw(self, context): @@ -106,7 +102,6 @@ class NLA_MT_marker(bpy.types.Menu): #layout.operator_context = 'EXEC_REGION_WIN' - layout.column() layout.operator("marker.add", "Add Marker") layout.operator("marker.duplicate", text="Duplicate Marker") layout.operator("marker.delete", text="Delete Marker") @@ -117,7 +112,7 @@ class NLA_MT_marker(bpy.types.Menu): layout.operator("marker.move", text="Grab/Move Marker") -class NLA_MT_edit(bpy.types.Menu): +class NLA_MT_edit(Menu): bl_label = "Edit" def draw(self, context): @@ -125,7 +120,6 @@ class NLA_MT_edit(bpy.types.Menu): scene = context.scene - layout.column() layout.menu("NLA_MT_edit_transform", text="Transform") layout.operator_menu_enum("nla.snap", "type", text="Snap") @@ -160,13 +154,12 @@ class NLA_MT_edit(bpy.types.Menu): layout.operator("nla.tweakmode_enter", text="Start Tweaking Strip Actions") -class NLA_MT_add(bpy.types.Menu): +class NLA_MT_add(Menu): bl_label = "Add" def draw(self, context): layout = self.layout - layout.column() layout.operator("nla.actionclip_add") layout.operator("nla.transition_add") @@ -179,13 +172,12 @@ class NLA_MT_add(bpy.types.Menu): layout.operator("nla.tracks_add", text="Add Tracks Above Selected").above_selected = True -class NLA_MT_edit_transform(bpy.types.Menu): +class NLA_MT_edit_transform(Menu): bl_label = "Transform" def draw(self, context): layout = self.layout - layout.column() layout.operator("transform.translate", text="Grab/Move") layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND' layout.operator("transform.transform", text="Scale").mode = 'TIME_SCALE' diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index 2088d8798f2..708017ba749 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -18,42 +18,39 @@ # <pep8 compliant> import bpy +from bpy.types import Header, Menu, Panel -class NODE_HT_header(bpy.types.Header): +class NODE_HT_header(Header): bl_space_type = 'NODE_EDITOR' def draw(self, context): layout = self.layout snode = context.space_data + snode_id = snode.id + id_from = snode.id_from row = layout.row(align=True) row.template_header() if context.area.show_menus: - sub = row.row(align=True) - sub.menu("NODE_MT_view") - sub.menu("NODE_MT_select") - sub.menu("NODE_MT_add") - sub.menu("NODE_MT_node") + row.menu("NODE_MT_view") + row.menu("NODE_MT_select") + row.menu("NODE_MT_add") + row.menu("NODE_MT_node") - row = layout.row() - row.prop(snode, "tree_type", text="", expand=True) + layout.prop(snode, "tree_type", text="", expand=True) if snode.tree_type == 'MATERIAL': - ob = snode.id_from - snode_id = snode.id - if ob: - layout.template_ID(ob, "active_material", new="material.new") + if id_from: + layout.template_ID(id_from, "active_material", new="material.new") if snode_id: layout.prop(snode_id, "use_nodes") elif snode.tree_type == 'TEXTURE': - row.prop(snode, "texture_type", text="", expand=True) + layout.prop(snode, "texture_type", text="", expand=True) - snode_id = snode.id - id_from = snode.id_from if id_from: if snode.texture_type == 'BRUSH': layout.template_ID(id_from, "texture", new="texture.new") @@ -63,10 +60,8 @@ class NODE_HT_header(bpy.types.Header): layout.prop(snode_id, "use_nodes") elif snode.tree_type == 'COMPOSITING': - scene = snode.id - - layout.prop(scene, "use_nodes") - layout.prop(scene.render, "use_free_unused_nodes", text="Free Unused") + layout.prop(snode_id, "use_nodes") + layout.prop(snode_id.render, "use_free_unused_nodes", text="Free Unused") layout.prop(snode, "show_backdrop") if snode.show_backdrop: row = layout.row(align=True) @@ -78,7 +73,7 @@ class NODE_HT_header(bpy.types.Header): layout.template_running_jobs() -class NODE_MT_view(bpy.types.Menu): +class NODE_MT_view(Menu): bl_label = "View" def draw(self, context): @@ -107,7 +102,7 @@ class NODE_MT_view(bpy.types.Menu): layout.operator("screen.screen_full_area") -class NODE_MT_select(bpy.types.Menu): +class NODE_MT_select(Menu): bl_label = "Select" def draw(self, context): @@ -124,7 +119,7 @@ class NODE_MT_select(bpy.types.Menu): layout.operator("node.select_same_type_prev") -class NODE_MT_node(bpy.types.Menu): +class NODE_MT_node(Menu): bl_label = "Node" def draw(self, context): @@ -165,7 +160,7 @@ class NODE_MT_node(bpy.types.Menu): # Node Backdrop options -class NODE_PT_properties(bpy.types.Panel): +class NODE_PT_properties(Panel): bl_space_type = 'NODE_EDITOR' bl_region_type = 'UI' bl_label = "Backdrop" diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py index 1f196cbd191..b1e6eaf3245 100644 --- a/release/scripts/startup/bl_ui/space_outliner.py +++ b/release/scripts/startup/bl_ui/space_outliner.py @@ -18,9 +18,10 @@ # <pep8 compliant> import bpy +from bpy.types import Header, Menu -class OUTLINER_HT_header(bpy.types.Header): +class OUTLINER_HT_header(Header): bl_space_type = 'OUTLINER' def draw(self, context): @@ -63,7 +64,7 @@ class OUTLINER_HT_header(bpy.types.Header): row.label(text="No Keying Set active") -class OUTLINER_MT_view(bpy.types.Menu): +class OUTLINER_MT_view(Menu): bl_label = "View" def draw(self, context): @@ -71,14 +72,13 @@ class OUTLINER_MT_view(bpy.types.Menu): space = context.space_data - col = layout.column() if space.display_mode not in {'DATABLOCKS', 'USER_PREFERENCES', 'KEYMAPS'}: - col.prop(space, "show_restrict_columns") - col.separator() - col.operator("outliner.show_active") + layout.prop(space, "show_restrict_columns") + layout.separator() + layout.operator("outliner.show_active") - col.operator("outliner.show_one_level") - col.operator("outliner.show_hierarchy") + layout.operator("outliner.show_one_level") + layout.operator("outliner.show_hierarchy") layout.separator() @@ -86,7 +86,7 @@ class OUTLINER_MT_view(bpy.types.Menu): layout.operator("screen.screen_full_area") -class OUTLINER_MT_search(bpy.types.Menu): +class OUTLINER_MT_search(Menu): bl_label = "Search" def draw(self, context): @@ -94,27 +94,23 @@ class OUTLINER_MT_search(bpy.types.Menu): space = context.space_data - col = layout.column() + layout.prop(space, "use_filter_case_sensitive") + layout.prop(space, "use_filter_complete") - col.prop(space, "use_filter_case_sensitive") - col.prop(space, "use_filter_complete") - -class OUTLINER_MT_edit_datablocks(bpy.types.Menu): +class OUTLINER_MT_edit_datablocks(Menu): bl_label = "Edit" def draw(self, context): layout = self.layout - col = layout.column() - - col.operator("outliner.keyingset_add_selected") - col.operator("outliner.keyingset_remove_selected") + layout.operator("outliner.keyingset_add_selected") + layout.operator("outliner.keyingset_remove_selected") - col.separator() + layout.separator() - col.operator("outliner.drivers_add_selected") - col.operator("outliner.drivers_delete_selected") + layout.operator("outliner.drivers_add_selected") + layout.operator("outliner.drivers_delete_selected") if __name__ == "__main__": # only for live edit. bpy.utils.register_module(__name__) diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index c477a2ff62b..84cc365425e 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Header, Menu, Panel def act_strip(context): @@ -27,7 +28,7 @@ def act_strip(context): return None -class SEQUENCER_HT_header(bpy.types.Header): +class SEQUENCER_HT_header(Header): bl_space_type = 'SEQUENCE_EDITOR' def draw(self, context): @@ -39,14 +40,13 @@ class SEQUENCER_HT_header(bpy.types.Header): row.template_header() if context.area.show_menus: - sub = row.row(align=True) - sub.menu("SEQUENCER_MT_view") + row.menu("SEQUENCER_MT_view") if st.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'}: - sub.menu("SEQUENCER_MT_select") - sub.menu("SEQUENCER_MT_marker") - sub.menu("SEQUENCER_MT_add") - sub.menu("SEQUENCER_MT_strip") + row.menu("SEQUENCER_MT_select") + row.menu("SEQUENCER_MT_marker") + row.menu("SEQUENCER_MT_add") + row.menu("SEQUENCER_MT_strip") layout.prop(st, "view_type", expand=True, text="") @@ -76,7 +76,7 @@ class SEQUENCER_HT_header(bpy.types.Header): row.prop(ed, "overlay_lock", text="", icon='LOCKED') -class SEQUENCER_MT_view_toggle(bpy.types.Menu): +class SEQUENCER_MT_view_toggle(Menu): bl_label = "View Type" def draw(self, context): @@ -87,7 +87,7 @@ class SEQUENCER_MT_view_toggle(bpy.types.Menu): layout.operator("sequencer.view_toggle").type = 'SEQUENCER_PREVIEW' -class SEQUENCER_MT_view(bpy.types.Menu): +class SEQUENCER_MT_view(Menu): bl_label = "View" def draw(self, context): @@ -95,8 +95,6 @@ class SEQUENCER_MT_view(bpy.types.Menu): st = context.space_data - layout.column() - layout.operator("sequencer.properties", icon='MENU_PANEL') layout.separator() @@ -129,13 +127,12 @@ class SEQUENCER_MT_view(bpy.types.Menu): layout.operator("screen.screen_full_area") -class SEQUENCER_MT_select(bpy.types.Menu): +class SEQUENCER_MT_select(Menu): bl_label = "Select" def draw(self, context): layout = self.layout - layout.column() layout.operator("sequencer.select_active_side", text="Strips to the Left").side = 'LEFT' layout.operator("sequencer.select_active_side", text="Strips to the Right").side = 'RIGHT' layout.separator() @@ -148,7 +145,7 @@ class SEQUENCER_MT_select(bpy.types.Menu): layout.operator("sequencer.select_inverse") -class SEQUENCER_MT_marker(bpy.types.Menu): +class SEQUENCER_MT_marker(Menu): bl_label = "Marker" def draw(self, context): @@ -156,7 +153,6 @@ class SEQUENCER_MT_marker(bpy.types.Menu): #layout.operator_context = 'EXEC_REGION_WIN' - layout.column() layout.operator("marker.add", "Add Marker") layout.operator("marker.duplicate", text="Duplicate Marker") layout.operator("marker.delete", text="Delete Marker") @@ -169,14 +165,26 @@ class SEQUENCER_MT_marker(bpy.types.Menu): #layout.operator("sequencer.sound_strip_add", text="Transform Markers") # toggle, will be rna - (sseq->flag & SEQ_MARKER_TRANS) -class SEQUENCER_MT_add(bpy.types.Menu): +class SEQUENCER_MT_change(Menu): + bl_label = "Change" + + def draw(self, context): + layout = self.layout + + layout.operator_context = 'INVOKE_REGION_WIN' + + layout.operator_menu_enum("sequencer.change_effect_input", "swap") + layout.operator_menu_enum("sequencer.change_effect_type", "type") + layout.operator("sequencer.change_path", text="Path/Files") + + +class SEQUENCER_MT_add(Menu): bl_label = "Add" def draw(self, context): layout = self.layout layout.operator_context = 'INVOKE_REGION_WIN' - layout.column() if len(bpy.data.scenes) > 10: layout.operator_context = 'INVOKE_DEFAULT' layout.operator("sequencer.scene_strip_add", text="Scene...") @@ -190,14 +198,13 @@ class SEQUENCER_MT_add(bpy.types.Menu): layout.menu("SEQUENCER_MT_add_effect") -class SEQUENCER_MT_add_effect(bpy.types.Menu): +class SEQUENCER_MT_add_effect(Menu): bl_label = "Effect Strip..." def draw(self, context): layout = self.layout layout.operator_context = 'INVOKE_REGION_WIN' - layout.column() layout.operator("sequencer.effect_strip_add", text="Add").type = 'ADD' layout.operator("sequencer.effect_strip_add", text="Subtract").type = 'SUBTRACT' layout.operator("sequencer.effect_strip_add", text="Alpha Over").type = 'ALPHA_OVER' @@ -216,7 +223,7 @@ class SEQUENCER_MT_add_effect(bpy.types.Menu): layout.operator("sequencer.effect_strip_add", text="Adjustment Layer").type = 'ADJUSTMENT' -class SEQUENCER_MT_strip(bpy.types.Menu): +class SEQUENCER_MT_strip(Menu): bl_label = "Strip" def draw(self, context): @@ -224,7 +231,6 @@ class SEQUENCER_MT_strip(bpy.types.Menu): layout.operator_context = 'INVOKE_REGION_WIN' - layout.column() layout.operator("transform.transform", text="Grab/Move").mode = 'TRANSLATION' layout.operator("transform.transform", text="Grab/Extend from frame").mode = 'TIME_EXTEND' # uiItemO(layout, NULL, 0, "sequencer.strip_snap"); // TODO - add this operator @@ -233,6 +239,7 @@ class SEQUENCER_MT_strip(bpy.types.Menu): layout.operator("sequencer.cut", text="Cut (hard) at frame").type = 'HARD' layout.operator("sequencer.cut", text="Cut (soft) at frame").type = 'SOFT' layout.operator("sequencer.images_separate") + layout.operator("sequencer.offset_clear") layout.operator("sequencer.deinterlace_selected_movies") layout.separator() @@ -292,6 +299,7 @@ class SEQUENCER_MT_strip(bpy.types.Menu): layout.separator() layout.operator("sequencer.swap_data") + layout.menu("SEQUENCER_MT_change") class SequencerButtonsPanel(): @@ -320,7 +328,7 @@ class SequencerButtonsPanel_Output(): return cls.has_preview(context) -class SEQUENCER_PT_edit(SequencerButtonsPanel, bpy.types.Panel): +class SEQUENCER_PT_edit(SequencerButtonsPanel, Panel): bl_label = "Edit Strip" def draw(self, context): @@ -374,9 +382,11 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel, bpy.types.Panel): if elem and elem.orig_width > 0 and elem.orig_height > 0: col.label(text="Orig Dim: %dx%d" % (elem.orig_width, elem.orig_height)) + else: + col.label(text="Orig Dim: None") -class SEQUENCER_PT_effect(SequencerButtonsPanel, bpy.types.Panel): +class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): bl_label = "Effect Strip" @classmethod @@ -514,7 +524,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, bpy.types.Panel): col.prop(strip, "rotation_start", text="Rotation") -class SEQUENCER_PT_input(SequencerButtonsPanel, bpy.types.Panel): +class SEQUENCER_PT_input(SequencerButtonsPanel, Panel): bl_label = "Strip Input" @classmethod @@ -558,6 +568,9 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, bpy.types.Panel): col = split.column() col.prop(elem, "filename", text="") # strip.elements[0] could be a fallback + # also accessible from the menu + layout.operator("sequencer.change_path") + elif seq_type == 'MOVIE': split = layout.split(percentage=0.2) col = split.column() @@ -595,7 +608,7 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, bpy.types.Panel): col.prop(strip, "frame_offset_end", text="End") -class SEQUENCER_PT_sound(SequencerButtonsPanel, bpy.types.Panel): +class SEQUENCER_PT_sound(SequencerButtonsPanel, Panel): bl_label = "Sound" @classmethod @@ -636,7 +649,7 @@ class SEQUENCER_PT_sound(SequencerButtonsPanel, bpy.types.Panel): col.prop(strip, "animation_offset_end", text="End") -class SEQUENCER_PT_scene(SequencerButtonsPanel, bpy.types.Panel): +class SEQUENCER_PT_scene(SequencerButtonsPanel, Panel): bl_label = "Scene" @classmethod @@ -670,7 +683,7 @@ class SEQUENCER_PT_scene(SequencerButtonsPanel, bpy.types.Panel): layout.label(text="Original frame range: %d-%d (%d)" % (sta, end, end - sta + 1)) -class SEQUENCER_PT_filter(SequencerButtonsPanel, bpy.types.Panel): +class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel): bl_label = "Filter" @classmethod @@ -732,7 +745,7 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel, bpy.types.Panel): col.prop(strip.color_balance, "invert_gain", text="Inverse") -class SEQUENCER_PT_proxy(SequencerButtonsPanel, bpy.types.Panel): +class SEQUENCER_PT_proxy(SequencerButtonsPanel, Panel): bl_label = "Proxy" @classmethod @@ -766,7 +779,7 @@ class SEQUENCER_PT_proxy(SequencerButtonsPanel, bpy.types.Panel): flow.prop(strip.proxy, "filepath") -class SEQUENCER_PT_preview(SequencerButtonsPanel_Output, bpy.types.Panel): +class SEQUENCER_PT_preview(SequencerButtonsPanel_Output, Panel): bl_label = "Scene Preview/Render" bl_space_type = 'SEQUENCE_EDITOR' bl_region_type = 'UI' @@ -791,7 +804,7 @@ class SEQUENCER_PT_preview(SequencerButtonsPanel_Output, bpy.types.Panel): ''' -class SEQUENCER_PT_view(SequencerButtonsPanel_Output, bpy.types.Panel): +class SEQUENCER_PT_view(SequencerButtonsPanel_Output, Panel): bl_label = "View Settings" def draw(self, context): diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py index b787fc5cf75..300211a26bf 100644 --- a/release/scripts/startup/bl_ui/space_text.py +++ b/release/scripts/startup/bl_ui/space_text.py @@ -18,9 +18,10 @@ # <pep8-80 compliant> import bpy +from bpy.types import Header, Menu, Panel -class TEXT_HT_header(bpy.types.Header): +class TEXT_HT_header(Header): bl_space_type = 'TEXT_EDITOR' def draw(self, context): @@ -74,7 +75,7 @@ class TEXT_HT_header(bpy.types.Header): else "Text: Internal") -class TEXT_PT_properties(bpy.types.Panel): +class TEXT_PT_properties(Panel): bl_space_type = 'TEXT_EDITOR' bl_region_type = 'UI' bl_label = "Properties" @@ -105,7 +106,7 @@ class TEXT_PT_properties(bpy.types.Panel): col.prop(st, "margin_column") -class TEXT_PT_find(bpy.types.Panel): +class TEXT_PT_find(Panel): bl_space_type = 'TEXT_EDITOR' bl_region_type = 'UI' bl_label = "Find" @@ -139,7 +140,7 @@ class TEXT_PT_find(bpy.types.Panel): row.prop(st, "use_find_all", text="All") -class TEXT_MT_view(bpy.types.Menu): +class TEXT_MT_view(Menu): bl_label = "View" def draw(self, context): @@ -162,7 +163,7 @@ class TEXT_MT_view(bpy.types.Menu): ).type = 'FILE_BOTTOM' -class TEXT_MT_text(bpy.types.Menu): +class TEXT_MT_text(Menu): bl_label = "Text" def draw(self, context): @@ -171,7 +172,6 @@ class TEXT_MT_text(bpy.types.Menu): st = context.space_data text = st.text - layout.column() layout.operator("text.new") layout.operator("text.open") @@ -188,13 +188,8 @@ class TEXT_MT_text(bpy.types.Menu): layout.column() layout.operator("text.run_script") - #ifdef WITH_PYTHON - # XXX if(BPY_is_pyconstraint(text)) - # XXX uiMenuItemO(head, 0, "text.refresh_pyconstraints"); - #endif - -class TEXT_MT_templates(bpy.types.Menu): +class TEXT_MT_templates(Menu): bl_label = "Templates" def draw(self, context): @@ -204,7 +199,7 @@ class TEXT_MT_templates(bpy.types.Menu): ) -class TEXT_MT_edit_select(bpy.types.Menu): +class TEXT_MT_edit_select(Menu): bl_label = "Select" def draw(self, context): @@ -214,7 +209,7 @@ class TEXT_MT_edit_select(bpy.types.Menu): layout.operator("text.select_line") -class TEXT_MT_edit_markers(bpy.types.Menu): +class TEXT_MT_edit_markers(Menu): bl_label = "Markers" def draw(self, context): @@ -225,7 +220,7 @@ class TEXT_MT_edit_markers(bpy.types.Menu): layout.operator("text.previous_marker") -class TEXT_MT_format(bpy.types.Menu): +class TEXT_MT_format(Menu): bl_label = "Format" def draw(self, context): @@ -244,7 +239,7 @@ class TEXT_MT_format(bpy.types.Menu): layout.operator_menu_enum("text.convert_whitespace", "type") -class TEXT_MT_edit_to3d(bpy.types.Menu): +class TEXT_MT_edit_to3d(Menu): bl_label = "Text To 3D Object" def draw(self, context): @@ -258,7 +253,7 @@ class TEXT_MT_edit_to3d(bpy.types.Menu): ).split_lines = True -class TEXT_MT_edit(bpy.types.Menu): +class TEXT_MT_edit(Menu): bl_label = "Edit" @classmethod @@ -292,7 +287,7 @@ class TEXT_MT_edit(bpy.types.Menu): layout.menu("TEXT_MT_edit_to3d") -class TEXT_MT_toolbox(bpy.types.Menu): +class TEXT_MT_toolbox(Menu): bl_label = "" def draw(self, context): diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py index 7e62465d1ee..db009fe43c2 100644 --- a/release/scripts/startup/bl_ui/space_time.py +++ b/release/scripts/startup/bl_ui/space_time.py @@ -18,9 +18,10 @@ # <pep8 compliant> import bpy +from bpy.types import Header, Menu -class TIME_HT_header(bpy.types.Header): +class TIME_HT_header(Header): bl_space_type = 'TIMELINE' def draw(self, context): @@ -34,10 +35,9 @@ class TIME_HT_header(bpy.types.Header): row.template_header() if context.area.show_menus: - sub = row.row(align=True) - sub.menu("TIME_MT_view") - sub.menu("TIME_MT_frame") - sub.menu("TIME_MT_playback") + row.menu("TIME_MT_view") + row.menu("TIME_MT_frame") + row.menu("TIME_MT_playback") layout.prop(scene, "use_preview_range", text="", toggle=True) @@ -91,7 +91,7 @@ class TIME_HT_header(bpy.types.Header): row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT') -class TIME_MT_view(bpy.types.Menu): +class TIME_MT_view(Menu): bl_label = "View" def draw(self, context): @@ -116,7 +116,7 @@ class TIME_MT_view(bpy.types.Menu): layout.operator("marker.camera_bind") -class TIME_MT_cache(bpy.types.Menu): +class TIME_MT_cache(Menu): bl_label = "Cache" def draw(self, context): @@ -136,7 +136,7 @@ class TIME_MT_cache(bpy.types.Menu): col.prop(st, "cache_smoke") -class TIME_MT_frame(bpy.types.Menu): +class TIME_MT_frame(Menu): bl_label = "Frame" def draw(self, context): @@ -162,7 +162,7 @@ class TIME_MT_frame(bpy.types.Menu): sub.menu("TIME_MT_autokey") -class TIME_MT_playback(bpy.types.Menu): +class TIME_MT_playback(Menu): bl_label = "Playback" def draw(self, context): @@ -187,7 +187,7 @@ class TIME_MT_playback(bpy.types.Menu): layout.prop(scene, "use_audio_scrub") -class TIME_MT_autokey(bpy.types.Menu): +class TIME_MT_autokey(Menu): bl_label = "Auto-Keyframing Mode" def draw(self, context): diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 944f5aaf4c1..148338368fe 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Header, Menu, Operator, Panel import os import addon_utils @@ -75,7 +76,7 @@ def opengl_lamp_buttons(column, lamp): col.prop(lamp, "direction", text="") -class USERPREF_HT_header(bpy.types.Header): +class USERPREF_HT_header(Header): bl_space_type = 'USER_PREFERENCES' def draw(self, context): @@ -99,7 +100,7 @@ class USERPREF_HT_header(bpy.types.Header): layout.operator("ui.reset_default_theme") -class USERPREF_PT_tabs(bpy.types.Panel): +class USERPREF_PT_tabs(Panel): bl_label = "" bl_space_type = 'USER_PREFERENCES' bl_region_type = 'WINDOW' @@ -113,14 +114,14 @@ class USERPREF_PT_tabs(bpy.types.Panel): layout.prop(userpref, "active_section", expand=True) -class USERPREF_MT_interaction_presets(bpy.types.Menu): +class USERPREF_MT_interaction_presets(Menu): bl_label = "Presets" preset_subdir = "interaction" preset_operator = "script.execute_preset" - draw = bpy.types.Menu.draw_preset + draw = Menu.draw_preset -class USERPREF_MT_appconfigs(bpy.types.Menu): +class USERPREF_MT_appconfigs(Menu): bl_label = "AppPresets" preset_subdir = "keyconfig" preset_operator = "wm.appconfig_activate" @@ -129,10 +130,10 @@ class USERPREF_MT_appconfigs(bpy.types.Menu): self.layout.operator("wm.appconfig_default", text="Blender (default)") # now draw the presets - bpy.types.Menu.draw_preset(self, context) + Menu.draw_preset(self, context) -class USERPREF_MT_splash(bpy.types.Menu): +class USERPREF_MT_splash(Menu): bl_label = "Splash" def draw(self, context): @@ -149,7 +150,7 @@ class USERPREF_MT_splash(bpy.types.Menu): row.menu("USERPREF_MT_appconfigs", text="Preset") -class USERPREF_PT_interface(bpy.types.Panel): +class USERPREF_PT_interface(Panel): bl_space_type = 'USER_PREFERENCES' bl_label = "Interface" bl_region_type = 'WINDOW' @@ -246,7 +247,7 @@ class USERPREF_PT_interface(bpy.types.Panel): col.prop(view, "show_splash") -class USERPREF_PT_edit(bpy.types.Panel): +class USERPREF_PT_edit(Panel): bl_space_type = 'USER_PREFERENCES' bl_label = "Edit" bl_region_type = 'WINDOW' @@ -359,7 +360,7 @@ class USERPREF_PT_edit(bpy.types.Panel): col.prop(edit, "use_duplicate_particle", text="Particle") -class USERPREF_PT_system(bpy.types.Panel): +class USERPREF_PT_system(Panel): bl_space_type = 'USER_PREFERENCES' bl_label = "System" bl_region_type = 'WINDOW' @@ -496,7 +497,7 @@ class USERPREF_PT_system(bpy.types.Panel): sub.template_color_ramp(system, "weight_color_range", expand=True) -class USERPREF_PT_theme(bpy.types.Panel): +class USERPREF_PT_theme(Panel): bl_space_type = 'USER_PREFERENCES' bl_label = "Themes" bl_region_type = 'WINDOW' @@ -679,7 +680,7 @@ class USERPREF_PT_theme(bpy.types.Panel): self._theme_generic(split, getattr(theme, theme.theme_area.lower())) -class USERPREF_PT_file(bpy.types.Panel): +class USERPREF_PT_file(Panel): bl_space_type = 'USER_PREFERENCES' bl_label = "Files" bl_region_type = 'WINDOW' @@ -755,7 +756,7 @@ class USERPREF_PT_file(bpy.types.Panel): from bl_ui.space_userpref_keymap import InputKeyMapPanel -class USERPREF_MT_ndof_settings(bpy.types.Menu): +class USERPREF_MT_ndof_settings(Menu): # accessed from the window keybindings in C (only) bl_label = "3D Mouse Settings" @@ -780,7 +781,7 @@ class USERPREF_MT_ndof_settings(bpy.types.Menu): layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM') -class USERPREF_PT_input(bpy.types.Panel, InputKeyMapPanel): +class USERPREF_PT_input(Panel, InputKeyMapPanel): bl_space_type = 'USER_PREFERENCES' bl_label = "Input" @@ -870,7 +871,7 @@ class USERPREF_PT_input(bpy.types.Panel, InputKeyMapPanel): #print("runtime", time.time() - start) -class USERPREF_MT_addons_dev_guides(bpy.types.Menu): +class USERPREF_MT_addons_dev_guides(Menu): bl_label = "Development Guides" # menu to open webpages with addons development guides @@ -881,7 +882,7 @@ class USERPREF_MT_addons_dev_guides(bpy.types.Menu): layout.operator('wm.url_open', text='How to share your addon', icon='URL').url = 'http://wiki.blender.org/index.php/Dev:Py/Sharing' -class USERPREF_PT_addons(bpy.types.Panel): +class USERPREF_PT_addons(Panel): bl_space_type = 'USER_PREFERENCES' bl_label = "Addons" bl_region_type = 'WINDOW' @@ -1071,7 +1072,7 @@ class USERPREF_PT_addons(bpy.types.Panel): row.operator("wm.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False).module = module_name -class WM_OT_addon_enable(bpy.types.Operator): +class WM_OT_addon_enable(Operator): "Enable an addon" bl_idname = "wm.addon_enable" bl_label = "Enable Add-On" @@ -1100,7 +1101,7 @@ class WM_OT_addon_enable(bpy.types.Operator): return {'CANCELLED'} -class WM_OT_addon_disable(bpy.types.Operator): +class WM_OT_addon_disable(Operator): "Disable an addon" bl_idname = "wm.addon_disable" bl_label = "Disable Add-On" @@ -1112,7 +1113,7 @@ class WM_OT_addon_disable(bpy.types.Operator): return {'FINISHED'} -class WM_OT_addon_install(bpy.types.Operator): +class WM_OT_addon_install(Operator): "Install an addon" bl_idname = "wm.addon_install" bl_label = "Install Add-On..." @@ -1258,7 +1259,7 @@ class WM_OT_addon_install(bpy.types.Operator): return {'RUNNING_MODAL'} -class WM_OT_addon_remove(bpy.types.Operator): +class WM_OT_addon_remove(Operator): "Disable an addon" bl_idname = "wm.addon_remove" bl_label = "Remove Add-On" @@ -1306,7 +1307,7 @@ class WM_OT_addon_remove(bpy.types.Operator): return wm.invoke_props_dialog(self, width=600) -class WM_OT_addon_expand(bpy.types.Operator): +class WM_OT_addon_expand(Operator): "Display more information on this add-on" bl_idname = "wm.addon_expand" bl_label = "" diff --git a/release/scripts/startup/bl_ui/space_userpref_keymap.py b/release/scripts/startup/bl_ui/space_userpref_keymap.py index f63da6551de..d595b32c710 100644 --- a/release/scripts/startup/bl_ui/space_userpref_keymap.py +++ b/release/scripts/startup/bl_ui/space_userpref_keymap.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Menu, Operator import os @@ -124,7 +125,7 @@ def _merge_keymaps(kc1, kc2): return merged_keymaps -class USERPREF_MT_keyconfigs(bpy.types.Menu): +class USERPREF_MT_keyconfigs(Menu): bl_label = "KeyPresets" preset_subdir = "keyconfig" preset_operator = "wm.keyconfig_activate" @@ -135,7 +136,7 @@ class USERPREF_MT_keyconfigs(bpy.types.Menu): props.value = "context.window_manager.keyconfigs.default" # now draw the presets - bpy.types.Menu.draw_preset(self, context) + Menu.draw_preset(self, context) class InputKeyMapPanel: @@ -232,7 +233,7 @@ class InputKeyMapPanel: flow = box.column_flow(columns=2) for pname, value in properties.bl_rna.properties.items(): if pname != "rna_type" and not properties.is_property_hidden(pname): - if isinstance(value, bpy.types.OperatorProperties): + if isinstance(value, OperatorProperties): InputKeyMapPanel.draw_kmi_properties(box, value, title=pname) else: flow.prop(properties, pname) @@ -410,7 +411,7 @@ def export_properties(prefix, properties, lines=None): for pname in properties.bl_rna.properties.keys(): if pname != "rna_type" and not properties.is_property_hidden(pname): value = getattr(properties, pname) - if isinstance(value, bpy.types.OperatorProperties): + if isinstance(value, OperatorProperties): export_properties(prefix + "." + pname, value, lines) elif properties.is_property_set(pname): value = _string_value(value) @@ -419,7 +420,7 @@ def export_properties(prefix, properties, lines=None): return lines -class WM_OT_keyconfig_test(bpy.types.Operator): +class WM_OT_keyconfig_test(Operator): "Test keyconfig for conflicts" bl_idname = "wm.keyconfig_test" bl_label = "Test Key Configuration for Conflicts" @@ -527,7 +528,7 @@ def _string_value(value): return result -class WM_OT_keyconfig_import(bpy.types.Operator): +class WM_OT_keyconfig_import(Operator): "Import key configuration from a python script" bl_idname = "wm.keyconfig_import" bl_label = "Import Key Configuration..." @@ -574,7 +575,7 @@ class WM_OT_keyconfig_import(bpy.types.Operator): # This operator is also used by interaction presets saving - AddPresetBase -class WM_OT_keyconfig_export(bpy.types.Operator): +class WM_OT_keyconfig_export(Operator): "Export key configuration to a python script" bl_idname = "wm.keyconfig_export" bl_label = "Export Key Configuration..." @@ -667,7 +668,7 @@ class WM_OT_keyconfig_export(bpy.types.Operator): return {'RUNNING_MODAL'} -class WM_OT_keymap_restore(bpy.types.Operator): +class WM_OT_keymap_restore(Operator): "Restore key map(s)" bl_idname = "wm.keymap_restore" bl_label = "Restore Key Map(s)" @@ -687,7 +688,7 @@ class WM_OT_keymap_restore(bpy.types.Operator): return {'FINISHED'} -class WM_OT_keyitem_restore(bpy.types.Operator): +class WM_OT_keyitem_restore(Operator): "Restore key map item" bl_idname = "wm.keyitem_restore" bl_label = "Restore Key Map Item" @@ -709,7 +710,7 @@ class WM_OT_keyitem_restore(bpy.types.Operator): return {'FINISHED'} -class WM_OT_keyitem_add(bpy.types.Operator): +class WM_OT_keyitem_add(Operator): "Add key map item" bl_idname = "wm.keyitem_add" bl_label = "Add Key Map Item" @@ -731,7 +732,7 @@ class WM_OT_keyitem_add(bpy.types.Operator): return {'FINISHED'} -class WM_OT_keyitem_remove(bpy.types.Operator): +class WM_OT_keyitem_remove(Operator): "Remove key map item" bl_idname = "wm.keyitem_remove" bl_label = "Remove Key Map Item" @@ -749,7 +750,7 @@ class WM_OT_keyitem_remove(bpy.types.Operator): return {'FINISHED'} -class WM_OT_keyconfig_remove(bpy.types.Operator): +class WM_OT_keyconfig_remove(Operator): "Remove key config" bl_idname = "wm.keyconfig_remove" bl_label = "Remove Key Config" diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 78cd9587737..3272f0379f1 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -18,9 +18,10 @@ # <pep8 compliant> import bpy +from bpy.types import Header, Menu, Operator, Panel -class VIEW3D_HT_header(bpy.types.Header): +class VIEW3D_HT_header(Header): bl_space_type = 'VIEW_3D' def draw(self, context): @@ -128,7 +129,7 @@ class ShowHideMenu(): layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True -class VIEW3D_MT_transform(bpy.types.Menu): +class VIEW3D_MT_transform(Menu): bl_label = "Transform" # TODO: get rid of the custom text strings? @@ -180,7 +181,7 @@ class VIEW3D_MT_transform(bpy.types.Menu): layout.operator("object.align") -class VIEW3D_MT_mirror(bpy.types.Menu): +class VIEW3D_MT_mirror(Menu): bl_label = "Mirror" def draw(self, context): @@ -218,7 +219,7 @@ class VIEW3D_MT_mirror(bpy.types.Menu): layout.operator("object.vertex_group_mirror") -class VIEW3D_MT_snap(bpy.types.Menu): +class VIEW3D_MT_snap(Menu): bl_label = "Snap" def draw(self, context): @@ -235,7 +236,7 @@ class VIEW3D_MT_snap(bpy.types.Menu): layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active") -class VIEW3D_MT_uv_map(bpy.types.Menu): +class VIEW3D_MT_uv_map(Menu): bl_label = "UV Mapping" def draw(self, context): @@ -268,7 +269,7 @@ class VIEW3D_MT_uv_map(bpy.types.Menu): # ********** View menus ********** -class VIEW3D_MT_view(bpy.types.Menu): +class VIEW3D_MT_view(Menu): bl_label = "View" def draw(self, context): @@ -326,7 +327,7 @@ class VIEW3D_MT_view(bpy.types.Menu): layout.operator("screen.screen_full_area") -class VIEW3D_MT_view_navigation(bpy.types.Menu): +class VIEW3D_MT_view_navigation(Menu): bl_label = "Navigation" def draw(self, context): @@ -349,7 +350,7 @@ class VIEW3D_MT_view_navigation(bpy.types.Menu): layout.operator("view3d.fly") -class VIEW3D_MT_view_align(bpy.types.Menu): +class VIEW3D_MT_view_align(Menu): bl_label = "Align View" def draw(self, context): @@ -365,7 +366,7 @@ class VIEW3D_MT_view_align(bpy.types.Menu): layout.operator("view3d.view_center_cursor") -class VIEW3D_MT_view_align_selected(bpy.types.Menu): +class VIEW3D_MT_view_align_selected(Menu): bl_label = "Align View to Selected" def draw(self, context): @@ -391,7 +392,7 @@ class VIEW3D_MT_view_align_selected(bpy.types.Menu): props.type = 'LEFT' -class VIEW3D_MT_view_cameras(bpy.types.Menu): +class VIEW3D_MT_view_cameras(Menu): bl_label = "Cameras" def draw(self, context): @@ -403,7 +404,7 @@ class VIEW3D_MT_view_cameras(bpy.types.Menu): # ********** Select menus, suffix from context.mode ********** -class VIEW3D_MT_select_object(bpy.types.Menu): +class VIEW3D_MT_select_object(Menu): bl_label = "Select" def draw(self, context): @@ -429,7 +430,7 @@ class VIEW3D_MT_select_object(bpy.types.Menu): layout.operator("object.select_pattern", text="Select Pattern...") -class VIEW3D_MT_select_pose(bpy.types.Menu): +class VIEW3D_MT_select_pose(Menu): bl_label = "Select" def draw(self, context): @@ -466,7 +467,7 @@ class VIEW3D_MT_select_pose(bpy.types.Menu): layout.operator("object.select_pattern", text="Select Pattern...") -class VIEW3D_MT_select_particle(bpy.types.Menu): +class VIEW3D_MT_select_particle(Menu): bl_label = "Select" def draw(self, context): @@ -491,7 +492,7 @@ class VIEW3D_MT_select_particle(bpy.types.Menu): layout.operator("particle.select_tips", text="Tips") -class VIEW3D_MT_select_edit_mesh(bpy.types.Menu): +class VIEW3D_MT_select_edit_mesh(Menu): bl_label = "Select" def draw(self, context): @@ -542,7 +543,7 @@ class VIEW3D_MT_select_edit_mesh(bpy.types.Menu): layout.operator("mesh.region_to_loop") -class VIEW3D_MT_select_edit_curve(bpy.types.Menu): +class VIEW3D_MT_select_edit_curve(Menu): bl_label = "Select" def draw(self, context): @@ -571,7 +572,7 @@ class VIEW3D_MT_select_edit_curve(bpy.types.Menu): layout.operator("curve.select_less") -class VIEW3D_MT_select_edit_surface(bpy.types.Menu): +class VIEW3D_MT_select_edit_surface(Menu): bl_label = "Select" def draw(self, context): @@ -597,7 +598,7 @@ class VIEW3D_MT_select_edit_surface(bpy.types.Menu): layout.operator("curve.select_less") -class VIEW3D_MT_select_edit_metaball(bpy.types.Menu): +class VIEW3D_MT_select_edit_metaball(Menu): bl_label = "Select" def draw(self, context): @@ -615,7 +616,7 @@ class VIEW3D_MT_select_edit_metaball(bpy.types.Menu): layout.operator("mball.select_random_metaelems") -class VIEW3D_MT_select_edit_lattice(bpy.types.Menu): +class VIEW3D_MT_select_edit_lattice(Menu): bl_label = "Select" def draw(self, context): @@ -628,7 +629,7 @@ class VIEW3D_MT_select_edit_lattice(bpy.types.Menu): layout.operator("lattice.select_all", text="Select/Deselect All") -class VIEW3D_MT_select_edit_armature(bpy.types.Menu): +class VIEW3D_MT_select_edit_armature(Menu): bl_label = "Select" def draw(self, context): @@ -659,7 +660,7 @@ class VIEW3D_MT_select_edit_armature(bpy.types.Menu): layout.operator("object.select_pattern", text="Select Pattern...") -class VIEW3D_MT_select_face(bpy.types.Menu): # XXX no matching enum +class VIEW3D_MT_select_face(Menu): # XXX no matching enum bl_label = "Select" def draw(self, context): @@ -672,7 +673,7 @@ class VIEW3D_MT_select_face(bpy.types.Menu): # XXX no matching enum # ********** Object menu ********** -class VIEW3D_MT_object(bpy.types.Menu): +class VIEW3D_MT_object(Menu): bl_context = "objectmode" bl_label = "Object" @@ -730,7 +731,7 @@ class VIEW3D_MT_object(bpy.types.Menu): layout.operator_menu_enum("object.convert", "target") -class VIEW3D_MT_object_animation(bpy.types.Menu): +class VIEW3D_MT_object_animation(Menu): bl_label = "Animation" def draw(self, context): @@ -741,7 +742,7 @@ class VIEW3D_MT_object_animation(bpy.types.Menu): layout.operator("anim.keying_set_active_set", text="Change Keying Set...") -class VIEW3D_MT_object_clear(bpy.types.Menu): +class VIEW3D_MT_object_clear(Menu): bl_label = "Clear" def draw(self, context): @@ -753,7 +754,7 @@ class VIEW3D_MT_object_clear(bpy.types.Menu): layout.operator("object.origin_clear", text="Origin") -class VIEW3D_MT_object_specials(bpy.types.Menu): +class VIEW3D_MT_object_specials(Menu): bl_label = "Specials" @classmethod @@ -848,7 +849,7 @@ class VIEW3D_MT_object_specials(bpy.types.Menu): props = layout.operator("object.hide_render_clear_all") -class VIEW3D_MT_object_apply(bpy.types.Menu): +class VIEW3D_MT_object_apply(Menu): bl_label = "Apply" def draw(self, context): @@ -867,7 +868,7 @@ class VIEW3D_MT_object_apply(bpy.types.Menu): layout.operator("object.duplicates_make_real") -class VIEW3D_MT_object_parent(bpy.types.Menu): +class VIEW3D_MT_object_parent(Menu): bl_label = "Parent" def draw(self, context): @@ -877,7 +878,7 @@ class VIEW3D_MT_object_parent(bpy.types.Menu): layout.operator("object.parent_clear", text="Clear") -class VIEW3D_MT_object_track(bpy.types.Menu): +class VIEW3D_MT_object_track(Menu): bl_label = "Track" def draw(self, context): @@ -887,7 +888,7 @@ class VIEW3D_MT_object_track(bpy.types.Menu): layout.operator("object.track_clear", text="Clear") -class VIEW3D_MT_object_group(bpy.types.Menu): +class VIEW3D_MT_object_group(Menu): bl_label = "Group" def draw(self, context): @@ -902,7 +903,7 @@ class VIEW3D_MT_object_group(bpy.types.Menu): layout.operator("group.objects_remove_active") -class VIEW3D_MT_object_constraints(bpy.types.Menu): +class VIEW3D_MT_object_constraints(Menu): bl_label = "Constraints" def draw(self, context): @@ -913,7 +914,7 @@ class VIEW3D_MT_object_constraints(bpy.types.Menu): layout.operator("object.constraints_clear") -class VIEW3D_MT_object_showhide(bpy.types.Menu): +class VIEW3D_MT_object_showhide(Menu): bl_label = "Show/Hide" def draw(self, context): @@ -924,7 +925,7 @@ class VIEW3D_MT_object_showhide(bpy.types.Menu): layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True -class VIEW3D_MT_make_single_user(bpy.types.Menu): +class VIEW3D_MT_make_single_user(Menu): bl_label = "Make Single User" def draw(self, context): @@ -946,7 +947,7 @@ class VIEW3D_MT_make_single_user(bpy.types.Menu): props.animation = True -class VIEW3D_MT_make_links(bpy.types.Menu): +class VIEW3D_MT_make_links(Menu): bl_label = "Make Links" def draw(self, context): @@ -963,7 +964,7 @@ class VIEW3D_MT_make_links(bpy.types.Menu): layout.operator_enum("object.make_links_data", "type") # inline -class VIEW3D_MT_object_game(bpy.types.Menu): +class VIEW3D_MT_object_game(Menu): bl_label = "Game" def draw(self, context): @@ -985,7 +986,7 @@ class VIEW3D_MT_object_game(bpy.types.Menu): # ********** Vertex paint menu ********** -class VIEW3D_MT_paint_vertex(bpy.types.Menu): +class VIEW3D_MT_paint_vertex(Menu): bl_label = "Paint" def draw(self, context): @@ -1000,7 +1001,7 @@ class VIEW3D_MT_paint_vertex(bpy.types.Menu): layout.operator("paint.vertex_color_dirt") -class VIEW3D_MT_hook(bpy.types.Menu): +class VIEW3D_MT_hook(Menu): bl_label = "Hooks" def draw(self, context): @@ -1019,7 +1020,7 @@ class VIEW3D_MT_hook(bpy.types.Menu): layout.operator_menu_enum("object.hook_recenter", "modifier") -class VIEW3D_MT_vertex_group(bpy.types.Menu): +class VIEW3D_MT_vertex_group(Menu): bl_label = "Vertex Groups" def draw(self, context): @@ -1044,7 +1045,7 @@ class VIEW3D_MT_vertex_group(bpy.types.Menu): # ********** Weight paint menu ********** -class VIEW3D_MT_paint_weight(bpy.types.Menu): +class VIEW3D_MT_paint_weight(Menu): bl_label = "Weights" def draw(self, context): @@ -1074,7 +1075,7 @@ class VIEW3D_MT_paint_weight(bpy.types.Menu): # ********** Sculpt menu ********** -class VIEW3D_MT_sculpt(bpy.types.Menu): +class VIEW3D_MT_sculpt(Menu): bl_label = "Sculpt" def draw(self, context): @@ -1124,7 +1125,7 @@ class VIEW3D_MT_sculpt(bpy.types.Menu): # ********** Particle menu ********** -class VIEW3D_MT_particle(bpy.types.Menu): +class VIEW3D_MT_particle(Menu): bl_label = "Particle" def draw(self, context): @@ -1156,7 +1157,7 @@ class VIEW3D_MT_particle(bpy.types.Menu): layout.menu("VIEW3D_MT_particle_showhide") -class VIEW3D_MT_particle_specials(bpy.types.Menu): +class VIEW3D_MT_particle_specials(Menu): bl_label = "Specials" def draw(self, context): @@ -1174,13 +1175,13 @@ class VIEW3D_MT_particle_specials(bpy.types.Menu): layout.operator("particle.remove_doubles") -class VIEW3D_MT_particle_showhide(ShowHideMenu, bpy.types.Menu): +class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu): _operator_name = "particle" # ********** Pose Menu ********** -class VIEW3D_MT_pose(bpy.types.Menu): +class VIEW3D_MT_pose(Menu): bl_label = "Pose" def draw(self, context): @@ -1249,7 +1250,7 @@ class VIEW3D_MT_pose(bpy.types.Menu): layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings") -class VIEW3D_MT_pose_transform(bpy.types.Menu): +class VIEW3D_MT_pose_transform(Menu): bl_label = "Clear Transform" def draw(self, context): @@ -1264,7 +1265,7 @@ class VIEW3D_MT_pose_transform(bpy.types.Menu): layout.label(text="Origin") -class VIEW3D_MT_pose_slide(bpy.types.Menu): +class VIEW3D_MT_pose_slide(Menu): bl_label = "In-Betweens" def draw(self, context): @@ -1275,7 +1276,7 @@ class VIEW3D_MT_pose_slide(bpy.types.Menu): layout.operator("pose.breakdown") -class VIEW3D_MT_pose_propagate(bpy.types.Menu): +class VIEW3D_MT_pose_propagate(Menu): bl_label = "Propagate" def draw(self, context): @@ -1293,7 +1294,7 @@ class VIEW3D_MT_pose_propagate(bpy.types.Menu): layout.operator("pose.propagate", text="On Selected Markers").mode = 'SELECTED_MARKERS' -class VIEW3D_MT_pose_library(bpy.types.Menu): +class VIEW3D_MT_pose_library(Menu): bl_label = "Pose Library" def draw(self, context): @@ -1308,7 +1309,7 @@ class VIEW3D_MT_pose_library(bpy.types.Menu): layout.operator("poselib.pose_remove", text="Remove Pose...") -class VIEW3D_MT_pose_motion(bpy.types.Menu): +class VIEW3D_MT_pose_motion(Menu): bl_label = "Motion Paths" def draw(self, context): @@ -1318,7 +1319,7 @@ class VIEW3D_MT_pose_motion(bpy.types.Menu): layout.operator("pose.paths_clear", text="Clear") -class VIEW3D_MT_pose_group(bpy.types.Menu): +class VIEW3D_MT_pose_group(Menu): bl_label = "Bone Groups" def draw(self, context): @@ -1332,7 +1333,7 @@ class VIEW3D_MT_pose_group(bpy.types.Menu): layout.operator("pose.group_unassign") -class VIEW3D_MT_pose_ik(bpy.types.Menu): +class VIEW3D_MT_pose_ik(Menu): bl_label = "Inverse Kinematics" def draw(self, context): @@ -1342,7 +1343,7 @@ class VIEW3D_MT_pose_ik(bpy.types.Menu): layout.operator("pose.ik_clear") -class VIEW3D_MT_pose_constraints(bpy.types.Menu): +class VIEW3D_MT_pose_constraints(Menu): bl_label = "Constraints" def draw(self, context): @@ -1353,11 +1354,11 @@ class VIEW3D_MT_pose_constraints(bpy.types.Menu): layout.operator("pose.constraints_clear") -class VIEW3D_MT_pose_showhide(ShowHideMenu, bpy.types.Menu): +class VIEW3D_MT_pose_showhide(ShowHideMenu, Menu): _operator_name = "pose" -class VIEW3D_MT_pose_apply(bpy.types.Menu): +class VIEW3D_MT_pose_apply(Menu): bl_label = "Apply" def draw(self, context): @@ -1396,24 +1397,24 @@ class BoneOptions: props.type = self.type -class VIEW3D_MT_bone_options_toggle(bpy.types.Menu, BoneOptions): +class VIEW3D_MT_bone_options_toggle(Menu, BoneOptions): bl_label = "Toggle Bone Options" type = 'TOGGLE' -class VIEW3D_MT_bone_options_enable(bpy.types.Menu, BoneOptions): +class VIEW3D_MT_bone_options_enable(Menu, BoneOptions): bl_label = "Enable Bone Options" type = 'ENABLE' -class VIEW3D_MT_bone_options_disable(bpy.types.Menu, BoneOptions): +class VIEW3D_MT_bone_options_disable(Menu, BoneOptions): bl_label = "Disable Bone Options" type = 'DISABLE' # ********** Edit Menus, suffix from ob.type ********** -class VIEW3D_MT_edit_mesh(bpy.types.Menu): +class VIEW3D_MT_edit_mesh(Menu): bl_label = "Mesh" def draw(self, context): @@ -1460,7 +1461,7 @@ class VIEW3D_MT_edit_mesh(bpy.types.Menu): layout.menu("VIEW3D_MT_edit_mesh_showhide") -class VIEW3D_MT_edit_mesh_specials(bpy.types.Menu): +class VIEW3D_MT_edit_mesh_specials(Menu): bl_label = "Specials" def draw(self, context): @@ -1484,7 +1485,7 @@ class VIEW3D_MT_edit_mesh_specials(bpy.types.Menu): layout.operator("mesh.select_vertex_path") -class VIEW3D_MT_edit_mesh_select_mode(bpy.types.Menu): +class VIEW3D_MT_edit_mesh_select_mode(Menu): bl_label = "Mesh Select Mode" def draw(self, context): @@ -1505,7 +1506,7 @@ class VIEW3D_MT_edit_mesh_select_mode(bpy.types.Menu): prop.data_path = "tool_settings.mesh_select_mode" -class VIEW3D_MT_edit_mesh_extrude(bpy.types.Menu): +class VIEW3D_MT_edit_mesh_extrude(Menu): bl_label = "Extrude" _extrude_funcs = { \ @@ -1539,7 +1540,7 @@ class VIEW3D_MT_edit_mesh_extrude(bpy.types.Menu): self._extrude_funcs[menu_id](layout) -class VIEW3D_OT_edit_mesh_extrude_individual_move(bpy.types.Operator): +class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator): "Extrude individual elements and move" bl_label = "Extrude Individual and Move" bl_idname = "view3d.edit_mesh_extrude_individual_move" @@ -1568,7 +1569,7 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(bpy.types.Operator): return self.execute(context) -class VIEW3D_OT_edit_mesh_extrude_move(bpy.types.Operator): +class VIEW3D_OT_edit_mesh_extrude_move(Operator): "Extrude and move along normals" bl_label = "Extrude and Move on Normals" bl_idname = "view3d.edit_mesh_extrude_move_normal" @@ -1594,7 +1595,7 @@ class VIEW3D_OT_edit_mesh_extrude_move(bpy.types.Operator): return self.execute(context) -class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu): +class VIEW3D_MT_edit_mesh_vertices(Menu): bl_label = "Vertices" def draw(self, context): @@ -1626,7 +1627,7 @@ class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu): layout.menu("VIEW3D_MT_hook") -class VIEW3D_MT_edit_mesh_edges(bpy.types.Menu): +class VIEW3D_MT_edit_mesh_edges(Menu): bl_label = "Edges" def draw(self, context): @@ -1670,7 +1671,7 @@ class VIEW3D_MT_edit_mesh_edges(bpy.types.Menu): layout.operator("mesh.region_to_loop") -class VIEW3D_MT_edit_mesh_faces(bpy.types.Menu): +class VIEW3D_MT_edit_mesh_faces(Menu): bl_label = "Faces" bl_idname = "VIEW3D_MT_edit_mesh_faces" @@ -1718,7 +1719,7 @@ class VIEW3D_MT_edit_mesh_faces(bpy.types.Menu): layout.operator_menu_enum("mesh.colors_mirror", "axis") -class VIEW3D_MT_edit_mesh_normals(bpy.types.Menu): +class VIEW3D_MT_edit_mesh_normals(Menu): bl_label = "Normals" def draw(self, context): @@ -1732,7 +1733,7 @@ class VIEW3D_MT_edit_mesh_normals(bpy.types.Menu): layout.operator("mesh.flip_normals") -class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, bpy.types.Menu): +class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu): _operator_name = "mesh" # Edit Curve @@ -1772,13 +1773,13 @@ def draw_curve(self, context): layout.menu("VIEW3D_MT_edit_curve_showhide") -class VIEW3D_MT_edit_curve(bpy.types.Menu): +class VIEW3D_MT_edit_curve(Menu): bl_label = "Curve" draw = draw_curve -class VIEW3D_MT_edit_curve_ctrlpoints(bpy.types.Menu): +class VIEW3D_MT_edit_curve_ctrlpoints(Menu): bl_label = "Control Points" def draw(self, context): @@ -1800,7 +1801,7 @@ class VIEW3D_MT_edit_curve_ctrlpoints(bpy.types.Menu): layout.menu("VIEW3D_MT_hook") -class VIEW3D_MT_edit_curve_segments(bpy.types.Menu): +class VIEW3D_MT_edit_curve_segments(Menu): bl_label = "Segments" def draw(self, context): @@ -1810,7 +1811,7 @@ class VIEW3D_MT_edit_curve_segments(bpy.types.Menu): layout.operator("curve.switch_direction") -class VIEW3D_MT_edit_curve_specials(bpy.types.Menu): +class VIEW3D_MT_edit_curve_specials(Menu): bl_label = "Specials" def draw(self, context): @@ -1824,17 +1825,17 @@ class VIEW3D_MT_edit_curve_specials(bpy.types.Menu): layout.operator("curve.smooth_radius") -class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, bpy.types.Menu): +class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu): _operator_name = "curve" -class VIEW3D_MT_edit_surface(bpy.types.Menu): +class VIEW3D_MT_edit_surface(Menu): bl_label = "Surface" draw = draw_curve -class VIEW3D_MT_edit_font(bpy.types.Menu): +class VIEW3D_MT_edit_font(Menu): bl_label = "Text" def draw(self, context): @@ -1854,7 +1855,7 @@ class VIEW3D_MT_edit_font(bpy.types.Menu): layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS' -class VIEW3D_MT_edit_text_chars(bpy.types.Menu): +class VIEW3D_MT_edit_text_chars(Menu): bl_label = "Special Characters" def draw(self, context): @@ -1888,7 +1889,7 @@ class VIEW3D_MT_edit_text_chars(bpy.types.Menu): layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = b'\xC2\xA1'.decode() -class VIEW3D_MT_edit_meta(bpy.types.Menu): +class VIEW3D_MT_edit_meta(Menu): bl_label = "Metaball" def draw(self, context): @@ -1921,7 +1922,7 @@ class VIEW3D_MT_edit_meta(bpy.types.Menu): layout.menu("VIEW3D_MT_edit_meta_showhide") -class VIEW3D_MT_edit_meta_showhide(bpy.types.Menu): +class VIEW3D_MT_edit_meta_showhide(Menu): bl_label = "Show/Hide" def draw(self, context): @@ -1932,7 +1933,7 @@ class VIEW3D_MT_edit_meta_showhide(bpy.types.Menu): layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True -class VIEW3D_MT_edit_lattice(bpy.types.Menu): +class VIEW3D_MT_edit_lattice(Menu): bl_label = "Lattice" def draw(self, context): @@ -1954,7 +1955,7 @@ class VIEW3D_MT_edit_lattice(bpy.types.Menu): layout.prop_menu_enum(settings, "proportional_edit_falloff") -class VIEW3D_MT_edit_armature(bpy.types.Menu): +class VIEW3D_MT_edit_armature(Menu): bl_label = "Armature" def draw(self, context): @@ -2009,7 +2010,7 @@ class VIEW3D_MT_edit_armature(bpy.types.Menu): layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings") -class VIEW3D_MT_armature_specials(bpy.types.Menu): +class VIEW3D_MT_armature_specials(Menu): bl_label = "Specials" def draw(self, context): @@ -2029,7 +2030,7 @@ class VIEW3D_MT_armature_specials(bpy.types.Menu): layout.operator("armature.flip_names", text="Flip Names") -class VIEW3D_MT_edit_armature_parent(bpy.types.Menu): +class VIEW3D_MT_edit_armature_parent(Menu): bl_label = "Parent" def draw(self, context): @@ -2039,7 +2040,7 @@ class VIEW3D_MT_edit_armature_parent(bpy.types.Menu): layout.operator("armature.parent_clear", text="Clear") -class VIEW3D_MT_edit_armature_roll(bpy.types.Menu): +class VIEW3D_MT_edit_armature_roll(Menu): bl_label = "Bone Roll" def draw(self, context): @@ -2054,7 +2055,7 @@ class VIEW3D_MT_edit_armature_roll(bpy.types.Menu): # ********** Panel ********** -class VIEW3D_PT_view3d_properties(bpy.types.Panel): +class VIEW3D_PT_view3d_properties(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'UI' bl_label = "View" @@ -2095,7 +2096,7 @@ class VIEW3D_PT_view3d_properties(bpy.types.Panel): layout.column().prop(view, "cursor_location") -class VIEW3D_PT_view3d_name(bpy.types.Panel): +class VIEW3D_PT_view3d_name(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'UI' bl_label = "Item" @@ -2120,7 +2121,7 @@ class VIEW3D_PT_view3d_name(bpy.types.Panel): row.prop(bone, "name", text="") -class VIEW3D_PT_view3d_display(bpy.types.Panel): +class VIEW3D_PT_view3d_display(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'UI' bl_label = "Display" @@ -2192,7 +2193,7 @@ class VIEW3D_PT_view3d_display(bpy.types.Panel): row.prop(region, "use_box_clip") -class VIEW3D_PT_view3d_meshdisplay(bpy.types.Panel): +class VIEW3D_PT_view3d_meshdisplay(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'UI' bl_label = "Mesh Display" @@ -2229,7 +2230,7 @@ class VIEW3D_PT_view3d_meshdisplay(bpy.types.Panel): col.prop(mesh, "show_extra_face_area") -class VIEW3D_PT_view3d_curvedisplay(bpy.types.Panel): +class VIEW3D_PT_view3d_curvedisplay(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'UI' bl_label = "Curve Display" @@ -2251,7 +2252,7 @@ class VIEW3D_PT_view3d_curvedisplay(bpy.types.Panel): col.prop(context.scene.tool_settings, "normal_size", text="Normal Size") -class VIEW3D_PT_background_image(bpy.types.Panel): +class VIEW3D_PT_background_image(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'UI' bl_label = "Background Images" @@ -2304,7 +2305,7 @@ class VIEW3D_PT_background_image(bpy.types.Panel): row.prop(bg, "offset_y", text="Y") -class VIEW3D_PT_transform_orientations(bpy.types.Panel): +class VIEW3D_PT_transform_orientations(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'UI' bl_label = "Transform Orientations" @@ -2332,7 +2333,7 @@ class VIEW3D_PT_transform_orientations(bpy.types.Panel): col.operator("transform.delete_orientation", text="Delete") -class VIEW3D_PT_etch_a_ton(bpy.types.Panel): +class VIEW3D_PT_etch_a_ton(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'UI' bl_label = "Skeleton Sketching" @@ -2377,7 +2378,7 @@ class VIEW3D_PT_etch_a_ton(bpy.types.Panel): col.operator("sketch.convert", text="Convert") -class VIEW3D_PT_context_properties(bpy.types.Panel): +class VIEW3D_PT_context_properties(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'UI' bl_label = "Properties" diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 85dd6f7da5e..864d59f0cdb 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -18,6 +18,7 @@ # <pep8 compliant> import bpy +from bpy.types import Menu, Panel class View3DPanel(): @@ -61,7 +62,7 @@ def draw_gpencil_tools(context, layout): # ********** default tools for objectmode **************** -class VIEW3D_PT_tools_objectmode(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_objectmode(View3DPanel, Panel): bl_context = "objectmode" bl_label = "Object Tools" @@ -106,7 +107,7 @@ class VIEW3D_PT_tools_objectmode(View3DPanel, bpy.types.Panel): # ********** default tools for editmode_mesh **************** -class VIEW3D_PT_tools_meshedit(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_meshedit(View3DPanel, Panel): bl_context = "mesh_edit" bl_label = "Mesh Tools" @@ -165,7 +166,7 @@ class VIEW3D_PT_tools_meshedit(View3DPanel, bpy.types.Panel): draw_gpencil_tools(context, layout) -class VIEW3D_PT_tools_meshedit_options(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_meshedit_options(View3DPanel, Panel): bl_context = "mesh_edit" bl_label = "Mesh Options" @@ -191,7 +192,7 @@ class VIEW3D_PT_tools_meshedit_options(View3DPanel, bpy.types.Panel): # ********** default tools for editmode_curve **************** -class VIEW3D_PT_tools_curveedit(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_curveedit(View3DPanel, Panel): bl_context = "curve_edit" bl_label = "Curve Tools" @@ -237,7 +238,7 @@ class VIEW3D_PT_tools_curveedit(View3DPanel, bpy.types.Panel): # ********** default tools for editmode_surface **************** -class VIEW3D_PT_tools_surfaceedit(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_surfaceedit(View3DPanel, Panel): bl_context = "surface_edit" bl_label = "Surface Tools" @@ -269,7 +270,7 @@ class VIEW3D_PT_tools_surfaceedit(View3DPanel, bpy.types.Panel): # ********** default tools for editmode_text **************** -class VIEW3D_PT_tools_textedit(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_textedit(View3DPanel, Panel): bl_context = "text_edit" bl_label = "Text Tools" @@ -299,7 +300,7 @@ class VIEW3D_PT_tools_textedit(View3DPanel, bpy.types.Panel): # ********** default tools for editmode_armature **************** -class VIEW3D_PT_tools_armatureedit(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_armatureedit(View3DPanel, Panel): bl_context = "armature_edit" bl_label = "Armature Tools" @@ -328,7 +329,7 @@ class VIEW3D_PT_tools_armatureedit(View3DPanel, bpy.types.Panel): draw_gpencil_tools(context, layout) -class VIEW3D_PT_tools_armatureedit_options(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_armatureedit_options(View3DPanel, Panel): bl_context = "armature_edit" bl_label = "Armature Options" @@ -340,7 +341,7 @@ class VIEW3D_PT_tools_armatureedit_options(View3DPanel, bpy.types.Panel): # ********** default tools for editmode_mball **************** -class VIEW3D_PT_tools_mballedit(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_mballedit(View3DPanel, Panel): bl_context = "mball_edit" bl_label = "Meta Tools" @@ -360,7 +361,7 @@ class VIEW3D_PT_tools_mballedit(View3DPanel, bpy.types.Panel): # ********** default tools for editmode_lattice **************** -class VIEW3D_PT_tools_latticeedit(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_latticeedit(View3DPanel, Panel): bl_context = "lattice_edit" bl_label = "Lattice Tools" @@ -384,7 +385,7 @@ class VIEW3D_PT_tools_latticeedit(View3DPanel, bpy.types.Panel): # ********** default tools for posemode **************** -class VIEW3D_PT_tools_posemode(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_posemode(View3DPanel, Panel): bl_context = "posemode" bl_label = "Pose Tools" @@ -425,7 +426,7 @@ class VIEW3D_PT_tools_posemode(View3DPanel, bpy.types.Panel): draw_gpencil_tools(context, layout) -class VIEW3D_PT_tools_posemode_options(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_posemode_options(View3DPanel, Panel): bl_context = "posemode" bl_label = "Pose Options" @@ -459,7 +460,7 @@ class PaintPanel(): return None -class VIEW3D_PT_tools_brush(PaintPanel, bpy.types.Panel): +class VIEW3D_PT_tools_brush(PaintPanel, Panel): bl_label = "Brush" @classmethod @@ -677,7 +678,7 @@ class VIEW3D_PT_tools_brush(PaintPanel, bpy.types.Panel): #row.prop(brush, "use_pressure_jitter", toggle=True, text="") -class VIEW3D_PT_tools_brush_texture(PaintPanel, bpy.types.Panel): +class VIEW3D_PT_tools_brush_texture(PaintPanel, Panel): bl_label = "Texture" bl_options = {'DEFAULT_CLOSED'} @@ -775,7 +776,7 @@ class VIEW3D_PT_tools_brush_texture(PaintPanel, bpy.types.Panel): col.active = tex_slot.map_mode in {'FIXED', 'TILED'} and brush.use_texture_overlay -class VIEW3D_PT_tools_brush_tool(PaintPanel, bpy.types.Panel): +class VIEW3D_PT_tools_brush_tool(PaintPanel, Panel): bl_label = "Tool" bl_options = {'DEFAULT_CLOSED'} @@ -809,7 +810,7 @@ class VIEW3D_PT_tools_brush_tool(PaintPanel, bpy.types.Panel): row.prop(brush, "use_paint_image", text="", icon='TPAINT_HLT') -class VIEW3D_PT_tools_brush_stroke(PaintPanel, bpy.types.Panel): +class VIEW3D_PT_tools_brush_stroke(PaintPanel, Panel): bl_label = "Stroke" bl_options = {'DEFAULT_CLOSED'} @@ -907,7 +908,7 @@ class VIEW3D_PT_tools_brush_stroke(PaintPanel, bpy.types.Panel): # row.prop(brush, "use_pressure_spacing", toggle=True, text="") -class VIEW3D_PT_tools_brush_curve(PaintPanel, bpy.types.Panel): +class VIEW3D_PT_tools_brush_curve(PaintPanel, Panel): bl_label = "Curve" bl_options = {'DEFAULT_CLOSED'} @@ -934,7 +935,7 @@ class VIEW3D_PT_tools_brush_curve(PaintPanel, bpy.types.Panel): row.operator("brush.curve_preset", icon="NOCURVE", text="").shape = 'MAX' -class VIEW3D_PT_sculpt_options(PaintPanel, bpy.types.Panel): +class VIEW3D_PT_sculpt_options(PaintPanel, Panel): bl_label = "Options" bl_options = {'DEFAULT_CLOSED'} @@ -964,7 +965,7 @@ class VIEW3D_PT_sculpt_options(PaintPanel, bpy.types.Panel): layout.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength") -class VIEW3D_PT_sculpt_symmetry(PaintPanel, bpy.types.Panel): +class VIEW3D_PT_sculpt_symmetry(PaintPanel, Panel): bl_label = "Symmetry" bl_options = {'DEFAULT_CLOSED'} @@ -992,7 +993,7 @@ class VIEW3D_PT_sculpt_symmetry(PaintPanel, bpy.types.Panel): layout.prop(sculpt, "use_symmetry_feather", text="Feather") -class VIEW3D_PT_tools_brush_appearance(PaintPanel, bpy.types.Panel): +class VIEW3D_PT_tools_brush_appearance(PaintPanel, Panel): bl_label = "Appearance" bl_options = {'DEFAULT_CLOSED'} @@ -1038,7 +1039,7 @@ class VIEW3D_PT_tools_brush_appearance(PaintPanel, bpy.types.Panel): # ********** default tools for weightpaint **************** -class VIEW3D_PT_tools_weightpaint(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel): bl_context = "weightpaint" bl_label = "Weight Tools" @@ -1056,7 +1057,7 @@ class VIEW3D_PT_tools_weightpaint(View3DPanel, bpy.types.Panel): col.operator("object.vertex_group_levels", text="Levels") -class VIEW3D_PT_tools_weightpaint_options(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_weightpaint_options(View3DPanel, Panel): bl_context = "weightpaint" bl_label = "Options" @@ -1093,7 +1094,7 @@ class VIEW3D_PT_tools_weightpaint_options(View3DPanel, bpy.types.Panel): # ********** default tools for vertexpaint **************** -class VIEW3D_PT_tools_vertexpaint(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_vertexpaint(View3DPanel, Panel): bl_context = "vertexpaint" bl_label = "Options" @@ -1122,7 +1123,7 @@ class VIEW3D_PT_tools_vertexpaint(View3DPanel, bpy.types.Panel): # ********** default tools for texturepaint **************** -class VIEW3D_PT_tools_projectpaint(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_projectpaint(View3DPanel, Panel): bl_context = "imagepaint" bl_label = "Project Paint" @@ -1214,7 +1215,7 @@ class VIEW3D_PT_imagepaint_options(PaintPanel): col.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength") -class VIEW3D_MT_tools_projectpaint_clone(bpy.types.Menu): +class VIEW3D_MT_tools_projectpaint_clone(Menu): bl_label = "Clone Layer" def draw(self, context): @@ -1225,7 +1226,7 @@ class VIEW3D_MT_tools_projectpaint_clone(bpy.types.Menu): prop.value = i -class VIEW3D_MT_tools_projectpaint_stencil(bpy.types.Menu): +class VIEW3D_MT_tools_projectpaint_stencil(Menu): bl_label = "Mask Layer" def draw(self, context): @@ -1236,7 +1237,7 @@ class VIEW3D_MT_tools_projectpaint_stencil(bpy.types.Menu): prop.value = i -class VIEW3D_PT_tools_particlemode(View3DPanel, bpy.types.Panel): +class VIEW3D_PT_tools_particlemode(View3DPanel, Panel): '''default tools for particle mode''' bl_context = "particlemode" bl_label = "Options" diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index bac5bd7d4e4..fae7e1492a2 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -607,7 +607,7 @@ void weight_to_rgb(float input, float *fr, float *fg, float *fb); typedef struct DMVertexAttribs { struct { struct MTFace *array; - int emOffset, glIndex; + int emOffset, glIndex, glTexco; } tface[MAX_MTFACE]; struct { @@ -622,7 +622,7 @@ typedef struct DMVertexAttribs { struct { float (*array)[3]; - int emOffset, glIndex; + int emOffset, glIndex, glTexco; } orco; int tottface, totmcol, tottang, totorco; diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index e8dd6b8ac26..ac6529dc875 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -53,7 +53,7 @@ extern "C" { /* can be left blank, otherwise a,b,c... etc with no quotes */ #define BLENDER_VERSION_CHAR /* alpha/beta/rc/release, docs use this */ -#define BLENDER_VERSION_CYCLE release +#define BLENDER_VERSION_CYCLE alpha struct ListBase; struct MemFile; diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 513ee68a101..9bd07e2639e 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -102,6 +102,7 @@ typedef enum { typedef void (*ObjectWalkFunc)(void *userData, struct Object *ob, struct Object **obpoin); typedef void (*IDWalkFunc)(void *userData, struct Object *ob, struct ID **idpoin); +typedef void (*TexWalkFunc)(void *userData, struct Object *ob, struct ModifierData *md, const char *propname); typedef struct ModifierTypeInfo { /* The user visible name for this modifier */ @@ -285,6 +286,16 @@ typedef struct ModifierTypeInfo { */ void (*foreachIDLink)(struct ModifierData *md, struct Object *ob, IDWalkFunc walk, void *userData); + + /* Should call the given walk function for each texture that the + * modifier data stores. This is used for finding all textures in + * the context for the UI. + * + * This function is optional. If it is not present, it will be + * assumed the modifier has no textures. + */ + void (*foreachTexLink)(struct ModifierData *md, struct Object *ob, + TexWalkFunc walk, void *userData); } ModifierTypeInfo; ModifierTypeInfo *modifierType_getInfo (ModifierType type); @@ -316,6 +327,10 @@ void modifiers_foreachObjectLink(struct Object *ob, void modifiers_foreachIDLink(struct Object *ob, IDWalkFunc walk, void *userData); +void modifiers_foreachTexLink(struct Object *ob, + TexWalkFunc walk, + void *userData); + struct ModifierData *modifiers_findByType(struct Object *ob, ModifierType type); struct ModifierData *modifiers_findByName(struct Object *ob, const char *name); void modifiers_clearErrors(struct Object *ob); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index c53cc458ccd..c463e43eef8 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2165,6 +2165,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, attribs->tface[a].array = NULL; attribs->tface[a].emOffset = pdata->layers[layer].offset; attribs->tface[a].glIndex = gattribs->layer[b].glindex; + attribs->tface[a].glTexco = gattribs->layer[b].gltexco; } }*/ @@ -2207,6 +2208,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, attribs->orco.array = vdata->layers[layer].data; attribs->orco.emOffset = vdata->layers[layer].offset; attribs->orco.glIndex = gattribs->layer[b].glindex; + attribs->orco.glTexco = gattribs->layer[b].gltexco; } } } diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index fef186fee9a..e517f4ae7b1 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1026,6 +1026,52 @@ static void cdDM_drawMappedFacesTex(DerivedMesh *dm, int (*setDrawOptions)(void cdDM_drawFacesTex_common(dm, NULL, setDrawOptions, userData); } + +static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int a, int index, int vert, int smoothnormal) +{ + int b; + + /* orco texture coordinates */ + if(attribs->totorco) { + if(attribs->orco.glTexco) + glTexCoord3fv(attribs->orco.array[index]); + else + glVertexAttrib3fvARB(attribs->orco.glIndex, attribs->orco.array[index]); + } + + /* uv texture coordinates */ + for(b = 0; b < attribs->tottface; b++) { + MTFace *tf = &attribs->tface[b].array[a]; + + if(attribs->tface[b].glTexco) + glTexCoord2fv(tf->uv[vert]); + else + glVertexAttrib2fvARB(attribs->tface[b].glIndex, tf->uv[vert]); + } + + /* vertex colors */ + for(b = 0; b < attribs->totmcol; b++) { + MCol *cp = &attribs->mcol[b].array[a*4 + vert]; + GLubyte col[4]; + col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; + glVertexAttrib4ubvARB(attribs->mcol[b].glIndex, col); + } + + /* tangent for normal mapping */ + if(attribs->tottang) { + float *tang = attribs->tang.array[a*4 + vert]; + glVertexAttrib4fvARB(attribs->tang.glIndex, tang); + } + + /* vertex normal */ + if(smoothnormal) + glNormal3sv(mvert[index].no); + + /* vertex coordinate */ + glVertex3fv(mvert[index].co); +} + + static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, void *attribs), int (*setDrawOptions)(void *userData, int index), void *userData) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; @@ -1116,35 +1162,13 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo } } -#define PASSVERT(index, vert) { \ - if(attribs.totorco) \ - glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]); \ - for(b = 0; b < attribs.tottface; b++) { \ - MTFace *tf = &attribs.tface[b].array[a]; \ - glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \ - } \ - for(b = 0; b < attribs.totmcol; b++) { \ - MCol *cp = &attribs.mcol[b].array[a*4 + vert]; \ - GLubyte col[4]; \ - col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; \ - glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col); \ - } \ - if(attribs.tottang) { \ - float *tang = attribs.tang.array[a*4 + vert]; \ - glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \ - } \ - if(smoothnormal) \ - glNormal3sv(mvert[index].no); \ - glVertex3fv(mvert[index].co); \ - } - - PASSVERT(mface->v1, 0); - PASSVERT(mface->v2, 1); - PASSVERT(mface->v3, 2); + cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v1, 0, smoothnormal); + cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v2, 1, smoothnormal); + cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v3, 2, smoothnormal); if(mface->v4) - PASSVERT(mface->v4, 3) + cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v4, 3, smoothnormal); else - PASSVERT(mface->v3, 2) + cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v3, 2, smoothnormal); } glEnd(); diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 51f1cd61e7c..fe26c0ccd2d 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -195,6 +195,18 @@ void modifiers_foreachIDLink(Object *ob, IDWalkFunc walk, void *userData) } } +void modifiers_foreachTexLink(Object *ob, TexWalkFunc walk, void *userData) +{ + ModifierData *md = ob->modifiers.first; + + for (; md; md=md->next) { + ModifierTypeInfo *mti = modifierType_getInfo(md->type); + + if(mti->foreachTexLink) + mti->foreachTexLink(md, ob, walk, userData); + } +} + void modifier_copyData(ModifierData *md, ModifierData *target) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index b89e576a562..a9792bc44fa 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -136,7 +136,7 @@ static struct bUnitDef buImperialLenDef[] = { {"yard", "yards", "yd", NULL, "Yards", UN_SC_YD, 0.0, B_UNIT_DEF_NONE}, {"foot", "feet", "'", "ft", "Feet", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {"inch", "inches", "\"", "in", "Inches", UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, - {"thou", "thous", "mil", NULL, "Thous", UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, + {"thou", "thou", "thou", "mil", "Thou", UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, /* plural for thou has no 's' */ {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; static struct bUnitCollection buImperialLenCollecton = {buImperialLenDef, 4, 0, sizeof(buImperialLenDef)/sizeof(bUnitDef)}; diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index dcc71fa1258..e4afc6ad79b 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -53,14 +53,14 @@ typedef void (*GHashValFreeFP) (void *val); typedef struct Entry { struct Entry *next; - + void *key, *val; } Entry; typedef struct GHash { GHashHashFP hashfp; GHashCmpFP cmpfp; - + Entry **buckets; struct BLI_mempool *entrypool; int nbuckets, nentries, cursize; @@ -72,15 +72,15 @@ typedef struct GHashIterator { struct Entry *curEntry; } GHashIterator; -GHash* BLI_ghash_new (GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info); -void BLI_ghash_free (GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); - -//BM_INLINE void BLI_ghash_insert (GHash *gh, void *key, void *val); -//BM_INLINE int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); -//BM_INLINE void* BLI_ghash_lookup (GHash *gh, void *key); -//BM_INLINE int BLI_ghash_haskey (GHash *gh, void *key); +/* *** */ -int BLI_ghash_size (GHash *gh); +GHash* BLI_ghash_new (GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info); +void BLI_ghash_free (GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); +void BLI_ghash_insert(GHash *gh, void *key, void *val); +void * BLI_ghash_lookup(GHash *gh, const void *key); +int BLI_ghash_remove(GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); +int BLI_ghash_haskey(GHash *gh, void *key); +int BLI_ghash_size (GHash *gh); /* *** */ @@ -149,127 +149,10 @@ unsigned int BLI_ghashutil_strhash (const void *key); int BLI_ghashutil_strcmp (const void *a, const void *b); unsigned int BLI_ghashutil_inthash (const void *ptr); -int BLI_ghashutil_intcmp(const void *a, const void *b); - -/*begin of macro-inlined functions*/ -extern unsigned int hashsizes[]; - -#if 0 -#define BLI_ghash_insert(gh, _k, _v){\ - unsigned int _hash= (gh)->hashfp(_k)%gh->nbuckets;\ - Entry *_e= BLI_mempool_alloc((gh)->entrypool);\ - _e->key= _k;\ - _e->val= _v;\ - _e->next= (gh)->buckets[_hash];\ - (gh)->buckets[_hash]= _e;\ - if (++(gh)->nentries>(gh)->nbuckets*3) {\ - Entry *_e, **_old= (gh)->buckets;\ - int _i, _nold= (gh)->nbuckets;\ - (gh)->nbuckets= hashsizes[++(gh)->cursize];\ - (gh)->buckets= malloc((gh)->nbuckets*sizeof(*(gh)->buckets));\ - memset((gh)->buckets, 0, (gh)->nbuckets*sizeof(*(gh)->buckets));\ - for (_i=0; _i<_nold; _i++) {\ - for (_e= _old[_i]; _e;) {\ - Entry *_n= _e->next;\ - _hash= (gh)->hashfp(_e->key)%(gh)->nbuckets;\ - _e->next= (gh)->buckets[_hash];\ - (gh)->buckets[_hash]= _e;\ - _e= _n;\ - }\ - }\ - free(_old); } } -#endif - -/*---------inlined functions---------*/ -BM_INLINE void BLI_ghash_insert(GHash *gh, void *key, void *val) { - unsigned int hash= gh->hashfp(key)%gh->nbuckets; - Entry *e= (Entry*) BLI_mempool_alloc(gh->entrypool); - - e->key= key; - e->val= val; - e->next= gh->buckets[hash]; - gh->buckets[hash]= e; - - if (++gh->nentries>(float)gh->nbuckets/2) { - Entry **old= gh->buckets; - int i, nold= gh->nbuckets; - - gh->nbuckets= hashsizes[++gh->cursize]; - gh->buckets= (Entry**)MEM_mallocN(gh->nbuckets*sizeof(*gh->buckets), "buckets"); - memset(gh->buckets, 0, gh->nbuckets*sizeof(*gh->buckets)); - - for (i=0; i<nold; i++) { - for (e= old[i]; e;) { - Entry *n= e->next; - - hash= gh->hashfp(e->key)%gh->nbuckets; - e->next= gh->buckets[hash]; - gh->buckets[hash]= e; - - e= n; - } - } - - MEM_freeN(old); - } -} - -BM_INLINE void* BLI_ghash_lookup(GHash *gh, const void *key) -{ - if(gh) { - unsigned int hash= gh->hashfp(key)%gh->nbuckets; - Entry *e; - - for (e= gh->buckets[hash]; e; e= e->next) - if (gh->cmpfp(key, e->key)==0) - return e->val; - } - return NULL; -} - -BM_INLINE int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp) -{ - unsigned int hash= gh->hashfp(key)%gh->nbuckets; - Entry *e; - Entry *p = NULL; - - for (e= gh->buckets[hash]; e; e= e->next) { - if (gh->cmpfp(key, e->key)==0) { - Entry *n= e->next; - - if (keyfreefp) keyfreefp(e->key); - if (valfreefp) valfreefp(e->val); - BLI_mempool_free(gh->entrypool, e); - - - e= n; - if (p) - p->next = n; - else - gh->buckets[hash] = n; - - --gh->nentries; - return 1; - } - p = e; - } - - return 0; -} - -BM_INLINE int BLI_ghash_haskey(GHash *gh, void *key) { - unsigned int hash= gh->hashfp(key)%gh->nbuckets; - Entry *e; - - for (e= gh->buckets[hash]; e; e= e->next) - if (gh->cmpfp(key, e->key)==0) - return 1; - - return 0; -} +int BLI_ghashutil_intcmp (const void *a, const void *b); #ifdef __cplusplus } #endif -#endif +#endif /* BLI_GHASH_H */ diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 0c9d6230f1e..432ba7c59cf 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -49,8 +49,6 @@ unsigned int hashsizes[]= { /***/ -/***/ - GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) { GHash *gh= MEM_mallocN(sizeof(*gh), info); gh->hashfp= hashfp; @@ -67,14 +65,96 @@ GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) { return gh; } -#ifdef BLI_ghash_insert -#undef BLI_ghash_insert -#endif - int BLI_ghash_size(GHash *gh) { return gh->nentries; } +void BLI_ghash_insert(GHash *gh, void *key, void *val) { + unsigned int hash= gh->hashfp(key)%gh->nbuckets; + Entry *e= (Entry*) BLI_mempool_alloc(gh->entrypool); + + e->key= key; + e->val= val; + e->next= gh->buckets[hash]; + gh->buckets[hash]= e; + + if (++gh->nentries>(float)gh->nbuckets/2) { + Entry **old= gh->buckets; + int i, nold= gh->nbuckets; + + gh->nbuckets= hashsizes[++gh->cursize]; + gh->buckets= (Entry**)MEM_mallocN(gh->nbuckets*sizeof(*gh->buckets), "buckets"); + memset(gh->buckets, 0, gh->nbuckets*sizeof(*gh->buckets)); + + for (i=0; i<nold; i++) { + for (e= old[i]; e;) { + Entry *n= e->next; + + hash= gh->hashfp(e->key)%gh->nbuckets; + e->next= gh->buckets[hash]; + gh->buckets[hash]= e; + + e= n; + } + } + + MEM_freeN(old); + } +} + +void *BLI_ghash_lookup(GHash *gh, const void *key) { + if(gh) { + unsigned int hash= gh->hashfp(key)%gh->nbuckets; + Entry *e; + + for (e= gh->buckets[hash]; e; e= e->next) + if (gh->cmpfp(key, e->key)==0) + return e->val; + } + return NULL; +} + +int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp) +{ + unsigned int hash= gh->hashfp(key)%gh->nbuckets; + Entry *e; + Entry *p = NULL; + + for (e= gh->buckets[hash]; e; e= e->next) { + if (gh->cmpfp(key, e->key)==0) { + Entry *n= e->next; + + if (keyfreefp) keyfreefp(e->key); + if (valfreefp) valfreefp(e->val); + BLI_mempool_free(gh->entrypool, e); + + + e= n; + if (p) + p->next = n; + else + gh->buckets[hash] = n; + + --gh->nentries; + return 1; + } + p = e; + } + + return 0; +} + +int BLI_ghash_haskey(GHash *gh, void *key) { + unsigned int hash= gh->hashfp(key)%gh->nbuckets; + Entry *e; + + for (e= gh->buckets[hash]; e; e= e->next) + if (gh->cmpfp(key, e->key)==0) + return 1; + + return 0; +} + void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp) { int i; diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 91fd7531c7a..7056c57c4c9 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1614,7 +1614,12 @@ static int gpencil_area_exists(bContext *C, ScrArea *satest) static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) { tGPsdata *p= op->customdata; - int estate = OPERATOR_PASS_THROUGH; /* default exit state - not handled, so let others have a share of the pie */ + //int estate = OPERATOR_PASS_THROUGH; /* default exit state - not handled, so let others have a share of the pie */ + /* currently, grease pencil conflicts with such operators as undo and set object mode + which makes behavior of operator totally unpredictable and crash for some cases. + the only way to solve this proper is to ger rid of pointers to data which can + chage stored in operator custom data (sergey) */ + int estate = OPERATOR_RUNNING_MODAL; // if (event->type == NDOF_MOTION) // return OPERATOR_PASS_THROUGH; diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index dfa457c22de..cc4dd6330fb 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -33,12 +33,14 @@ #ifndef ED_NODE_H #define ED_NODE_H +struct ID; +struct Main; struct Material; struct Scene; struct Tex; struct bContext; struct bNode; -struct ID; +struct bNodeTree; struct ScrArea; /* drawnode.c */ @@ -55,6 +57,8 @@ void ED_node_texture_default(struct Tex *tex); void ED_node_link_intersect_test(struct ScrArea *sa, int test); void ED_node_link_insert(struct ScrArea *sa); +void ED_node_set_active(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node); + /* node ops.c */ void ED_operatormacros_node(void); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 6384d91955f..2faac24fd78 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -39,6 +39,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BLI_ghash.h" #include "BKE_animsys.h" #include "BKE_colortools.h" @@ -2322,10 +2323,11 @@ static void operator_call_cb(bContext *C, void *UNUSED(arg1), void *arg2) static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items) { - wmOperatorType *ot = WM_operatortype_first(); - - for(; ot; ot= ot->next) { - + GHashIterator *iter= WM_operatortype_iter(); + + for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + wmOperatorType *ot= BLI_ghashIterator_getValue(iter); + if(BLI_strcasestr(ot->name, str)) { if(WM_operator_poll((bContext*)C, ot)) { char name[256]; @@ -2345,6 +2347,7 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char } } } + BLI_ghashIterator_free(iter); } void uiTemplateOperatorSearch(uiLayout *layout) diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index d3b3f601445..6689991bfef 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -182,7 +182,7 @@ void ED_object_add_generic_props(wmOperatorType *ot, int do_editmode) } RNA_def_float_vector_xyz(ot->srna, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "Location for the newly added object", -FLT_MAX, FLT_MAX); - RNA_def_float_rotation(ot->srna, "rotation", 3, NULL, -FLT_MAX, FLT_MAX, "Rotation", "Rotation for the newly added object", -FLT_MAX, FLT_MAX); + RNA_def_float_rotation(ot->srna, "rotation", 3, NULL, -FLT_MAX, FLT_MAX, "Rotation", "Rotation for the newly added object", -M_PI * 2.0f, M_PI * 2.0f); prop = RNA_def_boolean_layer_member(ot->srna, "layers", 20, NULL, "Layer", ""); RNA_def_property_flag(prop, PROP_HIDDEN); diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index fcf049023a7..39a10ba3963 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -247,7 +247,7 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op, } /* tag for updates */ - ob->recalc |= OB_RECALC_OB; + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } } CTX_DATA_END; @@ -342,7 +342,8 @@ static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op)) negate_v3_v3(v3, v1); mul_m3_v3(mat, v3); } - ob->recalc |= OB_RECALC_OB; + + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } CTX_DATA_END; @@ -872,7 +873,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) (ob->dup_group==ob_other->dup_group && (ob->transflag|ob_other->transflag) & OB_DUPLIGROUP) ) ) { ob_other->flag |= OB_DONE; - ob_other->recalc= OB_RECALC_OB|OB_RECALC_DATA; + DAG_id_tag_update(&ob_other->id, OB_RECALC_OB|OB_RECALC_DATA); copy_v3_v3(centn, cent); mul_mat3_m4_v3(ob_other->obmat, centn); /* ommit translation part */ @@ -891,11 +892,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - for (tob= bmain->object.first; tob; tob= tob->id.next) { - if(tob->data && (((ID *)tob->data)->flag & LIB_DOIT)) { - tob->recalc= OB_RECALC_OB|OB_RECALC_DATA; - } - } + for (tob= bmain->object.first; tob; tob= tob->id.next) + if(tob->data && (((ID *)tob->data)->flag & LIB_DOIT)) + DAG_id_tag_update(&tob->id, OB_RECALC_OB|OB_RECALC_DATA); if (tot_change) { DAG_ids_flush_update(bmain, 0); diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index 98f42fe97c1..b6fb60ac4f7 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -24,7 +24,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/render/render_shading.c +/** \file blender/editors/render/render_update.c * \ingroup edrend */ diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 3effea296d7..4707baa279b 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -675,7 +675,12 @@ static int scrollback_append_exec(bContext *C, wmOperator *op) console_scrollback_limit(sc); - console_textview_update_rect(sc, ar); + /* 'ar' can be null depending on the operator that runs + * rendering with invoke default for eg causes this */ + if(ar) { + console_textview_update_rect(sc, ar); + } + ED_area_tag_redraw(CTX_wm_area(C)); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index c719f749582..984e944321e 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -479,72 +479,88 @@ static void snode_tag_changed(SpaceNode *snode, bNode *node) NodeTagIDChanged(snode->nodetree, gnode->id); } -void node_set_active(SpaceNode *snode, bNode *node) +static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup) { - nodeSetActive(snode->edittree, node); + bNode *node; + + if(ntree == lookup) + return 1; + + for(node=ntree->nodes.first; node; node=node->next) + if(node->type == NODE_GROUP && node->id) + if(has_nodetree((bNodeTree*)node->id, lookup)) + return 1; + + return 0; +} + +void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) +{ + nodeSetActive(ntree, node); if(node->type!=NODE_GROUP) { int was_output= (node->flag & NODE_DO_OUTPUT); /* tree specific activate calls */ - if(snode->treetype==NTREE_SHADER) { + if(ntree->type==NTREE_SHADER) { /* when we select a material, active texture is cleared, for buttons */ if(node->id && GS(node->id->name)==ID_MA) - nodeClearActiveID(snode->edittree, ID_TE); + nodeClearActiveID(ntree, ID_TE); if(node->type==SH_NODE_OUTPUT) { bNode *tnode; - for(tnode= snode->edittree->nodes.first; tnode; tnode= tnode->next) + for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) if( tnode->type==SH_NODE_OUTPUT) tnode->flag &= ~NODE_DO_OUTPUT; node->flag |= NODE_DO_OUTPUT; if(was_output==0) - ED_node_changed_update(snode->id, node); + ED_node_generic_update(bmain, ntree, node); } WM_main_add_notifier(NC_MATERIAL|ND_NODES, node->id); } - else if(snode->treetype==NTREE_COMPOSIT) { - Scene *scene= (Scene*)snode->id; - + else if(ntree->type==NTREE_COMPOSIT) { /* make active viewer, currently only 1 supported... */ if( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { bNode *tnode; - for(tnode= snode->edittree->nodes.first; tnode; tnode= tnode->next) + for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) if( ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) tnode->flag &= ~NODE_DO_OUTPUT; node->flag |= NODE_DO_OUTPUT; - if(was_output==0) { - snode_tag_changed(snode, node); - - ED_node_changed_update(snode->id, node); - } + if(was_output==0) + ED_node_generic_update(bmain, ntree, node); /* addnode() doesnt link this yet... */ node->id= (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); } else if(node->type==CMP_NODE_R_LAYERS) { - if(node->id==NULL || node->id==(ID *)scene) { - scene->r.actlay= node->custom1; + Scene *scene; + + for(scene=bmain->scene.first; scene; scene=scene->id.next) { + if(scene->nodetree && scene->use_nodes && has_nodetree(scene->nodetree, ntree)) { + if(node->id==NULL || node->id==(ID *)scene) { + scene->r.actlay= node->custom1; + } + } } } else if(node->type==CMP_NODE_COMPOSITE) { bNode *tnode; - for(tnode= snode->edittree->nodes.first; tnode; tnode= tnode->next) + for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) if( tnode->type==CMP_NODE_COMPOSITE) tnode->flag &= ~NODE_DO_OUTPUT; node->flag |= NODE_DO_OUTPUT; - ED_node_changed_update(snode->id, node); + ED_node_generic_update(bmain, ntree, node); } } - else if(snode->treetype==NTREE_TEXTURE) { + else if(ntree->type==NTREE_TEXTURE) { // XXX #if 0 if(node->id) @@ -1940,7 +1956,7 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) } /* can be called from menus too, but they should do own undopush and redraws */ -bNode *node_add_node(SpaceNode *snode, Scene *scene, int type, float locx, float locy) +bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, int type, float locx, float locy) { bNode *node= NULL, *gnode; @@ -1955,7 +1971,7 @@ bNode *node_add_node(SpaceNode *snode, Scene *scene, int type, float locx, float return NULL; } else { - bNodeTree *ngroup= BLI_findlink(&G.main->nodetree, type-NODE_GROUP_MENU); + bNodeTree *ngroup= BLI_findlink(&bmain->nodetree, type-NODE_GROUP_MENU); if(ngroup) node= nodeAddNodeType(snode->edittree, NODE_GROUP, ngroup, NULL); } @@ -1976,7 +1992,7 @@ bNode *node_add_node(SpaceNode *snode, Scene *scene, int type, float locx, float } node_tree_verify_groups(snode->nodetree); - node_set_active(snode, node); + ED_node_set_active(bmain, snode->edittree, node); if(snode->nodetree->type==NTREE_COMPOSIT) { if(ELEM4(node->type, CMP_NODE_R_LAYERS, CMP_NODE_COMPOSITE, CMP_NODE_DEFOCUS, CMP_NODE_OUTPUT_FILE)) @@ -3205,6 +3221,7 @@ void NODE_OT_show_cyclic_dependencies(wmOperatorType *ot) static int node_add_file_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); SpaceNode *snode= CTX_wm_space_node(C); bNode *node; @@ -3245,7 +3262,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); - node = node_add_node(snode, scene, ntype, snode->mx, snode->my); + node = node_add_node(snode, bmain, scene, ntype, snode->mx, snode->my); if (!node) { BKE_report(op->reports, RPT_WARNING, "Could not add an image node."); diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 4f3991e8ff8..634e49dc515 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -64,6 +64,8 @@ static void do_node_add(bContext *C, void *UNUSED(arg), int event) { + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); SpaceNode *snode= CTX_wm_space_node(C); ScrArea *sa= CTX_wm_area(C); ARegion *ar; @@ -87,7 +89,7 @@ static void do_node_add(bContext *C, void *UNUSED(arg), int event) else node->flag &= ~NODE_TEST; } - node= node_add_node(snode, CTX_data_scene(C), event, snode->mx, snode->my); + node= node_add_node(snode, bmain, scene, event, snode->mx, snode->my); /* select previous selection before autoconnect */ for(node= snode->edittree->nodes.first; node; node= node->next) { diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 9122235f33c..4cfde22b8a0 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -43,6 +43,7 @@ struct wmWindowManager; struct bNode; struct bNodeSocket; struct bNodeLink; +struct Main; /* temp data to pass on to modal */ typedef struct bNodeLinkDrag @@ -97,10 +98,9 @@ void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *tre void snode_notify(bContext *C, SpaceNode *snode); void snode_dag_update(bContext *C, SpaceNode *snode); bNode *next_node(bNodeTree *ntree); -bNode *node_add_node(SpaceNode *snode, Scene *scene, int type, float locx, float locy); +bNode *node_add_node(SpaceNode *snode, struct Main *bmain, Scene *scene, int type, float locx, float locy); void snode_set_context(SpaceNode *snode, Scene *scene); void snode_make_group_editable(SpaceNode *snode, bNode *gnode); -void node_set_active(SpaceNode *snode, bNode *node); void node_deselectall(SpaceNode *snode); int node_select_same_type(SpaceNode *snode); int node_select_same_type_np(SpaceNode *snode, int dir); diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 1abcaccc939..ca673277739 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -37,10 +37,12 @@ #include "DNA_scene_types.h" #include "BKE_context.h" +#include "BKE_main.h" #include "BLI_rect.h" #include "BLI_utildefines.h" +#include "ED_node.h" #include "ED_screen.h" #include "ED_types.h" @@ -70,7 +72,7 @@ static bNode *node_under_mouse(bNodeTree *ntree, int mx, int my) /* ****** Click Select ****** */ -static bNode *node_mouse_select(SpaceNode *snode, ARegion *ar, const int mval[2], short extend) +static bNode *node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const int mval[2], short extend) { bNode *node; float mx, my; @@ -92,7 +94,7 @@ static bNode *node_mouse_select(SpaceNode *snode, ARegion *ar, const int mval[2] else node->flag ^= SELECT; - node_set_active(snode, node); + ED_node_set_active(bmain, snode->edittree, node); } return node; @@ -100,6 +102,7 @@ static bNode *node_mouse_select(SpaceNode *snode, ARegion *ar, const int mval[2] static int node_select_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); SpaceNode *snode= CTX_wm_space_node(C); ARegion *ar= CTX_wm_region(C); int mval[2]; @@ -113,7 +116,7 @@ static int node_select_exec(bContext *C, wmOperator *op) extend = RNA_boolean_get(op->ptr, "extend"); /* perform the select */ - node= node_mouse_select(snode, ar, mval, extend); + node= node_mouse_select(bmain, snode, ar, mval, extend); /* send notifiers */ WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL); diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index 4194d463e10..d969a80a678 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -37,8 +37,12 @@ set(INC_SYS ) set(SRC - outliner.c + outliner_draw.c + outliner_edit.c outliner_ops.c + outliner_select.c + outliner_tools.c + outliner_tree.c space_outliner.c outliner_intern.h diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c deleted file mode 100644 index 93dc96cf9c0..00000000000 --- a/source/blender/editors/space_outliner/outliner.c +++ /dev/null @@ -1,5792 +0,0 @@ -/* - * $Id$ - * - * ***** 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. - * - * The Original Code is Copyright (C) 2004 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/space_outliner/outliner.c - * \ingroup spoutliner - */ - - -#include <math.h> -#include <string.h> -#include <stdlib.h> -#include <stddef.h> - -#include "MEM_guardedalloc.h" - -#include "DNA_anim_types.h" -#include "DNA_armature_types.h" -#include "DNA_constraint_types.h" -#include "DNA_camera_types.h" -#include "DNA_group_types.h" -#include "DNA_key_types.h" -#include "DNA_lamp_types.h" -#include "DNA_material_types.h" -#include "DNA_mesh_types.h" -#include "DNA_meta_types.h" -#include "DNA_particle_types.h" -#include "DNA_scene_types.h" -#include "DNA_world_types.h" -#include "DNA_sequence_types.h" -#include "DNA_object_types.h" - -#include "BLI_blenlib.h" -#include "BLI_utildefines.h" -#include "BLI_math_base.h" - -#if defined WIN32 && !defined _LIBC -# include "BLI_fnmatch.h" /* use fnmatch included in blenlib */ -#else -# ifndef _GNU_SOURCE -# define _GNU_SOURCE -# endif -# include <fnmatch.h> -#endif - - -#include "BKE_animsys.h" -#include "BKE_context.h" -#include "BKE_deform.h" -#include "BKE_depsgraph.h" -#include "BKE_fcurve.h" -#include "BKE_global.h" -#include "BKE_group.h" -#include "BKE_library.h" -#include "BKE_main.h" -#include "BKE_modifier.h" -#include "BKE_report.h" -#include "BKE_scene.h" -#include "BKE_sequencer.h" - -#include "ED_armature.h" -#include "ED_object.h" -#include "ED_screen.h" -#include "ED_util.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "BIF_gl.h" -#include "BIF_glutil.h" - -#include "UI_interface.h" -#include "UI_interface_icons.h" -#include "UI_resources.h" -#include "UI_view2d.h" - -#include "RNA_access.h" -#include "RNA_define.h" - -#include "ED_keyframing.h" - -#include "outliner_intern.h" - - -#define OL_Y_OFFSET 2 - -#define OL_TOG_RESTRICT_VIEWX (UI_UNIT_X*3) -#define OL_TOG_RESTRICT_SELECTX (UI_UNIT_X*2) -#define OL_TOG_RESTRICT_RENDERX UI_UNIT_X - -#define OL_TOGW OL_TOG_RESTRICT_VIEWX - -#define OL_RNA_COLX (UI_UNIT_X*15) -#define OL_RNA_COL_SIZEX (UI_UNIT_X*7.5) -#define OL_RNA_COL_SPACEX (UI_UNIT_X*2.5) - -#define TS_CHUNK 128 - -#define TREESTORE(a) ((a)?soops->treestore->data+(a)->store_index:NULL) - -/* ************* XXX **************** */ - -static void error(const char *UNUSED(arg), ...) {} - -/* ********************************** */ - - -/* ******************** PROTOTYPES ***************** */ -static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int startx, int *starty); -static void outliner_do_object_operation(bContext *C, Scene *scene, SpaceOops *soops, ListBase *lb, - void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)); - -static int group_select_flag(Group *gr); - -/* ******************** PERSISTANT DATA ***************** */ - -static void outliner_storage_cleanup(SpaceOops *soops) -{ - TreeStore *ts= soops->treestore; - - if(ts) { - TreeStoreElem *tselem; - int a, unused= 0; - - /* each element used once, for ID blocks with more users to have each a treestore */ - for(a=0, tselem= ts->data; a<ts->usedelem; a++, tselem++) tselem->used= 0; - - /* cleanup only after reading file or undo step, and always for - * RNA datablocks view in order to save memory */ - if(soops->storeflag & SO_TREESTORE_CLEANUP) { - - for(a=0, tselem= ts->data; a<ts->usedelem; a++, tselem++) { - if(tselem->id==NULL) unused++; - } - - if(unused) { - if(ts->usedelem == unused) { - MEM_freeN(ts->data); - ts->data= NULL; - ts->usedelem= ts->totelem= 0; - } - else { - TreeStoreElem *tsnewar, *tsnew; - - tsnew=tsnewar= MEM_mallocN((ts->usedelem-unused)*sizeof(TreeStoreElem), "new tselem"); - for(a=0, tselem= ts->data; a<ts->usedelem; a++, tselem++) { - if(tselem->id) { - *tsnew= *tselem; - tsnew++; - } - } - MEM_freeN(ts->data); - ts->data= tsnewar; - ts->usedelem-= unused; - ts->totelem= ts->usedelem; - } - } - } - } -} - -static void check_persistant(SpaceOops *soops, TreeElement *te, ID *id, short type, short nr) -{ - TreeStore *ts; - TreeStoreElem *tselem; - int a; - - /* case 1; no TreeStore */ - if(soops->treestore==NULL) { - soops->treestore= MEM_callocN(sizeof(TreeStore), "treestore"); - } - ts= soops->treestore; - - /* check if 'te' is in treestore */ - tselem= ts->data; - for(a=0; a<ts->usedelem; a++, tselem++) { - if(tselem->id==id && tselem->used==0) { - if((type==0 && tselem->type==0) ||(tselem->type==type && tselem->nr==nr)) { - te->store_index= a; - tselem->used= 1; - return; - } - } - } - - /* add 1 element to treestore */ - if(ts->usedelem==ts->totelem) { - TreeStoreElem *tsnew; - - tsnew= MEM_mallocN((ts->totelem+TS_CHUNK)*sizeof(TreeStoreElem), "treestore data"); - if(ts->data) { - memcpy(tsnew, ts->data, ts->totelem*sizeof(TreeStoreElem)); - MEM_freeN(ts->data); - } - ts->data= tsnew; - ts->totelem+= TS_CHUNK; - } - - tselem= ts->data+ts->usedelem; - - tselem->type= type; - if(type) tselem->nr= nr; // we're picky! :) - else tselem->nr= 0; - tselem->id= id; - tselem->used = 0; - tselem->flag= TSE_CLOSED; - te->store_index= ts->usedelem; - - ts->usedelem++; -} - -/* ******************** TREE MANAGEMENT ****************** */ - -void outliner_free_tree(ListBase *lb) -{ - - while(lb->first) { - TreeElement *te= lb->first; - - outliner_free_tree(&te->subtree); - BLI_remlink(lb, te); - - if(te->flag & TE_FREE_NAME) MEM_freeN((void *)te->name); - MEM_freeN(te); - } -} - -static void outliner_height(SpaceOops *soops, ListBase *lb, int *h) -{ - TreeElement *te= lb->first; - while(te) { - TreeStoreElem *tselem= TREESTORE(te); - if((tselem->flag & TSE_CLOSED)==0) - outliner_height(soops, &te->subtree, h); - (*h) += UI_UNIT_Y; - te= te->next; - } -} - -#if 0 // XXX this is currently disabled until te->xend is set correctly -static void outliner_width(SpaceOops *soops, ListBase *lb, int *w) -{ - TreeElement *te= lb->first; - while(te) { -// TreeStoreElem *tselem= TREESTORE(te); - - // XXX fixme... te->xend is not set yet - if(tselem->flag & TSE_CLOSED) { - if (te->xend > *w) - *w = te->xend; - } - outliner_width(soops, &te->subtree, w); - te= te->next; - } -} -#endif - -static void outliner_rna_width(SpaceOops *soops, ListBase *lb, int *w, int startx) -{ - TreeElement *te= lb->first; - while(te) { - TreeStoreElem *tselem= TREESTORE(te); - // XXX fixme... (currently, we're using a fixed length of 100)! - /*if(te->xend) { - if(te->xend > *w) - *w = te->xend; - }*/ - if(startx+100 > *w) - *w = startx+100; - - if((tselem->flag & TSE_CLOSED)==0) - outliner_rna_width(soops, &te->subtree, w, startx+UI_UNIT_X); - te= te->next; - } -} - -static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index) -{ - TreeElement *te= lb->first, *tes; - while(te) { - if(te->store_index==store_index) return te; - tes= outliner_find_tree_element(&te->subtree, store_index); - if(tes) return tes; - te= te->next; - } - return NULL; -} - - - -static ID *outliner_search_back(SpaceOops *soops, TreeElement *te, short idcode) -{ - TreeStoreElem *tselem; - te= te->parent; - - while(te) { - tselem= TREESTORE(te); - if(tselem->type==0 && te->idcode==idcode) return tselem->id; - te= te->parent; - } - return NULL; -} - -struct treesort { - TreeElement *te; - ID *id; - const char *name; - short idcode; -}; - -static int treesort_alpha(const void *v1, const void *v2) -{ - const struct treesort *x1= v1, *x2= v2; - int comp; - - /* first put objects last (hierarchy) */ - comp= (x1->idcode==ID_OB); - if(x2->idcode==ID_OB) comp+=2; - - if(comp==1) return 1; - else if(comp==2) return -1; - else if(comp==3) { - comp= strcmp(x1->name, x2->name); - - if( comp>0 ) return 1; - else if( comp<0) return -1; - return 0; - } - return 0; -} - -/* this is nice option for later? doesnt look too useful... */ -#if 0 -static int treesort_obtype_alpha(const void *v1, const void *v2) -{ - const struct treesort *x1= v1, *x2= v2; - - /* first put objects last (hierarchy) */ - if(x1->idcode==ID_OB && x2->idcode!=ID_OB) return 1; - else if(x2->idcode==ID_OB && x1->idcode!=ID_OB) return -1; - else { - /* 2nd we check ob type */ - if(x1->idcode==ID_OB && x2->idcode==ID_OB) { - if( ((Object *)x1->id)->type > ((Object *)x2->id)->type) return 1; - else if( ((Object *)x1->id)->type > ((Object *)x2->id)->type) return -1; - else return 0; - } - else { - int comp= strcmp(x1->name, x2->name); - - if( comp>0 ) return 1; - else if( comp<0) return -1; - return 0; - } - } -} -#endif - -/* sort happens on each subtree individual */ -static void outliner_sort(SpaceOops *soops, ListBase *lb) -{ - TreeElement *te; - TreeStoreElem *tselem; - int totelem=0; - - te= lb->last; - if(te==NULL) return; - tselem= TREESTORE(te); - - /* sorting rules; only object lists or deformgroups */ - if( (tselem->type==TSE_DEFGROUP) || (tselem->type==0 && te->idcode==ID_OB)) { - - /* count first */ - for(te= lb->first; te; te= te->next) totelem++; - - if(totelem>1) { - struct treesort *tear= MEM_mallocN(totelem*sizeof(struct treesort), "tree sort array"); - struct treesort *tp=tear; - int skip= 0; - - for(te= lb->first; te; te= te->next, tp++) { - tselem= TREESTORE(te); - tp->te= te; - tp->name= te->name; - tp->idcode= te->idcode; - if(tselem->type && tselem->type!=TSE_DEFGROUP) tp->idcode= 0; // dont sort this - tp->id= tselem->id; - } - /* keep beginning of list */ - for(tp= tear, skip=0; skip<totelem; skip++, tp++) - if(tp->idcode) break; - - if(skip<totelem) - qsort(tear+skip, totelem-skip, sizeof(struct treesort), treesort_alpha); - - lb->first=lb->last= NULL; - tp= tear; - while(totelem--) { - BLI_addtail(lb, tp->te); - tp++; - } - MEM_freeN(tear); - } - } - - for(te= lb->first; te; te= te->next) { - outliner_sort(soops, &te->subtree); - } -} - -/* Prototype, see functions below */ -static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, - TreeElement *parent, short type, short index); - -#define LOG2I(x) (int)(log(x)/M_LN2) - -static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, SceneRenderLayer *srl) -{ - TreeStoreElem *tselem = NULL; - TreeElement *te = NULL; - - /* log stuff is to convert bitflags (powers of 2) to small integers, - * in order to not overflow short tselem->nr */ - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_COMBINED)); - te->name= "Combined"; - te->directdata= &srl->passflag; - - /* save cpu cycles, but we add the first to invoke an open/close triangle */ - tselem = TREESTORE(tenla); - if(tselem->flag & TSE_CLOSED) - return; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_Z)); - te->name= "Z"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_VECTOR)); - te->name= "Vector"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_NORMAL)); - te->name= "Normal"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_UV)); - te->name= "UV"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_MIST)); - te->name= "Mist"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXOB)); - te->name= "Index Object"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXMA)); - te->name= "Index Material"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_RGBA)); - te->name= "Color"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_DIFFUSE)); - te->name= "Diffuse"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SPEC)); - te->name= "Specular"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SHADOW)); - te->name= "Shadow"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_AO)); - te->name= "AO"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFLECT)); - te->name= "Reflection"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFRACT)); - te->name= "Refraction"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDIRECT)); - te->name= "Indirect"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_ENVIRONMENT)); - te->name= "Environment"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_EMIT)); - te->name= "Emit"; - te->directdata= &srl->passflag; -} - -#undef LOG2I - -/* special handling of hierarchical non-lib data */ -static void outliner_add_bone(SpaceOops *soops, ListBase *lb, ID *id, Bone *curBone, - TreeElement *parent, int *a) -{ - TreeElement *te= outliner_add_element(soops, lb, id, parent, TSE_BONE, *a); - - (*a)++; - te->name= curBone->name; - te->directdata= curBone; - - for(curBone= curBone->childbase.first; curBone; curBone=curBone->next) { - outliner_add_bone(soops, &te->subtree, id, curBone, te, a); - } -} - -static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *sce, TreeElement *te) -{ - SceneRenderLayer *srl; - TreeElement *tenla= outliner_add_element(soops, lb, sce, te, TSE_R_LAYER_BASE, 0); - int a; - - tenla->name= "RenderLayers"; - for(a=0, srl= sce->r.layers.first; srl; srl= srl->next, a++) { - TreeElement *tenlay= outliner_add_element(soops, &tenla->subtree, sce, te, TSE_R_LAYER, a); - tenlay->name= srl->name; - tenlay->directdata= &srl->passflag; - - if(srl->light_override) - outliner_add_element(soops, &tenlay->subtree, srl->light_override, tenlay, TSE_LINKED_LAMP, 0); - if(srl->mat_override) - outliner_add_element(soops, &tenlay->subtree, srl->mat_override, tenlay, TSE_LINKED_MAT, 0); - - outliner_add_passes(soops, tenlay, &sce->id, srl); - } - - outliner_add_element(soops, lb, sce->world, te, 0, 0); -} - -static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, - TreeElement *parent, short type, short index) -{ - TreeElement *te; - TreeStoreElem *tselem; - ID *id= idv; - int a = 0; - - if(ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { - id= ((PointerRNA*)idv)->id.data; - if(!id) id= ((PointerRNA*)idv)->data; - } - - if(id==NULL) return NULL; - - te= MEM_callocN(sizeof(TreeElement), "tree elem"); - /* add to the visual tree */ - BLI_addtail(lb, te); - /* add to the storage */ - check_persistant(soops, te, id, type, index); - tselem= TREESTORE(te); - - te->parent= parent; - te->index= index; // for data arays - if(ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)); - else if(ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)); - else if(type==TSE_ANIM_DATA); - else { - te->name= id->name+2; // default, can be overridden by Library or non-ID data - te->idcode= GS(id->name); - } - - if(type==0) { - - /* tuck pointer back in object, to construct hierarchy */ - if(GS(id->name)==ID_OB) id->newid= (ID *)te; - - /* expand specific data always */ - switch(GS(id->name)) { - case ID_LI: - te->name= ((Library *)id)->name; - break; - case ID_SCE: - outliner_add_scene_contents(soops, &te->subtree, (Scene *)id, te); - break; - case ID_OB: - { - Object *ob= (Object *)id; - - outliner_add_element(soops, &te->subtree, ob->adt, te, TSE_ANIM_DATA, 0); - outliner_add_element(soops, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this - - if(ob->proxy && ob->id.lib==NULL) - outliner_add_element(soops, &te->subtree, ob->proxy, te, TSE_PROXY, 0); - - outliner_add_element(soops, &te->subtree, ob->data, te, 0, 0); - - if(ob->pose) { - bArmature *arm= ob->data; - bPoseChannel *pchan; - TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_POSE_BASE, 0); - - tenla->name= "Pose"; - - if(arm->edbo==NULL && (ob->mode & OB_MODE_POSE)) { // channels undefined in editmode, but we want the 'tenla' pose icon itself - int a= 0, const_index= 1000; /* ensure unique id for bone constraints */ - - for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a); - ten->name= pchan->name; - ten->directdata= pchan; - pchan->prev= (bPoseChannel *)ten; - - if(pchan->constraints.first) { - //Object *target; - bConstraint *con; - TreeElement *ten1; - TreeElement *tenla1= outliner_add_element(soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0); - //char *str; - - tenla1->name= "Constraints"; - for(con= pchan->constraints.first; con; con= con->next, const_index++) { - ten1= outliner_add_element(soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index); -#if 0 /* disabled as it needs to be reworked for recoded constraints system */ - target= get_constraint_target(con, &str); - if(str && str[0]) ten1->name= str; - else if(target) ten1->name= target->id.name+2; - else ten1->name= con->name; -#endif - ten1->name= con->name; - ten1->directdata= con; - /* possible add all other types links? */ - } - } - } - /* make hierarchy */ - ten= tenla->subtree.first; - while(ten) { - TreeElement *nten= ten->next, *par; - tselem= TREESTORE(ten); - if(tselem->type==TSE_POSE_CHANNEL) { - pchan= (bPoseChannel *)ten->directdata; - if(pchan->parent) { - BLI_remlink(&tenla->subtree, ten); - par= (TreeElement *)pchan->parent->prev; - BLI_addtail(&par->subtree, ten); - ten->parent= par; - } - } - ten= nten; - } - /* restore prev pointers */ - pchan= ob->pose->chanbase.first; - if(pchan) pchan->prev= NULL; - for(; pchan; pchan= pchan->next) { - if(pchan->next) pchan->next->prev= pchan; - } - } - - /* Pose Groups */ - if(ob->pose->agroups.first) { - bActionGroup *agrp; - TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_POSEGRP_BASE, 0); - int a= 0; - - tenla->name= "Bone Groups"; - for (agrp=ob->pose->agroups.first; agrp; agrp=agrp->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSEGRP, a); - ten->name= agrp->name; - ten->directdata= agrp; - } - } - } - - for(a=0; a<ob->totcol; a++) - outliner_add_element(soops, &te->subtree, ob->mat[a], te, 0, a); - - if(ob->constraints.first) { - //Object *target; - bConstraint *con; - TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0); - int a= 0; - //char *str; - - tenla->name= "Constraints"; - for(con= ob->constraints.first; con; con= con->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a); -#if 0 /* disabled due to constraints system targets recode... code here needs review */ - target= get_constraint_target(con, &str); - if(str && str[0]) ten->name= str; - else if(target) ten->name= target->id.name+2; - else ten->name= con->name; -#endif - ten->name= con->name; - ten->directdata= con; - /* possible add all other types links? */ - } - } - - if(ob->modifiers.first) { - ModifierData *md; - TreeElement *temod = outliner_add_element(soops, &te->subtree, ob, te, TSE_MODIFIER_BASE, 0); - int index; - - temod->name = "Modifiers"; - for (index=0,md=ob->modifiers.first; md; index++,md=md->next) { - TreeElement *te = outliner_add_element(soops, &temod->subtree, ob, temod, TSE_MODIFIER, index); - te->name= md->name; - te->directdata = md; - - if (md->type==eModifierType_Lattice) { - outliner_add_element(soops, &te->subtree, ((LatticeModifierData*) md)->object, te, TSE_LINKED_OB, 0); - } else if (md->type==eModifierType_Curve) { - outliner_add_element(soops, &te->subtree, ((CurveModifierData*) md)->object, te, TSE_LINKED_OB, 0); - } else if (md->type==eModifierType_Armature) { - outliner_add_element(soops, &te->subtree, ((ArmatureModifierData*) md)->object, te, TSE_LINKED_OB, 0); - } else if (md->type==eModifierType_Hook) { - outliner_add_element(soops, &te->subtree, ((HookModifierData*) md)->object, te, TSE_LINKED_OB, 0); - } else if (md->type==eModifierType_ParticleSystem) { - TreeElement *ten; - ParticleSystem *psys= ((ParticleSystemModifierData*) md)->psys; - - ten = outliner_add_element(soops, &te->subtree, ob, te, TSE_LINKED_PSYS, 0); - ten->directdata = psys; - ten->name = psys->part->id.name+2; - } - } - } - if(ob->defbase.first) { - bDeformGroup *defgroup; - TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_DEFGROUP_BASE, 0); - int a= 0; - - tenla->name= "Vertex Groups"; - for (defgroup=ob->defbase.first; defgroup; defgroup=defgroup->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_DEFGROUP, a); - ten->name= defgroup->name; - ten->directdata= defgroup; - } - } - - if(ob->dup_group) - outliner_add_element(soops, &te->subtree, ob->dup_group, te, 0, 0); - - } - break; - case ID_ME: - { - Mesh *me= (Mesh *)id; - - //outliner_add_element(soops, &te->subtree, me->adt, te, TSE_ANIM_DATA, 0); - - outliner_add_element(soops, &te->subtree, me->key, te, 0, 0); - for(a=0; a<me->totcol; a++) - outliner_add_element(soops, &te->subtree, me->mat[a], te, 0, a); - /* could do tfaces with image links, but the images are not grouped nicely. - would require going over all tfaces, sort images in use. etc... */ - } - break; - case ID_CU: - { - Curve *cu= (Curve *)id; - - outliner_add_element(soops, &te->subtree, cu->adt, te, TSE_ANIM_DATA, 0); - - for(a=0; a<cu->totcol; a++) - outliner_add_element(soops, &te->subtree, cu->mat[a], te, 0, a); - } - break; - case ID_MB: - { - MetaBall *mb= (MetaBall *)id; - for(a=0; a<mb->totcol; a++) - outliner_add_element(soops, &te->subtree, mb->mat[a], te, 0, a); - } - break; - case ID_MA: - { - Material *ma= (Material *)id; - - outliner_add_element(soops, &te->subtree, ma->adt, te, TSE_ANIM_DATA, 0); - - for(a=0; a<MAX_MTEX; a++) { - if(ma->mtex[a]) outliner_add_element(soops, &te->subtree, ma->mtex[a]->tex, te, 0, a); - } - } - break; - case ID_TE: - { - Tex *tex= (Tex *)id; - - outliner_add_element(soops, &te->subtree, tex->adt, te, TSE_ANIM_DATA, 0); - outliner_add_element(soops, &te->subtree, tex->ima, te, 0, 0); - } - break; - case ID_CA: - { - Camera *ca= (Camera *)id; - outliner_add_element(soops, &te->subtree, ca->adt, te, TSE_ANIM_DATA, 0); - } - break; - case ID_LA: - { - Lamp *la= (Lamp *)id; - - outliner_add_element(soops, &te->subtree, la->adt, te, TSE_ANIM_DATA, 0); - - for(a=0; a<MAX_MTEX; a++) { - if(la->mtex[a]) outliner_add_element(soops, &te->subtree, la->mtex[a]->tex, te, 0, a); - } - } - break; - case ID_WO: - { - World *wrld= (World *)id; - - outliner_add_element(soops, &te->subtree, wrld->adt, te, TSE_ANIM_DATA, 0); - - for(a=0; a<MAX_MTEX; a++) { - if(wrld->mtex[a]) outliner_add_element(soops, &te->subtree, wrld->mtex[a]->tex, te, 0, a); - } - } - break; - case ID_KE: - { - Key *key= (Key *)id; - - outliner_add_element(soops, &te->subtree, key->adt, te, TSE_ANIM_DATA, 0); - } - break; - case ID_AC: - { - // XXX do we want to be exposing the F-Curves here? - //bAction *act= (bAction *)id; - } - break; - case ID_AR: - { - bArmature *arm= (bArmature *)id; - int a= 0; - - if(arm->edbo) { - EditBone *ebone; - TreeElement *ten; - - for (ebone = arm->edbo->first; ebone; ebone=ebone->next, a++) { - ten= outliner_add_element(soops, &te->subtree, id, te, TSE_EBONE, a); - ten->directdata= ebone; - ten->name= ebone->name; - ebone->temp= ten; - } - /* make hierarchy */ - ten= te->subtree.first; - while(ten) { - TreeElement *nten= ten->next, *par; - ebone= (EditBone *)ten->directdata; - if(ebone->parent) { - BLI_remlink(&te->subtree, ten); - par= ebone->parent->temp; - BLI_addtail(&par->subtree, ten); - ten->parent= par; - } - ten= nten; - } - } - else { - /* do not extend Armature when we have posemode */ - tselem= TREESTORE(te->parent); - if( GS(tselem->id->name)==ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE); - else { - Bone *curBone; - for (curBone=arm->bonebase.first; curBone; curBone=curBone->next){ - outliner_add_bone(soops, &te->subtree, id, curBone, te, &a); - } - } - } - } - break; - } - } - else if(type==TSE_ANIM_DATA) { - AnimData *adt= (AnimData *)idv; - - /* this element's info */ - te->name= "Animation"; - - /* Action */ - outliner_add_element(soops, &te->subtree, adt->action, te, 0, 0); - - /* Drivers */ - if (adt->drivers.first) { - TreeElement *ted= outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0); - ID *lastadded= NULL; - FCurve *fcu; - - ted->name= "Drivers"; - - for (fcu= adt->drivers.first; fcu; fcu= fcu->next) { - if (fcu->driver && fcu->driver->variables.first) { - ChannelDriver *driver= fcu->driver; - DriverVar *dvar; - - for (dvar= driver->variables.first; dvar; dvar= dvar->next) { - /* loop over all targets used here */ - DRIVER_TARGETS_USED_LOOPER(dvar) - { - if (lastadded != dtar->id) { - // XXX this lastadded check is rather lame, and also fails quite badly... - outliner_add_element(soops, &ted->subtree, dtar->id, ted, TSE_LINKED_OB, 0); - lastadded= dtar->id; - } - } - DRIVER_TARGETS_LOOPER_END - } - } - } - } - - /* NLA Data */ - if (adt->nla_tracks.first) { - TreeElement *tenla= outliner_add_element(soops, &te->subtree, adt, te, TSE_NLA, 0); - NlaTrack *nlt; - int a= 0; - - tenla->name= "NLA Tracks"; - - for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) { - TreeElement *tenlt= outliner_add_element(soops, &tenla->subtree, nlt, tenla, TSE_NLA_TRACK, a); - NlaStrip *strip; - TreeElement *ten; - int b= 0; - - tenlt->name= nlt->name; - - for (strip=nlt->strips.first; strip; strip=strip->next, b++) { - ten= outliner_add_element(soops, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b); - if(ten) ten->directdata= strip; - } - } - } - } - else if(type==TSE_SEQUENCE) { - Sequence *seq= (Sequence*) idv; - Sequence *p; - - /* - * The idcode is a little hack, but the outliner - * only check te->idcode if te->type is equal to zero, - * so this is "safe". - */ - te->idcode= seq->type; - te->directdata= seq; - - if(seq->type<7) { - /* - * This work like the sequence. - * If the sequence have a name (not default name) - * show it, in other case put the filename. - */ - if(strcmp(seq->name, "SQ")) - te->name= seq->name; - else { - if((seq->strip) && (seq->strip->stripdata)) - te->name= seq->strip->stripdata->name; - else - te->name= "SQ None"; - } - - if(seq->type==SEQ_META) { - te->name= "Meta Strip"; - p= seq->seqbase.first; - while(p) { - outliner_add_element(soops, &te->subtree, (void*)p, te, TSE_SEQUENCE, index); - p= p->next; - } - } - else - outliner_add_element(soops, &te->subtree, (void*)seq->strip, te, TSE_SEQ_STRIP, index); - } - else - te->name= "Effect"; - } - else if(type==TSE_SEQ_STRIP) { - Strip *strip= (Strip *)idv; - - if(strip->dir) - te->name= strip->dir; - else - te->name= "Strip None"; - te->directdata= strip; - } - else if(type==TSE_SEQUENCE_DUP) { - Sequence *seq= (Sequence*)idv; - - te->idcode= seq->type; - te->directdata= seq; - te->name= seq->strip->stripdata->name; - } - else if(ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { - PointerRNA pptr, propptr, *ptr= (PointerRNA*)idv; - PropertyRNA *prop, *iterprop; - PropertyType proptype; - int a, tot; - - /* we do lazy build, for speed and to avoid infinite recusion */ - - if(ptr->data == NULL) { - te->name= "(empty)"; - } - else if(type == TSE_RNA_STRUCT) { - /* struct */ - te->name= RNA_struct_name_get_alloc(ptr, NULL, 0); - - if(te->name) - te->flag |= TE_FREE_NAME; - else - te->name= (char*)RNA_struct_ui_name(ptr->type); - - iterprop= RNA_struct_iterator_property(ptr->type); - tot= RNA_property_collection_length(ptr, iterprop); - - /* auto open these cases */ - if(!parent || (RNA_property_type(parent->directdata)) == PROP_POINTER) - if(!tselem->used) - tselem->flag &= ~TSE_CLOSED; - - if(!(tselem->flag & TSE_CLOSED)) { - for(a=0; a<tot; a++) - outliner_add_element(soops, &te->subtree, (void*)ptr, te, TSE_RNA_PROPERTY, a); - } - else if(tot) - te->flag |= TE_LAZY_CLOSED; - - te->rnaptr= *ptr; - } - else if(type == TSE_RNA_PROPERTY) { - /* property */ - iterprop= RNA_struct_iterator_property(ptr->type); - RNA_property_collection_lookup_int(ptr, iterprop, index, &propptr); - - prop= propptr.data; - proptype= RNA_property_type(prop); - - te->name= (char*)RNA_property_ui_name(prop); - te->directdata= prop; - te->rnaptr= *ptr; - - if(proptype == PROP_POINTER) { - pptr= RNA_property_pointer_get(ptr, prop); - - if(pptr.data) { - if(!(tselem->flag & TSE_CLOSED)) - outliner_add_element(soops, &te->subtree, (void*)&pptr, te, TSE_RNA_STRUCT, -1); - else - te->flag |= TE_LAZY_CLOSED; - } - } - else if(proptype == PROP_COLLECTION) { - tot= RNA_property_collection_length(ptr, prop); - - if(!(tselem->flag & TSE_CLOSED)) { - for(a=0; a<tot; a++) { - RNA_property_collection_lookup_int(ptr, prop, a, &pptr); - outliner_add_element(soops, &te->subtree, (void*)&pptr, te, TSE_RNA_STRUCT, -1); - } - } - else if(tot) - te->flag |= TE_LAZY_CLOSED; - } - else if(ELEM3(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) { - tot= RNA_property_array_length(ptr, prop); - - if(!(tselem->flag & TSE_CLOSED)) { - for(a=0; a<tot; a++) - outliner_add_element(soops, &te->subtree, (void*)ptr, te, TSE_RNA_ARRAY_ELEM, a); - } - else if(tot) - te->flag |= TE_LAZY_CLOSED; - } - } - else if(type == TSE_RNA_ARRAY_ELEM) { - char c; - - prop= parent->directdata; - - te->directdata= prop; - te->rnaptr= *ptr; - te->index= index; - - c= RNA_property_array_item_char(prop, index); - - te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName"); - if(c) sprintf((char *)te->name, " %c", c); - else sprintf((char *)te->name, " %d", index+1); - te->flag |= TE_FREE_NAME; - } - } - else if(type == TSE_KEYMAP) { - wmKeyMap *km= (wmKeyMap *)idv; - wmKeyMapItem *kmi; - char opname[OP_MAX_TYPENAME]; - - te->directdata= idv; - te->name= km->idname; - - if(!(tselem->flag & TSE_CLOSED)) { - a= 0; - - for (kmi= km->items.first; kmi; kmi= kmi->next, a++) { - const char *key= WM_key_event_string(kmi->type); - - if(key[0]) { - wmOperatorType *ot= NULL; - - if(kmi->propvalue); - else ot= WM_operatortype_find(kmi->idname, 0); - - if(ot || kmi->propvalue) { - TreeElement *ten= outliner_add_element(soops, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a); - - ten->directdata= kmi; - - if(kmi->propvalue) { - ten->name= "Modal map, not yet"; - } - else { - WM_operator_py_idname(opname, ot->idname); - ten->name= BLI_strdup(opname); - ten->flag |= TE_FREE_NAME; - } - } - } - } - } - else - te->flag |= TE_LAZY_CLOSED; - } - - return te; -} - -static void outliner_make_hierarchy(SpaceOops *soops, ListBase *lb) -{ - TreeElement *te, *ten, *tep; - TreeStoreElem *tselem; - - /* build hierarchy */ - // XXX also, set extents here... - te= lb->first; - while(te) { - ten= te->next; - tselem= TREESTORE(te); - - if(tselem->type==0 && te->idcode==ID_OB) { - Object *ob= (Object *)tselem->id; - if(ob->parent && ob->parent->id.newid) { - BLI_remlink(lb, te); - tep= (TreeElement *)ob->parent->id.newid; - BLI_addtail(&tep->subtree, te); - // set correct parent pointers - for(te=tep->subtree.first; te; te= te->next) te->parent= tep; - } - } - te= ten; - } -} - -/* Helped function to put duplicate sequence in the same tree. */ -static int need_add_seq_dup(Sequence *seq) -{ - Sequence *p; - - if((!seq->strip) || (!seq->strip->stripdata) || (!seq->strip->stripdata->name)) - return(1); - - /* - * First check backward, if we found a duplicate - * sequence before this, don't need it, just return. - */ - p= seq->prev; - while(p) { - if((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { - p= p->prev; - continue; - } - - if(!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) - return(2); - p= p->prev; - } - - p= seq->next; - while(p) { - if((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { - p= p->next; - continue; - } - - if(!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) - return(0); - p= p->next; - } - return(1); -} - -static void add_seq_dup(SpaceOops *soops, Sequence *seq, TreeElement *te, short index) -{ - TreeElement *ch; - Sequence *p; - - p= seq; - while(p) { - if((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { - p= p->next; - continue; - } - - if(!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) - ch= outliner_add_element(soops, &te->subtree, (void*)p, te, TSE_SEQUENCE, index); - p= p->next; - } -} - -static int outliner_filter_has_name(TreeElement *te, const char *name, int flags) -{ -#if 0 - int found= 0; - - /* determine if match */ - if (flags & SO_FIND_CASE_SENSITIVE) { - if (flags & SO_FIND_COMPLETE) - found= strcmp(te->name, name) == 0; - else - found= strstr(te->name, name) != NULL; - } - else { - if (flags & SO_FIND_COMPLETE) - found= BLI_strcasecmp(te->name, name) == 0; - else - found= BLI_strcasestr(te->name, name) != NULL; - } -#else - - int fn_flag= 0; - int found= 0; - - if ((flags & SO_FIND_CASE_SENSITIVE) == 0) - fn_flag |= FNM_CASEFOLD; - - if (flags & SO_FIND_COMPLETE) { - found= fnmatch(name, te->name, fn_flag)==0; - } - else { - char fn_name[sizeof(((struct SpaceOops *)NULL)->search_string) + 2]; - sprintf(fn_name, "*%s*", name); - found= fnmatch(fn_name, te->name, fn_flag)==0; - } - return found; -#endif -} - -static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) -{ - TreeElement *te, *ten; - TreeStoreElem *tselem; - - /* although we don't have any search string, we return TRUE - * since the entire tree is ok then... - */ - if (soops->search_string[0]==0) - return 1; - - for (te= lb->first; te; te= ten) { - ten= te->next; - - if (0==outliner_filter_has_name(te, soops->search_string, soops->search_flags)) { - /* item isn't something we're looking for, but... - * - if the subtree is expanded, check if there are any matches that can be easily found - * so that searching for "cu" in the default scene will still match the Cube - * - otherwise, we can't see within the subtree and the item doesn't match, - * so these can be safely ignored (i.e. the subtree can get freed) - */ - tselem= TREESTORE(te); - - if ((tselem->flag & TSE_CLOSED) || outliner_filter_tree(soops, &te->subtree)==0) { - outliner_free_tree(&te->subtree); - BLI_remlink(lb, te); - - if(te->flag & TE_FREE_NAME) MEM_freeN((void *)te->name); - MEM_freeN(te); - } - } - else { - /* filter subtree too */ - outliner_filter_tree(soops, &te->subtree); - } - } - - /* if there are still items in the list, that means that there were still some matches */ - return (lb->first != NULL); -} - - -static void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) -{ - Base *base; - Object *ob; - TreeElement *te=NULL, *ten; - TreeStoreElem *tselem; - int show_opened= (soops->treestore==NULL); /* on first view, we open scenes */ - - if(soops->tree.first && (soops->storeflag & SO_TREESTORE_REDRAW)) - return; - - outliner_free_tree(&soops->tree); - outliner_storage_cleanup(soops); - - /* clear ob id.new flags */ - for(ob= mainvar->object.first; ob; ob= ob->id.next) ob->id.newid= NULL; - - /* options */ - if(soops->outlinevis == SO_LIBRARIES) { - Library *lib; - - for(lib= mainvar->library.first; lib; lib= lib->id.next) { - ten= outliner_add_element(soops, &soops->tree, lib, NULL, 0, 0); - lib->id.newid= (ID *)ten; - } - /* make hierarchy */ - ten= soops->tree.first; - while(ten) { - TreeElement *nten= ten->next, *par; - tselem= TREESTORE(ten); - lib= (Library *)tselem->id; - if(lib->parent) { - BLI_remlink(&soops->tree, ten); - par= (TreeElement *)lib->parent->id.newid; - BLI_addtail(&par->subtree, ten); - ten->parent= par; - } - ten= nten; - } - /* restore newid pointers */ - for(lib= mainvar->library.first; lib; lib= lib->id.next) - lib->id.newid= NULL; - - } - else if(soops->outlinevis == SO_ALL_SCENES) { - Scene *sce; - for(sce= mainvar->scene.first; sce; sce= sce->id.next) { - te= outliner_add_element(soops, &soops->tree, sce, NULL, 0, 0); - tselem= TREESTORE(te); - if(sce==scene && show_opened) - tselem->flag &= ~TSE_CLOSED; - - for(base= sce->base.first; base; base= base->next) { - ten= outliner_add_element(soops, &te->subtree, base->object, te, 0, 0); - ten->directdata= base; - } - outliner_make_hierarchy(soops, &te->subtree); - /* clear id.newid, to prevent objects be inserted in wrong scenes (parent in other scene) */ - for(base= sce->base.first; base; base= base->next) base->object->id.newid= NULL; - } - } - else if(soops->outlinevis == SO_CUR_SCENE) { - - outliner_add_scene_contents(soops, &soops->tree, scene, NULL); - - for(base= scene->base.first; base; base= base->next) { - ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); - ten->directdata= base; - } - outliner_make_hierarchy(soops, &soops->tree); - } - else if(soops->outlinevis == SO_VISIBLE) { - for(base= scene->base.first; base; base= base->next) { - if(base->lay & scene->lay) - outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); - } - outliner_make_hierarchy(soops, &soops->tree); - } - else if(soops->outlinevis == SO_GROUPS) { - Group *group; - GroupObject *go; - - for(group= mainvar->group.first; group; group= group->id.next) { - if(group->gobject.first) { - te= outliner_add_element(soops, &soops->tree, group, NULL, 0, 0); - - for(go= group->gobject.first; go; go= go->next) { - ten= outliner_add_element(soops, &te->subtree, go->ob, te, 0, 0); - ten->directdata= NULL; /* eh, why? */ - } - outliner_make_hierarchy(soops, &te->subtree); - /* clear id.newid, to prevent objects be inserted in wrong scenes (parent in other scene) */ - for(go= group->gobject.first; go; go= go->next) go->ob->id.newid= NULL; - } - } - } - else if(soops->outlinevis == SO_SAME_TYPE) { - Object *ob= OBACT; - if(ob) { - for(base= scene->base.first; base; base= base->next) { - if(base->object->type==ob->type) { - ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); - ten->directdata= base; - } - } - outliner_make_hierarchy(soops, &soops->tree); - } - } - else if(soops->outlinevis == SO_SELECTED) { - for(base= scene->base.first; base; base= base->next) { - if(base->lay & scene->lay) { - if(base==BASACT || (base->flag & SELECT)) { - ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); - ten->directdata= base; - } - } - } - outliner_make_hierarchy(soops, &soops->tree); - } - else if(soops->outlinevis==SO_SEQUENCE) { - Sequence *seq; - Editing *ed= seq_give_editing(scene, FALSE); - int op; - - if(ed==NULL) - return; - - seq= ed->seqbasep->first; - if(!seq) - return; - - while(seq) { - op= need_add_seq_dup(seq); - if(op==1) - ten= outliner_add_element(soops, &soops->tree, (void*)seq, NULL, TSE_SEQUENCE, 0); - else if(op==0) { - ten= outliner_add_element(soops, &soops->tree, (void*)seq, NULL, TSE_SEQUENCE_DUP, 0); - add_seq_dup(soops, seq, ten, 0); - } - seq= seq->next; - } - } - else if(soops->outlinevis==SO_DATABLOCKS) { - PointerRNA mainptr; - - RNA_main_pointer_create(mainvar, &mainptr); - - ten= outliner_add_element(soops, &soops->tree, (void*)&mainptr, NULL, TSE_RNA_STRUCT, -1); - - if(show_opened) { - tselem= TREESTORE(ten); - tselem->flag &= ~TSE_CLOSED; - } - } - else if(soops->outlinevis==SO_USERDEF) { - PointerRNA userdefptr; - - RNA_pointer_create(NULL, &RNA_UserPreferences, &U, &userdefptr); - - ten= outliner_add_element(soops, &soops->tree, (void*)&userdefptr, NULL, TSE_RNA_STRUCT, -1); - - if(show_opened) { - tselem= TREESTORE(ten); - tselem->flag &= ~TSE_CLOSED; - } - } - else if(soops->outlinevis==SO_KEYMAP) { - wmWindowManager *wm= mainvar->wm.first; - wmKeyMap *km; - - for(km= wm->defaultconf->keymaps.first; km; km= km->next) { - ten= outliner_add_element(soops, &soops->tree, (void*)km, NULL, TSE_KEYMAP, 0); - } - } - else { - ten= outliner_add_element(soops, &soops->tree, OBACT, NULL, 0, 0); - if(ten) ten->directdata= BASACT; - } - - outliner_sort(soops, &soops->tree); - outliner_filter_tree(soops, &soops->tree); -} - -/* **************** INTERACTIVE ************* */ - - -static int outliner_scroll_page_exec(bContext *C, wmOperator *op) -{ - ARegion *ar= CTX_wm_region(C); - int dy= ar->v2d.mask.ymax - ar->v2d.mask.ymin; - int up= 0; - - if(RNA_boolean_get(op->ptr, "up")) - up= 1; - - if(up == 0) dy= -dy; - ar->v2d.cur.ymin+= dy; - ar->v2d.cur.ymax+= dy; - - ED_region_tag_redraw(ar); - - return OPERATOR_FINISHED; -} - - -void OUTLINER_OT_scroll_page(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Scroll Page"; - ot->idname= "OUTLINER_OT_scroll_page"; - ot->description= "Scroll page up or down"; - - /* callbacks */ - ot->exec= outliner_scroll_page_exec; - ot->poll= ED_operator_outliner_active; - - /* properties */ - RNA_def_boolean(ot->srna, "up", 0, "Up", "Scroll up one page."); -} - - -static int outliner_count_levels(SpaceOops *soops, ListBase *lb, int curlevel) -{ - TreeElement *te; - int level=curlevel, lev; - - for(te= lb->first; te; te= te->next) { - - lev= outliner_count_levels(soops, &te->subtree, curlevel+1); - if(lev>level) level= lev; - } - return level; -} - -static int outliner_has_one_flag(SpaceOops *soops, ListBase *lb, short flag, short curlevel) -{ - TreeElement *te; - TreeStoreElem *tselem; - int level; - - for(te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if(tselem->flag & flag) return curlevel; - - level= outliner_has_one_flag(soops, &te->subtree, flag, curlevel+1); - if(level) return level; - } - return 0; -} - -static void outliner_set_flag(SpaceOops *soops, ListBase *lb, short flag, short set) -{ - TreeElement *te; - TreeStoreElem *tselem; - - for(te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if(set==0) tselem->flag &= ~flag; - else tselem->flag |= flag; - outliner_set_flag(soops, &te->subtree, flag, set); - } -} - -/* --- */ - -/* same check needed for both object operation and restrict column button func - * return 0 when in edit mode (cannot restrict view or select) - * otherwise return 1 */ -static int common_restrict_check(bContext *C, Object *ob) -{ - /* Don't allow hide an object in edit mode, - * check the bug #22153 and #21609, #23977 - */ - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit == ob) { - /* found object is hidden, reset */ - if (ob->restrictflag & OB_RESTRICT_VIEW) - ob->restrictflag &= ~OB_RESTRICT_VIEW; - /* found object is unselectable, reset */ - if (ob->restrictflag & OB_RESTRICT_SELECT) - ob->restrictflag &= ~OB_RESTRICT_SELECT; - return 0; - } - - return 1; -} - -static void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) -{ - Base *base= (Base *)te->directdata; - Object *ob = (Object *)tselem->id; - - /* add check for edit mode */ - if(!common_restrict_check(C, ob)) return; - - if(base || (base= object_in_scene(ob, scene))) { - if((base->object->restrictflag ^= OB_RESTRICT_VIEW)) { - ED_base_object_select(base, BA_DESELECT); - } - } -} - -static int outliner_toggle_visibility_exec(bContext *C, wmOperator *UNUSED(op)) -{ - SpaceOops *soops= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - - outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb); - - WM_event_add_notifier(C, NC_SCENE|ND_OB_VISIBLE, scene); - ED_region_tag_redraw(ar); - - return OPERATOR_FINISHED; -} - -void OUTLINER_OT_visibility_toggle(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Toggle Visibility"; - ot->idname= "OUTLINER_OT_visibility_toggle"; - ot->description= "Toggle the visibility of selected items"; - - /* callbacks */ - ot->exec= outliner_toggle_visibility_exec; - ot->poll= ED_operator_outliner_active_no_editobject; - - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -/* --- */ - -static void object_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) -{ - Base *base= (Base *)te->directdata; - - if(base==NULL) base= object_in_scene((Object *)tselem->id, scene); - if(base) { - base->object->restrictflag^=OB_RESTRICT_SELECT; - } -} - -static int outliner_toggle_selectability_exec(bContext *C, wmOperator *UNUSED(op)) -{ - SpaceOops *soops= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - - outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_selectability_cb); - - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); - ED_region_tag_redraw(ar); - - return OPERATOR_FINISHED; -} - -void OUTLINER_OT_selectability_toggle(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Toggle Selectability"; - ot->idname= "OUTLINER_OT_selectability_toggle"; - ot->description= "Toggle the selectability"; - - /* callbacks */ - ot->exec= outliner_toggle_selectability_exec; - ot->poll= ED_operator_outliner_active_no_editobject; - - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -static void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) -{ - Base *base= (Base *)te->directdata; - - if(base==NULL) base= object_in_scene((Object *)tselem->id, scene); - if(base) { - base->object->restrictflag^=OB_RESTRICT_RENDER; - } -} - -static int outliner_toggle_renderability_exec(bContext *C, wmOperator *UNUSED(op)) -{ - SpaceOops *soops= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - - outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb); - - ED_region_tag_redraw(ar); - - return OPERATOR_FINISHED; -} - -void OUTLINER_OT_renderability_toggle(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Toggle Renderability"; - ot->idname= "OUTLINER_OT_renderability_toggle"; - ot->description= "Toggle the renderability of selected items"; - - /* callbacks */ - ot->exec= outliner_toggle_renderability_exec; - ot->poll= ED_operator_outliner_active; - - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -/* --- */ - -static int outliner_toggle_expanded_exec(bContext *C, wmOperator *UNUSED(op)) -{ - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); - - if (outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1)) - outliner_set_flag(soops, &soops->tree, TSE_CLOSED, 0); - else - outliner_set_flag(soops, &soops->tree, TSE_CLOSED, 1); - - ED_region_tag_redraw(ar); - - return OPERATOR_FINISHED; -} - -void OUTLINER_OT_expanded_toggle(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Expand/Collapse All"; - ot->idname= "OUTLINER_OT_expanded_toggle"; - ot->description= "Expand/Collapse all items"; - - /* callbacks */ - ot->exec= outliner_toggle_expanded_exec; - ot->poll= ED_operator_outliner_active; - - /* no undo or registry, UI option */ -} - -/* --- */ - -static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) -{ - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); - - if (outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1)) - outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); - else - outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 1); - - soops->storeflag |= SO_TREESTORE_REDRAW; - - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); - ED_region_tag_redraw(ar); - - return OPERATOR_FINISHED; -} - -void OUTLINER_OT_selected_toggle(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Toggle Selected"; - ot->idname= "OUTLINER_OT_selected_toggle"; - ot->description= "Toggle the Outliner selection of items"; - - /* callbacks */ - ot->exec= outliner_toggle_selected_exec; - ot->poll= ED_operator_outliner_active; - - /* no undo or registry, UI option */ -} - -/* --- */ - -/* helper function for Show/Hide one level operator */ -static void outliner_openclose_level(SpaceOops *soops, ListBase *lb, int curlevel, int level, int open) -{ - TreeElement *te; - TreeStoreElem *tselem; - - for(te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - - if(open) { - if(curlevel<=level) tselem->flag &= ~TSE_CLOSED; - } - else { - if(curlevel>=level) tselem->flag |= TSE_CLOSED; - } - - outliner_openclose_level(soops, &te->subtree, curlevel+1, level, open); - } -} - -static int outliner_one_level_exec(bContext *C, wmOperator *op) -{ - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); - int add= RNA_boolean_get(op->ptr, "open"); - int level; - - level= outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1); - if(add==1) { - if(level) outliner_openclose_level(soops, &soops->tree, 1, level, 1); - } - else { - if(level==0) level= outliner_count_levels(soops, &soops->tree, 0); - if(level) outliner_openclose_level(soops, &soops->tree, 1, level-1, 0); - } - - ED_region_tag_redraw(ar); - - return OPERATOR_FINISHED; -} - -void OUTLINER_OT_show_one_level(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Show/Hide One Level"; - ot->idname= "OUTLINER_OT_show_one_level"; - ot->description= "Expand/collapse all entries by one level"; - - /* callbacks */ - ot->exec= outliner_one_level_exec; - ot->poll= ED_operator_outliner_active; - - /* no undo or registry, UI option */ - - /* properties */ - RNA_def_boolean(ot->srna, "open", 1, "Open", "Expand all entries one level deep."); -} - -/* This is not used anywhere at the moment */ -#if 0 -/* return 1 when levels were opened */ -static int outliner_open_back(SpaceOops *soops, TreeElement *te) -{ - TreeStoreElem *tselem; - int retval= 0; - - for (te= te->parent; te; te= te->parent) { - tselem= TREESTORE(te); - if (tselem->flag & TSE_CLOSED) { - tselem->flag &= ~TSE_CLOSED; - retval= 1; - } - } - return retval; -} - -static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *teFind, int *found) -{ - TreeElement *te; - TreeStoreElem *tselem; - - for (te= lb->first; te; te= te->next) { - /* check if this tree-element was the one we're seeking */ - if (te == teFind) { - *found= 1; - return; - } - - /* try to see if sub-tree contains it then */ - outliner_open_reveal(soops, &te->subtree, teFind, found); - if (*found) { - tselem= TREESTORE(te); - if (tselem->flag & TSE_CLOSED) - tselem->flag &= ~TSE_CLOSED; - return; - } - } -} -#endif - -// XXX just use View2D ops for this? -static void outliner_page_up_down(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int up) -{ - int dy= ar->v2d.mask.ymax-ar->v2d.mask.ymin; - - if(up == -1) dy= -dy; - ar->v2d.cur.ymin+= dy; - ar->v2d.cur.ymax+= dy; - - soops->storeflag |= SO_TREESTORE_REDRAW; -} - -/* **** do clicks on items ******* */ - -static int tree_element_active_renderlayer(bContext *C, TreeElement *te, TreeStoreElem *tselem, int set) -{ - Scene *sce; - - /* paranoia check */ - if(te->idcode!=ID_SCE) - return 0; - sce= (Scene *)tselem->id; - - if(set) { - sce->r.actlay= tselem->nr; - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, sce); - } - else { - return sce->r.actlay==tselem->nr; - } - return 0; -} - -static void tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) -{ - TreeStoreElem *tselem= TREESTORE(te); - Scene *sce; - Base *base; - Object *ob= NULL; - - /* if id is not object, we search back */ - if(te->idcode==ID_OB) ob= (Object *)tselem->id; - else { - ob= (Object *)outliner_search_back(soops, te, ID_OB); - if(ob==OBACT) return; - } - if(ob==NULL) return; - - sce= (Scene *)outliner_search_back(soops, te, ID_SCE); - if(sce && scene != sce) { - ED_screen_set_scene(C, sce); - } - - /* find associated base in current scene */ - base= object_in_scene(ob, scene); - - if(base) { - if(set==2) { - /* swap select */ - if(base->flag & SELECT) - ED_base_object_select(base, BA_DESELECT); - else - ED_base_object_select(base, BA_SELECT); - } - else { - /* deleselect all */ - scene_deselect_all(scene); - ED_base_object_select(base, BA_SELECT); - } - if(C) { - ED_base_object_activate(C, base); /* adds notifier */ - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); - } - } - - if(ob!=scene->obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); -} - -static int tree_element_active_material(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) -{ - TreeElement *tes; - Object *ob; - - /* we search for the object parent */ - ob= (Object *)outliner_search_back(soops, te, ID_OB); - // note: ob->matbits can be NULL when a local object points to a library mesh. - if(ob==NULL || ob!=OBACT || ob->matbits==NULL) return 0; // just paranoia - - /* searching in ob mat array? */ - tes= te->parent; - if(tes->idcode==ID_OB) { - if(set) { - ob->actcol= te->index+1; - ob->matbits[te->index]= 1; // make ob material active too - ob->colbits |= (1<<te->index); - } - else { - if(ob->actcol == te->index+1) - if(ob->matbits[te->index]) return 1; - } - } - /* or we search for obdata material */ - else { - if(set) { - ob->actcol= te->index+1; - ob->matbits[te->index]= 0; // make obdata material active too - ob->colbits &= ~(1<<te->index); - } - else { - if(ob->actcol == te->index+1) - if(ob->matbits[te->index]==0) return 1; - } - } - if(set) { - WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING, NULL); - } - return 0; -} - -static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) -{ - TreeElement *tep; - TreeStoreElem /* *tselem,*/ *tselemp; - Object *ob=OBACT; - SpaceButs *sbuts=NULL; - - if(ob==NULL) return 0; // no active object - - /*tselem= TREESTORE(te);*/ /*UNUSED*/ - - /* find buttons area (note, this is undefined really still, needs recode in blender) */ - /* XXX removed finding sbuts */ - - /* where is texture linked to? */ - tep= te->parent; - tselemp= TREESTORE(tep); - - if(tep->idcode==ID_WO) { - World *wrld= (World *)tselemp->id; - - if(set) { - if(sbuts) { - // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c - // XXX sbuts->texfrom= 1; - } -// XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture - wrld->texact= te->index; - } - else if(tselemp->id == (ID *)(scene->world)) { - if(wrld->texact==te->index) return 1; - } - } - else if(tep->idcode==ID_LA) { - Lamp *la= (Lamp *)tselemp->id; - if(set) { - if(sbuts) { - // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c - // XXX sbuts->texfrom= 2; - } -// XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture - la->texact= te->index; - } - else { - if(tselemp->id == ob->data) { - if(la->texact==te->index) return 1; - } - } - } - else if(tep->idcode==ID_MA) { - Material *ma= (Material *)tselemp->id; - if(set) { - if(sbuts) { - //sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c - // XXX sbuts->texfrom= 0; - } -// XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture - ma->texact= (char)te->index; - - /* also set active material */ - ob->actcol= tep->index+1; - } - else if(tep->flag & TE_ACTIVE) { // this is active material - if(ma->texact==te->index) return 1; - } - } - - if(set) - WM_event_add_notifier(C, NC_TEXTURE, NULL); - - return 0; -} - - -static int tree_element_active_lamp(bContext *UNUSED(C), Scene *scene, SpaceOops *soops, TreeElement *te, int set) -{ - Object *ob; - - /* we search for the object parent */ - ob= (Object *)outliner_search_back(soops, te, ID_OB); - if(ob==NULL || ob!=OBACT) return 0; // just paranoia - - if(set) { -// XXX extern_set_butspace(F5KEY, 0); - } - else return 1; - - return 0; -} - -static int tree_element_active_camera(bContext *UNUSED(C), Scene *scene, SpaceOops *soops, TreeElement *te, int set) -{ - Object *ob= (Object *)outliner_search_back(soops, te, ID_OB); - - if(set) - return 0; - - return scene->camera == ob; -} - -static int tree_element_active_world(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) -{ - TreeElement *tep; - TreeStoreElem *tselem=NULL; - Scene *sce=NULL; - - tep= te->parent; - if(tep) { - tselem= TREESTORE(tep); - sce= (Scene *)tselem->id; - } - - if(set) { // make new scene active - if(sce && scene != sce) { - ED_screen_set_scene(C, sce); - } - } - - if(tep==NULL || tselem->id == (ID *)scene) { - if(set) { -// XXX extern_set_butspace(F8KEY, 0); - } - else { - return 1; - } - } - return 0; -} - -static int tree_element_active_defgroup(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) -{ - Object *ob; - - /* id in tselem is object */ - ob= (Object *)tselem->id; - if(set) { - ob->actdef= te->index+1; - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); - } - else { - if(ob==OBACT) - if(ob->actdef== te->index+1) return 1; - } - return 0; -} - -static int tree_element_active_posegroup(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) -{ - Object *ob= (Object *)tselem->id; - - if(set) { - if (ob->pose) { - ob->pose->active_group= te->index+1; - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - } - } - else { - if(ob==OBACT && ob->pose) { - if (ob->pose->active_group== te->index+1) return 1; - } - } - return 0; -} - -static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) -{ - Object *ob= (Object *)tselem->id; - bArmature *arm= ob->data; - bPoseChannel *pchan= te->directdata; - - if(set) { - if(!(pchan->bone->flag & BONE_HIDDEN_P)) { - - if(set==2) ED_pose_deselectall(ob, 2); // 2 = clear active tag - else ED_pose_deselectall(ob, 0); // 0 = deselect - - if(set==2 && (pchan->bone->flag & BONE_SELECTED)) { - pchan->bone->flag &= ~BONE_SELECTED; - } else { - pchan->bone->flag |= BONE_SELECTED; - arm->act_bone= pchan->bone; - } - - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, ob); - - } - } - else { - if(ob==OBACT && ob->pose) { - if (pchan->bone->flag & BONE_SELECTED) return 1; - } - } - return 0; -} - -static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) -{ - bArmature *arm= (bArmature *)tselem->id; - Bone *bone= te->directdata; - - if(set) { - if(!(bone->flag & BONE_HIDDEN_P)) { - if(set==2) ED_pose_deselectall(OBACT, 2); // 2 is clear active tag - else ED_pose_deselectall(OBACT, 0); - - if(set==2 && (bone->flag & BONE_SELECTED)) { - bone->flag &= ~BONE_SELECTED; - } else { - bone->flag |= BONE_SELECTED; - arm->act_bone= bone; - } - - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, OBACT); - } - } - else { - Object *ob= OBACT; - - if(ob && ob->data==arm) { - if (bone->flag & BONE_SELECTED) return 1; - } - } - return 0; -} - - -/* ebones only draw in editmode armature */ -static void tree_element_active_ebone__sel(bContext *C, Scene *scene, bArmature *arm, EditBone *ebone, short sel) -{ - if(sel) { - ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL; - arm->act_edbone= ebone; - // flush to parent? - if(ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL; - } - else { - ebone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL); - // flush to parent? - if(ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag &= ~BONE_TIPSEL; - } - - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, scene->obedit); -} -static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) -{ - bArmature *arm= scene->obedit->data; - EditBone *ebone= te->directdata; - - if(set==1) { - if(!(ebone->flag & BONE_HIDDEN_A)) { - ED_armature_deselect_all(scene->obedit, 0); // deselect - tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); - return 1; - } - } - else if (set==2) { - if(!(ebone->flag & BONE_HIDDEN_A)) { - if(!(ebone->flag & BONE_SELECTED)) { - tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); - return 1; - } - else { - /* entirely selected, so de-select */ - tree_element_active_ebone__sel(C, scene, arm, ebone, FALSE); - return 0; - } - } - } - else if (ebone->flag & BONE_SELECTED) { - return 1; - } - return 0; -} - -static int tree_element_active_modifier(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) -{ - if(set) { - Object *ob= (Object *)tselem->id; - - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); - -// XXX extern_set_butspace(F9KEY, 0); - } - - return 0; -} - -static int tree_element_active_psys(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) -{ - if(set) { - Object *ob= (Object *)tselem->id; - - WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob); - -// XXX extern_set_butspace(F7KEY, 0); - } - - return 0; -} - -static int tree_element_active_constraint(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) -{ - if(set) { - Object *ob= (Object *)tselem->id; - - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); -// XXX extern_set_butspace(F7KEY, 0); - } - - return 0; -} - -static int tree_element_active_text(bContext *UNUSED(C), Scene *UNUSED(scene), SpaceOops *UNUSED(soops), TreeElement *UNUSED(te), int UNUSED(set)) -{ - // XXX removed - return 0; -} - -/* generic call for ID data check or make/check active in UI */ -static int tree_element_active(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) -{ - - switch(te->idcode) { - case ID_MA: - return tree_element_active_material(C, scene, soops, te, set); - case ID_WO: - return tree_element_active_world(C, scene, soops, te, set); - case ID_LA: - return tree_element_active_lamp(C, scene, soops, te, set); - case ID_TE: - return tree_element_active_texture(C, scene, soops, te, set); - case ID_TXT: - return tree_element_active_text(C, scene, soops, te, set); - case ID_CA: - return tree_element_active_camera(C, scene, soops, te, set); - } - return 0; -} - -static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) -{ - Object *ob= (Object *)tselem->id; - Base *base= object_in_scene(ob, scene); - - if(set) { - if(scene->obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); - - if(ob->mode & OB_MODE_POSE) - ED_armature_exit_posemode(C, base); - else - ED_armature_enter_posemode(C, base); - } - else { - if(ob->mode & OB_MODE_POSE) return 1; - } - return 0; -} - -static int tree_element_active_sequence(TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) -{ - Sequence *seq= (Sequence*) te->directdata; - - if(set) { -// XXX select_single_seq(seq, 1); - } - else { - if(seq->flag & SELECT) - return(1); - } - return(0); -} - -static int tree_element_active_sequence_dup(Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) -{ - Sequence *seq, *p; - Editing *ed= seq_give_editing(scene, FALSE); - - seq= (Sequence*)te->directdata; - if(set==0) { - if(seq->flag & SELECT) - return(1); - return(0); - } - -// XXX select_single_seq(seq, 1); - p= ed->seqbasep->first; - while(p) { - if((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { - p= p->next; - continue; - } - -// if(!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) -// XXX select_single_seq(p, 0); - p= p->next; - } - return(0); -} - -static int tree_element_active_keymap_item(bContext *UNUSED(C), TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) -{ - wmKeyMapItem *kmi= te->directdata; - - if(set==0) { - if(kmi->flag & KMI_INACTIVE) return 0; - return 1; - } - else { - kmi->flag ^= KMI_INACTIVE; - } - return 0; -} - - -/* generic call for non-id data to make/check active in UI */ -/* Context can be NULL when set==0 */ -static int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, int set) -{ - switch(tselem->type) { - case TSE_DEFGROUP: - return tree_element_active_defgroup(C, scene, te, tselem, set); - case TSE_BONE: - return tree_element_active_bone(C, scene, te, tselem, set); - case TSE_EBONE: - return tree_element_active_ebone(C, scene, te, tselem, set); - case TSE_MODIFIER: - return tree_element_active_modifier(C, te, tselem, set); - case TSE_LINKED_OB: - if(set) tree_element_set_active_object(C, scene, soops, te, set); - else if(tselem->id==(ID *)OBACT) return 1; - break; - case TSE_LINKED_PSYS: - return tree_element_active_psys(C, scene, te, tselem, set); - case TSE_POSE_BASE: - return tree_element_active_pose(C, scene, te, tselem, set); - case TSE_POSE_CHANNEL: - return tree_element_active_posechannel(C, scene, te, tselem, set); - case TSE_CONSTRAINT: - return tree_element_active_constraint(C, te, tselem, set); - case TSE_R_LAYER: - return tree_element_active_renderlayer(C, te, tselem, set); - case TSE_POSEGRP: - return tree_element_active_posegroup(C, scene, te, tselem, set); - case TSE_SEQUENCE: - return tree_element_active_sequence(te, tselem, set); - case TSE_SEQUENCE_DUP: - return tree_element_active_sequence_dup(scene, te, tselem, set); - case TSE_KEYMAP_ITEM: - return tree_element_active_keymap_item(C, te, tselem, set); - - } - return 0; -} - -static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int extend, const float mval[2]) -{ - - if(mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) { - TreeStoreElem *tselem= TREESTORE(te); - int openclose= 0; - - /* open close icon */ - if((te->flag & TE_ICONROW)==0) { // hidden icon, no open/close - if( mval[0]>te->xs && mval[0]<te->xs+UI_UNIT_X) - openclose= 1; - } - - if(openclose) { - /* all below close/open? */ - if(extend) { - tselem->flag &= ~TSE_CLOSED; - outliner_set_flag(soops, &te->subtree, TSE_CLOSED, !outliner_has_one_flag(soops, &te->subtree, TSE_CLOSED, 1)); - } - else { - if(tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; - else tselem->flag |= TSE_CLOSED; - - } - - return 1; - } - /* name and first icon */ - else if(mval[0]>te->xs+UI_UNIT_X && mval[0]<te->xend) { - - /* always makes active object */ - if(tselem->type!=TSE_SEQUENCE && tselem->type!=TSE_SEQ_STRIP && tselem->type!=TSE_SEQUENCE_DUP) - tree_element_set_active_object(C, scene, soops, te, 1 + (extend!=0 && tselem->type==0)); - - if(tselem->type==0) { // the lib blocks - /* editmode? */ - if(te->idcode==ID_SCE) { - if(scene!=(Scene *)tselem->id) { - ED_screen_set_scene(C, (Scene *)tselem->id); - } - } - else if(te->idcode==ID_GR) { - Group *gr= (Group *)tselem->id; - GroupObject *gob; - - if(extend) { - int sel= BA_SELECT; - for(gob= gr->gobject.first; gob; gob= gob->next) { - if(gob->ob->flag & SELECT) { - sel= BA_DESELECT; - break; - } - } - - for(gob= gr->gobject.first; gob; gob= gob->next) { - ED_base_object_select(object_in_scene(gob->ob, scene), sel); - } - } - else { - scene_deselect_all(scene); - - for(gob= gr->gobject.first; gob; gob= gob->next) { - if((gob->ob->flag & SELECT) == 0) - ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT); - } - } - - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); - } - else if(ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) { - WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL); - } else { // rest of types - tree_element_active(C, scene, soops, te, 1); - } - - } - else tree_element_type_active(C, scene, soops, te, tselem, 1+(extend!=0)); - - return 1; - } - } - - for(te= te->subtree.first; te; te= te->next) { - if(do_outliner_item_activate(C, scene, ar, soops, te, extend, mval)) return 1; - } - return 0; -} - -/* event can enterkey, then it opens/closes */ -static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) -{ - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - TreeElement *te; - float fmval[2]; - int extend= RNA_boolean_get(op->ptr, "extend"); - - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); - - if(!ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && !(soops->flag & SO_HIDE_RESTRICTCOLS) && fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX) - return OPERATOR_CANCELLED; - - for(te= soops->tree.first; te; te= te->next) { - if(do_outliner_item_activate(C, scene, ar, soops, te, extend, fmval)) break; - } - - if(te) { - ED_undo_push(C, "Outliner click event"); - } - else { - short selecting= -1; - int row; - - /* get row number - 100 here is just a dummy value since we don't need the column */ - UI_view2d_listview_view_to_cell(&ar->v2d, 1000, UI_UNIT_Y, 0.0f, OL_Y_OFFSET, - fmval[0], fmval[1], NULL, &row); - - /* select relevant row */ - outliner_select(soops, &soops->tree, &row, &selecting); - - soops->storeflag |= SO_TREESTORE_REDRAW; - - ED_undo_push(C, "Outliner selection event"); - } - - ED_region_tag_redraw(ar); - - return OPERATOR_FINISHED; -} - -void OUTLINER_OT_item_activate(wmOperatorType *ot) -{ - ot->name= "Activate Item"; - ot->idname= "OUTLINER_OT_item_activate"; - ot->description= "Handle mouse clicks to activate/select items"; - - ot->invoke= outliner_item_activate; - - ot->poll= ED_operator_outliner_active; - - RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection for activation."); -} - -/* *********** */ - -static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement *te, int all, const float mval[2]) -{ - - if(mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) { - TreeStoreElem *tselem= TREESTORE(te); - - /* all below close/open? */ - if(all) { - tselem->flag &= ~TSE_CLOSED; - outliner_set_flag(soops, &te->subtree, TSE_CLOSED, !outliner_has_one_flag(soops, &te->subtree, TSE_CLOSED, 1)); - } - else { - if(tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; - else tselem->flag |= TSE_CLOSED; - } - - return 1; - } - - for(te= te->subtree.first; te; te= te->next) { - if(do_outliner_item_openclose(C, soops, te, all, mval)) - return 1; - } - return 0; - -} - -/* event can enterkey, then it opens/closes */ -static int outliner_item_openclose(bContext *C, wmOperator *op, wmEvent *event) -{ - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - TreeElement *te; - float fmval[2]; - int all= RNA_boolean_get(op->ptr, "all"); - - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); - - for(te= soops->tree.first; te; te= te->next) { - if(do_outliner_item_openclose(C, soops, te, all, fmval)) - break; - } - - ED_region_tag_redraw(ar); - - return OPERATOR_FINISHED; -} - -void OUTLINER_OT_item_openclose(wmOperatorType *ot) -{ - ot->name= "Open/Close Item"; - ot->idname= "OUTLINER_OT_item_openclose"; - ot->description= "Toggle whether item under cursor is enabled or closed"; - - ot->invoke= outliner_item_openclose; - - ot->poll= ED_operator_outliner_active; - - RNA_def_boolean(ot->srna, "all", 1, "All", "Close or open all items."); - -} - - -/* ********************************************** */ - -static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, TreeElement *te, const float mval[2]) -{ - - if(mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) { - TreeStoreElem *tselem= TREESTORE(te); - - /* name and first icon */ - if(mval[0]>te->xs+UI_UNIT_X && mval[0]<te->xend) { - - /* can't rename rna datablocks entries */ - if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) - ; - else if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) - error("Cannot edit builtin name"); - else if(ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) - error("Cannot edit sequence name"); - else if(tselem->id->lib) { - // XXX error_libdata(); - } - else if(te->idcode == ID_LI && te->parent) { - error("Cannot edit the path of an indirectly linked library"); - } - else { - tselem->flag |= TSE_TEXTBUT; - ED_region_tag_redraw(ar); - } - } - return 1; - } - - for(te= te->subtree.first; te; te= te->next) { - if(do_outliner_item_rename(C, ar, soops, te, mval)) return 1; - } - return 0; -} - -static int outliner_item_rename(bContext *C, wmOperator *UNUSED(op), wmEvent *event) -{ - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - TreeElement *te; - float fmval[2]; - - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); - - for(te= soops->tree.first; te; te= te->next) { - if(do_outliner_item_rename(C, ar, soops, te, fmval)) break; - } - - return OPERATOR_FINISHED; -} - - -void OUTLINER_OT_item_rename(wmOperatorType *ot) -{ - ot->name= "Rename Item"; - ot->idname= "OUTLINER_OT_item_rename"; - ot->description= "Rename item under cursor"; - - ot->invoke= outliner_item_rename; - - ot->poll= ED_operator_outliner_active; -} - -static TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id) -{ - TreeElement *te, *tes; - TreeStoreElem *tselem; - - for(te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if(tselem->type==0) { - if(tselem->id==id) return te; - /* only deeper on scene or object */ - if( te->idcode==ID_OB || te->idcode==ID_SCE || (soops->outlinevis == SO_GROUPS && te->idcode==ID_GR)) { - tes= outliner_find_id(soops, &te->subtree, id); - if(tes) return tes; - } - } - } - return NULL; -} - -static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) -{ - SpaceOops *so= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - View2D *v2d= &ar->v2d; - - TreeElement *te; - int xdelta, ytop; - - // TODO: make this get this info from context instead... - if (OBACT == NULL) - return OPERATOR_CANCELLED; - - te= outliner_find_id(so, &so->tree, (ID *)OBACT); - if (te) { - /* make te->ys center of view */ - ytop= (int)(te->ys + (v2d->mask.ymax - v2d->mask.ymin)/2); - if (ytop>0) ytop= 0; - - v2d->cur.ymax= (float)ytop; - v2d->cur.ymin= (float)(ytop-(v2d->mask.ymax - v2d->mask.ymin)); - - /* make te->xs ==> te->xend center of view */ - xdelta = (int)(te->xs - v2d->cur.xmin); - v2d->cur.xmin += xdelta; - v2d->cur.xmax += xdelta; - - so->storeflag |= SO_TREESTORE_REDRAW; - } - - ED_region_tag_redraw(ar); - - return OPERATOR_FINISHED; -} - -void OUTLINER_OT_show_active(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Show Active"; - ot->idname= "OUTLINER_OT_show_active"; - ot->description= "Adjust the view so that the active Object is shown centered"; - - /* callbacks */ - ot->exec= outliner_show_active_exec; - ot->poll= ED_operator_outliner_active; -} - -/* tse is not in the treestore, we use its contents to find a match */ -static TreeElement *outliner_find_tse(SpaceOops *soops, TreeStoreElem *tse) -{ - TreeStore *ts= soops->treestore; - TreeStoreElem *tselem; - int a; - - if(tse->id==NULL) return NULL; - - /* check if 'tse' is in treestore */ - tselem= ts->data; - for(a=0; a<ts->usedelem; a++, tselem++) { - if((tse->type==0 && tselem->type==0) || (tselem->type==tse->type && tselem->nr==tse->nr)) { - if(tselem->id==tse->id) { - break; - } - } - } - if(tselem) - return outliner_find_tree_element(&soops->tree, a); - - return NULL; -} - - -/* Called to find an item based on name. - */ -#if 0 - -/* recursive helper for function below */ -static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te, int startx, int *starty) -{ - TreeStoreElem *tselem= TREESTORE(te); - - /* store coord and continue, we need coordinates for elements outside view too */ - te->xs= (float)startx; - te->ys= (float)(*starty); - *starty-= UI_UNIT_Y; - - if((tselem->flag & TSE_CLOSED)==0) { - TreeElement *ten; - for(ten= te->subtree.first; ten; ten= ten->next) { - outliner_set_coordinates_element(soops, ten, startx+UI_UNIT_X, starty); - } - } - -} - -/* to retrieve coordinates with redrawing the entire tree */ -static void outliner_set_coordinates(ARegion *ar, SpaceOops *soops) -{ - TreeElement *te; - int starty= (int)(ar->v2d.tot.ymax)-UI_UNIT_Y; - int startx= 0; - - for(te= soops->tree.first; te; te= te->next) { - outliner_set_coordinates_element(soops, te, startx, &starty); - } -} - -/* find next element that has this name */ -static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *name, int flags, TreeElement *prev, int *prevFound) -{ - TreeElement *te, *tes; - - for (te= lb->first; te; te= te->next) { - int found = outliner_filter_has_name(te, name, flags); - - if(found) { - /* name is right, but is element the previous one? */ - if (prev) { - if ((te != prev) && (*prevFound)) - return te; - if (te == prev) { - *prevFound = 1; - } - } - else - return te; - } - - tes= outliner_find_named(soops, &te->subtree, name, flags, prev, prevFound); - if(tes) return tes; - } - - /* nothing valid found */ - return NULL; -} - -static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int again, int flags) -{ - TreeElement *te= NULL; - TreeElement *last_find; - TreeStoreElem *tselem; - int ytop, xdelta, prevFound=0; - char name[32]; - - /* get last found tree-element based on stored search_tse */ - last_find= outliner_find_tse(soops, &soops->search_tse); - - /* determine which type of search to do */ - if (again && last_find) { - /* no popup panel - previous + user wanted to search for next after previous */ - BLI_strncpy(name, soops->search_string, sizeof(name)); - flags= soops->search_flags; - - /* try to find matching element */ - te= outliner_find_named(soops, &soops->tree, name, flags, last_find, &prevFound); - if (te==NULL) { - /* no more matches after previous, start from beginning again */ - prevFound= 1; - te= outliner_find_named(soops, &soops->tree, name, flags, last_find, &prevFound); - } - } - else { - /* pop up panel - no previous, or user didn't want search after previous */ - strcpy(name, ""); -// XXX if (sbutton(name, 0, sizeof(name)-1, "Find: ") && name[0]) { -// te= outliner_find_named(soops, &soops->tree, name, flags, NULL, &prevFound); -// } -// else return; /* XXX RETURN! XXX */ - } - - /* do selection and reveal */ - if (te) { - tselem= TREESTORE(te); - if (tselem) { - /* expand branches so that it will be visible, we need to get correct coordinates */ - if( outliner_open_back(soops, te)) - outliner_set_coordinates(ar, soops); - - /* deselect all visible, and select found element */ - outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); - tselem->flag |= TSE_SELECTED; - - /* make te->ys center of view */ - ytop= (int)(te->ys + (ar->v2d.mask.ymax-ar->v2d.mask.ymin)/2); - if(ytop>0) ytop= 0; - ar->v2d.cur.ymax= (float)ytop; - ar->v2d.cur.ymin= (float)(ytop-(ar->v2d.mask.ymax-ar->v2d.mask.ymin)); - - /* make te->xs ==> te->xend center of view */ - xdelta = (int)(te->xs - ar->v2d.cur.xmin); - ar->v2d.cur.xmin += xdelta; - ar->v2d.cur.xmax += xdelta; - - /* store selection */ - soops->search_tse= *tselem; - - BLI_strncpy(soops->search_string, name, 33); - soops->search_flags= flags; - - /* redraw */ - soops->storeflag |= SO_TREESTORE_REDRAW; - } - } - else { - /* no tree-element found */ - error("Not found: %s", name); - } -} -#endif - -/* helper function for tree_element_shwo_hierarchy() - recursively checks whether subtrees have any objects*/ -static int subtree_has_objects(SpaceOops *soops, ListBase *lb) -{ - TreeElement *te; - TreeStoreElem *tselem; - - for(te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if(tselem->type==0 && te->idcode==ID_OB) return 1; - if( subtree_has_objects(soops, &te->subtree)) return 1; - } - return 0; -} - -/* recursive helper function for Show Hierarchy operator */ -static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase *lb) -{ - TreeElement *te; - TreeStoreElem *tselem; - - /* open all object elems, close others */ - for(te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - - if(tselem->type==0) { - if(te->idcode==ID_SCE) { - if(tselem->id!=(ID *)scene) tselem->flag |= TSE_CLOSED; - else tselem->flag &= ~TSE_CLOSED; - } - else if(te->idcode==ID_OB) { - if(subtree_has_objects(soops, &te->subtree)) tselem->flag &= ~TSE_CLOSED; - else tselem->flag |= TSE_CLOSED; - } - } - else tselem->flag |= TSE_CLOSED; - - if(tselem->flag & TSE_CLOSED); else tree_element_show_hierarchy(scene, soops, &te->subtree); - } -} - -/* show entire object level hierarchy */ -static int outliner_show_hierarchy_exec(bContext *C, wmOperator *UNUSED(op)) -{ - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); - - /* recursively open/close levels */ - tree_element_show_hierarchy(scene, soops, &soops->tree); - - ED_region_tag_redraw(ar); - - return OPERATOR_FINISHED; -} - -void OUTLINER_OT_show_hierarchy(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Show Hierarchy"; - ot->idname= "OUTLINER_OT_show_hierarchy"; - ot->description= "Open all object entries and close all others"; - - /* callbacks */ - ot->exec= outliner_show_hierarchy_exec; - ot->poll= ED_operator_outliner_active; // TODO: shouldn't be allowed in RNA views... - - /* no undo or registry, UI option */ -} - -void outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *selecting) -{ - TreeElement *te; - TreeStoreElem *tselem; - - for (te= lb->first; te && *index >= 0; te=te->next, (*index)--) { - tselem= TREESTORE(te); - - /* if we've encountered the right item, set its 'Outliner' selection status */ - if (*index == 0) { - /* this should be the last one, so no need to do anything with index */ - if ((te->flag & TE_ICONROW)==0) { - /* -1 value means toggle testing for now... */ - if (*selecting == -1) { - if (tselem->flag & TSE_SELECTED) - *selecting= 0; - else - *selecting= 1; - } - - /* set selection */ - if (*selecting) - tselem->flag |= TSE_SELECTED; - else - tselem->flag &= ~TSE_SELECTED; - } - } - else if ((tselem->flag & TSE_CLOSED)==0) { - /* Only try selecting sub-elements if we haven't hit the right element yet - * - * Hack warning: - * Index must be reduced before supplying it to the sub-tree to try to do - * selection, however, we need to increment it again for the next loop to - * function correctly - */ - (*index)--; - outliner_select(soops, &te->subtree, index, selecting); - (*index)++; - } - } -} - -/* ************ SELECTION OPERATIONS ********* */ - -static void set_operation_types(SpaceOops *soops, ListBase *lb, - int *scenelevel, - int *objectlevel, - int *idlevel, - int *datalevel) -{ - TreeElement *te; - TreeStoreElem *tselem; - - for(te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if(tselem->flag & TSE_SELECTED) { - if(tselem->type) { - if(*datalevel==0) - *datalevel= tselem->type; - else if(*datalevel!=tselem->type) - *datalevel= -1; - } - else { - int idcode= GS(tselem->id->name); - switch(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_MA: case ID_TE: case ID_IP: case ID_IM: - case ID_SO: case ID_KE: case ID_WO: case ID_AC: - case ID_NLA: case ID_TXT: case ID_GR: - if(*idlevel==0) *idlevel= idcode; - else if(*idlevel!=idcode) *idlevel= -1; - break; - } - } - } - if((tselem->flag & TSE_CLOSED)==0) { - set_operation_types(soops, &te->subtree, - scenelevel, objectlevel, idlevel, datalevel); - } - } -} - -static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem)) -{ - Material **matar=NULL; - int a, totcol=0; - - if( GS(tsep->id->name)==ID_OB) { - Object *ob= (Object *)tsep->id; - totcol= ob->totcol; - matar= ob->mat; - } - else if( GS(tsep->id->name)==ID_ME) { - Mesh *me= (Mesh *)tsep->id; - totcol= me->totcol; - matar= me->mat; - } - else if( GS(tsep->id->name)==ID_CU) { - Curve *cu= (Curve *)tsep->id; - totcol= cu->totcol; - matar= cu->mat; - } - else if( GS(tsep->id->name)==ID_MB) { - MetaBall *mb= (MetaBall *)tsep->id; - totcol= mb->totcol; - matar= mb->mat; - } - - for(a=0; a<totcol; a++) { - if(a==te->index && matar[a]) { - matar[a]->id.us--; - matar[a]= NULL; - } - } -} - -static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem)) -{ - MTex **mtex= NULL; - int a; - - if( GS(tsep->id->name)==ID_MA) { - Material *ma= (Material *)tsep->id; - mtex= ma->mtex; - } - else if( GS(tsep->id->name)==ID_LA) { - Lamp *la= (Lamp *)tsep->id; - mtex= la->mtex; - } - else if( GS(tsep->id->name)==ID_WO) { - World *wrld= (World *)tsep->id; - mtex= wrld->mtex; - } - else return; - - for(a=0; a<MAX_MTEX; a++) { - if(a==te->index && mtex[a]) { - if(mtex[a]->tex) { - mtex[a]->tex->id.us--; - mtex[a]->tex= NULL; - } - } - } -} - -static void unlink_group_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *tselem) -{ - Group *group= (Group *)tselem->id; - - if(tsep) { - if( GS(tsep->id->name)==ID_OB) { - Object *ob= (Object *)tsep->id; - ob->dup_group= NULL; - } - } - else { - unlink_group(group); - } -} - -static void outliner_do_libdata_operation(bContext *C, Scene *scene, SpaceOops *soops, ListBase *lb, - void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) -{ - TreeElement *te; - TreeStoreElem *tselem; - - for(te=lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if(tselem->flag & TSE_SELECTED) { - if(tselem->type==0) { - TreeStoreElem *tsep= TREESTORE(te->parent); - operation_cb(C, scene, te, tsep, tselem); - } - } - if((tselem->flag & TSE_CLOSED)==0) { - outliner_do_libdata_operation(C, scene, soops, &te->subtree, operation_cb); - } - } -} - -/* */ - -static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) -{ - Base *base= (Base *)te->directdata; - - if(base==NULL) base= object_in_scene((Object *)tselem->id, scene); - if(base && ((base->object->restrictflag & OB_RESTRICT_VIEW)==0)) { - base->flag |= SELECT; - base->object->flag |= SELECT; - } -} - -static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) -{ - Base *base= (Base *)te->directdata; - - if(base==NULL) base= object_in_scene((Object *)tselem->id, scene); - if(base) { - base->flag &= ~SELECT; - base->object->flag &= ~SELECT; - } -} - -static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) -{ - Base *base= (Base *)te->directdata; - - if(base==NULL) - base= object_in_scene((Object *)tselem->id, scene); - if(base) { - // check also library later - if(scene->obedit==base->object) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); - - ED_base_object_free_and_unlink(CTX_data_main(C), scene, base); - te->directdata= NULL; - tselem->id= NULL; - } - -} - -static void id_local_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) -{ - if(tselem->id->lib && (tselem->id->flag & LIB_EXTERN)) { - tselem->id->lib= NULL; - tselem->id->flag= LIB_LOCAL; - new_id(NULL, tselem->id, NULL); - } -} - -static void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) -{ - Group *group= (Group *)tselem->id; - GroupObject *gob; - Base *base; - - for(gob=group->gobject.first; gob; gob=gob->next) { - base= object_in_scene(gob->ob, scene); - if (base) { - base->object->flag |= SELECT; - base->flag |= SELECT; - } else { - /* link to scene */ - base= MEM_callocN( sizeof(Base), "add_base"); - BLI_addhead(&scene->base, base); - base->lay= (1<<20)-1; /*v3d->lay;*/ /* would be nice to use the 3d layer but the include's not here */ - gob->ob->flag |= SELECT; - base->flag = gob->ob->flag; - base->object= gob->ob; - id_lib_extern((ID *)gob->ob); /* incase these are from a linked group */ - } - } -} - -static void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOops *soops, ListBase *lb, - void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) -{ - TreeElement *te; - TreeStoreElem *tselem; - - for(te=lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if(tselem->flag & TSE_SELECTED) { - if(tselem->type==0 && te->idcode==ID_OB) { - // when objects selected in other scenes... dunno if that should be allowed - Scene *scene_owner= (Scene *)outliner_search_back(soops, te, ID_SCE); - if(scene_owner && scene_act != scene_owner) { - ED_screen_set_scene(C, scene_owner); - } - /* important to use 'scene_owner' not scene_act else deleting objects can crash. - * only use 'scene_act' when 'scene_owner' is NULL, which can happen when the - * outliner isnt showing scenes: Visible Layer draw mode for eg. */ - operation_cb(C, scene_owner ? scene_owner : scene_act, te, NULL, tselem); - } - } - if((tselem->flag & TSE_CLOSED)==0) { - outliner_do_object_operation(C, scene_act, soops, &te->subtree, operation_cb); - } - } -} - -/* ******************************************** */ - -static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) -{ - bPoseChannel *pchan= (bPoseChannel *)te->directdata; - - if(event==1) - pchan->bone->flag |= BONE_SELECTED; - else if(event==2) - pchan->bone->flag &= ~BONE_SELECTED; - else if(event==3) { - pchan->bone->flag |= BONE_HIDDEN_P; - pchan->bone->flag &= ~BONE_SELECTED; - } - else if(event==4) - pchan->bone->flag &= ~BONE_HIDDEN_P; -} - -static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) -{ - Bone *bone= (Bone *)te->directdata; - - if(event==1) - bone->flag |= BONE_SELECTED; - else if(event==2) - bone->flag &= ~BONE_SELECTED; - else if(event==3) { - bone->flag |= BONE_HIDDEN_P; - bone->flag &= ~BONE_SELECTED; - } - else if(event==4) - bone->flag &= ~BONE_HIDDEN_P; -} - -static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) -{ - EditBone *ebone= (EditBone *)te->directdata; - - if(event==1) - ebone->flag |= BONE_SELECTED; - else if(event==2) - ebone->flag &= ~BONE_SELECTED; - else if(event==3) { - ebone->flag |= BONE_HIDDEN_A; - ebone->flag &= ~BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; - } - else if(event==4) - ebone->flag &= ~BONE_HIDDEN_A; -} - -static void sequence_cb(int event, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tselem)) -{ -// Sequence *seq= (Sequence*) te->directdata; - if(event==1) { -// XXX select_single_seq(seq, 1); - } -} - -static void outliner_do_data_operation(SpaceOops *soops, int type, int event, ListBase *lb, - void (*operation_cb)(int, TreeElement *, TreeStoreElem *)) -{ - TreeElement *te; - TreeStoreElem *tselem; - - for(te=lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if(tselem->flag & TSE_SELECTED) { - if(tselem->type==type) { - operation_cb(event, te, tselem); - } - } - if((tselem->flag & TSE_CLOSED)==0) { - outliner_do_data_operation(soops, type, event, &te->subtree, operation_cb); - } - } -} - -static void outliner_del(bContext *C, Scene *scene, ARegion *UNUSED(ar), SpaceOops *soops) -{ - - if(soops->outlinevis==SO_SEQUENCE) - ;// del_seq(); - else { - outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb); - DAG_scene_sort(CTX_data_main(C), scene); - ED_undo_push(C, "Delete Objects"); - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); - } -} - -/* **************************************** */ - -static EnumPropertyItem prop_object_op_types[] = { - {1, "SELECT", 0, "Select", ""}, - {2, "DESELECT", 0, "Deselect", ""}, - {4, "DELETE", 0, "Delete", ""}, - {6, "TOGVIS", 0, "Toggle Visible", ""}, - {7, "TOGSEL", 0, "Toggle Selectable", ""}, - {8, "TOGREN", 0, "Toggle Renderable", ""}, - {0, NULL, 0, NULL, NULL} -}; - -static int outliner_object_operation_exec(bContext *C, wmOperator *op) -{ - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - int event; - const char *str= NULL; - - /* check for invalid states */ - if (soops == NULL) - return OPERATOR_CANCELLED; - - event= RNA_enum_get(op->ptr, "type"); - - if(event==1) { - Scene *sce= scene; // to be able to delete, scenes are set... - outliner_do_object_operation(C, scene, soops, &soops->tree, object_select_cb); - if(scene != sce) { - ED_screen_set_scene(C, sce); - } - - str= "Select Objects"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); - } - else if(event==2) { - outliner_do_object_operation(C, scene, soops, &soops->tree, object_deselect_cb); - str= "Deselect Objects"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); - } - else if(event==4) { - outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb); - DAG_scene_sort(bmain, scene); - str= "Delete Objects"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); - } - else if(event==5) { /* disabled, see above enum (ton) */ - outliner_do_object_operation(C, scene, soops, &soops->tree, id_local_cb); - str= "Localized Objects"; - } - else if(event==6) { - outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb); - str= "Toggle Visibility"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_VISIBLE, scene); - } - else if(event==7) { - outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_selectability_cb); - str= "Toggle Selectability"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); - } - else if(event==8) { - outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb); - str= "Toggle Renderability"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, scene); - } - - ED_undo_push(C, str); - - return OPERATOR_FINISHED; -} - - -void OUTLINER_OT_object_operation(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Outliner Object Operation"; - ot->idname= "OUTLINER_OT_object_operation"; - ot->description= ""; - - /* callbacks */ - ot->invoke= WM_menu_invoke; - ot->exec= outliner_object_operation_exec; - ot->poll= ED_operator_outliner_active; - - ot->flag= 0; - - ot->prop= RNA_def_enum(ot->srna, "type", prop_object_op_types, 0, "Object Operation", ""); -} - -/* **************************************** */ - -static EnumPropertyItem prop_group_op_types[] = { - {1, "UNLINK", 0, "Unlink", ""}, - {2, "LOCAL", 0, "Make Local", ""}, - {3, "LINK", 0, "Link Group Objects to Scene", ""}, - {4, "TOGVIS", 0, "Toggle Visible", ""}, - {5, "TOGSEL", 0, "Toggle Selectable", ""}, - {6, "TOGREN", 0, "Toggle Renderable", ""}, - {0, NULL, 0, NULL, NULL} -}; - -static int outliner_group_operation_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - int event; - - /* check for invalid states */ - if (soops == NULL) - return OPERATOR_CANCELLED; - - event= RNA_enum_get(op->ptr, "type"); - - if(event==1) { - outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb); - ED_undo_push(C, "Unlink group"); - } - else if(event==2) { - outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); - ED_undo_push(C, "Localized Data"); - } - else if(event==3) { - outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb); - ED_undo_push(C, "Link Group Objects to Scene"); - } - - - WM_event_add_notifier(C, NC_GROUP, NULL); - - return OPERATOR_FINISHED; -} - - -void OUTLINER_OT_group_operation(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Outliner Group Operation"; - ot->idname= "OUTLINER_OT_group_operation"; - ot->description= ""; - - /* callbacks */ - ot->invoke= WM_menu_invoke; - ot->exec= outliner_group_operation_exec; - ot->poll= ED_operator_outliner_active; - - ot->flag= 0; - - ot->prop= RNA_def_enum(ot->srna, "type", prop_group_op_types, 0, "Group Operation", ""); -} - -/* **************************************** */ - -static EnumPropertyItem prop_id_op_types[] = { - {1, "UNLINK", 0, "Unlink", ""}, - {2, "LOCAL", 0, "Make Local", ""}, - {0, NULL, 0, NULL, NULL} -}; - -static int outliner_id_operation_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; - int event; - - /* check for invalid states */ - if (soops == NULL) - return OPERATOR_CANCELLED; - - set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - - event= RNA_enum_get(op->ptr, "type"); - - if(event==1) { - switch(idlevel) { - case ID_MA: - outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_material_cb); - ED_undo_push(C, "Unlink material"); - break; - case ID_TE: - outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_texture_cb); - ED_undo_push(C, "Unlink texture"); - break; - default: - BKE_report(op->reports, RPT_WARNING, "Not Yet"); - } - } - else if(event==2) { - outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); - ED_undo_push(C, "Localized Data"); - } - - /* wrong notifier still... */ - WM_event_add_notifier(C, NC_OBJECT, NULL); - - return OPERATOR_FINISHED; -} - - -void OUTLINER_OT_id_operation(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Outliner ID data Operation"; - ot->idname= "OUTLINER_OT_id_operation"; - ot->description= ""; - - /* callbacks */ - ot->invoke= WM_menu_invoke; - ot->exec= outliner_id_operation_exec; - ot->poll= ED_operator_outliner_active; - - ot->flag= 0; - - ot->prop= RNA_def_enum(ot->srna, "type", prop_id_op_types, 0, "ID data Operation", ""); -} - -/* **************************************** */ - -static EnumPropertyItem prop_data_op_types[] = { - {1, "SELECT", 0, "Select", ""}, - {2, "DESELECT", 0, "Deselect", ""}, - {3, "HIDE", 0, "Hide", ""}, - {4, "UNHIDE", 0, "Unhide", ""}, - {0, NULL, 0, NULL, NULL} -}; - -static int outliner_data_operation_exec(bContext *C, wmOperator *op) -{ - SpaceOops *soops= CTX_wm_space_outliner(C); - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; - int event; - - /* check for invalid states */ - if (soops == NULL) - return OPERATOR_CANCELLED; - - event= RNA_enum_get(op->ptr, "type"); - set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - - if(datalevel==TSE_POSE_CHANNEL) { - if(event>0) { - outliner_do_data_operation(soops, datalevel, event, &soops->tree, pchan_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); - ED_undo_push(C, "PoseChannel operation"); - } - } - else if(datalevel==TSE_BONE) { - if(event>0) { - outliner_do_data_operation(soops, datalevel, event, &soops->tree, bone_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); - ED_undo_push(C, "Bone operation"); - } - } - else if(datalevel==TSE_EBONE) { - if(event>0) { - outliner_do_data_operation(soops, datalevel, event, &soops->tree, ebone_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); - ED_undo_push(C, "EditBone operation"); - } - } - else if(datalevel==TSE_SEQUENCE) { - if(event>0) { - outliner_do_data_operation(soops, datalevel, event, &soops->tree, sequence_cb); - } - } - - return OPERATOR_FINISHED; -} - - -void OUTLINER_OT_data_operation(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Outliner Data Operation"; - ot->idname= "OUTLINER_OT_data_operation"; - ot->description= ""; - - /* callbacks */ - ot->invoke= WM_menu_invoke; - ot->exec= outliner_data_operation_exec; - ot->poll= ED_operator_outliner_active; - - ot->flag= 0; - - ot->prop= RNA_def_enum(ot->srna, "type", prop_data_op_types, 0, "Data Operation", ""); -} - - -/* ******************** */ - - -static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, wmEvent *event, const float mval[2]) -{ - - 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); - - /* select object that's clicked on and popup context menu */ - if (!(tselem->flag & TSE_SELECTED)) { - - if ( outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1) ) - outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); - - tselem->flag |= TSE_SELECTED; - /* redraw, same as outliner_select function */ - soops->storeflag |= SO_TREESTORE_REDRAW; - ED_region_tag_redraw(ar); - } - - set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - - if(scenelevel) { - //if(objectlevel || datalevel || idlevel) error("Mixed selection"); - //else pupmenu("Scene Operations%t|Delete"); - } - else if(objectlevel) { - WM_operator_name_call(C, "OUTLINER_OT_object_operation", WM_OP_INVOKE_REGION_WIN, NULL); - } - else if(idlevel) { - if(idlevel==-1 || datalevel) error("Mixed selection"); - else { - if (idlevel==ID_GR) - WM_operator_name_call(C, "OUTLINER_OT_group_operation", WM_OP_INVOKE_REGION_WIN, NULL); - else - WM_operator_name_call(C, "OUTLINER_OT_id_operation", WM_OP_INVOKE_REGION_WIN, NULL); - } - } - else if(datalevel) { - if(datalevel==-1) error("Mixed selection"); - else { - WM_operator_name_call(C, "OUTLINER_OT_data_operation", WM_OP_INVOKE_REGION_WIN, NULL); - } - } - - return 1; - } - - for(te= te->subtree.first; te; te= te->next) { - if(do_outliner_operation_event(C, scene, ar, soops, te, event, mval)) - return 1; - } - return 0; -} - - -static int outliner_operation(bContext *C, wmOperator *UNUSED(op), wmEvent *event) -{ - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - TreeElement *te; - float fmval[2]; - - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); - - for(te= soops->tree.first; te; te= te->next) { - if(do_outliner_operation_event(C, scene, ar, soops, te, event, fmval)) break; - } - - return OPERATOR_FINISHED; -} - -/* Menu only! Calls other operators */ -void OUTLINER_OT_operation(wmOperatorType *ot) -{ - ot->name= "Execute Operation"; - ot->idname= "OUTLINER_OT_operation"; - ot->description= "Context menu for item operations"; - - ot->invoke= outliner_operation; - - ot->poll= ED_operator_outliner_active; -} - - - -/* ***************** ANIMATO OPERATIONS ********************************** */ -/* KeyingSet and Driver Creation - Helper functions */ - -/* specialised poll callback for these operators to work in Datablocks view only */ -static int ed_operator_outliner_datablocks_active(bContext *C) -{ - ScrArea *sa= CTX_wm_area(C); - if ((sa) && (sa->spacetype==SPACE_OUTLINER)) { - SpaceOops *so= CTX_wm_space_outliner(C); - return (so->outlinevis == SO_DATABLOCKS); - } - return 0; -} - - -/* Helper func to extract an RNA path from selected tree element - * NOTE: the caller must zero-out all values of the pointers that it passes here first, as - * this function does not do that yet - */ -static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, - ID **id, char **path, int *array_index, short *flag, short *UNUSED(groupmode)) -{ - ListBase hierarchy = {NULL, NULL}; - LinkData *ld; - TreeElement *tem, *temnext, *temsub; - TreeStoreElem *tse, *tsenext; - PointerRNA *ptr, *nextptr; - PropertyRNA *prop; - char *newpath=NULL; - - /* optimise tricks: - * - Don't do anything if the selected item is a 'struct', but arrays are allowed - */ - if (tselem->type == TSE_RNA_STRUCT) - return; - - /* Overview of Algorithm: - * 1. Go up the chain of parents until we find the 'root', taking note of the - * levels encountered in reverse-order (i.e. items are added to the start of the list - * for more convenient looping later) - * 2. Walk down the chain, adding from the first ID encountered - * (which will become the 'ID' for the KeyingSet Path), and build a - * path as we step through the chain - */ - - /* step 1: flatten out hierarchy of parents into a flat chain */ - for (tem= te->parent; tem; tem= tem->parent) { - ld= MEM_callocN(sizeof(LinkData), "LinkData for tree_element_to_path()"); - ld->data= tem; - BLI_addhead(&hierarchy, ld); - } - - /* step 2: step down hierarchy building the path (NOTE: addhead in previous loop was needed so that we can loop like this) */ - for (ld= hierarchy.first; ld; ld= ld->next) { - /* get data */ - tem= (TreeElement *)ld->data; - tse= TREESTORE(tem); - ptr= &tem->rnaptr; - prop= tem->directdata; - - /* check if we're looking for first ID, or appending to path */ - if (*id) { - /* just 'append' property to path - * - to prevent memory leaks, we must write to newpath not path, then free old path + swap them - */ - if(tse->type == TSE_RNA_PROPERTY) { - if(RNA_property_type(prop) == PROP_POINTER) { - /* for pointer we just append property name */ - newpath= RNA_path_append(*path, ptr, prop, 0, NULL); - } - else if(RNA_property_type(prop) == PROP_COLLECTION) { - char buf[128], *name; - - temnext= (TreeElement*)(ld->next->data); - tsenext= TREESTORE(temnext); - - nextptr= &temnext->rnaptr; - name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf)); - - if(name) { - /* if possible, use name as a key in the path */ - newpath= RNA_path_append(*path, NULL, prop, 0, name); - - if(name != buf) - MEM_freeN(name); - } - else { - /* otherwise use index */ - int index= 0; - - for(temsub=tem->subtree.first; temsub; temsub=temsub->next, index++) - if(temsub == temnext) - break; - - newpath= RNA_path_append(*path, NULL, prop, index, NULL); - } - - ld= ld->next; - } - } - - if(newpath) { - if (*path) MEM_freeN(*path); - *path= newpath; - newpath= NULL; - } - } - else { - /* no ID, so check if entry is RNA-struct, and if that RNA-struct is an ID datablock to extract info from */ - if (tse->type == TSE_RNA_STRUCT) { - /* ptr->data not ptr->id.data seems to be the one we want, since ptr->data is sometimes the owner of this ID? */ - if(RNA_struct_is_ID(ptr->type)) { - *id= (ID *)ptr->data; - - /* clear path */ - if(*path) { - MEM_freeN(*path); - path= NULL; - } - } - } - } - } - - /* step 3: if we've got an ID, add the current item to the path */ - if (*id) { - /* add the active property to the path */ - ptr= &te->rnaptr; - prop= te->directdata; - - /* array checks */ - if (tselem->type == TSE_RNA_ARRAY_ELEM) { - /* item is part of an array, so must set the array_index */ - *array_index= te->index; - } - else if (RNA_property_array_length(ptr, prop)) { - /* entire array was selected, so keyframe all */ - *flag |= KSP_FLAG_WHOLE_ARRAY; - } - - /* path */ - newpath= RNA_path_append(*path, NULL, prop, 0, NULL); - if (*path) MEM_freeN(*path); - *path= newpath; - } - - /* free temp data */ - BLI_freelistN(&hierarchy); -} - -/* ***************** KEYINGSET OPERATIONS *************** */ - -/* These operators are only available in databrowser mode for now, as - * they depend on having RNA paths and/or hierarchies available. - */ -enum { - DRIVERS_EDITMODE_ADD = 0, - DRIVERS_EDITMODE_REMOVE, -} /*eDrivers_EditModes*/; - -/* Utilities ---------------------------------- */ - -/* Recursively iterate over tree, finding and working on selected items */ -static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportList *reports, short mode) -{ - TreeElement *te; - TreeStoreElem *tselem; - - for (te= tree->first; te; te=te->next) { - tselem= TREESTORE(te); - - /* if item is selected, perform operation */ - if (tselem->flag & TSE_SELECTED) { - ID *id= NULL; - char *path= NULL; - int array_index= 0; - short flag= 0; - short groupmode= KSP_GROUP_KSNAME; - - /* check if RNA-property described by this selected element is an animateable prop */ - if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) { - /* get id + path + index info from the selected element */ - tree_element_to_path(soops, te, tselem, - &id, &path, &array_index, &flag, &groupmode); - } - - /* only if ID and path were set, should we perform any actions */ - if (id && path) { - short dflags = CREATEDRIVER_WITH_DEFAULT_DVAR; - int arraylen = 1; - - /* array checks */ - if (flag & KSP_FLAG_WHOLE_ARRAY) { - /* entire array was selected, so add drivers for all */ - arraylen= RNA_property_array_length(&te->rnaptr, te->directdata); - } - else - arraylen= array_index; - - /* we should do at least one step */ - if (arraylen == array_index) - arraylen++; - - /* for each array element we should affect, add driver */ - for (; array_index < arraylen; array_index++) { - /* action depends on mode */ - switch (mode) { - case DRIVERS_EDITMODE_ADD: - { - /* add a new driver with the information obtained (only if valid) */ - ANIM_add_driver(reports, id, path, array_index, dflags, DRIVER_TYPE_PYTHON); - } - break; - case DRIVERS_EDITMODE_REMOVE: - { - /* remove driver matching the information obtained (only if valid) */ - ANIM_remove_driver(reports, id, path, array_index, dflags); - } - break; - } - } - - /* free path, since it had to be generated */ - MEM_freeN(path); - } - - - } - - /* go over sub-tree */ - if ((tselem->flag & TSE_CLOSED)==0) - do_outliner_drivers_editop(soops, &te->subtree, reports, mode); - } -} - -/* Add Operator ---------------------------------- */ - -static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op) -{ - SpaceOops *soutliner= CTX_wm_space_outliner(C); - - /* check for invalid states */ - if (soutliner == NULL) - return OPERATOR_CANCELLED; - - /* recursively go into tree, adding selected items */ - do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_ADD); - - /* send notifiers */ - WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX - - return OPERATOR_FINISHED; -} - -void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot) -{ - /* api callbacks */ - ot->idname= "OUTLINER_OT_drivers_add_selected"; - ot->name= "Add Drivers for Selected"; - ot->description= "Add drivers to selected items"; - - /* api callbacks */ - ot->exec= outliner_drivers_addsel_exec; - ot->poll= ed_operator_outliner_datablocks_active; - - /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; -} - - -/* Remove Operator ---------------------------------- */ - -static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op) -{ - SpaceOops *soutliner= CTX_wm_space_outliner(C); - - /* check for invalid states */ - if (soutliner == NULL) - return OPERATOR_CANCELLED; - - /* recursively go into tree, adding selected items */ - do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_REMOVE); - - /* send notifiers */ - WM_event_add_notifier(C, ND_KEYS, NULL); // XXX - - return OPERATOR_FINISHED; -} - -void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot) -{ - /* identifiers */ - ot->idname= "OUTLINER_OT_drivers_delete_selected"; - ot->name= "Delete Drivers for Selected"; - ot->description= "Delete drivers assigned to selected items"; - - /* api callbacks */ - ot->exec= outliner_drivers_deletesel_exec; - ot->poll= ed_operator_outliner_datablocks_active; - - /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; -} - -/* ***************** KEYINGSET OPERATIONS *************** */ - -/* These operators are only available in databrowser mode for now, as - * they depend on having RNA paths and/or hierarchies available. - */ -enum { - KEYINGSET_EDITMODE_ADD = 0, - KEYINGSET_EDITMODE_REMOVE, -} /*eKeyingSet_EditModes*/; - -/* Utilities ---------------------------------- */ - -/* find the 'active' KeyingSet, and add if not found (if adding is allowed) */ -// TODO: should this be an API func? -static KeyingSet *verify_active_keyingset(Scene *scene, short add) -{ - KeyingSet *ks= NULL; - - /* sanity check */ - if (scene == NULL) - return NULL; - - /* try to find one from scene */ - if (scene->active_keyingset > 0) - ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); - - /* add if none found */ - // XXX the default settings have yet to evolve - if ((add) && (ks==NULL)) { - ks= BKE_keyingset_add(&scene->keyingsets, NULL, KEYINGSET_ABSOLUTE, 0); - scene->active_keyingset= BLI_countlist(&scene->keyingsets); - } - - return ks; -} - -/* Recursively iterate over tree, finding and working on selected items */ -static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBase *tree, short mode) -{ - TreeElement *te; - TreeStoreElem *tselem; - - for (te= tree->first; te; te=te->next) { - tselem= TREESTORE(te); - - /* if item is selected, perform operation */ - if (tselem->flag & TSE_SELECTED) { - ID *id= NULL; - char *path= NULL; - int array_index= 0; - short flag= 0; - short groupmode= KSP_GROUP_KSNAME; - - /* check if RNA-property described by this selected element is an animateable prop */ - if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) { - /* get id + path + index info from the selected element */ - tree_element_to_path(soops, te, tselem, - &id, &path, &array_index, &flag, &groupmode); - } - - /* only if ID and path were set, should we perform any actions */ - if (id && path) { - /* action depends on mode */ - switch (mode) { - case KEYINGSET_EDITMODE_ADD: - { - /* add a new path with the information obtained (only if valid) */ - // TODO: what do we do with group name? for now, we don't supply one, and just let this use the KeyingSet name - BKE_keyingset_add_path(ks, id, NULL, path, array_index, flag, groupmode); - ks->active_path= BLI_countlist(&ks->paths); - } - break; - case KEYINGSET_EDITMODE_REMOVE: - { - /* find the relevant path, then remove it from the KeyingSet */ - KS_Path *ksp= BKE_keyingset_find_path(ks, id, NULL, path, array_index, groupmode); - - if (ksp) { - /* free path's data */ - BKE_keyingset_free_path(ks, ksp); - - ks->active_path= 0; - } - } - break; - } - - /* free path, since it had to be generated */ - MEM_freeN(path); - } - } - - /* go over sub-tree */ - if ((tselem->flag & TSE_CLOSED)==0) - do_outliner_keyingset_editop(soops, ks, &te->subtree, mode); - } -} - -/* Add Operator ---------------------------------- */ - -static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op) -{ - SpaceOops *soutliner= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - KeyingSet *ks= verify_active_keyingset(scene, 1); - - /* check for invalid states */ - if (ks == NULL) { - BKE_report(op->reports, RPT_ERROR, "Operation requires an Active Keying Set"); - return OPERATOR_CANCELLED; - } - if (soutliner == NULL) - return OPERATOR_CANCELLED; - - /* recursively go into tree, adding selected items */ - do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_ADD); - - /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); - - return OPERATOR_FINISHED; -} - -void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot) -{ - /* identifiers */ - ot->idname= "OUTLINER_OT_keyingset_add_selected"; - ot->name= "Keying Set Add Selected"; - ot->description= "Add selected items (blue-grey rows) to active Keying Set"; - - /* api callbacks */ - ot->exec= outliner_keyingset_additems_exec; - ot->poll= ed_operator_outliner_datablocks_active; - - /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; -} - - -/* Remove Operator ---------------------------------- */ - -static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(op)) -{ - SpaceOops *soutliner= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - KeyingSet *ks= verify_active_keyingset(scene, 1); - - /* check for invalid states */ - if (soutliner == NULL) - return OPERATOR_CANCELLED; - - /* recursively go into tree, adding selected items */ - do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_REMOVE); - - /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); - - return OPERATOR_FINISHED; -} - -void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) -{ - /* identifiers */ - ot->idname= "OUTLINER_OT_keyingset_remove_selected"; - ot->name= "Keying Set Remove Selected"; - ot->description = "Remove selected items (blue-grey rows) from active Keying Set"; - - /* api callbacks */ - ot->exec= outliner_keyingset_removeitems_exec; - ot->poll= ed_operator_outliner_datablocks_active; - - /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; -} - -/* ***************** DRAW *************** */ - -/* make function calls a bit compacter */ -struct DrawIconArg { - uiBlock *block; - ID *id; - int xmax, x, y; - float alpha; -}; - -static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon) -{ - /* restrict collumn clip... it has been coded by simply overdrawing, doesnt work for buttons */ - if(arg->x >= arg->xmax) - UI_icon_draw(arg->x, arg->y, icon); - else { - /* XXX investigate: button placement of icons is way different than UI_icon_draw? */ - float ufac= UI_UNIT_X/20.0f; - uiBut *but= uiDefIconBut(arg->block, LABEL, 0, icon, arg->x-3.0f*ufac, arg->y, UI_UNIT_X-4.0f*ufac, UI_UNIT_Y-4.0f*ufac, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && arg->id->lib) ? arg->id->lib->name : ""); - - if(arg->id) - uiButSetDragID(but, arg->id); - } - -} - -static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeStoreElem *tselem, TreeElement *te, float alpha) -{ - struct DrawIconArg arg; - - /* make function calls a bit compacter */ - arg.block= block; - arg.id= tselem->id; - arg.xmax= xmax; - arg.x= x; - arg.y= y; - arg.alpha= alpha; - - if(tselem->type) { - switch( tselem->type) { - case TSE_ANIM_DATA: - UI_icon_draw(x, y, ICON_ANIM_DATA); break; // xxx - case TSE_NLA: - UI_icon_draw(x, y, ICON_NLA); break; - case TSE_NLA_TRACK: - UI_icon_draw(x, y, ICON_NLA); break; // XXX - case TSE_NLA_ACTION: - UI_icon_draw(x, y, ICON_ACTION); break; - case TSE_DEFGROUP_BASE: - UI_icon_draw(x, y, ICON_GROUP_VERTEX); break; - case TSE_BONE: - case TSE_EBONE: - UI_icon_draw(x, y, ICON_BONE_DATA); break; - case TSE_CONSTRAINT_BASE: - UI_icon_draw(x, y, ICON_CONSTRAINT); break; - case TSE_MODIFIER_BASE: - UI_icon_draw(x, y, ICON_MODIFIER); break; - case TSE_LINKED_OB: - UI_icon_draw(x, y, ICON_OBJECT_DATA); break; - case TSE_LINKED_PSYS: - UI_icon_draw(x, y, ICON_PARTICLES); break; - case TSE_MODIFIER: - { - Object *ob= (Object *)tselem->id; - ModifierData *md= BLI_findlink(&ob->modifiers, tselem->nr); - switch(md->type) { - case eModifierType_Subsurf: - UI_icon_draw(x, y, ICON_MOD_SUBSURF); break; - case eModifierType_Armature: - UI_icon_draw(x, y, ICON_MOD_ARMATURE); break; - case eModifierType_Lattice: - UI_icon_draw(x, y, ICON_MOD_LATTICE); break; - case eModifierType_Curve: - UI_icon_draw(x, y, ICON_MOD_CURVE); break; - case eModifierType_Build: - UI_icon_draw(x, y, ICON_MOD_BUILD); break; - case eModifierType_Mirror: - UI_icon_draw(x, y, ICON_MOD_MIRROR); break; - case eModifierType_Decimate: - UI_icon_draw(x, y, ICON_MOD_DECIM); break; - case eModifierType_Wave: - UI_icon_draw(x, y, ICON_MOD_WAVE); break; - case eModifierType_Hook: - UI_icon_draw(x, y, ICON_HOOK); break; - case eModifierType_Softbody: - UI_icon_draw(x, y, ICON_MOD_SOFT); break; - case eModifierType_Boolean: - UI_icon_draw(x, y, ICON_MOD_BOOLEAN); break; - case eModifierType_ParticleSystem: - UI_icon_draw(x, y, ICON_MOD_PARTICLES); break; - case eModifierType_ParticleInstance: - UI_icon_draw(x, y, ICON_MOD_PARTICLES); break; - case eModifierType_EdgeSplit: - UI_icon_draw(x, y, ICON_MOD_EDGESPLIT); break; - case eModifierType_Array: - UI_icon_draw(x, y, ICON_MOD_ARRAY); break; - case eModifierType_UVProject: - UI_icon_draw(x, y, ICON_MOD_UVPROJECT); break; - case eModifierType_Displace: - UI_icon_draw(x, y, ICON_MOD_DISPLACE); break; - case eModifierType_Shrinkwrap: - UI_icon_draw(x, y, ICON_MOD_SHRINKWRAP); break; - case eModifierType_Cast: - UI_icon_draw(x, y, ICON_MOD_CAST); break; - case eModifierType_MeshDeform: - UI_icon_draw(x, y, ICON_MOD_MESHDEFORM); break; - case eModifierType_Bevel: - UI_icon_draw(x, y, ICON_MOD_BEVEL); break; - case eModifierType_Smooth: - UI_icon_draw(x, y, ICON_MOD_SMOOTH); break; - case eModifierType_SimpleDeform: - UI_icon_draw(x, y, ICON_MOD_SIMPLEDEFORM); break; - case eModifierType_Mask: - UI_icon_draw(x, y, ICON_MOD_MASK); break; - case eModifierType_Cloth: - UI_icon_draw(x, y, ICON_MOD_CLOTH); break; - case eModifierType_Explode: - UI_icon_draw(x, y, ICON_MOD_EXPLODE); break; - case eModifierType_Collision: - UI_icon_draw(x, y, ICON_MOD_PHYSICS); break; - case eModifierType_Fluidsim: - UI_icon_draw(x, y, ICON_MOD_FLUIDSIM); break; - case eModifierType_Multires: - UI_icon_draw(x, y, ICON_MOD_MULTIRES); break; - case eModifierType_Smoke: - UI_icon_draw(x, y, ICON_MOD_SMOKE); break; - case eModifierType_Solidify: - UI_icon_draw(x, y, ICON_MOD_SOLIDIFY); break; - case eModifierType_Screw: - UI_icon_draw(x, y, ICON_MOD_SCREW); break; - default: - UI_icon_draw(x, y, ICON_DOT); break; - } - break; - } - case TSE_SCRIPT_BASE: - UI_icon_draw(x, y, ICON_TEXT); break; - case TSE_POSE_BASE: - UI_icon_draw(x, y, ICON_ARMATURE_DATA); break; - case TSE_POSE_CHANNEL: - UI_icon_draw(x, y, ICON_BONE_DATA); break; - case TSE_PROXY: - UI_icon_draw(x, y, ICON_GHOST); break; - case TSE_R_LAYER_BASE: - UI_icon_draw(x, y, ICON_RENDERLAYERS); break; - case TSE_R_LAYER: - UI_icon_draw(x, y, ICON_RENDERLAYERS); break; - case TSE_LINKED_LAMP: - UI_icon_draw(x, y, ICON_LAMP_DATA); break; - case TSE_LINKED_MAT: - UI_icon_draw(x, y, ICON_MATERIAL_DATA); break; - case TSE_POSEGRP_BASE: - UI_icon_draw(x, y, ICON_VERTEXSEL); break; - case TSE_SEQUENCE: - if(te->idcode==SEQ_MOVIE) - UI_icon_draw(x, y, ICON_SEQUENCE); - else if(te->idcode==SEQ_META) - UI_icon_draw(x, y, ICON_DOT); - else if(te->idcode==SEQ_SCENE) - UI_icon_draw(x, y, ICON_SCENE); - else if(te->idcode==SEQ_SOUND) - UI_icon_draw(x, y, ICON_SOUND); - else if(te->idcode==SEQ_IMAGE) - UI_icon_draw(x, y, ICON_IMAGE_COL); - else - UI_icon_draw(x, y, ICON_PARTICLES); - break; - case TSE_SEQ_STRIP: - UI_icon_draw(x, y, ICON_LIBRARY_DATA_DIRECT); - break; - case TSE_SEQUENCE_DUP: - UI_icon_draw(x, y, ICON_OBJECT_DATA); - break; - case TSE_RNA_STRUCT: - if(RNA_struct_is_ID(te->rnaptr.type)) { - arg.id= (ID *)te->rnaptr.data; - tselem_draw_icon_uibut(&arg, RNA_struct_ui_icon(te->rnaptr.type)); - } - else - UI_icon_draw(x, y, RNA_struct_ui_icon(te->rnaptr.type)); - break; - default: - UI_icon_draw(x, y, ICON_DOT); break; - } - } - else if (GS(tselem->id->name) == ID_OB) { - Object *ob= (Object *)tselem->id; - switch (ob->type) { - case OB_LAMP: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_LAMP); break; - case OB_MESH: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_MESH); break; - case OB_CAMERA: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_CAMERA); break; - case OB_CURVE: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_CURVE); break; - case OB_MBALL: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_META); break; - case OB_LATTICE: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_LATTICE); break; - case OB_ARMATURE: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_ARMATURE); break; - case OB_FONT: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_FONT); break; - case OB_SURF: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_SURFACE); break; - case OB_EMPTY: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_EMPTY); break; - - } - } - else { - switch( GS(tselem->id->name)) { - case ID_SCE: - tselem_draw_icon_uibut(&arg, ICON_SCENE_DATA); break; - case ID_ME: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_MESH); break; - case ID_CU: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_CURVE); break; - case ID_MB: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_META); break; - case ID_LT: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_LATTICE); break; - case ID_LA: - { - Lamp *la= (Lamp *)tselem->id; - - switch(la->type) { - case LA_LOCAL: - tselem_draw_icon_uibut(&arg, ICON_LAMP_POINT); break; - case LA_SUN: - tselem_draw_icon_uibut(&arg, ICON_LAMP_SUN); break; - case LA_SPOT: - tselem_draw_icon_uibut(&arg, ICON_LAMP_SPOT); break; - case LA_HEMI: - tselem_draw_icon_uibut(&arg, ICON_LAMP_HEMI); break; - case LA_AREA: - tselem_draw_icon_uibut(&arg, ICON_LAMP_AREA); break; - default: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_LAMP); break; - } - break; - } - case ID_MA: - tselem_draw_icon_uibut(&arg, ICON_MATERIAL_DATA); break; - case ID_TE: - tselem_draw_icon_uibut(&arg, ICON_TEXTURE_DATA); break; - case ID_IM: - tselem_draw_icon_uibut(&arg, ICON_IMAGE_DATA); break; - case ID_SO: - tselem_draw_icon_uibut(&arg, ICON_SPEAKER); break; - case ID_AR: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_ARMATURE); break; - case ID_CA: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_CAMERA); break; - case ID_KE: - tselem_draw_icon_uibut(&arg, ICON_SHAPEKEY_DATA); break; - case ID_WO: - tselem_draw_icon_uibut(&arg, ICON_WORLD_DATA); break; - case ID_AC: - tselem_draw_icon_uibut(&arg, ICON_ACTION); break; - case ID_NLA: - tselem_draw_icon_uibut(&arg, ICON_NLA); break; - case ID_TXT: - tselem_draw_icon_uibut(&arg, ICON_SCRIPT); break; - case ID_GR: - tselem_draw_icon_uibut(&arg, ICON_GROUP); break; - case ID_LI: - tselem_draw_icon_uibut(&arg, ICON_LIBRARY_DATA_DIRECT); break; - } - } -} - -static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, SpaceOops *soops, ListBase *lb, int level, int xmax, int *offsx, int ys) -{ - TreeElement *te; - TreeStoreElem *tselem; - int active; - - for(te= lb->first; te; te= te->next) { - - /* exit drawing early */ - if((*offsx) - UI_UNIT_X > xmax) - break; - - tselem= TREESTORE(te); - - /* object hierarchy always, further constrained on level */ - if(level<1 || (tselem->type==0 && te->idcode==ID_OB)) { - - /* active blocks get white circle */ - if(tselem->type==0) { - if(te->idcode==ID_OB) active= (OBACT==(Object *)tselem->id); - else if(scene->obedit && scene->obedit->data==tselem->id) active= 1; // XXX use context? - else active= tree_element_active(C, scene, soops, te, 0); - } - else active= tree_element_type_active(NULL, scene, soops, te, tselem, 0); - - if(active) { - float ufac= UI_UNIT_X/20.0f; - - uiSetRoundBox(15); - glColor4ub(255, 255, 255, 100); - uiRoundBox( (float)*offsx-0.5f*ufac, (float)ys-1.0f*ufac, (float)*offsx+UI_UNIT_Y-3.0f*ufac, (float)ys+UI_UNIT_Y-3.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac); - glEnable(GL_BLEND); /* roundbox disables */ - } - - tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, 0.5f); - te->xs= (float)*offsx; - te->ys= (float)ys; - te->xend= (short)*offsx+UI_UNIT_X; - te->flag |= TE_ICONROW; // for click - - (*offsx) += UI_UNIT_X; - } - - /* this tree element always has same amount of branches, so dont draw */ - if(tselem->type!=TSE_R_LAYER) - outliner_draw_iconrow(C, block, scene, soops, &te->subtree, level+1, xmax, offsx, ys); - } - -} - -/* closed tree element */ -static void outliner_set_coord_tree_element(SpaceOops *soops, TreeElement *te, int startx, int *starty) -{ - TreeElement *ten; - - /* store coord and continue, we need coordinates for elements outside view too */ - te->xs= (float)startx; - te->ys= (float)(*starty); - - for(ten= te->subtree.first; ten; ten= ten->next) { - outliner_set_coord_tree_element(soops, ten, startx+UI_UNIT_X, starty); - } -} - - -static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int startx, int *starty) -{ - TreeElement *ten; - TreeStoreElem *tselem; - float ufac= UI_UNIT_X/20.0f; - int offsx= 0, active=0; // active=1 active obj, else active data - - tselem= TREESTORE(te); - - if(*starty+2*UI_UNIT_Y >= ar->v2d.cur.ymin && *starty<= ar->v2d.cur.ymax) { - int xmax= ar->v2d.cur.xmax; - - /* icons can be ui buts, we dont want it to overlap with restrict */ - if((soops->flag & SO_HIDE_RESTRICTCOLS)==0) - xmax-= OL_TOGW+UI_UNIT_X; - - glEnable(GL_BLEND); - - /* colors for active/selected data */ - if(tselem->type==0) { - if(te->idcode==ID_SCE) { - if(tselem->id == (ID *)scene) { - glColor4ub(255, 255, 255, 100); - active= 2; - } - } - else if(te->idcode==ID_GR) { - Group *gr = (Group *)tselem->id; - - if(group_select_flag(gr)) { - char col[4]; - UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); - col[3]= 100; - glColor4ubv((GLubyte *)col); - - active= 2; - } - } - else if(te->idcode==ID_OB) { - Object *ob= (Object *)tselem->id; - - if(ob==OBACT || (ob->flag & SELECT)) { - char col[4]= {0, 0, 0, 0}; - - /* outliner active ob: always white text, circle color now similar to view3d */ - - active= 2; /* means it draws a color circle */ - if(ob==OBACT) { - if(ob->flag & SELECT) { - UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col); - col[3]= 100; - } - - active= 1; /* means it draws white text */ - } - else if(ob->flag & SELECT) { - UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); - col[3]= 100; - } - - glColor4ubv((GLubyte *)col); - } - - } - else if(scene->obedit && scene->obedit->data==tselem->id) { - glColor4ub(255, 255, 255, 100); - active= 2; - } - else { - if(tree_element_active(C, scene, soops, te, 0)) { - glColor4ub(220, 220, 255, 100); - active= 2; - } - } - } - else { - if( tree_element_type_active(NULL, scene, soops, te, tselem, 0) ) active= 2; - glColor4ub(220, 220, 255, 100); - } - - /* active circle */ - if(active) { - uiSetRoundBox(15); - uiRoundBox( (float)startx+UI_UNIT_Y-1.5f*ufac, (float)*starty+2.0f*ufac, (float)startx+2.0f*UI_UNIT_Y-4.0f*ufac, (float)*starty+UI_UNIT_Y-1.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac); - glEnable(GL_BLEND); /* roundbox disables it */ - - te->flag |= TE_ACTIVE; // for lookup in display hierarchies - } - - /* open/close icon, only when sublevels, except for scene */ - if(te->subtree.first || (tselem->type==0 && te->idcode==ID_SCE) || (te->flag & TE_LAZY_CLOSED)) { - int icon_x; - if(tselem->type==0 && ELEM(te->idcode, ID_OB, ID_SCE)) - icon_x = startx; - else - icon_x = startx+5*ufac; - - // icons a bit higher - if(tselem->flag & TSE_CLOSED) - UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_RIGHT); - else - UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_DOWN); - } - offsx+= UI_UNIT_X; - - /* datatype icon */ - - if(!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))) { - // icons a bit higher - tselem_draw_icon(block, xmax, (float)startx+offsx - 0.5f*ufac, (float)*starty+2.0f*ufac, tselem, te, 1.0f); - - offsx+= UI_UNIT_X; - } - else - offsx+= 2*ufac; - - if(tselem->type==0 && tselem->id->lib) { - glPixelTransferf(GL_ALPHA_SCALE, 0.5f); - if(tselem->id->flag & LIB_INDIRECT) - UI_icon_draw((float)startx+offsx, (float)*starty+2*ufac, ICON_LIBRARY_DATA_INDIRECT); - else - UI_icon_draw((float)startx+offsx, (float)*starty+2*ufac, ICON_LIBRARY_DATA_DIRECT); - glPixelTransferf(GL_ALPHA_SCALE, 1.0f); - offsx+= UI_UNIT_X; - } - glDisable(GL_BLEND); - - /* name */ - if(active==1) UI_ThemeColor(TH_TEXT_HI); - else if(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.75f); - else UI_ThemeColor(TH_TEXT); - - UI_DrawString(startx+offsx, *starty+5*ufac, te->name); - - offsx+= (int)(UI_UNIT_X + UI_GetStringWidth(te->name)); - - /* closed item, we draw the icons, not when it's a scene, or master-server list though */ - if(tselem->flag & TSE_CLOSED) { - if(te->subtree.first) { - if(tselem->type==0 && te->idcode==ID_SCE); - else if(tselem->type!=TSE_R_LAYER) { /* this tree element always has same amount of branches, so dont draw */ - int tempx= startx+offsx; - - // divider - UI_ThemeColorShade(TH_BACK, -40); - glRecti(tempx -10, *starty+4, tempx -8, *starty+UI_UNIT_Y-4); - - glEnable(GL_BLEND); - glPixelTransferf(GL_ALPHA_SCALE, 0.5); - - outliner_draw_iconrow(C, block, scene, soops, &te->subtree, 0, xmax, &tempx, *starty+2); - - glPixelTransferf(GL_ALPHA_SCALE, 1.0); - glDisable(GL_BLEND); - } - } - } - } - /* store coord and continue, we need coordinates for elements outside view too */ - te->xs= (float)startx; - te->ys= (float)*starty; - te->xend= startx+offsx; - - if((tselem->flag & TSE_CLOSED)==0) { - *starty-= UI_UNIT_Y; - - for(ten= te->subtree.first; ten; ten= ten->next) - outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx+UI_UNIT_X, starty); - } - else { - for(ten= te->subtree.first; ten; ten= ten->next) - outliner_set_coord_tree_element(soops, te, startx, starty); - - *starty-= UI_UNIT_Y; - } -} - -static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx, int *starty) -{ - TreeElement *te; - TreeStoreElem *tselem; - int y1, y2; - - if(lb->first==NULL) return; - - y1=y2= *starty; /* for vertical lines between objects */ - for(te=lb->first; te; te= te->next) { - y2= *starty; - tselem= TREESTORE(te); - - /* horizontal line? */ - if(tselem->type==0 && (te->idcode==ID_OB || te->idcode==ID_SCE)) - glRecti(startx, *starty, startx+UI_UNIT_X, *starty-1); - - *starty-= UI_UNIT_Y; - - if((tselem->flag & TSE_CLOSED)==0) - outliner_draw_hierarchy(soops, &te->subtree, startx+UI_UNIT_X, starty); - } - - /* vertical line */ - te= lb->last; - if(te->parent || lb->first!=lb->last) { - tselem= TREESTORE(te); - if(tselem->type==0 && te->idcode==ID_OB) { - - glRecti(startx, y1+UI_UNIT_Y, startx+1, y2); - } - } -} - -static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase *lb, int *starty) -{ - TreeElement *te; - TreeStoreElem *tselem; - - for(te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - - /* selection status */ - if((tselem->flag & TSE_CLOSED)==0) - if(tselem->type == TSE_RNA_STRUCT) - glRecti(0, *starty+1, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, *starty+UI_UNIT_Y-1); - - *starty-= UI_UNIT_Y; - if((tselem->flag & TSE_CLOSED)==0) { - outliner_draw_struct_marks(ar, soops, &te->subtree, starty); - if(tselem->type == TSE_RNA_STRUCT) - fdrawline(0, (float)*starty+UI_UNIT_Y, ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, (float)*starty+UI_UNIT_Y); - } - } -} - -static void outliner_draw_selection(ARegion *ar, SpaceOops *soops, ListBase *lb, int *starty) -{ - TreeElement *te; - TreeStoreElem *tselem; - - for(te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - - /* selection status */ - if(tselem->flag & TSE_SELECTED) { - glRecti(0, *starty+1, (int)ar->v2d.cur.xmax, *starty+UI_UNIT_Y-1); - } - *starty-= UI_UNIT_Y; - if((tselem->flag & TSE_CLOSED)==0) outliner_draw_selection(ar, soops, &te->subtree, starty); - } -} - - -static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops) -{ - TreeElement *te; - int starty, startx; - float col[4]; - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // only once - - if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { - /* struct marks */ - UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); - //UI_ThemeColorShade(TH_BACK, -20); - starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; - outliner_draw_struct_marks(ar, soops, &soops->tree, &starty); - } - - /* always draw selection fill before hierarchy */ - UI_GetThemeColor3fv(TH_BACK, col); - glColor3f(col[0]+0.06f, col[1]+0.08f, col[2]+0.10f); - starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; - outliner_draw_selection(ar, soops, &soops->tree, &starty); - - // grey hierarchy lines - UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.4f); - starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y/2-OL_Y_OFFSET; - startx= 6; - outliner_draw_hierarchy(soops, &soops->tree, startx, &starty); - - // items themselves - starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; - startx= 0; - for(te= soops->tree.first; te; te= te->next) { - outliner_draw_tree_element(C, block, scene, ar, soops, te, startx, &starty); - } -} - - -static void outliner_back(ARegion *ar) -{ - int ystart; - - UI_ThemeColorShade(TH_BACK, 6); - ystart= (int)ar->v2d.tot.ymax; - ystart= UI_UNIT_Y*(ystart/(UI_UNIT_Y))-OL_Y_OFFSET; - - while(ystart+2*UI_UNIT_Y > ar->v2d.cur.ymin) { - glRecti(0, ystart, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, ystart+UI_UNIT_Y); - ystart-= 2*UI_UNIT_Y; - } -} - -static void outliner_draw_restrictcols(ARegion *ar) -{ - int ystart; - - /* background underneath */ - UI_ThemeColor(TH_BACK); - glRecti((int)ar->v2d.cur.xmax-OL_TOGW, (int)ar->v2d.cur.ymin-V2D_SCROLL_HEIGHT-1, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, (int)ar->v2d.cur.ymax); - - UI_ThemeColorShade(TH_BACK, 6); - ystart= (int)ar->v2d.tot.ymax; - ystart= UI_UNIT_Y*(ystart/(UI_UNIT_Y))-OL_Y_OFFSET; - - while(ystart+2*UI_UNIT_Y > ar->v2d.cur.ymin) { - glRecti((int)ar->v2d.cur.xmax-OL_TOGW, ystart, (int)ar->v2d.cur.xmax, ystart+UI_UNIT_Y); - ystart-= 2*UI_UNIT_Y; - } - - UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); - - /* view */ - fdrawline(ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, - ar->v2d.cur.ymax, - ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, - ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); - - /* render */ - fdrawline(ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, - ar->v2d.cur.ymax, - ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, - ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); - - /* render */ - fdrawline(ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, - ar->v2d.cur.ymax, - ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, - ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); -} - -static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2) -{ - Scene *scene = (Scene *)poin; - Object *ob = (Object *)poin2; - - if(!common_restrict_check(C, ob)) return; - - /* deselect objects that are invisible */ - if (ob->restrictflag & OB_RESTRICT_VIEW) { - /* Ouch! There is no backwards pointer from Object to Base, - * so have to do loop to find it. */ - ED_base_object_select(object_in_scene(ob, scene), BA_DESELECT); - } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); - -} - -static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2) -{ - Scene *scene = (Scene *)poin; - Object *ob = (Object *)poin2; - - if(!common_restrict_check(C, ob)) return; - - /* if select restriction has just been turned on */ - if (ob->restrictflag & OB_RESTRICT_SELECT) { - /* Ouch! There is no backwards pointer from Object to Base, - * so have to do loop to find it. */ - ED_base_object_select(object_in_scene(ob, scene), BA_DESELECT); - } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); - -} - -static void restrictbutton_rend_cb(bContext *C, void *poin, void *UNUSED(poin2)) -{ - WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, poin); -} - -static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *UNUSED(poin2)) -{ - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, poin); -} - -static void restrictbutton_modifier_cb(bContext *C, void *UNUSED(poin), void *poin2) -{ - Object *ob = (Object *)poin2; - - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); -} - -static void restrictbutton_bone_cb(bContext *C, void *UNUSED(poin), void *poin2) -{ - Bone *bone= (Bone *)poin2; - if(bone && (bone->flag & BONE_HIDDEN_P)) - bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); -} - -static void restrictbutton_ebone_cb(bContext *C, void *UNUSED(poin), void *poin2) -{ - EditBone *ebone= (EditBone *)poin2; - if(ebone && (ebone->flag & BONE_HIDDEN_A)) - ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); -} - -static int group_restrict_flag(Group *gr, int flag) -{ - GroupObject *gob; - - for(gob= gr->gobject.first; gob; gob= gob->next) { - if((gob->ob->restrictflag & flag) == 0) - return 0; - } - - return 1; -} - -static int group_select_flag(Group *gr) -{ - GroupObject *gob; - - for(gob= gr->gobject.first; gob; gob= gob->next) - if((gob->ob->flag & SELECT)) - return 1; - - return 0; -} - -static void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) -{ - Scene *scene = (Scene *)poin; - GroupObject *gob; - Group *gr = (Group *)poin2; - - if(group_restrict_flag(gr, flag)) { - for(gob= gr->gobject.first; gob; gob= gob->next) { - gob->ob->restrictflag &= ~flag; - - if(flag==OB_RESTRICT_VIEW) - if(gob->ob->flag & SELECT) - ED_base_object_select(object_in_scene(gob->ob, scene), BA_DESELECT); - } - } - else { - for(gob= gr->gobject.first; gob; gob= gob->next) { - /* not in editmode */ - if(scene->obedit!=gob->ob) { - gob->ob->restrictflag |= flag; - - if(flag==OB_RESTRICT_VIEW) - if((gob->ob->flag & SELECT) == 0) - ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT); - } - } - } -} - -static void restrictbutton_gr_restrict_view(bContext *C, void *poin, void *poin2) -{ - restrictbutton_gr_restrict_flag(poin, poin2, OB_RESTRICT_VIEW); - WM_event_add_notifier(C, NC_GROUP, NULL); -} -static void restrictbutton_gr_restrict_select(bContext *C, void *poin, void *poin2) -{ - restrictbutton_gr_restrict_flag(poin, poin2, OB_RESTRICT_SELECT); - WM_event_add_notifier(C, NC_GROUP, NULL); -} -static void restrictbutton_gr_restrict_render(bContext *C, void *poin, void *poin2) -{ - restrictbutton_gr_restrict_flag(poin, poin2, OB_RESTRICT_RENDER); - WM_event_add_notifier(C, NC_GROUP, NULL); -} - - -static void namebutton_cb(bContext *C, void *tsep, char *oldname) -{ - SpaceOops *soops= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - TreeStore *ts= soops->treestore; - TreeStoreElem *tselem= tsep; - - if(ts && tselem) { - TreeElement *te= outliner_find_tse(soops, tselem); - - if(tselem->type==0) { - test_idbutton(tselem->id->name+2); // library.c, unique name and alpha sort - - switch(GS(tselem->id->name)) { - case ID_MA: - WM_event_add_notifier(C, NC_MATERIAL, NULL); break; - case ID_TE: - WM_event_add_notifier(C, NC_TEXTURE, NULL); break; - case ID_IM: - WM_event_add_notifier(C, NC_IMAGE, NULL); break; - case ID_SCE: - WM_event_add_notifier(C, NC_SCENE, NULL); break; - default: - WM_event_add_notifier(C, NC_ID|NA_RENAME, NULL); break; - } - /* Check the library target exists */ - if (te->idcode == ID_LI) { - char expanded[FILE_MAXDIR + FILE_MAXFILE]; - BLI_strncpy(expanded, ((Library *)tselem->id)->name, FILE_MAXDIR + FILE_MAXFILE); - BLI_path_abs(expanded, G.main->name); - if (!BLI_exists(expanded)) { - error("This path does not exist, correct this before saving"); - } - } - } - else { - switch(tselem->type) { - case TSE_DEFGROUP: - defgroup_unique_name(te->directdata, (Object *)tselem->id); // id = object - break; - case TSE_NLA_ACTION: - test_idbutton(tselem->id->name+2); - break; - case TSE_EBONE: - { - bArmature *arm= (bArmature *)tselem->id; - if(arm->edbo) { - EditBone *ebone= te->directdata; - char newname[sizeof(ebone->name)]; - - /* restore bone name */ - BLI_strncpy(newname, ebone->name, sizeof(ebone->name)); - BLI_strncpy(ebone->name, oldname, sizeof(ebone->name)); - ED_armature_bone_rename(obedit->data, oldname, newname); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, OBACT); - } - } - break; - - case TSE_BONE: - { - Bone *bone= te->directdata; - Object *ob; - char newname[sizeof(bone->name)]; - - // always make current object active - tree_element_set_active_object(C, scene, soops, te, 1); - ob= OBACT; - - /* restore bone name */ - BLI_strncpy(newname, bone->name, sizeof(bone->name)); - BLI_strncpy(bone->name, oldname, sizeof(bone->name)); - ED_armature_bone_rename(ob->data, oldname, newname); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); - } - break; - case TSE_POSE_CHANNEL: - { - bPoseChannel *pchan= te->directdata; - Object *ob; - char newname[sizeof(pchan->name)]; - - // always make current object active - tree_element_set_active_object(C, scene, soops, te, 1); - ob= OBACT; - - /* restore bone name */ - BLI_strncpy(newname, pchan->name, sizeof(pchan->name)); - BLI_strncpy(pchan->name, oldname, sizeof(pchan->name)); - ED_armature_bone_rename(ob->data, oldname, newname); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); - } - break; - case TSE_POSEGRP: - { - Object *ob= (Object *)tselem->id; // id = object - bActionGroup *grp= te->directdata; - - BLI_uniquename(&ob->pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), sizeof(grp->name)); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); - } - break; - case TSE_R_LAYER: - break; - } - } - tselem->flag &= ~TSE_TEXTBUT; - } -} - -static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, ListBase *lb) -{ - uiBut *bt; - TreeElement *te; - TreeStoreElem *tselem; - Object *ob = NULL; - Group *gr = NULL; - - for(te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if(te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { - /* objects have toggle-able restriction flags */ - if(tselem->type==0 && te->idcode==ID_OB) { - PointerRNA ptr; - - ob = (Object *)tselem->id; - RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ptr); - - uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, - &ptr, "hide", -1, 0, 0, -1, -1, NULL); - uiButSetFunc(bt, restrictbutton_view_cb, scene, ob); - - bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, - &ptr, "hide_select", -1, 0, 0, -1, -1, NULL); - uiButSetFunc(bt, restrictbutton_sel_cb, scene, ob); - - bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, - &ptr, "hide_render", -1, 0, 0, -1, -1, NULL); - uiButSetFunc(bt, restrictbutton_rend_cb, scene, ob); - - uiBlockSetEmboss(block, UI_EMBOSS); - - } - if(tselem->type==0 && te->idcode==ID_GR){ - int restrict_bool; - gr = (Group *)tselem->id; - - uiBlockSetEmboss(block, UI_EMBOSSN); - - restrict_bool= group_restrict_flag(gr, OB_RESTRICT_VIEW); - bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); - uiButSetFunc(bt, restrictbutton_gr_restrict_view, scene, gr); - - restrict_bool= group_restrict_flag(gr, OB_RESTRICT_SELECT); - bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); - uiButSetFunc(bt, restrictbutton_gr_restrict_select, scene, gr); - - restrict_bool= group_restrict_flag(gr, OB_RESTRICT_RENDER); - bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow renderability"); - uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr); - - uiBlockSetEmboss(block, UI_EMBOSS); - } - /* scene render layers and passes have toggle-able flags too! */ - else if(tselem->type==TSE_R_LAYER) { - uiBlockSetEmboss(block, UI_EMBOSSN); - - bt= uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, 0, ICON_CHECKBOX_HLT-1, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, te->directdata, 0, 0, 0, 0, "Render this RenderLayer"); - uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); - - uiBlockSetEmboss(block, UI_EMBOSS); - } - else if(tselem->type==TSE_R_PASS) { - int *layflag= te->directdata; - int passflag= 1<<tselem->nr; - - uiBlockSetEmboss(block, UI_EMBOSSN); - - - bt= uiDefIconButBitI(block, ICONTOG, passflag, 0, ICON_CHECKBOX_HLT-1, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, layflag, 0, 0, 0, 0, "Render this Pass"); - uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); - - layflag++; /* is lay_xor */ - if(ELEM8(passflag, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT, SCE_PASS_INDIRECT, SCE_PASS_EMIT, SCE_PASS_ENVIRONMENT)) - bt= uiDefIconButBitI(block, TOG, passflag, 0, (*layflag & passflag)?ICON_DOT:ICON_BLANK1, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined"); - uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); - - uiBlockSetEmboss(block, UI_EMBOSS); - } - else if(tselem->type==TSE_MODIFIER) { - ModifierData *md= (ModifierData *)te->directdata; - ob = (Object *)tselem->id; - - uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Realtime, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); - uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob); - - bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability"); - uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob); - } - else if(tselem->type==TSE_POSE_CHANNEL) { - bPoseChannel *pchan= (bPoseChannel *)te->directdata; - Bone *bone = pchan->bone; - - uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); - uiButSetFunc(bt, restrictbutton_bone_cb, NULL, bone); - - bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); - uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL); - } - else if(tselem->type==TSE_EBONE) { - EditBone *ebone= (EditBone *)te->directdata; - - uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); - uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, ebone); - - bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); - uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, NULL); - } - } - - if((tselem->flag & TSE_CLOSED)==0) outliner_draw_restrictbuts(block, scene, ar, soops, &te->subtree); - } -} - -static void outliner_draw_rnacols(ARegion *ar, int sizex) -{ - View2D *v2d= &ar->v2d; - - float miny = v2d->cur.ymin-V2D_SCROLL_HEIGHT; - if(miny<v2d->tot.ymin) miny = v2d->tot.ymin; - - UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); - - /* draw column separator lines */ - fdrawline((float)sizex, - v2d->cur.ymax, - (float)sizex, - miny); - - fdrawline((float)sizex+OL_RNA_COL_SIZEX, - v2d->cur.ymax, - (float)sizex+OL_RNA_COL_SIZEX, - miny); -} - -static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, int sizex, ListBase *lb) -{ - TreeElement *te; - TreeStoreElem *tselem; - PointerRNA *ptr; - PropertyRNA *prop; - - uiBlockSetEmboss(block, UI_EMBOSST); - - for(te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if(te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { - if(tselem->type == TSE_RNA_PROPERTY) { - ptr= &te->rnaptr; - prop= te->directdata; - - if(!(RNA_property_type(prop) == PROP_POINTER && (tselem->flag & TSE_CLOSED)==0)) - uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y-1); - } - else if(tselem->type == TSE_RNA_ARRAY_ELEM) { - ptr= &te->rnaptr; - prop= te->directdata; - - uiDefAutoButR(block, ptr, prop, te->index, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y-1); - } - } - - if((tselem->flag & TSE_CLOSED)==0) outliner_draw_rnabuts(block, scene, ar, soops, sizex, &te->subtree); - } -} - -static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *arg2) -{ - wmOperatorType *ot= arg2; - wmKeyMapItem *kmi= arg_kmi; - - if(ot) - BLI_strncpy(kmi->idname, ot->idname, OP_MAX_TYPENAME); -} - -static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(arg_kmi), const char *str, uiSearchItems *items) -{ - wmOperatorType *ot = WM_operatortype_first(); - - for(; ot; ot= ot->next) { - - if(BLI_strcasestr(ot->idname, str)) { - char name[OP_MAX_TYPENAME]; - - /* display name for menu */ - WM_operator_py_idname(name, ot->idname); - - if(0==uiSearchItemAdd(items, name, ot, 0)) - break; - } - } -} - -/* operator Search browse menu, open */ -static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi) -{ - static char search[OP_MAX_TYPENAME]; - wmEvent event; - wmWindow *win= CTX_wm_window(C); - wmKeyMapItem *kmi= arg_kmi; - wmOperatorType *ot= WM_operatortype_find(kmi->idname, 0); - uiBlock *block; - uiBut *but; - - /* clear initial search string, then all items show */ - search[0]= 0; - - block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1); - - /* fake button, it holds space for search items */ - uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); - - but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 0, 150, UI_UNIT_Y, 0, 0, ""); - uiButSetSearchFunc(but, operator_search_cb, arg_kmi, operator_call_cb, ot); - - uiBoundsBlock(block, 6); - uiBlockSetDirection(block, UI_DOWN); - uiEndBlock(C, block); - - event= *(win->eventstate); /* XXX huh huh? make api call */ - event.type= EVT_BUT_OPEN; - event.val= KM_PRESS; - event.customdata= but; - event.customdatafree= FALSE; - wm_event_add(win, &event); - - return block; -} - -#define OL_KM_KEYBOARD 0 -#define OL_KM_MOUSE 1 -#define OL_KM_TWEAK 2 -#define OL_KM_SPECIALS 3 - -static short keymap_menu_type(short type) -{ - if(ISKEYBOARD(type)) return OL_KM_KEYBOARD; - if(ISTWEAK(type)) return OL_KM_TWEAK; - if(ISMOUSE(type)) return OL_KM_MOUSE; -// return OL_KM_SPECIALS; - return 0; -} - -static const char *keymap_type_menu(void) -{ - static const char string[]= - "Event Type%t" - "|Keyboard%x" STRINGIFY(OL_KM_KEYBOARD) - "|Mouse%x" STRINGIFY(OL_KM_MOUSE) - "|Tweak%x" STRINGIFY(OL_KM_TWEAK) -// "|Specials%x" STRINGIFY(OL_KM_SPECIALS) - ; - - return string; -} - -static const char *keymap_mouse_menu(void) -{ - static const char string[]= - "Mouse Event%t" - "|Left Mouse%x" STRINGIFY(LEFTMOUSE) - "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) - "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) - "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) - "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) - "|Button4 Mouse%x" STRINGIFY(BUTTON4MOUSE) - "|Button5 Mouse%x" STRINGIFY(BUTTON5MOUSE) - "|Action Mouse%x" STRINGIFY(ACTIONMOUSE) - "|Select Mouse%x" STRINGIFY(SELECTMOUSE) - "|Mouse Move%x" STRINGIFY(MOUSEMOVE) - "|Wheel Up%x" STRINGIFY(WHEELUPMOUSE) - "|Wheel Down%x" STRINGIFY(WHEELDOWNMOUSE) - "|Wheel In%x" STRINGIFY(WHEELINMOUSE) - "|Wheel Out%x" STRINGIFY(WHEELOUTMOUSE) - "|Mouse/Trackpad Pan%x" STRINGIFY(MOUSEPAN) - "|Mouse/Trackpad Zoom%x" STRINGIFY(MOUSEZOOM) - "|Mouse/Trackpad Rotate%x" STRINGIFY(MOUSEROTATE) - ; - - return string; -} - -static const char *keymap_tweak_menu(void) -{ - static const char string[]= - "Tweak Event%t" - "|Left Mouse%x" STRINGIFY(EVT_TWEAK_L) - "|Middle Mouse%x" STRINGIFY(EVT_TWEAK_M) - "|Right Mouse%x" STRINGIFY(EVT_TWEAK_R) - "|Action Mouse%x" STRINGIFY(EVT_TWEAK_A) - "|Select Mouse%x" STRINGIFY(EVT_TWEAK_S) - ; - - return string; -} - -static const char *keymap_tweak_dir_menu(void) -{ - static const char string[]= - "Tweak Direction%t" - "|Any%x" STRINGIFY(KM_ANY) - "|North%x" STRINGIFY(EVT_GESTURE_N) - "|North-East%x" STRINGIFY(EVT_GESTURE_NE) - "|East%x" STRINGIFY(EVT_GESTURE_E) - "|Sout-East%x" STRINGIFY(EVT_GESTURE_SE) - "|South%x" STRINGIFY(EVT_GESTURE_S) - "|South-West%x" STRINGIFY(EVT_GESTURE_SW) - "|West%x" STRINGIFY(EVT_GESTURE_W) - "|North-West%x" STRINGIFY(EVT_GESTURE_NW) - ; - - return string; -} - - -static void keymap_type_cb(bContext *C, void *kmi_v, void *UNUSED(arg_v)) -{ - wmKeyMapItem *kmi= kmi_v; - short maptype= keymap_menu_type(kmi->type); - - if(maptype!=kmi->maptype) { - switch(kmi->maptype) { - case OL_KM_KEYBOARD: - kmi->type= AKEY; - kmi->val= KM_PRESS; - break; - case OL_KM_MOUSE: - kmi->type= LEFTMOUSE; - kmi->val= KM_PRESS; - break; - case OL_KM_TWEAK: - kmi->type= EVT_TWEAK_L; - kmi->val= KM_ANY; - break; - case OL_KM_SPECIALS: - kmi->type= AKEY; - kmi->val= KM_PRESS; - } - ED_region_tag_redraw(CTX_wm_region(C)); - } -} - -static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soops, ListBase *lb) -{ - TreeElement *te; - TreeStoreElem *tselem; - - uiBlockSetEmboss(block, UI_EMBOSST); - - for(te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if(te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { - uiBut *but; - const char *str; - int xstart= 240; - int butw1= UI_UNIT_X; /* operator */ - int butw2= 90; /* event type, menus */ - int butw3= 43; /* modifiers */ - - if(tselem->type == TSE_KEYMAP_ITEM) { - wmKeyMapItem *kmi= te->directdata; - - /* modal map? */ - if(kmi->propvalue); - else { - uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, (int)te->ys+1, butw1, UI_UNIT_Y-1, "Assign new Operator"); - } - xstart+= butw1+10; - - /* map type button */ - kmi->maptype= keymap_menu_type(kmi->type); - - str= keymap_type_menu(); - but= uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->maptype, 0, 0, 0, 0, "Event type"); - uiButSetFunc(but, keymap_type_cb, kmi, NULL); - xstart+= butw2+5; - - /* edit actual event */ - switch(kmi->maptype) { - case OL_KM_KEYBOARD: - uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, "Key code"); - xstart+= butw2+5; - break; - case OL_KM_MOUSE: - str= keymap_mouse_menu(); - uiDefButS(block, MENU, 0, str, xstart,(int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, 0, 0, 0, 0, "Mouse button"); - xstart+= butw2+5; - break; - case OL_KM_TWEAK: - str= keymap_tweak_menu(); - uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, 0, 0, 0, 0, "Tweak gesture"); - xstart+= butw2+5; - str= keymap_tweak_dir_menu(); - uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->val, 0, 0, 0, 0, "Tweak gesture direction"); - xstart+= butw2+5; - break; - } - - /* modifiers */ - uiDefButS(block, OPTION, 0, "Shift", xstart, (int)te->ys+1, butw3+5, UI_UNIT_Y-1, &kmi->shift, 0, 0, 0, 0, "Modifier"); xstart+= butw3+5; - uiDefButS(block, OPTION, 0, "Ctrl", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->ctrl, 0, 0, 0, 0, "Modifier"); xstart+= butw3; - uiDefButS(block, OPTION, 0, "Alt", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->alt, 0, 0, 0, 0, "Modifier"); xstart+= butw3; - uiDefButS(block, OPTION, 0, "OS", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->oskey, 0, 0, 0, 0, "Modifier"); xstart+= butw3; - xstart+= 5; - uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->keymodifier, "Key Modifier code"); - xstart+= butw3+5; - - /* rna property */ - if(kmi->ptr && kmi->ptr->data) { - uiDefBut(block, LABEL, 0, "(RNA property)", xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->oskey, 0, 0, 0, 0, ""); xstart+= butw2; - } - - (void)xstart; - } - } - - if((tselem->flag & TSE_CLOSED)==0) outliner_draw_keymapbuts(block, ar, soops, &te->subtree); - } -} - - -static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, SpaceOops *soops, ListBase *lb) -{ - uiBut *bt; - TreeElement *te; - TreeStoreElem *tselem; - int spx, dx, len; - - for(te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if(te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { - - if(tselem->flag & TSE_TEXTBUT) { - - /* If we add support to rename Sequence. - * need change this. - */ - if(tselem->type == TSE_POSE_BASE) continue; // prevent crash when trying to rename 'pose' entry of armature - - if(tselem->type==TSE_EBONE) len = sizeof(((EditBone*) 0)->name); - else if (tselem->type==TSE_MODIFIER) len = sizeof(((ModifierData*) 0)->name); - else if(tselem->id && GS(tselem->id->name)==ID_LI) len = sizeof(((Library*) 0)->name); - else len= MAX_ID_NAME-2; - - - dx= (int)UI_GetStringWidth(te->name); - if(dx<100) dx= 100; - spx=te->xs+2*UI_UNIT_X-4; - if(spx+dx+10>ar->v2d.cur.xmax) dx = ar->v2d.cur.xmax-spx-10; - - bt= uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, (int)te->ys, dx+10, UI_UNIT_Y-1, (void *)te->name, 1.0, (float)len, 0, 0, ""); - uiButSetRenameFunc(bt, namebutton_cb, tselem); - - /* returns false if button got removed */ - if( 0 == uiButActiveOnly(C, block, bt) ) - tselem->flag &= ~TSE_TEXTBUT; - } - } - - if((tselem->flag & TSE_CLOSED)==0) outliner_buttons(C, block, ar, soops, &te->subtree); - } -} - -void draw_outliner(const bContext *C) -{ - Main *mainvar= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - View2D *v2d= &ar->v2d; - SpaceOops *soops= CTX_wm_space_outliner(C); - uiBlock *block; - int sizey= 0, sizex= 0, sizex_rna= 0; - - outliner_build_tree(mainvar, scene, soops); // always - - /* get extents of data */ - outliner_height(soops, &soops->tree, &sizey); - - if (ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP)) { - /* RNA has two columns: - * - column 1 is (max_width + OL_RNA_COL_SPACEX) or - * (OL_RNA_COL_X), whichever is wider... - * - column 2 is fixed at OL_RNA_COL_SIZEX - * - * (*) XXX max width for now is a fixed factor of UI_UNIT_X*(max_indention+100) - */ - - /* get actual width of column 1 */ - outliner_rna_width(soops, &soops->tree, &sizex_rna, 0); - sizex_rna= MAX2(OL_RNA_COLX, sizex_rna+OL_RNA_COL_SPACEX); - - /* get width of data (for setting 'tot' rect, this is column 1 + column 2 + a bit extra) */ - if (soops->outlinevis == SO_KEYMAP) - sizex= sizex_rna + OL_RNA_COL_SIZEX*3 + 50; // XXX this is only really a quick hack to make this wide enough... - else - sizex= sizex_rna + OL_RNA_COL_SIZEX + 50; - } - else { - /* width must take into account restriction columns (if visible) so that entries will still be visible */ - //outliner_width(soops, &soops->tree, &sizex); - outliner_rna_width(soops, &soops->tree, &sizex, 0); // XXX should use outliner_width instead when te->xend will be set correctly... - - /* constant offset for restriction columns */ - // XXX this isn't that great yet... - if ((soops->flag & SO_HIDE_RESTRICTCOLS)==0) - sizex += OL_TOGW*3; - } - - /* tweak to display last line (when list bigger than window) */ - sizey += V2D_SCROLL_HEIGHT; - - /* adds vertical offset */ - sizey += OL_Y_OFFSET; - - /* update size of tot-rect (extents of data/viewable area) */ - UI_view2d_totRect_set(v2d, sizex, sizey); - - /* force display to pixel coords */ - v2d->flag |= (V2D_PIXELOFS_X|V2D_PIXELOFS_Y); - /* set matrix for 2d-view controls */ - UI_view2d_view_ortho(v2d); - - /* draw outliner stuff (background, hierachy lines and names) */ - outliner_back(ar); - block= uiBeginBlock(C, ar, "outliner buttons", UI_EMBOSS); - outliner_draw_tree((bContext *)C, block, scene, ar, soops); - - if(ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { - /* draw rna buttons */ - outliner_draw_rnacols(ar, sizex_rna); - outliner_draw_rnabuts(block, scene, ar, soops, sizex_rna, &soops->tree); - } - else if(soops->outlinevis == SO_KEYMAP) { - outliner_draw_keymapbuts(block, ar, soops, &soops->tree); - } - else if (!(soops->flag & SO_HIDE_RESTRICTCOLS)) { - /* draw restriction columns */ - outliner_draw_restrictcols(ar); - outliner_draw_restrictbuts(block, scene, ar, soops, &soops->tree); - } - - /* draw edit buttons if nessecery */ - outliner_buttons(C, block, ar, soops, &soops->tree); - - uiEndBlock(C, block); - uiDrawBlock(C, block); - - /* clear flag that allows quick redraws */ - soops->storeflag &= ~SO_TREESTORE_REDRAW; -} - diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c new file mode 100644 index 00000000000..17b44022c80 --- /dev/null +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -0,0 +1,1671 @@ +/* + * $Id$ + * + * ***** 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. + * + * The Original Code is Copyright (C) 2004 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Joshua Leung + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_outliner/outliner_draw.c + * \ingroup spoutliner + */ + +#include <string.h> +#include <stdlib.h> + +#include "MEM_guardedalloc.h" + +#include "DNA_anim_types.h" +#include "DNA_armature_types.h" +#include "DNA_camera_types.h" +#include "DNA_group_types.h" +#include "DNA_key_types.h" +#include "DNA_lamp_types.h" +#include "DNA_material_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meta_types.h" +#include "DNA_particle_types.h" +#include "DNA_scene_types.h" +#include "DNA_world_types.h" +#include "DNA_sequence_types.h" +#include "DNA_object_types.h" + +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" + +#include "BKE_animsys.h" +#include "BKE_context.h" +#include "BKE_deform.h" +#include "BKE_depsgraph.h" +#include "BKE_fcurve.h" +#include "BKE_global.h" +#include "BKE_group.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_modifier.h" +#include "BKE_report.h" +#include "BKE_scene.h" +#include "BKE_sequencer.h" + +#include "BLI_ghash.h" + +#include "ED_armature.h" +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_util.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "UI_interface.h" +#include "UI_interface_icons.h" +#include "UI_resources.h" +#include "UI_view2d.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "outliner_intern.h" + +/* ****************************************************** */ +/* Tree Size Functions */ + +static void outliner_height(SpaceOops *soops, ListBase *lb, int *h) +{ + TreeElement *te= lb->first; + while(te) { + TreeStoreElem *tselem= TREESTORE(te); + if((tselem->flag & TSE_CLOSED)==0) + outliner_height(soops, &te->subtree, h); + (*h) += UI_UNIT_Y; + te= te->next; + } +} + +#if 0 // XXX this is currently disabled until te->xend is set correctly +static void outliner_width(SpaceOops *soops, ListBase *lb, int *w) +{ + TreeElement *te= lb->first; + while(te) { +// TreeStoreElem *tselem= TREESTORE(te); + + // XXX fixme... te->xend is not set yet + if(tselem->flag & TSE_CLOSED) { + if (te->xend > *w) + *w = te->xend; + } + outliner_width(soops, &te->subtree, w); + te= te->next; + } +} +#endif + +static void outliner_rna_width(SpaceOops *soops, ListBase *lb, int *w, int startx) +{ + TreeElement *te= lb->first; + while(te) { + TreeStoreElem *tselem= TREESTORE(te); + // XXX fixme... (currently, we're using a fixed length of 100)! + /*if(te->xend) { + if(te->xend > *w) + *w = te->xend; + }*/ + if(startx+100 > *w) + *w = startx+100; + + if((tselem->flag & TSE_CLOSED)==0) + outliner_rna_width(soops, &te->subtree, w, startx+UI_UNIT_X); + te= te->next; + } +} + +/* ****************************************************** */ + +static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2) +{ + Scene *scene = (Scene *)poin; + Object *ob = (Object *)poin2; + + if(!common_restrict_check(C, ob)) return; + + /* deselect objects that are invisible */ + if (ob->restrictflag & OB_RESTRICT_VIEW) { + /* Ouch! There is no backwards pointer from Object to Base, + * so have to do loop to find it. */ + ED_base_object_select(object_in_scene(ob, scene), BA_DESELECT); + } + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + +} + +static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2) +{ + Scene *scene = (Scene *)poin; + Object *ob = (Object *)poin2; + + if(!common_restrict_check(C, ob)) return; + + /* if select restriction has just been turned on */ + if (ob->restrictflag & OB_RESTRICT_SELECT) { + /* Ouch! There is no backwards pointer from Object to Base, + * so have to do loop to find it. */ + ED_base_object_select(object_in_scene(ob, scene), BA_DESELECT); + } + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + +} + +static void restrictbutton_rend_cb(bContext *C, void *poin, void *UNUSED(poin2)) +{ + WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, poin); +} + +static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *UNUSED(poin2)) +{ + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, poin); +} + +static void restrictbutton_modifier_cb(bContext *C, void *UNUSED(poin), void *poin2) +{ + Object *ob = (Object *)poin2; + + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); +} + +static void restrictbutton_bone_cb(bContext *C, void *UNUSED(poin), void *poin2) +{ + Bone *bone= (Bone *)poin2; + if(bone && (bone->flag & BONE_HIDDEN_P)) + bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); +} + +static void restrictbutton_ebone_cb(bContext *C, void *UNUSED(poin), void *poin2) +{ + EditBone *ebone= (EditBone *)poin2; + if(ebone && (ebone->flag & BONE_HIDDEN_A)) + ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + + WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); +} + +static int group_restrict_flag(Group *gr, int flag) +{ + GroupObject *gob; + + for(gob= gr->gobject.first; gob; gob= gob->next) { + if((gob->ob->restrictflag & flag) == 0) + return 0; + } + + return 1; +} + +static int group_select_flag(Group *gr) +{ + GroupObject *gob; + + for(gob= gr->gobject.first; gob; gob= gob->next) + if((gob->ob->flag & SELECT)) + return 1; + + return 0; +} + +static void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) +{ + Scene *scene = (Scene *)poin; + GroupObject *gob; + Group *gr = (Group *)poin2; + + if(group_restrict_flag(gr, flag)) { + for(gob= gr->gobject.first; gob; gob= gob->next) { + gob->ob->restrictflag &= ~flag; + + if(flag==OB_RESTRICT_VIEW) + if(gob->ob->flag & SELECT) + ED_base_object_select(object_in_scene(gob->ob, scene), BA_DESELECT); + } + } + else { + for(gob= gr->gobject.first; gob; gob= gob->next) { + /* not in editmode */ + if(scene->obedit!=gob->ob) { + gob->ob->restrictflag |= flag; + + if(flag==OB_RESTRICT_VIEW) + if((gob->ob->flag & SELECT) == 0) + ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT); + } + } + } +} + +static void restrictbutton_gr_restrict_view(bContext *C, void *poin, void *poin2) +{ + restrictbutton_gr_restrict_flag(poin, poin2, OB_RESTRICT_VIEW); + WM_event_add_notifier(C, NC_GROUP, NULL); +} +static void restrictbutton_gr_restrict_select(bContext *C, void *poin, void *poin2) +{ + restrictbutton_gr_restrict_flag(poin, poin2, OB_RESTRICT_SELECT); + WM_event_add_notifier(C, NC_GROUP, NULL); +} +static void restrictbutton_gr_restrict_render(bContext *C, void *poin, void *poin2) +{ + restrictbutton_gr_restrict_flag(poin, poin2, OB_RESTRICT_RENDER); + WM_event_add_notifier(C, NC_GROUP, NULL); +} + + +static void namebutton_cb(bContext *C, void *tsep, char *oldname) +{ + SpaceOops *soops= CTX_wm_space_outliner(C); + Scene *scene= CTX_data_scene(C); + Object *obedit= CTX_data_edit_object(C); + TreeStore *ts= soops->treestore; + TreeStoreElem *tselem= tsep; + + if(ts && tselem) { + TreeElement *te= outliner_find_tse(soops, tselem); + + if(tselem->type==0) { + test_idbutton(tselem->id->name+2); // library.c, unique name and alpha sort + + switch(GS(tselem->id->name)) { + case ID_MA: + WM_event_add_notifier(C, NC_MATERIAL, NULL); break; + case ID_TE: + WM_event_add_notifier(C, NC_TEXTURE, NULL); break; + case ID_IM: + WM_event_add_notifier(C, NC_IMAGE, NULL); break; + case ID_SCE: + WM_event_add_notifier(C, NC_SCENE, NULL); break; + default: + WM_event_add_notifier(C, NC_ID|NA_RENAME, NULL); break; + } + /* Check the library target exists */ + if (te->idcode == ID_LI) { + char expanded[FILE_MAXDIR + FILE_MAXFILE]; + BLI_strncpy(expanded, ((Library *)tselem->id)->name, FILE_MAXDIR + FILE_MAXFILE); + BLI_path_abs(expanded, G.main->name); + if (!BLI_exists(expanded)) { + BKE_report(CTX_wm_reports(C), RPT_ERROR, "This path does not exist, correct this before saving"); + } + } + } + else { + switch(tselem->type) { + case TSE_DEFGROUP: + defgroup_unique_name(te->directdata, (Object *)tselem->id); // id = object + break; + case TSE_NLA_ACTION: + test_idbutton(tselem->id->name+2); + break; + case TSE_EBONE: + { + bArmature *arm= (bArmature *)tselem->id; + if(arm->edbo) { + EditBone *ebone= te->directdata; + char newname[sizeof(ebone->name)]; + + /* restore bone name */ + BLI_strncpy(newname, ebone->name, sizeof(ebone->name)); + BLI_strncpy(ebone->name, oldname, sizeof(ebone->name)); + ED_armature_bone_rename(obedit->data, oldname, newname); + WM_event_add_notifier(C, NC_OBJECT|ND_POSE, OBACT); + } + } + break; + + case TSE_BONE: + { + Bone *bone= te->directdata; + Object *ob; + char newname[sizeof(bone->name)]; + + // always make current object active + tree_element_active(C, scene, soops, te, 1); // was set_active_object() + ob= OBACT; + + /* restore bone name */ + BLI_strncpy(newname, bone->name, sizeof(bone->name)); + BLI_strncpy(bone->name, oldname, sizeof(bone->name)); + ED_armature_bone_rename(ob->data, oldname, newname); + WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + } + break; + case TSE_POSE_CHANNEL: + { + bPoseChannel *pchan= te->directdata; + Object *ob; + char newname[sizeof(pchan->name)]; + + // always make current object active + tree_element_active(C, scene, soops, te, 1); // was set_active_object() + ob= OBACT; + + /* restore bone name */ + BLI_strncpy(newname, pchan->name, sizeof(pchan->name)); + BLI_strncpy(pchan->name, oldname, sizeof(pchan->name)); + ED_armature_bone_rename(ob->data, oldname, newname); + WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + } + break; + case TSE_POSEGRP: + { + Object *ob= (Object *)tselem->id; // id = object + bActionGroup *grp= te->directdata; + + BLI_uniquename(&ob->pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), sizeof(grp->name)); + WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + } + break; + case TSE_R_LAYER: + break; + } + } + tselem->flag &= ~TSE_TEXTBUT; + } +} + +static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, ListBase *lb) +{ + uiBut *bt; + TreeElement *te; + TreeStoreElem *tselem; + Object *ob = NULL; + Group *gr = NULL; + + for(te= lb->first; te; te= te->next) { + tselem= TREESTORE(te); + if(te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + /* objects have toggle-able restriction flags */ + if(tselem->type==0 && te->idcode==ID_OB) { + PointerRNA ptr; + + ob = (Object *)tselem->id; + RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ptr); + + uiBlockSetEmboss(block, UI_EMBOSSN); + bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, + &ptr, "hide", -1, 0, 0, -1, -1, NULL); + uiButSetFunc(bt, restrictbutton_view_cb, scene, ob); + + bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, + &ptr, "hide_select", -1, 0, 0, -1, -1, NULL); + uiButSetFunc(bt, restrictbutton_sel_cb, scene, ob); + + bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, + &ptr, "hide_render", -1, 0, 0, -1, -1, NULL); + uiButSetFunc(bt, restrictbutton_rend_cb, scene, ob); + + uiBlockSetEmboss(block, UI_EMBOSS); + + } + if(tselem->type==0 && te->idcode==ID_GR){ + int restrict_bool; + gr = (Group *)tselem->id; + + uiBlockSetEmboss(block, UI_EMBOSSN); + + restrict_bool= group_restrict_flag(gr, OB_RESTRICT_VIEW); + bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + uiButSetFunc(bt, restrictbutton_gr_restrict_view, scene, gr); + + restrict_bool= group_restrict_flag(gr, OB_RESTRICT_SELECT); + bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + uiButSetFunc(bt, restrictbutton_gr_restrict_select, scene, gr); + + restrict_bool= group_restrict_flag(gr, OB_RESTRICT_RENDER); + bt = uiDefIconBut(block, BUT, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow renderability"); + uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr); + + uiBlockSetEmboss(block, UI_EMBOSS); + } + /* scene render layers and passes have toggle-able flags too! */ + else if(tselem->type==TSE_R_LAYER) { + uiBlockSetEmboss(block, UI_EMBOSSN); + + bt= uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, 0, ICON_CHECKBOX_HLT-1, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, te->directdata, 0, 0, 0, 0, "Render this RenderLayer"); + uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); + + uiBlockSetEmboss(block, UI_EMBOSS); + } + else if(tselem->type==TSE_R_PASS) { + int *layflag= te->directdata; + int passflag= 1<<tselem->nr; + + uiBlockSetEmboss(block, UI_EMBOSSN); + + + bt= uiDefIconButBitI(block, ICONTOG, passflag, 0, ICON_CHECKBOX_HLT-1, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, layflag, 0, 0, 0, 0, "Render this Pass"); + uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); + + layflag++; /* is lay_xor */ + if(ELEM8(passflag, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT, SCE_PASS_INDIRECT, SCE_PASS_EMIT, SCE_PASS_ENVIRONMENT)) + bt= uiDefIconButBitI(block, TOG, passflag, 0, (*layflag & passflag)?ICON_DOT:ICON_BLANK1, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined"); + uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); + + uiBlockSetEmboss(block, UI_EMBOSS); + } + else if(tselem->type==TSE_MODIFIER) { + ModifierData *md= (ModifierData *)te->directdata; + ob = (Object *)tselem->id; + + uiBlockSetEmboss(block, UI_EMBOSSN); + bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Realtime, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob); + + bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability"); + uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob); + } + else if(tselem->type==TSE_POSE_CHANNEL) { + bPoseChannel *pchan= (bPoseChannel *)te->directdata; + Bone *bone = pchan->bone; + + uiBlockSetEmboss(block, UI_EMBOSSN); + bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + uiButSetFunc(bt, restrictbutton_bone_cb, NULL, bone); + + bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL); + } + else if(tselem->type==TSE_EBONE) { + EditBone *ebone= (EditBone *)te->directdata; + + uiBlockSetEmboss(block, UI_EMBOSSN); + bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, ebone); + + bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, NULL); + } + } + + if((tselem->flag & TSE_CLOSED)==0) outliner_draw_restrictbuts(block, scene, ar, soops, &te->subtree); + } +} + +static void outliner_draw_rnacols(ARegion *ar, int sizex) +{ + View2D *v2d= &ar->v2d; + + float miny = v2d->cur.ymin-V2D_SCROLL_HEIGHT; + if(miny<v2d->tot.ymin) miny = v2d->tot.ymin; + + UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); + + /* draw column separator lines */ + fdrawline((float)sizex, + v2d->cur.ymax, + (float)sizex, + miny); + + fdrawline((float)sizex+OL_RNA_COL_SIZEX, + v2d->cur.ymax, + (float)sizex+OL_RNA_COL_SIZEX, + miny); +} + +static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, int sizex, ListBase *lb) +{ + TreeElement *te; + TreeStoreElem *tselem; + PointerRNA *ptr; + PropertyRNA *prop; + + uiBlockSetEmboss(block, UI_EMBOSST); + + for(te= lb->first; te; te= te->next) { + tselem= TREESTORE(te); + if(te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + if(tselem->type == TSE_RNA_PROPERTY) { + ptr= &te->rnaptr; + prop= te->directdata; + + if(!(RNA_property_type(prop) == PROP_POINTER && (tselem->flag & TSE_CLOSED)==0)) + uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y-1); + } + else if(tselem->type == TSE_RNA_ARRAY_ELEM) { + ptr= &te->rnaptr; + prop= te->directdata; + + uiDefAutoButR(block, ptr, prop, te->index, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y-1); + } + } + + if((tselem->flag & TSE_CLOSED)==0) outliner_draw_rnabuts(block, scene, ar, soops, sizex, &te->subtree); + } +} + +static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *arg2) +{ + wmOperatorType *ot= arg2; + wmKeyMapItem *kmi= arg_kmi; + + if(ot) + BLI_strncpy(kmi->idname, ot->idname, OP_MAX_TYPENAME); +} + +static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(arg_kmi), const char *str, uiSearchItems *items) +{ + GHashIterator *iter= WM_operatortype_iter(); + + for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + wmOperatorType *ot= BLI_ghashIterator_getValue(iter); + + if(BLI_strcasestr(ot->idname, str)) { + char name[OP_MAX_TYPENAME]; + + /* display name for menu */ + WM_operator_py_idname(name, ot->idname); + + if(0==uiSearchItemAdd(items, name, ot, 0)) + break; + } + } + BLI_ghashIterator_free(iter); +} + +/* operator Search browse menu, open */ +static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi) +{ + static char search[OP_MAX_TYPENAME]; + wmEvent event; + wmWindow *win= CTX_wm_window(C); + wmKeyMapItem *kmi= arg_kmi; + wmOperatorType *ot= WM_operatortype_find(kmi->idname, 0); + uiBlock *block; + uiBut *but; + + /* clear initial search string, then all items show */ + search[0]= 0; + + block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); + uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1); + + /* fake button, it holds space for search items */ + uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); + + but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 0, 150, UI_UNIT_Y, 0, 0, ""); + uiButSetSearchFunc(but, operator_search_cb, arg_kmi, operator_call_cb, ot); + + uiBoundsBlock(block, 6); + uiBlockSetDirection(block, UI_DOWN); + uiEndBlock(C, block); + + event= *(win->eventstate); /* XXX huh huh? make api call */ + event.type= EVT_BUT_OPEN; + event.val= KM_PRESS; + event.customdata= but; + event.customdatafree= FALSE; + wm_event_add(win, &event); + + return block; +} + +#define OL_KM_KEYBOARD 0 +#define OL_KM_MOUSE 1 +#define OL_KM_TWEAK 2 +#define OL_KM_SPECIALS 3 + +static short keymap_menu_type(short type) +{ + if(ISKEYBOARD(type)) return OL_KM_KEYBOARD; + if(ISTWEAK(type)) return OL_KM_TWEAK; + if(ISMOUSE(type)) return OL_KM_MOUSE; +// return OL_KM_SPECIALS; + return 0; +} + +static const char *keymap_type_menu(void) +{ + static const char string[]= + "Event Type%t" + "|Keyboard%x" STRINGIFY(OL_KM_KEYBOARD) + "|Mouse%x" STRINGIFY(OL_KM_MOUSE) + "|Tweak%x" STRINGIFY(OL_KM_TWEAK) +// "|Specials%x" STRINGIFY(OL_KM_SPECIALS) + ; + + return string; +} + +static const char *keymap_mouse_menu(void) +{ + static const char string[]= + "Mouse Event%t" + "|Left Mouse%x" STRINGIFY(LEFTMOUSE) + "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) + "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) + "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) + "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) + "|Button4 Mouse%x" STRINGIFY(BUTTON4MOUSE) + "|Button5 Mouse%x" STRINGIFY(BUTTON5MOUSE) + "|Action Mouse%x" STRINGIFY(ACTIONMOUSE) + "|Select Mouse%x" STRINGIFY(SELECTMOUSE) + "|Mouse Move%x" STRINGIFY(MOUSEMOVE) + "|Wheel Up%x" STRINGIFY(WHEELUPMOUSE) + "|Wheel Down%x" STRINGIFY(WHEELDOWNMOUSE) + "|Wheel In%x" STRINGIFY(WHEELINMOUSE) + "|Wheel Out%x" STRINGIFY(WHEELOUTMOUSE) + "|Mouse/Trackpad Pan%x" STRINGIFY(MOUSEPAN) + "|Mouse/Trackpad Zoom%x" STRINGIFY(MOUSEZOOM) + "|Mouse/Trackpad Rotate%x" STRINGIFY(MOUSEROTATE) + ; + + return string; +} + +static const char *keymap_tweak_menu(void) +{ + static const char string[]= + "Tweak Event%t" + "|Left Mouse%x" STRINGIFY(EVT_TWEAK_L) + "|Middle Mouse%x" STRINGIFY(EVT_TWEAK_M) + "|Right Mouse%x" STRINGIFY(EVT_TWEAK_R) + "|Action Mouse%x" STRINGIFY(EVT_TWEAK_A) + "|Select Mouse%x" STRINGIFY(EVT_TWEAK_S) + ; + + return string; +} + +static const char *keymap_tweak_dir_menu(void) +{ + static const char string[]= + "Tweak Direction%t" + "|Any%x" STRINGIFY(KM_ANY) + "|North%x" STRINGIFY(EVT_GESTURE_N) + "|North-East%x" STRINGIFY(EVT_GESTURE_NE) + "|East%x" STRINGIFY(EVT_GESTURE_E) + "|Sout-East%x" STRINGIFY(EVT_GESTURE_SE) + "|South%x" STRINGIFY(EVT_GESTURE_S) + "|South-West%x" STRINGIFY(EVT_GESTURE_SW) + "|West%x" STRINGIFY(EVT_GESTURE_W) + "|North-West%x" STRINGIFY(EVT_GESTURE_NW) + ; + + return string; +} + + +static void keymap_type_cb(bContext *C, void *kmi_v, void *UNUSED(arg_v)) +{ + wmKeyMapItem *kmi= kmi_v; + short maptype= keymap_menu_type(kmi->type); + + if(maptype!=kmi->maptype) { + switch(kmi->maptype) { + case OL_KM_KEYBOARD: + kmi->type= AKEY; + kmi->val= KM_PRESS; + break; + case OL_KM_MOUSE: + kmi->type= LEFTMOUSE; + kmi->val= KM_PRESS; + break; + case OL_KM_TWEAK: + kmi->type= EVT_TWEAK_L; + kmi->val= KM_ANY; + break; + case OL_KM_SPECIALS: + kmi->type= AKEY; + kmi->val= KM_PRESS; + } + ED_region_tag_redraw(CTX_wm_region(C)); + } +} + +static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soops, ListBase *lb) +{ + TreeElement *te; + TreeStoreElem *tselem; + + uiBlockSetEmboss(block, UI_EMBOSST); + + for(te= lb->first; te; te= te->next) { + tselem= TREESTORE(te); + if(te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + uiBut *but; + const char *str; + int xstart= 240; + int butw1= UI_UNIT_X; /* operator */ + int butw2= 90; /* event type, menus */ + int butw3= 43; /* modifiers */ + + if(tselem->type == TSE_KEYMAP_ITEM) { + wmKeyMapItem *kmi= te->directdata; + + /* modal map? */ + if(kmi->propvalue); + else { + uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, (int)te->ys+1, butw1, UI_UNIT_Y-1, "Assign new Operator"); + } + xstart+= butw1+10; + + /* map type button */ + kmi->maptype= keymap_menu_type(kmi->type); + + str= keymap_type_menu(); + but= uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->maptype, 0, 0, 0, 0, "Event type"); + uiButSetFunc(but, keymap_type_cb, kmi, NULL); + xstart+= butw2+5; + + /* edit actual event */ + switch(kmi->maptype) { + case OL_KM_KEYBOARD: + uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, "Key code"); + xstart+= butw2+5; + break; + case OL_KM_MOUSE: + str= keymap_mouse_menu(); + uiDefButS(block, MENU, 0, str, xstart,(int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, 0, 0, 0, 0, "Mouse button"); + xstart+= butw2+5; + break; + case OL_KM_TWEAK: + str= keymap_tweak_menu(); + uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, 0, 0, 0, 0, "Tweak gesture"); + xstart+= butw2+5; + str= keymap_tweak_dir_menu(); + uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->val, 0, 0, 0, 0, "Tweak gesture direction"); + xstart+= butw2+5; + break; + } + + /* modifiers */ + uiDefButS(block, OPTION, 0, "Shift", xstart, (int)te->ys+1, butw3+5, UI_UNIT_Y-1, &kmi->shift, 0, 0, 0, 0, "Modifier"); xstart+= butw3+5; + uiDefButS(block, OPTION, 0, "Ctrl", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->ctrl, 0, 0, 0, 0, "Modifier"); xstart+= butw3; + uiDefButS(block, OPTION, 0, "Alt", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->alt, 0, 0, 0, 0, "Modifier"); xstart+= butw3; + uiDefButS(block, OPTION, 0, "OS", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->oskey, 0, 0, 0, 0, "Modifier"); xstart+= butw3; + xstart+= 5; + uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->keymodifier, "Key Modifier code"); + xstart+= butw3+5; + + /* rna property */ + if(kmi->ptr && kmi->ptr->data) { + uiDefBut(block, LABEL, 0, "(RNA property)", xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->oskey, 0, 0, 0, 0, ""); xstart+= butw2; + } + + (void)xstart; + } + } + + if((tselem->flag & TSE_CLOSED)==0) outliner_draw_keymapbuts(block, ar, soops, &te->subtree); + } +} + + +static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, SpaceOops *soops, ListBase *lb) +{ + uiBut *bt; + TreeElement *te; + TreeStoreElem *tselem; + int spx, dx, len; + + for(te= lb->first; te; te= te->next) { + tselem= TREESTORE(te); + if(te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + + if(tselem->flag & TSE_TEXTBUT) { + + /* If we add support to rename Sequence. + * need change this. + */ + if(tselem->type == TSE_POSE_BASE) continue; // prevent crash when trying to rename 'pose' entry of armature + + if(tselem->type==TSE_EBONE) len = sizeof(((EditBone*) 0)->name); + else if (tselem->type==TSE_MODIFIER) len = sizeof(((ModifierData*) 0)->name); + else if(tselem->id && GS(tselem->id->name)==ID_LI) len = sizeof(((Library*) 0)->name); + else len= MAX_ID_NAME-2; + + + dx= (int)UI_GetStringWidth(te->name); + if(dx<100) dx= 100; + spx=te->xs+2*UI_UNIT_X-4; + if(spx+dx+10>ar->v2d.cur.xmax) dx = ar->v2d.cur.xmax-spx-10; + + bt= uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, (int)te->ys, dx+10, UI_UNIT_Y-1, (void *)te->name, 1.0, (float)len, 0, 0, ""); + uiButSetRenameFunc(bt, namebutton_cb, tselem); + + /* returns false if button got removed */ + if( 0 == uiButActiveOnly(C, block, bt) ) + tselem->flag &= ~TSE_TEXTBUT; + } + } + + if((tselem->flag & TSE_CLOSED)==0) outliner_buttons(C, block, ar, soops, &te->subtree); + } +} + +/* ****************************************************** */ +/* Normal Drawing... */ + +/* make function calls a bit compacter */ +struct DrawIconArg { + uiBlock *block; + ID *id; + int xmax, x, y; + float alpha; +}; + +static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon) +{ + /* restrict collumn clip... it has been coded by simply overdrawing, doesnt work for buttons */ + if(arg->x >= arg->xmax) + UI_icon_draw(arg->x, arg->y, icon); + else { + /* XXX investigate: button placement of icons is way different than UI_icon_draw? */ + float ufac= UI_UNIT_X/20.0f; + uiBut *but= uiDefIconBut(arg->block, LABEL, 0, icon, arg->x-3.0f*ufac, arg->y, UI_UNIT_X-4.0f*ufac, UI_UNIT_Y-4.0f*ufac, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && arg->id->lib) ? arg->id->lib->name : ""); + + if(arg->id) + uiButSetDragID(but, arg->id); + } + +} + +static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeStoreElem *tselem, TreeElement *te, float alpha) +{ + struct DrawIconArg arg; + + /* make function calls a bit compacter */ + arg.block= block; + arg.id= tselem->id; + arg.xmax= xmax; + arg.x= x; + arg.y= y; + arg.alpha= alpha; + + if(tselem->type) { + switch( tselem->type) { + case TSE_ANIM_DATA: + UI_icon_draw(x, y, ICON_ANIM_DATA); break; // xxx + case TSE_NLA: + UI_icon_draw(x, y, ICON_NLA); break; + case TSE_NLA_TRACK: + UI_icon_draw(x, y, ICON_NLA); break; // XXX + case TSE_NLA_ACTION: + UI_icon_draw(x, y, ICON_ACTION); break; + case TSE_DRIVER_BASE: + +#if 0 // GSOC_PEPPER + + UI_icon_draw(x, y, ICON_DRIVER); break; + +#endif // GSOC_PEPPER + + case TSE_DEFGROUP_BASE: + UI_icon_draw(x, y, ICON_GROUP_VERTEX); break; + case TSE_BONE: + case TSE_EBONE: + UI_icon_draw(x, y, ICON_BONE_DATA); break; + case TSE_CONSTRAINT_BASE: + UI_icon_draw(x, y, ICON_CONSTRAINT); break; + case TSE_MODIFIER_BASE: + UI_icon_draw(x, y, ICON_MODIFIER); break; + case TSE_LINKED_OB: + UI_icon_draw(x, y, ICON_OBJECT_DATA); break; + case TSE_LINKED_PSYS: + UI_icon_draw(x, y, ICON_PARTICLES); break; + case TSE_MODIFIER: + { + Object *ob= (Object *)tselem->id; + ModifierData *md= BLI_findlink(&ob->modifiers, tselem->nr); + switch(md->type) { + case eModifierType_Subsurf: + UI_icon_draw(x, y, ICON_MOD_SUBSURF); break; + case eModifierType_Armature: + UI_icon_draw(x, y, ICON_MOD_ARMATURE); break; + case eModifierType_Lattice: + UI_icon_draw(x, y, ICON_MOD_LATTICE); break; + case eModifierType_Curve: + UI_icon_draw(x, y, ICON_MOD_CURVE); break; + case eModifierType_Build: + UI_icon_draw(x, y, ICON_MOD_BUILD); break; + case eModifierType_Mirror: + UI_icon_draw(x, y, ICON_MOD_MIRROR); break; + case eModifierType_Decimate: + UI_icon_draw(x, y, ICON_MOD_DECIM); break; + case eModifierType_Wave: + UI_icon_draw(x, y, ICON_MOD_WAVE); break; + case eModifierType_Hook: + UI_icon_draw(x, y, ICON_HOOK); break; + case eModifierType_Softbody: + UI_icon_draw(x, y, ICON_MOD_SOFT); break; + case eModifierType_Boolean: + UI_icon_draw(x, y, ICON_MOD_BOOLEAN); break; + case eModifierType_ParticleSystem: + UI_icon_draw(x, y, ICON_MOD_PARTICLES); break; + case eModifierType_ParticleInstance: + UI_icon_draw(x, y, ICON_MOD_PARTICLES); break; + case eModifierType_EdgeSplit: + UI_icon_draw(x, y, ICON_MOD_EDGESPLIT); break; + case eModifierType_Array: + UI_icon_draw(x, y, ICON_MOD_ARRAY); break; + case eModifierType_UVProject: + UI_icon_draw(x, y, ICON_MOD_UVPROJECT); break; + case eModifierType_Displace: + UI_icon_draw(x, y, ICON_MOD_DISPLACE); break; + case eModifierType_Shrinkwrap: + UI_icon_draw(x, y, ICON_MOD_SHRINKWRAP); break; + case eModifierType_Cast: + UI_icon_draw(x, y, ICON_MOD_CAST); break; + case eModifierType_MeshDeform: + UI_icon_draw(x, y, ICON_MOD_MESHDEFORM); break; + case eModifierType_Bevel: + UI_icon_draw(x, y, ICON_MOD_BEVEL); break; + case eModifierType_Smooth: + UI_icon_draw(x, y, ICON_MOD_SMOOTH); break; + case eModifierType_SimpleDeform: + UI_icon_draw(x, y, ICON_MOD_SIMPLEDEFORM); break; + case eModifierType_Mask: + UI_icon_draw(x, y, ICON_MOD_MASK); break; + case eModifierType_Cloth: + UI_icon_draw(x, y, ICON_MOD_CLOTH); break; + case eModifierType_Explode: + UI_icon_draw(x, y, ICON_MOD_EXPLODE); break; + case eModifierType_Collision: + UI_icon_draw(x, y, ICON_MOD_PHYSICS); break; + case eModifierType_Fluidsim: + UI_icon_draw(x, y, ICON_MOD_FLUIDSIM); break; + case eModifierType_Multires: + UI_icon_draw(x, y, ICON_MOD_MULTIRES); break; + case eModifierType_Smoke: + UI_icon_draw(x, y, ICON_MOD_SMOKE); break; + case eModifierType_Solidify: + UI_icon_draw(x, y, ICON_MOD_SOLIDIFY); break; + case eModifierType_Screw: + UI_icon_draw(x, y, ICON_MOD_SCREW); break; + default: + UI_icon_draw(x, y, ICON_DOT); break; + } + break; + } + case TSE_SCRIPT_BASE: + UI_icon_draw(x, y, ICON_TEXT); break; + case TSE_POSE_BASE: + UI_icon_draw(x, y, ICON_ARMATURE_DATA); break; + case TSE_POSE_CHANNEL: + UI_icon_draw(x, y, ICON_BONE_DATA); break; + case TSE_PROXY: + UI_icon_draw(x, y, ICON_GHOST); break; + case TSE_R_LAYER_BASE: + UI_icon_draw(x, y, ICON_RENDERLAYERS); break; + case TSE_R_LAYER: + UI_icon_draw(x, y, ICON_RENDERLAYERS); break; + case TSE_LINKED_LAMP: + UI_icon_draw(x, y, ICON_LAMP_DATA); break; + case TSE_LINKED_MAT: + UI_icon_draw(x, y, ICON_MATERIAL_DATA); break; + case TSE_POSEGRP_BASE: + UI_icon_draw(x, y, ICON_VERTEXSEL); break; + case TSE_SEQUENCE: + if(te->idcode==SEQ_MOVIE) + UI_icon_draw(x, y, ICON_SEQUENCE); + else if(te->idcode==SEQ_META) + UI_icon_draw(x, y, ICON_DOT); + else if(te->idcode==SEQ_SCENE) + UI_icon_draw(x, y, ICON_SCENE); + else if(te->idcode==SEQ_SOUND) + UI_icon_draw(x, y, ICON_SOUND); + else if(te->idcode==SEQ_IMAGE) + UI_icon_draw(x, y, ICON_IMAGE_COL); + else + UI_icon_draw(x, y, ICON_PARTICLES); + break; + case TSE_SEQ_STRIP: + UI_icon_draw(x, y, ICON_LIBRARY_DATA_DIRECT); + break; + case TSE_SEQUENCE_DUP: + UI_icon_draw(x, y, ICON_OBJECT_DATA); + break; + case TSE_RNA_STRUCT: + if(RNA_struct_is_ID(te->rnaptr.type)) { + arg.id= (ID *)te->rnaptr.data; + tselem_draw_icon_uibut(&arg, RNA_struct_ui_icon(te->rnaptr.type)); + } + else + UI_icon_draw(x, y, RNA_struct_ui_icon(te->rnaptr.type)); + break; + default: + UI_icon_draw(x, y, ICON_DOT); break; + } + } + else if (GS(tselem->id->name) == ID_OB) { + Object *ob= (Object *)tselem->id; + switch (ob->type) { + case OB_LAMP: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_LAMP); break; + case OB_MESH: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_MESH); break; + case OB_CAMERA: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_CAMERA); break; + case OB_CURVE: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_CURVE); break; + case OB_MBALL: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_META); break; + case OB_LATTICE: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_LATTICE); break; + case OB_ARMATURE: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_ARMATURE); break; + case OB_FONT: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_FONT); break; + case OB_SURF: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_SURFACE); break; + +#if 0 // GSOC_PEPPER + + case OB_SPEAKER: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_SPEAKER); break; + +#endif // GSOC_PEPPER + + case OB_EMPTY: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_EMPTY); break; + + } + } + else { + switch( GS(tselem->id->name)) { + case ID_SCE: + tselem_draw_icon_uibut(&arg, ICON_SCENE_DATA); break; + case ID_ME: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_MESH); break; + case ID_CU: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_CURVE); break; + case ID_MB: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_META); break; + case ID_LT: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_LATTICE); break; + case ID_LA: + { + Lamp *la= (Lamp *)tselem->id; + + switch(la->type) { + case LA_LOCAL: + tselem_draw_icon_uibut(&arg, ICON_LAMP_POINT); break; + case LA_SUN: + tselem_draw_icon_uibut(&arg, ICON_LAMP_SUN); break; + case LA_SPOT: + tselem_draw_icon_uibut(&arg, ICON_LAMP_SPOT); break; + case LA_HEMI: + tselem_draw_icon_uibut(&arg, ICON_LAMP_HEMI); break; + case LA_AREA: + tselem_draw_icon_uibut(&arg, ICON_LAMP_AREA); break; + default: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_LAMP); break; + } + break; + } + case ID_MA: + tselem_draw_icon_uibut(&arg, ICON_MATERIAL_DATA); break; + case ID_TE: + tselem_draw_icon_uibut(&arg, ICON_TEXTURE_DATA); break; + case ID_IM: + tselem_draw_icon_uibut(&arg, ICON_IMAGE_DATA); break; + +#if 0 // GSOC_PEPPER + + case ID_SPK: + case ID_SO: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_SPEAKER); break; + +#endif // GSOC_PEPPER + + case ID_AR: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_ARMATURE); break; + case ID_CA: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_CAMERA); break; + case ID_KE: + tselem_draw_icon_uibut(&arg, ICON_SHAPEKEY_DATA); break; + case ID_WO: + tselem_draw_icon_uibut(&arg, ICON_WORLD_DATA); break; + case ID_AC: + tselem_draw_icon_uibut(&arg, ICON_ACTION); break; + case ID_NLA: + tselem_draw_icon_uibut(&arg, ICON_NLA); break; + case ID_TXT: + tselem_draw_icon_uibut(&arg, ICON_SCRIPT); break; + case ID_GR: + tselem_draw_icon_uibut(&arg, ICON_GROUP); break; + case ID_LI: + tselem_draw_icon_uibut(&arg, ICON_LIBRARY_DATA_DIRECT); break; + } + } +} + +static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, SpaceOops *soops, ListBase *lb, int level, int xmax, int *offsx, int ys) +{ + TreeElement *te; + TreeStoreElem *tselem; + int active; + + for(te= lb->first; te; te= te->next) { + + /* exit drawing early */ + if((*offsx) - UI_UNIT_X > xmax) + break; + + tselem= TREESTORE(te); + + /* object hierarchy always, further constrained on level */ + if(level<1 || (tselem->type==0 && te->idcode==ID_OB)) { + + /* active blocks get white circle */ + if(tselem->type==0) { + if(te->idcode==ID_OB) active= (OBACT==(Object *)tselem->id); + else if(scene->obedit && scene->obedit->data==tselem->id) active= 1; // XXX use context? + else active= tree_element_active(C, scene, soops, te, 0); + } + else active= tree_element_type_active(NULL, scene, soops, te, tselem, 0); + + if(active) { + float ufac= UI_UNIT_X/20.0f; + + uiSetRoundBox(15); + glColor4ub(255, 255, 255, 100); + uiRoundBox( (float)*offsx-0.5f*ufac, (float)ys-1.0f*ufac, (float)*offsx+UI_UNIT_Y-3.0f*ufac, (float)ys+UI_UNIT_Y-3.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac); + glEnable(GL_BLEND); /* roundbox disables */ + } + + tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, 0.5f); + te->xs= (float)*offsx; + te->ys= (float)ys; + te->xend= (short)*offsx+UI_UNIT_X; + te->flag |= TE_ICONROW; // for click + + (*offsx) += UI_UNIT_X; + } + + /* this tree element always has same amount of branches, so dont draw */ + if(tselem->type!=TSE_R_LAYER) + outliner_draw_iconrow(C, block, scene, soops, &te->subtree, level+1, xmax, offsx, ys); + } + +} + +/* closed tree element */ +static void outliner_set_coord_tree_element(SpaceOops *soops, TreeElement *te, int startx, int *starty) +{ + TreeElement *ten; + + /* store coord and continue, we need coordinates for elements outside view too */ + te->xs= (float)startx; + te->ys= (float)(*starty); + + for(ten= te->subtree.first; ten; ten= ten->next) { + outliner_set_coord_tree_element(soops, ten, startx+UI_UNIT_X, starty); + } +} + + +static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int startx, int *starty) +{ + TreeElement *ten; + TreeStoreElem *tselem; + float ufac= UI_UNIT_X/20.0f; + int offsx= 0, active=0; // active=1 active obj, else active data + + tselem= TREESTORE(te); + + if(*starty+2*UI_UNIT_Y >= ar->v2d.cur.ymin && *starty<= ar->v2d.cur.ymax) { + int xmax= ar->v2d.cur.xmax; + + /* icons can be ui buts, we dont want it to overlap with restrict */ + if((soops->flag & SO_HIDE_RESTRICTCOLS)==0) + xmax-= OL_TOGW+UI_UNIT_X; + + glEnable(GL_BLEND); + + /* colors for active/selected data */ + if(tselem->type==0) { + if(te->idcode==ID_SCE) { + if(tselem->id == (ID *)scene) { + glColor4ub(255, 255, 255, 100); + active= 2; + } + } + else if(te->idcode==ID_GR) { + Group *gr = (Group *)tselem->id; + + if(group_select_flag(gr)) { + char col[4]; + UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); + col[3]= 100; + glColor4ubv((GLubyte *)col); + + active= 2; + } + } + else if(te->idcode==ID_OB) { + Object *ob= (Object *)tselem->id; + + if(ob==OBACT || (ob->flag & SELECT)) { + char col[4]= {0, 0, 0, 0}; + + /* outliner active ob: always white text, circle color now similar to view3d */ + + active= 2; /* means it draws a color circle */ + if(ob==OBACT) { + if(ob->flag & SELECT) { + UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col); + col[3]= 100; + } + + active= 1; /* means it draws white text */ + } + else if(ob->flag & SELECT) { + UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); + col[3]= 100; + } + + glColor4ubv((GLubyte *)col); + } + + } + else if(scene->obedit && scene->obedit->data==tselem->id) { + glColor4ub(255, 255, 255, 100); + active= 2; + } + else { + if(tree_element_active(C, scene, soops, te, 0)) { + glColor4ub(220, 220, 255, 100); + active= 2; + } + } + } + else { + if( tree_element_type_active(NULL, scene, soops, te, tselem, 0) ) active= 2; + glColor4ub(220, 220, 255, 100); + } + + /* active circle */ + if(active) { + uiSetRoundBox(15); + uiRoundBox( (float)startx+UI_UNIT_Y-1.5f*ufac, (float)*starty+2.0f*ufac, (float)startx+2.0f*UI_UNIT_Y-4.0f*ufac, (float)*starty+UI_UNIT_Y-1.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac); + glEnable(GL_BLEND); /* roundbox disables it */ + + te->flag |= TE_ACTIVE; // for lookup in display hierarchies + } + + /* open/close icon, only when sublevels, except for scene */ + if(te->subtree.first || (tselem->type==0 && te->idcode==ID_SCE) || (te->flag & TE_LAZY_CLOSED)) { + int icon_x; + if(tselem->type==0 && ELEM(te->idcode, ID_OB, ID_SCE)) + icon_x = startx; + else + icon_x = startx+5*ufac; + + // icons a bit higher + if(tselem->flag & TSE_CLOSED) + UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_RIGHT); + else + UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_DOWN); + } + offsx+= UI_UNIT_X; + + /* datatype icon */ + + if(!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))) { + // icons a bit higher + tselem_draw_icon(block, xmax, (float)startx+offsx - 0.5f*ufac, (float)*starty+2.0f*ufac, tselem, te, 1.0f); + + offsx+= UI_UNIT_X; + } + else + offsx+= 2*ufac; + + if(tselem->type==0 && tselem->id->lib) { + glPixelTransferf(GL_ALPHA_SCALE, 0.5f); + if(tselem->id->flag & LIB_INDIRECT) + UI_icon_draw((float)startx+offsx, (float)*starty+2*ufac, ICON_LIBRARY_DATA_INDIRECT); + else + UI_icon_draw((float)startx+offsx, (float)*starty+2*ufac, ICON_LIBRARY_DATA_DIRECT); + glPixelTransferf(GL_ALPHA_SCALE, 1.0f); + offsx+= UI_UNIT_X; + } + glDisable(GL_BLEND); + + /* name */ + if(active==1) UI_ThemeColor(TH_TEXT_HI); + else if(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.75f); + else UI_ThemeColor(TH_TEXT); + + UI_DrawString(startx+offsx, *starty+5*ufac, te->name); + + offsx+= (int)(UI_UNIT_X + UI_GetStringWidth(te->name)); + + /* closed item, we draw the icons, not when it's a scene, or master-server list though */ + if(tselem->flag & TSE_CLOSED) { + if(te->subtree.first) { + if(tselem->type==0 && te->idcode==ID_SCE); + else if(tselem->type!=TSE_R_LAYER) { /* this tree element always has same amount of branches, so dont draw */ + int tempx= startx+offsx; + + // divider + UI_ThemeColorShade(TH_BACK, -40); + glRecti(tempx -10, *starty+4, tempx -8, *starty+UI_UNIT_Y-4); + + glEnable(GL_BLEND); + glPixelTransferf(GL_ALPHA_SCALE, 0.5); + + outliner_draw_iconrow(C, block, scene, soops, &te->subtree, 0, xmax, &tempx, *starty+2); + + glPixelTransferf(GL_ALPHA_SCALE, 1.0); + glDisable(GL_BLEND); + } + } + } + } + /* store coord and continue, we need coordinates for elements outside view too */ + te->xs= (float)startx; + te->ys= (float)*starty; + te->xend= startx+offsx; + + if((tselem->flag & TSE_CLOSED)==0) { + *starty-= UI_UNIT_Y; + + for(ten= te->subtree.first; ten; ten= ten->next) + outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx+UI_UNIT_X, starty); + } + else { + for(ten= te->subtree.first; ten; ten= ten->next) + outliner_set_coord_tree_element(soops, te, startx, starty); + + *starty-= UI_UNIT_Y; + } +} + +static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx, int *starty) +{ + TreeElement *te; + TreeStoreElem *tselem; + int y1, y2; + + if(lb->first==NULL) return; + + y1=y2= *starty; /* for vertical lines between objects */ + for(te=lb->first; te; te= te->next) { + y2= *starty; + tselem= TREESTORE(te); + + /* horizontal line? */ + if(tselem->type==0 && (te->idcode==ID_OB || te->idcode==ID_SCE)) + glRecti(startx, *starty, startx+UI_UNIT_X, *starty-1); + + *starty-= UI_UNIT_Y; + + if((tselem->flag & TSE_CLOSED)==0) + outliner_draw_hierarchy(soops, &te->subtree, startx+UI_UNIT_X, starty); + } + + /* vertical line */ + te= lb->last; + if(te->parent || lb->first!=lb->last) { + tselem= TREESTORE(te); + if(tselem->type==0 && te->idcode==ID_OB) { + + glRecti(startx, y1+UI_UNIT_Y, startx+1, y2); + } + } +} + +static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase *lb, int *starty) +{ + TreeElement *te; + TreeStoreElem *tselem; + + for(te= lb->first; te; te= te->next) { + tselem= TREESTORE(te); + + /* selection status */ + if((tselem->flag & TSE_CLOSED)==0) + if(tselem->type == TSE_RNA_STRUCT) + glRecti(0, *starty+1, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, *starty+UI_UNIT_Y-1); + + *starty-= UI_UNIT_Y; + if((tselem->flag & TSE_CLOSED)==0) { + outliner_draw_struct_marks(ar, soops, &te->subtree, starty); + if(tselem->type == TSE_RNA_STRUCT) + fdrawline(0, (float)*starty+UI_UNIT_Y, ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, (float)*starty+UI_UNIT_Y); + } + } +} + +static void outliner_draw_selection(ARegion *ar, SpaceOops *soops, ListBase *lb, int *starty) +{ + TreeElement *te; + TreeStoreElem *tselem; + + for(te= lb->first; te; te= te->next) { + tselem= TREESTORE(te); + + /* selection status */ + if(tselem->flag & TSE_SELECTED) { + glRecti(0, *starty+1, (int)ar->v2d.cur.xmax, *starty+UI_UNIT_Y-1); + } + *starty-= UI_UNIT_Y; + if((tselem->flag & TSE_CLOSED)==0) outliner_draw_selection(ar, soops, &te->subtree, starty); + } +} + + +static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops) +{ + TreeElement *te; + int starty, startx; + float col[4]; + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // only once + + if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { + /* struct marks */ + UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); + //UI_ThemeColorShade(TH_BACK, -20); + starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; + outliner_draw_struct_marks(ar, soops, &soops->tree, &starty); + } + + /* always draw selection fill before hierarchy */ + UI_GetThemeColor3fv(TH_BACK, col); + glColor3f(col[0]+0.06f, col[1]+0.08f, col[2]+0.10f); + starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; + outliner_draw_selection(ar, soops, &soops->tree, &starty); + + // grey hierarchy lines + UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.4f); + starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y/2-OL_Y_OFFSET; + startx= 6; + outliner_draw_hierarchy(soops, &soops->tree, startx, &starty); + + // items themselves + starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; + startx= 0; + for(te= soops->tree.first; te; te= te->next) { + outliner_draw_tree_element(C, block, scene, ar, soops, te, startx, &starty); + } +} + + +static void outliner_back(ARegion *ar) +{ + int ystart; + + UI_ThemeColorShade(TH_BACK, 6); + ystart= (int)ar->v2d.tot.ymax; + ystart= UI_UNIT_Y*(ystart/(UI_UNIT_Y))-OL_Y_OFFSET; + + while(ystart+2*UI_UNIT_Y > ar->v2d.cur.ymin) { + glRecti(0, ystart, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, ystart+UI_UNIT_Y); + ystart-= 2*UI_UNIT_Y; + } +} + +static void outliner_draw_restrictcols(ARegion *ar) +{ + int ystart; + + /* background underneath */ + UI_ThemeColor(TH_BACK); + glRecti((int)ar->v2d.cur.xmax-OL_TOGW, (int)ar->v2d.cur.ymin-V2D_SCROLL_HEIGHT-1, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, (int)ar->v2d.cur.ymax); + + UI_ThemeColorShade(TH_BACK, 6); + ystart= (int)ar->v2d.tot.ymax; + ystart= UI_UNIT_Y*(ystart/(UI_UNIT_Y))-OL_Y_OFFSET; + + while(ystart+2*UI_UNIT_Y > ar->v2d.cur.ymin) { + glRecti((int)ar->v2d.cur.xmax-OL_TOGW, ystart, (int)ar->v2d.cur.xmax, ystart+UI_UNIT_Y); + ystart-= 2*UI_UNIT_Y; + } + + UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); + + /* view */ + fdrawline(ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, + ar->v2d.cur.ymax, + ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, + ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); + + /* render */ + fdrawline(ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, + ar->v2d.cur.ymax, + ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, + ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); + + /* render */ + fdrawline(ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, + ar->v2d.cur.ymax, + ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, + ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); +} + +/* ****************************************************** */ +/* Main Entrypoint - Draw contents of Outliner editor */ + +void draw_outliner(const bContext *C) +{ + Main *mainvar= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); + ARegion *ar= CTX_wm_region(C); + View2D *v2d= &ar->v2d; + SpaceOops *soops= CTX_wm_space_outliner(C); + uiBlock *block; + int sizey= 0, sizex= 0, sizex_rna= 0; + + outliner_build_tree(mainvar, scene, soops); // always + + /* get extents of data */ + outliner_height(soops, &soops->tree, &sizey); + + if (ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP)) { + /* RNA has two columns: + * - column 1 is (max_width + OL_RNA_COL_SPACEX) or + * (OL_RNA_COL_X), whichever is wider... + * - column 2 is fixed at OL_RNA_COL_SIZEX + * + * (*) XXX max width for now is a fixed factor of UI_UNIT_X*(max_indention+100) + */ + + /* get actual width of column 1 */ + outliner_rna_width(soops, &soops->tree, &sizex_rna, 0); + sizex_rna= MAX2(OL_RNA_COLX, sizex_rna+OL_RNA_COL_SPACEX); + + /* get width of data (for setting 'tot' rect, this is column 1 + column 2 + a bit extra) */ + if (soops->outlinevis == SO_KEYMAP) + sizex= sizex_rna + OL_RNA_COL_SIZEX*3 + 50; // XXX this is only really a quick hack to make this wide enough... + else + sizex= sizex_rna + OL_RNA_COL_SIZEX + 50; + } + else { + /* width must take into account restriction columns (if visible) so that entries will still be visible */ + //outliner_width(soops, &soops->tree, &sizex); + outliner_rna_width(soops, &soops->tree, &sizex, 0); // XXX should use outliner_width instead when te->xend will be set correctly... + + /* constant offset for restriction columns */ + // XXX this isn't that great yet... + if ((soops->flag & SO_HIDE_RESTRICTCOLS)==0) + sizex += OL_TOGW*3; + } + + /* tweak to display last line (when list bigger than window) */ + sizey += V2D_SCROLL_HEIGHT; + + /* adds vertical offset */ + sizey += OL_Y_OFFSET; + + /* update size of tot-rect (extents of data/viewable area) */ + UI_view2d_totRect_set(v2d, sizex, sizey); + + /* force display to pixel coords */ + v2d->flag |= (V2D_PIXELOFS_X|V2D_PIXELOFS_Y); + /* set matrix for 2d-view controls */ + UI_view2d_view_ortho(v2d); + + /* draw outliner stuff (background, hierachy lines and names) */ + outliner_back(ar); + block= uiBeginBlock(C, ar, "outliner buttons", UI_EMBOSS); + outliner_draw_tree((bContext *)C, block, scene, ar, soops); + + if(ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { + /* draw rna buttons */ + outliner_draw_rnacols(ar, sizex_rna); + outliner_draw_rnabuts(block, scene, ar, soops, sizex_rna, &soops->tree); + } + else if(soops->outlinevis == SO_KEYMAP) { + outliner_draw_keymapbuts(block, ar, soops, &soops->tree); + } + else if (!(soops->flag & SO_HIDE_RESTRICTCOLS)) { + /* draw restriction columns */ + outliner_draw_restrictcols(ar); + outliner_draw_restrictbuts(block, scene, ar, soops, &soops->tree); + } + + /* draw edit buttons if nessecery */ + outliner_buttons(C, block, ar, soops, &soops->tree); + + uiEndBlock(C, block); + uiDrawBlock(C, block); + + /* clear flag that allows quick redraws */ + soops->storeflag &= ~SO_TREESTORE_REDRAW; +} diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c new file mode 100644 index 00000000000..15167a3ba2c --- /dev/null +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -0,0 +1,1398 @@ +/* + * $Id$ + * + * ***** 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. + * + * The Original Code is Copyright (C) 2004 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Joshua Leung + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_outliner/outliner_edit.c + * \ingroup spoutliner + */ + +#include <math.h> +#include <string.h> +#include <stdlib.h> +#include <stddef.h> + +#include "MEM_guardedalloc.h" + +#include "DNA_anim_types.h" +#include "DNA_armature_types.h" +#include "DNA_constraint_types.h" +#include "DNA_camera_types.h" +#include "DNA_group_types.h" +#include "DNA_key_types.h" +#include "DNA_lamp_types.h" +#include "DNA_material_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meta_types.h" +#include "DNA_particle_types.h" +#include "DNA_scene_types.h" +#include "DNA_world_types.h" +#include "DNA_sequence_types.h" +#include "DNA_object_types.h" + +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" +#include "BLI_math_base.h" + +#if defined WIN32 && !defined _LIBC +# include "BLI_fnmatch.h" /* use fnmatch included in blenlib */ +#else +# ifndef _GNU_SOURCE +# define _GNU_SOURCE +# endif +# include <fnmatch.h> +#endif + + +#include "BKE_animsys.h" +#include "BKE_context.h" +#include "BKE_deform.h" +#include "BKE_depsgraph.h" +#include "BKE_fcurve.h" +#include "BKE_global.h" +#include "BKE_group.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_modifier.h" +#include "BKE_report.h" +#include "BKE_scene.h" +#include "BKE_sequencer.h" + +#include "ED_armature.h" +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_util.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "UI_interface.h" +#include "UI_interface_icons.h" +#include "UI_resources.h" +#include "UI_view2d.h" + +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "ED_keyframing.h" + +#include "outliner_intern.h" + +/* ************************************************************** */ +/* Unused Utilities */ +// XXX: where to place these? + +/* This is not used anywhere at the moment */ +#if 0 +/* return 1 when levels were opened */ +static int outliner_open_back(SpaceOops *soops, TreeElement *te) +{ + TreeStoreElem *tselem; + int retval= 0; + + for (te= te->parent; te; te= te->parent) { + tselem= TREESTORE(te); + if (tselem->flag & TSE_CLOSED) { + tselem->flag &= ~TSE_CLOSED; + retval= 1; + } + } + return retval; +} + +static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *teFind, int *found) +{ + TreeElement *te; + TreeStoreElem *tselem; + + for (te= lb->first; te; te= te->next) { + /* check if this tree-element was the one we're seeking */ + if (te == teFind) { + *found= 1; + return; + } + + /* try to see if sub-tree contains it then */ + outliner_open_reveal(soops, &te->subtree, teFind, found); + if (*found) { + tselem= TREESTORE(te); + if (tselem->flag & TSE_CLOSED) + tselem->flag &= ~TSE_CLOSED; + return; + } + } +} +#endif + +/* ************************************************************** */ +/* Click Activated */ + +/* Toggle Open/Closed ------------------------------------------- */ + +static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement *te, int all, const float mval[2]) +{ + + if(mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) { + TreeStoreElem *tselem= TREESTORE(te); + + /* all below close/open? */ + if(all) { + tselem->flag &= ~TSE_CLOSED; + outliner_set_flag(soops, &te->subtree, TSE_CLOSED, !outliner_has_one_flag(soops, &te->subtree, TSE_CLOSED, 1)); + } + else { + if(tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; + else tselem->flag |= TSE_CLOSED; + } + + return 1; + } + + for(te= te->subtree.first; te; te= te->next) { + if(do_outliner_item_openclose(C, soops, te, all, mval)) + return 1; + } + return 0; + +} + +/* event can enterkey, then it opens/closes */ +static int outliner_item_openclose(bContext *C, wmOperator *op, wmEvent *event) +{ + ARegion *ar= CTX_wm_region(C); + SpaceOops *soops= CTX_wm_space_outliner(C); + TreeElement *te; + float fmval[2]; + int all= RNA_boolean_get(op->ptr, "all"); + + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); + + for(te= soops->tree.first; te; te= te->next) { + if(do_outliner_item_openclose(C, soops, te, all, fmval)) + break; + } + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_item_openclose(wmOperatorType *ot) +{ + ot->name= "Open/Close Item"; + ot->idname= "OUTLINER_OT_item_openclose"; + ot->description= "Toggle whether item under cursor is enabled or closed"; + + ot->invoke= outliner_item_openclose; + + ot->poll= ED_operator_outliner_active; + + RNA_def_boolean(ot->srna, "all", 1, "All", "Close or open all items."); +} + +/* Rename --------------------------------------------------- */ + +static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, TreeElement *te, const float mval[2]) +{ + ReportList *reports= CTX_wm_reports(C); // XXX + + if(mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) { + TreeStoreElem *tselem= TREESTORE(te); + + /* name and first icon */ + if(mval[0]>te->xs+UI_UNIT_X && mval[0]<te->xend) { + + /* can't rename rna datablocks entries */ + if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) + ; + else if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) + BKE_report(reports, RPT_WARNING, "Cannot edit builtin name"); + else if(ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) + BKE_report(reports, RPT_WARNING, "Cannot edit sequence name"); + else if(tselem->id->lib) { + // XXX error_libdata(); + } + else if(te->idcode == ID_LI && te->parent) { + BKE_report(reports, RPT_WARNING, "Cannot edit the path of an indirectly linked library"); + } + else { + tselem->flag |= TSE_TEXTBUT; + ED_region_tag_redraw(ar); + } + } + return 1; + } + + for(te= te->subtree.first; te; te= te->next) { + if(do_outliner_item_rename(C, ar, soops, te, mval)) return 1; + } + return 0; +} + +static int outliner_item_rename(bContext *C, wmOperator *UNUSED(op), wmEvent *event) +{ + ARegion *ar= CTX_wm_region(C); + SpaceOops *soops= CTX_wm_space_outliner(C); + TreeElement *te; + float fmval[2]; + + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); + + for(te= soops->tree.first; te; te= te->next) { + if(do_outliner_item_rename(C, ar, soops, te, fmval)) break; + } + + return OPERATOR_FINISHED; +} + + +void OUTLINER_OT_item_rename(wmOperatorType *ot) +{ + ot->name= "Rename Item"; + ot->idname= "OUTLINER_OT_item_rename"; + ot->description= "Rename item under cursor"; + + ot->invoke= outliner_item_rename; + + ot->poll= ED_operator_outliner_active; +} + +/* ************************************************************** */ +/* Setting Toggling Operators */ + +/* =============================================== */ +/* Toggling Utilities (Exported) */ + +/* Apply Settings ------------------------------- */ + +static int outliner_count_levels(SpaceOops *soops, ListBase *lb, int curlevel) +{ + TreeElement *te; + int level=curlevel, lev; + + for(te= lb->first; te; te= te->next) { + + lev= outliner_count_levels(soops, &te->subtree, curlevel+1); + if(lev>level) level= lev; + } + return level; +} + +int outliner_has_one_flag(SpaceOops *soops, ListBase *lb, short flag, short curlevel) +{ + TreeElement *te; + TreeStoreElem *tselem; + int level; + + for(te= lb->first; te; te= te->next) { + tselem= TREESTORE(te); + if(tselem->flag & flag) return curlevel; + + level= outliner_has_one_flag(soops, &te->subtree, flag, curlevel+1); + if(level) return level; + } + return 0; +} + +void outliner_set_flag(SpaceOops *soops, ListBase *lb, short flag, short set) +{ + TreeElement *te; + TreeStoreElem *tselem; + + for(te= lb->first; te; te= te->next) { + tselem= TREESTORE(te); + if(set==0) tselem->flag &= ~flag; + else tselem->flag |= flag; + outliner_set_flag(soops, &te->subtree, flag, set); + } +} + +/* Restriction Columns ------------------------------- */ + +/* same check needed for both object operation and restrict column button func + * return 0 when in edit mode (cannot restrict view or select) + * otherwise return 1 */ +int common_restrict_check(bContext *C, Object *ob) +{ + /* Don't allow hide an object in edit mode, + * check the bug #22153 and #21609, #23977 + */ + Object *obedit= CTX_data_edit_object(C); + if (obedit && obedit == ob) { + /* found object is hidden, reset */ + if (ob->restrictflag & OB_RESTRICT_VIEW) + ob->restrictflag &= ~OB_RESTRICT_VIEW; + /* found object is unselectable, reset */ + if (ob->restrictflag & OB_RESTRICT_SELECT) + ob->restrictflag &= ~OB_RESTRICT_SELECT; + return 0; + } + + return 1; +} + +/* =============================================== */ +/* Restriction toggles */ + +/* Toggle Visibility ---------------------------------------- */ + +void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + Base *base= (Base *)te->directdata; + Object *ob = (Object *)tselem->id; + + /* add check for edit mode */ + if(!common_restrict_check(C, ob)) return; + + if(base || (base= object_in_scene(ob, scene))) { + if((base->object->restrictflag ^= OB_RESTRICT_VIEW)) { + ED_base_object_select(base, BA_DESELECT); + } + } +} + +static int outliner_toggle_visibility_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceOops *soops= CTX_wm_space_outliner(C); + Scene *scene= CTX_data_scene(C); + ARegion *ar= CTX_wm_region(C); + + outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb); + + WM_event_add_notifier(C, NC_SCENE|ND_OB_VISIBLE, scene); + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_visibility_toggle(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Toggle Visibility"; + ot->idname= "OUTLINER_OT_visibility_toggle"; + ot->description= "Toggle the visibility of selected items"; + + /* callbacks */ + ot->exec= outliner_toggle_visibility_exec; + ot->poll= ED_operator_outliner_active_no_editobject; + + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/* Toggle Selectability ---------------------------------------- */ + +void object_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + Base *base= (Base *)te->directdata; + + if(base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if(base) { + base->object->restrictflag^=OB_RESTRICT_SELECT; + } +} + +static int outliner_toggle_selectability_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceOops *soops= CTX_wm_space_outliner(C); + Scene *scene= CTX_data_scene(C); + ARegion *ar= CTX_wm_region(C); + + outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_selectability_cb); + + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_selectability_toggle(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Toggle Selectability"; + ot->idname= "OUTLINER_OT_selectability_toggle"; + ot->description= "Toggle the selectability"; + + /* callbacks */ + ot->exec= outliner_toggle_selectability_exec; + ot->poll= ED_operator_outliner_active_no_editobject; + + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/* Toggle Renderability ---------------------------------------- */ + +void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + Base *base= (Base *)te->directdata; + + if(base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if(base) { + base->object->restrictflag^=OB_RESTRICT_RENDER; + } +} + +static int outliner_toggle_renderability_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceOops *soops= CTX_wm_space_outliner(C); + Scene *scene= CTX_data_scene(C); + ARegion *ar= CTX_wm_region(C); + + outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb); + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_renderability_toggle(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Toggle Renderability"; + ot->idname= "OUTLINER_OT_renderability_toggle"; + ot->description= "Toggle the renderability of selected items"; + + /* callbacks */ + ot->exec= outliner_toggle_renderability_exec; + ot->poll= ED_operator_outliner_active; + + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/* =============================================== */ +/* Outliner setting toggles */ + +/* Toggle Expanded (Outliner) ---------------------------------------- */ + +static int outliner_toggle_expanded_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceOops *soops= CTX_wm_space_outliner(C); + ARegion *ar= CTX_wm_region(C); + + if (outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1)) + outliner_set_flag(soops, &soops->tree, TSE_CLOSED, 0); + else + outliner_set_flag(soops, &soops->tree, TSE_CLOSED, 1); + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_expanded_toggle(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Expand/Collapse All"; + ot->idname= "OUTLINER_OT_expanded_toggle"; + ot->description= "Expand/Collapse all items"; + + /* callbacks */ + ot->exec= outliner_toggle_expanded_exec; + ot->poll= ED_operator_outliner_active; + + /* no undo or registry, UI option */ +} + +/* Toggle Selected (Outliner) ---------------------------------------- */ + +static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceOops *soops= CTX_wm_space_outliner(C); + ARegion *ar= CTX_wm_region(C); + Scene *scene= CTX_data_scene(C); + + if (outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1)) + outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); + else + outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 1); + + soops->storeflag |= SO_TREESTORE_REDRAW; + + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_selected_toggle(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Toggle Selected"; + ot->idname= "OUTLINER_OT_selected_toggle"; + ot->description= "Toggle the Outliner selection of items"; + + /* callbacks */ + ot->exec= outliner_toggle_selected_exec; + ot->poll= ED_operator_outliner_active; + + /* no undo or registry, UI option */ +} + +/* ************************************************************** */ +/* Hotkey Only Operators */ + +/* Show Active --------------------------------------------------- */ + +static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceOops *so= CTX_wm_space_outliner(C); + Scene *scene= CTX_data_scene(C); + ARegion *ar= CTX_wm_region(C); + View2D *v2d= &ar->v2d; + + TreeElement *te; + int xdelta, ytop; + + // TODO: make this get this info from context instead... + if (OBACT == NULL) + return OPERATOR_CANCELLED; + + te= outliner_find_id(so, &so->tree, (ID *)OBACT); + if (te) { + /* make te->ys center of view */ + ytop= (int)(te->ys + (v2d->mask.ymax - v2d->mask.ymin)/2); + if (ytop>0) ytop= 0; + + v2d->cur.ymax= (float)ytop; + v2d->cur.ymin= (float)(ytop-(v2d->mask.ymax - v2d->mask.ymin)); + + /* make te->xs ==> te->xend center of view */ + xdelta = (int)(te->xs - v2d->cur.xmin); + v2d->cur.xmin += xdelta; + v2d->cur.xmax += xdelta; + + so->storeflag |= SO_TREESTORE_REDRAW; + } + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_show_active(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Show Active"; + ot->idname= "OUTLINER_OT_show_active"; + ot->description= "Adjust the view so that the active Object is shown centered"; + + /* callbacks */ + ot->exec= outliner_show_active_exec; + ot->poll= ED_operator_outliner_active; +} + +/* View Panning --------------------------------------------------- */ + +static int outliner_scroll_page_exec(bContext *C, wmOperator *op) +{ + ARegion *ar= CTX_wm_region(C); + int dy= ar->v2d.mask.ymax - ar->v2d.mask.ymin; + int up= 0; + + if(RNA_boolean_get(op->ptr, "up")) + up= 1; + + if(up == 0) dy= -dy; + ar->v2d.cur.ymin+= dy; + ar->v2d.cur.ymax+= dy; + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + + +void OUTLINER_OT_scroll_page(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Scroll Page"; + ot->idname= "OUTLINER_OT_scroll_page"; + ot->description= "Scroll page up or down"; + + /* callbacks */ + ot->exec= outliner_scroll_page_exec; + ot->poll= ED_operator_outliner_active; + + /* properties */ + RNA_def_boolean(ot->srna, "up", 0, "Up", "Scroll up one page."); +} + +/* Search ------------------------------------------------------- */ +// TODO: probably obsolete now with filtering? + +#if 0 + +/* recursive helper for function below */ +static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te, int startx, int *starty) +{ + TreeStoreElem *tselem= TREESTORE(te); + + /* store coord and continue, we need coordinates for elements outside view too */ + te->xs= (float)startx; + te->ys= (float)(*starty); + *starty-= UI_UNIT_Y; + + if((tselem->flag & TSE_CLOSED)==0) { + TreeElement *ten; + for(ten= te->subtree.first; ten; ten= ten->next) { + outliner_set_coordinates_element(soops, ten, startx+UI_UNIT_X, starty); + } + } + +} + +/* to retrieve coordinates with redrawing the entire tree */ +static void outliner_set_coordinates(ARegion *ar, SpaceOops *soops) +{ + TreeElement *te; + int starty= (int)(ar->v2d.tot.ymax)-UI_UNIT_Y; + int startx= 0; + + for(te= soops->tree.first; te; te= te->next) { + outliner_set_coordinates_element(soops, te, startx, &starty); + } +} + +/* find next element that has this name */ +static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *name, int flags, TreeElement *prev, int *prevFound) +{ + TreeElement *te, *tes; + + for (te= lb->first; te; te= te->next) { + int found = outliner_filter_has_name(te, name, flags); + + if(found) { + /* name is right, but is element the previous one? */ + if (prev) { + if ((te != prev) && (*prevFound)) + return te; + if (te == prev) { + *prevFound = 1; + } + } + else + return te; + } + + tes= outliner_find_named(soops, &te->subtree, name, flags, prev, prevFound); + if(tes) return tes; + } + + /* nothing valid found */ + return NULL; +} + +static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int again, int flags) +{ + ReportList *reports = NULL; // CTX_wm_reports(C); + TreeElement *te= NULL; + TreeElement *last_find; + TreeStoreElem *tselem; + int ytop, xdelta, prevFound=0; + char name[32]; + + /* get last found tree-element based on stored search_tse */ + last_find= outliner_find_tse(soops, &soops->search_tse); + + /* determine which type of search to do */ + if (again && last_find) { + /* no popup panel - previous + user wanted to search for next after previous */ + BLI_strncpy(name, soops->search_string, sizeof(name)); + flags= soops->search_flags; + + /* try to find matching element */ + te= outliner_find_named(soops, &soops->tree, name, flags, last_find, &prevFound); + if (te==NULL) { + /* no more matches after previous, start from beginning again */ + prevFound= 1; + te= outliner_find_named(soops, &soops->tree, name, flags, last_find, &prevFound); + } + } + else { + /* pop up panel - no previous, or user didn't want search after previous */ + strcpy(name, ""); +// XXX if (sbutton(name, 0, sizeof(name)-1, "Find: ") && name[0]) { +// te= outliner_find_named(soops, &soops->tree, name, flags, NULL, &prevFound); +// } +// else return; /* XXX RETURN! XXX */ + } + + /* do selection and reveal */ + if (te) { + tselem= TREESTORE(te); + if (tselem) { + /* expand branches so that it will be visible, we need to get correct coordinates */ + if( outliner_open_back(soops, te)) + outliner_set_coordinates(ar, soops); + + /* deselect all visible, and select found element */ + outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); + tselem->flag |= TSE_SELECTED; + + /* make te->ys center of view */ + ytop= (int)(te->ys + (ar->v2d.mask.ymax-ar->v2d.mask.ymin)/2); + if(ytop>0) ytop= 0; + ar->v2d.cur.ymax= (float)ytop; + ar->v2d.cur.ymin= (float)(ytop-(ar->v2d.mask.ymax-ar->v2d.mask.ymin)); + + /* make te->xs ==> te->xend center of view */ + xdelta = (int)(te->xs - ar->v2d.cur.xmin); + ar->v2d.cur.xmin += xdelta; + ar->v2d.cur.xmax += xdelta; + + /* store selection */ + soops->search_tse= *tselem; + + BLI_strncpy(soops->search_string, name, 33); + soops->search_flags= flags; + + /* redraw */ + soops->storeflag |= SO_TREESTORE_REDRAW; + } + } + else { + /* no tree-element found */ + BKE_report(reports, RPT_WARNING, "Not found: %s", name); + } +} +#endif + +/* Show One Level ----------------------------------------------- */ + +/* helper function for Show/Hide one level operator */ +static void outliner_openclose_level(SpaceOops *soops, ListBase *lb, int curlevel, int level, int open) +{ + TreeElement *te; + TreeStoreElem *tselem; + + for(te= lb->first; te; te= te->next) { + tselem= TREESTORE(te); + + if(open) { + if(curlevel<=level) tselem->flag &= ~TSE_CLOSED; + } + else { + if(curlevel>=level) tselem->flag |= TSE_CLOSED; + } + + outliner_openclose_level(soops, &te->subtree, curlevel+1, level, open); + } +} + +static int outliner_one_level_exec(bContext *C, wmOperator *op) +{ + SpaceOops *soops= CTX_wm_space_outliner(C); + ARegion *ar= CTX_wm_region(C); + int add= RNA_boolean_get(op->ptr, "open"); + int level; + + level= outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1); + if(add==1) { + if(level) outliner_openclose_level(soops, &soops->tree, 1, level, 1); + } + else { + if(level==0) level= outliner_count_levels(soops, &soops->tree, 0); + if(level) outliner_openclose_level(soops, &soops->tree, 1, level-1, 0); + } + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_show_one_level(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Show/Hide One Level"; + ot->idname= "OUTLINER_OT_show_one_level"; + ot->description= "Expand/collapse all entries by one level"; + + /* callbacks */ + ot->exec= outliner_one_level_exec; + ot->poll= ED_operator_outliner_active; + + /* no undo or registry, UI option */ + + /* properties */ + RNA_def_boolean(ot->srna, "open", 1, "Open", "Expand all entries one level deep."); +} + +/* Show Hierarchy ----------------------------------------------- */ + +/* helper function for tree_element_shwo_hierarchy() - recursively checks whether subtrees have any objects*/ +static int subtree_has_objects(SpaceOops *soops, ListBase *lb) +{ + TreeElement *te; + TreeStoreElem *tselem; + + for(te= lb->first; te; te= te->next) { + tselem= TREESTORE(te); + if(tselem->type==0 && te->idcode==ID_OB) return 1; + if( subtree_has_objects(soops, &te->subtree)) return 1; + } + return 0; +} + +/* recursive helper function for Show Hierarchy operator */ +static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase *lb) +{ + TreeElement *te; + TreeStoreElem *tselem; + + /* open all object elems, close others */ + for(te= lb->first; te; te= te->next) { + tselem= TREESTORE(te); + + if(tselem->type==0) { + if(te->idcode==ID_SCE) { + if(tselem->id!=(ID *)scene) tselem->flag |= TSE_CLOSED; + else tselem->flag &= ~TSE_CLOSED; + } + else if(te->idcode==ID_OB) { + if(subtree_has_objects(soops, &te->subtree)) tselem->flag &= ~TSE_CLOSED; + else tselem->flag |= TSE_CLOSED; + } + } + else tselem->flag |= TSE_CLOSED; + + if(tselem->flag & TSE_CLOSED); else tree_element_show_hierarchy(scene, soops, &te->subtree); + } +} + +/* show entire object level hierarchy */ +static int outliner_show_hierarchy_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceOops *soops= CTX_wm_space_outliner(C); + ARegion *ar= CTX_wm_region(C); + Scene *scene= CTX_data_scene(C); + + /* recursively open/close levels */ + tree_element_show_hierarchy(scene, soops, &soops->tree); + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_show_hierarchy(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Show Hierarchy"; + ot->idname= "OUTLINER_OT_show_hierarchy"; + ot->description= "Open all object entries and close all others"; + + /* callbacks */ + ot->exec= outliner_show_hierarchy_exec; + ot->poll= ED_operator_outliner_active; // TODO: shouldn't be allowed in RNA views... + + /* no undo or registry, UI option */ +} + +/* ************************************************************** */ +/* ANIMATO OPERATIONS */ +/* KeyingSet and Driver Creation - Helper functions */ + +/* specialised poll callback for these operators to work in Datablocks view only */ +static int ed_operator_outliner_datablocks_active(bContext *C) +{ + ScrArea *sa= CTX_wm_area(C); + if ((sa) && (sa->spacetype==SPACE_OUTLINER)) { + SpaceOops *so= CTX_wm_space_outliner(C); + return (so->outlinevis == SO_DATABLOCKS); + } + return 0; +} + + +/* Helper func to extract an RNA path from selected tree element + * NOTE: the caller must zero-out all values of the pointers that it passes here first, as + * this function does not do that yet + */ +static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, + ID **id, char **path, int *array_index, short *flag, short *UNUSED(groupmode)) +{ + ListBase hierarchy = {NULL, NULL}; + LinkData *ld; + TreeElement *tem, *temnext, *temsub; + TreeStoreElem *tse, *tsenext; + PointerRNA *ptr, *nextptr; + PropertyRNA *prop; + char *newpath=NULL; + + /* optimise tricks: + * - Don't do anything if the selected item is a 'struct', but arrays are allowed + */ + if (tselem->type == TSE_RNA_STRUCT) + return; + + /* Overview of Algorithm: + * 1. Go up the chain of parents until we find the 'root', taking note of the + * levels encountered in reverse-order (i.e. items are added to the start of the list + * for more convenient looping later) + * 2. Walk down the chain, adding from the first ID encountered + * (which will become the 'ID' for the KeyingSet Path), and build a + * path as we step through the chain + */ + + /* step 1: flatten out hierarchy of parents into a flat chain */ + for (tem= te->parent; tem; tem= tem->parent) { + ld= MEM_callocN(sizeof(LinkData), "LinkData for tree_element_to_path()"); + ld->data= tem; + BLI_addhead(&hierarchy, ld); + } + + /* step 2: step down hierarchy building the path (NOTE: addhead in previous loop was needed so that we can loop like this) */ + for (ld= hierarchy.first; ld; ld= ld->next) { + /* get data */ + tem= (TreeElement *)ld->data; + tse= TREESTORE(tem); + ptr= &tem->rnaptr; + prop= tem->directdata; + + /* check if we're looking for first ID, or appending to path */ + if (*id) { + /* just 'append' property to path + * - to prevent memory leaks, we must write to newpath not path, then free old path + swap them + */ + if(tse->type == TSE_RNA_PROPERTY) { + if(RNA_property_type(prop) == PROP_POINTER) { + /* for pointer we just append property name */ + newpath= RNA_path_append(*path, ptr, prop, 0, NULL); + } + else if(RNA_property_type(prop) == PROP_COLLECTION) { + char buf[128], *name; + + temnext= (TreeElement*)(ld->next->data); + tsenext= TREESTORE(temnext); + + nextptr= &temnext->rnaptr; + name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf)); + + if(name) { + /* if possible, use name as a key in the path */ + newpath= RNA_path_append(*path, NULL, prop, 0, name); + + if(name != buf) + MEM_freeN(name); + } + else { + /* otherwise use index */ + int index= 0; + + for(temsub=tem->subtree.first; temsub; temsub=temsub->next, index++) + if(temsub == temnext) + break; + + newpath= RNA_path_append(*path, NULL, prop, index, NULL); + } + + ld= ld->next; + } + } + + if(newpath) { + if (*path) MEM_freeN(*path); + *path= newpath; + newpath= NULL; + } + } + else { + /* no ID, so check if entry is RNA-struct, and if that RNA-struct is an ID datablock to extract info from */ + if (tse->type == TSE_RNA_STRUCT) { + /* ptr->data not ptr->id.data seems to be the one we want, since ptr->data is sometimes the owner of this ID? */ + if(RNA_struct_is_ID(ptr->type)) { + *id= (ID *)ptr->data; + + /* clear path */ + if(*path) { + MEM_freeN(*path); + path= NULL; + } + } + } + } + } + + /* step 3: if we've got an ID, add the current item to the path */ + if (*id) { + /* add the active property to the path */ + ptr= &te->rnaptr; + prop= te->directdata; + + /* array checks */ + if (tselem->type == TSE_RNA_ARRAY_ELEM) { + /* item is part of an array, so must set the array_index */ + *array_index= te->index; + } + else if (RNA_property_array_length(ptr, prop)) { + /* entire array was selected, so keyframe all */ + *flag |= KSP_FLAG_WHOLE_ARRAY; + } + + /* path */ + newpath= RNA_path_append(*path, NULL, prop, 0, NULL); + if (*path) MEM_freeN(*path); + *path= newpath; + } + + /* free temp data */ + BLI_freelistN(&hierarchy); +} + +/* =============================================== */ +/* Driver Operations */ + +/* These operators are only available in databrowser mode for now, as + * they depend on having RNA paths and/or hierarchies available. + */ +enum { + DRIVERS_EDITMODE_ADD = 0, + DRIVERS_EDITMODE_REMOVE, +} /*eDrivers_EditModes*/; + +/* Utilities ---------------------------------- */ + +/* Recursively iterate over tree, finding and working on selected items */ +static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportList *reports, short mode) +{ + TreeElement *te; + TreeStoreElem *tselem; + + for (te= tree->first; te; te=te->next) { + tselem= TREESTORE(te); + + /* if item is selected, perform operation */ + if (tselem->flag & TSE_SELECTED) { + ID *id= NULL; + char *path= NULL; + int array_index= 0; + short flag= 0; + short groupmode= KSP_GROUP_KSNAME; + + /* check if RNA-property described by this selected element is an animateable prop */ + if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) { + /* get id + path + index info from the selected element */ + tree_element_to_path(soops, te, tselem, + &id, &path, &array_index, &flag, &groupmode); + } + + /* only if ID and path were set, should we perform any actions */ + if (id && path) { + short dflags = CREATEDRIVER_WITH_DEFAULT_DVAR; + int arraylen = 1; + + /* array checks */ + if (flag & KSP_FLAG_WHOLE_ARRAY) { + /* entire array was selected, so add drivers for all */ + arraylen= RNA_property_array_length(&te->rnaptr, te->directdata); + } + else + arraylen= array_index; + + /* we should do at least one step */ + if (arraylen == array_index) + arraylen++; + + /* for each array element we should affect, add driver */ + for (; array_index < arraylen; array_index++) { + /* action depends on mode */ + switch (mode) { + case DRIVERS_EDITMODE_ADD: + { + /* add a new driver with the information obtained (only if valid) */ + ANIM_add_driver(reports, id, path, array_index, dflags, DRIVER_TYPE_PYTHON); + } + break; + case DRIVERS_EDITMODE_REMOVE: + { + /* remove driver matching the information obtained (only if valid) */ + ANIM_remove_driver(reports, id, path, array_index, dflags); + } + break; + } + } + + /* free path, since it had to be generated */ + MEM_freeN(path); + } + + + } + + /* go over sub-tree */ + if ((tselem->flag & TSE_CLOSED)==0) + do_outliner_drivers_editop(soops, &te->subtree, reports, mode); + } +} + +/* Add Operator ---------------------------------- */ + +static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op) +{ + SpaceOops *soutliner= CTX_wm_space_outliner(C); + + /* check for invalid states */ + if (soutliner == NULL) + return OPERATOR_CANCELLED; + + /* recursively go into tree, adding selected items */ + do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_ADD); + + /* send notifiers */ + WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot) +{ + /* api callbacks */ + ot->idname= "OUTLINER_OT_drivers_add_selected"; + ot->name= "Add Drivers for Selected"; + ot->description= "Add drivers to selected items"; + + /* api callbacks */ + ot->exec= outliner_drivers_addsel_exec; + ot->poll= ed_operator_outliner_datablocks_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} + + +/* Remove Operator ---------------------------------- */ + +static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op) +{ + SpaceOops *soutliner= CTX_wm_space_outliner(C); + + /* check for invalid states */ + if (soutliner == NULL) + return OPERATOR_CANCELLED; + + /* recursively go into tree, adding selected items */ + do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_REMOVE); + + /* send notifiers */ + WM_event_add_notifier(C, ND_KEYS, NULL); // XXX + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot) +{ + /* identifiers */ + ot->idname= "OUTLINER_OT_drivers_delete_selected"; + ot->name= "Delete Drivers for Selected"; + ot->description= "Delete drivers assigned to selected items"; + + /* api callbacks */ + ot->exec= outliner_drivers_deletesel_exec; + ot->poll= ed_operator_outliner_datablocks_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/* =============================================== */ +/* Keying Set Operations */ + +/* These operators are only available in databrowser mode for now, as + * they depend on having RNA paths and/or hierarchies available. + */ +enum { + KEYINGSET_EDITMODE_ADD = 0, + KEYINGSET_EDITMODE_REMOVE, +} /*eKeyingSet_EditModes*/; + +/* Utilities ---------------------------------- */ + +/* find the 'active' KeyingSet, and add if not found (if adding is allowed) */ +// TODO: should this be an API func? +static KeyingSet *verify_active_keyingset(Scene *scene, short add) +{ + KeyingSet *ks= NULL; + + /* sanity check */ + if (scene == NULL) + return NULL; + + /* try to find one from scene */ + if (scene->active_keyingset > 0) + ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + + /* add if none found */ + // XXX the default settings have yet to evolve + if ((add) && (ks==NULL)) { + ks= BKE_keyingset_add(&scene->keyingsets, NULL, KEYINGSET_ABSOLUTE, 0); + scene->active_keyingset= BLI_countlist(&scene->keyingsets); + } + + return ks; +} + +/* Recursively iterate over tree, finding and working on selected items */ +static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBase *tree, short mode) +{ + TreeElement *te; + TreeStoreElem *tselem; + + for (te= tree->first; te; te=te->next) { + tselem= TREESTORE(te); + + /* if item is selected, perform operation */ + if (tselem->flag & TSE_SELECTED) { + ID *id= NULL; + char *path= NULL; + int array_index= 0; + short flag= 0; + short groupmode= KSP_GROUP_KSNAME; + + /* check if RNA-property described by this selected element is an animateable prop */ + if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) { + /* get id + path + index info from the selected element */ + tree_element_to_path(soops, te, tselem, + &id, &path, &array_index, &flag, &groupmode); + } + + /* only if ID and path were set, should we perform any actions */ + if (id && path) { + /* action depends on mode */ + switch (mode) { + case KEYINGSET_EDITMODE_ADD: + { + /* add a new path with the information obtained (only if valid) */ + // TODO: what do we do with group name? for now, we don't supply one, and just let this use the KeyingSet name + BKE_keyingset_add_path(ks, id, NULL, path, array_index, flag, groupmode); + ks->active_path= BLI_countlist(&ks->paths); + } + break; + case KEYINGSET_EDITMODE_REMOVE: + { + /* find the relevant path, then remove it from the KeyingSet */ + KS_Path *ksp= BKE_keyingset_find_path(ks, id, NULL, path, array_index, groupmode); + + if (ksp) { + /* free path's data */ + BKE_keyingset_free_path(ks, ksp); + + ks->active_path= 0; + } + } + break; + } + + /* free path, since it had to be generated */ + MEM_freeN(path); + } + } + + /* go over sub-tree */ + if ((tselem->flag & TSE_CLOSED)==0) + do_outliner_keyingset_editop(soops, ks, &te->subtree, mode); + } +} + +/* Add Operator ---------------------------------- */ + +static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op) +{ + SpaceOops *soutliner= CTX_wm_space_outliner(C); + Scene *scene= CTX_data_scene(C); + KeyingSet *ks= verify_active_keyingset(scene, 1); + + /* check for invalid states */ + if (ks == NULL) { + BKE_report(op->reports, RPT_ERROR, "Operation requires an Active Keying Set"); + return OPERATOR_CANCELLED; + } + if (soutliner == NULL) + return OPERATOR_CANCELLED; + + /* recursively go into tree, adding selected items */ + do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_ADD); + + /* send notifiers */ + WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot) +{ + /* identifiers */ + ot->idname= "OUTLINER_OT_keyingset_add_selected"; + ot->name= "Keying Set Add Selected"; + ot->description= "Add selected items (blue-grey rows) to active Keying Set"; + + /* api callbacks */ + ot->exec= outliner_keyingset_additems_exec; + ot->poll= ed_operator_outliner_datablocks_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} + + +/* Remove Operator ---------------------------------- */ + +static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceOops *soutliner= CTX_wm_space_outliner(C); + Scene *scene= CTX_data_scene(C); + KeyingSet *ks= verify_active_keyingset(scene, 1); + + /* check for invalid states */ + if (soutliner == NULL) + return OPERATOR_CANCELLED; + + /* recursively go into tree, adding selected items */ + do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_REMOVE); + + /* send notifiers */ + WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) +{ + /* identifiers */ + ot->idname= "OUTLINER_OT_keyingset_remove_selected"; + ot->name= "Keying Set Remove Selected"; + ot->description = "Remove selected items (blue-grey rows) from active Keying Set"; + + /* api callbacks */ + ot->exec= outliner_keyingset_removeitems_exec; + ot->poll= ed_operator_outliner_datablocks_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index cbb26d79c4b..85bbbd4fffb 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -44,6 +44,8 @@ struct TreeStoreElem; struct bContext; struct Scene; struct ARegion; +struct ID; +struct Object; typedef struct TreeElement { struct TreeElement *next, *prev, *parent; @@ -107,27 +109,65 @@ typedef struct TreeElement { /* button events */ #define OL_NAMEBUTTON 1 +/* get TreeStoreElem associated with a TreeElement + * < a: (TreeElement) tree element to find stored element for + */ +#define TREESTORE(a) ((a)?soops->treestore->data+(a)->store_index:NULL) -/* outliner_ops.c */ -void outliner_operatortypes(void); -void outliner_keymap(struct wmKeyConfig *keyconf); +/* size constants */ +#define OL_Y_OFFSET 2 -/* outliner_header.c */ -void outliner_header_buttons(const struct bContext *C, struct ARegion *ar); +#define OL_TOG_RESTRICT_VIEWX (UI_UNIT_X*3) +#define OL_TOG_RESTRICT_SELECTX (UI_UNIT_X*2) +#define OL_TOG_RESTRICT_RENDERX UI_UNIT_X + +#define OL_TOGW OL_TOG_RESTRICT_VIEWX + +#define OL_RNA_COLX (UI_UNIT_X*15) +#define OL_RNA_COL_SIZEX (UI_UNIT_X*7.5) +#define OL_RNA_COL_SPACEX (UI_UNIT_X*2.5) + + +/* outliner_tree.c ----------------------------------------------- */ + +void outliner_free_tree(ListBase *lb); + +TreeElement *outliner_find_tse(struct SpaceOops *soops, TreeStoreElem *tse); +TreeElement *outliner_find_id(struct SpaceOops *soops, ListBase *lb, struct ID *id); +struct ID *outliner_search_back(SpaceOops *soops, TreeElement *te, short idcode); + +void outliner_build_tree(struct Main *mainvar, struct Scene *scene, struct SpaceOops *soops); + +/* outliner_draw.c ---------------------------------------------- */ -/* outliner.c */ -void outliner_free_tree(struct ListBase *lb); -void outliner_select(struct SpaceOops *soops, struct ListBase *lb, int *index, short *selecting); void draw_outliner(const struct bContext *C); +/* outliner_select.c -------------------------------------------- */ + +void outliner_select(struct SpaceOops *soops, ListBase *lb, int *index, short *selecting); + +int tree_element_type_active(struct bContext *C, struct Scene *scene, struct SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, int set); +int tree_element_active(struct bContext *C, struct Scene *scene, SpaceOops *soops, TreeElement *te, int set); + +/* outliner_edit.c ---------------------------------------------- */ + +void outliner_do_object_operation(struct bContext *C, struct Scene *scene, struct SpaceOops *soops, struct ListBase *lb, + void (*operation_cb)(struct bContext *C, struct Scene *scene, struct TreeElement *, struct TreeStoreElem *, TreeStoreElem *)); + +int common_restrict_check(struct bContext *C, struct Object *ob); + +int outliner_has_one_flag(struct SpaceOops *soops, ListBase *lb, short flag, short curlevel); +void outliner_set_flag(struct SpaceOops *soops, ListBase *lb, short flag, short set); + +void object_toggle_visibility_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); +void object_toggle_selectability_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); +void object_toggle_renderability_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); + +/* ...................................................... */ + void OUTLINER_OT_item_activate(struct wmOperatorType *ot); void OUTLINER_OT_item_openclose(struct wmOperatorType *ot); void OUTLINER_OT_item_rename(struct wmOperatorType *ot); -void OUTLINER_OT_operation(struct wmOperatorType *ot); -void OUTLINER_OT_object_operation(struct wmOperatorType *ot); -void OUTLINER_OT_group_operation(struct wmOperatorType *ot); -void OUTLINER_OT_id_operation(struct wmOperatorType *ot); -void OUTLINER_OT_data_operation(struct wmOperatorType *ot); void OUTLINER_OT_show_one_level(struct wmOperatorType *ot); void OUTLINER_OT_show_active(struct wmOperatorType *ot); @@ -148,5 +188,23 @@ void OUTLINER_OT_keyingset_remove_selected(struct wmOperatorType *ot); void OUTLINER_OT_drivers_add_selected(struct wmOperatorType *ot); void OUTLINER_OT_drivers_delete_selected(struct wmOperatorType *ot); -#endif /* ED_OUTLINER_INTERN_H */ +/* outliner_tools.c ---------------------------------------------- */ + +void OUTLINER_OT_operation(struct wmOperatorType *ot); +void OUTLINER_OT_object_operation(struct wmOperatorType *ot); +void OUTLINER_OT_group_operation(struct wmOperatorType *ot); +void OUTLINER_OT_id_operation(struct wmOperatorType *ot); +void OUTLINER_OT_data_operation(struct wmOperatorType *ot); +void OUTLINER_OT_animdata_operation(struct wmOperatorType *ot); +void OUTLINER_OT_action_set(struct wmOperatorType *ot); + +/* ---------------------------------------------------------------- */ +/* outliner_ops.c */ +void outliner_operatortypes(void); +void outliner_keymap(struct wmKeyConfig *keyconf); + +/* outliner_header.c */ +void outliner_header_buttons(const struct bContext *C, struct ARegion *ar); + +#endif /* ED_OUTLINER_INTERN_H */ diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 8bd30235931..f3e2c352172 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -57,6 +57,13 @@ void outliner_operatortypes(void) WM_operatortype_append(OUTLINER_OT_group_operation); WM_operatortype_append(OUTLINER_OT_id_operation); WM_operatortype_append(OUTLINER_OT_data_operation); + WM_operatortype_append(OUTLINER_OT_animdata_operation); + +#if 0 // GSOC_PEPPER + + WM_operatortype_append(OUTLINER_OT_action_set); + +#endif // GSOC_PEPPER WM_operatortype_append(OUTLINER_OT_show_one_level); WM_operatortype_append(OUTLINER_OT_show_active); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c new file mode 100644 index 00000000000..c571fa1de6c --- /dev/null +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -0,0 +1,867 @@ +/* + * $Id$ + * + * ***** 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. + * + * The Original Code is Copyright (C) 2004 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Joshua Leung + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_outliner/outliner_select.c + * \ingroup spoutliner + */ + +#include <math.h> +#include <string.h> +#include <stdlib.h> +#include <stddef.h> + +#include "MEM_guardedalloc.h" + +#include "DNA_anim_types.h" +#include "DNA_armature_types.h" +#include "DNA_constraint_types.h" +#include "DNA_camera_types.h" +#include "DNA_group_types.h" +#include "DNA_key_types.h" +#include "DNA_lamp_types.h" +#include "DNA_material_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meta_types.h" +#include "DNA_particle_types.h" +#include "DNA_scene_types.h" +#include "DNA_world_types.h" +#include "DNA_sequence_types.h" +#include "DNA_object_types.h" + +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" +#include "BLI_math_base.h" + +#if defined WIN32 && !defined _LIBC +# include "BLI_fnmatch.h" /* use fnmatch included in blenlib */ +#else +# ifndef _GNU_SOURCE +# define _GNU_SOURCE +# endif +# include <fnmatch.h> +#endif + + +#include "BKE_animsys.h" +#include "BKE_context.h" +#include "BKE_deform.h" +#include "BKE_depsgraph.h" +#include "BKE_fcurve.h" +#include "BKE_global.h" +#include "BKE_group.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_modifier.h" +#include "BKE_report.h" +#include "BKE_scene.h" +#include "BKE_sequencer.h" + +#include "ED_armature.h" +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_util.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "UI_interface.h" +#include "UI_interface_icons.h" +#include "UI_resources.h" +#include "UI_view2d.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "outliner_intern.h" + +/* ****************************************************** */ +/* Outliner Selection (grey-blue highlight for rows) */ + +void outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *selecting) +{ + TreeElement *te; + TreeStoreElem *tselem; + + for (te= lb->first; te && *index >= 0; te=te->next, (*index)--) { + tselem= TREESTORE(te); + + /* if we've encountered the right item, set its 'Outliner' selection status */ + if (*index == 0) { + /* this should be the last one, so no need to do anything with index */ + if ((te->flag & TE_ICONROW)==0) { + /* -1 value means toggle testing for now... */ + if (*selecting == -1) { + if (tselem->flag & TSE_SELECTED) + *selecting= 0; + else + *selecting= 1; + } + + /* set selection */ + if (*selecting) + tselem->flag |= TSE_SELECTED; + else + tselem->flag &= ~TSE_SELECTED; + } + } + else if ((tselem->flag & TSE_CLOSED)==0) { + /* Only try selecting sub-elements if we haven't hit the right element yet + * + * Hack warning: + * Index must be reduced before supplying it to the sub-tree to try to do + * selection, however, we need to increment it again for the next loop to + * function correctly + */ + (*index)--; + outliner_select(soops, &te->subtree, index, selecting); + (*index)++; + } + } +} + +/* ****************************************************** */ +/* Outliner Element Selection/Activation on Click */ + +static int tree_element_active_renderlayer(bContext *C, TreeElement *te, TreeStoreElem *tselem, int set) +{ + Scene *sce; + + /* paranoia check */ + if(te->idcode!=ID_SCE) + return 0; + sce= (Scene *)tselem->id; + + if(set) { + sce->r.actlay= tselem->nr; + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, sce); + } + else { + return sce->r.actlay==tselem->nr; + } + return 0; +} + +static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) +{ + TreeStoreElem *tselem= TREESTORE(te); + Scene *sce; + Base *base; + Object *ob= NULL; + + /* if id is not object, we search back */ + if(te->idcode==ID_OB) ob= (Object *)tselem->id; + else { + ob= (Object *)outliner_search_back(soops, te, ID_OB); + if(ob==OBACT) return 0; + } + if(ob==NULL) return 0; + + sce= (Scene *)outliner_search_back(soops, te, ID_SCE); + if(sce && scene != sce) { + ED_screen_set_scene(C, sce); + } + + /* find associated base in current scene */ + base= object_in_scene(ob, scene); + + if(base) { + if(set==2) { + /* swap select */ + if(base->flag & SELECT) + ED_base_object_select(base, BA_DESELECT); + else + ED_base_object_select(base, BA_SELECT); + } + else { + /* deleselect all */ + scene_deselect_all(scene); + ED_base_object_select(base, BA_SELECT); + } + if(C) { + ED_base_object_activate(C, base); /* adds notifier */ + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + } + } + + if(ob!=scene->obedit) + ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); + + return 1; +} + +static int tree_element_active_material(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) +{ + TreeElement *tes; + Object *ob; + + /* we search for the object parent */ + ob= (Object *)outliner_search_back(soops, te, ID_OB); + // note: ob->matbits can be NULL when a local object points to a library mesh. + if(ob==NULL || ob!=OBACT || ob->matbits==NULL) return 0; // just paranoia + + /* searching in ob mat array? */ + tes= te->parent; + if(tes->idcode==ID_OB) { + if(set) { + ob->actcol= te->index+1; + ob->matbits[te->index]= 1; // make ob material active too + ob->colbits |= (1<<te->index); + } + else { + if(ob->actcol == te->index+1) + if(ob->matbits[te->index]) return 1; + } + } + /* or we search for obdata material */ + else { + if(set) { + ob->actcol= te->index+1; + ob->matbits[te->index]= 0; // make obdata material active too + ob->colbits &= ~(1<<te->index); + } + else { + if(ob->actcol == te->index+1) + if(ob->matbits[te->index]==0) return 1; + } + } + if(set) { + WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING, NULL); + } + return 0; +} + +static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) +{ + TreeElement *tep; + TreeStoreElem /* *tselem,*/ *tselemp; + Object *ob=OBACT; + SpaceButs *sbuts=NULL; + + if(ob==NULL) return 0; // no active object + + /*tselem= TREESTORE(te);*/ /*UNUSED*/ + + /* find buttons area (note, this is undefined really still, needs recode in blender) */ + /* XXX removed finding sbuts */ + + /* where is texture linked to? */ + tep= te->parent; + tselemp= TREESTORE(tep); + + if(tep->idcode==ID_WO) { + World *wrld= (World *)tselemp->id; + + if(set) { + if(sbuts) { + // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c + // XXX sbuts->texfrom= 1; + } +// XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture + wrld->texact= te->index; + } + else if(tselemp->id == (ID *)(scene->world)) { + if(wrld->texact==te->index) return 1; + } + } + else if(tep->idcode==ID_LA) { + Lamp *la= (Lamp *)tselemp->id; + if(set) { + if(sbuts) { + // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c + // XXX sbuts->texfrom= 2; + } +// XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture + la->texact= te->index; + } + else { + if(tselemp->id == ob->data) { + if(la->texact==te->index) return 1; + } + } + } + else if(tep->idcode==ID_MA) { + Material *ma= (Material *)tselemp->id; + if(set) { + if(sbuts) { + //sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c + // XXX sbuts->texfrom= 0; + } +// XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture + ma->texact= (char)te->index; + + /* also set active material */ + ob->actcol= tep->index+1; + } + else if(tep->flag & TE_ACTIVE) { // this is active material + if(ma->texact==te->index) return 1; + } + } + + if(set) + WM_event_add_notifier(C, NC_TEXTURE, NULL); + + return 0; +} + + +static int tree_element_active_lamp(bContext *UNUSED(C), Scene *scene, SpaceOops *soops, TreeElement *te, int set) +{ + Object *ob; + + /* we search for the object parent */ + ob= (Object *)outliner_search_back(soops, te, ID_OB); + if(ob==NULL || ob!=OBACT) return 0; // just paranoia + + if(set) { +// XXX extern_set_butspace(F5KEY, 0); + } + else return 1; + + return 0; +} + +static int tree_element_active_camera(bContext *UNUSED(C), Scene *scene, SpaceOops *soops, TreeElement *te, int set) +{ + Object *ob= (Object *)outliner_search_back(soops, te, ID_OB); + + if(set) + return 0; + + return scene->camera == ob; +} + +static int tree_element_active_world(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) +{ + TreeElement *tep; + TreeStoreElem *tselem=NULL; + Scene *sce=NULL; + + tep= te->parent; + if(tep) { + tselem= TREESTORE(tep); + sce= (Scene *)tselem->id; + } + + if(set) { // make new scene active + if(sce && scene != sce) { + ED_screen_set_scene(C, sce); + } + } + + if(tep==NULL || tselem->id == (ID *)scene) { + if(set) { +// XXX extern_set_butspace(F8KEY, 0); + } + else { + return 1; + } + } + return 0; +} + +static int tree_element_active_defgroup(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) +{ + Object *ob; + + /* id in tselem is object */ + ob= (Object *)tselem->id; + if(set) { + ob->actdef= te->index+1; + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); + } + else { + if(ob==OBACT) + if(ob->actdef== te->index+1) return 1; + } + return 0; +} + +static int tree_element_active_posegroup(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) +{ + Object *ob= (Object *)tselem->id; + + if(set) { + if (ob->pose) { + ob->pose->active_group= te->index+1; + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + } + } + else { + if(ob==OBACT && ob->pose) { + if (ob->pose->active_group== te->index+1) return 1; + } + } + return 0; +} + +static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) +{ + Object *ob= (Object *)tselem->id; + bArmature *arm= ob->data; + bPoseChannel *pchan= te->directdata; + + if(set) { + if(!(pchan->bone->flag & BONE_HIDDEN_P)) { + + if(set==2) ED_pose_deselectall(ob, 2); // 2 = clear active tag + else ED_pose_deselectall(ob, 0); // 0 = deselect + + if(set==2 && (pchan->bone->flag & BONE_SELECTED)) { + pchan->bone->flag &= ~BONE_SELECTED; + } else { + pchan->bone->flag |= BONE_SELECTED; + arm->act_bone= pchan->bone; + } + + WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, ob); + + } + } + else { + if(ob==OBACT && ob->pose) { + if (pchan->bone->flag & BONE_SELECTED) return 1; + } + } + return 0; +} + +static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) +{ + bArmature *arm= (bArmature *)tselem->id; + Bone *bone= te->directdata; + + if(set) { + if(!(bone->flag & BONE_HIDDEN_P)) { + if(set==2) ED_pose_deselectall(OBACT, 2); // 2 is clear active tag + else ED_pose_deselectall(OBACT, 0); + + if(set==2 && (bone->flag & BONE_SELECTED)) { + bone->flag &= ~BONE_SELECTED; + } else { + bone->flag |= BONE_SELECTED; + arm->act_bone= bone; + } + + WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, OBACT); + } + } + else { + Object *ob= OBACT; + + if(ob && ob->data==arm) { + if (bone->flag & BONE_SELECTED) return 1; + } + } + return 0; +} + + +/* ebones only draw in editmode armature */ +static void tree_element_active_ebone__sel(bContext *C, Scene *scene, bArmature *arm, EditBone *ebone, short sel) +{ + if(sel) { + ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL; + arm->act_edbone= ebone; + // flush to parent? + if(ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL; + } + else { + ebone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL); + // flush to parent? + if(ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag &= ~BONE_TIPSEL; + } + + WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, scene->obedit); +} +static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) +{ + bArmature *arm= scene->obedit->data; + EditBone *ebone= te->directdata; + + if(set==1) { + if(!(ebone->flag & BONE_HIDDEN_A)) { + ED_armature_deselect_all(scene->obedit, 0); // deselect + tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); + return 1; + } + } + else if (set==2) { + if(!(ebone->flag & BONE_HIDDEN_A)) { + if(!(ebone->flag & BONE_SELECTED)) { + tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); + return 1; + } + else { + /* entirely selected, so de-select */ + tree_element_active_ebone__sel(C, scene, arm, ebone, FALSE); + return 0; + } + } + } + else if (ebone->flag & BONE_SELECTED) { + return 1; + } + return 0; +} + +static int tree_element_active_modifier(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) +{ + if(set) { + Object *ob= (Object *)tselem->id; + + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + +// XXX extern_set_butspace(F9KEY, 0); + } + + return 0; +} + +static int tree_element_active_psys(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) +{ + if(set) { + Object *ob= (Object *)tselem->id; + + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob); + +// XXX extern_set_butspace(F7KEY, 0); + } + + return 0; +} + +static int tree_element_active_constraint(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) +{ + if(set) { + Object *ob= (Object *)tselem->id; + + WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); +// XXX extern_set_butspace(F7KEY, 0); + } + + return 0; +} + +static int tree_element_active_text(bContext *UNUSED(C), Scene *UNUSED(scene), SpaceOops *UNUSED(soops), TreeElement *UNUSED(te), int UNUSED(set)) +{ + // XXX removed + return 0; +} + +static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) +{ + Object *ob= (Object *)tselem->id; + Base *base= object_in_scene(ob, scene); + + if(set) { + if(scene->obedit) + ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); + + if(ob->mode & OB_MODE_POSE) + ED_armature_exit_posemode(C, base); + else + ED_armature_enter_posemode(C, base); + } + else { + if(ob->mode & OB_MODE_POSE) return 1; + } + return 0; +} + +static int tree_element_active_sequence(TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) +{ + Sequence *seq= (Sequence*) te->directdata; + + if(set) { +// XXX select_single_seq(seq, 1); + } + else { + if(seq->flag & SELECT) + return(1); + } + return(0); +} + +static int tree_element_active_sequence_dup(Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) +{ + Sequence *seq, *p; + Editing *ed= seq_give_editing(scene, FALSE); + + seq= (Sequence*)te->directdata; + if(set==0) { + if(seq->flag & SELECT) + return(1); + return(0); + } + +// XXX select_single_seq(seq, 1); + p= ed->seqbasep->first; + while(p) { + if((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { + p= p->next; + continue; + } + +// if(!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) +// XXX select_single_seq(p, 0); + p= p->next; + } + return(0); +} + +static int tree_element_active_keymap_item(bContext *UNUSED(C), TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) +{ + wmKeyMapItem *kmi= te->directdata; + + if(set==0) { + if(kmi->flag & KMI_INACTIVE) return 0; + return 1; + } + else { + kmi->flag ^= KMI_INACTIVE; + } + return 0; +} + +/* ---------------------------------------------- */ + +/* generic call for ID data check or make/check active in UI */ +int tree_element_active(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) +{ + + switch(te->idcode) { + case ID_OB: + return tree_element_set_active_object(C, scene, soops, te, set); + case ID_MA: + return tree_element_active_material(C, scene, soops, te, set); + case ID_WO: + return tree_element_active_world(C, scene, soops, te, set); + case ID_LA: + return tree_element_active_lamp(C, scene, soops, te, set); + case ID_TE: + return tree_element_active_texture(C, scene, soops, te, set); + case ID_TXT: + return tree_element_active_text(C, scene, soops, te, set); + case ID_CA: + return tree_element_active_camera(C, scene, soops, te, set); + } + return 0; +} + +/* generic call for non-id data to make/check active in UI */ +/* Context can be NULL when set==0 */ +int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, int set) +{ + switch(tselem->type) { + case TSE_DEFGROUP: + return tree_element_active_defgroup(C, scene, te, tselem, set); + case TSE_BONE: + return tree_element_active_bone(C, scene, te, tselem, set); + case TSE_EBONE: + return tree_element_active_ebone(C, scene, te, tselem, set); + case TSE_MODIFIER: + return tree_element_active_modifier(C, te, tselem, set); + case TSE_LINKED_OB: + if(set) tree_element_set_active_object(C, scene, soops, te, set); + else if(tselem->id==(ID *)OBACT) return 1; + break; + case TSE_LINKED_PSYS: + return tree_element_active_psys(C, scene, te, tselem, set); + case TSE_POSE_BASE: + return tree_element_active_pose(C, scene, te, tselem, set); + case TSE_POSE_CHANNEL: + return tree_element_active_posechannel(C, scene, te, tselem, set); + case TSE_CONSTRAINT: + return tree_element_active_constraint(C, te, tselem, set); + case TSE_R_LAYER: + return tree_element_active_renderlayer(C, te, tselem, set); + case TSE_POSEGRP: + return tree_element_active_posegroup(C, scene, te, tselem, set); + case TSE_SEQUENCE: + return tree_element_active_sequence(te, tselem, set); + case TSE_SEQUENCE_DUP: + return tree_element_active_sequence_dup(scene, te, tselem, set); + case TSE_KEYMAP_ITEM: + return tree_element_active_keymap_item(C, te, tselem, set); + + } + return 0; +} + +/* ================================================ */ + +static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int extend, const float mval[2]) +{ + + if(mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) { + TreeStoreElem *tselem= TREESTORE(te); + int openclose= 0; + + /* open close icon */ + if((te->flag & TE_ICONROW)==0) { // hidden icon, no open/close + if( mval[0]>te->xs && mval[0]<te->xs+UI_UNIT_X) + openclose= 1; + } + + if(openclose) { + /* all below close/open? */ + if(extend) { + tselem->flag &= ~TSE_CLOSED; + outliner_set_flag(soops, &te->subtree, TSE_CLOSED, !outliner_has_one_flag(soops, &te->subtree, TSE_CLOSED, 1)); + } + else { + if(tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; + else tselem->flag |= TSE_CLOSED; + + } + + return 1; + } + /* name and first icon */ + else if(mval[0]>te->xs+UI_UNIT_X && mval[0]<te->xend) { + + /* always makes active object */ + if(tselem->type!=TSE_SEQUENCE && tselem->type!=TSE_SEQ_STRIP && tselem->type!=TSE_SEQUENCE_DUP) + tree_element_set_active_object(C, scene, soops, te, 1 + (extend!=0 && tselem->type==0)); + + if(tselem->type==0) { // the lib blocks + /* editmode? */ + if(te->idcode==ID_SCE) { + if(scene!=(Scene *)tselem->id) { + ED_screen_set_scene(C, (Scene *)tselem->id); + } + } + else if(te->idcode==ID_GR) { + Group *gr= (Group *)tselem->id; + GroupObject *gob; + + if(extend) { + int sel= BA_SELECT; + for(gob= gr->gobject.first; gob; gob= gob->next) { + if(gob->ob->flag & SELECT) { + sel= BA_DESELECT; + break; + } + } + + for(gob= gr->gobject.first; gob; gob= gob->next) { + ED_base_object_select(object_in_scene(gob->ob, scene), sel); + } + } + else { + scene_deselect_all(scene); + + for(gob= gr->gobject.first; gob; gob= gob->next) { + if((gob->ob->flag & SELECT) == 0) + ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT); + } + } + + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + } + else if(ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) { + WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL); + } else { // rest of types + tree_element_active(C, scene, soops, te, 1); + } + + } + else tree_element_type_active(C, scene, soops, te, tselem, 1+(extend!=0)); + + return 1; + } + } + + for(te= te->subtree.first; te; te= te->next) { + if(do_outliner_item_activate(C, scene, ar, soops, te, extend, mval)) return 1; + } + return 0; +} + +/* event can enterkey, then it opens/closes */ +static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) +{ + Scene *scene= CTX_data_scene(C); + ARegion *ar= CTX_wm_region(C); + SpaceOops *soops= CTX_wm_space_outliner(C); + TreeElement *te; + float fmval[2]; + int extend= RNA_boolean_get(op->ptr, "extend"); + + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); + + if(!ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && !(soops->flag & SO_HIDE_RESTRICTCOLS) && fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX) + return OPERATOR_CANCELLED; + + for(te= soops->tree.first; te; te= te->next) { + if(do_outliner_item_activate(C, scene, ar, soops, te, extend, fmval)) break; + } + + if(te) { + ED_undo_push(C, "Outliner click event"); + } + else { + short selecting= -1; + int row; + + /* get row number - 100 here is just a dummy value since we don't need the column */ + UI_view2d_listview_view_to_cell(&ar->v2d, 1000, UI_UNIT_Y, 0.0f, OL_Y_OFFSET, + fmval[0], fmval[1], NULL, &row); + + /* select relevant row */ + outliner_select(soops, &soops->tree, &row, &selecting); + + soops->storeflag |= SO_TREESTORE_REDRAW; + + ED_undo_push(C, "Outliner selection event"); + } + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_item_activate(wmOperatorType *ot) +{ + ot->name= "Activate Item"; + ot->idname= "OUTLINER_OT_item_activate"; + ot->description= "Handle mouse clicks to activate/select items"; + + ot->invoke= outliner_item_activate; + + ot->poll= ED_operator_outliner_active; + + RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection for activation."); +} + +/* ****************************************************** */ diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c new file mode 100644 index 00000000000..f5e1a67010e --- /dev/null +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -0,0 +1,1217 @@ +/* + * $Id$ + * + * ***** 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. + * + * The Original Code is Copyright (C) 2004 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Joshua Leung + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_outliner/outliner_tools.c + * \ingroup spoutliner + */ + +#include <math.h> +#include <string.h> +#include <stdlib.h> +#include <stddef.h> + +#include "MEM_guardedalloc.h" + +#include "DNA_anim_types.h" +#include "DNA_armature_types.h" +#include "DNA_constraint_types.h" +#include "DNA_camera_types.h" +#include "DNA_group_types.h" +#include "DNA_key_types.h" +#include "DNA_lamp_types.h" +#include "DNA_material_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meta_types.h" +#include "DNA_particle_types.h" +#include "DNA_scene_types.h" +#include "DNA_world_types.h" +#include "DNA_sequence_types.h" +#include "DNA_object_types.h" + +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" +#include "BLI_math_base.h" + +#if defined WIN32 && !defined _LIBC +# include "BLI_fnmatch.h" /* use fnmatch included in blenlib */ +#else +# ifndef _GNU_SOURCE +# define _GNU_SOURCE +# endif +# include <fnmatch.h> +#endif + + +#include "BKE_animsys.h" +#include "BKE_context.h" +#include "BKE_deform.h" +#include "BKE_depsgraph.h" +#include "BKE_fcurve.h" +#include "BKE_global.h" +#include "BKE_group.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_modifier.h" +#include "BKE_report.h" +#include "BKE_scene.h" +#include "BKE_sequencer.h" + +#include "ED_armature.h" +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_util.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "UI_interface.h" +#include "UI_interface_icons.h" +#include "UI_resources.h" +#include "UI_view2d.h" + +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "outliner_intern.h" + +/* ****************************************************** */ + +/* ************ SELECTION OPERATIONS ********* */ + +static void set_operation_types(SpaceOops *soops, ListBase *lb, + int *scenelevel, + int *objectlevel, + int *idlevel, + int *datalevel) +{ + TreeElement *te; + TreeStoreElem *tselem; + + for(te= lb->first; te; te= te->next) { + tselem= TREESTORE(te); + if(tselem->flag & TSE_SELECTED) { + if(tselem->type) { + if(*datalevel==0) + *datalevel= tselem->type; + else if(*datalevel!=tselem->type) + *datalevel= -1; + } + else { + int idcode= GS(tselem->id->name); + switch(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: */ /* GSOC_PEPPER */ + 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_NLA: case ID_TXT: case ID_GR: + if(*idlevel==0) *idlevel= idcode; + else if(*idlevel!=idcode) *idlevel= -1; + break; + } + } + } + if((tselem->flag & TSE_CLOSED)==0) { + set_operation_types(soops, &te->subtree, + scenelevel, objectlevel, idlevel, datalevel); + } + } +} + +#if 0 // GSOC_PEPPER + +static void unlink_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem)) +{ + /* just set action to NULL */ + BKE_animdata_set_action(CTX_wm_reports(C), tsep->id, NULL); +} + +#endif // GSOC_PEPPER + +static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem)) +{ + Material **matar=NULL; + int a, totcol=0; + + if( GS(tsep->id->name)==ID_OB) { + Object *ob= (Object *)tsep->id; + totcol= ob->totcol; + matar= ob->mat; + } + else if( GS(tsep->id->name)==ID_ME) { + Mesh *me= (Mesh *)tsep->id; + totcol= me->totcol; + matar= me->mat; + } + else if( GS(tsep->id->name)==ID_CU) { + Curve *cu= (Curve *)tsep->id; + totcol= cu->totcol; + matar= cu->mat; + } + else if( GS(tsep->id->name)==ID_MB) { + MetaBall *mb= (MetaBall *)tsep->id; + totcol= mb->totcol; + matar= mb->mat; + } + + for(a=0; a<totcol; a++) { + if(a==te->index && matar[a]) { + matar[a]->id.us--; + matar[a]= NULL; + } + } +} + +static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem)) +{ + MTex **mtex= NULL; + int a; + + if( GS(tsep->id->name)==ID_MA) { + Material *ma= (Material *)tsep->id; + mtex= ma->mtex; + } + else if( GS(tsep->id->name)==ID_LA) { + Lamp *la= (Lamp *)tsep->id; + mtex= la->mtex; + } + else if( GS(tsep->id->name)==ID_WO) { + World *wrld= (World *)tsep->id; + mtex= wrld->mtex; + } + else return; + + for(a=0; a<MAX_MTEX; a++) { + if(a==te->index && mtex[a]) { + if(mtex[a]->tex) { + mtex[a]->tex->id.us--; + mtex[a]->tex= NULL; + } + } + } +} + +static void unlink_group_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *tselem) +{ + Group *group= (Group *)tselem->id; + + if(tsep) { + if( GS(tsep->id->name)==ID_OB) { + Object *ob= (Object *)tsep->id; + ob->dup_group= NULL; + } + } + else { + unlink_group(group); + } +} + +static void outliner_do_libdata_operation(bContext *C, Scene *scene, SpaceOops *soops, ListBase *lb, + void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) +{ + TreeElement *te; + TreeStoreElem *tselem; + + for(te=lb->first; te; te= te->next) { + tselem= TREESTORE(te); + if(tselem->flag & TSE_SELECTED) { + if(tselem->type==0) { + TreeStoreElem *tsep= TREESTORE(te->parent); + operation_cb(C, scene, te, tsep, tselem); + } + } + if((tselem->flag & TSE_CLOSED)==0) { + outliner_do_libdata_operation(C, scene, soops, &te->subtree, operation_cb); + } + } +} + +/* */ + +static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + Base *base= (Base *)te->directdata; + + if(base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if(base && ((base->object->restrictflag & OB_RESTRICT_VIEW)==0)) { + base->flag |= SELECT; + base->object->flag |= SELECT; + } +} + +static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + Base *base= (Base *)te->directdata; + + if(base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if(base) { + base->flag &= ~SELECT; + base->object->flag &= ~SELECT; + } +} + +static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + Base *base= (Base *)te->directdata; + + if(base==NULL) + base= object_in_scene((Object *)tselem->id, scene); + if(base) { + // check also library later + if(scene->obedit==base->object) + ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); + + ED_base_object_free_and_unlink(CTX_data_main(C), scene, base); + te->directdata= NULL; + tselem->id= NULL; + } + +} + +static void id_local_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + if (tselem->id->lib && (tselem->id->flag & LIB_EXTERN)) { + tselem->id->lib= NULL; + tselem->id->flag= LIB_LOCAL; + new_id(NULL, tselem->id, NULL); + } +} + +static void id_fake_user_set_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + ID *id = tselem->id; + + if ((id) && ((id->flag & LIB_FAKEUSER) == 0)) { + id->flag |= LIB_FAKEUSER; + id_us_plus(id); + } +} + +static void id_fake_user_clear_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + ID *id = tselem->id; + + if ((id) && (id->flag & LIB_FAKEUSER)) { + id->flag &= ~LIB_FAKEUSER; + id_us_min(id); + } +} + +#if 0 // GSOC_PEPPER + +static void singleuser_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *tselem) +{ + ID *id = tselem->id; + + if (id) { + IdAdtTemplate *iat = (IdAdtTemplate *)tsep->id; + PointerRNA ptr = {{0}}; + PropertyRNA *prop; + + RNA_pointer_create(&iat->id, &RNA_AnimData, iat->adt, &ptr); + prop = RNA_struct_find_property(&ptr, "action"); + + id_single_user(C, id, &ptr, prop); + } +} + +#endif + +static void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + Group *group= (Group *)tselem->id; + GroupObject *gob; + Base *base; + + for(gob=group->gobject.first; gob; gob=gob->next) { + base= object_in_scene(gob->ob, scene); + if (base) { + base->object->flag |= SELECT; + base->flag |= SELECT; + } else { + /* link to scene */ + base= MEM_callocN( sizeof(Base), "add_base"); + BLI_addhead(&scene->base, base); + base->lay= (1<<20)-1; /*v3d->lay;*/ /* would be nice to use the 3d layer but the include's not here */ + gob->ob->flag |= SELECT; + base->flag = gob->ob->flag; + base->object= gob->ob; + id_lib_extern((ID *)gob->ob); /* incase these are from a linked group */ + } + } +} + +void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOops *soops, ListBase *lb, + void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) +{ + TreeElement *te; + TreeStoreElem *tselem; + + for(te=lb->first; te; te= te->next) { + tselem= TREESTORE(te); + if(tselem->flag & TSE_SELECTED) { + if(tselem->type==0 && te->idcode==ID_OB) { + // when objects selected in other scenes... dunno if that should be allowed + Scene *scene_owner= (Scene *)outliner_search_back(soops, te, ID_SCE); + if(scene_owner && scene_act != scene_owner) { + ED_screen_set_scene(C, scene_owner); + } + /* important to use 'scene_owner' not scene_act else deleting objects can crash. + * only use 'scene_act' when 'scene_owner' is NULL, which can happen when the + * outliner isnt showing scenes: Visible Layer draw mode for eg. */ + operation_cb(C, scene_owner ? scene_owner : scene_act, te, NULL, tselem); + } + } + if((tselem->flag & TSE_CLOSED)==0) { + outliner_do_object_operation(C, scene_act, soops, &te->subtree, operation_cb); + } + } +} + +/* ******************************************** */ + +#if 0 // GSOC_PEPPER + +static void unlinkact_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te), TreeStoreElem *tselem) +{ + /* just set action to NULL */ + BKE_animdata_set_action(NULL, tselem->id, NULL); +} + +#endif // GSOC_PEPPER + +static void cleardrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te), TreeStoreElem *tselem) +{ + IdAdtTemplate *iat = (IdAdtTemplate *)tselem->id; + + /* just free drivers - stored as a list of F-Curves */ + free_fcurves(&iat->adt->drivers); +} + +static void refreshdrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te), TreeStoreElem *tselem) +{ + IdAdtTemplate *iat = (IdAdtTemplate *)tselem->id; + FCurve *fcu; + + /* loop over drivers, performing refresh (i.e. check graph_buttons.c and rna_fcurve.c for details) */ + for (fcu = iat->adt->drivers.first; fcu; fcu= fcu->next) { + fcu->flag &= ~FCURVE_DISABLED; + + if (fcu->driver) + fcu->driver->flag &= ~DRIVER_FLAG_INVALID; + } +} + +/* --------------------------------- */ + +static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) +{ + bPoseChannel *pchan= (bPoseChannel *)te->directdata; + + if(event==1) + pchan->bone->flag |= BONE_SELECTED; + else if(event==2) + pchan->bone->flag &= ~BONE_SELECTED; + else if(event==3) { + pchan->bone->flag |= BONE_HIDDEN_P; + pchan->bone->flag &= ~BONE_SELECTED; + } + else if(event==4) + pchan->bone->flag &= ~BONE_HIDDEN_P; +} + +static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) +{ + Bone *bone= (Bone *)te->directdata; + + if(event==1) + bone->flag |= BONE_SELECTED; + else if(event==2) + bone->flag &= ~BONE_SELECTED; + else if(event==3) { + bone->flag |= BONE_HIDDEN_P; + bone->flag &= ~BONE_SELECTED; + } + else if(event==4) + bone->flag &= ~BONE_HIDDEN_P; +} + +static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) +{ + EditBone *ebone= (EditBone *)te->directdata; + + if(event==1) + ebone->flag |= BONE_SELECTED; + else if(event==2) + ebone->flag &= ~BONE_SELECTED; + else if(event==3) { + ebone->flag |= BONE_HIDDEN_A; + ebone->flag &= ~BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; + } + else if(event==4) + ebone->flag &= ~BONE_HIDDEN_A; +} + +static void sequence_cb(int event, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tselem)) +{ +// Sequence *seq= (Sequence*) te->directdata; + if(event==1) { +// XXX select_single_seq(seq, 1); + } +} + +static void outliner_do_data_operation(SpaceOops *soops, int type, int event, ListBase *lb, + void (*operation_cb)(int, TreeElement *, TreeStoreElem *)) +{ + TreeElement *te; + TreeStoreElem *tselem; + + for(te=lb->first; te; te= te->next) { + tselem= TREESTORE(te); + if(tselem->flag & TSE_SELECTED) { + if(tselem->type==type) { + operation_cb(event, te, tselem); + } + } + if((tselem->flag & TSE_CLOSED)==0) { + outliner_do_data_operation(soops, type, event, &te->subtree, operation_cb); + } + } +} + +/* **************************************** */ + +static EnumPropertyItem prop_object_op_types[] = { + {1, "SELECT", 0, "Select", ""}, + {2, "DESELECT", 0, "Deselect", ""}, + {4, "DELETE", 0, "Delete", ""}, + {6, "TOGVIS", 0, "Toggle Visible", ""}, + {7, "TOGSEL", 0, "Toggle Selectable", ""}, + {8, "TOGREN", 0, "Toggle Renderable", ""}, + {0, NULL, 0, NULL, NULL} +}; + +static int outliner_object_operation_exec(bContext *C, wmOperator *op) +{ + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); + SpaceOops *soops= CTX_wm_space_outliner(C); + int event; + const char *str= NULL; + + /* check for invalid states */ + if (soops == NULL) + return OPERATOR_CANCELLED; + + event= RNA_enum_get(op->ptr, "type"); + + if(event==1) { + Scene *sce= scene; // to be able to delete, scenes are set... + outliner_do_object_operation(C, scene, soops, &soops->tree, object_select_cb); + if(scene != sce) { + ED_screen_set_scene(C, sce); + } + + str= "Select Objects"; + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + } + else if(event==2) { + outliner_do_object_operation(C, scene, soops, &soops->tree, object_deselect_cb); + str= "Deselect Objects"; + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + } + else if(event==4) { + outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb); + DAG_scene_sort(bmain, scene); + str= "Delete Objects"; + WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); + } + else if(event==5) { /* disabled, see above enum (ton) */ + outliner_do_object_operation(C, scene, soops, &soops->tree, id_local_cb); + str= "Localized Objects"; + } + else if(event==6) { + outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb); + str= "Toggle Visibility"; + WM_event_add_notifier(C, NC_SCENE|ND_OB_VISIBLE, scene); + } + else if(event==7) { + outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_selectability_cb); + str= "Toggle Selectability"; + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + } + else if(event==8) { + outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb); + str= "Toggle Renderability"; + WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, scene); + } + + ED_undo_push(C, str); + + return OPERATOR_FINISHED; +} + + +void OUTLINER_OT_object_operation(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Outliner Object Operation"; + ot->idname= "OUTLINER_OT_object_operation"; + ot->description= ""; + + /* callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= outliner_object_operation_exec; + ot->poll= ED_operator_outliner_active; + + ot->flag= 0; + + ot->prop= RNA_def_enum(ot->srna, "type", prop_object_op_types, 0, "Object Operation", ""); +} + +/* **************************************** */ + +static EnumPropertyItem prop_group_op_types[] = { + {1, "UNLINK", 0, "Unlink", ""}, + {2, "LOCAL", 0, "Make Local", ""}, + {3, "LINK", 0, "Link Group Objects to Scene", ""}, + {4, "TOGVIS", 0, "Toggle Visible", ""}, + {5, "TOGSEL", 0, "Toggle Selectable", ""}, + {6, "TOGREN", 0, "Toggle Renderable", ""}, + {0, NULL, 0, NULL, NULL} +}; + +static int outliner_group_operation_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + SpaceOops *soops= CTX_wm_space_outliner(C); + int event; + + /* check for invalid states */ + if (soops == NULL) + return OPERATOR_CANCELLED; + + event= RNA_enum_get(op->ptr, "type"); + + if(event==1) { + outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb); + ED_undo_push(C, "Unlink group"); + } + else if(event==2) { + outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); + ED_undo_push(C, "Localized Data"); + } + else if(event==3) { + outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb); + ED_undo_push(C, "Link Group Objects to Scene"); + } + + + WM_event_add_notifier(C, NC_GROUP, NULL); + + return OPERATOR_FINISHED; +} + + +void OUTLINER_OT_group_operation(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Outliner Group Operation"; + ot->idname= "OUTLINER_OT_group_operation"; + ot->description= ""; + + /* callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= outliner_group_operation_exec; + ot->poll= ED_operator_outliner_active; + + ot->flag= 0; + + ot->prop= RNA_def_enum(ot->srna, "type", prop_group_op_types, 0, "Group Operation", ""); +} + +/* **************************************** */ + +typedef enum eOutlinerIdOpTypes { + OUTLINER_IDOP_INVALID = 0, + + OUTLINER_IDOP_UNLINK, + OUTLINER_IDOP_LOCAL, + OUTLINER_IDOP_SINGLE, + + OUTLINER_IDOP_FAKE_ADD, + OUTLINER_IDOP_FAKE_CLEAR +} eOutlinerIdOpTypes; + +// TODO: implement support for changing the ID-block used +static EnumPropertyItem prop_id_op_types[] = { + {OUTLINER_IDOP_UNLINK, "UNLINK", 0, "Unlink", ""}, + {OUTLINER_IDOP_LOCAL, "LOCAL", 0, "Make Local", ""}, + {OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""}, + {OUTLINER_IDOP_FAKE_ADD, "ADD_FAKE", 0, "Add Fake User", "Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"}, + {OUTLINER_IDOP_FAKE_CLEAR, "CLEAR_FAKE", 0, "Clear Fake User", ""}, + {0, NULL, 0, NULL, NULL} +}; + +static int outliner_id_operation_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + SpaceOops *soops= CTX_wm_space_outliner(C); + int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; + eOutlinerIdOpTypes event; + + /* check for invalid states */ + if (soops == NULL) + return OPERATOR_CANCELLED; + + set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); + + event= RNA_enum_get(op->ptr, "type"); + + switch (event) { + case OUTLINER_IDOP_UNLINK: + { + /* unlink datablock from its parent */ + switch (idlevel) { + +#if 0 // GSOC_PEPPER + + case ID_AC: + outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_action_cb); + + WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + ED_undo_push(C, "Unlink action"); + break; + +#endif // GSOC_PEPPER + + case ID_MA: + outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_material_cb); + + WM_event_add_notifier(C, NC_OBJECT|ND_OB_SHADING, NULL); + ED_undo_push(C, "Unlink material"); + break; + case ID_TE: + outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_texture_cb); + + WM_event_add_notifier(C, NC_OBJECT|ND_OB_SHADING, NULL); + ED_undo_push(C, "Unlink texture"); + break; + default: + BKE_report(op->reports, RPT_WARNING, "Not Yet"); + break; + } + } + break; + + case OUTLINER_IDOP_LOCAL: + { + /* make local */ + outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); + ED_undo_push(C, "Localized Data"); + } + break; + +#if 0 // GSOC_PEPPER + + case OUTLINER_IDOP_SINGLE: + { + /* make single user */ + switch (idlevel) { + case ID_AC: + outliner_do_libdata_operation(C, scene, soops, &soops->tree, singleuser_action_cb); + + WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + ED_undo_push(C, "Single-User Action"); + break; + + default: + BKE_report(op->reports, RPT_WARNING, "Not Yet"); + break; + } + } + break; + +#endif // GSOC_PEPPER + + case OUTLINER_IDOP_FAKE_ADD: + { + /* set fake user */ + outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_fake_user_set_cb); + + WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + ED_undo_push(C, "Add Fake User"); + } + break; + + case OUTLINER_IDOP_FAKE_CLEAR: + { + /* clear fake user */ + outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_fake_user_clear_cb); + + WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + ED_undo_push(C, "Clear Fake User"); + } + break; + + default: + // invalid - unhandled + break; + } + + /* wrong notifier still... */ + WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + + // XXX: this is just so that outliner is always up to date + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_OUTLINER, NULL); + + return OPERATOR_FINISHED; +} + + +void OUTLINER_OT_id_operation(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Outliner ID data Operation"; + ot->idname= "OUTLINER_OT_id_operation"; + ot->description= ""; + + /* callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= outliner_id_operation_exec; + ot->poll= ED_operator_outliner_active; + + ot->flag= 0; + + ot->prop= RNA_def_enum(ot->srna, "type", prop_id_op_types, 0, "ID data Operation", ""); +} + +/* **************************************** */ + +static void outliner_do_id_set_operation(SpaceOops *soops, int type, ListBase *lb, ID *newid, + void (*operation_cb)(TreeElement *, TreeStoreElem *, TreeStoreElem *, ID *)) +{ + TreeElement *te; + TreeStoreElem *tselem; + + for (te=lb->first; te; te= te->next) { + tselem= TREESTORE(te); + if (tselem->flag & TSE_SELECTED) { + if(tselem->type==type) { + TreeStoreElem *tsep = TREESTORE(te->parent); + operation_cb(te, tselem, tsep, newid); + } + } + if ((tselem->flag & TSE_CLOSED)==0) { + outliner_do_id_set_operation(soops, type, &te->subtree, newid, operation_cb); + } + } +} + +/* ------------------------------------------ */ + +#if 0 // GSOC_PEPPER + +static void actionset_id_cb(TreeElement *te, TreeStoreElem *tselem, TreeStoreElem *tsep, ID *actId) +{ + bAction *act = (bAction *)actId; + + if (tselem->type == TSE_ANIM_DATA) { + /* "animation" entries - action is child of this */ + BKE_animdata_set_action(NULL, tselem->id, act); + } + /* TODO: if any other "expander" channels which own actions need to support this menu, + * add: tselem->type = ... + */ + else if (tsep && (tsep->type == TSE_ANIM_DATA)) { + /* "animation" entries case again */ + BKE_animdata_set_action(NULL, tsep->id, act); + } + // TODO: other cases not supported yet +} + +static int outliner_action_set_exec(bContext *C, wmOperator *op) +{ + SpaceOops *soops= CTX_wm_space_outliner(C); + int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; + + bAction *act; + + /* check for invalid states */ + if (soops == NULL) + return OPERATOR_CANCELLED; + set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); + + /* get action to use */ + act= BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action")); + + if (act == NULL) { + BKE_report(op->reports, RPT_ERROR, "No valid Action to add."); + return OPERATOR_CANCELLED; + } + else if (act->idroot == 0) { + /* hopefully in this case (i.e. library of userless actions), the user knows what they're doing... */ + BKE_reportf(op->reports, RPT_WARNING, + "Action '%s' does not specify what datablocks it can be used on. Try setting the 'ID Root Type' setting from the Datablocks Editor for this Action to avoid future problems", + act->id.name+2); + } + + /* perform action if valid channel */ + if (datalevel == TSE_ANIM_DATA) + outliner_do_id_set_operation(soops, datalevel, &soops->tree, (ID*)act, actionset_id_cb); + else if (idlevel == ID_AC) + outliner_do_id_set_operation(soops, idlevel, &soops->tree, (ID*)act, actionset_id_cb); + else + return OPERATOR_CANCELLED; + + /* set notifier that things have changed */ + WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + ED_undo_push(C, "Set action"); + + /* done */ + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_action_set(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name= "Outliner Set Action"; + ot->idname= "OUTLINER_OT_action_set"; + ot->description= "Change the active action used"; + + /* api callbacks */ + ot->invoke= WM_enum_search_invoke; + ot->exec= outliner_action_set_exec; + ot->poll= ED_operator_outliner_active; + + /* flags */ + ot->flag= 0; + + /* props */ + // TODO: this would be nicer as an ID-pointer... + prop= RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", ""); + RNA_def_enum_funcs(prop, RNA_action_itemf); + ot->prop= prop; +} + +#endif // GSOC_PEPPER + +/* **************************************** */ + +typedef enum eOutliner_AnimDataOps { + OUTLINER_ANIMOP_INVALID = 0, + + OUTLINER_ANIMOP_SET_ACT, + OUTLINER_ANIMOP_CLEAR_ACT, + + OUTLINER_ANIMOP_REFRESH_DRV, + OUTLINER_ANIMOP_CLEAR_DRV + + //OUTLINER_ANIMOP_COPY_DRIVERS, + //OUTLINER_ANIMOP_PASTE_DRIVERS +} eOutliner_AnimDataOps; + +static EnumPropertyItem prop_animdata_op_types[] = { + {OUTLINER_ANIMOP_SET_ACT, "SET_ACT", 0, "Set Action", ""}, + {OUTLINER_ANIMOP_CLEAR_ACT, "CLEAR_ACT", 0, "Unlink Action", ""}, + {OUTLINER_ANIMOP_REFRESH_DRV, "REFRESH_DRIVERS", 0, "Refresh Drivers", ""}, + //{OUTLINER_ANIMOP_COPY_DRIVERS, "COPY_DRIVERS", 0, "Copy Drivers", ""}, + //{OUTLINER_ANIMOP_PASTE_DRIVERS, "PASTE_DRIVERS", 0, "Paste Drivers", ""}, + {OUTLINER_ANIMOP_CLEAR_DRV, "CLEAR_DRIVERS", 0, "Clear Drivers", ""}, + {0, NULL, 0, NULL, NULL} +}; + +static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) +{ + SpaceOops *soops= CTX_wm_space_outliner(C); + int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; + eOutliner_AnimDataOps event; + short updateDeps = 0; + + /* check for invalid states */ + if (soops == NULL) + return OPERATOR_CANCELLED; + + event= RNA_enum_get(op->ptr, "type"); + set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); + + if (datalevel != TSE_ANIM_DATA) + return OPERATOR_CANCELLED; + + /* perform the core operation */ + switch (event) { + +#if 0 // GSOC_PEPPER + + case OUTLINER_ANIMOP_SET_ACT: + /* delegate once again... */ + WM_operator_name_call(C, "OUTLINER_OT_action_set", WM_OP_INVOKE_REGION_WIN, NULL); + break; + + case OUTLINER_ANIMOP_CLEAR_ACT: + /* clear active action - using standard rules */ + outliner_do_data_operation(soops, datalevel, event, &soops->tree, unlinkact_animdata_cb); + + WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + ED_undo_push(C, "Unlink action"); + break; + +#endif // GSOC_PEPPER + + case OUTLINER_ANIMOP_REFRESH_DRV: + outliner_do_data_operation(soops, datalevel, event, &soops->tree, refreshdrivers_animdata_cb); + + WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN, NULL); + //ED_undo_push(C, "Refresh Drivers"); /* no undo needed - shouldn't have any impact? */ + updateDeps = 1; + break; + + case OUTLINER_ANIMOP_CLEAR_DRV: + outliner_do_data_operation(soops, datalevel, event, &soops->tree, cleardrivers_animdata_cb); + + WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN, NULL); + ED_undo_push(C, "Clear Drivers"); + updateDeps = 1; + break; + + default: // invalid + break; + } + + /* update dependencies */ + if (updateDeps) { + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + + /* rebuild depsgraph for the new deps */ + DAG_scene_sort(bmain, scene); + + /* force an update of depsgraph */ + DAG_ids_flush_update(bmain, 0); + } + + return OPERATOR_FINISHED; +} + + +void OUTLINER_OT_animdata_operation(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Outliner Animation Data Operation"; + ot->idname= "OUTLINER_OT_animdata_operation"; + ot->description= ""; + + /* callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= outliner_animdata_operation_exec; + ot->poll= ED_operator_outliner_active; + + ot->flag= 0; + + ot->prop= RNA_def_enum(ot->srna, "type", prop_animdata_op_types, 0, "Animation Operation", ""); +} + +/* **************************************** */ + +static EnumPropertyItem prop_data_op_types[] = { + {1, "SELECT", 0, "Select", ""}, + {2, "DESELECT", 0, "Deselect", ""}, + {3, "HIDE", 0, "Hide", ""}, + {4, "UNHIDE", 0, "Unhide", ""}, + {0, NULL, 0, NULL, NULL} +}; + +static int outliner_data_operation_exec(bContext *C, wmOperator *op) +{ + SpaceOops *soops= CTX_wm_space_outliner(C); + int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; + int event; + + /* check for invalid states */ + if (soops == NULL) + return OPERATOR_CANCELLED; + + event= RNA_enum_get(op->ptr, "type"); + set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); + + if(datalevel==TSE_POSE_CHANNEL) { + if(event>0) { + outliner_do_data_operation(soops, datalevel, event, &soops->tree, pchan_cb); + WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + ED_undo_push(C, "PoseChannel operation"); + } + } + else if(datalevel==TSE_BONE) { + if(event>0) { + outliner_do_data_operation(soops, datalevel, event, &soops->tree, bone_cb); + WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + ED_undo_push(C, "Bone operation"); + } + } + else if(datalevel==TSE_EBONE) { + if(event>0) { + outliner_do_data_operation(soops, datalevel, event, &soops->tree, ebone_cb); + WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + ED_undo_push(C, "EditBone operation"); + } + } + else if(datalevel==TSE_SEQUENCE) { + if(event>0) { + outliner_do_data_operation(soops, datalevel, event, &soops->tree, sequence_cb); + } + } + + return OPERATOR_FINISHED; +} + + +void OUTLINER_OT_data_operation(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Outliner Data Operation"; + ot->idname= "OUTLINER_OT_data_operation"; + ot->description= ""; + + /* callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= outliner_data_operation_exec; + ot->poll= ED_operator_outliner_active; + + ot->flag= 0; + + ot->prop= RNA_def_enum(ot->srna, "type", prop_data_op_types, 0, "Data Operation", ""); +} + + +/* ******************** */ + + +static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, wmEvent *event, const float mval[2]) +{ + ReportList *reports = CTX_wm_reports(C); // XXX... + + 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); + + /* select object that's clicked on and popup context menu */ + if (!(tselem->flag & TSE_SELECTED)) { + + if ( outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1) ) + outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); + + tselem->flag |= TSE_SELECTED; + /* redraw, same as outliner_select function */ + soops->storeflag |= SO_TREESTORE_REDRAW; + ED_region_tag_redraw(ar); + } + + set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); + + if(scenelevel) { + //if(objectlevel || datalevel || idlevel) error("Mixed selection"); + //else pupmenu("Scene Operations%t|Delete"); + } + else if(objectlevel) { + WM_operator_name_call(C, "OUTLINER_OT_object_operation", WM_OP_INVOKE_REGION_WIN, NULL); + } + else if(idlevel) { + if(idlevel==-1 || datalevel) BKE_report(reports, RPT_WARNING, "Mixed selection"); + else { + if (idlevel==ID_GR) + WM_operator_name_call(C, "OUTLINER_OT_group_operation", WM_OP_INVOKE_REGION_WIN, NULL); + else + WM_operator_name_call(C, "OUTLINER_OT_id_operation", WM_OP_INVOKE_REGION_WIN, NULL); + } + } + else if(datalevel) { + if(datalevel==-1) BKE_report(reports, RPT_WARNING, "Mixed selection"); + else { + if (datalevel == TSE_ANIM_DATA) + WM_operator_name_call(C, "OUTLINER_OT_animdata_operation", WM_OP_INVOKE_REGION_WIN, NULL); + else if (datalevel == TSE_DRIVER_BASE) + /* do nothing... no special ops needed yet */; + else + WM_operator_name_call(C, "OUTLINER_OT_data_operation", WM_OP_INVOKE_REGION_WIN, NULL); + } + } + + return 1; + } + + for(te= te->subtree.first; te; te= te->next) { + if(do_outliner_operation_event(C, scene, ar, soops, te, event, mval)) + return 1; + } + return 0; +} + + +static int outliner_operation(bContext *C, wmOperator *UNUSED(op), wmEvent *event) +{ + Scene *scene= CTX_data_scene(C); + ARegion *ar= CTX_wm_region(C); + SpaceOops *soops= CTX_wm_space_outliner(C); + TreeElement *te; + float fmval[2]; + + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); + + for(te= soops->tree.first; te; te= te->next) { + if(do_outliner_operation_event(C, scene, ar, soops, te, event, fmval)) break; + } + + return OPERATOR_FINISHED; +} + +/* Menu only! Calls other operators */ +void OUTLINER_OT_operation(wmOperatorType *ot) +{ + ot->name= "Execute Operation"; + ot->idname= "OUTLINER_OT_operation"; + ot->description= "Context menu for item operations"; + + ot->invoke= outliner_operation; + + ot->poll= ED_operator_outliner_active; +} + +/* ****************************************************** */ diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c new file mode 100644 index 00000000000..3560bfb9896 --- /dev/null +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -0,0 +1,1585 @@ +/* + * $Id$ + * + * ***** 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. + * + * The Original Code is Copyright (C) 2004 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Joshua Leung + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_outliner/outliner_tree.c + * \ingroup spoutliner + */ + +#include <math.h> +#include <string.h> +#include <stdlib.h> +#include <stddef.h> + +#include "MEM_guardedalloc.h" + +#include "DNA_anim_types.h" +#include "DNA_armature_types.h" +#include "DNA_constraint_types.h" +#include "DNA_camera_types.h" +#include "DNA_group_types.h" +#include "DNA_key_types.h" +#include "DNA_lamp_types.h" +#include "DNA_material_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meta_types.h" +#include "DNA_particle_types.h" +#include "DNA_scene_types.h" +#include "DNA_world_types.h" +#include "DNA_sequence_types.h" + +#if 0 // GSOC_PEPPER + +#include "DNA_speaker_types.h" + +#endif // GSOC_PEPPER + +#include "DNA_object_types.h" + +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" +#include "BLI_math_base.h" + +#if defined WIN32 && !defined _LIBC +# include "BLI_fnmatch.h" /* use fnmatch included in blenlib */ +#else +# ifndef _GNU_SOURCE +# define _GNU_SOURCE +# endif +# include <fnmatch.h> +#endif + + +#include "BKE_animsys.h" +#include "BKE_context.h" +#include "BKE_deform.h" +#include "BKE_depsgraph.h" +#include "BKE_fcurve.h" +#include "BKE_global.h" +#include "BKE_group.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_modifier.h" +#include "BKE_report.h" +#include "BKE_scene.h" +#include "BKE_sequencer.h" + +#include "ED_armature.h" +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_util.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "UI_interface.h" +#include "UI_interface_icons.h" +#include "UI_resources.h" +#include "UI_view2d.h" + +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "outliner_intern.h" + +/* ********************************************************* */ +/* Defines */ + +#define TS_CHUNK 128 + +/* ********************************************************* */ +/* Persistant Data */ + +static void outliner_storage_cleanup(SpaceOops *soops) +{ + TreeStore *ts= soops->treestore; + + if(ts) { + TreeStoreElem *tselem; + int a, unused= 0; + + /* each element used once, for ID blocks with more users to have each a treestore */ + for(a=0, tselem= ts->data; a<ts->usedelem; a++, tselem++) tselem->used= 0; + + /* cleanup only after reading file or undo step, and always for + * RNA datablocks view in order to save memory */ + if(soops->storeflag & SO_TREESTORE_CLEANUP) { + + for(a=0, tselem= ts->data; a<ts->usedelem; a++, tselem++) { + if(tselem->id==NULL) unused++; + } + + if(unused) { + if(ts->usedelem == unused) { + MEM_freeN(ts->data); + ts->data= NULL; + ts->usedelem= ts->totelem= 0; + } + else { + TreeStoreElem *tsnewar, *tsnew; + + tsnew=tsnewar= MEM_mallocN((ts->usedelem-unused)*sizeof(TreeStoreElem), "new tselem"); + for(a=0, tselem= ts->data; a<ts->usedelem; a++, tselem++) { + if(tselem->id) { + *tsnew= *tselem; + tsnew++; + } + } + MEM_freeN(ts->data); + ts->data= tsnewar; + ts->usedelem-= unused; + ts->totelem= ts->usedelem; + } + } + } + } +} + +static void check_persistant(SpaceOops *soops, TreeElement *te, ID *id, short type, short nr) +{ + TreeStore *ts; + TreeStoreElem *tselem; + int a; + + /* case 1; no TreeStore */ + if(soops->treestore==NULL) { + soops->treestore= MEM_callocN(sizeof(TreeStore), "treestore"); + } + ts= soops->treestore; + + /* check if 'te' is in treestore */ + tselem= ts->data; + for(a=0; a<ts->usedelem; a++, tselem++) { + if(tselem->id==id && tselem->used==0) { + if((type==0 && tselem->type==0) ||(tselem->type==type && tselem->nr==nr)) { + te->store_index= a; + tselem->used= 1; + return; + } + } + } + + /* add 1 element to treestore */ + if(ts->usedelem==ts->totelem) { + TreeStoreElem *tsnew; + + tsnew= MEM_mallocN((ts->totelem+TS_CHUNK)*sizeof(TreeStoreElem), "treestore data"); + if(ts->data) { + memcpy(tsnew, ts->data, ts->totelem*sizeof(TreeStoreElem)); + MEM_freeN(ts->data); + } + ts->data= tsnew; + ts->totelem+= TS_CHUNK; + } + + tselem= ts->data+ts->usedelem; + + tselem->type= type; + if(type) tselem->nr= nr; // we're picky! :) + else tselem->nr= 0; + tselem->id= id; + tselem->used = 0; + tselem->flag= TSE_CLOSED; + te->store_index= ts->usedelem; + + ts->usedelem++; +} + +/* ********************************************************* */ +/* Tree Management */ + +void outliner_free_tree(ListBase *lb) +{ + while(lb->first) { + TreeElement *te= lb->first; + + outliner_free_tree(&te->subtree); + BLI_remlink(lb, te); + + if(te->flag & TE_FREE_NAME) MEM_freeN((void *)te->name); + MEM_freeN(te); + } +} + +/* Find ith item from the treestore */ +TreeElement *outliner_find_tree_element(ListBase *lb, int store_index) +{ + TreeElement *te= lb->first, *tes; + while(te) { + if(te->store_index==store_index) return te; + tes= outliner_find_tree_element(&te->subtree, store_index); + if(tes) return tes; + te= te->next; + } + return NULL; +} + +/* tse is not in the treestore, we use its contents to find a match */ +TreeElement *outliner_find_tse(SpaceOops *soops, TreeStoreElem *tse) +{ + TreeStore *ts= soops->treestore; + TreeStoreElem *tselem; + int a; + + if(tse->id==NULL) return NULL; + + /* check if 'tse' is in treestore */ + tselem= ts->data; + for(a=0; a<ts->usedelem; a++, tselem++) { + if((tse->type==0 && tselem->type==0) || (tselem->type==tse->type && tselem->nr==tse->nr)) { + if(tselem->id==tse->id) { + break; + } + } + } + if(tselem) + return outliner_find_tree_element(&soops->tree, a); + + return NULL; +} + +/* Find treestore that refers to given ID */ +TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id) +{ + TreeElement *te, *tes; + TreeStoreElem *tselem; + + for(te= lb->first; te; te= te->next) { + tselem= TREESTORE(te); + if(tselem->type==0) { + if(tselem->id==id) return te; + /* only deeper on scene or object */ + if( te->idcode==ID_OB || te->idcode==ID_SCE || (soops->outlinevis == SO_GROUPS && te->idcode==ID_GR)) { + tes= outliner_find_id(soops, &te->subtree, id); + if(tes) return tes; + } + } + } + return NULL; +} + + +ID *outliner_search_back(SpaceOops *soops, TreeElement *te, short idcode) +{ + TreeStoreElem *tselem; + te= te->parent; + + while(te) { + tselem= TREESTORE(te); + if(tselem->type==0 && te->idcode==idcode) return tselem->id; + te= te->parent; + } + return NULL; +} + + +/* ********************************************************* */ + +/* Prototype, see functions below */ +static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, + TreeElement *parent, short type, short index); + +/* -------------------------------------------------------- */ + +/* special handling of hierarchical non-lib data */ +static void outliner_add_bone(SpaceOops *soops, ListBase *lb, ID *id, Bone *curBone, + TreeElement *parent, int *a) +{ + TreeElement *te= outliner_add_element(soops, lb, id, parent, TSE_BONE, *a); + + (*a)++; + te->name= curBone->name; + te->directdata= curBone; + + for(curBone= curBone->childbase.first; curBone; curBone=curBone->next) { + outliner_add_bone(soops, &te->subtree, id, curBone, te, a); + } +} + +/* -------------------------------------------------------- */ + +#define LOG2I(x) (int)(log(x)/M_LN2) + +static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, SceneRenderLayer *srl) +{ + TreeStoreElem *tselem = NULL; + TreeElement *te = NULL; + + /* log stuff is to convert bitflags (powers of 2) to small integers, + * in order to not overflow short tselem->nr */ + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_COMBINED)); + te->name= "Combined"; + te->directdata= &srl->passflag; + + /* save cpu cycles, but we add the first to invoke an open/close triangle */ + tselem = TREESTORE(tenla); + if(tselem->flag & TSE_CLOSED) + return; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_Z)); + te->name= "Z"; + te->directdata= &srl->passflag; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_VECTOR)); + te->name= "Vector"; + te->directdata= &srl->passflag; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_NORMAL)); + te->name= "Normal"; + te->directdata= &srl->passflag; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_UV)); + te->name= "UV"; + te->directdata= &srl->passflag; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_MIST)); + te->name= "Mist"; + te->directdata= &srl->passflag; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXOB)); + te->name= "Index Object"; + te->directdata= &srl->passflag; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXMA)); + te->name= "Index Material"; + te->directdata= &srl->passflag; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_RGBA)); + te->name= "Color"; + te->directdata= &srl->passflag; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_DIFFUSE)); + te->name= "Diffuse"; + te->directdata= &srl->passflag; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SPEC)); + te->name= "Specular"; + te->directdata= &srl->passflag; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SHADOW)); + te->name= "Shadow"; + te->directdata= &srl->passflag; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_AO)); + te->name= "AO"; + te->directdata= &srl->passflag; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFLECT)); + te->name= "Reflection"; + te->directdata= &srl->passflag; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFRACT)); + te->name= "Refraction"; + te->directdata= &srl->passflag; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDIRECT)); + te->name= "Indirect"; + te->directdata= &srl->passflag; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_ENVIRONMENT)); + te->name= "Environment"; + te->directdata= &srl->passflag; + + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_EMIT)); + te->name= "Emit"; + te->directdata= &srl->passflag; +} + +#undef LOG2I + +static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *sce, TreeElement *te) +{ + SceneRenderLayer *srl; + TreeElement *tenla= outliner_add_element(soops, lb, sce, te, TSE_R_LAYER_BASE, 0); + int a; + + tenla->name= "RenderLayers"; + for(a=0, srl= sce->r.layers.first; srl; srl= srl->next, a++) { + TreeElement *tenlay= outliner_add_element(soops, &tenla->subtree, sce, te, TSE_R_LAYER, a); + tenlay->name= srl->name; + tenlay->directdata= &srl->passflag; + + if(srl->light_override) + outliner_add_element(soops, &tenlay->subtree, srl->light_override, tenlay, TSE_LINKED_LAMP, 0); + if(srl->mat_override) + outliner_add_element(soops, &tenlay->subtree, srl->mat_override, tenlay, TSE_LINKED_MAT, 0); + + outliner_add_passes(soops, tenlay, &sce->id, srl); + } + + // TODO: move this to the front? + if (sce->adt) + outliner_add_element(soops, lb, sce, te, TSE_ANIM_DATA, 0); + + outliner_add_element(soops, lb, sce->world, te, 0, 0); +} + +// can be inlined if necessary +static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, Object *ob) +{ + int a = 0; + + if (ob->adt) + outliner_add_element(soops, &te->subtree, ob, te, TSE_ANIM_DATA, 0); + + outliner_add_element(soops, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this + + if (ob->proxy && ob->id.lib==NULL) + outliner_add_element(soops, &te->subtree, ob->proxy, te, TSE_PROXY, 0); + + outliner_add_element(soops, &te->subtree, ob->data, te, 0, 0); + + if (ob->pose) { + bArmature *arm= ob->data; + bPoseChannel *pchan; + TreeElement *ten; + TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_POSE_BASE, 0); + + tenla->name= "Pose"; + + /* channels undefined in editmode, but we want the 'tenla' pose icon itself */ + if ((arm->edbo == NULL) && (ob->mode & OB_MODE_POSE)) { + int a= 0, const_index= 1000; /* ensure unique id for bone constraints */ + + for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) { + ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a); + ten->name= pchan->name; + ten->directdata= pchan; + pchan->prev= (bPoseChannel *)ten; + + if(pchan->constraints.first) { + //Object *target; + bConstraint *con; + TreeElement *ten1; + TreeElement *tenla1= outliner_add_element(soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0); + //char *str; + + tenla1->name= "Constraints"; + for(con= pchan->constraints.first; con; con= con->next, const_index++) { + ten1= outliner_add_element(soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index); +#if 0 /* disabled as it needs to be reworked for recoded constraints system */ + target= get_constraint_target(con, &str); + if(str && str[0]) ten1->name= str; + else if(target) ten1->name= target->id.name+2; + else ten1->name= con->name; +#endif + ten1->name= con->name; + ten1->directdata= con; + /* possible add all other types links? */ + } + } + } + /* make hierarchy */ + ten= tenla->subtree.first; + while(ten) { + TreeElement *nten= ten->next, *par; + tselem= TREESTORE(ten); + if(tselem->type==TSE_POSE_CHANNEL) { + pchan= (bPoseChannel *)ten->directdata; + if(pchan->parent) { + BLI_remlink(&tenla->subtree, ten); + par= (TreeElement *)pchan->parent->prev; + BLI_addtail(&par->subtree, ten); + ten->parent= par; + } + } + ten= nten; + } + /* restore prev pointers */ + pchan= ob->pose->chanbase.first; + if(pchan) pchan->prev= NULL; + for(; pchan; pchan= pchan->next) { + if(pchan->next) pchan->next->prev= pchan; + } + } + + /* Pose Groups */ + if(ob->pose->agroups.first) { + bActionGroup *agrp; + TreeElement *ten; + TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_POSEGRP_BASE, 0); + int a= 0; + + tenla->name= "Bone Groups"; + for (agrp=ob->pose->agroups.first; agrp; agrp=agrp->next, a++) { + ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSEGRP, a); + ten->name= agrp->name; + ten->directdata= agrp; + } + } + } + + for(a=0; a<ob->totcol; a++) + outliner_add_element(soops, &te->subtree, ob->mat[a], te, 0, a); + + if(ob->constraints.first) { + //Object *target; + bConstraint *con; + TreeElement *ten; + TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0); + //char *str; + + tenla->name= "Constraints"; + for (con=ob->constraints.first, a=0; con; con= con->next, a++) { + ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a); +#if 0 /* disabled due to constraints system targets recode... code here needs review */ + target= get_constraint_target(con, &str); + if(str && str[0]) ten->name= str; + else if(target) ten->name= target->id.name+2; + else ten->name= con->name; +#endif + ten->name= con->name; + ten->directdata= con; + /* possible add all other types links? */ + } + } + + if (ob->modifiers.first) { + ModifierData *md; + TreeElement *temod = outliner_add_element(soops, &te->subtree, ob, te, TSE_MODIFIER_BASE, 0); + int index; + + temod->name = "Modifiers"; + for (index=0,md=ob->modifiers.first; md; index++,md=md->next) { + TreeElement *te = outliner_add_element(soops, &temod->subtree, ob, temod, TSE_MODIFIER, index); + te->name= md->name; + te->directdata = md; + + if (md->type==eModifierType_Lattice) { + outliner_add_element(soops, &te->subtree, ((LatticeModifierData*) md)->object, te, TSE_LINKED_OB, 0); + } + else if (md->type==eModifierType_Curve) { + outliner_add_element(soops, &te->subtree, ((CurveModifierData*) md)->object, te, TSE_LINKED_OB, 0); + } + else if (md->type==eModifierType_Armature) { + outliner_add_element(soops, &te->subtree, ((ArmatureModifierData*) md)->object, te, TSE_LINKED_OB, 0); + } + else if (md->type==eModifierType_Hook) { + outliner_add_element(soops, &te->subtree, ((HookModifierData*) md)->object, te, TSE_LINKED_OB, 0); + } + else if (md->type==eModifierType_ParticleSystem) { + TreeElement *ten; + ParticleSystem *psys= ((ParticleSystemModifierData*) md)->psys; + + ten = outliner_add_element(soops, &te->subtree, ob, te, TSE_LINKED_PSYS, 0); + ten->directdata = psys; + ten->name = psys->part->id.name+2; + } + } + } + + /* vertex groups */ + if (ob->defbase.first) { + bDeformGroup *defgroup; + TreeElement *ten; + TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_DEFGROUP_BASE, 0); + + tenla->name= "Vertex Groups"; + for (defgroup=ob->defbase.first, a=0; defgroup; defgroup=defgroup->next, a++) { + ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_DEFGROUP, a); + ten->name= defgroup->name; + ten->directdata= defgroup; + } + } + + /* duplicated group */ + if (ob->dup_group) + outliner_add_element(soops, &te->subtree, ob->dup_group, te, 0, 0); +} + +// can be inlined if necessary +static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, ID *id) +{ + /* tuck pointer back in object, to construct hierarchy */ + if (GS(id->name)==ID_OB) id->newid= (ID *)te; + + /* expand specific data always */ + switch (GS(id->name)) { + case ID_LI: + { + te->name= ((Library *)id)->name; + } + break; + case ID_SCE: + { + outliner_add_scene_contents(soops, &te->subtree, (Scene *)id, te); + } + break; + case ID_OB: + { + outliner_add_object_contents(soops, te, tselem, (Object *)id); + } + break; + case ID_ME: + { + Mesh *me= (Mesh *)id; + int a; + + if (me->adt) + outliner_add_element(soops, &te->subtree, me, te, TSE_ANIM_DATA, 0); + + outliner_add_element(soops, &te->subtree, me->key, te, 0, 0); + for(a=0; a<me->totcol; a++) + outliner_add_element(soops, &te->subtree, me->mat[a], te, 0, a); + /* could do tfaces with image links, but the images are not grouped nicely. + would require going over all tfaces, sort images in use. etc... */ + } + break; + case ID_CU: + { + Curve *cu= (Curve *)id; + int a; + + if (cu->adt) + outliner_add_element(soops, &te->subtree, cu, te, TSE_ANIM_DATA, 0); + + for(a=0; a<cu->totcol; a++) + outliner_add_element(soops, &te->subtree, cu->mat[a], te, 0, a); + } + break; + case ID_MB: + { + MetaBall *mb= (MetaBall *)id; + int a; + + if (mb->adt) + outliner_add_element(soops, &te->subtree, mb, te, TSE_ANIM_DATA, 0); + + for(a=0; a<mb->totcol; a++) + outliner_add_element(soops, &te->subtree, mb->mat[a], te, 0, a); + } + break; + case ID_MA: + { + Material *ma= (Material *)id; + int a; + + if (ma->adt) + outliner_add_element(soops, &te->subtree, ma, te, TSE_ANIM_DATA, 0); + + for(a=0; a<MAX_MTEX; a++) { + if(ma->mtex[a]) outliner_add_element(soops, &te->subtree, ma->mtex[a]->tex, te, 0, a); + } + } + break; + case ID_TE: + { + Tex *tex= (Tex *)id; + + if (tex->adt) + outliner_add_element(soops, &te->subtree, tex, te, TSE_ANIM_DATA, 0); + + outliner_add_element(soops, &te->subtree, tex->ima, te, 0, 0); + } + break; + case ID_CA: + { + Camera *ca= (Camera *)id; + + if (ca->adt) + outliner_add_element(soops, &te->subtree, ca, te, TSE_ANIM_DATA, 0); + } + break; + case ID_LA: + { + Lamp *la= (Lamp *)id; + int a; + + if (la->adt) + outliner_add_element(soops, &te->subtree, la, te, TSE_ANIM_DATA, 0); + + for(a=0; a<MAX_MTEX; a++) { + if(la->mtex[a]) outliner_add_element(soops, &te->subtree, la->mtex[a]->tex, te, 0, a); + } + } + break; + +#if 0 // GSOC_PEPPER + + case ID_SPK: + { + Speaker *spk= (Speaker *)id; + + if(spk->adt) + outliner_add_element(soops, &te->subtree, spk, te, TSE_ANIM_DATA, 0); + } + break; + +#endif // GSOC_PEPPER + + case ID_WO: + { + World *wrld= (World *)id; + int a; + + if (wrld->adt) + outliner_add_element(soops, &te->subtree, wrld, te, TSE_ANIM_DATA, 0); + + for(a=0; a<MAX_MTEX; a++) { + if(wrld->mtex[a]) outliner_add_element(soops, &te->subtree, wrld->mtex[a]->tex, te, 0, a); + } + } + break; + case ID_KE: + { + Key *key= (Key *)id; + + if (key->adt) + outliner_add_element(soops, &te->subtree, key, te, TSE_ANIM_DATA, 0); + } + break; + case ID_AC: + { + // XXX do we want to be exposing the F-Curves here? + //bAction *act= (bAction *)id; + } + break; + case ID_AR: + { + bArmature *arm= (bArmature *)id; + int a= 0; + + if (arm->adt) + outliner_add_element(soops, &te->subtree, arm, te, TSE_ANIM_DATA, 0); + + if(arm->edbo) { + EditBone *ebone; + TreeElement *ten; + + for (ebone = arm->edbo->first; ebone; ebone=ebone->next, a++) { + ten= outliner_add_element(soops, &te->subtree, id, te, TSE_EBONE, a); + ten->directdata= ebone; + ten->name= ebone->name; + ebone->temp= ten; + } + /* make hierarchy */ + ten= te->subtree.first; + while(ten) { + TreeElement *nten= ten->next, *par; + ebone= (EditBone *)ten->directdata; + if(ebone->parent) { + BLI_remlink(&te->subtree, ten); + par= ebone->parent->temp; + BLI_addtail(&par->subtree, ten); + ten->parent= par; + } + ten= nten; + } + } + else { + /* do not extend Armature when we have posemode */ + tselem= TREESTORE(te->parent); + if( GS(tselem->id->name)==ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE); + else { + Bone *curBone; + for (curBone=arm->bonebase.first; curBone; curBone=curBone->next){ + outliner_add_bone(soops, &te->subtree, id, curBone, te, &a); + } + } + } + } + break; + } +} + +// TODO: this function needs to be split up! It's getting a bit too large... +static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, + TreeElement *parent, short type, short index) +{ + TreeElement *te; + TreeStoreElem *tselem; + ID *id= idv; + int a = 0; + + if(ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { + id= ((PointerRNA*)idv)->id.data; + if(!id) id= ((PointerRNA*)idv)->data; + } + + if(id==NULL) return NULL; + + te= MEM_callocN(sizeof(TreeElement), "tree elem"); + /* add to the visual tree */ + BLI_addtail(lb, te); + /* add to the storage */ + check_persistant(soops, te, id, type, index); + tselem= TREESTORE(te); + + te->parent= parent; + te->index= index; // for data arays + if(ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)); + else if(ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)); + else if(type==TSE_ANIM_DATA); + else { + te->name= id->name+2; // default, can be overridden by Library or non-ID data + te->idcode= GS(id->name); + } + + if(type==0) { + /* ID datablock */ + outliner_add_id_contents(soops, te, tselem, id); + } + else if(type==TSE_ANIM_DATA) { + IdAdtTemplate *iat = (IdAdtTemplate *)idv; + AnimData *adt= (AnimData *)iat->adt; + + /* this element's info */ + te->name= "Animation"; + te->directdata= adt; + + /* Action */ + outliner_add_element(soops, &te->subtree, adt->action, te, 0, 0); + + /* Drivers */ + if (adt->drivers.first) { + TreeElement *ted= outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0); + ID *lastadded= NULL; + FCurve *fcu; + + ted->name= "Drivers"; + + for (fcu= adt->drivers.first; fcu; fcu= fcu->next) { + if (fcu->driver && fcu->driver->variables.first) { + ChannelDriver *driver= fcu->driver; + DriverVar *dvar; + + for (dvar= driver->variables.first; dvar; dvar= dvar->next) { + /* loop over all targets used here */ + DRIVER_TARGETS_USED_LOOPER(dvar) + { + if (lastadded != dtar->id) { + // XXX this lastadded check is rather lame, and also fails quite badly... + outliner_add_element(soops, &ted->subtree, dtar->id, ted, TSE_LINKED_OB, 0); + lastadded= dtar->id; + } + } + DRIVER_TARGETS_LOOPER_END + } + } + } + } + + /* NLA Data */ + if (adt->nla_tracks.first) { + TreeElement *tenla= outliner_add_element(soops, &te->subtree, adt, te, TSE_NLA, 0); + NlaTrack *nlt; + int a= 0; + + tenla->name= "NLA Tracks"; + + for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) { + TreeElement *tenlt= outliner_add_element(soops, &tenla->subtree, nlt, tenla, TSE_NLA_TRACK, a); + NlaStrip *strip; + TreeElement *ten; + int b= 0; + + tenlt->name= nlt->name; + + for (strip=nlt->strips.first; strip; strip=strip->next, b++) { + ten= outliner_add_element(soops, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b); + if(ten) ten->directdata= strip; + } + } + } + } + else if(type==TSE_SEQUENCE) { + Sequence *seq= (Sequence*) idv; + Sequence *p; + + /* + * The idcode is a little hack, but the outliner + * only check te->idcode if te->type is equal to zero, + * so this is "safe". + */ + te->idcode= seq->type; + te->directdata= seq; + + if(seq->type<7) { + /* + * This work like the sequence. + * If the sequence have a name (not default name) + * show it, in other case put the filename. + */ + if(strcmp(seq->name, "SQ")) + te->name= seq->name; + else { + if((seq->strip) && (seq->strip->stripdata)) + te->name= seq->strip->stripdata->name; + else + te->name= "SQ None"; + } + + if(seq->type==SEQ_META) { + te->name= "Meta Strip"; + p= seq->seqbase.first; + while(p) { + outliner_add_element(soops, &te->subtree, (void*)p, te, TSE_SEQUENCE, index); + p= p->next; + } + } + else + outliner_add_element(soops, &te->subtree, (void*)seq->strip, te, TSE_SEQ_STRIP, index); + } + else + te->name= "Effect"; + } + else if(type==TSE_SEQ_STRIP) { + Strip *strip= (Strip *)idv; + + if(strip->dir) + te->name= strip->dir; + else + te->name= "Strip None"; + te->directdata= strip; + } + else if(type==TSE_SEQUENCE_DUP) { + Sequence *seq= (Sequence*)idv; + + te->idcode= seq->type; + te->directdata= seq; + te->name= seq->strip->stripdata->name; + } + else if(ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { + PointerRNA pptr, propptr, *ptr= (PointerRNA*)idv; + PropertyRNA *prop, *iterprop; + PropertyType proptype; + int a, tot; + + /* we do lazy build, for speed and to avoid infinite recusion */ + + if(ptr->data == NULL) { + te->name= "(empty)"; + } + else if(type == TSE_RNA_STRUCT) { + /* struct */ + te->name= RNA_struct_name_get_alloc(ptr, NULL, 0); + + if(te->name) + te->flag |= TE_FREE_NAME; + else + te->name= (char*)RNA_struct_ui_name(ptr->type); + + iterprop= RNA_struct_iterator_property(ptr->type); + tot= RNA_property_collection_length(ptr, iterprop); + + /* auto open these cases */ + if(!parent || (RNA_property_type(parent->directdata)) == PROP_POINTER) + if(!tselem->used) + tselem->flag &= ~TSE_CLOSED; + + if(!(tselem->flag & TSE_CLOSED)) { + for(a=0; a<tot; a++) + outliner_add_element(soops, &te->subtree, (void*)ptr, te, TSE_RNA_PROPERTY, a); + } + else if(tot) + te->flag |= TE_LAZY_CLOSED; + + te->rnaptr= *ptr; + } + else if(type == TSE_RNA_PROPERTY) { + /* property */ + iterprop= RNA_struct_iterator_property(ptr->type); + RNA_property_collection_lookup_int(ptr, iterprop, index, &propptr); + + prop= propptr.data; + proptype= RNA_property_type(prop); + + te->name= (char*)RNA_property_ui_name(prop); + te->directdata= prop; + te->rnaptr= *ptr; + + if(proptype == PROP_POINTER) { + pptr= RNA_property_pointer_get(ptr, prop); + + if(pptr.data) { + if(!(tselem->flag & TSE_CLOSED)) + outliner_add_element(soops, &te->subtree, (void*)&pptr, te, TSE_RNA_STRUCT, -1); + else + te->flag |= TE_LAZY_CLOSED; + } + } + else if(proptype == PROP_COLLECTION) { + tot= RNA_property_collection_length(ptr, prop); + + if(!(tselem->flag & TSE_CLOSED)) { + for(a=0; a<tot; a++) { + RNA_property_collection_lookup_int(ptr, prop, a, &pptr); + outliner_add_element(soops, &te->subtree, (void*)&pptr, te, TSE_RNA_STRUCT, a); + } + } + else if(tot) + te->flag |= TE_LAZY_CLOSED; + } + else if(ELEM3(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) { + tot= RNA_property_array_length(ptr, prop); + + if(!(tselem->flag & TSE_CLOSED)) { + for(a=0; a<tot; a++) + outliner_add_element(soops, &te->subtree, (void*)ptr, te, TSE_RNA_ARRAY_ELEM, a); + } + else if(tot) + te->flag |= TE_LAZY_CLOSED; + } + } + else if(type == TSE_RNA_ARRAY_ELEM) { + char c; + + prop= parent->directdata; + + te->directdata= prop; + te->rnaptr= *ptr; + te->index= index; + + c= RNA_property_array_item_char(prop, index); + + te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName"); + if(c) sprintf((char *)te->name, " %c", c); + else sprintf((char *)te->name, " %d", index+1); + te->flag |= TE_FREE_NAME; + } + } + else if(type == TSE_KEYMAP) { + wmKeyMap *km= (wmKeyMap *)idv; + wmKeyMapItem *kmi; + char opname[OP_MAX_TYPENAME]; + + te->directdata= idv; + te->name= km->idname; + + if(!(tselem->flag & TSE_CLOSED)) { + a= 0; + + for (kmi= km->items.first; kmi; kmi= kmi->next, a++) { + const char *key= WM_key_event_string(kmi->type); + + if(key[0]) { + wmOperatorType *ot= NULL; + + if(kmi->propvalue); + else ot= WM_operatortype_find(kmi->idname, 0); + + if(ot || kmi->propvalue) { + TreeElement *ten= outliner_add_element(soops, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a); + + ten->directdata= kmi; + + if(kmi->propvalue) { + ten->name= "Modal map, not yet"; + } + else { + WM_operator_py_idname(opname, ot->idname); + ten->name= BLI_strdup(opname); + ten->flag |= TE_FREE_NAME; + } + } + } + } + } + else + te->flag |= TE_LAZY_CLOSED; + } + + return te; +} + +/* ======================================================= */ +/* Sequencer mode tree building */ + +/* Helped function to put duplicate sequence in the same tree. */ +static int need_add_seq_dup(Sequence *seq) +{ + Sequence *p; + + if((!seq->strip) || (!seq->strip->stripdata) || (!seq->strip->stripdata->name)) + return(1); + + /* + * First check backward, if we found a duplicate + * sequence before this, don't need it, just return. + */ + p= seq->prev; + while(p) { + if((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { + p= p->prev; + continue; + } + + if(!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) + return(2); + p= p->prev; + } + + p= seq->next; + while(p) { + if((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { + p= p->next; + continue; + } + + if(!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) + return(0); + p= p->next; + } + return(1); +} + +static void outliner_add_seq_dup(SpaceOops *soops, Sequence *seq, TreeElement *te, short index) +{ + TreeElement *ch; + Sequence *p; + + p= seq; + while(p) { + if((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { + p= p->next; + continue; + } + + if(!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) + ch= outliner_add_element(soops, &te->subtree, (void*)p, te, TSE_SEQUENCE, index); + p= p->next; + } +} + +/* ======================================================= */ +/* Generic Tree Building helpers - order these are called is top to bottom */ + +/* Hierarchy --------------------------------------------- */ + +/* make sure elements are correctly nested */ +static void outliner_make_hierarchy(SpaceOops *soops, ListBase *lb) +{ + TreeElement *te, *ten, *tep; + TreeStoreElem *tselem; + + /* build hierarchy */ + // XXX also, set extents here... + te= lb->first; + while(te) { + ten= te->next; + tselem= TREESTORE(te); + + if(tselem->type==0 && te->idcode==ID_OB) { + Object *ob= (Object *)tselem->id; + if(ob->parent && ob->parent->id.newid) { + BLI_remlink(lb, te); + tep= (TreeElement *)ob->parent->id.newid; + BLI_addtail(&tep->subtree, te); + // set correct parent pointers + for(te=tep->subtree.first; te; te= te->next) te->parent= tep; + } + } + te= ten; + } +} + +/* Sorting ------------------------------------------------------ */ + +typedef struct tTreeSort { + TreeElement *te; + ID *id; + const char *name; + short idcode; +} tTreeSort; + +/* alphabetical comparator */ +static int treesort_alpha(const void *v1, const void *v2) +{ + const tTreeSort *x1= v1, *x2= v2; + int comp; + + /* first put objects last (hierarchy) */ + comp= (x1->idcode==ID_OB); + if(x2->idcode==ID_OB) comp+=2; + + if(comp==1) return 1; + else if(comp==2) return -1; + else if(comp==3) { + comp= strcmp(x1->name, x2->name); + + if( comp>0 ) return 1; + else if( comp<0) return -1; + return 0; + } + return 0; +} + +/* this is nice option for later? doesnt look too useful... */ +#if 0 +static int treesort_obtype_alpha(const void *v1, const void *v2) +{ + const tTreeSort *x1= v1, *x2= v2; + + /* first put objects last (hierarchy) */ + if(x1->idcode==ID_OB && x2->idcode!=ID_OB) return 1; + else if(x2->idcode==ID_OB && x1->idcode!=ID_OB) return -1; + else { + /* 2nd we check ob type */ + if(x1->idcode==ID_OB && x2->idcode==ID_OB) { + if( ((Object *)x1->id)->type > ((Object *)x2->id)->type) return 1; + else if( ((Object *)x1->id)->type > ((Object *)x2->id)->type) return -1; + else return 0; + } + else { + int comp= strcmp(x1->name, x2->name); + + if( comp>0 ) return 1; + else if( comp<0) return -1; + return 0; + } + } +} +#endif + +/* sort happens on each subtree individual */ +static void outliner_sort(SpaceOops *soops, ListBase *lb) +{ + TreeElement *te; + TreeStoreElem *tselem; + int totelem=0; + + te= lb->last; + if(te==NULL) return; + tselem= TREESTORE(te); + + /* sorting rules; only object lists or deformgroups */ + if( (tselem->type==TSE_DEFGROUP) || (tselem->type==0 && te->idcode==ID_OB)) { + + /* count first */ + for(te= lb->first; te; te= te->next) totelem++; + + if(totelem>1) { + tTreeSort *tear= MEM_mallocN(totelem*sizeof(tTreeSort), "tree sort array"); + tTreeSort *tp=tear; + int skip= 0; + + for(te= lb->first; te; te= te->next, tp++) { + tselem= TREESTORE(te); + tp->te= te; + tp->name= te->name; + tp->idcode= te->idcode; + if(tselem->type && tselem->type!=TSE_DEFGROUP) tp->idcode= 0; // dont sort this + tp->id= tselem->id; + } + /* keep beginning of list */ + for(tp= tear, skip=0; skip<totelem; skip++, tp++) + if(tp->idcode) break; + + if(skip<totelem) + qsort(tear+skip, totelem-skip, sizeof(tTreeSort), treesort_alpha); + + lb->first=lb->last= NULL; + tp= tear; + while(totelem--) { + BLI_addtail(lb, tp->te); + tp++; + } + MEM_freeN(tear); + } + } + + for(te= lb->first; te; te= te->next) { + outliner_sort(soops, &te->subtree); + } +} + +/* Filtering ----------------------------------------------- */ + +static int outliner_filter_has_name(TreeElement *te, const char *name, int flags) +{ +#if 0 + int found= 0; + + /* determine if match */ + if (flags & SO_FIND_CASE_SENSITIVE) { + if (flags & SO_FIND_COMPLETE) + found= strcmp(te->name, name) == 0; + else + found= strstr(te->name, name) != NULL; + } + else { + if (flags & SO_FIND_COMPLETE) + found= BLI_strcasecmp(te->name, name) == 0; + else + found= BLI_strcasestr(te->name, name) != NULL; + } +#else + + int fn_flag= 0; + int found= 0; + + if ((flags & SO_FIND_CASE_SENSITIVE) == 0) + fn_flag |= FNM_CASEFOLD; + + if (flags & SO_FIND_COMPLETE) { + found= fnmatch(name, te->name, fn_flag)==0; + } + else { + char fn_name[sizeof(((struct SpaceOops *)NULL)->search_string) + 2]; + sprintf(fn_name, "*%s*", name); + found= fnmatch(fn_name, te->name, fn_flag)==0; + } + return found; +#endif +} + +static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) +{ + TreeElement *te, *ten; + TreeStoreElem *tselem; + + /* although we don't have any search string, we return TRUE + * since the entire tree is ok then... + */ + if (soops->search_string[0]==0) + return 1; + + for (te= lb->first; te; te= ten) { + ten= te->next; + + if (0==outliner_filter_has_name(te, soops->search_string, soops->search_flags)) { + /* item isn't something we're looking for, but... + * - if the subtree is expanded, check if there are any matches that can be easily found + * so that searching for "cu" in the default scene will still match the Cube + * - otherwise, we can't see within the subtree and the item doesn't match, + * so these can be safely ignored (i.e. the subtree can get freed) + */ + tselem= TREESTORE(te); + + if ((tselem->flag & TSE_CLOSED) || outliner_filter_tree(soops, &te->subtree)==0) { + outliner_free_tree(&te->subtree); + BLI_remlink(lb, te); + + if(te->flag & TE_FREE_NAME) MEM_freeN((void *)te->name); + MEM_freeN(te); + } + } + else { + /* filter subtree too */ + outliner_filter_tree(soops, &te->subtree); + } + } + + /* if there are still items in the list, that means that there were still some matches */ + return (lb->first != NULL); +} + +/* ======================================================= */ +/* Main Tree Building API */ + +/* Main entry point for building the tree data-structure that the outliner represents */ +// TODO: split each mode into its own function? +void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) +{ + Base *base; + Object *ob; + TreeElement *te=NULL, *ten; + TreeStoreElem *tselem; + int show_opened= (soops->treestore==NULL); /* on first view, we open scenes */ + + if(soops->tree.first && (soops->storeflag & SO_TREESTORE_REDRAW)) + return; + + outliner_free_tree(&soops->tree); + outliner_storage_cleanup(soops); + + /* clear ob id.new flags */ + for(ob= mainvar->object.first; ob; ob= ob->id.next) ob->id.newid= NULL; + + /* options */ + if(soops->outlinevis == SO_LIBRARIES) { + Library *lib; + + for(lib= mainvar->library.first; lib; lib= lib->id.next) { + ten= outliner_add_element(soops, &soops->tree, lib, NULL, 0, 0); + lib->id.newid= (ID *)ten; + } + /* make hierarchy */ + ten= soops->tree.first; + while(ten) { + TreeElement *nten= ten->next, *par; + tselem= TREESTORE(ten); + lib= (Library *)tselem->id; + if(lib->parent) { + BLI_remlink(&soops->tree, ten); + par= (TreeElement *)lib->parent->id.newid; + BLI_addtail(&par->subtree, ten); + ten->parent= par; + } + ten= nten; + } + /* restore newid pointers */ + for(lib= mainvar->library.first; lib; lib= lib->id.next) + lib->id.newid= NULL; + + } + else if(soops->outlinevis == SO_ALL_SCENES) { + Scene *sce; + for(sce= mainvar->scene.first; sce; sce= sce->id.next) { + te= outliner_add_element(soops, &soops->tree, sce, NULL, 0, 0); + tselem= TREESTORE(te); + if(sce==scene && show_opened) + tselem->flag &= ~TSE_CLOSED; + + for(base= sce->base.first; base; base= base->next) { + ten= outliner_add_element(soops, &te->subtree, base->object, te, 0, 0); + ten->directdata= base; + } + outliner_make_hierarchy(soops, &te->subtree); + /* clear id.newid, to prevent objects be inserted in wrong scenes (parent in other scene) */ + for(base= sce->base.first; base; base= base->next) base->object->id.newid= NULL; + } + } + else if(soops->outlinevis == SO_CUR_SCENE) { + + outliner_add_scene_contents(soops, &soops->tree, scene, NULL); + + for(base= scene->base.first; base; base= base->next) { + ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); + ten->directdata= base; + } + outliner_make_hierarchy(soops, &soops->tree); + } + else if(soops->outlinevis == SO_VISIBLE) { + for(base= scene->base.first; base; base= base->next) { + if(base->lay & scene->lay) + outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); + } + outliner_make_hierarchy(soops, &soops->tree); + } + else if(soops->outlinevis == SO_GROUPS) { + Group *group; + GroupObject *go; + + for(group= mainvar->group.first; group; group= group->id.next) { + if(group->gobject.first) { + te= outliner_add_element(soops, &soops->tree, group, NULL, 0, 0); + + for(go= group->gobject.first; go; go= go->next) { + ten= outliner_add_element(soops, &te->subtree, go->ob, te, 0, 0); + ten->directdata= NULL; /* eh, why? */ + } + outliner_make_hierarchy(soops, &te->subtree); + /* clear id.newid, to prevent objects be inserted in wrong scenes (parent in other scene) */ + for(go= group->gobject.first; go; go= go->next) go->ob->id.newid= NULL; + } + } + } + else if(soops->outlinevis == SO_SAME_TYPE) { + Object *ob= OBACT; + if(ob) { + for(base= scene->base.first; base; base= base->next) { + if(base->object->type==ob->type) { + ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); + ten->directdata= base; + } + } + outliner_make_hierarchy(soops, &soops->tree); + } + } + else if(soops->outlinevis == SO_SELECTED) { + for(base= scene->base.first; base; base= base->next) { + if(base->lay & scene->lay) { + if(base==BASACT || (base->flag & SELECT)) { + ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); + ten->directdata= base; + } + } + } + outliner_make_hierarchy(soops, &soops->tree); + } + else if(soops->outlinevis==SO_SEQUENCE) { + Sequence *seq; + Editing *ed= seq_give_editing(scene, FALSE); + int op; + + if(ed==NULL) + return; + + seq= ed->seqbasep->first; + if(!seq) + return; + + while(seq) { + op= need_add_seq_dup(seq); + if(op==1) + ten= outliner_add_element(soops, &soops->tree, (void*)seq, NULL, TSE_SEQUENCE, 0); + else if(op==0) { + ten= outliner_add_element(soops, &soops->tree, (void*)seq, NULL, TSE_SEQUENCE_DUP, 0); + outliner_add_seq_dup(soops, seq, ten, 0); + } + seq= seq->next; + } + } + else if(soops->outlinevis==SO_DATABLOCKS) { + PointerRNA mainptr; + + RNA_main_pointer_create(mainvar, &mainptr); + + ten= outliner_add_element(soops, &soops->tree, (void*)&mainptr, NULL, TSE_RNA_STRUCT, -1); + + if(show_opened) { + tselem= TREESTORE(ten); + tselem->flag &= ~TSE_CLOSED; + } + } + else if(soops->outlinevis==SO_USERDEF) { + PointerRNA userdefptr; + + RNA_pointer_create(NULL, &RNA_UserPreferences, &U, &userdefptr); + + ten= outliner_add_element(soops, &soops->tree, (void*)&userdefptr, NULL, TSE_RNA_STRUCT, -1); + + if(show_opened) { + tselem= TREESTORE(ten); + tselem->flag &= ~TSE_CLOSED; + } + } + else if(soops->outlinevis==SO_KEYMAP) { + wmWindowManager *wm= mainvar->wm.first; + wmKeyMap *km; + + for(km= wm->defaultconf->keymaps.first; km; km= km->next) { + ten= outliner_add_element(soops, &soops->tree, (void*)km, NULL, TSE_KEYMAP, 0); + } + } + else { + ten= outliner_add_element(soops, &soops->tree, OBACT, NULL, 0, 0); + if(ten) ten->directdata= BASACT; + } + + outliner_sort(soops, &soops->tree); + outliner_filter_tree(soops, &soops->tree); +} + + diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 13b186b174b..603be557a3c 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -179,6 +179,13 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn) break; } break; + case NC_ANIMATION: + switch(wmn->data) { + case ND_NLA_ACTCHANGE: + ED_region_tag_redraw(ar); + break; + } + break; } } diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index b105b2507ab..14004e7fbba 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -83,9 +83,8 @@ /* avoid passing multiple args and be more verbose */ #define SEQPROP_STARTFRAME (1<<0) #define SEQPROP_ENDFRAME (1<<1) -#define SEQPROP_FILES (1<<2) -#define SEQPROP_NOPATHS (1<<3) -#define SEQPROP_NOCHAN (1<<4) +#define SEQPROP_NOPATHS (1<<2) +#define SEQPROP_NOCHAN (1<<3) #define SELECT 1 @@ -102,9 +101,6 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) RNA_def_boolean(ot->srna, "replace_sel", 1, "Replace Selection", "replace the current selection"); RNA_def_boolean(ot->srna, "overlap", 0, "Allow Overlap", "Don't correct overlap on new sequence strips"); - - if(flag & SEQPROP_FILES) - RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", ""); } static void sequencer_generic_invoke_path__internal(bContext *C, wmOperator *op, const char *identifier) @@ -411,8 +407,8 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); - sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILES); + WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH|WM_FILESEL_FILES); + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); RNA_def_boolean(ot->srna, "sound", TRUE, "Sound", "Load sound with the movie"); } @@ -466,8 +462,8 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); - sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILES); + WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH|WM_FILESEL_FILES); + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory."); } @@ -573,8 +569,8 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH); - sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME|SEQPROP_FILES); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH|WM_FILESEL_FILES); + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME); } diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 6a69d32d307..447426aed13 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -392,205 +392,6 @@ void recurs_sel_seq(Sequence *seqm) } } -int event_to_efftype(int event) -{ - if(event==2) return SEQ_CROSS; - if(event==3) return SEQ_GAMCROSS; - if(event==4) return SEQ_ADD; - if(event==5) return SEQ_SUB; - if(event==6) return SEQ_MUL; - if(event==7) return SEQ_ALPHAOVER; - if(event==8) return SEQ_ALPHAUNDER; - if(event==9) return SEQ_OVERDROP; - if(event==10) return SEQ_PLUGIN; - if(event==13) return SEQ_WIPE; - if(event==14) return SEQ_GLOW; - if(event==15) return SEQ_TRANSFORM; - if(event==16) return SEQ_COLOR; - if(event==17) return SEQ_SPEED; - if(event==18) return SEQ_ADJUSTMENT; - return 0; -} - -#if 0 -static void reload_sound_strip(Scene *scene, char *name) -{ - Editing *ed; - Sequence *seq, *seqact; - SpaceFile *sfile; - Sequence *last_seq= seq_active_get(scene); - - ed= scene->ed; - - if(last_seq==0 || last_seq->type!=SEQ_SOUND) return; - seqact= last_seq; /* last_seq changes in alloc_sequence */ - - /* search sfile */ -// sfile= scrarea_find_space_of_type(curarea, SPACE_FILE); - if(sfile==0) return; - - waitcursor(1); - - seq = sfile_to_snd_sequence(sfile, seqact->start, seqact->machine); - printf("seq->type: %i\n", seq->type); - if(seq && seq!=seqact) { - /* i'm not sure about this one, seems to work without it -- sgefant */ - seq_free_strip(seqact->strip); - - seqact->strip= seq->strip; - - seqact->len= seq->len; - calc_sequence(scene, seqact); - - seq->strip= 0; - seq_free_sequence(scene, seq); - BLI_remlink(ed->seqbasep, seq); - - seq= ed->seqbasep->first; - - } - - waitcursor(0); - -} -#endif - -static void reload_image_strip(Scene *scene, char *UNUSED(name)) -{ - Editing *ed= seq_give_editing(scene, FALSE); - Sequence *seq=NULL, *seqact; - SpaceFile *sfile=NULL; - Sequence *last_seq= seq_active_get(scene); - - - - if(last_seq==NULL || last_seq->type!=SEQ_IMAGE) return; - seqact= last_seq; /* last_seq changes in alloc_sequence */ - - /* search sfile */ -// sfile= scrarea_find_space_of_type(curarea, SPACE_FILE); - if(sfile == NULL) return; - - waitcursor(1); - -// seq= sfile_to_sequence(scene, sfile, seqact->start, seqact->machine, 1); // XXX ADD BACK - if(seq && seq!=seqact) { - seq_free_strip(seqact->strip); - - seqact->strip= seq->strip; - - seqact->len= seq->len; - calc_sequence(scene, seqact); - - seq->strip= NULL; - seq_free_sequence(scene, seq); - BLI_remlink(ed->seqbasep, seq); - - update_changed_seq_and_deps(scene, seqact, 1, 1); - } - waitcursor(0); - -} - - -static void change_sequence(Scene *scene) -{ - Editing *ed= seq_give_editing(scene, FALSE); - Sequence *last_seq= seq_active_get(scene); - Scene *sce; - short event; - - if(last_seq == NULL) return; - - if(last_seq->type & SEQ_EFFECT) { - event = pupmenu("Change Effect%t" - "|Switch A <-> B %x1" - "|Switch B <-> C %x10" - "|Plugin%x11" - "|Recalculate%x12" - "|Cross%x2" - "|Gamma Cross%x3" - "|Add%x4" - "|Sub%x5" - "|Mul%x6" - "|Alpha Over%x7" - "|Alpha Under%x8" - "|Alpha Over Drop%x9" - "|Wipe%x13" - "|Glow%x14" - "|Transform%x15" - "|Color Generator%x16" - "|Speed Control%x17" - "|Adjustment Layer%x18"); - if(event > 0) { - if(event==1) { - SWAP(Sequence *,last_seq->seq1,last_seq->seq2); - } - else if(event==10) { - SWAP(Sequence *,last_seq->seq2,last_seq->seq3); - } - else if(event==11) { - activate_fileselect( - FILE_SPECIAL, "Select Plugin", - U.plugseqdir, change_plugin_seq); - } - else if(event==12); - /* recalculate: only new_stripdata */ - else { - /* free previous effect and init new effect */ - struct SeqEffectHandle sh; - - if (get_sequence_effect_num_inputs( - last_seq->type) - < get_sequence_effect_num_inputs( - event_to_efftype(event))) { - error("New effect needs more " - "input strips!"); - } else { - sh = get_sequence_effect(last_seq); - sh.free(last_seq); - - last_seq->type - = event_to_efftype(event); - - sh = get_sequence_effect(last_seq); - sh.init(last_seq); - } - } - - update_changed_seq_and_deps(scene, last_seq, 0, 1); - } - } - else if(last_seq->type == SEQ_IMAGE) { - if(okee("Change images")) { - activate_fileselect(FILE_SPECIAL, - "Select Images", - ed->act_imagedir, - reload_image_strip); - } - } - else if(last_seq->type == SEQ_MOVIE) { - ; - } - else if(last_seq->type == SEQ_SCENE) { - event= pupmenu("Change Scene%t|Update Start and End"); - - if(event==1) { - sce= last_seq->scene; - - last_seq->len= sce->r.efra - sce->r.sfra + 1; - last_seq->sfra= sce->r.sfra; - - /* bad code to change seq->len? update_changed_seq_and_deps() expects the strip->len to be OK */ - new_tstripdata(last_seq); - - update_changed_seq_and_deps(scene, last_seq, 1, 1); - - } - } - -} - int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequence **selseq1, Sequence **selseq2, Sequence **selseq3, const char **error_str) { Editing *ed = seq_give_editing(scene, FALSE); @@ -1103,6 +904,19 @@ int sequencer_edit_poll(bContext *C) return (seq_give_editing(CTX_data_scene(C), FALSE) != NULL); } +int sequencer_strip_poll(bContext *C) +{ + Editing *ed; + return (((ed= seq_give_editing(CTX_data_scene(C), FALSE)) != NULL) && (ed->act_seq != NULL)); +} + +int sequencer_strip_has_path_poll(bContext *C) +{ + Editing *ed; + Sequence *seq; + return (((ed= seq_give_editing(CTX_data_scene(C), FALSE)) != NULL) && ((seq= ed->act_seq) != NULL) && (SEQ_HAS_PATH(seq))); +} + int sequencer_view_poll(bContext *C) { SpaceSeq *sseq= CTX_wm_space_seq(C); @@ -1755,6 +1569,58 @@ void SEQUENCER_OT_delete(wmOperatorType *ot) } +/* offset clear operator */ +static int sequencer_offset_clear_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene= CTX_data_scene(C); + Editing *ed= seq_give_editing(scene, FALSE); + Sequence *seq; + + /* for effects, try to find a replacement input */ + for(seq=ed->seqbasep->first; seq; seq=seq->next) { + if((seq->type & SEQ_EFFECT)==0 && (seq->flag & SELECT)) { + seq->startofs= seq->endofs= seq->startstill= seq->endstill= 0; + } + } + + /* updates lengths etc */ + seq= ed->seqbasep->first; + while(seq) { + calc_sequence(scene, seq); + seq= seq->next; + } + + for(seq=ed->seqbasep->first; seq; seq=seq->next) { + if((seq->type & SEQ_EFFECT)==0 && (seq->flag & SELECT)) { + if(seq_test_overlap(ed->seqbasep, seq)) { + shuffle_seq(ed->seqbasep, seq, scene); + } + } + } + + WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + + +void SEQUENCER_OT_offset_clear(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name= "Clear Strip Offset"; + ot->idname= "SEQUENCER_OT_offset_clear"; + ot->description="Clear strip offsets from the start and end frames"; + + /* api callbacks */ + ot->exec= sequencer_offset_clear_exec; + ot->poll= sequencer_edit_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + + /* separate_images operator */ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) { @@ -2830,3 +2696,227 @@ void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot) /* rna */ WM_operator_properties_gesture_border(ot, FALSE); } + + +/* change ops */ + +static EnumPropertyItem prop_change_effect_input_types[] = { + {0, "A_B", 0, "A -> B", ""}, + {1, "B_C", 0, "B -> C", ""}, + {2, "A_C", 0, "A -> C", ""}, + {0, NULL, 0, NULL, NULL} +}; + +static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Editing *ed= seq_give_editing(scene, FALSE); + Sequence *seq= seq_active_get(scene); + + Sequence **seq_1, **seq_2; + + switch(RNA_enum_get(op->ptr, "swap")) { + case 0: + seq_1= &seq->seq1; + seq_2= &seq->seq2; + break; + case 1: + seq_1= &seq->seq2; + seq_2= &seq->seq3; + break; + default: /* 2 */ + seq_1= &seq->seq1; + seq_2= &seq->seq3; + break; + } + + if(*seq_1 == NULL || *seq_2 == NULL) { + BKE_report(op->reports, RPT_ERROR, "One of the effect inputs is unset, can't swap"); + return OPERATOR_CANCELLED; + } + else { + SWAP(Sequence *, *seq_1, *seq_2); + } + + update_changed_seq_and_deps(scene, seq, 0, 1); + + /* important else we dont get the imbuf cache flushed */ + free_imbuf_seq(scene, &ed->seqbase, FALSE, FALSE); + + WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_change_effect_input(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Change Effect Input"; + ot->idname= "SEQUENCER_OT_change_effect_input"; + ot->description=""; + + /* api callbacks */ + ot->exec= sequencer_change_effect_input_exec; + ot->poll= sequencer_effect_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + ot->prop= RNA_def_enum(ot->srna, "swap", prop_change_effect_input_types, 0, "Swap", "The effect inputs to swap"); +} + +static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Editing *ed= seq_give_editing(scene, FALSE); + Sequence *seq= seq_active_get(scene); + const int new_type= RNA_enum_get(op->ptr, "type"); + + /* free previous effect and init new effect */ + struct SeqEffectHandle sh; + + if ((seq->type & SEQ_EFFECT) == 0) { + return OPERATOR_CANCELLED; + } + + /* can someone explain the logic behind only allowing to increse this, + * copied from 2.4x - campbell */ + if (get_sequence_effect_num_inputs(seq->type) < + get_sequence_effect_num_inputs(new_type) + ) { + BKE_report(op->reports, RPT_ERROR, "New effect needs more input strips"); + return OPERATOR_CANCELLED; + } + else { + sh = get_sequence_effect(seq); + sh.free(seq); + + seq->type= new_type; + + sh = get_sequence_effect(seq); + sh.init(seq); + } + + /* update */ + update_changed_seq_and_deps(scene, seq, 0, 1); + + /* important else we dont get the imbuf cache flushed */ + free_imbuf_seq(scene, &ed->seqbase, FALSE, FALSE); + + WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_change_effect_type(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Change Effect Type"; + ot->idname= "SEQUENCER_OT_change_effect_type"; + ot->description=""; + + /* api callbacks */ + ot->exec= sequencer_change_effect_type_exec; + ot->poll= sequencer_effect_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + ot->prop= RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, SEQ_CROSS, "Type", "Sequencer effect type"); +} + +static int sequencer_change_path_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Editing *ed= seq_give_editing(scene, FALSE); + Sequence *seq= seq_active_get(scene); + + if(seq->type == SEQ_IMAGE) { + char directory[FILE_MAX]; + const int len= RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); + StripElem *se; + + if(len==0) + return OPERATOR_CANCELLED; + + RNA_string_get(op->ptr, "directory", directory); + BLI_strncpy(seq->strip->dir, directory, sizeof(seq->strip->dir)); + + if(seq->strip->stripdata) { + MEM_freeN(seq->strip->stripdata); + } + seq->strip->stripdata= se= MEM_callocN(len*sizeof(StripElem), "stripelem"); + + RNA_BEGIN(op->ptr, itemptr, "files") { + char *filename= RNA_string_get_alloc(&itemptr, "name", NULL, 0); + BLI_strncpy(se->name, filename, sizeof(se->name)); + MEM_freeN(filename); + se++; + } + RNA_END; + + /* reset these else we wont see all the images */ + seq->anim_startofs= seq->anim_endofs= 0; + + /* correct start/end frames so we dont move + * important not to set seq->len= len; allow the function to handle it */ + reload_sequence_new_file(scene, seq, TRUE); + + calc_sequence(scene, seq); + + /* important else we dont get the imbuf cache flushed */ + free_imbuf_seq(scene, &ed->seqbase, FALSE, FALSE); + } + else { + /* lame, set rna filepath */ + PointerRNA seq_ptr; + char filepath[FILE_MAX]; + + RNA_pointer_create(&scene->id, &RNA_Sequence, seq, &seq_ptr); + + RNA_string_get(op->ptr, "filepath", filepath); + RNA_string_set(&seq_ptr, "filepath", filepath); + } + + WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + +static int sequencer_change_path_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + Scene *scene= CTX_data_scene(C); + Sequence *seq= seq_active_get(scene); + + RNA_string_set(op->ptr, "directory", seq->strip->dir); + + /* set default display depending on seq type */ + if(seq->type == SEQ_IMAGE) { + RNA_boolean_set(op->ptr, "filter_movie", 0); + } + else { + RNA_boolean_set(op->ptr, "filter_image", 0); + } + + WM_event_add_fileselect(C, op); + + return OPERATOR_RUNNING_MODAL; +} + +void SEQUENCER_OT_change_path(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Change Data/Files"; + ot->idname= "SEQUENCER_OT_change_path"; + ot->description=""; + + /* api callbacks */ + ot->exec= sequencer_change_path_exec; + ot->invoke= sequencer_change_path_invoke; + ot->poll= sequencer_strip_has_path_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH|WM_FILESEL_FILEPATH|WM_FILESEL_FILES); +} diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 209b39662aa..7ab76f9b6d7 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -70,6 +70,8 @@ int seq_effect_find_selected(struct Scene *scene, struct Sequence *activeseq, in /* operator helpers */ int sequencer_edit_poll(struct bContext *C); +int sequencer_strip_poll(struct bContext *C); +int sequencer_strip_has_path_poll(struct bContext *C); int sequencer_view_poll(struct bContext *C); /* externs */ @@ -91,6 +93,7 @@ void SEQUENCER_OT_reassign_inputs(struct wmOperatorType *ot); void SEQUENCER_OT_swap_inputs(struct wmOperatorType *ot); void SEQUENCER_OT_duplicate(struct wmOperatorType *ot); void SEQUENCER_OT_delete(struct wmOperatorType *ot); +void SEQUENCER_OT_offset_clear(struct wmOperatorType *ot); void SEQUENCER_OT_images_separate(struct wmOperatorType *ot); void SEQUENCER_OT_meta_toggle(struct wmOperatorType *ot); void SEQUENCER_OT_meta_make(struct wmOperatorType *ot); @@ -108,6 +111,10 @@ void SEQUENCER_OT_view_selected(struct wmOperatorType *ot); void SEQUENCER_OT_view_zoom_ratio(struct wmOperatorType *ot); void SEQUENCER_OT_view_ghost_border(struct wmOperatorType *ot); +void SEQUENCER_OT_change_effect_input(struct wmOperatorType *ot); +void SEQUENCER_OT_change_effect_type(struct wmOperatorType *ot); +void SEQUENCER_OT_change_path(struct wmOperatorType *ot); + void SEQUENCER_OT_copy(struct wmOperatorType *ot); void SEQUENCER_OT_paste(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index f5c26cb17d3..df33ce73b9c 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -68,6 +68,7 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_swap_inputs); WM_operatortype_append(SEQUENCER_OT_duplicate); WM_operatortype_append(SEQUENCER_OT_delete); + WM_operatortype_append(SEQUENCER_OT_offset_clear); WM_operatortype_append(SEQUENCER_OT_images_separate); WM_operatortype_append(SEQUENCER_OT_meta_toggle); WM_operatortype_append(SEQUENCER_OT_meta_make); @@ -86,6 +87,10 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_view_zoom_ratio); WM_operatortype_append(SEQUENCER_OT_view_ghost_border); + WM_operatortype_append(SEQUENCER_OT_change_effect_input); + WM_operatortype_append(SEQUENCER_OT_change_effect_type); + WM_operatortype_append(SEQUENCER_OT_change_path); + /* sequencer_select.c */ WM_operatortype_append(SEQUENCER_OT_select_all_toggle); WM_operatortype_append(SEQUENCER_OT_select_inverse); @@ -145,6 +150,8 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_reassign_inputs", RKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_reload", RKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "SEQUENCER_OT_offset_clear", OKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "SEQUENCER_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", XKEY, KM_PRESS, 0, 0); @@ -240,6 +247,8 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_select_border", BKEY, KM_PRESS, 0, 0); WM_keymap_add_menu(keymap, "SEQUENCER_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0); + + WM_keymap_add_menu(keymap, "SEQUENCER_MT_change", CKEY, KM_PRESS, 0, 0); kmi= WM_keymap_add_item(keymap, "WM_OT_context_set_int", OKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "scene.sequence_editor.overlay_frame"); diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 351be1ca4c9..9a6e14fcbad 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -29,7 +29,6 @@ * \ingroup spview3d */ - #include <string.h> #include <math.h> @@ -73,24 +72,21 @@ #include "view3d_intern.h" // own include -/***/ +/**************************** Face Select Mode *******************************/ - /* Flags for marked edges */ +/* Flags for marked edges */ enum { eEdge_Visible = (1<<0), eEdge_Select = (1<<1), }; - /* Creates a hash of edges to flags indicating - * adjacent tface select/active/etc flags. - */ +/* Creates a hash of edges to flags indicating selected/visible */ static void get_marked_edge_info__orFlags(EdgeHash *eh, int v0, int v1, int flags) { int *flags_p; - if (!BLI_edgehash_haskey(eh, v0, v1)) { + if(!BLI_edgehash_haskey(eh, v0, v1)) BLI_edgehash_insert(eh, v0, v1, NULL); - } flags_p = (int*) BLI_edgehash_lookup_p(eh, v0, v1); *flags_p |= flags; @@ -99,26 +95,25 @@ static void get_marked_edge_info__orFlags(EdgeHash *eh, int v0, int v1, int flag static EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me) { EdgeHash *eh = BLI_edgehash_new(); - int i; MFace *mf; + int i; - for (i=0; i<me->totface; i++) { + for(i=0; i<me->totface; i++) { mf = &me->mface[i]; - if (mf->v3) { - if (!(mf->flag&ME_HIDE)) { - unsigned int flags = eEdge_Visible; - if (mf->flag&ME_FACE_SEL) flags |= eEdge_Select; - - get_marked_edge_info__orFlags(eh, mf->v1, mf->v2, flags); - get_marked_edge_info__orFlags(eh, mf->v2, mf->v3, flags); - if (mf->v4) { - get_marked_edge_info__orFlags(eh, mf->v3, mf->v4, flags); - get_marked_edge_info__orFlags(eh, mf->v4, mf->v1, flags); - } else { - get_marked_edge_info__orFlags(eh, mf->v3, mf->v1, flags); - } + if(!(mf->flag & ME_HIDE)) { + unsigned int flags = eEdge_Visible; + if(mf->flag & ME_FACE_SEL) flags |= eEdge_Select; + + get_marked_edge_info__orFlags(eh, mf->v1, mf->v2, flags); + get_marked_edge_info__orFlags(eh, mf->v2, mf->v3, flags); + + if(mf->v4) { + get_marked_edge_info__orFlags(eh, mf->v3, mf->v4, flags); + get_marked_edge_info__orFlags(eh, mf->v4, mf->v1, flags); } + else + get_marked_edge_info__orFlags(eh, mf->v3, mf->v1, flags); } } @@ -126,45 +121,24 @@ static EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me) } -static int draw_tfaces3D__setHiddenOpts(void *userData, int index) +static int draw_mesh_face_select__setHiddenOpts(void *userData, int index) { struct { Mesh *me; EdgeHash *eh; } *data = userData; Mesh *me= data->me; MEdge *med = &me->medge[index]; uintptr_t flags = (intptr_t) BLI_edgehash_lookup(data->eh, med->v1, med->v2); - if((me->drawflag & ME_DRAWSEAMS) && (med->flag&ME_SEAM)) { - return 0; - } else if(me->drawflag & ME_DRAWEDGES){ - if (me->drawflag & ME_HIDDENEDGES) { + if(me->drawflag & ME_DRAWEDGES) { + if(me->drawflag & ME_HIDDENEDGES) return 1; - } else { - return (flags & eEdge_Visible); - } - } else { - return (flags & eEdge_Select); - } -} - -static int draw_tfaces3D__setSeamOpts(void *userData, int index) -{ - struct { Mesh *me; EdgeHash *eh; } *data = userData; - Mesh *me= data->me; - MEdge *med = &data->me->medge[index]; - uintptr_t flags = (intptr_t) BLI_edgehash_lookup(data->eh, med->v1, med->v2); - - if (med->flag & ME_SEAM) { - if (me->drawflag & ME_HIDDENEDGES) { - return 1; - } else { + else return (flags & eEdge_Visible); - } - } else { - return 0; } + else + return (flags & eEdge_Select); } -static int draw_tfaces3D__setSelectOpts(void *userData, int index) +static int draw_mesh_face_select__setSelectOpts(void *userData, int index) { struct { Mesh *me; EdgeHash *eh; } *data = userData; MEdge *med = &data->me->medge[index]; @@ -173,45 +147,19 @@ static int draw_tfaces3D__setSelectOpts(void *userData, int index) return flags & eEdge_Select; } -#if 0 -static int draw_tfaces3D__setActiveOpts(void *userData, int index) -{ - struct { Mesh *me; EdgeHash *eh; } *data = userData; - MEdge *med = &data->me->medge[index]; - uintptr_t flags = (intptr_t) BLI_edgehash_lookup(data->eh, med->v1, med->v2); - - if (flags & eEdge_Select) { - return 1; - } else { - return 0; - } -} - -static int draw_tfaces3D__drawFaceOpts(void *userData, int index) -{ - Mesh *me = (Mesh*)userData; - - MFace *mface = &me->mface[index]; - if (!(mface->flag&ME_HIDE) && (mface->flag&ME_FACE_SEL)) - return 2; /* Don't set color */ - else - return 0; -} -#endif - /* draws unselected */ -static int draw_tfaces3D__drawFaceOptsInv(void *userData, int index) +static int draw_mesh_face_select__drawFaceOptsInv(void *userData, int index) { Mesh *me = (Mesh*)userData; MFace *mface = &me->mface[index]; - if (!(mface->flag&ME_HIDE) && !(mface->flag&ME_FACE_SEL)) + if(!(mface->flag&ME_HIDE) && !(mface->flag&ME_FACE_SEL)) return 2; /* Don't set color */ else return 0; } -static void draw_tfaces3D(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm, short draw_seams) +static void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm) { struct { Mesh *me; EdgeHash *eh; } data; @@ -225,30 +173,16 @@ static void draw_tfaces3D(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm, short d /* Draw (Hidden) Edges */ setlinestyle(1); UI_ThemeColor(TH_EDGE_FACESEL); - dm->drawMappedEdges(dm, draw_tfaces3D__setHiddenOpts, &data); + dm->drawMappedEdges(dm, draw_mesh_face_select__setHiddenOpts, &data); setlinestyle(0); - /* Draw Seams */ - if(draw_seams && me->drawflag & ME_DRAWSEAMS) { - UI_ThemeColor(TH_EDGE_SEAM); - glLineWidth(2); - dm->drawMappedEdges(dm, draw_tfaces3D__setSeamOpts, &data); - glLineWidth(1); - } - /* Draw Selected Faces */ if(me->drawflag & ME_DRAWFACES) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -#if 0 - UI_ThemeColor4(TH_FACE_SELECT); - - dm->drawMappedFacesTex(dm, draw_tfaces3D__drawFaceOpts, (void*)me); -#else /* dull unselected faces so as not to get in the way of seeing color */ glColor4ub(96, 96, 96, 64); - dm->drawMappedFacesTex(dm, draw_tfaces3D__drawFaceOptsInv, (void*)me); -#endif + dm->drawMappedFacesTex(dm, draw_mesh_face_select__drawFaceOptsInv, (void*)me); glDisable(GL_BLEND); } @@ -258,7 +192,7 @@ static void draw_tfaces3D(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm, short d /* Draw Stippled Outline for selected faces */ glColor3ub(255, 255, 255); setlinestyle(1); - dm->drawMappedEdges(dm, draw_tfaces3D__setSelectOpts, &data); + dm->drawMappedEdges(dm, draw_mesh_face_select__setSelectOpts, &data); setlinestyle(0); bglPolygonOffset(rv3d->dist, 0.0); // resets correctly now, even after calling accumulated offsets @@ -266,6 +200,8 @@ static void draw_tfaces3D(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm, short d BLI_edgehash_free(data.eh, NULL); } +/***************************** Texture Drawing ******************************/ + static Material *give_current_material_or_def(Object *ob, int matnr) { extern Material defmaterial; // render module abuse... @@ -695,18 +631,21 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o if(ob->mode & OB_MODE_EDIT) { dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, me->edit_btmesh); - } else if(faceselect) { + } + else if(faceselect) { if(ob->mode & OB_MODE_WEIGHT_PAINT) dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1, GPU_enable_material); else dm->drawMappedFacesTex(dm, me->mface ? draw_tface_mapped__set_draw : NULL, me); } else { - if( GPU_buffer_legacy(dm) ) + if(GPU_buffer_legacy(dm)) { dm->drawFacesTex(dm, draw_tface__set_draw_legacy); + } else { - if( !CustomData_has_layer(&dm->faceData,CD_TEXTURE_MCOL) ) + if(!CustomData_has_layer(&dm->faceData,CD_TEXTURE_MCOL)) add_tface_color_layer(dm); + dm->drawFacesTex(dm, draw_tface__set_draw); } } @@ -719,7 +658,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o /* draw edges and selected faces over textured mesh */ if(!(ob == scene->obedit) && faceselect) - draw_tfaces3D(rv3d, me, dm, ob->mode & OB_MODE_WEIGHT_PAINT); + draw_mesh_face_select(rv3d, me, dm); /* reset from negative scale correction */ glFrontFace(GL_CCW); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 6e3f6549ba3..7cf95261211 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2769,3 +2769,4 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) v3d->flag |= V3D_INVALID_BACKBUF; } + diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index f06b4678d70..0cfeaffe981 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -46,6 +46,7 @@ #include "BLI_editVert.h" #include "BLI_rand.h" #include "BLI_utildefines.h" +#include "BLI_ghash.h" #include "BKE_context.h" #include "BKE_idprop.h" @@ -140,10 +141,11 @@ static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2) static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items) { - wmOperatorType *ot = WM_operatortype_first(); - - for(; ot; ot= ot->next) { - + GHashIterator *iter= WM_operatortype_iter(); + + for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + wmOperatorType *ot= BLI_ghashIterator_getValue(iter); + if(BLI_strcasestr(ot->name, str)) { if(WM_operator_poll((bContext*)C, ot)) { @@ -152,6 +154,7 @@ static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), cons } } } + BLI_ghashIterator_free(iter); } diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index 8bf923a5679..d0c7f9d494f 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -178,6 +178,7 @@ typedef struct GPUVertexAttribs { struct { int type; int glindex; + int gltexco; char name[32]; } layer[GPU_MAX_ATTRIB]; diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 251c4449c34..82ad20d4001 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -713,16 +713,16 @@ typedef struct ShapeKeyModifierData { typedef struct SolidifyModifierData { ModifierData modifier; - char defgrp_name[32]; /* name of vertex group to use */ + char defgrp_name[32]; /* name of vertex group to use */ float offset; /* new surface offset level*/ float offset_fac; /* midpoint of the offset */ + float offset_fac_vg; /* factor for the minimum weight to use when vgroups are used, avoids 0.0 weights giving duplicate geometry */ float crease_inner; float crease_outer; float crease_rim; int flag; short mat_ofs; short mat_ofs_rim; - int pad; } SolidifyModifierData; #define MOD_SOLIDIFY_RIM (1<<0) diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 54977066909..3244c9c6305 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -2268,6 +2268,13 @@ static void rna_def_modifier_solidify(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Thickness", "Thickness of the shell"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop= RNA_def_property(srna, "thickness_vertex_group", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "offset_fac_vg"); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_ui_range(prop, 0, 1, 0.1, 3); + RNA_def_property_ui_text(prop, "Vertex Group Factor", "Thickness factor to use for zero vertex group influence"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "offset_fac"); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index 4e520f19f58..b74918601e0 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -213,4 +213,5 @@ ModifierTypeInfo modifierType_Armature = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 7128715c15a..d987e3fb3a9 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -563,4 +563,5 @@ ModifierTypeInfo modifierType_Array = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 1bcaf4df8f9..9da150f2f60 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -153,4 +153,5 @@ ModifierTypeInfo modifierType_Bevel = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index f8a9fdcfbb1..826ddf0dd1e 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -197,4 +197,5 @@ ModifierTypeInfo modifierType_Boolean = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index fbe1548eab1..ee38ba41171 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -328,5 +328,6 @@ ModifierTypeInfo modifierType_Build = { /* dependsOnTime */ dependsOnTime, /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index 0327497d267..d504445109c 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -632,4 +632,5 @@ ModifierTypeInfo modifierType_Cast = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index 1d2a6b2f788..f5493162322 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -229,4 +229,5 @@ ModifierTypeInfo modifierType_Cloth = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ foreachIDLink, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c index 315361ff227..2c07a6ee63c 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.c @@ -267,4 +267,5 @@ ModifierTypeInfo modifierType_Collision = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c index da793287520..6387155b8fd 100644 --- a/source/blender/modifiers/intern/MOD_curve.c +++ b/source/blender/modifiers/intern/MOD_curve.c @@ -162,4 +162,5 @@ ModifierTypeInfo modifierType_Curve = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c index 61aae4e573b..db1181d0652 100644 --- a/source/blender/modifiers/intern/MOD_decimate.c +++ b/source/blender/modifiers/intern/MOD_decimate.c @@ -222,4 +222,5 @@ ModifierTypeInfo modifierType_Decimate = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 15af3132b04..7bd2dbaa7e0 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -134,6 +134,12 @@ static void foreachIDLink(ModifierData *md, Object *ob, foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData); } +static void foreachTexLink(ModifierData *md, Object *ob, + TexWalkFunc walk, void *userData) +{ + walk(userData, ob, md, "texture"); +} + static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { DisplaceModifierData *dmd = (DisplaceModifierData*) md; @@ -284,4 +290,5 @@ ModifierTypeInfo modifierType_Displace = { /* dependsOnNormals */ dependsOnNormals, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ foreachIDLink, + /* foreachTexLink */ foreachTexLink, }; diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index 90faff5c68c..e793f12de23 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -193,4 +193,5 @@ ModifierTypeInfo modifierType_EdgeSplit = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index e879d984dc8..bfd4be66c03 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -1041,4 +1041,5 @@ ModifierTypeInfo modifierType_Explode = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c index 354dc33ffe0..cce288b4ad5 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim.c +++ b/source/blender/modifiers/intern/MOD_fluidsim.c @@ -162,4 +162,5 @@ ModifierTypeInfo modifierType_Fluidsim = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index c504c1bf660..1c984fbe323 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -289,4 +289,5 @@ ModifierTypeInfo modifierType_Hook = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c index 0d7c0f1509c..2ddbe45ee26 100644 --- a/source/blender/modifiers/intern/MOD_lattice.c +++ b/source/blender/modifiers/intern/MOD_lattice.c @@ -156,4 +156,5 @@ ModifierTypeInfo modifierType_Lattice = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index 3a985b49c35..b93d1e38abd 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -411,4 +411,5 @@ ModifierTypeInfo modifierType_Mask = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index 22a6c28557f..e172531f9ad 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -463,4 +463,5 @@ ModifierTypeInfo modifierType_MeshDeform = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c index 3a9cc133b83..d93d7aecb5d 100644 --- a/source/blender/modifiers/intern/MOD_mirror.c +++ b/source/blender/modifiers/intern/MOD_mirror.c @@ -333,4 +333,5 @@ ModifierTypeInfo modifierType_Mirror = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index 29d4c2a0530..582360dfc09 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -131,4 +131,5 @@ ModifierTypeInfo modifierType_Multires = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_none.c b/source/blender/modifiers/intern/MOD_none.c index 48c5b9a4c08..8fed2150a75 100644 --- a/source/blender/modifiers/intern/MOD_none.c +++ b/source/blender/modifiers/intern/MOD_none.c @@ -77,4 +77,5 @@ ModifierTypeInfo modifierType_None = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c index 8077f20d40a..22ff0a646d9 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.c +++ b/source/blender/modifiers/intern/MOD_particleinstance.c @@ -354,4 +354,5 @@ ModifierTypeInfo modifierType_ParticleInstance = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c index 7ab23cfd27b..4ee19f71976 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.c +++ b/source/blender/modifiers/intern/MOD_particlesystem.c @@ -242,4 +242,5 @@ ModifierTypeInfo modifierType_ParticleSystem = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index 49753aeb7e9..bbc17447b1c 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -907,4 +907,5 @@ ModifierTypeInfo modifierType_Screw = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c index 254814feb37..4368f1718ff 100644 --- a/source/blender/modifiers/intern/MOD_shapekey.c +++ b/source/blender/modifiers/intern/MOD_shapekey.c @@ -148,5 +148,6 @@ ModifierTypeInfo modifierType_ShapeKey = { /* dependsOnTime */ NULL, /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c index bbb426b83b1..02503a7ea30 100644 --- a/source/blender/modifiers/intern/MOD_shrinkwrap.c +++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c @@ -186,4 +186,5 @@ ModifierTypeInfo modifierType_Shrinkwrap = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c index db02edbefd8..c51a20364d6 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.c @@ -385,4 +385,5 @@ ModifierTypeInfo modifierType_SimpleDeform = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c index b6203bb3c1d..2e156d82ec6 100644 --- a/source/blender/modifiers/intern/MOD_smoke.c +++ b/source/blender/modifiers/intern/MOD_smoke.c @@ -189,4 +189,5 @@ ModifierTypeInfo modifierType_Smoke = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ foreachIDLink, + /* foreachTexLink */ NULL }; diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c index d34d6ac937c..94fc48f6280 100644 --- a/source/blender/modifiers/intern/MOD_smooth.c +++ b/source/blender/modifiers/intern/MOD_smooth.c @@ -270,4 +270,5 @@ ModifierTypeInfo modifierType_Smooth = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c index 25996286735..c475328676b 100644 --- a/source/blender/modifiers/intern/MOD_softbody.c +++ b/source/blender/modifiers/intern/MOD_softbody.c @@ -87,4 +87,5 @@ ModifierTypeInfo modifierType_Softbody = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index 7d5c6c7aa7c..a7ebd2ed575 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -230,8 +230,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, float (*vert_nors)[3]= NULL; - float const ofs_orig= - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset); - float const ofs_new= smd->offset - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset); + const float ofs_orig= - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset); + const float ofs_new= smd->offset - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset); + const float offset_fac_vg= smd->offset_fac_vg; + const float offset_fac_vg_inv= 1.0f - smd->offset_fac_vg; /* weights */ MDeformVert *dvert, *dv= NULL; @@ -398,8 +400,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, dv= dvert; for(i=0; i<numVerts; i++, mv++) { if(dv) { - if(defgrp_invert) scalar_short_vgroup = scalar_short * (1.0f - defvert_find_weight(dv, defgrp_index)); - else scalar_short_vgroup = scalar_short * defvert_find_weight(dv, defgrp_index); + if(defgrp_invert) scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index); + else scalar_short_vgroup = defvert_find_weight(dv, defgrp_index); + scalar_short_vgroup= (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) * scalar_short; dv++; } VECADDFAC(mv->co, mv->co, mv->no, scalar_short_vgroup); @@ -412,8 +415,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, dv= dvert; for(i=0; i<numVerts; i++, mv++) { if(dv) { - if(defgrp_invert) scalar_short_vgroup = scalar_short * (1.0f - defvert_find_weight(dv, defgrp_index)); - else scalar_short_vgroup = scalar_short * defvert_find_weight(dv, defgrp_index); + if(defgrp_invert) scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index); + else scalar_short_vgroup = defvert_find_weight(dv, defgrp_index); + scalar_short_vgroup= (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) * scalar_short; dv++; } VECADDFAC(mv->co, mv->co, mv->no, scalar_short_vgroup); @@ -473,15 +477,21 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* vertex group support */ if(dvert) { + float scalar; + dv= dvert; if(defgrp_invert) { for(i=0; i<numVerts; i++, dv++) { - vert_angles[i] *= (1.0f - defvert_find_weight(dv, defgrp_index)); + scalar= 1.0f - defvert_find_weight(dv, defgrp_index); + scalar= offset_fac_vg + (scalar * offset_fac_vg_inv); + vert_angles[i] *= scalar; } } else { for(i=0; i<numVerts; i++, dv++) { - vert_angles[i] *= defvert_find_weight(dv, defgrp_index); + scalar= defvert_find_weight(dv, defgrp_index); + scalar= offset_fac_vg + (scalar * offset_fac_vg_inv); + vert_angles[i] *= scalar; } } } @@ -748,5 +758,6 @@ ModifierTypeInfo modifierType_Solidify = { /* dependsOnTime */ NULL, /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c index 61b7de7183a..071e5ad7119 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.c +++ b/source/blender/modifiers/intern/MOD_subsurf.c @@ -152,4 +152,6 @@ ModifierTypeInfo modifierType_Subsurf = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; + diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c index 05ecee6ab29..4734685cf88 100644 --- a/source/blender/modifiers/intern/MOD_surface.c +++ b/source/blender/modifiers/intern/MOD_surface.c @@ -192,4 +192,5 @@ ModifierTypeInfo modifierType_Surface = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index 9e0d21e41fa..d3aaf762b01 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -434,4 +434,5 @@ ModifierTypeInfo modifierType_UVProject = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ foreachIDLink, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index a6406011d09..e6e9c347e6d 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -140,6 +140,11 @@ static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *u walk(userData, ob, (ID **)&wmd->map_object); } +static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void *userData) +{ + walk(userData, ob, md, "texture"); +} + static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UNUSED(scene), Object *UNUSED(ob), DagNode *obNode) { @@ -364,4 +369,5 @@ ModifierTypeInfo modifierType_Warp = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ foreachIDLink, + /* foreachTexLink */ foreachTexLink, }; diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index c80d73b1616..305f4383369 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -126,6 +126,12 @@ static void foreachIDLink(ModifierData *md, Object *ob, foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData); } +static void foreachTexLink(ModifierData *md, Object *ob, + TexWalkFunc walk, void *userData) +{ + walk(userData, ob, md, "texture"); +} + static void updateDepgraph(ModifierData *md, DagForest *forest, Scene *UNUSED(scene), Object *UNUSED(ob), @@ -466,4 +472,5 @@ ModifierTypeInfo modifierType_Wave = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ foreachIDLink, + /* foreachTexLink */ foreachTexLink, }; diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index 4b05a9c0c72..7310878f661 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -52,6 +52,9 @@ #include "WM_types.h" #include "MEM_guardedalloc.h" + +#include "BLI_ghash.h" + #include "BKE_report.h" #include "BKE_context.h" @@ -359,15 +362,18 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args) static PyObject *pyop_dir(PyObject *UNUSED(self)) { + GHashIterator *iter= WM_operatortype_iter(); PyObject *list= PyList_New(0), *name; - wmOperatorType *ot; - - for(ot= WM_operatortype_first(); ot; ot= ot->next) { + + for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + wmOperatorType *ot= BLI_ghashIterator_getValue(iter); + name= PyUnicode_FromString(ot->idname); PyList_Append(list, name); Py_DECREF(name); } - + BLI_ghashIterator_free(iter); + return list; } diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 3202b534557..54c12f568c7 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -1728,6 +1728,21 @@ static int Vector_setLength(VectorObject *self, PyObject *value) return 0; } +/* vector.length_squared */ +static PyObject *Vector_getLengthSquared(VectorObject *self, void *UNUSED(closure)) +{ + double dot = 0.0f; + int i; + + if(BaseMath_ReadCallback(self) == -1) + return NULL; + + for(i = 0; i < self->size; i++){ + dot += (double)(self->vec[i] * self->vec[i]); + } + return PyFloat_FromDouble(dot); +} + /* Get a new Vector according to the provided swizzle. This function has little error checking, as we are in control of the inputs: the closure is set by us in Vector_createSwizzleGetSeter. */ @@ -1851,6 +1866,7 @@ static PyGetSetDef Vector_getseters[] = { {(char *)"z", (getter)Vector_getAxis, (setter)Vector_setAxis, (char *)"Vector Z axis (3D Vectors only).\n\n:type: float", (void *)2}, {(char *)"w", (getter)Vector_getAxis, (setter)Vector_setAxis, (char *)"Vector W axis (4D Vectors only).\n\n:type: float", (void *)3}, {(char *)"length", (getter)Vector_getLength, (setter)Vector_setLength, (char *)"Vector Length.\n\n:type: float", NULL}, + {(char *)"length_squared", (getter)Vector_getLengthSquared, (setter)NULL, (char *)"Vector length squared (v.dot(v)).\n\n:type: float", NULL}, {(char *)"magnitude", (getter)Vector_getLength, (setter)Vector_setLength, (char *)"Vector Length.\n\n:type: float", NULL}, {(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, (char *)BaseMathObject_Wrapped_doc, NULL}, {(char *)"owner", (getter)BaseMathObject_getOwner, (setter)NULL, (char *)BaseMathObject_Owner_doc, NULL}, diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 42c3096dfc9..e1b8cefca4b 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -179,7 +179,7 @@ void WM_operator_free (struct wmOperator *op); void WM_operator_stack_clear(struct wmWindowManager *wm); struct wmOperatorType *WM_operatortype_find(const char *idnamem, int quiet); -struct wmOperatorType *WM_operatortype_first(void); +struct GHashIterator *WM_operatortype_iter(void); void WM_operatortype_append (void (*opfunc)(struct wmOperatorType*)); void WM_operatortype_append_ptr (void (*opfunc)(struct wmOperatorType*, void *), void *userdata); void WM_operatortype_append_macro_ptr (void (*opfunc)(struct wmOperatorType*, void *), void *userdata); @@ -222,6 +222,7 @@ wmOperator *WM_operator_last_redo(const struct bContext *C); #define WM_FILESEL_DIRECTORY (1 << 1) #define WM_FILESEL_FILENAME (1 << 2) #define WM_FILESEL_FILEPATH (1 << 3) +#define WM_FILESEL_FILES (1 << 4) /* operator as a python command (resultuing string must be free'd) */ @@ -230,6 +231,7 @@ void WM_operator_bl_idname(char *to, const char *from); void WM_operator_py_idname(char *to, const char *from); /* *************** menu types ******************** */ +void WM_menutype_init(void); struct MenuType *WM_menutype_find(const char *idname, int quiet); int WM_menutype_add(struct MenuType* mt); int WM_menutype_contains(struct MenuType* mt); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 697133bb163..cc3ae3ab753 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -423,8 +423,6 @@ typedef struct wmTimer { typedef struct wmOperatorType { - struct wmOperatorType *next, *prev; - const char *name; /* text for ui, undo */ const char *idname; /* unique identifier */ const char *description; /* tooltips and python docs */ diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 1d5cf1cdc53..9299b50103c 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -40,7 +40,11 @@ #include "GHOST_C-api.h" +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" #include "BLI_blenlib.h" +#include "BLI_ghash.h" #include "BKE_blender.h" #include "BKE_context.h" @@ -59,8 +63,6 @@ #include "wm_draw.h" #include "wm.h" -#include "MEM_guardedalloc.h" - #include "ED_screen.h" #ifdef WITH_PYTHON @@ -151,14 +153,14 @@ void WM_operator_stack_clear(wmWindowManager *wm) /* ****************************************** */ -static ListBase menutypes = {NULL, NULL}; /* global menutype list */ +static GHash *menutypes_hash= NULL; MenuType *WM_menutype_find(const char *idname, int quiet) { MenuType* mt; if (idname[0]) { - mt= BLI_findstring(&menutypes, idname, offsetof(MenuType, idname)); + mt= BLI_ghash_lookup(menutypes_hash, idname); if(mt) return mt; } @@ -171,35 +173,55 @@ MenuType *WM_menutype_find(const char *idname, int quiet) int WM_menutype_add(MenuType* mt) { - BLI_addtail(&menutypes, mt); + BLI_ghash_insert(menutypes_hash, (void *)mt->idname, mt); return 1; } /* inefficient but only used for tooltip code */ int WM_menutype_contains(MenuType* mt) { - return (mt != NULL && BLI_findindex(&menutypes, mt) != -1); + int found= FALSE; + + if(mt) { + GHashIterator *iter= BLI_ghashIterator_new(menutypes_hash); + + for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + if(mt == BLI_ghashIterator_getValue(iter)) { + found= TRUE; + break; + } + } + BLI_ghashIterator_free(iter); + } + + return found; } void WM_menutype_freelink(MenuType* mt) { - BLI_freelinkN(&menutypes, mt); + BLI_ghash_remove(menutypes_hash, mt->idname, NULL, (GHashValFreeFP)MEM_freeN); } -void WM_menutype_free(void) +/* called on initialize WM_init() */ +void WM_menutype_init(void) { - MenuType* mt= menutypes.first, *mt_next; + menutypes_hash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "menutypes_hash gh"); +} - while(mt) { - mt_next= mt->next; +void WM_menutype_free(void) +{ + GHashIterator *iter= BLI_ghashIterator_new(menutypes_hash); - if(mt->ext.free) + for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + MenuType *mt= BLI_ghashIterator_getValue(iter); + if(mt->ext.free) { mt->ext.free(mt->ext.data); - - WM_menutype_freelink(mt); - - mt= mt_next; + } } + BLI_ghashIterator_free(iter); + + BLI_ghash_free(menutypes_hash, NULL, (GHashValFreeFP)MEM_freeN); + menutypes_hash= NULL; } /* ****************************************** */ diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 6991b17abbd..3a4f7c14ba8 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -128,7 +128,8 @@ void WM_init(bContext *C, int argc, const char **argv) } GHOST_CreateSystemPaths(); wm_operatortype_init(); - + WM_menutype_init(); + set_free_windowmanager_cb(wm_close_and_free); /* library.c */ set_blender_test_break_cb(wm_window_testbreak); /* blender.c */ DAG_editors_update_cb(ED_render_id_flush_update); /* depsgraph.c */ diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 2fb0a1b2ab9..2dfe4d8ccdc 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -1009,7 +1009,8 @@ void WM_keyconfig_update(wmWindowManager *wm) addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid); /* diff */ - wm_keymap_diff_update(&U.user_keymaps, defaultmap, addonmap, km); + if(defaultmap) + wm_keymap_diff_update(&U.user_keymaps, defaultmap, addonmap, km); } } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 610a962ba62..105b2e8189a 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -58,6 +58,7 @@ #include "BLI_math.h" #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BLI_ghash.h" #include "BLO_readfile.h" @@ -100,7 +101,7 @@ #include "wm_subwindow.h" #include "wm_window.h" -static ListBase global_ops= {NULL, NULL}; +static GHash *global_ops_hash= NULL; /* ************ operator API, exported ********** */ @@ -113,7 +114,7 @@ wmOperatorType *WM_operatortype_find(const char *idname, int quiet) WM_operator_bl_idname(idname_bl, idname); if (idname_bl[0]) { - ot= (wmOperatorType *)BLI_findstring_ptr(&global_ops, idname_bl, offsetof(wmOperatorType, idname)); + ot= BLI_ghash_lookup(global_ops_hash, idname_bl); if(ot) { return ot; } @@ -125,9 +126,10 @@ wmOperatorType *WM_operatortype_find(const char *idname, int quiet) return NULL; } -wmOperatorType *WM_operatortype_first(void) +/* caller must free */ +GHashIterator *WM_operatortype_iter(void) { - return global_ops.first; + return BLI_ghashIterator_new(global_ops_hash); } /* all ops in 1 list (for time being... needs evaluation later) */ @@ -147,7 +149,8 @@ void WM_operatortype_append(void (*opfunc)(wmOperatorType*)) RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description:"(undocumented operator)"); // XXX All ops should have a description but for now allow them not to. RNA_def_struct_identifier(ot->srna, ot->idname); - BLI_addtail(&global_ops, ot); + + BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); } void WM_operatortype_append_ptr(void (*opfunc)(wmOperatorType*, void*), void *userdata) @@ -159,7 +162,8 @@ void WM_operatortype_append_ptr(void (*opfunc)(wmOperatorType*, void*), void *us opfunc(ot, userdata); RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description:"(undocumented operator)"); RNA_def_struct_identifier(ot->srna, ot->idname); - BLI_addtail(&global_ops, ot); + + BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); } /* ********************* macro operator ******************** */ @@ -351,7 +355,7 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *nam RNA_def_struct_ui_text(ot->srna, ot->name, ot->description); // XXX All ops should have a description but for now allow them not to. RNA_def_struct_identifier(ot->srna, ot->idname); - BLI_addtail(&global_ops, ot); + BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); return ot; } @@ -378,7 +382,7 @@ void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType*, void*), vo RNA_def_struct_ui_text(ot->srna, ot->name, ot->description); RNA_def_struct_identifier(ot->srna, ot->idname); - BLI_addtail(&global_ops, ot); + BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); } wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char *idname) @@ -426,14 +430,14 @@ int WM_operatortype_remove(const char *idname) if (ot==NULL) return 0; - BLI_remlink(&global_ops, ot); RNA_struct_free(&BLENDER_RNA, ot->srna); if(ot->macro.first) wm_operatortype_free_macro(ot); - - MEM_freeN(ot); + BLI_ghash_remove(global_ops_hash, (void *)ot->idname, NULL, NULL); + + MEM_freeN(ot); return 1; } @@ -807,6 +811,9 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, if(flag & WM_FILESEL_FILENAME) RNA_def_string_file_name(ot->srna, "filename", "", FILE_MAX, "File Name", "Name of the file"); + if(flag & WM_FILESEL_FILES) + RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", ""); + if (action == FILE_SAVE) { prop= RNA_def_boolean(ot->srna, "check_existing", 1, "Check Existing", "Check and warn on overwriting existing files"); RNA_def_property_flag(prop, PROP_HIDDEN); @@ -1311,9 +1318,10 @@ static void operator_call_cb(struct bContext *C, void *UNUSED(arg1), void *arg2) static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items) { - wmOperatorType *ot = WM_operatortype_first(); - - for(; ot; ot= ot->next) { + GHashIterator *iter= WM_operatortype_iter(); + + for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + wmOperatorType *ot= BLI_ghashIterator_getValue(iter); if((ot->flag & OPTYPE_INTERNAL) && (G.f & G_DEBUG) == 0) continue; @@ -1337,6 +1345,7 @@ static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), cons } } } + BLI_ghashIterator_free(iter); } static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *UNUSED(arg_op)) @@ -1742,14 +1751,12 @@ static void WM_OT_link_append(wmOperatorType *ot) ot->flag |= OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_LOADLIB, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_DIRECTORY|WM_FILESEL_FILENAME| WM_FILESEL_RELPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_LOADLIB, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_DIRECTORY|WM_FILESEL_FILENAME| WM_FILESEL_RELPATH|WM_FILESEL_FILES); RNA_def_boolean(ot->srna, "link", 1, "Link", "Link the objects or datablocks rather than appending"); RNA_def_boolean(ot->srna, "autoselect", 1, "Select", "Select the linked objects"); RNA_def_boolean(ot->srna, "active_layer", 1, "Active Layer", "Put the linked objects on the active layer"); RNA_def_boolean(ot->srna, "instance_groups", 1, "Instance Groups", "Create instances for each group as a DupliGroup"); - - RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", ""); } /* *************** recover last session **************** */ @@ -3457,26 +3464,31 @@ static void WM_OT_ndof_sensitivity_change(wmOperatorType *ot) RNA_def_boolean(ot->srna, "fast", 0, "Fast NDOF sensitivity change", "If true then sensitivity changes 50%, otherwise 10%"); } + +static void operatortype_ghash_free_cb(wmOperatorType *ot) +{ + if(ot->macro.first) + wm_operatortype_free_macro(ot); + + if(ot->ext.srna) /* python operator, allocs own string */ + MEM_freeN((void *)ot->idname); + + MEM_freeN(ot); +} + /* ******************************************************* */ /* called on initialize WM_exit() */ void wm_operatortype_free(void) { - wmOperatorType *ot; - - for(ot= global_ops.first; ot; ot= ot->next) { - if(ot->macro.first) - wm_operatortype_free_macro(ot); - - if(ot->ext.srna) /* python operator, allocs own string */ - MEM_freeN((void *)ot->idname); - } - - BLI_freelistN(&global_ops); + BLI_ghash_free(global_ops_hash, NULL, (GHashValFreeFP)operatortype_ghash_free_cb); + global_ops_hash= NULL; } /* called on initialize WM_init() */ void wm_operatortype_init(void) { + global_ops_hash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "wm_operatortype_init gh"); + WM_operatortype_append(WM_OT_window_duplicate); WM_operatortype_append(WM_OT_read_homefile); WM_operatortype_append(WM_OT_read_factory_settings); diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index a87001fb1b4..8ea1f2fdd0a 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -378,7 +378,8 @@ unsigned int index_to_framebuffer(int index) void WM_set_framebuffer_index_color(int index) { - cpack(index_to_framebuffer(index)); + const int col= index_to_framebuffer(index); + cpack(col); } int WM_framebuffer_to_index(unsigned int col) diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index ba73f4c0e92..89a9141f942 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -402,7 +402,7 @@ void RE_engine_report(struct RenderEngine *engine, int type, const char *msg) {} /* python */ struct wmOperatorType *WM_operatortype_find(const char *idname, int quiet){return (struct wmOperatorType *) NULL;} -struct wmOperatorType *WM_operatortype_first(){return (struct wmOperatorType *) NULL;} +struct GHashIterator *WM_operatortype_iter(){return (struct GHashIterator *) NULL;} struct wmOperatorType *WM_operatortype_exists(const char *idname){return (struct wmOperatorType *) NULL;} struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname){return (struct wmOperatorTypeMacro *) NULL;} int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, int context, struct PointerRNA *properties, struct ReportList *reports){return 0;} diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 49f00e39110..3f09eee013e 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -254,8 +254,12 @@ void KX_LightObject::BindShadowBuffer(RAS_IRasterizer *ras, KX_Camera *cam, MT_T cam->NodeUpdateGS(0); /* setup rasterizer transformations */ + /* SetViewMatrix may use stereomode which we temporarily disable here */ + RAS_IRasterizer::StereoMode stereomode = ras->GetStereoMode(); + ras->SetStereoMode(RAS_IRasterizer::RAS_STEREO_NOSTEREO); ras->SetProjectionMatrix(projectionmat); ras->SetViewMatrix(modelviewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), cam->GetCameraData()->m_perspective); + ras->SetStereoMode(stereomode); } void KX_LightObject::UnbindShadowBuffer(RAS_IRasterizer *ras) |