diff options
Diffstat (limited to 'release/scripts')
93 files changed, 2693 insertions, 4828 deletions
diff --git a/release/scripts/io/engine_render_pov.py b/release/scripts/io/engine_render_pov.py deleted file mode 100644 index 9cda4375ecc..00000000000 --- a/release/scripts/io/engine_render_pov.py +++ /dev/null @@ -1,1001 +0,0 @@ -# ##### BEGIN GPL LICENSE BLOCK ##### -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# ##### END GPL LICENSE BLOCK ##### - -# <pep8 compliant> - -import bpy - -from math import atan, pi, degrees -import subprocess -import os -import sys -import time - -import platform as pltfrm - -if pltfrm.architecture()[0] == '64bit': - bitness = 64 -else: - bitness = 32 - - -def write_pov(filename, scene=None, info_callback=None): - file = open(filename, 'w') - - # Only for testing - if not scene: - scene = bpy.data.scenes[0] - - render = scene.render - world = scene.world - - def uniqueName(name, nameSeq): - - if name not in nameSeq: - return name - - name_orig = name - i = 1 - while name in nameSeq: - name = '%s_%.3d' % (name_orig, i) - i += 1 - - return name - - def writeMatrix(matrix): - file.write('\tmatrix <%.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f>\n' %\ - (matrix[0][0], matrix[0][1], matrix[0][2], matrix[1][0], matrix[1][1], matrix[1][2], matrix[2][0], matrix[2][1], matrix[2][2], matrix[3][0], matrix[3][1], matrix[3][2])) - - def writeObjectMaterial(material): - if material and material.transparency_method == 'RAYTRACE': - file.write('\tinterior { ior %.6f }\n' % material.raytrace_transparency.ior) - - # Other interior args - # fade_distance 2 - # fade_power [Value] - # fade_color - - # dispersion - # dispersion_samples - - materialNames = {} - DEF_MAT_NAME = 'Default' - - def writeMaterial(material): - # Assumes only called once on each material - - if material: - name_orig = material.name - else: - name_orig = DEF_MAT_NAME - - name = materialNames[name_orig] = uniqueName(bpy.utils.clean_name(name_orig), materialNames) - - file.write('#declare %s = finish {\n' % name) - - if material: - file.write('\tdiffuse %.3g\n' % material.diffuse_intensity) - file.write('\tspecular %.3g\n' % material.specular_intensity) - - file.write('\tambient %.3g\n' % material.ambient) - #file.write('\tambient rgb <%.3g, %.3g, %.3g>\n' % tuple([c*material.ambient for c in world.ambient_color])) # povray blends the global value - - # map hardness between 0.0 and 1.0 - roughness = ((1.0 - ((material.specular_hardness - 1.0) / 510.0))) - # scale from 0.0 to 0.1 - roughness *= 0.1 - # add a small value because 0.0 is invalid - roughness += (1 / 511.0) - - file.write('\troughness %.3g\n' % roughness) - - # 'phong 70.0 ' - - if material.raytrace_mirror.enabled: - raytrace_mirror = material.raytrace_mirror - if raytrace_mirror.reflect_factor: - file.write('\treflection {\n') - file.write('\t\trgb <%.3g, %.3g, %.3g>' % tuple(material.mirror_color)) - file.write('\t\tfresnel 1 falloff %.3g exponent %.3g metallic %.3g} ' % (raytrace_mirror.fresnel, raytrace_mirror.fresnel_factor, raytrace_mirror.reflect_factor)) - - else: - file.write('\tdiffuse 0.8\n') - file.write('\tspecular 0.2\n') - - - # This is written into the object - ''' - if material and material.transparency_method=='RAYTRACE': - 'interior { ior %.3g} ' % material.raytrace_transparency.ior - ''' - - #file.write('\t\t\tcrand 1.0\n') # Sand granyness - #file.write('\t\t\tmetallic %.6f\n' % material.spec) - #file.write('\t\t\tphong %.6f\n' % material.spec) - #file.write('\t\t\tphong_size %.6f\n' % material.spec) - #file.write('\t\t\tbrilliance %.6f ' % (material.specular_hardness/256.0) # Like hardness - - file.write('}\n') - - def exportCamera(): - camera = scene.camera - matrix = camera.matrix_world - - # compute resolution - Qsize = float(render.resolution_x) / float(render.resolution_y) - - file.write('camera {\n') - file.write('\tlocation <0, 0, 0>\n') - file.write('\tlook_at <0, 0, -1>\n') - file.write('\tright <%s, 0, 0>\n' % - Qsize) - file.write('\tup <0, 1, 0>\n') - file.write('\tangle %f \n' % (360.0 * atan(16.0 / camera.data.lens) / pi)) - - file.write('\trotate <%.6f, %.6f, %.6f>\n' % tuple([degrees(e) for e in matrix.rotation_part().to_euler()])) - file.write('\ttranslate <%.6f, %.6f, %.6f>\n' % (matrix[3][0], matrix[3][1], matrix[3][2])) - file.write('}\n') - - def exportLamps(lamps): - # Get all lamps - for ob in lamps: - lamp = ob.data - - matrix = ob.matrix_world - - color = tuple([c * lamp.energy for c in lamp.color]) # Colour is modified by energy - - file.write('light_source {\n') - file.write('\t< 0,0,0 >\n') - file.write('\tcolor rgb<%.3g, %.3g, %.3g>\n' % color) - - if lamp.type == 'POINT': # Point Lamp - pass - elif lamp.type == 'SPOT': # Spot - file.write('\tspotlight\n') - - # Falloff is the main radius from the centre line - file.write('\tfalloff %.2f\n' % (degrees(lamp.spot_size) / 2.0)) # 1 TO 179 FOR BOTH - file.write('\tradius %.6f\n' % ((degrees(lamp.spot_size) / 2.0) * (1.0 - lamp.spot_blend))) - - # Blender does not have a tightness equivilent, 0 is most like blender default. - file.write('\ttightness 0\n') # 0:10f - - file.write('\tpoint_at <0, 0, -1>\n') - elif lamp.type == 'SUN': - file.write('\tparallel\n') - file.write('\tpoint_at <0, 0, -1>\n') # *must* be after 'parallel' - - elif lamp.type == 'AREA': - - size_x = lamp.size - samples_x = lamp.shadow_ray_samples_x - if lamp.shape == 'SQUARE': - size_y = size_x - samples_y = samples_x - else: - size_y = lamp.size_y - samples_y = lamp.shadow_ray_samples_y - - file.write('\tarea_light <%d,0,0>,<0,0,%d> %d, %d\n' % (size_x, size_y, samples_x, samples_y)) - if lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED': - if lamp.jitter: - file.write('\tjitter\n') - else: - file.write('\tadaptive 1\n') - file.write('\tjitter\n') - - if lamp.shadow_method == 'NOSHADOW': - file.write('\tshadowless\n') - - file.write('\tfade_distance %.6f\n' % lamp.distance) - file.write('\tfade_power %d\n' % 1) # Could use blenders lamp quad? - writeMatrix(matrix) - - file.write('}\n') - - def exportMeta(metas): - - # TODO - blenders 'motherball' naming is not supported. - - for ob in metas: - meta = ob.data - - file.write('blob {\n') - file.write('\t\tthreshold %.4g\n' % meta.threshold) - - try: - material = meta.materials[0] # lame! - blender cant do enything else. - except: - material = None - - for elem in meta.elements: - - if elem.type not in ('BALL', 'ELLIPSOID'): - continue # Not supported - - loc = elem.location - - stiffness = elem.stiffness - if elem.negative: - stiffness = - stiffness - - if elem.type == 'BALL': - - file.write('\tsphere { <%.6g, %.6g, %.6g>, %.4g, %.4g ' % (loc.x, loc.y, loc.z, elem.radius, stiffness)) - - # After this wecould do something simple like... - # "pigment {Blue} }" - # except we'll write the color - - elif elem.type == 'ELLIPSOID': - # location is modified by scale - file.write('\tsphere { <%.6g, %.6g, %.6g>, %.4g, %.4g ' % (loc.x / elem.size_x, loc.y / elem.size_y, loc.z / elem.size_z, elem.radius, stiffness)) - file.write('scale <%.6g, %.6g, %.6g> ' % (elem.size_x, elem.size_y, elem.size_z)) - - if material: - diffuse_color = material.diffuse_color - - if material.transparency and material.transparency_method == 'RAYTRACE': - trans = 1.0 - material.raytrace_transparency.filter - else: - trans = 0.0 - - file.write('pigment {rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>} finish {%s} }\n' % \ - (diffuse_color[0], diffuse_color[1], diffuse_color[2], 1.0 - material.alpha, trans, materialNames[material.name])) - - else: - file.write('pigment {rgb<1 1 1>} finish {%s} }\n' % DEF_MAT_NAME) # Write the finish last. - - writeObjectMaterial(material) - - writeMatrix(ob.matrix_world) - - file.write('}\n') - - def exportMeshs(scene, sel): - - ob_num = 0 - - for ob in sel: - ob_num += 1 - - if ob.type in ('LAMP', 'CAMERA', 'EMPTY', 'META', 'ARMATURE'): - continue - - me = ob.data - me_materials = me.materials - - me = ob.create_mesh(scene, True, 'RENDER') - - if not me: - continue - - if info_callback: - info_callback('Object %2.d of %2.d (%s)' % (ob_num, len(sel), ob.name)) - - #if ob.type!='MESH': - # continue - # me = ob.data - - matrix = ob.matrix_world - try: - uv_layer = me.active_uv_texture.data - except: - uv_layer = None - - try: - vcol_layer = me.active_vertex_color.data - except: - vcol_layer = None - - faces_verts = [f.verts for f in me.faces] - faces_normals = [tuple(f.normal) for f in me.faces] - verts_normals = [tuple(v.normal) for v in me.verts] - - # quads incur an extra face - quadCount = len([f for f in faces_verts if len(f) == 4]) - - file.write('mesh2 {\n') - file.write('\tvertex_vectors {\n') - file.write('\t\t%s' % (len(me.verts))) # vert count - for v in me.verts: - file.write(',\n\t\t<%.6f, %.6f, %.6f>' % tuple(v.co)) # vert count - file.write('\n }\n') - - - # Build unique Normal list - uniqueNormals = {} - for fi, f in enumerate(me.faces): - fv = faces_verts[fi] - # [-1] is a dummy index, use a list so we can modify in place - if f.smooth: # Use vertex normals - for v in fv: - key = verts_normals[v] - uniqueNormals[key] = [-1] - else: # Use face normal - key = faces_normals[fi] - uniqueNormals[key] = [-1] - - file.write('\tnormal_vectors {\n') - file.write('\t\t%d' % len(uniqueNormals)) # vert count - idx = 0 - for no, index in uniqueNormals.items(): - file.write(',\n\t\t<%.6f, %.6f, %.6f>' % no) # vert count - index[0] = idx - idx += 1 - file.write('\n }\n') - - - # Vertex colours - vertCols = {} # Use for material colours also. - - if uv_layer: - # Generate unique UV's - uniqueUVs = {} - - for fi, uv in enumerate(uv_layer): - - if len(faces_verts[fi]) == 4: - uvs = uv.uv1, uv.uv2, uv.uv3, uv.uv4 - else: - uvs = uv.uv1, uv.uv2, uv.uv3 - - for uv in uvs: - uniqueUVs[tuple(uv)] = [-1] - - file.write('\tuv_vectors {\n') - #print unique_uvs - file.write('\t\t%s' % (len(uniqueUVs))) # vert count - idx = 0 - for uv, index in uniqueUVs.items(): - file.write(',\n\t\t<%.6f, %.6f>' % uv) - index[0] = idx - idx += 1 - ''' - else: - # Just add 1 dummy vector, no real UV's - file.write('\t\t1') # vert count - file.write(',\n\t\t<0.0, 0.0>') - ''' - file.write('\n }\n') - - - if me.vertex_colors: - - for fi, f in enumerate(me.faces): - material_index = f.material_index - material = me_materials[material_index] - - if material and material.vertex_color_paint: - - col = vcol_layer[fi] - - if len(faces_verts[fi]) == 4: - cols = col.color1, col.color2, col.color3, col.color4 - else: - cols = col.color1, col.color2, col.color3 - - for col in cols: - key = col[0], col[1], col[2], material_index # Material index! - vertCols[key] = [-1] - - else: - if material: - diffuse_color = tuple(material.diffuse_color) - key = diffuse_color[0], diffuse_color[1], diffuse_color[2], material_index - vertCols[key] = [-1] - - - else: - # No vertex colours, so write material colours as vertex colours - for i, material in enumerate(me_materials): - - if material: - diffuse_color = tuple(material.diffuse_color) - key = diffuse_color[0], diffuse_color[1], diffuse_color[2], i # i == f.mat - vertCols[key] = [-1] - - - # Vert Colours - file.write('\ttexture_list {\n') - file.write('\t\t%s' % (len(vertCols))) # vert count - idx = 0 - for col, index in vertCols.items(): - - if me_materials: - material = me_materials[col[3]] - material_finish = materialNames[material.name] - - if material.transparency and material.transparency_method == 'RAYTRACE': - trans = 1.0 - material.raytrace_transparency.filter - else: - trans = 0.0 - - else: - material_finish = DEF_MAT_NAME # not working properly, - trans = 0.0 - - #print material.apl - file.write(',\n\t\ttexture { pigment {rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>} finish {%s}}' % - (col[0], col[1], col[2], 1.0 - material.alpha, trans, material_finish)) - - index[0] = idx - idx += 1 - - file.write('\n }\n') - - # Face indicies - file.write('\tface_indices {\n') - file.write('\t\t%d' % (len(me.faces) + quadCount)) # faces count - for fi, f in enumerate(me.faces): - fv = faces_verts[fi] - material_index = f.material_index - if len(fv) == 4: - indicies = (0, 1, 2), (0, 2, 3) - else: - indicies = ((0, 1, 2),) - - if vcol_layer: - col = vcol_layer[fi] - - if len(fv) == 4: - cols = col.color1, col.color2, col.color3, col.color4 - else: - cols = col.color1, col.color2, col.color3 - - - if not me_materials or me_materials[material_index] == None: # No materials - for i1, i2, i3 in indicies: - file.write(',\n\t\t<%d,%d,%d>' % (fv[i1], fv[i2], fv[i3])) # vert count - else: - material = me_materials[material_index] - for i1, i2, i3 in indicies: - if me.vertex_colors and material.vertex_color_paint: - # Colour per vertex - vertex colour - - col1 = cols[i1] - col2 = cols[i2] - col3 = cols[i3] - - ci1 = vertCols[col1[0], col1[1], col1[2], material_index][0] - ci2 = vertCols[col2[0], col2[1], col2[2], material_index][0] - ci3 = vertCols[col3[0], col3[1], col3[2], material_index][0] - else: - # Colour per material - flat material colour - diffuse_color = material.diffuse_color - ci1 = ci2 = ci3 = vertCols[diffuse_color[0], diffuse_color[1], diffuse_color[2], f.material_index][0] - - file.write(',\n\t\t<%d,%d,%d>, %d,%d,%d' % (fv[i1], fv[i2], fv[i3], ci1, ci2, ci3)) # vert count - - - file.write('\n }\n') - - # normal_indices indicies - file.write('\tnormal_indices {\n') - file.write('\t\t%d' % (len(me.faces) + quadCount)) # faces count - for fi, fv in enumerate(faces_verts): - - if len(fv) == 4: - indicies = (0, 1, 2), (0, 2, 3) - else: - indicies = ((0, 1, 2),) - - for i1, i2, i3 in indicies: - if f.smooth: - file.write(',\n\t\t<%d,%d,%d>' %\ - (uniqueNormals[verts_normals[fv[i1]]][0],\ - uniqueNormals[verts_normals[fv[i2]]][0],\ - uniqueNormals[verts_normals[fv[i3]]][0])) # vert count - else: - idx = uniqueNormals[faces_normals[fi]][0] - file.write(',\n\t\t<%d,%d,%d>' % (idx, idx, idx)) # vert count - - file.write('\n }\n') - - if uv_layer: - file.write('\tuv_indices {\n') - file.write('\t\t%d' % (len(me.faces) + quadCount)) # faces count - for fi, fv in enumerate(faces_verts): - - if len(fv) == 4: - indicies = (0, 1, 2), (0, 2, 3) - else: - indicies = ((0, 1, 2),) - - uv = uv_layer[fi] - if len(faces_verts[fi]) == 4: - uvs = tuple(uv.uv1), tuple(uv.uv2), tuple(uv.uv3), tuple(uv.uv4) - else: - uvs = tuple(uv.uv1), tuple(uv.uv2), tuple(uv.uv3) - - for i1, i2, i3 in indicies: - file.write(',\n\t\t<%d,%d,%d>' %\ - (uniqueUVs[uvs[i1]][0],\ - uniqueUVs[uvs[i2]][0],\ - uniqueUVs[uvs[i2]][0])) # vert count - file.write('\n }\n') - - if me.materials: - material = me.materials[0] # dodgy - writeObjectMaterial(material) - - writeMatrix(matrix) - file.write('}\n') - - bpy.data.meshes.remove(me) - - def exportWorld(world): - if not world: - return - - mist = world.mist - - if mist.use_mist: - file.write('fog {\n') - file.write('\tdistance %.6f\n' % mist.depth) - file.write('\tcolor rgbt<%.3g, %.3g, %.3g, %.3g>\n' % (tuple(world.horizon_color) + (1 - mist.intensity,))) - #file.write('\tfog_offset %.6f\n' % mist.start) - #file.write('\tfog_alt 5\n') - #file.write('\tturbulence 0.2\n') - #file.write('\tturb_depth 0.3\n') - file.write('\tfog_type 1\n') - file.write('}\n') - - def exportGlobalSettings(scene): - - file.write('global_settings {\n') - - if scene.pov_radio_enable: - file.write('\tradiosity {\n') - file.write("\t\tadc_bailout %.4g\n" % scene.pov_radio_adc_bailout) - file.write("\t\talways_sample %d\n" % scene.pov_radio_always_sample) - file.write("\t\tbrightness %.4g\n" % scene.pov_radio_brightness) - file.write("\t\tcount %d\n" % scene.pov_radio_count) - file.write("\t\terror_bound %.4g\n" % scene.pov_radio_error_bound) - file.write("\t\tgray_threshold %.4g\n" % scene.pov_radio_gray_threshold) - file.write("\t\tlow_error_factor %.4g\n" % scene.pov_radio_low_error_factor) - file.write("\t\tmedia %d\n" % scene.pov_radio_media) - file.write("\t\tminimum_reuse %.4g\n" % scene.pov_radio_minimum_reuse) - file.write("\t\tnearest_count %d\n" % scene.pov_radio_nearest_count) - file.write("\t\tnormal %d\n" % scene.pov_radio_normal) - file.write("\t\trecursion_limit %d\n" % scene.pov_radio_recursion_limit) - file.write('\t}\n') - - if world: - file.write("\tambient_light rgb<%.3g, %.3g, %.3g>\n" % tuple(world.ambient_color)) - - file.write('}\n') - - - # Convert all materials to strings we can access directly per vertex. - writeMaterial(None) # default material - - for material in bpy.data.materials: - writeMaterial(material) - - exportCamera() - #exportMaterials() - sel = scene.objects - exportLamps([l for l in sel if l.type == 'LAMP']) - exportMeta([l for l in sel if l.type == 'META']) - exportMeshs(scene, sel) - exportWorld(scene.world) - exportGlobalSettings(scene) - - file.close() - - -def write_pov_ini(filename_ini, filename_pov, filename_image): - scene = bpy.data.scenes[0] - render = scene.render - - x = int(render.resolution_x * render.resolution_percentage * 0.01) - y = int(render.resolution_y * render.resolution_percentage * 0.01) - - file = open(filename_ini, 'w') - - file.write('Input_File_Name="%s"\n' % filename_pov) - file.write('Output_File_Name="%s"\n' % filename_image) - - file.write('Width=%d\n' % x) - file.write('Height=%d\n' % y) - - # Needed for border render. - ''' - file.write('Start_Column=%d\n' % part.x) - file.write('End_Column=%d\n' % (part.x+part.w)) - - file.write('Start_Row=%d\n' % (part.y)) - file.write('End_Row=%d\n' % (part.y+part.h)) - ''' - - file.write('Display=0\n') - file.write('Pause_When_Done=0\n') - file.write('Output_File_Type=T\n') # TGA, best progressive loading - file.write('Output_Alpha=1\n') - - if render.render_antialiasing: - aa_mapping = {'5': 2, '8': 3, '11': 4, '16': 5} # method 1 assumed - file.write('Antialias=1\n') - file.write('Antialias_Depth=%d\n' % aa_mapping[render.antialiasing_samples]) - else: - file.write('Antialias=0\n') - - file.close() - -# Radiosity panel, use in the scene for now. -FloatProperty = bpy.types.Scene.FloatProperty -IntProperty = bpy.types.Scene.IntProperty -BoolProperty = bpy.types.Scene.BoolProperty - -# Not a real pov option, just to know if we should write -BoolProperty(attr="pov_radio_enable", - name="Enable Radiosity", - description="Enable povrays radiosity calculation", - default=False) -BoolProperty(attr="pov_radio_display_advanced", - name="Advanced Options", - description="Show advanced options", - default=False) - -# Real pov options -FloatProperty(attr="pov_radio_adc_bailout", - name="ADC Bailout", - description="The adc_bailout for radiosity rays. Use adc_bailout = 0.01 / brightest_ambient_object for good results", - min=0.0, max=1000.0, soft_min=0.0, soft_max=1.0, default=0.01) - -BoolProperty(attr="pov_radio_always_sample", - name="Always Sample", - description="Only use the data from the pretrace step and not gather any new samples during the final radiosity pass", - default=True) - -FloatProperty(attr="pov_radio_brightness", - name="Brightness", - description="Amount objects are brightened before being returned upwards to the rest of the system", - min=0.0, max=1000.0, soft_min=0.0, soft_max=10.0, default=1.0) - -IntProperty(attr="pov_radio_count", - name="Ray Count", - description="Number of rays that are sent out whenever a new radiosity value has to be calculated", - min=1, max=1600, default=35) - -FloatProperty(attr="pov_radio_error_bound", - name="Error Bound", - description="One of the two main speed/quality tuning values, lower values are more accurate", - min=0.0, max=1000.0, soft_min=0.1, soft_max=10.0, default=1.8) - -FloatProperty(attr="pov_radio_gray_threshold", - name="Gray Threshold", - description="One of the two main speed/quality tuning values, lower values are more accurate", - min=0.0, max=1.0, soft_min=0, soft_max=1, default=0.0) - -FloatProperty(attr="pov_radio_low_error_factor", - name="Low Error Factor", - description="If you calculate just enough samples, but no more, you will get an image which has slightly blotchy lighting", - min=0.0, max=1.0, soft_min=0.0, soft_max=1.0, default=0.5) - -# max_sample - not available yet -BoolProperty(attr="pov_radio_media", - name="Media", - description="Radiosity estimation can be affected by media", - default=False) - -FloatProperty(attr="pov_radio_minimum_reuse", - name="Minimum Reuse", - description="Fraction of the screen width which sets the minimum radius of reuse for each sample point (At values higher than 2% expect errors)", - min=0.0, max=1.0, soft_min=0.1, soft_max=0.1, default=0.015) - -IntProperty(attr="pov_radio_nearest_count", - name="Nearest Count", - description="Number of old ambient values blended together to create a new interpolated value", - min=1, max=20, default=5) - -BoolProperty(attr="pov_radio_normal", - name="Normals", - description="Radiosity estimation can be affected by normals", - default=False) - -IntProperty(attr="pov_radio_recursion_limit", - name="Recursion Limit", - description="how many recursion levels are used to calculate the diffuse inter-reflection", - min=1, max=20, default=3) - - -class PovrayRender(bpy.types.RenderEngine): - bl_idname = 'POVRAY_RENDER' - bl_label = "Povray" - DELAY = 0.02 - - def _export(self, scene): - import tempfile - - self._temp_file_in = tempfile.mktemp(suffix='.pov') - self._temp_file_out = tempfile.mktemp(suffix='.tga') - self._temp_file_ini = tempfile.mktemp(suffix='.ini') - ''' - self._temp_file_in = '/test.pov' - self._temp_file_out = '/test.tga' - self._temp_file_ini = '/test.ini' - ''' - - def info_callback(txt): - self.update_stats("", "POVRAY: " + txt) - - write_pov(self._temp_file_in, scene, info_callback) - - def _render(self): - - try: - os.remove(self._temp_file_out) # so as not to load the old file - except: - pass - - write_pov_ini(self._temp_file_ini, self._temp_file_in, self._temp_file_out) - - print ("***-STARTING-***") - - pov_binary = "povray" - - if sys.platform == 'win32': - import winreg - regKey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'Software\\POV-Ray\\v3.6\\Windows') - - if bitness == 64: - pov_binary = winreg.QueryValueEx(regKey, 'Home')[0] + '\\bin\\pvengine64' - else: - pov_binary = winreg.QueryValueEx(regKey, 'Home')[0] + '\\bin\\pvengine' - - if 1: - # TODO, when povray isnt found this gives a cryptic error, would be nice to be able to detect if it exists - try: - self._process = subprocess.Popen([pov_binary, self._temp_file_ini]) # stdout=subprocess.PIPE, stderr=subprocess.PIPE - except OSError: - # TODO, report api - print("POVRAY: could not execute '%s', possibly povray isn't installed" % pov_binary) - import traceback - traceback.print_exc() - print ("***-DONE-***") - return False - - else: - # This works too but means we have to wait until its done - os.system('%s %s' % (pov_binary, self._temp_file_ini)) - - print ("***-DONE-***") - return True - - def _cleanup(self): - for f in (self._temp_file_in, self._temp_file_ini, self._temp_file_out): - try: - os.remove(f) - except: - pass - - self.update_stats("", "") - - def render(self, scene): - - self.update_stats("", "POVRAY: Exporting data from Blender") - self._export(scene) - self.update_stats("", "POVRAY: Parsing File") - - if not self._render(): - self.update_stats("", "POVRAY: Not found") - return - - r = scene.render - - # compute resolution - x = int(r.resolution_x * r.resolution_percentage * 0.01) - y = int(r.resolution_y * r.resolution_percentage * 0.01) - - # Wait for the file to be created - while not os.path.exists(self._temp_file_out): - if self.test_break(): - try: - self._process.terminate() - except: - pass - break - - if self._process.poll() != None: - self.update_stats("", "POVRAY: Failed") - break - - time.sleep(self.DELAY) - - if os.path.exists(self._temp_file_out): - - self.update_stats("", "POVRAY: Rendering") - - prev_size = -1 - - def update_image(): - result = self.begin_result(0, 0, x, y) - lay = result.layers[0] - # possible the image wont load early on. - try: - lay.load_from_file(self._temp_file_out) - except: - pass - self.end_result(result) - - # Update while povray renders - while True: - - # test if povray exists - if self._process.poll() is not None: - update_image() - break - - # user exit - if self.test_break(): - try: - self._process.terminate() - except: - pass - - break - - # Would be nice to redirect the output - # stdout_value, stderr_value = self._process.communicate() # locks - - - # check if the file updated - new_size = os.path.getsize(self._temp_file_out) - - if new_size != prev_size: - update_image() - prev_size = new_size - - time.sleep(self.DELAY) - - self._cleanup() - - -# Use some of the existing buttons. -import properties_render -properties_render.RENDER_PT_render.COMPAT_ENGINES.add('POVRAY_RENDER') -properties_render.RENDER_PT_dimensions.COMPAT_ENGINES.add('POVRAY_RENDER') -properties_render.RENDER_PT_antialiasing.COMPAT_ENGINES.add('POVRAY_RENDER') -properties_render.RENDER_PT_output.COMPAT_ENGINES.add('POVRAY_RENDER') -del properties_render - -# Use only a subset of the world panels -import properties_world -properties_world.WORLD_PT_preview.COMPAT_ENGINES.add('POVRAY_RENDER') -properties_world.WORLD_PT_context_world.COMPAT_ENGINES.add('POVRAY_RENDER') -properties_world.WORLD_PT_world.COMPAT_ENGINES.add('POVRAY_RENDER') -properties_world.WORLD_PT_mist.COMPAT_ENGINES.add('POVRAY_RENDER') -del properties_world - -# Example of wrapping every class 'as is' -import properties_material -for member in dir(properties_material): - subclass = getattr(properties_material, member) - try: - subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except: - pass -del properties_material -import properties_data_mesh -for member in dir(properties_data_mesh): - subclass = getattr(properties_data_mesh, member) - try: - subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except: - pass -del properties_data_mesh -import properties_texture -for member in dir(properties_texture): - subclass = getattr(properties_texture, member) - try: - subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except: - pass -del properties_texture -import properties_data_camera -for member in dir(properties_data_camera): - subclass = getattr(properties_data_camera, member) - try: - subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except: - pass -del properties_data_camera - - -class RenderButtonsPanel(bpy.types.Panel): - bl_space_type = 'PROPERTIES' - bl_region_type = 'WINDOW' - bl_context = "render" - # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here - - def poll(self, context): - rd = context.scene.render - return (rd.use_game_engine == False) and (rd.engine in self.COMPAT_ENGINES) - - -class RENDER_PT_povray_radiosity(RenderButtonsPanel): - bl_label = "Radiosity" - COMPAT_ENGINES = {'POVRAY_RENDER'} - - def draw_header(self, context): - scene = context.scene - - self.layout.prop(scene, "pov_radio_enable", text="") - - def draw(self, context): - layout = self.layout - - scene = context.scene - rd = scene.render - - layout.active = scene.pov_radio_enable - - split = layout.split() - - col = split.column() - col.prop(scene, "pov_radio_count", text="Rays") - col.prop(scene, "pov_radio_recursion_limit", text="Recursions") - col = split.column() - col.prop(scene, "pov_radio_error_bound", text="Error") - - layout.prop(scene, "pov_radio_display_advanced") - - if scene.pov_radio_display_advanced: - split = layout.split() - - col = split.column() - col.prop(scene, "pov_radio_adc_bailout", slider=True) - col.prop(scene, "pov_radio_gray_threshold", slider=True) - col.prop(scene, "pov_radio_low_error_factor", slider=True) - - col = split.column() - col.prop(scene, "pov_radio_brightness") - col.prop(scene, "pov_radio_minimum_reuse", text="Min Reuse") - col.prop(scene, "pov_radio_nearest_count") - - split = layout.split() - - col = split.column() - col.label(text="Estimation Influence:") - col.prop(scene, "pov_radio_media") - col.prop(scene, "pov_radio_normal") - - col = split.column() - col.prop(scene, "pov_radio_always_sample") - - -classes = [ - PovrayRender, - RENDER_PT_povray_radiosity] - - -def register(): - register = bpy.types.register - for cls in classes: - register(cls) - - -def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) - -if __name__ == "__main__": - register() diff --git a/release/scripts/io/export_3ds.py b/release/scripts/io/export_3ds.py index 910d462a9f9..2a8b43c4e84 100644 --- a/release/scripts/io/export_3ds.py +++ b/release/scripts/io/export_3ds.py @@ -922,7 +922,7 @@ def make_kf_obj_node(obj, name_to_id): """ # import BPyMessages -def save_3ds(filename, context): +def write(filename, context): '''Save the Blender scene to a 3ds file.''' # Time the export @@ -1107,12 +1107,7 @@ def save_3ds(filename, context): #primary.dump() -# if __name__=='__main__': -# if struct: -# Blender.Window.FileSelector(save_3ds, "Export 3DS", Blender.sys.makename(ext='.3ds')) -# else: -# Blender.Draw.PupMenu("Error%t|This script requires a full python installation") -# # save_3ds('/test_b.3ds') +# # write('/test_b.3ds') from bpy.props import * class Export3DS(bpy.types.Operator): '''Export to 3DS file format (.3ds)''' @@ -1127,7 +1122,10 @@ class Export3DS(bpy.types.Operator): check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'}) def execute(self, context): - save_3ds(self.properties.filepath, context) + filepath = self.properties.filepath + filepath = bpy.path.ensure_ext(filepath, ".3ds") + + write(filepath, context) return {'FINISHED'} def invoke(self, context, event): @@ -1135,10 +1133,10 @@ class Export3DS(bpy.types.Operator): wm.add_fileselect(self) return {'RUNNING_MODAL'} - def poll(self, context): # Poll isnt working yet + @classmethod + def poll(cls, context): # Poll isnt working yet return context.active_object != None - # Add to a menu def menu_func(self, context): default_path = os.path.splitext(bpy.data.filepath)[0] + ".3ds" @@ -1146,11 +1144,9 @@ def menu_func(self, context): def register(): - bpy.types.register(Export3DS) bpy.types.INFO_MT_file_export.append(menu_func) def unregister(): - bpy.types.unregister(Export3DS) bpy.types.INFO_MT_file_export.remove(menu_func) if __name__ == "__main__": diff --git a/release/scripts/io/export_fbx.py b/release/scripts/io/export_fbx.py index 72b03a110bd..5c2e0cb5f95 100644 --- a/release/scripts/io/export_fbx.py +++ b/release/scripts/io/export_fbx.py @@ -75,7 +75,7 @@ def copy_images(dest_dir, textures): image_paths = set() for tex in textures: - image_paths.add(bpy.utils.expandpath(tex.filepath)) + image_paths.add(bpy.path.abspath(tex.filepath)) # Now copy images copyCount = 0 @@ -176,7 +176,7 @@ def sane_name(data, dct): name = 'unnamed' # blank string, ASKING FOR TROUBLE! else: - name = bpy.utils.clean_name(name) # use our own + name = bpy.path.clean_name(name) # use our own while name in iter(dct.values()): name = increment_string(name) @@ -200,14 +200,14 @@ def sane_groupname(data): return sane_name(data, sane_name_mapping_group) # FORCE_CWD - dont use the basepath, just add a ./ to the filename. # use when we know the file will be in the basepath. # ''' -# fname = bpy.utils.expandpath(fname_orig) +# fname = bpy.path.abspath(fname_orig) # # fname = Blender.sys.expandpath(fname_orig) # fname_strip = os.path.basename(fname) # # fname_strip = strip_path(fname) # if FORCE_CWD: # fname_rel = '.' + os.sep + fname_strip # else: -# fname_rel = bpy.utils.relpath(fname, basepath) +# fname_rel = bpy.path.relpath(fname, basepath) # # fname_rel = Blender.sys.relpath(fname, basepath) # if fname_rel.startswith('//'): fname_rel = '.' + os.sep + fname_rel[2:] # return fname, fname_strip, fname_rel @@ -354,8 +354,8 @@ def write(filename, batch_objects = None, \ new_fbxpath = fbxpath # own dir option modifies, we need to keep an original for data in data_seq: # scene or group - newname = BATCH_FILE_PREFIX + bpy.utils.clean_name(data.name) -# newname = BATCH_FILE_PREFIX + BPySys.bpy.utils.clean_name(data.name) + newname = BATCH_FILE_PREFIX + bpy.path.clean_name(data.name) +# newname = BATCH_FILE_PREFIX + BPySys.bpy.path.clean_name(data.name) if BATCH_OWN_DIR: @@ -1250,7 +1250,7 @@ def write(filename, batch_objects = None, \ file.write('\n\t}') def copy_image(image): - fn = bpy.utils.expandpath(image.filepath) + fn = bpy.path.abspath(image.filepath) fn_strip = os.path.basename(fn) if EXP_IMAGE_COPY: @@ -3361,20 +3361,24 @@ class ExportFBX(bpy.types.Operator): BATCH_FILE_PREFIX = StringProperty(name="Prefix", description="Prefix each file with this name", maxlen=1024, default="") - def poll(self, context): + @classmethod + def poll(cls, context): return context.active_object def execute(self, context): if not self.properties.filepath: raise Exception("filepath not set") + filepath = self.properties.filepath + filepath = bpy.path.ensure_ext(filepath, ".fbx") + GLOBAL_MATRIX = mtx4_identity GLOBAL_MATRIX[0][0] = GLOBAL_MATRIX[1][1] = GLOBAL_MATRIX[2][2] = self.properties.TX_SCALE if self.properties.TX_XROT90: GLOBAL_MATRIX = mtx4_x90n * GLOBAL_MATRIX if self.properties.TX_YROT90: GLOBAL_MATRIX = mtx4_y90n * GLOBAL_MATRIX if self.properties.TX_ZROT90: GLOBAL_MATRIX = mtx4_z90n * GLOBAL_MATRIX - write(self.properties.filepath, + write(filepath, None, # XXX context, self.properties.EXP_OBS_SELECTED, @@ -3394,7 +3398,8 @@ class ExportFBX(bpy.types.Operator): self.properties.BATCH_ENABLE, self.properties.BATCH_GROUP, self.properties.BATCH_FILE_PREFIX, - self.properties.BATCH_OWN_DIR) + self.properties.BATCH_OWN_DIR, + ) return {'FINISHED'} @@ -3412,7 +3417,7 @@ class ExportFBX(bpy.types.Operator): # NOTES (all line numbers correspond to original export_fbx.py (under release/scripts) # - Draw.PupMenu alternative in 2.5?, temporarily replaced PupMenu with print -# - get rid of bpy.utils.clean_name somehow +# - get rid of bpy.path.clean_name somehow # + fixed: isinstance(inst, bpy.types.*) doesn't work on RNA objects: line 565 # + get rid of BPyObject_getObjectArmature, move it in RNA? # - BATCH_ENABLE and BATCH_GROUP options: line 327 @@ -3427,7 +3432,7 @@ class ExportFBX(bpy.types.Operator): # - bpy.data.remove_scene: line 366 # - bpy.sys.time move to bpy.sys.util? # - new scene creation, activation: lines 327-342, 368 -# - uses bpy.utils.expandpath, *.relpath - replace at least relpath +# - uses bpy.path.abspath, *.relpath - replace at least relpath # SMALL or COSMETICAL # - find a way to get blender version, and put it in bpy.util?, old was Blender.Get('version') @@ -3439,12 +3444,10 @@ def menu_func(self, context): def register(): - bpy.types.register(ExportFBX) bpy.types.INFO_MT_file_export.append(menu_func) def unregister(): - bpy.types.unregister(ExportFBX) bpy.types.INFO_MT_file_export.remove(menu_func) if __name__ == "__main__": diff --git a/release/scripts/io/export_mdd.py b/release/scripts/io/export_mdd.py index d2e53070910..2d45e18ef77 100644 --- a/release/scripts/io/export_mdd.py +++ b/release/scripts/io/export_mdd.py @@ -165,15 +165,23 @@ class ExportMDD(bpy.types.Operator): frame_start = IntProperty(name="Start Frame", description="Start frame for baking", min=minframe, max=maxframe, default=1) frame_end = IntProperty(name="End Frame", description="End frame for baking", min=minframe, max=maxframe, default=250) - def poll(self, context): + @classmethod + def poll(cls, context): ob = context.active_object return (ob and ob.type == 'MESH') def execute(self, context): - if not self.properties.filepath: - raise Exception("filename not set") - write(self.properties.filepath, context.scene, context.active_object, - self.properties.frame_start, self.properties.frame_end, self.properties.fps) + filepath = self.properties.filepath + filepath = bpy.path.ensure_ext(filepath, ".mdd") + + write(filepath, + context.scene, + context.active_object, + self.properties.frame_start, + self.properties.frame_end, + self.properties.fps, + ) + return {'FINISHED'} def invoke(self, context, event): @@ -189,12 +197,10 @@ def menu_func(self, context): def register(): - bpy.types.register(ExportMDD) bpy.types.INFO_MT_file_export.append(menu_func) def unregister(): - bpy.types.unregister(ExportMDD) bpy.types.INFO_MT_file_export.remove(menu_func) if __name__ == "__main__": diff --git a/release/scripts/io/export_obj.py b/release/scripts/io/export_obj.py index a4d98aac12e..fa378d26878 100644 --- a/release/scripts/io/export_obj.py +++ b/release/scripts/io/export_obj.py @@ -18,13 +18,6 @@ # <pep8 compliant> -""" -Name: 'Wavefront (.obj)...' -Blender: 248 -Group: 'Export' -Tooltip: 'Save a Wavefront OBJ File' -""" - __author__ = "Campbell Barton, Jiri Hnidek, Paolo Ciccone" __url__ = ['http://wiki.blender.org/index.php/Scripts/Manual/Export/wavefront_obj', 'www.blender.org', 'blenderartists.org'] __version__ = "1.21" @@ -73,7 +66,7 @@ def write_mtl(scene, filepath, copy_images, mtl_dict): dest_dir = os.path.dirname(filepath) def copy_image(image): - fn = bpy.utils.expandpath(image.filepath) + fn = bpy.path.abspath(image.filepath) fn_strip = os.path.basename(fn) if copy_images: rel = fn_strip @@ -189,7 +182,7 @@ def copy_images(dest_dir): copyCount = 0 # for bImage in uniqueImages.values(): -# image_path = bpy.utils.expandpath(bImage.filepath) +# image_path = bpy.path.abspath(bImage.filepath) # if bpy.sys.exists(image_path): # # Make a name for the target path. # dest_image_path = dest_dir + image_path.split('\\')[-1].split('/')[-1] @@ -797,7 +790,7 @@ def write(filepath, objects, scene, print("OBJ Export time: %.2f" % (time.clock() - time1)) # print "OBJ Export time: %.2f" % (sys.time() - time1) -def do_export(filepath, context, +def write(filepath, context, EXPORT_APPLY_MODIFIERS = True, # not used EXPORT_ROTX90 = True, # wrong EXPORT_TRI = False, # ok @@ -844,7 +837,7 @@ def do_export(filepath, context, orig_frame = scn.frame_current if EXPORT_ALL_SCENES: # Add scene name into the context_name - context_name[1] = '_%s' % bpy.utils.clean_name(scn.name) # WARNING, its possible that this could cause a collision. we could fix if were feeling parranoied. + context_name[1] = '_%s' % bpy.path.clean_name(scn.name) # WARNING, its possible that this could cause a collision. we could fix if were feeling parranoied. # Export an animation? if EXPORT_ANIMATION: @@ -934,27 +927,27 @@ class ExportOBJ(bpy.types.Operator): def execute(self, context): filepath = self.properties.filepath - if not filepath.lower().endswith(".obj"): - filepath += ".obj" - - do_export(filepath, context, - EXPORT_TRI=self.properties.use_triangles, - EXPORT_EDGES=self.properties.use_edges, - EXPORT_NORMALS=self.properties.use_normals, - EXPORT_NORMALS_HQ=self.properties.use_hq_normals, - EXPORT_UV=self.properties.use_uvs, - EXPORT_MTL=self.properties.use_materials, - EXPORT_COPY_IMAGES=self.properties.copy_images, - EXPORT_APPLY_MODIFIERS=self.properties.use_modifiers, - EXPORT_ROTX90=self.properties.use_rotate90, - EXPORT_BLEN_OBS=self.properties.use_blen_objects, - EXPORT_GROUP_BY_OB=self.properties.group_by_object, - EXPORT_GROUP_BY_MAT=self.properties.group_by_material, - EXPORT_KEEP_VERT_ORDER=self.properties.keep_vertex_order, - EXPORT_POLYGROUPS=self.properties.use_vertex_groups, - EXPORT_CURVE_AS_NURBS=self.properties.use_nurbs, - EXPORT_SEL_ONLY=self.properties.use_selection, - EXPORT_ALL_SCENES=self.properties.use_all_scenes) + filepath = bpy.path.ensure_ext(filepath, ".obj") + + write(filepath, context, + EXPORT_TRI=self.properties.use_triangles, + EXPORT_EDGES=self.properties.use_edges, + EXPORT_NORMALS=self.properties.use_normals, + EXPORT_NORMALS_HQ=self.properties.use_hq_normals, + EXPORT_UV=self.properties.use_uvs, + EXPORT_MTL=self.properties.use_materials, + EXPORT_COPY_IMAGES=self.properties.copy_images, + EXPORT_APPLY_MODIFIERS=self.properties.use_modifiers, + EXPORT_ROTX90=self.properties.use_rotate90, + EXPORT_BLEN_OBS=self.properties.use_blen_objects, + EXPORT_GROUP_BY_OB=self.properties.group_by_object, + EXPORT_GROUP_BY_MAT=self.properties.group_by_material, + EXPORT_KEEP_VERT_ORDER=self.properties.keep_vertex_order, + EXPORT_POLYGROUPS=self.properties.use_vertex_groups, + EXPORT_CURVE_AS_NURBS=self.properties.use_nurbs, + EXPORT_SEL_ONLY=self.properties.use_selection, + EXPORT_ALL_SCENES=self.properties.use_all_scenes, + ) return {'FINISHED'} @@ -970,11 +963,9 @@ def menu_func(self, context): def register(): - bpy.types.register(ExportOBJ) bpy.types.INFO_MT_file_export.append(menu_func) def unregister(): - bpy.types.unregister(ExportOBJ) bpy.types.INFO_MT_file_export.remove(menu_func) diff --git a/release/scripts/io/export_ply.py b/release/scripts/io/export_ply.py index 07865e4f65a..f4d7cae75a3 100644 --- a/release/scripts/io/export_ply.py +++ b/release/scripts/io/export_ply.py @@ -275,16 +275,15 @@ class ExportPLY(bpy.types.Operator): use_uvs = BoolProperty(name="UVs", description="Exort the active UV layer", default=True) use_colors = BoolProperty(name="Vertex Colors", description="Exort the active vertex color layer", default=True) - def poll(self, context): + @classmethod + def poll(cls, context): return context.active_object != None def execute(self, context): - # print("Selected: " + context.active_object.name) + filepath = self.properties.filepath + filepath = bpy.path.ensure_ext(filepath, ".ply") - if not self.properties.filepath: - raise Exception("filename not set") - - write(self.properties.filepath, context.scene, context.active_object,\ + write(filepath, context.scene, context.active_object,\ EXPORT_APPLY_MODIFIERS=self.properties.use_modifiers, EXPORT_NORMALS=self.properties.use_normals, EXPORT_UV=self.properties.use_uvs, @@ -317,12 +316,10 @@ def menu_func(self, context): def register(): - bpy.types.register(ExportPLY) bpy.types.INFO_MT_file_export.append(menu_func) def unregister(): - bpy.types.unregister(ExportPLY) bpy.types.INFO_MT_file_export.remove(menu_func) if __name__ == "__main__": diff --git a/release/scripts/io/export_x3d.py b/release/scripts/io/export_x3d.py index 7f5dd57171c..5fe48a2550a 100644 --- a/release/scripts/io/export_x3d.py +++ b/release/scripts/io/export_x3d.py @@ -794,7 +794,7 @@ class x3d_class: pic = tex.image # using .expandpath just in case, os.path may not expect // - basename = os.path.basename(bpy.utils.expandpath(pic.filepath)) + basename = os.path.basename(bpy.path.abspath(pic.filepath)) pic = alltextures[i].image # pic = alltextures[i].getImage() @@ -1140,7 +1140,7 @@ class x3d_class: # Callbacks, needed before Main ########################################################## -def x3d_export(filename, +def write(filename, context, EXPORT_APPLY_MODIFIERS=False, EXPORT_TRI=False, @@ -1175,47 +1175,6 @@ def x3d_export(filename, ) -def x3d_export_ui(filename): - if not filename.endswith(extension): - filename += extension - #if _safeOverwrite and sys.exists(filename): - # result = Draw.PupMenu("File Already Exists, Overwrite?%t|Yes%x1|No%x0") - #if(result != 1): - # return - - # Get user options - EXPORT_APPLY_MODIFIERS = Draw.Create(1) - EXPORT_TRI = Draw.Create(0) - EXPORT_GZIP = Draw.Create( filename.lower().endswith('.x3dz') ) - - # Get USER Options - pup_block = [\ - ('Apply Modifiers', EXPORT_APPLY_MODIFIERS, 'Use transformed mesh data from each object.'),\ - ('Triangulate', EXPORT_TRI, 'Triangulate quads.'),\ - ('Compress', EXPORT_GZIP, 'GZip the resulting file, requires a full python install'),\ - ] - - if not Draw.PupBlock('Export...', pup_block): - return - - Blender.Window.EditMode(0) - Blender.Window.WaitCursor(1) - - x3d_export(filename,\ - EXPORT_APPLY_MODIFIERS = EXPORT_APPLY_MODIFIERS.val,\ - EXPORT_TRI = EXPORT_TRI.val,\ - EXPORT_GZIP = EXPORT_GZIP.val\ - ) - - Blender.Window.WaitCursor(0) - - - -######################################################### -# main routine -######################################################### - - from bpy.props import * class ExportX3D(bpy.types.Operator): @@ -1233,7 +1192,16 @@ class ExportX3D(bpy.types.Operator): compress = BoolProperty(name="Compress", description="GZip the resulting file, requires a full python install", default=False) def execute(self, context): - x3d_export(self.properties.filepath, context, self.properties.apply_modifiers, self.properties.triangulate, self.properties.compress) + filepath = self.properties.filepath + filepath = bpy.path.ensure_ext(filepath, ".x3d") + + write(filepath, + context, + self.properties.apply_modifiers, + self.properties.triangulate, + self.properties.compress, + ) + return {'FINISHED'} def invoke(self, context, event): @@ -1248,11 +1216,9 @@ def menu_func(self, context): def register(): - bpy.types.register(ExportX3D) bpy.types.INFO_MT_file_export.append(menu_func) def unregister(): - bpy.types.unregister(ExportX3D) bpy.types.INFO_MT_file_export.remove(menu_func) # NOTES diff --git a/release/scripts/io/import_anim_bvh.py b/release/scripts/io/import_anim_bvh.py index 89097fd53f5..ba9b8a1f91d 100644 --- a/release/scripts/io/import_anim_bvh.py +++ b/release/scripts/io/import_anim_bvh.py @@ -612,12 +612,10 @@ def menu_func(self, context): def register(): - bpy.types.register(BvhImporter) bpy.types.INFO_MT_file_import.append(menu_func) def unregister(): - bpy.types.unregister(BvhImporter) bpy.types.INFO_MT_file_import.remove(menu_func) if __name__ == "__main__": diff --git a/release/scripts/io/import_scene_3ds.py b/release/scripts/io/import_scene_3ds.py index 435e08a209e..fe242ca1f29 100644 --- a/release/scripts/io/import_scene_3ds.py +++ b/release/scripts/io/import_scene_3ds.py @@ -1032,11 +1032,9 @@ def menu_func(self, context): self.layout.operator(IMPORT_OT_autodesk_3ds.bl_idname, text="3D Studio (.3ds)") def register(): - bpy.types.register(IMPORT_OT_autodesk_3ds) bpy.types.INFO_MT_file_import.append(menu_func) def unregister(): - bpy.types.unregister(IMPORT_OT_autodesk_3ds) bpy.types.INFO_MT_file_import.remove(menu_func) # NOTES: diff --git a/release/scripts/io/import_scene_obj.py b/release/scripts/io/import_scene_obj.py index 5b29a5ded90..e832489a560 100644 --- a/release/scripts/io/import_scene_obj.py +++ b/release/scripts/io/import_scene_obj.py @@ -1606,11 +1606,9 @@ def menu_func(self, context): def register(): - bpy.types.register(IMPORT_OT_obj) bpy.types.INFO_MT_file_import.append(menu_func) def unregister(): - bpy.types.unregister(IMPORT_OT_obj) bpy.types.INFO_MT_file_import.remove(menu_func) diff --git a/release/scripts/io/import_shape_mdd.py b/release/scripts/io/import_shape_mdd.py index ec0e7696630..d74726dce2e 100644 --- a/release/scripts/io/import_shape_mdd.py +++ b/release/scripts/io/import_shape_mdd.py @@ -120,7 +120,8 @@ class importMDD(bpy.types.Operator): #fps = IntProperty(name="Frames Per Second", description="Number of frames/second", min=minfps, max=maxfps, default=25) frame_start = IntProperty(name="Start Frame", description="Start frame for inserting animation", min=minframe, max=maxframe, default=0) - def poll(self, context): + @classmethod + def poll(cls, context): ob = context.active_object return (ob and ob.type == 'MESH') @@ -143,12 +144,10 @@ def menu_func(self, context): def register(): - bpy.types.register(importMDD) bpy.types.INFO_MT_file_import.append(menu_func) def unregister(): - bpy.types.unregister(importMDD) bpy.types.INFO_MT_file_import.remove(menu_func) if __name__ == "__main__": diff --git a/release/scripts/io/netrender/client.py b/release/scripts/io/netrender/client.py index 9f6d1a7639e..4a116bb982a 100644 --- a/release/scripts/io/netrender/client.py +++ b/release/scripts/io/netrender/client.py @@ -49,7 +49,7 @@ def addPointCache(job, ob, point_cache, default_path): if name == "": name = "".join(["%02X" % ord(c) for c in ob.name]) - cache_path = bpy.utils.expandpath(point_cache.filepath) if point_cache.external else default_path + cache_path = bpy.path.abspath(point_cache.filepath) if point_cache.external else default_path index = "%02i" % point_cache.index @@ -113,7 +113,7 @@ def clientSendJob(conn, scene, anim = False): # LIBRARIES ########################### for lib in bpy.data.libraries: - file_path = bpy.utils.expandpath(lib.filepath) + file_path = bpy.path.abspath(lib.filepath) if os.path.exists(file_path): job.addFile(file_path) @@ -122,7 +122,7 @@ def clientSendJob(conn, scene, anim = False): ########################### for image in bpy.data.images: if image.source == "FILE" and not image.packed_file: - file_path = bpy.utils.expandpath(image.filepath) + file_path = bpy.path.abspath(image.filepath) if os.path.exists(file_path): job.addFile(file_path) @@ -139,7 +139,7 @@ def clientSendJob(conn, scene, anim = False): for object in bpy.data.objects: for modifier in object.modifiers: if modifier.type == 'FLUID_SIMULATION' and modifier.settings.type == "DOMAIN": - addFluidFiles(job, bpy.utils.expandpath(modifier.settings.path)) + addFluidFiles(job, bpy.path.abspath(modifier.settings.path)) elif modifier.type == "CLOTH": addPointCache(job, object, modifier.point_cache, default_path) elif modifier.type == "SOFT_BODY": @@ -149,7 +149,7 @@ def clientSendJob(conn, scene, anim = False): if modifier.domain_settings.highres: addPointCache(job, object, modifier.domain_settings.point_cache_high, default_path) elif modifier.type == "MULTIRES" and modifier.external: - file_path = bpy.utils.expandpath(modifier.filepath) + file_path = bpy.path.abspath(modifier.filepath) job.addFile(file_path) # particles modifier are stupid and don't contain data @@ -189,7 +189,6 @@ def clientSendJob(conn, scene, anim = False): def requestResult(conn, job_id, frame): conn.request("GET", renderURL(job_id, frame)) -@rnaType class NetworkRenderEngine(bpy.types.RenderEngine): bl_idname = 'NET_RENDER' bl_label = "Network Render" diff --git a/release/scripts/io/netrender/operators.py b/release/scripts/io/netrender/operators.py index 858ec800dbc..55c2d11e28e 100644 --- a/release/scripts/io/netrender/operators.py +++ b/release/scripts/io/netrender/operators.py @@ -26,13 +26,13 @@ from netrender.utils import * import netrender.client as client import netrender.model -@rnaType class RENDER_OT_netslave_bake(bpy.types.Operator): '''NEED DESCRIPTION''' bl_idname = "render.netslavebake" bl_label = "Bake all in file" - def poll(self, context): + @classmethod + def poll(cls, context): return True def execute(self, context): @@ -84,13 +84,13 @@ class RENDER_OT_netslave_bake(bpy.types.Operator): def invoke(self, context, event): return self.execute(context) -@rnaType class RENDER_OT_netclientanim(bpy.types.Operator): '''Start rendering an animation on network''' bl_idname = "render.netclientanim" bl_label = "Animation on network" - def poll(self, context): + @classmethod + def poll(cls, context): return True def execute(self, context): @@ -111,13 +111,13 @@ class RENDER_OT_netclientanim(bpy.types.Operator): def invoke(self, context, event): return self.execute(context) -@rnaType class RENDER_OT_netclientrun(bpy.types.Operator): '''Start network rendering service''' bl_idname = "render.netclientstart" bl_label = "Start Service" - def poll(self, context): + @classmethod + def poll(cls, context): return True def execute(self, context): @@ -128,13 +128,13 @@ class RENDER_OT_netclientrun(bpy.types.Operator): def invoke(self, context, event): return self.execute(context) -@rnaType class RENDER_OT_netclientsend(bpy.types.Operator): '''Send Render Job to the Network''' bl_idname = "render.netclientsend" bl_label = "Send job" - def poll(self, context): + @classmethod + def poll(cls, context): return True def execute(self, context): @@ -158,13 +158,13 @@ class RENDER_OT_netclientsend(bpy.types.Operator): def invoke(self, context, event): return self.execute(context) -@rnaType class RENDER_OT_netclientsendframe(bpy.types.Operator): '''Send Render Job with current frame to the Network''' bl_idname = "render.netclientsendframe" bl_label = "Send current frame job" - def poll(self, context): + @classmethod + def poll(cls, context): return True def execute(self, context): @@ -188,13 +188,13 @@ class RENDER_OT_netclientsendframe(bpy.types.Operator): def invoke(self, context, event): return self.execute(context) -@rnaType class RENDER_OT_netclientstatus(bpy.types.Operator): '''Refresh the status of the current jobs''' bl_idname = "render.netclientstatus" bl_label = "Client Status" - def poll(self, context): + @classmethod + def poll(cls, context): return True def execute(self, context): @@ -228,13 +228,13 @@ class RENDER_OT_netclientstatus(bpy.types.Operator): def invoke(self, context, event): return self.execute(context) -@rnaType class RENDER_OT_netclientblacklistslave(bpy.types.Operator): '''Operator documentation text, will be used for the operator tooltip and python docs.''' bl_idname = "render.netclientblacklistslave" bl_label = "Client Blacklist Slave" - def poll(self, context): + @classmethod + def poll(cls, context): return True def execute(self, context): @@ -258,13 +258,13 @@ class RENDER_OT_netclientblacklistslave(bpy.types.Operator): def invoke(self, context, event): return self.execute(context) -@rnaType class RENDER_OT_netclientwhitelistslave(bpy.types.Operator): '''Operator documentation text, will be used for the operator tooltip and python docs.''' bl_idname = "render.netclientwhitelistslave" bl_label = "Client Whitelist Slave" - def poll(self, context): + @classmethod + def poll(cls, context): return True def execute(self, context): @@ -289,13 +289,13 @@ class RENDER_OT_netclientwhitelistslave(bpy.types.Operator): return self.execute(context) -@rnaType class RENDER_OT_netclientslaves(bpy.types.Operator): '''Refresh status about available Render slaves''' bl_idname = "render.netclientslaves" bl_label = "Client Slaves" - def poll(self, context): + @classmethod + def poll(cls, context): return True def execute(self, context): @@ -334,13 +334,13 @@ class RENDER_OT_netclientslaves(bpy.types.Operator): def invoke(self, context, event): return self.execute(context) -@rnaType class RENDER_OT_netclientcancel(bpy.types.Operator): '''Cancel the selected network rendering job.''' bl_idname = "render.netclientcancel" bl_label = "Client Cancel" - def poll(self, context): + @classmethod + def poll(cls, context): netsettings = context.scene.network_render return netsettings.active_job_index >= 0 and len(netsettings.jobs) > 0 @@ -363,13 +363,13 @@ class RENDER_OT_netclientcancel(bpy.types.Operator): def invoke(self, context, event): return self.execute(context) -@rnaType class RENDER_OT_netclientcancelall(bpy.types.Operator): '''Cancel all running network rendering jobs.''' bl_idname = "render.netclientcancelall" bl_label = "Client Cancel All" - def poll(self, context): + @classmethod + def poll(cls, context): return True def execute(self, context): @@ -390,13 +390,13 @@ class RENDER_OT_netclientcancelall(bpy.types.Operator): def invoke(self, context, event): return self.execute(context) -@rnaType class netclientdownload(bpy.types.Operator): '''Download render results from the network''' bl_idname = "render.netclientdownload" bl_label = "Client Download" - def poll(self, context): + @classmethod + def poll(cls, context): netsettings = context.scene.network_render return netsettings.active_job_index >= 0 and len(netsettings.jobs) > 0 @@ -435,13 +435,13 @@ class netclientdownload(bpy.types.Operator): def invoke(self, context, event): return self.execute(context) -@rnaType class netclientscan(bpy.types.Operator): '''Listen on network for master server broadcasting its address and port.''' bl_idname = "render.netclientscan" bl_label = "Client Scan" - def poll(self, context): + @classmethod + def poll(cls, context): return True def execute(self, context): @@ -458,13 +458,13 @@ class netclientscan(bpy.types.Operator): def invoke(self, context, event): return self.execute(context) -@rnaType class netclientweb(bpy.types.Operator): '''Open new window with information about running rendering jobs''' bl_idname = "render.netclientweb" bl_label = "Open Master Monitor" - def poll(self, context): + @classmethod + def poll(cls, context): netsettings = context.scene.network_render return netsettings.server_address != "[default]" diff --git a/release/scripts/io/netrender/repath.py b/release/scripts/io/netrender/repath.py index d9a13ade987..9243505bd3b 100644 --- a/release/scripts/io/netrender/repath.py +++ b/release/scripts/io/netrender/repath.py @@ -92,7 +92,7 @@ def process(paths): # LIBRARIES ########################### for lib in bpy.data.libraries: - file_path = bpy.utils.expandpath(lib.filepath) + file_path = bpy.path.abspath(lib.filepath) new_path = path_map.get(os.path.split(file_path)[1], None) if new_path: lib.filepath = new_path @@ -102,7 +102,7 @@ def process(paths): ########################### for image in bpy.data.images: if image.source == "FILE" and not image.packed_file: - file_path = bpy.utils.expandpath(image.filepath) + file_path = bpy.path.abspath(image.filepath) new_path = path_map.get(os.path.split(file_path)[1], None) if new_path: image.filepath = new_path @@ -124,7 +124,7 @@ def process(paths): if modifier.domain_settings.highres: processPointCache(modifier.domain_settings.point_cache_high) elif modifier.type == "MULTIRES" and modifier.external: - file_path = bpy.utils.expandpath(modifier.filepath) + file_path = bpy.path.abspath(modifier.filepath) new_path = path_map.get(file_path, None) if new_path: modifier.filepath = new_path diff --git a/release/scripts/io/netrender/ui.py b/release/scripts/io/netrender/ui.py index c82a031100b..1dcee85820b 100644 --- a/release/scripts/io/netrender/ui.py +++ b/release/scripts/io/netrender/ui.py @@ -36,6 +36,11 @@ DISPATCHED = 1 DONE = 2 ERROR = 3 +def base_poll(cls, context): + rd = context.scene.render + return (rd.use_game_engine==False) and (rd.engine in cls.COMPAT_ENGINES) + + def init_file(): if netrender.init_file != bpy.data.filepath: netrender.init_file = bpy.data.filepath @@ -82,16 +87,16 @@ class RenderButtonsPanel(): bl_context = "render" # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here - def poll(self, context): - rd = context.scene.render - return (rd.use_game_engine==False) and (rd.engine in self.COMPAT_ENGINES) # Setting panel, use in the scene for now. -@rnaType class RENDER_PT_network_settings(bpy.types.Panel, RenderButtonsPanel): bl_label = "Network Settings" COMPAT_ENGINES = {'NET_RENDER'} + @classmethod + def poll(cls, context): + return base_poll(cls, context) + def draw(self, context): layout = self.layout @@ -122,15 +127,14 @@ class RENDER_PT_network_settings(bpy.types.Panel, RenderButtonsPanel): layout.operator("render.netclientweb", icon='QUESTION') -@rnaType class RENDER_PT_network_slave_settings(bpy.types.Panel, RenderButtonsPanel): bl_label = "Slave Settings" COMPAT_ENGINES = {'NET_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): scene = context.scene - return (super().poll(context) - and scene.network_render.mode == "RENDER_SLAVE") + return base_poll(cls, context) and scene.network_render.mode == "RENDER_SLAVE" def draw(self, context): layout = self.layout @@ -147,15 +151,15 @@ class RENDER_PT_network_slave_settings(bpy.types.Panel, RenderButtonsPanel): sub = layout.column() sub.enabled = rd.threads_mode == 'FIXED' sub.prop(rd, "threads") -@rnaType + class RENDER_PT_network_master_settings(bpy.types.Panel, RenderButtonsPanel): bl_label = "Master Settings" COMPAT_ENGINES = {'NET_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): scene = context.scene - return (super().poll(context) - and scene.network_render.mode == "RENDER_MASTER") + return base_poll(cls, context) and scene.network_render.mode == "RENDER_MASTER" def draw(self, context): layout = self.layout @@ -166,15 +170,14 @@ class RENDER_PT_network_master_settings(bpy.types.Panel, RenderButtonsPanel): layout.prop(netsettings, "master_broadcast") layout.prop(netsettings, "master_clear") -@rnaType class RENDER_PT_network_job(bpy.types.Panel, RenderButtonsPanel): bl_label = "Job Settings" COMPAT_ENGINES = {'NET_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): scene = context.scene - return (super().poll(context) - and scene.network_render.mode == "RENDER_CLIENT") + return base_poll(cls, context) and scene.network_render.mode == "RENDER_CLIENT" def draw(self, context): layout = self.layout @@ -207,19 +210,18 @@ class RENDER_PT_network_job(bpy.types.Panel, RenderButtonsPanel): row.prop(netsettings, "priority") row.prop(netsettings, "chunks") -@rnaType class RENDER_PT_network_slaves(bpy.types.Panel, RenderButtonsPanel): bl_label = "Slaves Status" COMPAT_ENGINES = {'NET_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): scene = context.scene netsettings = scene.network_render if netsettings.mode != "RENDER_CLIENT": return False verify_address(netsettings) - return (super().poll(context) - and netsettings.server_address != "[default]") + return base_poll(cls, context) and netsettings.server_address != "[default]" def draw(self, context): layout = self.layout @@ -246,19 +248,18 @@ class RENDER_PT_network_slaves(bpy.types.Panel, RenderButtonsPanel): layout.label(text="Seen: " + time.ctime(slave.last_seen)) layout.label(text="Stats: " + slave.stats) -@rnaType class RENDER_PT_network_slaves_blacklist(bpy.types.Panel, RenderButtonsPanel): bl_label = "Slaves Blacklist" COMPAT_ENGINES = {'NET_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): scene = context.scene netsettings = scene.network_render if netsettings.mode != "RENDER_CLIENT": return False verify_address(netsettings) - return (super().poll(context) - and netsettings.server_address != "[default]") + return base_poll(cls, context) and netsettings.server_address != "[default]" def draw(self, context): layout = self.layout @@ -284,19 +285,18 @@ class RENDER_PT_network_slaves_blacklist(bpy.types.Panel, RenderButtonsPanel): layout.label(text="Seen: " + time.ctime(slave.last_seen)) layout.label(text="Stats: " + slave.stats) -@rnaType class RENDER_PT_network_jobs(bpy.types.Panel, RenderButtonsPanel): bl_label = "Jobs" COMPAT_ENGINES = {'NET_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): scene = context.scene netsettings = scene.network_render if netsettings.mode != "RENDER_CLIENT": return False verify_address(netsettings) - return (super().poll(context) - and netsettings.server_address != "[default]") + return base_poll(cls, context) and netsettings.server_address != "[default]" def draw(self, context): layout = self.layout @@ -325,15 +325,12 @@ class RENDER_PT_network_jobs(bpy.types.Panel, RenderButtonsPanel): layout.label(text="Done: %04i" % job.results[DONE]) layout.label(text="Error: %04i" % job.results[ERROR]) -@rnaType class NetRenderSettings(bpy.types.IDPropertyGroup): pass -@rnaType class NetRenderSlave(bpy.types.IDPropertyGroup): pass -@rnaType class NetRenderJob(bpy.types.IDPropertyGroup): pass diff --git a/release/scripts/io/netrender/utils.py b/release/scripts/io/netrender/utils.py index fa2eb6fb5f5..31123ce26da 100644 --- a/release/scripts/io/netrender/utils.py +++ b/release/scripts/io/netrender/utils.py @@ -57,10 +57,6 @@ FRAME_STATUS_TEXT = { ERROR: "Error" } -def rnaType(rna_type): - if bpy: bpy.types.register(rna_type) - return rna_type - def reporting(report, message, errorType = None): if errorType: t = 'ERROR' diff --git a/release/scripts/modules/bpy/__init__.py b/release/scripts/modules/bpy/__init__.py index 1e6db441599..3431054413e 100644 --- a/release/scripts/modules/bpy/__init__.py +++ b/release/scripts/modules/bpy/__init__.py @@ -26,7 +26,7 @@ data = _bpy.data context = _bpy.context # python modules -from bpy import utils +from bpy import utils, path from bpy import ops as _ops_module diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py new file mode 100644 index 00000000000..63149f2fce8 --- /dev/null +++ b/release/scripts/modules/bpy/path.py @@ -0,0 +1,174 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# <pep8 compliant> + +""" +This module has a similar scope to os.path, containing utility +functions for dealing with paths in Blender. +""" + +import bpy as _bpy +import os as _os + +def abspath(path): + """ + Returns the absolute path relative to the current blend file using the "//" prefix. + """ + if path.startswith("//"): + return _os.path.join(_os.path.dirname(_bpy.data.filepath), path[2:]) + + return path + + +def relpath(path, start=None): + """ + Returns the path relative to the current blend file using the "//" prefix. + + :arg start: Relative to this path, when not set the current filename is used. + :type start: string + """ + if not path.startswith("//"): + if start is None: + start = _os.path.dirname(_bpy.data.filepath) + return "//" + _os.path.relpath(path, start) + + return path + + +def clean_name(name, replace="_"): + """ + Returns a name with characters replaced that may cause problems under various circumstances, such as writing to a file. + All characters besides A-Z/a-z, 0-9 are replaced with "_" + or the replace argument if defined. + """ + + unclean_chars = \ + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\ + \x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\ + \x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\ + \x2e\x2f\x3a\x3b\x3c\x3d\x3e\x3f\x40\x5b\x5c\x5d\x5e\x60\x7b\ + \x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\ + \x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\ + \x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\ + \xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\ + \xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\ + \xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\ + \xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\ + \xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\ + \xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe" + + for ch in unclean_chars: + name = name.replace(ch, replace) + return name + + +def display_name(name): + """ + Creates a display string from name to be used menus and the user interface. + Capitalize the first letter in all lowercase names, mixed case names are kept as is. + Intended for use with filenames and module names. + """ + + name_base = _os.path.splitext(name)[0] + + # string replacements + name_base = name_base.replace("_colon_", ":") + + name_base = name_base.replace("_", " ") + + if name_base.islower(): + return name_base.capitalize() + else: + return name_base + + +def resolve_ncase(path): + """ + Resolve a case insensitive path on a case sensitive system, + returning a string with the path if found else return the original path. + """ + + import os + + def _ncase_path_found(path): + if path=='' or os.path.exists(path): + return path, True + + filename = os.path.basename(path) # filename may be a directory or a file + dirpath = os.path.dirname(path) + + suffix = "" + if not filename: # dir ends with a slash? + if len(dirpath) < len(path): + suffix = path[:len(path)-len(dirpath)] + + filename = os.path.basename(dirpath) + dirpath = os.path.dirname(dirpath) + + if not os.path.exists(dirpath): + dirpath, found = _ncase_path_found(dirpath) + + if not found: + return path, False + + # at this point, the directory exists but not the file + + # we are expecting 'dirpath' to be a directory, but it could be a file + if os.path.isdir(dirpath): + files = os.listdir(dirpath) + else: + return path, False + + filename_low = filename.lower() + f_iter_nocase = None + + for f_iter in files: + if f_iter.lower() == filename_low: + f_iter_nocase = f_iter + break + + if f_iter_nocase: + return os.path.join(dirpath, f_iter_nocase) + suffix, True + else: + # cant find the right one, just return the path as is. + return path, False + + ncase_path, found = _ncase_path_found(path) + return ncase_path if found else path + + +def ensure_ext(filepath, ext, case_sensitive=False): + """ + Return the path with the extension added its its not alredy set. + + :arg ext: The extension to check for. + :type ext: string + :arg case_sensitive: Check for matching case when comparing extensions. + :type case_sensitive: bool + """ + import os + fn_base, fn_ext = os.path.splitext(filepath) + if fn_base and fn_ext: + if (case_sensitive and ext == fn_ext) or (ext.lower() == fn_ext.lower()): + return filepath + else: + return fn_base + ext + + else: + return filepath + ext diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index 06dbe8fd4cc..c7ee23264e8 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -30,6 +30,7 @@ import sys as _sys from _bpy import blend_paths from _bpy import script_paths as _bpy_script_paths +_TEST_XML = _bpy.app.debug def _test_import(module_name, loaded_modules): import traceback @@ -53,6 +54,35 @@ def _test_import(module_name, loaded_modules): loaded_modules.add(mod.__name__) # should match mod.__name__ too return mod +if _TEST_XML: + # TEST CODE + def _test_import_xml(path, f, loaded_modules): + import bpy_xml_ui + import traceback + + f_full = _os.path.join(path, f) + _bpy_types._register_immediate = True + try: + classes = bpy_xml_ui.load_xml(f_full) + except: + traceback.print_exc() + classes = [] + _bpy_types._register_immediate = False + + if classes: + mod_name = f.split(".")[0] + + # fake module + mod = type(traceback)(mod_name) + mod.__file__ = f_full + for cls in classes: + setattr(mod, cls.__name__, cls) + + loaded_modules.add(mod_name) + _sys.modules[mod_name] = mod + mod.register = lambda: None # quiet errors + return mod + def modules_from_path(path, loaded_modules): """ @@ -80,13 +110,17 @@ def modules_from_path(path, loaded_modules): else: mod = None + if _TEST_XML: + if mod is None and f.endswith(".xml"): + mod = _test_import_xml(path, f, loaded_modules) + if mod: modules.append(mod) return modules - -_loaded = [] # store loaded modules for reloading. -_bpy_types = __import__("bpy_types") # keep for comparisons, never ever reload this. + +_global_loaded_modules = [] # store loaded module names for reloading. +import bpy_types as _bpy_types # keep for comparisons, never ever reload this. def load_scripts(reload_scripts=False, refresh_scripts=False): @@ -101,12 +135,39 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): import traceback import time + # must be set back to True on exits + _bpy_types._register_immediate = False + t_main = time.time() loaded_modules = set() if refresh_scripts: original_modules = _sys.modules.values() + + if reload_scripts: + _bpy_types.TypeMap.clear() + _bpy_types.PropertiesMap.clear() + + def register_module_call(mod): + _bpy_types._register_module(mod.__name__) + register = getattr(mod, "register", None) + if register: + try: + register() + except: + traceback.print_exc() + else: + print("\nWarning! '%s' has no register function, this is now a requirement for registerable scripts." % mod.__file__) + + def unregister_module_call(mod): + _bpy_types._unregister_module(mod.__name__) + unregister = getattr(mod, "unregister", None) + if unregister: + try: + unregister() + except: + traceback.print_exc() def sys_path_ensure(path): if path not in _sys.path: # reloading would add twice @@ -134,48 +195,23 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): mod = test_reload(mod) if mod: - register = getattr(mod, "register", None) - if register: - try: - register() - except: - traceback.print_exc() - else: - print("\nWarning! '%s' has no register function, this is now a requirement for registerable scripts." % mod.__file__) - _loaded.append(mod) + register_module_call(mod) + _global_loaded_modules.append(mod.__name__) if reload_scripts: - # TODO, this is broken but should work, needs looking into - ''' - # reload modules that may not be directly included - for type_class_name in dir(_bpy.types): - type_class = getattr(_bpy.types, type_class_name) - module_name = getattr(type_class, "__module__", "") - - if module_name and module_name != "bpy.types": # hard coded for C types - loaded_modules.add(module_name) - - # sorting isnt needed but rather it be pradictable - for module_name in sorted(loaded_modules): - print("Reloading:", module_name) - test_reload(_sys.modules[module_name]) - ''' + # module names -> modules + _global_loaded_modules[:] = [_sys.modules[mod_name] for mod_name in _global_loaded_modules] # loop over and unload all scripts - _loaded.reverse() - for mod in _loaded: - unregister = getattr(mod, "unregister", None) - if unregister: - try: - unregister() - except: - traceback.print_exc() + _global_loaded_modules.reverse() + for mod in _global_loaded_modules: + unregister_module_call(mod) - for mod in _loaded: - reload(mod) + for mod in _global_loaded_modules: + test_reload(mod) - _loaded[:] = [] + _global_loaded_modules[:] = [] user_path = user_script_path() @@ -197,7 +233,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): # load addons used_ext = {ext.module for ext in _bpy.context.user_preferences.addons} - paths = script_paths("addons") + paths = script_paths("addons") + script_paths("addons_contrib") for path in paths: sys_path_ensure(path) @@ -211,77 +247,10 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): if _bpy.app.debug: print("Python Script Load Time %.4f" % (time.time() - t_main)) + + _bpy_types._register_immediate = True -def expandpath(path): - """ - Returns the absolute path relative to the current blend file using the "//" prefix. - """ - if path.startswith("//"): - return _os.path.join(_os.path.dirname(_bpy.data.filepath), path[2:]) - - return path - - -def relpath(path, start=None): - """ - Returns the path relative to the current blend file using the "//" prefix. - - :arg start: Relative to this path, when not set the current filename is used. - :type start: string - """ - if not path.startswith("//"): - if start is None: - start = _os.path.dirname(_bpy.data.filepath) - return "//" + _os.path.relpath(path, start) - - return path - - -def clean_name(name, replace="_"): - """ - Returns a name with characters replaced that may cause problems under various circumstances, such as writing to a file. - All characters besides A-Z/a-z, 0-9 are replaced with "_" - or the replace argument if defined. - """ - - unclean_chars = \ - "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\ - \x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\ - \x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\ - \x2e\x2f\x3a\x3b\x3c\x3d\x3e\x3f\x40\x5b\x5c\x5d\x5e\x60\x7b\ - \x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\ - \x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\ - \x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\ - \xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\ - \xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\ - \xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\ - \xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\ - \xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\ - \xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe" - - for ch in unclean_chars: - name = name.replace(ch, replace) - return name - - -def display_name(name): - """ - Creates a display string from name to be used menus and the user interface. - Capitalize the first letter in all lowercase names, mixed case names are kept as is. - Intended for use with filenames and module names. - """ - name_base = _os.path.splitext(name)[0] - - # string replacements - name_base = name_base.replace("_colon_", ":") - - name_base = name_base.replace("_", " ") - - if name_base.islower(): - return name_base.capitalize() - else: - return name_base # base scripts @@ -336,7 +305,7 @@ _presets = _os.path.join(_scripts[0], "presets") # FIXME - multiple paths def preset_paths(subdir): ''' - Returns a list of paths for a spesific preset. + Returns a list of paths for a specific preset. ''' return (_os.path.join(_presets, subdir), ) diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 8cbb2bf4e80..0cd0aaaa3f0 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -19,6 +19,7 @@ # <pep8 compliant> from _bpy import types as bpy_types +import _bpy from mathutils import Vector StructRNA = bpy_types.Struct.__bases__[0] @@ -539,8 +540,83 @@ class Text(bpy_types.ID): import collections +TypeMap = {} +# Properties (IDPropertyGroup) are different from types because they need to be registered +# before adding sub properties to them, so they are registered on definition +# and unregistered on unload +PropertiesMap = {} -class OrderedMeta(type): +# Using our own loading function we set this to false +# so when running a script directly in the text editor +# registers moduals instantly. +_register_immediate = True + +def _unregister_module(module, free=True): + for t in TypeMap.get(module, ()): + try: + bpy_types.unregister(t) + except: + import traceback + print("bpy.utils._unregister_module(): Module '%s' failed to unregister class '%s.%s'" % (module, t.__module__, t.__name__)) + traceback.print_exc() + + if free == True and module in TypeMap: + del TypeMap[module] + + + for t in PropertiesMap.get(module, ()): + try: + bpy_types.unregister(t) + except: + import traceback + print("bpy.utils._unload_module(): Module '%s' failed to unregister class '%s.%s'" % (module, t.__module__, t.__name__)) + traceback.print_exc() + + if free == True and module in PropertiesMap: + del PropertiesMap[module] + + +def _register_module(module): + for t in TypeMap.get(module, ()): + try: + bpy_types.register(t) + except: + import traceback + print("bpy.utils._register_module(): Module '%s' failed to register class '%s.%s'" % (module, t.__module__, t.__name__)) + traceback.print_exc() + + +class RNAMeta(type): + @classmethod + def _register_immediate(cls): + return _register_immediate + + def __new__(cls, name, bases, classdict, **args): + result = type.__new__(cls, name, bases, classdict) + if bases and bases[0] != StructRNA: + module = result.__module__ + + ClassMap = TypeMap + + # Register right away if needed + if cls._register_immediate(): + bpy_types.register(result) + ClassMap = PropertiesMap + + # first part of packages only + if "." in module: + module = module[:module.index(".")] + + ClassMap.setdefault(module, []).append(result) + + return result + +class RNAMetaRegister(RNAMeta): + @classmethod + def _register_immediate(cls): + return True + +class OrderedMeta(RNAMeta): def __init__(cls, name, bases, attributes): super(OrderedMeta, cls).__init__(name, bases, attributes) @@ -549,7 +625,6 @@ class OrderedMeta(type): def __prepare__(name, bases, **kwargs): return collections.OrderedDict() - # Only defined so operators members can be used by accessing self.order class Operator(StructRNA, metaclass=OrderedMeta): __slots__ = () @@ -564,7 +639,12 @@ class Macro(StructRNA, metaclass=OrderedMeta): def define(self, opname): from _bpy import ops return ops.macro_define(self, opname) + +class IDPropertyGroup(StructRNA, metaclass=RNAMetaRegister): + __slots__ = () +class RenderEngine(StructRNA, metaclass=RNAMeta): + __slots__ = () class _GenericUI: __slots__ = () @@ -606,15 +686,15 @@ class _GenericUI: pass -class Panel(StructRNA, _GenericUI): +class Panel(StructRNA, _GenericUI, metaclass=RNAMeta): __slots__ = () -class Header(StructRNA, _GenericUI): +class Header(StructRNA, _GenericUI, metaclass=RNAMeta): __slots__ = () -class Menu(StructRNA, _GenericUI): +class Menu(StructRNA, _GenericUI, metaclass=RNAMeta): __slots__ = () def path_menu(self, searchpaths, operator, props_default={}): @@ -638,7 +718,7 @@ class Menu(StructRNA, _GenericUI): if f.startswith("."): continue - preset_name = bpy.utils.display_name(f) + preset_name = bpy.path.display_name(f) props = layout.operator(operator, text=preset_name) for attr, value in props_default.items(): diff --git a/release/scripts/modules/bpy_xml_ui.py b/release/scripts/modules/bpy_xml_ui.py new file mode 100644 index 00000000000..18eec9c4ef4 --- /dev/null +++ b/release/scripts/modules/bpy_xml_ui.py @@ -0,0 +1,151 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# <pep8 compliant> + +""" +This module translates XML into blender/ui function calls. +""" + +import xml.dom.minidom +import bpy as _bpy + +def parse_rna(prop, value): + if prop.type == 'FLOAT': + value = float(value) + elif prop.type == 'INT': + value = int(value) + elif prop.type == 'BOOLEAN': + if value not in ("true", "false"): + raise Exception("invalid bool value: %s", value) + value = bool(value == "true") + elif prop.type in ('STRING', 'ENUM'): + pass + elif prop.type == 'POINTER': + value = eval("_bpy." + value) + else: + raise Exception("type not supported %s.%s" % (prop.identifier, prop.type)) + return value + +def parse_args(base, xml_node): + args = {} + rna_params = base.bl_rna.functions[xml_node.tagName].parameters + for key, value in xml_node.attributes.items(): + args[key] = parse_rna(rna_params[key], value) + return args + +def ui_xml(base, xml_node): + name = xml_node.tagName + prop = base.bl_rna.properties.get(name) + if name in base.bl_rna.properties: + attr = xml_node.attributes.get("expr") + if attr: + value = attr.value + value = eval(value, {"context": _bpy.context}) + setattr(base, name, value) + else: + attr = xml_node.attributes['value'] + value = attr.value + value = parse_rna(prop, value) + setattr(base, name, value) + else: + func_new = getattr(base, name) + kw_args = parse_args(base, xml_node) + base_new = func_new(**kw_args) # call blender func + if xml_node.hasChildNodes(): + ui_xml_list(base_new, xml_node.childNodes) + +def ui_xml_list(base, xml_nodes): + import bpy + for node in xml_nodes: + if node.nodeType not in (node.TEXT_NODE, node.COMMENT_NODE): + ui_xml(base, node) + bpy.N = node + +def test(layout): + uixml = xml.dom.minidom.parseString(open("/mnt/test/blender-svn/blender/release/scripts/ui/test.xml", 'r').read()) + panel = uixml.getElementsByTagName('panel')[0] + ui_xml_list(layout, panel.childNodes) + +def load_xml(filepath): + classes = [] + fn = open(filepath, 'r') + data = fn.read() + uixml = xml.dom.minidom.parseString(data).getElementsByTagName("ui")[0] + fn.close() + + def draw_xml(self, context): + node = self._xml_node.getElementsByTagName("draw")[0] + ui_xml_list(self.layout, node.childNodes) + + def draw_header_xml(self, context): + node = self._xml_node.getElementsByTagName("draw_header")[0] + ui_xml_list(self.layout, node.childNodes) + + for node in uixml.childNodes: + if node.nodeType not in (node.TEXT_NODE, node.COMMENT_NODE): + name = node.tagName + class_name = node.attributes["identifier"].value + + if name == "panel": + class_dict = { + "bl_label": node.attributes["label"].value, + "bl_region_type": node.attributes["region_type"].value, + "bl_space_type": node.attributes["space_type"].value, + "bl_context": node.attributes["context"].value, + "bl_default_closed": ((node.attributes["default_closed"].value == "true") if "default_closed" in node.attributes else False), + + "draw": draw_xml, + "_xml_node": node + } + + if node.getElementsByTagName("draw_header"): + class_dict["draw_header"] = draw_header_xml + + # will register instantly + class_new = type(class_name, (_bpy.types.Panel,), class_dict) + + elif name == "menu": + class_dict = { + "bl_label": node.attributes["label"].value, + + "draw": draw_xml, + "_xml_node": node + } + + # will register instantly + class_new = type(class_name, (_bpy.types.Menu,), class_dict) + + elif name == "header": + class_dict = { + "bl_label": node.attributes["label"].value, + "bl_space_type": node.attributes["space_type"].value, + + "draw": draw_xml, + "_xml_node": node + } + + # will register instantly + class_new = type(class_name, (_bpy.types.Header,), class_dict) + else: + raise Exception("invalid id found '%s': expected a value in ('header', 'panel', 'menu)'" % name) + + classes.append(class_new) + + + return classes diff --git a/release/scripts/modules/rigify/__init__.py b/release/scripts/modules/rigify/__init__.py index 095229016e9..f495406e8d8 100644 --- a/release/scripts/modules/rigify/__init__.py +++ b/release/scripts/modules/rigify/__init__.py @@ -537,7 +537,7 @@ def generate_test_all(context, GRAPH=False): base_name = os.path.splitext(bpy.data.filepath)[0] for obj, obj_new in new_objects: for obj in (obj, obj_new): - fn = base_name + "-" + bpy.utils.clean_name(obj.name) + fn = base_name + "-" + bpy.path.clean_name(obj.name) path_dot = fn + ".dot" path_png = fn + ".png" diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py index 3e8662c275f..63762855737 100644 --- a/release/scripts/modules/rna_prop_ui.py +++ b/release/scripts/modules/rna_prop_ui.py @@ -124,7 +124,7 @@ def draw(layout, context, context_member, use_edit=True): assign_props(prop, val_draw, key) -class PropertyPanel(bpy.types.Panel): +class PropertyPanel(): """ The subclass should have its own poll function and the variable '_context_path' MUST be set. @@ -132,133 +132,10 @@ class PropertyPanel(bpy.types.Panel): bl_label = "Custom Properties" bl_default_closed = True + @classmethod + def poll(cls, context): + bool(eval("context.%s" % cls._context_path)) + def draw(self, context): draw(self.layout, context, self._context_path) - -from bpy.props import * - - -rna_path = StringProperty(name="Property Edit", - description="Property data_path edit", maxlen=1024, default="", options={'HIDDEN'}) - -rna_value = StringProperty(name="Property Value", - description="Property value edit", maxlen=1024, default="") - -rna_property = StringProperty(name="Property Name", - description="Property name edit", maxlen=1024, default="") - -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): - '''Internal use (edit a property data_path)''' - bl_idname = "wm.properties_edit" - bl_label = "Edit Property" - - data_path = rna_path - property = rna_property - value = rna_value - min = rna_min - max = rna_max - description = StringProperty(name="Tip", default="") - - def execute(self, context): - data_path = self.properties.data_path - value = self.properties.value - prop = self.properties.property - prop_old = self._last_prop[0] - - try: - value_eval = eval(value) - except: - value_eval = value - - # First remove - item = eval("context.%s" % data_path) - - rna_idprop_ui_prop_clear(item, prop_old) - exec_str = "del item['%s']" % prop_old - # print(exec_str) - exec(exec_str) - - - # Reassign - exec_str = "item['%s'] = %s" % (prop, repr(value_eval)) - # print(exec_str) - exec(exec_str) - self._last_prop[:] = [prop] - - prop_type = type(item[prop]) - - prop_ui = rna_idprop_ui_prop_get(item, prop) - - if prop_type in (float, int): - - prop_ui['soft_min'] = prop_ui['min'] = prop_type(self.properties.min) - prop_ui['soft_max'] = prop_ui['max'] = prop_type(self.properties.max) - - prop_ui['description'] = self.properties.description - - return {'FINISHED'} - - def invoke(self, context, event): - - self._last_prop = [self.properties.property] - - item = eval("context.%s" % self.properties.data_path) - - # setup defaults - prop_ui = rna_idprop_ui_prop_get(item, self.properties.property, False) # dont create - if prop_ui: - self.properties.min = prop_ui.get("min", -1000000000) - self.properties.max = prop_ui.get("max", 1000000000) - self.properties.description = prop_ui.get("description", "") - - wm = context.manager - # This crashes, TODO - fix - #return wm.invoke_props_popup(self, event) - - wm.invoke_props_popup(self, event) - return {'RUNNING_MODAL'} - - -class WM_OT_properties_add(bpy.types.Operator): - '''Internal use (edit a property data_path)''' - bl_idname = "wm.properties_add" - bl_label = "Add Property" - - data_path = rna_path - - def execute(self, context): - item = eval("context.%s" % self.properties.data_path) - - def unique_name(names): - prop = 'prop' - prop_new = prop - i = 1 - while prop_new in names: - prop_new = prop + str(i) - i += 1 - - return prop_new - - property = unique_name(item.keys()) - - item[property] = 1.0 - return {'FINISHED'} - - -class WM_OT_properties_remove(bpy.types.Operator): - '''Internal use (edit a property data_path)''' - bl_idname = "wm.properties_remove" - bl_label = "Remove Property" - - data_path = rna_path - property = rna_property - - def execute(self, context): - item = eval("context.%s" % self.properties.data_path) - del item[self.properties.property] - return {'FINISHED'} diff --git a/release/scripts/op/add_armature_human.py b/release/scripts/op/add_armature_human.py index 164bbfb100b..5d6ec1f559f 100644 --- a/release/scripts/op/add_armature_human.py +++ b/release/scripts/op/add_armature_human.py @@ -606,12 +606,10 @@ menu_func = (lambda self, context: self.layout.operator(AddHuman.bl_idname, def register(): - bpy.types.register(AddHuman) bpy.types.INFO_MT_armature_add.append(menu_func) def unregister(): - bpy.types.unregister(AddHuman) bpy.types.INFO_MT_armature_add.remove(menu_func) if __name__ == "__main__": diff --git a/release/scripts/op/add_mesh_torus.py b/release/scripts/op/add_mesh_torus.py index 16bf4e1c92c..d64b92a8b19 100644 --- a/release/scripts/op/add_mesh_torus.py +++ b/release/scripts/op/add_mesh_torus.py @@ -137,12 +137,10 @@ def menu_func(self, context): def register(): - bpy.types.register(AddTorus) bpy.types.INFO_MT_mesh_add.append(menu_func) def unregister(): - bpy.types.unregister(AddTorus) bpy.types.INFO_MT_mesh_add.remove(menu_func) if __name__ == "__main__": diff --git a/release/scripts/op/console_python.py b/release/scripts/op/console_python.py index 2881e87fe00..cc0f3673e5c 100644 --- a/release/scripts/op/console_python.py +++ b/release/scripts/op/console_python.py @@ -44,16 +44,17 @@ def get_console(console_id): from code import InteractiveConsole consoles = getattr(get_console, "consoles", None) + hash_next = hash(bpy.context.manager) if consoles is None: consoles = get_console.consoles = {} + get_console.consoles_namespace_hash = hash_next else: # check if clearning the namespace is needed to avoid a memory leak. # the window manager is normally loaded with new blend files # so this is a reasonable way to deal with namespace clearing. # bpy.data hashing is reset by undo so cant be used. hash_prev = getattr(get_console, "consoles_namespace_hash", 0) - hash_next = hash(bpy.context.manager) if hash_prev != hash_next: get_console.consoles_namespace_hash = hash_next @@ -205,6 +206,10 @@ def autocomplete(context): scrollback = "" scrollback_error = "" + if _BPY_MAIN_OWN: + main_mod_back = sys.modules["__main__"] + sys.modules["__main__"] = console._bpy_main_mod + try: current_line = sc.history[-1] line = current_line.line @@ -223,6 +228,9 @@ def autocomplete(context): import traceback scrollback_error = traceback.format_exc() + if _BPY_MAIN_OWN: + sys.modules["__main__"] = main_mod_back + # Separate automplete output by command prompts if scrollback != '': bpy.ops.console.scrollback_append(text=sc.prompt + current_line.line, type='INPUT') diff --git a/release/scripts/op/fcurve_euler_filter.py b/release/scripts/op/fcurve_euler_filter.py index 39c226294ee..c6f5ddd12e4 100644 --- a/release/scripts/op/fcurve_euler_filter.py +++ b/release/scripts/op/fcurve_euler_filter.py @@ -48,7 +48,8 @@ class DiscontFilterOp(bpy.types.Operator): bl_idname = "graph.euler_filter" bl_label = "Filter out discontinuities in the active fcurves" - def poll(self, context): + @classmethod + def poll(cls, context): return context.active_object != None def execute(self, context): @@ -56,10 +57,10 @@ class DiscontFilterOp(bpy.types.Operator): return {'FINISHED'} def register(): - bpy.types.register(DiscontFilterOp) + pass def unregister(): - bpy.types.unregister(DiscontFilterOp) + pass if __name__ == "__main__": register() diff --git a/release/scripts/op/image.py b/release/scripts/op/image.py index be583012d7a..c393041d22c 100644 --- a/release/scripts/op/image.py +++ b/release/scripts/op/image.py @@ -56,13 +56,15 @@ class EditExternally(bpy.types.Operator): return image_editor def execute(self, context): + import os import subprocess - filepath = self.properties.filepath - image_editor = self._editor_guess(context) + filepath = bpy.path.abspath(self.properties.filepath) + + if not os.path.exists(filepath): + self.report('ERROR', "Image path '%s' not found." % filepath) + return {'CANCELLED'} - cmd = [] - cmd.extend(image_editor) - cmd.append(bpy.utils.expandpath(filepath)) + cmd = self._editor_guess(context) + [filepath] subprocess.Popen(cmd) @@ -91,7 +93,7 @@ class SaveDirty(bpy.types.Operator): unique_paths = set() for image in bpy.data.images: if image.dirty: - filepath = bpy.utils.expandpath(image.filepath) + filepath = bpy.path.abspath(image.filepath) if "\\" not in filepath and "/" not in filepath: self.report({'WARNING'}, "Invalid path: " + filepath) elif filepath in unique_paths: @@ -133,7 +135,7 @@ class ProjectEdit(bpy.types.Operator): filepath = os.path.basename(bpy.data.filepath) filepath = os.path.splitext(filepath)[0] - # filepath = bpy.utils.clean_name(filepath) # fixes <memory> rubbish, needs checking + # filepath = bpy.path.clean_name(filepath) # fixes <memory> rubbish, needs checking if filepath.startswith(".") or filepath == "": # TODO, have a way to check if the file is saved, assume .B25.blend @@ -145,12 +147,12 @@ class ProjectEdit(bpy.types.Operator): obj = context.object if obj: - filepath += "_" + bpy.utils.clean_name(obj.name) + filepath += "_" + bpy.path.clean_name(obj.name) filepath_final = filepath + "." + EXT i = 0 - while os.path.exists(bpy.utils.expandpath(filepath_final)): + while os.path.exists(bpy.path.abspath(filepath_final)): filepath_final = filepath + ("%.3d.%s" % (i, EXT)) i += 1 @@ -186,23 +188,12 @@ class ProjectApply(bpy.types.Operator): return {'FINISHED'} -classes = [ - EditExternally, - SaveDirty, - ProjectEdit, - ProjectApply] - def register(): - register = bpy.types.register - for cls in classes: - register(cls) - + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/op/mesh.py b/release/scripts/op/mesh.py index b63997b8eba..736ec41ba14 100644 --- a/release/scripts/op/mesh.py +++ b/release/scripts/op/mesh.py @@ -28,7 +28,8 @@ class MeshSelectInteriorFaces(bpy.types.Operator): bl_label = "Select Interior Faces" bl_options = {'REGISTER', 'UNDO'} - def poll(self, context): + @classmethod + def poll(cls, context): ob = context.active_object return (ob and ob.type == 'MESH') @@ -69,7 +70,8 @@ class MeshMirrorUV(bpy.types.Operator): bl_label = "Copy Mirrored UV coords" bl_options = {'REGISTER', 'UNDO'} - def poll(self, context): + @classmethod + def poll(cls, context): ob = context.active_object return (ob and ob.type == 'MESH') @@ -172,22 +174,12 @@ class MeshMirrorUV(bpy.types.Operator): return {'FINISHED'} -# Register the operator -classes = [ - MeshSelectInteriorFaces, - MeshMirrorUV] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/op/nla.py b/release/scripts/op/nla.py index ceb4621d643..bec5f5b3909 100644 --- a/release/scripts/op/nla.py +++ b/release/scripts/op/nla.py @@ -178,12 +178,12 @@ class BakeAction(bpy.types.Operator): def register(): - bpy.types.register(BakeAction) + pass # bpy.types.INFO_MT_mesh_add.append(menu_func) def unregister(): - bpy.types.unregister(BakeAction) + pass # bpy.types.INFO_MT_mesh_add.remove(menu_func) if __name__ == "__main__": diff --git a/release/scripts/op/object.py b/release/scripts/op/object.py index 403491bfa28..476db76735e 100644 --- a/release/scripts/op/object.py +++ b/release/scripts/op/object.py @@ -80,7 +80,8 @@ class SelectCamera(bpy.types.Operator): bl_label = "Select Camera" bl_options = {'REGISTER', 'UNDO'} - def poll(self, context): + @classmethod + def poll(cls, context): return context.scene.camera is not None def execute(self, context): @@ -109,7 +110,8 @@ class SelectHierarchy(bpy.types.Operator): extend = BoolProperty(name="Extend", description="Extend the existing selection", default=False) - def poll(self, context): + @classmethod + def poll(cls, context): return context.object def execute(self, context): @@ -167,7 +169,8 @@ class SubdivisionSet(bpy.types.Operator): relative = BoolProperty(name="Relative", description="Apply the subsurf level as an offset relative to the current level", default=False) - def poll(self, context): + @classmethod + def poll(cls, context): obs = context.selected_editable_objects return (obs is not None) @@ -379,7 +382,8 @@ class ShapeTransfer(bpy.types.Operator): return {'FINISHED'} - def poll(self, context): + @classmethod + def poll(cls, context): obj = context.active_object return (obj and obj.mode != 'EDIT') @@ -409,7 +413,8 @@ class JoinUVs(bpy.types.Operator): bl_idname = "object.join_uvs" bl_label = "Join as UVs" - def poll(self, context): + @classmethod + def poll(cls, context): obj = context.active_object return (obj and obj.type == 'MESH') @@ -467,7 +472,8 @@ class MakeDupliFace(bpy.types.Operator): bl_idname = "object.make_dupli_face" bl_label = "Make DupliFace" - def poll(self, context): + @classmethod + def poll(cls, context): obj = context.active_object return (obj and obj.type == 'MESH') @@ -558,28 +564,12 @@ class ClearAllRestrictRender(bpy.types.Operator): return {'FINISHED'} -classes = [ - SelectPattern, - SelectCamera, - SelectHierarchy, - SubdivisionSet, - ShapeTransfer, - JoinUVs, - IsolateTypeRender, - MakeDupliFace, - ClearAllRestrictRender] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register()
\ No newline at end of file diff --git a/release/scripts/op/object_align.py b/release/scripts/op/object_align.py index 6e5eef0fbc2..dc9b7c34523 100644 --- a/release/scripts/op/object_align.py +++ b/release/scripts/op/object_align.py @@ -263,7 +263,8 @@ class AlignObjects(bpy.types.Operator): align_z = BoolProperty(name="Align Z", description="Align in the Z axis", default=False) - def poll(self, context): + @classmethod + def poll(cls, context): return context.mode == 'OBJECT' def execute(self, context): @@ -286,12 +287,10 @@ def menu_func(self, context): def register(): - bpy.types.register(AlignObjects) bpy.types.VIEW3D_MT_transform.append(menu_func) def unregister(): - bpy.types.unregister(AlignObjects) bpy.types.VIEW3D_MT_transform.remove(menu_func) if __name__ == "__main__": diff --git a/release/scripts/op/object_randomize_transform.py b/release/scripts/op/object_randomize_transform.py index 89884b1767f..8c3f4eb6dfd 100644 --- a/release/scripts/op/object_randomize_transform.py +++ b/release/scripts/op/object_randomize_transform.py @@ -140,12 +140,10 @@ def menu_func(self, context): def register(): - bpy.types.register(RandomizeLocRotSize) bpy.types.VIEW3D_MT_transform.append(menu_func) def unregister(): - bpy.types.unregister(RandomizeLocRotSize) bpy.types.VIEW3D_MT_transform.remove(menu_func) if __name__ == "__main__": diff --git a/release/scripts/op/presets.py b/release/scripts/op/presets.py index f80c5e69ddd..2012ba913fb 100644 --- a/release/scripts/op/presets.py +++ b/release/scripts/op/presets.py @@ -22,7 +22,7 @@ import bpy import os -class AddPresetBase(bpy.types.Operator): +class AddPresetBase(): '''Base preset class, only for subclassing subclasses must define - preset_values @@ -91,7 +91,7 @@ class ExecutePreset(bpy.types.Operator): return {'FINISHED'} -class AddPresetRender(AddPresetBase): +class AddPresetRender(AddPresetBase, bpy.types.Operator): '''Add a Render Preset''' bl_idname = "render.preset_add" bl_label = "Add Render Preset" @@ -113,7 +113,7 @@ class AddPresetRender(AddPresetBase): preset_subdir = "render" -class AddPresetSSS(AddPresetBase): +class AddPresetSSS(AddPresetBase, bpy.types.Operator): '''Add a Subsurface Scattering Preset''' bl_idname = "material.sss_preset_add" bl_label = "Add SSS Preset" @@ -138,7 +138,7 @@ class AddPresetSSS(AddPresetBase): preset_subdir = "sss" -class AddPresetCloth(AddPresetBase): +class AddPresetCloth(AddPresetBase, bpy.types.Operator): '''Add a Cloth Preset''' bl_idname = "cloth.preset_add" bl_label = "Add Cloth Preset" @@ -156,7 +156,7 @@ class AddPresetCloth(AddPresetBase): preset_subdir = "cloth" -class AddPresetSunSky(AddPresetBase): +class AddPresetSunSky(AddPresetBase, bpy.types.Operator): '''Add a Sky & Atmosphere Preset''' bl_idname = "lamp.sunsky_preset_add" bl_label = "Add Sunsky Preset" @@ -181,7 +181,7 @@ class AddPresetSunSky(AddPresetBase): preset_subdir = "sunsky" -class AddPresetInteraction(AddPresetBase): +class AddPresetInteraction(AddPresetBase, bpy.types.Operator): '''Add an Application Interaction Preset''' bl_idname = "wm.interaction_preset_add" bl_label = "Add Interaction Preset" @@ -203,25 +203,12 @@ class AddPresetInteraction(AddPresetBase): preset_subdir = "interaction" -classes = [ - ExecutePreset, - AddPresetRender, - AddPresetSSS, - AddPresetCloth, - AddPresetSunSky, - AddPresetInteraction] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/op/screen_play_rendered_anim.py b/release/scripts/op/screen_play_rendered_anim.py index 2ecd445df1d..8775a144b2d 100644 --- a/release/scripts/op/screen_play_rendered_anim.py +++ b/release/scripts/op/screen_play_rendered_anim.py @@ -79,7 +79,7 @@ class PlayRenderedAnim(bpy.types.Operator): preset = prefs.filepaths.animation_player_preset player_path = prefs.filepaths.animation_player - file_path = bpy.utils.expandpath(rd.output_path) + file_path = bpy.path.abspath(rd.output_path) is_movie = rd.is_movie_format # try and guess a command line if it doesn't exist @@ -105,7 +105,7 @@ class PlayRenderedAnim(bpy.types.Operator): # works for movies and images file = rd.frame_path(frame=scene.frame_start) - file = bpy.utils.expandpath(file) # expand '//' + file = bpy.path.abspath(file) # expand '//' cmd = [player_path] # extra options, fps controls etc. @@ -144,11 +144,11 @@ class PlayRenderedAnim(bpy.types.Operator): def register(): - bpy.types.register(PlayRenderedAnim) + pass def unregister(): - bpy.types.unregister(PlayRenderedAnim) + pass if __name__ == "__main__": register() diff --git a/release/scripts/op/sequencer.py b/release/scripts/op/sequencer.py index 432486b70cf..cbb7d00e659 100644 --- a/release/scripts/op/sequencer.py +++ b/release/scripts/op/sequencer.py @@ -30,7 +30,8 @@ class SequencerCrossfadeSounds(bpy.types.Operator): bl_label = "Crossfade sounds" bl_options = {'REGISTER', 'UNDO'} - def poll(self, context): + @classmethod + def poll(cls, context): if context.scene and context.scene.sequence_editor and context.scene.sequence_editor.active_strip: return context.scene.sequence_editor.active_strip.type == 'SOUND' else: @@ -83,7 +84,8 @@ class SequencerCutMulticam(bpy.types.Operator): camera = IntProperty(name="Camera", default=1, min=1, max=32, soft_min=1, soft_max=32) - def poll(self, context): + @classmethod + def poll(cls, context): if context.scene and context.scene.sequence_editor and context.scene.sequence_editor.active_strip: return context.scene.sequence_editor.active_strip.type == 'MULTICAM' else: @@ -117,7 +119,8 @@ class SequencerDeinterlaceSelectedMovies(bpy.types.Operator): bl_label = "Deinterlace Movies" bl_options = {'REGISTER', 'UNDO'} - def poll(self, context): + @classmethod + def poll(cls, context): if context.scene and context.scene.sequence_editor: return True else: @@ -132,19 +135,11 @@ class SequencerDeinterlaceSelectedMovies(bpy.types.Operator): def register(): - register = bpy.types.register - - register(SequencerCrossfadeSounds) - register(SequencerCutMulticam) - register(SequencerDeinterlaceSelectedMovies) + pass def unregister(): - unregister = bpy.types.unregister - - unregister(SequencerCrossfadeSounds) - unregister(SequencerCutMulticam) - unregister(SequencerDeinterlaceSelectedMovies) + pass if __name__ == "__main__": diff --git a/release/scripts/op/uv.py b/release/scripts/op/uv.py index a7abd475b8d..7d677181858 100644 --- a/release/scripts/op/uv.py +++ b/release/scripts/op/uv.py @@ -39,7 +39,8 @@ class ExportUVLayout(bpy.types.Operator): description="File format to export the UV layout to", default='SVG') - def poll(self, context): + @classmethod + def poll(cls, context): obj = context.active_object return (obj and obj.type == 'MESH') @@ -113,7 +114,9 @@ class ExportUVLayout(bpy.types.Operator): mode = self.properties.mode - file = open(self.properties.filepath, "w") + filepath = self.properties.filepath + filepath = bpy.path.ensure_ext(filepath, "." + mode.lower()) + file = open(filepath, "w") fw = file.write if mode == 'SVG': @@ -216,12 +219,10 @@ def menu_func(self, context): def register(): - bpy.types.register(ExportUVLayout) bpy.types.IMAGE_MT_uvs.append(menu_func) def unregister(): - bpy.types.unregister(ExportUVLayout) bpy.types.IMAGE_MT_uvs.remove(menu_func) if __name__ == "__main__": diff --git a/release/scripts/op/uvcalc_follow_active.py b/release/scripts/op/uvcalc_follow_active.py index 6466d48a9fe..f02ee497999 100644 --- a/release/scripts/op/uvcalc_follow_active.py +++ b/release/scripts/op/uvcalc_follow_active.py @@ -249,7 +249,8 @@ class FollowActiveQuads(bpy.types.Operator): description="Method to space UV edge loops", default="LENGTH") - def poll(self, context): + @classmethod + def poll(cls, context): obj = context.active_object return (obj is not None and obj.type == 'MESH') @@ -263,12 +264,10 @@ menu_func = (lambda self, context: self.layout.operator(FollowActiveQuads.bl_idn def register(): - bpy.types.register(FollowActiveQuads) bpy.types.VIEW3D_MT_uv_map.append(menu_func) def unregister(): - bpy.types.unregister(FollowActiveQuads) bpy.types.VIEW3D_MT_uv_map.remove(menu_func) if __name__ == "__main__": diff --git a/release/scripts/op/uvcalc_smart_project.py b/release/scripts/op/uvcalc_smart_project.py index 78cef26f78c..fbda1955013 100644 --- a/release/scripts/op/uvcalc_smart_project.py +++ b/release/scripts/op/uvcalc_smart_project.py @@ -1124,7 +1124,8 @@ class SmartProject(bpy.types.Operator): description="Margin to reduce bleed from adjacent islands.", default=0.0, min=0.0, max=1.0) - def poll(self, context): + @classmethod + def poll(cls, context): return context.active_object != None def execute(self, context): @@ -1138,12 +1139,10 @@ menu_func = (lambda self, context: self.layout.operator(SmartProject.bl_idname, def register(): - bpy.types.register(SmartProject) bpy.types.VIEW3D_MT_uv_map.append(menu_func) def unregister(): - bpy.types.unregister(SmartProject) bpy.types.VIEW3D_MT_uv_map.remove(menu_func) if __name__ == "__main__": diff --git a/release/scripts/op/vertexpaint_dirt.py b/release/scripts/op/vertexpaint_dirt.py index 63a3aa3896b..21c19d528cc 100644 --- a/release/scripts/op/vertexpaint_dirt.py +++ b/release/scripts/op/vertexpaint_dirt.py @@ -180,11 +180,11 @@ class VertexPaintDirt(bpy.types.Operator): def register(): - bpy.types.register(VertexPaintDirt) + pass def unregister(): - bpy.types.unregister(VertexPaintDirt) + pass if __name__ == "__main__": register() diff --git a/release/scripts/op/wm.py b/release/scripts/op/wm.py index ed77f32ff6d..cc35a0ab3dd 100644 --- a/release/scripts/op/wm.py +++ b/release/scripts/op/wm.py @@ -21,7 +21,7 @@ import bpy from bpy.props import * - +from rna_prop_ui import rna_idprop_ui_prop_get, rna_idprop_ui_prop_clear class MESH_OT_delete_edgeloop(bpy.types.Operator): '''Delete an edge loop by merging the faces on each side to a single face loop''' @@ -325,6 +325,42 @@ class WM_OT_context_cycle_enum(bpy.types.Operator): exec("context.%s=advance_enum" % self.properties.data_path) return {'FINISHED'} + +class WM_OT_context_set_id(bpy.types.Operator): + '''Toggle a context value.''' + bl_idname = "wm.context_set_id" + bl_label = "Set Library ID" + bl_options = {'UNDO'} + + data_path = rna_path_prop + value = StringProperty(name="Value", + description="Assign value", maxlen=1024, default="") + + def execute(self, context): + value = self.properties.value + data_path = self.properties.data_path + + # match the pointer type from the target property to bpy.data.* + # so we lookup the correct list. + data_path_base, data_path_prop = data_path.rsplit(".", 1) + data_prop_rna = eval("context.%s" % data_path_base).rna_type.properties[data_path_prop] + data_prop_rna_type = data_prop_rna.fixed_type + + id_iter = None + + for prop in bpy.data.rna_type.properties: + if prop.rna_type.identifier == "CollectionProperty": + if prop.fixed_type == data_prop_rna_type: + id_iter = prop.identifier + break + + if id_iter: + value_id = getattr(bpy.data, id_iter).get(value) + exec("context.%s=value_id" % data_path) + + return {'FINISHED'} + + doc_id = StringProperty(name="Doc ID", description="", maxlen=1024, default="", options={'HIDDEN'}) @@ -442,7 +478,7 @@ class WM_OT_path_open(bpy.types.Operator): import os import subprocess - filepath = bpy.utils.expandpath(self.properties.filepath) + filepath = bpy.path.abspath(self.properties.filepath) filepath = os.path.normpath(filepath) if not os.path.exists(filepath): @@ -576,46 +612,139 @@ class WM_OT_doc_edit(bpy.types.Operator): return wm.invoke_props_dialog(self, width=600) -import rna_prop_ui +from bpy.props import * + + +rna_path = StringProperty(name="Property Edit", + description="Property data_path edit", maxlen=1024, default="", options={'HIDDEN'}) + +rna_value = StringProperty(name="Property Value", + description="Property value edit", maxlen=1024, default="") + +rna_property = StringProperty(name="Property Name", + description="Property name edit", maxlen=1024, default="") + +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): + '''Internal use (edit a property data_path)''' + bl_idname = "wm.properties_edit" + bl_label = "Edit Property" + + data_path = rna_path + property = rna_property + value = rna_value + min = rna_min + max = rna_max + description = StringProperty(name="Tip", default="") + + def execute(self, context): + data_path = self.properties.data_path + value = self.properties.value + prop = self.properties.property + prop_old = self._last_prop[0] + + try: + value_eval = eval(value) + except: + value_eval = value + + # First remove + item = eval("context.%s" % data_path) + + rna_idprop_ui_prop_clear(item, prop_old) + exec_str = "del item['%s']" % prop_old + # print(exec_str) + exec(exec_str) + + + # Reassign + exec_str = "item['%s'] = %s" % (prop, repr(value_eval)) + # print(exec_str) + exec(exec_str) + self._last_prop[:] = [prop] + + prop_type = type(item[prop]) + + prop_ui = rna_idprop_ui_prop_get(item, prop) + + if prop_type in (float, int): + + prop_ui['soft_min'] = prop_ui['min'] = prop_type(self.properties.min) + prop_ui['soft_max'] = prop_ui['max'] = prop_type(self.properties.max) + + prop_ui['description'] = self.properties.description + + return {'FINISHED'} + + def invoke(self, context, event): + + self._last_prop = [self.properties.property] + + item = eval("context.%s" % self.properties.data_path) + + # setup defaults + prop_ui = rna_idprop_ui_prop_get(item, self.properties.property, False) # dont create + if prop_ui: + self.properties.min = prop_ui.get("min", -1000000000) + self.properties.max = prop_ui.get("max", 1000000000) + self.properties.description = prop_ui.get("description", "") + + wm = context.manager + # This crashes, TODO - fix + #return wm.invoke_props_popup(self, event) + + wm.invoke_props_popup(self, event) + return {'RUNNING_MODAL'} + + +class WM_OT_properties_add(bpy.types.Operator): + '''Internal use (edit a property data_path)''' + bl_idname = "wm.properties_add" + bl_label = "Add Property" -classes = [ - MESH_OT_delete_edgeloop, + data_path = rna_path - WM_OT_context_set_boolean, - WM_OT_context_set_int, - WM_OT_context_scale_int, - WM_OT_context_set_float, - WM_OT_context_set_string, - WM_OT_context_set_enum, - WM_OT_context_set_value, - WM_OT_context_toggle, - WM_OT_context_toggle_enum, - WM_OT_context_cycle_enum, - WM_OT_context_cycle_int, - WM_OT_context_modal_mouse, + def execute(self, context): + item = eval("context.%s" % self.properties.data_path) + + def unique_name(names): + prop = 'prop' + prop_new = prop + i = 1 + while prop_new in names: + prop_new = prop + str(i) + i += 1 + + return prop_new + + property = unique_name(item.keys()) + + item[property] = 1.0 + return {'FINISHED'} - WM_OT_url_open, - WM_OT_path_open, - WM_OT_doc_view, - WM_OT_doc_edit, +class WM_OT_properties_remove(bpy.types.Operator): + '''Internal use (edit a property data_path)''' + bl_idname = "wm.properties_remove" + bl_label = "Remove Property" - # experemental! - rna_prop_ui.WM_OT_properties_edit, - rna_prop_ui.WM_OT_properties_add, - rna_prop_ui.WM_OT_properties_remove] + data_path = rna_path + property = rna_property + def execute(self, context): + item = eval("context.%s" % self.properties.data_path) + del item[self.properties.property] + return {'FINISHED'} def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/templates/operator.py b/release/scripts/templates/operator.py index e20b92c9b6a..5a525784b51 100644 --- a/release/scripts/templates/operator.py +++ b/release/scripts/templates/operator.py @@ -23,7 +23,8 @@ class ExportSomeData(bpy.types.Operator): description="Choose between two items", default='OPT_A') - def poll(self, context): + @classmethod + def poll(cls, context): return context.active_object != None def execute(self, context): @@ -54,9 +55,6 @@ class ExportSomeData(bpy.types.Operator): return self.execute(context) - -bpy.types.register(ExportSomeData) - # Only needed if you want to add into a dynamic menu menu_func = lambda self, context: self.layout.operator("export.some_data", text="Example Exporter...") bpy.types.INFO_MT_file_export.append(menu_func) diff --git a/release/scripts/templates/operator_modal.py b/release/scripts/templates/operator_modal.py index e029d91a7fa..0c5db47674b 100644 --- a/release/scripts/templates/operator_modal.py +++ b/release/scripts/templates/operator_modal.py @@ -34,7 +34,5 @@ class ModalOperator(bpy.types.Operator): return {'CANCELLED'} -bpy.types.register(ModalOperator) - if __name__ == "__main__": bpy.ops.object.modal_operator() diff --git a/release/scripts/templates/operator_modal_draw.py b/release/scripts/templates/operator_modal_draw.py index 1f24672346b..56ffb95f555 100644 --- a/release/scripts/templates/operator_modal_draw.py +++ b/release/scripts/templates/operator_modal_draw.py @@ -64,15 +64,3 @@ class ModalDrawOperator(bpy.types.Operator): else: self.report({'WARNING'}, "View3D not found, cannot run operator") return {'CANCELLED'} - - -def register(): - bpy.types.register(ModalDrawOperator) - - -def unregister(): - bpy.types.unregister(ModalDrawOperator) - - -if __name__ == "__main__": - register() diff --git a/release/scripts/templates/operator_modal_view3d.py b/release/scripts/templates/operator_modal_view3d.py index da019c2b653..9b49fd947ad 100644 --- a/release/scripts/templates/operator_modal_view3d.py +++ b/release/scripts/templates/operator_modal_view3d.py @@ -51,6 +51,3 @@ class ViewOperator(bpy.types.Operator): else: self.report({'WARNING'}, "Active space must be a View3d") return {'CANCELLED'} - - -bpy.types.register(ViewOperator) diff --git a/release/scripts/templates/operator_simple.py b/release/scripts/templates/operator_simple.py index 985a628c2d0..853bfa666eb 100644 --- a/release/scripts/templates/operator_simple.py +++ b/release/scripts/templates/operator_simple.py @@ -9,18 +9,14 @@ class SimpleOperator(bpy.types.Operator): bl_idname = "object.simple_operator" bl_label = "Simple Object Operator" - def poll(self, context): + @classmethod + def poll(cls, context): return context.active_object != None def execute(self, context): main(context) return {'FINISHED'} -def register(): - bpy.types.register(SimpleOperator) - -def unregister(): - bpy.types.unregister(SimpleOperator) if __name__ == "__main__": - register() + bpy.ops.object.simple_operator() diff --git a/release/scripts/templates/operator_uv.py b/release/scripts/templates/operator_uv.py index 9327de33312..46ce15f090d 100644 --- a/release/scripts/templates/operator_uv.py +++ b/release/scripts/templates/operator_uv.py @@ -24,12 +24,14 @@ def main(context): if is_editmode: bpy.ops.object.mode_set(mode='EDIT', toggle=False) + class UvOperator(bpy.types.Operator): - '''''' + '''UV Operator description''' bl_idname = "uv.simple_operator" bl_label = "Simple UV Operator" - def poll(self, context): + @classmethod + def poll(cls, context): obj = context.active_object return (obj and obj.type == 'MESH') @@ -37,7 +39,6 @@ class UvOperator(bpy.types.Operator): main(context) return {'FINISHED'} -bpy.types.register(UvOperator) if __name__ == "__main__": bpy.ops.uv.simple_operator() diff --git a/release/scripts/templates/panel_simple.py b/release/scripts/templates/panel_simple.py index aac4b6e715e..7c73e58a3e5 100644 --- a/release/scripts/templates/panel_simple.py +++ b/release/scripts/templates/panel_simple.py @@ -18,5 +18,3 @@ class OBJECT_PT_hello(bpy.types.Panel): row.label(text="Active object is: " + obj.name) row = layout.row() row.prop(obj, "name") - -bpy.types.register(OBJECT_PT_hello) diff --git a/release/scripts/ui/properties_animviz.py b/release/scripts/ui/properties_animviz.py index 9eb046cc2c8..b337485ae10 100644 --- a/release/scripts/ui/properties_animviz.py +++ b/release/scripts/ui/properties_animviz.py @@ -19,27 +19,22 @@ # <pep8 compliant> import bpy -narrowui = bpy.context.user_preferences.view.properties_width_check -################################################ # Generic Panels (Independent of DataType) -class MotionPathButtonsPanel(bpy.types.Panel): +class MotionPathButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_label = "Motion Paths" bl_default_closed = True - def draw_settings(self, context, avs, wide_ui, bones=False): + def draw_settings(self, context, avs, bones=False): layout = self.layout mps = avs.motion_paths - if wide_ui: - layout.prop(mps, "type", expand=True) - else: - layout.prop(mps, "type", text="") + layout.prop(mps, "type", expand=True) split = layout.split() @@ -56,8 +51,7 @@ class MotionPathButtonsPanel(bpy.types.Panel): if bones: col.row().prop(mps, "bake_location", expand=True) - if wide_ui: - col = split.column() + col = split.column() col.label(text="Display:") col.prop(mps, "show_frame_numbers", text="Frame Numbers") col.prop(mps, "highlight_keyframes", text="Keyframes") @@ -67,7 +61,7 @@ class MotionPathButtonsPanel(bpy.types.Panel): # FIXME: this panel still needs to be ported so that it will work correctly with animviz -class OnionSkinButtonsPanel(bpy.types.Panel): +class OnionSkinButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_label = "Onion Skinning" @@ -77,12 +71,8 @@ class OnionSkinButtonsPanel(bpy.types.Panel): layout = self.layout arm = context.armature - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(arm, "ghost_type", expand=True) - else: - layout.prop(arm, "ghost_type", text="") + layout.prop(arm, "ghost_type", expand=True) split = layout.split() @@ -97,124 +87,23 @@ class OnionSkinButtonsPanel(bpy.types.Panel): sub.prop(arm, "ghost_step", text="Range") sub.prop(arm, "ghost_size", text="Step") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Display:") col.prop(arm, "ghost_only_selected", text="Selected Only") -################################################ -# Specific Panels for DataTypes - - -class OBJECT_PT_motion_paths(MotionPathButtonsPanel): - #bl_label = "Object Motion Paths" - bl_context = "object" - - def poll(self, context): - return (context.object) - - def draw(self, context): - layout = self.layout - - ob = context.object - wide_ui = context.region.width > narrowui - - self.draw_settings(context, ob.animation_visualisation, wide_ui) - - layout.separator() - - split = layout.split() - - col = split.column() - col.operator("object.paths_calculate", text="Calculate Paths") - - if wide_ui: - col = split.column() - col.operator("object.paths_clear", text="Clear Paths") - - -class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel): - #bl_label = "Object Onion Skinning" - bl_context = "object" - - def poll(self, context): - return (context.object) - - def draw(self, context): - layout = self.layout - - ob = context.object - wide_ui = context.region.width > narrowui - - self.draw_settings(context, ob.animation_visualisation, wide_ui) -class DATA_PT_motion_paths(MotionPathButtonsPanel): - #bl_label = "Bones Motion Paths" - bl_context = "data" - - def poll(self, context): - # XXX: include posemode check? - return (context.object) and (context.armature) - - def draw(self, context): - layout = self.layout - - ob = context.object - wide_ui = context.region.width > narrowui - - self.draw_settings(context, ob.pose.animation_visualisation, wide_ui, bones=True) - - layout.separator() - - split = layout.split() - - col = split.column() - col.operator("pose.paths_calculate", text="Calculate Paths") - - if wide_ui: - col = split.column() - col.operator("pose.paths_clear", text="Clear Paths") - - -class DATA_PT_onion_skinning(OnionSkinButtonsPanel): - #bl_label = "Bones Onion Skinning" - bl_context = "data" - - def poll(self, context): - # XXX: include posemode check? - return (context.object) and (context.armature) - - def draw(self, context): - layout = self.layout - - ob = context.object - wide_ui = context.region.width > narrowui - - self.draw_settings(context, ob.pose.animation_visualisation, wide_ui, bones=True) - # NOTE: -# The specialised panel types defined here (i.e. OBJECT_PT_*, etc.) -# aren't registered here, but are rather imported to (and registered) -# in the files defining the contexts where they reside. Otherwise, -# these panels appear at the top of the lists by default. -# -# However, we keep these empty register funcs here just in case -# something will need them again one day, and also to make -# it easier to maintain these scripts. -classes = [] +# The specialised panel types are derived in their respective UI modules + def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_data_armature.py b/release/scripts/ui/properties_data_armature.py index 31ede4adfb5..3d8f2cdc092 100644 --- a/release/scripts/ui/properties_data_armature.py +++ b/release/scripts/ui/properties_data_armature.py @@ -20,19 +20,18 @@ import bpy from rna_prop_ui import PropertyPanel -narrowui = bpy.context.user_preferences.view.properties_width_check - -class DataButtonsPanel(bpy.types.Panel): +class ArmatureButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "data" - def poll(self, context): + @classmethod + def poll(cls, context): return context.armature -class DATA_PT_context_arm(DataButtonsPanel): +class DATA_PT_context_arm(ArmatureButtonsPanel, bpy.types.Panel): bl_label = "" bl_show_header = False @@ -42,37 +41,30 @@ class DATA_PT_context_arm(DataButtonsPanel): ob = context.object arm = context.armature space = context.space_data - wide_ui = context.region.width > narrowui - if wide_ui: - split = layout.split(percentage=0.65) - if ob: - split.template_ID(ob, "data") - split.separator() - elif arm: - split.template_ID(space, "pin_id") - split.separator() - else: - layout.template_ID(ob, "data") + split = layout.split(percentage=0.65) + if ob: + split.template_ID(ob, "data") + split.separator() + elif arm: + split.template_ID(space, "pin_id") + split.separator() -class DATA_PT_custom_props_arm(DataButtonsPanel, PropertyPanel): +class DATA_PT_custom_props_arm(ArmatureButtonsPanel, PropertyPanel, bpy.types.Panel): + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "object.data" -class DATA_PT_skeleton(DataButtonsPanel): +class DATA_PT_skeleton(ArmatureButtonsPanel, bpy.types.Panel): bl_label = "Skeleton" def draw(self, context): layout = self.layout arm = context.armature - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(arm, "pose_position", expand=True) - else: - layout.prop(arm, "pose_position", text="") + layout.prop(arm, "pose_position", expand=True) split = layout.split() @@ -90,12 +82,11 @@ class DATA_PT_skeleton(DataButtonsPanel): col.prop(arm, "deform_vertexgroups", text="Vertex Groups") col.prop(arm, "deform_envelope", text="Envelopes") - if wide_ui: - col = split.column() + col = split.column() col.prop(arm, "deform_quaternion", text="Quaternion") -class DATA_PT_display(DataButtonsPanel): +class DATA_PT_display(ArmatureButtonsPanel, bpy.types.Panel): bl_label = "Display" def draw(self, context): @@ -103,12 +94,8 @@ class DATA_PT_display(DataButtonsPanel): ob = context.object arm = context.armature - wide_ui = context.region.width > narrowui - if wide_ui: - layout.row().prop(arm, "drawtype", expand=True) - else: - layout.row().prop(arm, "drawtype", text="") + layout.row().prop(arm, "drawtype", expand=True) split = layout.split() @@ -117,17 +104,17 @@ class DATA_PT_display(DataButtonsPanel): col.prop(arm, "draw_axes", text="Axes") col.prop(arm, "draw_custom_bone_shapes", text="Shapes") - if wide_ui: - col = split.column() + col = split.column() col.prop(arm, "draw_group_colors", text="Colors") col.prop(ob, "x_ray", text="X-Ray") col.prop(arm, "delay_deform", text="Delay Refresh") -class DATA_PT_bone_groups(DataButtonsPanel): +class DATA_PT_bone_groups(ArmatureButtonsPanel, bpy.types.Panel): bl_label = "Bone Groups" - def poll(self, context): + @classmethod + def poll(cls, context): return (context.object and context.object.type == 'ARMATURE' and context.object.pose) def draw(self, context): @@ -135,7 +122,6 @@ class DATA_PT_bone_groups(DataButtonsPanel): ob = context.object pose = ob.pose - wide_ui = context.region.width > narrowui row = layout.row() row.template_list(pose, "bone_groups", pose, "active_bone_group_index", rows=2) @@ -157,8 +143,7 @@ class DATA_PT_bone_groups(DataButtonsPanel): col = split.column() col.prop(group, "color_set") if group.color_set: - if wide_ui: - col = split.column() + col = split.column() col.template_triColorSet(group, "colors") row = layout.row() @@ -174,19 +159,15 @@ class DATA_PT_bone_groups(DataButtonsPanel): # TODO: this panel will soon be depreceated too -class DATA_PT_ghost(DataButtonsPanel): +class DATA_PT_ghost(ArmatureButtonsPanel, bpy.types.Panel): bl_label = "Ghost" def draw(self, context): layout = self.layout arm = context.armature - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(arm, "ghost_type", expand=True) - else: - layout.prop(arm, "ghost_type", text="") + layout.prop(arm, "ghost_type", expand=True) split = layout.split() @@ -201,17 +182,17 @@ class DATA_PT_ghost(DataButtonsPanel): sub.prop(arm, "ghost_step", text="Range") sub.prop(arm, "ghost_size", text="Step") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Display:") col.prop(arm, "ghost_only_selected", text="Selected Only") -class DATA_PT_iksolver_itasc(DataButtonsPanel): +class DATA_PT_iksolver_itasc(ArmatureButtonsPanel, bpy.types.Panel): bl_label = "iTaSC parameters" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): ob = context.object return (ob and ob.pose) @@ -221,7 +202,6 @@ class DATA_PT_iksolver_itasc(DataButtonsPanel): ob = context.object itasc = ob.pose.ik_param - wide_ui = (context.region.width > narrowui) row = layout.row() row.prop(ob.pose, "ik_solver") @@ -238,8 +218,7 @@ class DATA_PT_iksolver_itasc(DataButtonsPanel): col = split.column() col.prop(itasc, "precision") - if wide_ui: - col = split.column() + col = split.column() col.prop(itasc, "num_iter") @@ -261,33 +240,57 @@ class DATA_PT_iksolver_itasc(DataButtonsPanel): row.prop(itasc, "dampmax", text="Damp", slider=True) row.prop(itasc, "dampeps", text="Eps", slider=True) -# import generic panels from other files -from properties_animviz import DATA_PT_motion_paths, DATA_PT_onion_skinning +from properties_animviz import MotionPathButtonsPanel, OnionSkinButtonsPanel + +class DATA_PT_motion_paths(MotionPathButtonsPanel, bpy.types.Panel): + #bl_label = "Bones Motion Paths" + bl_context = "data" + + @classmethod + def poll(cls, context): + # XXX: include posemode check? + return (context.object) and (context.armature) + + def draw(self, context): + layout = self.layout + + ob = context.object + + self.draw_settings(context, ob.pose.animation_visualisation, bones=True) + + layout.separator() + + split = layout.split() + + col = split.column() + col.operator("pose.paths_calculate", text="Calculate Paths") + + col = split.column() + col.operator("pose.paths_clear", text="Clear Paths") + + +class DATA_PT_onion_skinning(OnionSkinButtonsPanel): #, bpy.types.Panel): # inherit from panel when ready + #bl_label = "Bones Onion Skinning" + bl_context = "data" -classes = [ - DATA_PT_context_arm, - DATA_PT_skeleton, - DATA_PT_display, - DATA_PT_bone_groups, - DATA_PT_ghost, - DATA_PT_iksolver_itasc, + @classmethod + def poll(cls, context): + # XXX: include posemode check? + return (context.object) and (context.armature) - DATA_PT_motion_paths, - #DATA_PT_onion_skinning, + def draw(self, context): + layout = self.layout - DATA_PT_custom_props_arm] + ob = context.object + self.draw_settings(context, ob.pose.animation_visualisation, bones=True) def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_data_armature_rigify.py b/release/scripts/ui/properties_data_armature_rigify.py index 5af676d5aa8..070f1fb7678 100644 --- a/release/scripts/ui/properties_data_armature_rigify.py +++ b/release/scripts/ui/properties_data_armature_rigify.py @@ -19,8 +19,6 @@ # <pep8 compliant> import bpy -narrowui = bpy.context.user_preferences.view.properties_width_check - class PoseTemplateSettings(bpy.types.IDPropertyGroup): pass @@ -44,7 +42,8 @@ class DATA_PT_template(bpy.types.Panel): templates = [] - def poll(self, context): + @classmethod + def poll(cls, context): if not context.armature: return False obj = context.object @@ -212,7 +211,7 @@ class Graph(bpy.types.Operator): import bpy reload(graphviz_export) obj = bpy.context.object - path = os.path.splitext(bpy.data.filepath)[0] + "-" + bpy.utils.clean_name(obj.name) + path = os.path.splitext(bpy.data.filepath)[0] + "-" + bpy.path.clean_name(obj.name) path_dot = path + ".dot" path_png = path + ".png" saved = graphviz_export.graph_armature(bpy.context.object, path_dot, CONSTRAINTS=False, DRIVERS=False) @@ -249,7 +248,7 @@ class AsScript(bpy.types.Operator): def invoke(self, context, event): import os obj = context.object - self.properties.filepath = os.path.splitext(bpy.data.filepath)[0] + "-" + bpy.utils.clean_name(obj.name) + ".py" + self.properties.filepath = os.path.splitext(bpy.data.filepath)[0] + "-" + bpy.path.clean_name(obj.name) + ".py" wm = context.manager wm.add_fileselect(self) return {'RUNNING_MODAL'} @@ -262,7 +261,8 @@ class ActiveAssign(bpy.types.Operator): bl_idname = "pose.metarig_assign" bl_label = "Assign to the active posebone" - def poll(self, context): + @classmethod + def poll(cls, context): bone = context.active_pose_bone return bool(bone and bone.id_data.mode == 'POSE') @@ -280,7 +280,8 @@ class ActiveClear(bpy.types.Operator): bl_idname = "pose.metarig_clear" bl_label = "Metarig Clear Type" - def poll(self, context): + @classmethod + def poll(cls, context): bone = context.active_pose_bone return bool(bone and bone.id_data.mode == 'POSE') @@ -304,36 +305,14 @@ class INFO_MT_armature_metarig_add(bpy.types.Menu): layout.operator_context = 'INVOKE_REGION_WIN' for submodule_type in rigify.get_submodule_types(): - text = bpy.utils.display_name(submodule_type) + text = bpy.path.display_name(submodule_type) layout.operator("pose.metarig_sample_add", text=text, icon='OUTLINER_OB_ARMATURE').metarig_type = submodule_type -classes = [ - DATA_PT_template, - - PoseTemplateSettings, - PoseTemplate, - - Reload, - Generate, - Validate, - Sample, - Graph, - AsScript, - - ActiveAssign, - ActiveClear, - - INFO_MT_armature_metarig_add] - menu_func = (lambda self, context: self.layout.menu("INFO_MT_armature_metarig_add", icon='OUTLINER_OB_ARMATURE')) import space_info # ensure the menu is loaded first def register(): - register = bpy.types.register - for cls in classes: - register(cls) - PoseTemplate.StringProperty(attr="name", name="Name of the slave", description="", @@ -361,10 +340,6 @@ def register(): def unregister(): bpy.types.Scene.RemoveProperty("pose_templates") - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) - space_info.INFO_MT_armature_add.remove(menu_func) if __name__ == "__main__": diff --git a/release/scripts/ui/properties_data_bone.py b/release/scripts/ui/properties_data_bone.py index a4be7b31042..1296ccd7e70 100644 --- a/release/scripts/ui/properties_data_bone.py +++ b/release/scripts/ui/properties_data_bone.py @@ -20,19 +20,18 @@ import bpy from rna_prop_ui import PropertyPanel -narrowui = bpy.context.user_preferences.view.properties_width_check - -class BoneButtonsPanel(bpy.types.Panel): +class BoneButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "bone" - def poll(self, context): + @classmethod + def poll(cls, context): return (context.bone or context.edit_bone) -class BONE_PT_context_bone(BoneButtonsPanel): +class BONE_PT_context_bone(BoneButtonsPanel, bpy.types.Panel): bl_label = "" bl_show_header = False @@ -48,7 +47,8 @@ class BONE_PT_context_bone(BoneButtonsPanel): row.prop(bone, "name", text="") -class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel): +class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel, bpy.types.Panel): + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @property def _context_path(self): @@ -59,7 +59,7 @@ class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel): return "active_bone" -class BONE_PT_transform(BoneButtonsPanel): +class BONE_PT_transform(BoneButtonsPanel, bpy.types.Panel): bl_label = "Transform" def draw(self, context): @@ -67,72 +67,50 @@ class BONE_PT_transform(BoneButtonsPanel): ob = context.object bone = context.bone - wide_ui = context.region.width > narrowui if not bone: bone = context.edit_bone - if wide_ui: - row = layout.row() - row.column().prop(bone, "head") - row.column().prop(bone, "tail") - - col = row.column() - sub = col.column(align=True) - sub.label(text="Roll:") - sub.prop(bone, "roll", text="") - sub.label() - sub.prop(bone, "lock") - else: - col = layout.column() - col.prop(bone, "head") - col.prop(bone, "tail") - col.prop(bone, "roll") - col.prop(bone, "lock") + row = layout.row() + row.column().prop(bone, "head") + row.column().prop(bone, "tail") + + col = row.column() + sub = col.column(align=True) + sub.label(text="Roll:") + sub.prop(bone, "roll", text="") + sub.label() + sub.prop(bone, "lock") else: pchan = ob.pose.bones[context.bone.name] - if wide_ui: - row = layout.row() - col = row.column() - col.prop(pchan, "location") - col.active = not (bone.parent and bone.connected) - - col = row.column() - if pchan.rotation_mode == 'QUATERNION': - col.prop(pchan, "rotation_quaternion", text="Rotation") - elif pchan.rotation_mode == 'AXIS_ANGLE': - #col.label(text="Rotation") - #col.prop(pchan, "rotation_angle", text="Angle") - #col.prop(pchan, "rotation_axis", text="Axis") - col.prop(pchan, "rotation_axis_angle", text="Rotation") - else: - col.prop(pchan, "rotation_euler", text="Rotation") - - row.column().prop(pchan, "scale") - - layout.prop(pchan, "rotation_mode") + row = layout.row() + col = row.column() + col.prop(pchan, "location") + col.active = not (bone.parent and bone.connected) + + col = row.column() + if pchan.rotation_mode == 'QUATERNION': + col.prop(pchan, "rotation_quaternion", text="Rotation") + elif pchan.rotation_mode == 'AXIS_ANGLE': + #col.label(text="Rotation") + #col.prop(pchan, "rotation_angle", text="Angle") + #col.prop(pchan, "rotation_axis", text="Axis") + col.prop(pchan, "rotation_axis_angle", text="Rotation") else: - col = layout.column() - sub = col.column() - sub.active = not (bone.parent and bone.connected) - sub.prop(pchan, "location") - col.label(text="Rotation:") - col.prop(pchan, "rotation_mode", text="") - if pchan.rotation_mode == 'QUATERNION': - col.prop(pchan, "rotation_quaternion", text="") - elif pchan.rotation_mode == 'AXIS_ANGLE': - col.prop(pchan, "rotation_axis_angle", text="") - else: - col.prop(pchan, "rotation_euler", text="") - col.prop(pchan, "scale") - - -class BONE_PT_transform_locks(BoneButtonsPanel): + col.prop(pchan, "rotation_euler", text="Rotation") + + row.column().prop(pchan, "scale") + + layout.prop(pchan, "rotation_mode") + + +class BONE_PT_transform_locks(BoneButtonsPanel, bpy.types.Panel): bl_label = "Transform Locks" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): return context.bone def draw(self, context): @@ -159,7 +137,7 @@ class BONE_PT_transform_locks(BoneButtonsPanel): row.column().prop(pchan, "lock_scale") -class BONE_PT_relations(BoneButtonsPanel): +class BONE_PT_relations(BoneButtonsPanel, bpy.types.Panel): bl_label = "Relations" def draw(self, context): @@ -168,7 +146,6 @@ class BONE_PT_relations(BoneButtonsPanel): ob = context.object bone = context.bone arm = context.armature - wide_ui = context.region.width > narrowui if not bone: bone = context.edit_bone @@ -188,8 +165,7 @@ class BONE_PT_relations(BoneButtonsPanel): col.label(text="Bone Group:") col.prop_object(pchan, "bone_group", ob.pose, "bone_groups", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Parent:") if context.bone: col.prop(bone, "parent", text="") @@ -206,10 +182,11 @@ class BONE_PT_relations(BoneButtonsPanel): sub.prop(bone, "local_location", text="Local Location") -class BONE_PT_display(BoneButtonsPanel): +class BONE_PT_display(BoneButtonsPanel, bpy.types.Panel): bl_label = "Display" - def poll(self, context): + @classmethod + def poll(cls, context): return context.bone def draw(self, context): @@ -217,7 +194,6 @@ class BONE_PT_display(BoneButtonsPanel): ob = context.object bone = context.bone - wide_ui = context.region.width > narrowui if not bone: bone = context.edit_bone @@ -233,8 +209,7 @@ class BONE_PT_display(BoneButtonsPanel): col.prop(bone, "draw_wire", text="Wireframe") col.prop(bone, "hide", text="Hide") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Custom Shape:") col.prop(pchan, "custom_shape", text="") @@ -242,11 +217,12 @@ class BONE_PT_display(BoneButtonsPanel): col.prop_object(pchan, "custom_shape_transform", ob.pose, "bones", text="At") -class BONE_PT_inverse_kinematics(BoneButtonsPanel): +class BONE_PT_inverse_kinematics(BoneButtonsPanel, bpy.types.Panel): bl_label = "Inverse Kinematics" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): return context.active_pose_bone def draw(self, context): @@ -255,7 +231,6 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel): ob = context.object bone = context.bone pchan = ob.pose.bones[bone.name] - wide_ui = context.region.width > narrowui row = layout.row() row.prop(ob.pose, "ik_solver") @@ -267,15 +242,12 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel): row.prop(pchan, "ik_stiffness_x", text="Stiffness", slider=True) row.active = pchan.ik_dof_x and pchan.has_ik - if wide_ui: - split = layout.split(percentage=0.25) - sub = split.row() - else: - sub = layout.column(align=True) + split = layout.split(percentage=0.25) + sub = split.row() + sub.prop(pchan, "ik_limit_x", text="Limit") sub.active = pchan.ik_dof_x and pchan.has_ik - if wide_ui: - sub = split.row(align=True) + sub = split.row(align=True) sub.prop(pchan, "ik_min_x", text="") sub.prop(pchan, "ik_max_x", text="") sub.active = pchan.ik_dof_x and pchan.ik_limit_x and pchan.has_ik @@ -287,15 +259,13 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel): row.prop(pchan, "ik_stiffness_y", text="Stiffness", slider=True) row.active = pchan.ik_dof_y and pchan.has_ik - if wide_ui: - split = layout.split(percentage=0.25) - sub = split.row() - else: - sub = layout.column(align=True) + split = layout.split(percentage=0.25) + sub = split.row() + sub.prop(pchan, "ik_limit_y", text="Limit") sub.active = pchan.ik_dof_y and pchan.has_ik - if wide_ui: - sub = split.row(align=True) + + sub = split.row(align=True) sub.prop(pchan, "ik_min_y", text="") sub.prop(pchan, "ik_max_y", text="") sub.active = pchan.ik_dof_y and pchan.ik_limit_y and pchan.has_ik @@ -307,22 +277,18 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel): sub.prop(pchan, "ik_stiffness_z", text="Stiffness", slider=True) sub.active = pchan.ik_dof_z and pchan.has_ik - if wide_ui: - split = layout.split(percentage=0.25) - sub = split.row() - else: - sub = layout.column(align=True) + split = layout.split(percentage=0.25) + sub = split.row() + sub.prop(pchan, "ik_limit_z", text="Limit") sub.active = pchan.ik_dof_z and pchan.has_ik - if wide_ui: - sub = split.row(align=True) + sub = split.row(align=True) sub.prop(pchan, "ik_min_z", text="") sub.prop(pchan, "ik_max_z", text="") sub.active = pchan.ik_dof_z and pchan.ik_limit_z and pchan.has_ik split = layout.split() split.prop(pchan, "ik_stretch", text="Stretch", slider=True) - if wide_ui: - split.label() + split.label() split.active = pchan.has_ik if ob.pose.ik_solver == 'ITASC': @@ -330,8 +296,7 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel): col = split.column() col.prop(pchan, "ik_rot_control", text="Control Rotation") col.active = pchan.has_ik - if wide_ui: - col = split.column() + col = split.column() col.prop(pchan, "ik_rot_weight", text="Weight", slider=True) col.active = pchan.has_ik # not supported yet @@ -340,7 +305,7 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel): #row.prop(pchan, "ik_lin_weight", text="Weight", slider=True) -class BONE_PT_deform(BoneButtonsPanel): +class BONE_PT_deform(BoneButtonsPanel, bpy.types.Panel): bl_label = "Deform" bl_default_closed = True @@ -356,7 +321,6 @@ class BONE_PT_deform(BoneButtonsPanel): layout = self.layout bone = context.bone - wide_ui = context.region.width > narrowui if not bone: bone = context.edit_bone @@ -378,8 +342,7 @@ class BONE_PT_deform(BoneButtonsPanel): sub.prop(bone, "head_radius", text="Head") sub.prop(bone, "tail_radius", text="Tail") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Curved Bones:") sub = col.column(align=True) @@ -390,28 +353,13 @@ class BONE_PT_deform(BoneButtonsPanel): col.label(text="Offset:") col.prop(bone, "cyclic_offset") -classes = [ - BONE_PT_context_bone, - BONE_PT_transform, - BONE_PT_transform_locks, - BONE_PT_relations, - BONE_PT_display, - BONE_PT_inverse_kinematics, - BONE_PT_deform, - - BONE_PT_custom_props] - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_data_camera.py b/release/scripts/ui/properties_data_camera.py index 3abd460c427..cda2b79c909 100644 --- a/release/scripts/ui/properties_data_camera.py +++ b/release/scripts/ui/properties_data_camera.py @@ -20,20 +20,19 @@ import bpy from rna_prop_ui import PropertyPanel -narrowui = bpy.context.user_preferences.view.properties_width_check - -class DataButtonsPanel(bpy.types.Panel): +class CameraButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "data" - def poll(self, context): + @classmethod + def poll(cls, context): engine = context.scene.render.engine - return context.camera and (engine in self.COMPAT_ENGINES) + return context.camera and (engine in cls.COMPAT_ENGINES) -class DATA_PT_context_camera(DataButtonsPanel): +class DATA_PT_context_camera(CameraButtonsPanel, bpy.types.Panel): bl_label = "" bl_show_header = False COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -44,29 +43,22 @@ class DATA_PT_context_camera(DataButtonsPanel): ob = context.object cam = context.camera space = context.space_data - wide_ui = context.region.width > narrowui - - if wide_ui: - split = layout.split(percentage=0.65) - if ob: - split.template_ID(ob, "data") - split.separator() - elif cam: - split.template_ID(space, "pin_id") - split.separator() - else: - if ob: - layout.template_ID(ob, "data") - elif cam: - layout.template_ID(space, "pin_id") - - -class DATA_PT_custom_props_camera(DataButtonsPanel, PropertyPanel): - _context_path = "object.data" + + split = layout.split(percentage=0.65) + if ob: + split.template_ID(ob, "data") + split.separator() + elif cam: + split.template_ID(space, "pin_id") + split.separator() + + +class DATA_PT_custom_props_camera(CameraButtonsPanel, PropertyPanel, bpy.types.Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + _context_path = "object.data" -class DATA_PT_camera(DataButtonsPanel): +class DATA_PT_camera(CameraButtonsPanel, bpy.types.Panel): bl_label = "Lens" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -74,12 +66,8 @@ class DATA_PT_camera(DataButtonsPanel): layout = self.layout cam = context.camera - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(cam, "type", expand=True) - else: - layout.prop(cam, "type", text="") + layout.prop(cam, "type", expand=True) split = layout.split() @@ -89,8 +77,7 @@ class DATA_PT_camera(DataButtonsPanel): col.prop(cam, "lens", text="Angle") elif cam.lens_unit == 'DEGREES': col.prop(cam, "angle") - if wide_ui: - col = split.column() + col = split.column() col.prop(cam, "lens_unit", text="") elif cam.type == 'ORTHO': @@ -105,8 +92,7 @@ class DATA_PT_camera(DataButtonsPanel): col.prop(cam, "shift_x", text="X") col.prop(cam, "shift_y", text="Y") - if wide_ui: - col = split.column(align=True) + col = split.column(align=True) col.label(text="Clipping:") col.prop(cam, "clip_start", text="Start") col.prop(cam, "clip_end", text="End") @@ -118,16 +104,14 @@ class DATA_PT_camera(DataButtonsPanel): col = split.column() col.prop(cam, "dof_object", text="") - if wide_ui: - col = split.column() - else: - col = col.column() + col = split.column() + if cam.dof_object != None: col.enabled = False col.prop(cam, "dof_distance", text="Distance") -class DATA_PT_camera_display(DataButtonsPanel): +class DATA_PT_camera_display(CameraButtonsPanel, bpy.types.Panel): bl_label = "Display" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -135,7 +119,6 @@ class DATA_PT_camera_display(DataButtonsPanel): layout = self.layout cam = context.camera - wide_ui = context.region.width > narrowui split = layout.split() @@ -145,8 +128,7 @@ class DATA_PT_camera_display(DataButtonsPanel): col.prop(cam, "show_title_safe", text="Title Safe") col.prop(cam, "show_name", text="Name") - if wide_ui: - col = split.column() + col = split.column() col.prop(cam, "draw_size", text="Size") col.separator() col.prop(cam, "show_passepartout", text="Passepartout") @@ -155,24 +137,12 @@ class DATA_PT_camera_display(DataButtonsPanel): sub.prop(cam, "passepartout_alpha", text="Alpha", slider=True) -classes = [ - DATA_PT_context_camera, - DATA_PT_camera, - DATA_PT_camera_display, - - DATA_PT_custom_props_camera] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_data_curve.py b/release/scripts/ui/properties_data_curve.py index fd836f5e5d4..1262f6739b7 100644 --- a/release/scripts/ui/properties_data_curve.py +++ b/release/scripts/ui/properties_data_curve.py @@ -20,34 +20,35 @@ import bpy from rna_prop_ui import PropertyPanel -narrowui = bpy.context.user_preferences.view.properties_width_check - -class DataButtonsPanel(bpy.types.Panel): +class CurveButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "data" - def poll(self, context): + @classmethod + def poll(cls, context): return (context.object and context.object.type in ('CURVE', 'SURFACE', 'TEXT') and context.curve) -class DataButtonsPanelCurve(DataButtonsPanel): +class CurveButtonsPanelCurve(CurveButtonsPanel): '''Same as above but for curves only''' - def poll(self, context): + @classmethod + def poll(cls, context): return (context.object and context.object.type == 'CURVE' and context.curve) -class DataButtonsPanelActive(DataButtonsPanel): +class CurveButtonsPanelActive(CurveButtonsPanel): '''Same as above but for curves only''' - def poll(self, context): + @classmethod + def poll(cls, context): curve = context.curve return (curve and type(curve) is not bpy.types.TextCurve and curve.splines.active) -class DATA_PT_context_curve(DataButtonsPanel): +class DATA_PT_context_curve(CurveButtonsPanel, bpy.types.Panel): bl_label = "" bl_show_header = False @@ -57,27 +58,23 @@ class DATA_PT_context_curve(DataButtonsPanel): ob = context.object curve = context.curve space = context.space_data - wide_ui = context.region.width > narrowui - - if wide_ui: - split = layout.split(percentage=0.65) + split = layout.split(percentage=0.65) - if ob: - split.template_ID(ob, "data") - split.separator() - elif curve: - split.template_ID(space, "pin_id") - split.separator() - else: - layout.template_ID(ob, "data") + if ob: + split.template_ID(ob, "data") + split.separator() + elif curve: + split.template_ID(space, "pin_id") + split.separator() -class DATA_PT_custom_props_curve(DataButtonsPanel, PropertyPanel): +class DATA_PT_custom_props_curve(CurveButtonsPanel, PropertyPanel, bpy.types.Panel): + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "object.data" -class DATA_PT_shape_curve(DataButtonsPanel): +class DATA_PT_shape_curve(CurveButtonsPanel, bpy.types.Panel): bl_label = "Shape" def draw(self, context): @@ -85,7 +82,6 @@ class DATA_PT_shape_curve(DataButtonsPanel): ob = context.object curve = context.curve - wide_ui = context.region.width > narrowui is_surf = (ob.type == 'SURFACE') is_curve = (ob.type == 'CURVE') is_text = (ob.type == 'TEXT') @@ -109,8 +105,7 @@ class DATA_PT_shape_curve(DataButtonsPanel): col.label(text="Display:") col.prop(curve, "fast", text="Fast Editing") - if wide_ui: - col = split.column() + col = split.column() if is_surf: sub = col.column(align=True) @@ -130,10 +125,11 @@ class DATA_PT_shape_curve(DataButtonsPanel): col.prop(curve, "auto_texspace") -class DATA_PT_geometry_curve(DataButtonsPanel): +class DATA_PT_geometry_curve(CurveButtonsPanel, bpy.types.Panel): bl_label = "Geometry" - def poll(self, context): + @classmethod + def poll(cls, context): obj = context.object if obj and obj.type == 'SURFACE': return False @@ -144,7 +140,6 @@ class DATA_PT_geometry_curve(DataButtonsPanel): layout = self.layout curve = context.curve - wide_ui = context.region.width > narrowui split = layout.split() @@ -155,8 +150,7 @@ class DATA_PT_geometry_curve(DataButtonsPanel): col.label(text="Taper Object:") col.prop(curve, "taper_object", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Bevel:") col.prop(curve, "bevel_depth", text="Depth") col.prop(curve, "bevel_resolution", text="Resolution") @@ -164,7 +158,7 @@ class DATA_PT_geometry_curve(DataButtonsPanel): col.prop(curve, "bevel_object", text="") -class DATA_PT_pathanim(DataButtonsPanelCurve): +class DATA_PT_pathanim(CurveButtonsPanelCurve, bpy.types.Panel): bl_label = "Path Animation" def draw_header(self, context): @@ -176,7 +170,6 @@ class DATA_PT_pathanim(DataButtonsPanelCurve): layout = self.layout curve = context.curve - wide_ui = context.region.width > narrowui layout.active = curve.use_path @@ -189,14 +182,14 @@ class DATA_PT_pathanim(DataButtonsPanelCurve): col = split.column() col.prop(curve, "use_path_follow") col.prop(curve, "use_stretch") + col.prop(curve, "use_deform_bounds") - if wide_ui: - col = split.column() + col = split.column() col.prop(curve, "use_radius") col.prop(curve, "use_time_offset", text="Offset Children") -class DATA_PT_active_spline(DataButtonsPanelActive): +class DATA_PT_active_spline(CurveButtonsPanelActive, bpy.types.Panel): bl_label = "Active Spline" def draw(self, context): @@ -267,10 +260,11 @@ class DATA_PT_active_spline(DataButtonsPanelActive): layout.prop(act_spline, "smooth") -class DATA_PT_font(DataButtonsPanel): +class DATA_PT_font(CurveButtonsPanel, bpy.types.Panel): bl_label = "Font" - def poll(self, context): + @classmethod + def poll(cls, context): return (context.object and context.object.type == 'TEXT' and context.curve) def draw(self, context): @@ -278,21 +272,16 @@ class DATA_PT_font(DataButtonsPanel): text = context.curve char = context.curve.edit_format - wide_ui = context.region.width > narrowui layout.template_ID(text, "font", open="font.open", unlink="font.unlink") - #if wide_ui: - # layout.prop(text, "font") - #else: - # layout.prop(text, "font", text="") + #layout.prop(text, "font") split = layout.split() col = split.column() col.prop(text, "text_size", text="Size") - if wide_ui: - col = split.column() + col = split.column() col.prop(text, "shear") split = layout.split() @@ -301,8 +290,7 @@ class DATA_PT_font(DataButtonsPanel): col.label(text="Object Font:") col.prop(text, "family", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Text on Curve:") col.prop(text, "text_on_curve", text="") @@ -314,8 +302,7 @@ class DATA_PT_font(DataButtonsPanel): colsub.prop(text, "ul_position", text="Position") colsub.prop(text, "ul_height", text="Thickness") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Character:") col.prop(char, "bold") col.prop(char, "italic") @@ -329,23 +316,20 @@ class DATA_PT_font(DataButtonsPanel): col.prop(char, "use_small_caps") -class DATA_PT_paragraph(DataButtonsPanel): +class DATA_PT_paragraph(CurveButtonsPanel, bpy.types.Panel): bl_label = "Paragraph" - def poll(self, context): + @classmethod + def poll(cls, context): return (context.object and context.object.type == 'TEXT' and context.curve) def draw(self, context): layout = self.layout text = context.curve - wide_ui = context.region.width > narrowui layout.label(text="Align:") - if wide_ui: - layout.prop(text, "spacemode", expand=True) - else: - layout.prop(text, "spacemode", text="") + layout.prop(text, "spacemode", expand=True) split = layout.split() @@ -355,30 +339,28 @@ class DATA_PT_paragraph(DataButtonsPanel): col.prop(text, "word_spacing", text="Word") col.prop(text, "line_dist", text="Line") - if wide_ui: - col = split.column(align=True) + col = split.column(align=True) col.label(text="Offset:") col.prop(text, "offset_x", text="X") col.prop(text, "offset_y", text="Y") -class DATA_PT_textboxes(DataButtonsPanel): +class DATA_PT_textboxes(CurveButtonsPanel, bpy.types.Panel): bl_label = "Text Boxes" - def poll(self, context): + @classmethod + def poll(cls, context): return (context.object and context.object.type == 'TEXT' and context.curve) def draw(self, context): layout = self.layout text = context.curve - wide_ui = context.region.width > narrowui split = layout.split() col = split.column() col.operator("font.textbox_add", icon='ZOOMIN') - if wide_ui: - col = split.column() + col = split.column() for i, box in enumerate(text.textboxes): @@ -394,8 +376,7 @@ class DATA_PT_textboxes(DataButtonsPanel): col.prop(box, "width", text="Width") col.prop(box, "height", text="Height") - if wide_ui: - col = split.column(align=True) + col = split.column(align=True) col.label(text="Offset:") col.prop(box, "x", text="X") @@ -404,29 +385,12 @@ class DATA_PT_textboxes(DataButtonsPanel): row.operator("font.textbox_remove", text='', icon='X', emboss=False).index = i -classes = [ - DATA_PT_context_curve, - DATA_PT_shape_curve, - DATA_PT_geometry_curve, - DATA_PT_pathanim, - DATA_PT_active_spline, - DATA_PT_font, - DATA_PT_paragraph, - DATA_PT_textboxes, - - DATA_PT_custom_props_curve] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_data_empty.py b/release/scripts/ui/properties_data_empty.py index 577e32ed840..bf2f3b3d0ba 100644 --- a/release/scripts/ui/properties_data_empty.py +++ b/release/scripts/ui/properties_data_empty.py @@ -19,49 +19,37 @@ # <pep8 compliant> import bpy -narrowui = bpy.context.user_preferences.view.properties_width_check - -class DataButtonsPanel(bpy.types.Panel): +class DataButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "data" - def poll(self, context): + @classmethod + def poll(cls, context): return (context.object and context.object.type == 'EMPTY') -class DATA_PT_empty(DataButtonsPanel): +class DATA_PT_empty(DataButtonsPanel, bpy.types.Panel): bl_label = "Empty" def draw(self, context): layout = self.layout ob = context.object - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(ob, "empty_draw_type", text="Display") - else: - layout.prop(ob, "empty_draw_type", text="") + layout.prop(ob, "empty_draw_type", text="Display") layout.prop(ob, "empty_draw_size", text="Size") -classes = [ - DATA_PT_empty] - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_data_lamp.py b/release/scripts/ui/properties_data_lamp.py index 14493301b1e..9a58622974e 100644 --- a/release/scripts/ui/properties_data_lamp.py +++ b/release/scripts/ui/properties_data_lamp.py @@ -20,8 +20,6 @@ import bpy from rna_prop_ui import PropertyPanel -narrowui = bpy.context.user_preferences.view.properties_width_check - class LAMP_MT_sunsky_presets(bpy.types.Menu): bl_label = "Sun & Sky Presets" @@ -31,25 +29,25 @@ class LAMP_MT_sunsky_presets(bpy.types.Menu): draw = bpy.types.Menu.draw_preset -class DataButtonsPanel(bpy.types.Panel): +class DataButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "data" - def poll(self, context): + @classmethod + def poll(cls, context): engine = context.scene.render.engine - return context.lamp and (engine in self.COMPAT_ENGINES) + return context.lamp and (engine in cls.COMPAT_ENGINES) -class DATA_PT_preview(DataButtonsPanel): +class DATA_PT_preview(DataButtonsPanel, bpy.types.Panel): bl_label = "Preview" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} def draw(self, context): self.layout.template_preview(context.lamp) - -class DATA_PT_context_lamp(DataButtonsPanel): +class DATA_PT_context_lamp(DataButtonsPanel, bpy.types.Panel): bl_label = "" bl_show_header = False COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -60,29 +58,23 @@ class DATA_PT_context_lamp(DataButtonsPanel): ob = context.object lamp = context.lamp space = context.space_data - wide_ui = context.region.width > narrowui - - if wide_ui: - split = layout.split(percentage=0.65) - if ob: - split.template_ID(ob, "data") - split.separator() - elif lamp: - split.template_ID(space, "pin_id") - split.separator() - else: - if ob: - layout.template_ID(ob, "data") - elif lamp: - layout.template_ID(space, "pin_id") - - -class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel): - _context_path = "object.data" + + split = layout.split(percentage=0.65) + + if ob: + split.template_ID(ob, "data") + split.separator() + elif lamp: + split.template_ID(space, "pin_id") + split.separator() + + +class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel, bpy.types.Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + _context_path = "object.data" -class DATA_PT_lamp(DataButtonsPanel): +class DATA_PT_lamp(DataButtonsPanel, bpy.types.Panel): bl_label = "Lamp" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -90,12 +82,8 @@ class DATA_PT_lamp(DataButtonsPanel): layout = self.layout lamp = context.lamp - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(lamp, "type", expand=True) - else: - layout.prop(lamp, "type", text="") + layout.prop(lamp, "type", expand=True) split = layout.split() @@ -121,28 +109,27 @@ class DATA_PT_lamp(DataButtonsPanel): col.prop(lamp, "distance") col.prop(lamp, "gamma") - if wide_ui: - col = split.column() + col = split.column() col.prop(lamp, "negative") col.prop(lamp, "layer", text="This Layer Only") col.prop(lamp, "specular") col.prop(lamp, "diffuse") -class DATA_PT_sunsky(DataButtonsPanel): +class DATA_PT_sunsky(DataButtonsPanel, bpy.types.Panel): bl_label = "Sky & Atmosphere" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): lamp = context.lamp engine = context.scene.render.engine - return (lamp and lamp.type == 'SUN') and (engine in self.COMPAT_ENGINES) + return (lamp and lamp.type == 'SUN') and (engine in cls.COMPAT_ENGINES) def draw(self, context): layout = self.layout lamp = context.lamp.sky - wide_ui = context.region.width > narrowui row = layout.row(align=True) row.prop(lamp, "use_sky") @@ -167,8 +154,7 @@ class DATA_PT_sunsky(DataButtonsPanel): sub.row().prop(lamp, "sky_color_space", expand=True) sub.prop(lamp, "sky_exposure", text="Exposure") - if wide_ui: - col = split.column() + col = split.column() col.active = lamp.use_sky col.label(text="Horizon:") sub = col.column() @@ -193,8 +179,7 @@ class DATA_PT_sunsky(DataButtonsPanel): col.prop(lamp, "sun_intensity", text="Sun") col.prop(lamp, "atmosphere_distance_factor", text="Distance") - if wide_ui: - col = split.column() + col = split.column() col.active = lamp.use_atmosphere col.label(text="Scattering:") sub = col.column(align=True) @@ -202,25 +187,36 @@ class DATA_PT_sunsky(DataButtonsPanel): sub.prop(lamp, "atmosphere_extinction", slider=True, text="Extinction") -class DATA_PT_shadow(DataButtonsPanel): +class DATA_PT_shadow(DataButtonsPanel, bpy.types.Panel): bl_label = "Shadow" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): lamp = context.lamp engine = context.scene.render.engine - return (lamp and lamp.type in ('POINT', 'SUN', 'SPOT', 'AREA')) and (engine in self.COMPAT_ENGINES) + return (lamp and lamp.type in ('POINT', 'SUN', 'SPOT', 'AREA')) and (engine in cls.COMPAT_ENGINES) def draw(self, context): layout = self.layout lamp = context.lamp - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(lamp, "shadow_method", expand=True) - else: - layout.prop(lamp, "shadow_method", text="") + layout.prop(lamp, "shadow_method", expand=True) + + if lamp.shadow_method == 'NOSHADOW' and lamp.type == 'AREA': + split = layout.split() + + col= split.column() + col.label(text="Form factor sampling:") + + sub=col.row(align=True) + + if lamp.shape == 'SQUARE': + sub.prop(lamp, "shadow_ray_samples_x", text="Samples") + elif lamp.shape == 'RECTANGLE': + sub.prop(lamp, "shadow_ray_samples_x", text="Samples X") + sub.prop(lamp, "shadow_ray_samples_y", text="Samples Y") if lamp.shadow_method != 'NOSHADOW': split = layout.split() @@ -228,65 +224,51 @@ class DATA_PT_shadow(DataButtonsPanel): col = split.column() col.prop(lamp, "shadow_color", text="") - if wide_ui: - col = split.column() + col = split.column() col.prop(lamp, "shadow_layer", text="This Layer Only") col.prop(lamp, "only_shadow") if lamp.shadow_method == 'RAY_SHADOW': - col = layout.column() + split = layout.split() + + col = split.column() col.label(text="Sampling:") - if wide_ui: - col.row().prop(lamp, "shadow_ray_sampling_method", expand=True) - else: - col.prop(lamp, "shadow_ray_sampling_method", text="") - + if lamp.type in ('POINT', 'SUN', 'SPOT'): - split = layout.split() - - col = split.column() - col.prop(lamp, "shadow_soft_size", text="Soft Size") - - col.prop(lamp, "shadow_ray_samples", text="Samples") - if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC': - col.prop(lamp, "shadow_adaptive_threshold", text="Threshold") - if wide_ui: - col = split.column() - + sub = col.row() + + sub.prop(lamp, "shadow_ray_samples", text="Samples") + sub.prop(lamp, "shadow_soft_size", text="Soft Size") + elif lamp.type == 'AREA': - split = layout.split() - - col = split.column() - + sub = col.row(align=True) + if lamp.shape == 'SQUARE': - col.prop(lamp, "shadow_ray_samples_x", text="Samples") + sub.prop(lamp, "shadow_ray_samples_x", text="Samples") elif lamp.shape == 'RECTANGLE': - col.prop(lamp, "shadow_ray_samples_x", text="Samples X") - col.prop(lamp, "shadow_ray_samples_y", text="Samples Y") - - if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC': - col.prop(lamp, "shadow_adaptive_threshold", text="Threshold") - if wide_ui: - col = split.column() + sub.prop(lamp, "shadow_ray_samples_x", text="Samples X") + sub.prop(lamp, "shadow_ray_samples_y", text="Samples Y") - elif lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED': - if wide_ui: - col = split.column() - col.prop(lamp, "umbra") - col.prop(lamp, "dither") - col.prop(lamp, "jitter") - else: - if wide_ui: - col = split.column() + col.row().prop(lamp, "shadow_ray_sampling_method", expand=True) + split = layout.split() + col = split.column() + + if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC': + col.prop(lamp, "shadow_adaptive_threshold", text="Threshold") + col = split.column() + + if lamp.type == 'AREA' and lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED': + col = split.column() + col = split.column() + col.prop(lamp, "umbra") + col.prop(lamp, "dither") + col.prop(lamp, "jitter") elif lamp.shadow_method == 'BUFFER_SHADOW': col = layout.column() col.label(text="Buffer Type:") - if wide_ui: - col.row().prop(lamp, "shadow_buffer_type", expand=True) - else: - col.row().prop(lamp, "shadow_buffer_type", text="") + col.row().prop(lamp, "shadow_buffer_type", expand=True) if lamp.shadow_buffer_type in ('REGULAR', 'HALFWAY', 'DEEP'): split = layout.split() @@ -298,8 +280,7 @@ class DATA_PT_shadow(DataButtonsPanel): sub.prop(lamp, "shadow_buffer_soft", text="Soft") sub.prop(lamp, "shadow_buffer_bias", text="Bias") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Sample Buffers:") col.prop(lamp, "shadow_sample_buffers", text="") sub = col.column(align=True) @@ -319,34 +300,34 @@ class DATA_PT_shadow(DataButtonsPanel): sub.active = not lamp.auto_clip_start sub.prop(lamp, "shadow_buffer_clip_start", text="Clip Start") - if wide_ui: - col = split.column() + col = split.column() col.prop(lamp, "auto_clip_end", text="Autoclip End") sub = col.column() sub.active = not lamp.auto_clip_end sub.prop(lamp, "shadow_buffer_clip_end", text=" Clip End") -class DATA_PT_area(DataButtonsPanel): +class DATA_PT_area(DataButtonsPanel, bpy.types.Panel): bl_label = "Area Shape" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): lamp = context.lamp engine = context.scene.render.engine - return (lamp and lamp.type == 'AREA') and (engine in self.COMPAT_ENGINES) + return (lamp and lamp.type == 'AREA') and (engine in cls.COMPAT_ENGINES) def draw(self, context): - layout = self.layout - lamp = context.lamp + layout = self.layout split = layout.split() col = split.column() + col.row().prop(lamp, "shape", expand=True) + sub = col.row(align=True) - sub = col.column(align=True) if (lamp.shape == 'SQUARE'): sub.prop(lamp, "size") elif (lamp.shape == 'RECTANGLE'): @@ -354,20 +335,20 @@ class DATA_PT_area(DataButtonsPanel): sub.prop(lamp, "size_y", text="Size Y") -class DATA_PT_spot(DataButtonsPanel): +class DATA_PT_spot(DataButtonsPanel, bpy.types.Panel): bl_label = "Spot Shape" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): lamp = context.lamp engine = context.scene.render.engine - return (lamp and lamp.type == 'SPOT') and (engine in self.COMPAT_ENGINES) + return (lamp and lamp.type == 'SPOT') and (engine in cls.COMPAT_ENGINES) def draw(self, context): layout = self.layout lamp = context.lamp - wide_ui = context.region.width > narrowui split = layout.split() @@ -378,10 +359,8 @@ class DATA_PT_spot(DataButtonsPanel): col.prop(lamp, "square") col.prop(lamp, "show_cone") - if wide_ui: - col = split.column() - else: - col.separator() + col = split.column() + col.prop(lamp, "halo") sub = col.column(align=True) sub.active = lamp.halo @@ -390,16 +369,17 @@ class DATA_PT_spot(DataButtonsPanel): sub.prop(lamp, "halo_step", text="Step") -class DATA_PT_falloff_curve(DataButtonsPanel): +class DATA_PT_falloff_curve(DataButtonsPanel, bpy.types.Panel): bl_label = "Falloff Curve" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): lamp = context.lamp engine = context.scene.render.engine - return (lamp and lamp.type in ('POINT', 'SPOT') and lamp.falloff_type == 'CUSTOM_CURVE') and (engine in self.COMPAT_ENGINES) + return (lamp and lamp.type in ('POINT', 'SPOT') and lamp.falloff_type == 'CUSTOM_CURVE') and (engine in cls.COMPAT_ENGINES) def draw(self, context): lamp = context.lamp @@ -407,31 +387,12 @@ class DATA_PT_falloff_curve(DataButtonsPanel): self.layout.template_curve_mapping(lamp, "falloff_curve") -classes = [ - LAMP_MT_sunsky_presets, - - DATA_PT_context_lamp, - DATA_PT_preview, - DATA_PT_lamp, - DATA_PT_falloff_curve, - DATA_PT_area, - DATA_PT_spot, - DATA_PT_shadow, - DATA_PT_sunsky, - - DATA_PT_custom_props_lamp] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_data_lattice.py b/release/scripts/ui/properties_data_lattice.py index 2aa719437a7..5e313b79d85 100644 --- a/release/scripts/ui/properties_data_lattice.py +++ b/release/scripts/ui/properties_data_lattice.py @@ -20,19 +20,18 @@ import bpy from rna_prop_ui import PropertyPanel -narrowui = bpy.context.user_preferences.view.properties_width_check - -class DataButtonsPanel(bpy.types.Panel): +class DataButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "data" - def poll(self, context): + @classmethod + def poll(cls, context): return context.lattice -class DATA_PT_context_lattice(DataButtonsPanel): +class DATA_PT_context_lattice(DataButtonsPanel, bpy.types.Panel): bl_label = "" bl_show_header = False @@ -42,55 +41,45 @@ class DATA_PT_context_lattice(DataButtonsPanel): ob = context.object lat = context.lattice space = context.space_data - wide_ui = context.region.width > narrowui - - if wide_ui: - split = layout.split(percentage=0.65) - if ob: - split.template_ID(ob, "data") - split.separator() - elif lat: - split.template_ID(space, "pin_id") - split.separator() - else: - if ob: - layout.template_ID(ob, "data") - elif lat: - layout.template_ID(space, "pin_id") - - -class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel): + + split = layout.split(percentage=0.65) + if ob: + split.template_ID(ob, "data") + split.separator() + elif lat: + split.template_ID(space, "pin_id") + split.separator() + + +class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel, bpy.types.Panel): + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "object.data" -class DATA_PT_lattice(DataButtonsPanel): +class DATA_PT_lattice(DataButtonsPanel, bpy.types.Panel): bl_label = "Lattice" def draw(self, context): layout = self.layout lat = context.lattice - wide_ui = context.region.width > narrowui split = layout.split() col = split.column() col.prop(lat, "points_u") - if wide_ui: - col = split.column() + col = split.column() col.prop(lat, "interpolation_type_u", text="") split = layout.split() col = split.column() col.prop(lat, "points_v") - if wide_ui: - col = split.column() + col = split.column() col.prop(lat, "interpolation_type_v", text="") split = layout.split() col = split.column() col.prop(lat, "points_w") - if wide_ui: - col = split.column() + col = split.column() col.prop(lat, "interpolation_type_w", text="") row = layout.row() @@ -98,23 +87,12 @@ class DATA_PT_lattice(DataButtonsPanel): row.prop_object(lat, "vertex_group", context.object, "vertex_groups", text="") -classes = [ - DATA_PT_context_lattice, - DATA_PT_lattice, - - DATA_PT_custom_props_lattice] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_data_mesh.py b/release/scripts/ui/properties_data_mesh.py index c3170be8860..1be2ce824fa 100644 --- a/release/scripts/ui/properties_data_mesh.py +++ b/release/scripts/ui/properties_data_mesh.py @@ -20,8 +20,6 @@ import bpy from rna_prop_ui import PropertyPanel -narrowui = bpy.context.user_preferences.view.properties_width_check - class MESH_MT_vertex_group_specials(bpy.types.Menu): bl_label = "Vertex Group Specials" @@ -49,17 +47,18 @@ class MESH_MT_shape_key_specials(bpy.types.Menu): layout.operator("object.shape_key_mirror", icon='ARROW_LEFTRIGHT') -class DataButtonsPanel(bpy.types.Panel): +class MeshButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "data" - def poll(self, context): + @classmethod + def poll(cls, context): engine = context.scene.render.engine - return context.mesh and (engine in self.COMPAT_ENGINES) + return context.mesh and (engine in cls.COMPAT_ENGINES) -class DATA_PT_context_mesh(DataButtonsPanel): +class DATA_PT_context_mesh(MeshButtonsPanel, bpy.types.Panel): bl_label = "" bl_show_header = False COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -70,29 +69,22 @@ class DATA_PT_context_mesh(DataButtonsPanel): ob = context.object mesh = context.mesh space = context.space_data - wide_ui = context.region.width > narrowui - - if wide_ui: - split = layout.split(percentage=0.65) - if ob: - split.template_ID(ob, "data") - split.separator() - elif mesh: - split.template_ID(space, "pin_id") - split.separator() - else: - if ob: - layout.template_ID(ob, "data") - elif mesh: - layout.template_ID(space, "pin_id") + split = layout.split(percentage=0.65) + if ob: + split.template_ID(ob, "data") + split.separator() + elif mesh: + split.template_ID(space, "pin_id") + split.separator() -class DATA_PT_custom_props_mesh(DataButtonsPanel, PropertyPanel): - _context_path = "object.data" + +class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, bpy.types.Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + _context_path = "object.data" -class DATA_PT_normals(DataButtonsPanel): +class DATA_PT_normals(MeshButtonsPanel, bpy.types.Panel): bl_label = "Normals" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -100,7 +92,6 @@ class DATA_PT_normals(DataButtonsPanel): layout = self.layout mesh = context.mesh - wide_ui = context.region.width > narrowui split = layout.split() @@ -110,14 +101,12 @@ class DATA_PT_normals(DataButtonsPanel): sub.active = mesh.autosmooth sub.prop(mesh, "autosmooth_angle", text="Angle") - if wide_ui: - col = split.column() - else: - col.separator() + col = split.column() + col.prop(mesh, "double_sided") -class DATA_PT_settings(DataButtonsPanel): +class DATA_PT_settings(MeshButtonsPanel, bpy.types.Panel): bl_label = "Settings" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -129,13 +118,15 @@ class DATA_PT_settings(DataButtonsPanel): layout.prop(mesh, "texture_mesh") -class DATA_PT_vertex_groups(DataButtonsPanel): +class DATA_PT_vertex_groups(MeshButtonsPanel, bpy.types.Panel): bl_label = "Vertex Groups" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): engine = context.scene.render.engine - return (context.object and context.object.type in ('MESH', 'LATTICE') and (engine in self.COMPAT_ENGINES)) + obj = context.object + return (obj and obj.type in ('MESH', 'LATTICE') and (engine in cls.COMPAT_ENGINES)) def draw(self, context): layout = self.layout @@ -176,13 +167,15 @@ class DATA_PT_vertex_groups(DataButtonsPanel): layout.prop(context.tool_settings, "vertex_group_weight", text="Weight") -class DATA_PT_shape_keys(DataButtonsPanel): +class DATA_PT_shape_keys(MeshButtonsPanel, bpy.types.Panel): bl_label = "Shape Keys" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): engine = context.scene.render.engine - return (context.object and context.object.type in ('MESH', 'LATTICE', 'CURVE', 'SURFACE') and (engine in self.COMPAT_ENGINES)) + obj = context.object + return (obj and obj.type in ('MESH', 'LATTICE', 'CURVE', 'SURFACE') and (engine in cls.COMPAT_ENGINES)) def draw(self, context): layout = self.layout @@ -190,7 +183,6 @@ class DATA_PT_shape_keys(DataButtonsPanel): ob = context.object key = ob.data.shape_keys kb = ob.active_shape_key - wide_ui = context.region.width > narrowui enable_edit = ob.mode != 'EDIT' enable_edit_value = False @@ -223,17 +215,11 @@ class DATA_PT_shape_keys(DataButtonsPanel): split = layout.split(percentage=0.4) row = split.row() row.enabled = enable_edit - if wide_ui: - row.prop(key, "relative") + row.prop(key, "relative") row = split.row() row.alignment = 'RIGHT' - if not wide_ui: - layout.prop(key, "relative") - row = layout.row() - - sub = row.row(align=True) subsub = sub.row(align=True) subsub.active = enable_edit_value @@ -261,8 +247,7 @@ class DATA_PT_shape_keys(DataButtonsPanel): col.prop(kb, "slider_min", text="Min") col.prop(kb, "slider_max", text="Max") - if wide_ui: - col = split.column(align=True) + col = split.column(align=True) col.active = enable_edit_value col.label(text="Blend:") col.prop_object(kb, "vertex_group", ob, "vertex_groups", text="") @@ -274,7 +259,7 @@ class DATA_PT_shape_keys(DataButtonsPanel): row.prop(key, "slurph") -class DATA_PT_uv_texture(DataButtonsPanel): +class DATA_PT_uv_texture(MeshButtonsPanel, bpy.types.Panel): bl_label = "UV Texture" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -297,11 +282,12 @@ class DATA_PT_uv_texture(DataButtonsPanel): layout.prop(lay, "name") -class DATA_PT_texface(DataButtonsPanel): +class DATA_PT_texface(MeshButtonsPanel, bpy.types.Panel): bl_label = "Texture Face" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): ob = context.active_object rd = context.scene.render @@ -311,7 +297,6 @@ class DATA_PT_texface(DataButtonsPanel): layout = self.layout col = layout.column() - wide_ui = context.region.width > narrowui me = context.mesh tf = me.faces.active_tface @@ -329,8 +314,7 @@ class DATA_PT_texface(DataButtonsPanel): col.prop(tf, "twoside") col.prop(tf, "object_color") - if wide_ui: - col = split.column() + col = split.column() col.prop(tf, "halo") col.prop(tf, "billboard") @@ -344,7 +328,7 @@ class DATA_PT_texface(DataButtonsPanel): col.label(text="No UV Texture") -class DATA_PT_vertex_colors(DataButtonsPanel): +class DATA_PT_vertex_colors(MeshButtonsPanel, bpy.types.Panel): bl_label = "Vertex Colors" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -367,32 +351,12 @@ class DATA_PT_vertex_colors(DataButtonsPanel): layout.prop(lay, "name") -classes = [ - MESH_MT_vertex_group_specials, - MESH_MT_shape_key_specials, - - DATA_PT_context_mesh, - DATA_PT_normals, - DATA_PT_settings, - DATA_PT_vertex_groups, - DATA_PT_shape_keys, - DATA_PT_uv_texture, - DATA_PT_texface, - DATA_PT_vertex_colors, - - DATA_PT_custom_props_mesh] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_data_metaball.py b/release/scripts/ui/properties_data_metaball.py index e0155059b98..a6b1bb75cbe 100644 --- a/release/scripts/ui/properties_data_metaball.py +++ b/release/scripts/ui/properties_data_metaball.py @@ -20,19 +20,18 @@ import bpy from rna_prop_ui import PropertyPanel -narrowui = bpy.context.user_preferences.view.properties_width_check - -class DataButtonsPanel(bpy.types.Panel): +class DataButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "data" - def poll(self, context): + @classmethod + def poll(cls, context): return context.meta_ball -class DATA_PT_context_metaball(DataButtonsPanel): +class DATA_PT_context_metaball(DataButtonsPanel, bpy.types.Panel): bl_label = "" bl_show_header = False @@ -42,35 +41,28 @@ class DATA_PT_context_metaball(DataButtonsPanel): ob = context.object mball = context.meta_ball space = context.space_data - wide_ui = context.region.width > narrowui - - if wide_ui: - split = layout.split(percentage=0.65) - if ob: - split.template_ID(ob, "data") - split.separator() - elif mball: - split.template_ID(space, "pin_id") - split.separator() - else: - if ob: - layout.template_ID(ob, "data") - elif mball: - layout.template_ID(space, "pin_id") - - -class DATA_PT_custom_props_metaball(DataButtonsPanel, PropertyPanel): + + split = layout.split(percentage=0.65) + if ob: + split.template_ID(ob, "data") + split.separator() + elif mball: + split.template_ID(space, "pin_id") + split.separator() + + +class DATA_PT_custom_props_metaball(DataButtonsPanel, PropertyPanel, bpy.types.Panel): + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "object.data" -class DATA_PT_metaball(DataButtonsPanel): +class DATA_PT_metaball(DataButtonsPanel, bpy.types.Panel): bl_label = "Metaball" def draw(self, context): layout = self.layout mball = context.meta_ball - wide_ui = context.region.width > narrowui split = layout.split() @@ -80,34 +72,27 @@ class DATA_PT_metaball(DataButtonsPanel): sub.prop(mball, "wire_size", text="View") sub.prop(mball, "render_size", text="Render") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Settings:") col.prop(mball, "threshold", text="Threshold") layout.label(text="Update:") - if wide_ui: - layout.prop(mball, "flag", expand=True) - else: - layout.prop(mball, "flag", text="") + layout.prop(mball, "flag", expand=True) -class DATA_PT_metaball_element(DataButtonsPanel): +class DATA_PT_metaball_element(DataButtonsPanel, bpy.types.Panel): bl_label = "Active Element" - def poll(self, context): + @classmethod + def poll(cls, context): return (context.meta_ball and context.meta_ball.active_element) def draw(self, context): layout = self.layout metaelem = context.meta_ball.active_element - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(metaelem, "type") - else: - layout.prop(metaelem, "type", text="") + layout.prop(metaelem, "type") split = layout.split() @@ -117,8 +102,7 @@ class DATA_PT_metaball_element(DataButtonsPanel): col.prop(metaelem, "negative", text="Negative") col.prop(metaelem, "hide", text="Hide") - if wide_ui: - col = split.column(align=True) + col = split.column(align=True) if metaelem.type in ('CUBE', 'ELLIPSOID'): col.label(text="Size:") @@ -136,24 +120,12 @@ class DATA_PT_metaball_element(DataButtonsPanel): col.prop(metaelem, "size_y", text="Y") -classes = [ - DATA_PT_context_metaball, - DATA_PT_metaball, - DATA_PT_metaball_element, - - DATA_PT_custom_props_metaball] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_data_modifier.py b/release/scripts/ui/properties_data_modifier.py index 37764e20854..2847810f417 100644 --- a/release/scripts/ui/properties_data_modifier.py +++ b/release/scripts/ui/properties_data_modifier.py @@ -19,47 +19,41 @@ # <pep8 compliant> import bpy -narrowui = bpy.context.user_preferences.view.properties_width_check -narrowmod = 260 - -class DataButtonsPanel(bpy.types.Panel): +class ModifierButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "modifier" -class DATA_PT_modifiers(DataButtonsPanel): +class DATA_PT_modifiers(ModifierButtonsPanel, bpy.types.Panel): bl_label = "Modifiers" def draw(self, context): layout = self.layout ob = context.object - wide_ui = context.region.width > narrowui - compact_mod = context.region.width < narrowmod layout.operator_menu_enum("object.modifier_add", "type") for md in ob.modifiers: - box = layout.template_modifier(md, compact=compact_mod) + box = layout.template_modifier(md) if box: # match enum type to our functions, avoids a lookup table. - getattr(self, md.type)(box, ob, md, wide_ui) + getattr(self, md.type)(box, ob, md) # the mt.type enum is (ab)used for a lookup on function names # ...to avoid lengthy if statements # so each type must have a function here. - def ARMATURE(self, layout, ob, md, wide_ui): + def ARMATURE(self, layout, ob, md): split = layout.split() col = split.column() col.label(text="Object:") col.prop(md, "object", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Vertex Group::") col.prop_object(md, "vertex_group", ob, "vertex_groups", text="") sub = col.column() @@ -73,18 +67,13 @@ class DATA_PT_modifiers(DataButtonsPanel): col.prop(md, "use_vertex_groups", text="Vertex Groups") col.prop(md, "use_bone_envelopes", text="Bone Envelopes") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Deformation:") col.prop(md, "quaternion") col.prop(md, "multi_modifier") - def ARRAY(self, layout, ob, md, wide_ui): - if wide_ui: - layout.prop(md, "fit_type") - else: - layout.prop(md, "fit_type", text="") - + def ARRAY(self, layout, ob, md): + layout.prop(md, "fit_type") if md.fit_type == 'FIXED_COUNT': layout.prop(md, "count") @@ -111,8 +100,7 @@ class DATA_PT_modifiers(DataButtonsPanel): sub.prop(md, "merge_end_vertices", text="First Last") sub.prop(md, "merge_distance", text="Distance") - if wide_ui: - col = split.column() + col = split.column() col.prop(md, "relative_offset") sub = col.column() sub.active = md.relative_offset @@ -131,14 +119,13 @@ class DATA_PT_modifiers(DataButtonsPanel): col.prop(md, "start_cap") col.prop(md, "end_cap") - def BEVEL(self, layout, ob, md, wide_ui): + def BEVEL(self, layout, ob, md): split = layout.split() col = split.column() col.prop(md, "width") - if wide_ui: - col = split.column() + col = split.column() col.prop(md, "only_vertices") layout.label(text="Limit Method:") @@ -148,40 +135,35 @@ class DATA_PT_modifiers(DataButtonsPanel): elif md.limit_method == 'WEIGHT': layout.row().prop(md, "edge_weight_method", expand=True) - def BOOLEAN(self, layout, ob, md, wide_ui): + def BOOLEAN(self, layout, ob, md): split = layout.split() col = split.column() col.label(text="Operation:") col.prop(md, "operation", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Object:") col.prop(md, "object", text="") - def BUILD(self, layout, ob, md, wide_ui): + def BUILD(self, layout, ob, md): split = layout.split() col = split.column() col.prop(md, "frame_start") col.prop(md, "length") - if wide_ui: - col = split.column() + col = split.column() col.prop(md, "randomize") sub = col.column() sub.active = md.randomize sub.prop(md, "seed") - def CAST(self, layout, ob, md, wide_ui): + def CAST(self, layout, ob, md): split = layout.split(percentage=0.25) - if wide_ui: - split.label(text="Cast Type:") - split.prop(md, "cast_type", text="") - else: - layout.prop(md, "cast_type", text="") + split.label(text="Cast Type:") + split.prop(md, "cast_type", text="") split = layout.split(percentage=0.25) @@ -201,37 +183,35 @@ class DATA_PT_modifiers(DataButtonsPanel): col = split.column() col.label(text="Vertex Group:") col.prop_object(md, "vertex_group", ob, "vertex_groups", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Control Object:") col.prop(md, "object", text="") if md.object: col.prop(md, "use_transform") - def CLOTH(self, layout, ob, md, wide_ui): + def CLOTH(self, layout, ob, md): layout.label(text="See Cloth panel.") - def COLLISION(self, layout, ob, md, wide_ui): + def COLLISION(self, layout, ob, md): layout.label(text="See Collision panel.") - def CURVE(self, layout, ob, md, wide_ui): + def CURVE(self, layout, ob, md): split = layout.split() col = split.column() col.label(text="Object:") col.prop(md, "object", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Vertex Group:") col.prop_object(md, "vertex_group", ob, "vertex_groups", text="") layout.label(text="Deformation Axis:") layout.row().prop(md, "deform_axis", expand=True) - def DECIMATE(self, layout, ob, md, wide_ui): + def DECIMATE(self, layout, ob, md): layout.prop(md, "ratio") layout.label(text="Face Count: %s" % str(md.face_count)) - def DISPLACE(self, layout, ob, md, wide_ui): + def DISPLACE(self, layout, ob, md): split = layout.split() col = split.column() @@ -240,8 +220,7 @@ class DATA_PT_modifiers(DataButtonsPanel): col.label(text="Vertex Group:") col.prop_object(md, "vertex_group", ob, "vertex_groups", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Direction:") col.prop(md, "direction", text="") col.label(text="Texture Coordinates:") @@ -258,11 +237,10 @@ class DATA_PT_modifiers(DataButtonsPanel): col = split.column() col.prop(md, "midlevel") - if wide_ui: - col = split.column() + col = split.column() col.prop(md, "strength") - def EDGE_SPLIT(self, layout, ob, md, wide_ui): + def EDGE_SPLIT(self, layout, ob, md): split = layout.split() col = split.column() @@ -271,11 +249,10 @@ class DATA_PT_modifiers(DataButtonsPanel): sub.active = md.use_edge_angle sub.prop(md, "split_angle") - if wide_ui: - col = split.column() + col = split.column() col.prop(md, "use_sharp", text="Sharp Edges") - def EXPLODE(self, layout, ob, md, wide_ui): + def EXPLODE(self, layout, ob, md): split = layout.split() col = split.column() @@ -285,8 +262,7 @@ class DATA_PT_modifiers(DataButtonsPanel): sub.active = bool(md.vertex_group) sub.prop(md, "protect") - if wide_ui: - col = split.column() + col = split.column() col.prop(md, "split_edges") col.prop(md, "unborn") col.prop(md, "alive") @@ -295,10 +271,10 @@ class DATA_PT_modifiers(DataButtonsPanel): layout.operator("object.explode_refresh", text="Refresh") - def FLUID_SIMULATION(self, layout, ob, md, wide_ui): + def FLUID_SIMULATION(self, layout, ob, md): layout.label(text="See Fluid panel.") - def HOOK(self, layout, ob, md, wide_ui): + def HOOK(self, layout, ob, md): split = layout.split() col = split.column() @@ -307,8 +283,7 @@ class DATA_PT_modifiers(DataButtonsPanel): if md.object and md.object.type == 'ARMATURE': col.label(text="Bone:") col.prop_object(md, "subtarget", md.object.data, "bones", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Vertex Group:") col.prop_object(md, "vertex_group", ob, "vertex_groups", text="") @@ -319,10 +294,8 @@ class DATA_PT_modifiers(DataButtonsPanel): col = split.column() col.prop(md, "falloff") col.prop(md, "force", slider=True) - if wide_ui: - col = split.column() - else: - col.separator() + + col = split.column() col.operator("object.hook_reset", text="Reset") col.operator("object.hook_recenter", text="Recenter") @@ -332,26 +305,24 @@ class DATA_PT_modifiers(DataButtonsPanel): row.operator("object.hook_select", text="Select") row.operator("object.hook_assign", text="Assign") - def LATTICE(self, layout, ob, md, wide_ui): + def LATTICE(self, layout, ob, md): split = layout.split() col = split.column() col.label(text="Object:") col.prop(md, "object", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Vertex Group:") col.prop_object(md, "vertex_group", ob, "vertex_groups", text="") - def MASK(self, layout, ob, md, wide_ui): + def MASK(self, layout, ob, md): split = layout.split() col = split.column() col.label(text="Mode:") col.prop(md, "mode", text="") - if wide_ui: - col = split.column() + col = split.column() if md.mode == 'ARMATURE': col.label(text="Armature:") col.prop(md, "armature", text="") @@ -363,15 +334,14 @@ class DATA_PT_modifiers(DataButtonsPanel): sub.active = bool(md.vertex_group) sub.prop(md, "invert") - def MESH_DEFORM(self, layout, ob, md, wide_ui): + def MESH_DEFORM(self, layout, ob, md): split = layout.split() col = split.column() sub = col.column() sub.label(text="Object:") sub.prop(md, "object", text="") sub.active = not md.is_bound - if wide_ui: - col = split.column() + col = split.column() col.label(text="Vertex Group:") col.prop_object(md, "vertex_group", ob, "vertex_groups", text="") @@ -391,16 +361,12 @@ class DATA_PT_modifiers(DataButtonsPanel): col = split.column() col.prop(md, "precision") - if wide_ui: - col = split.column() + col = split.column() col.prop(md, "dynamic") - def MIRROR(self, layout, ob, md, wide_ui): + def MIRROR(self, layout, ob, md): layout.prop(md, "merge_limit") - if wide_ui: - split = layout.split(percentage=0.25) - else: - split = layout.split(percentage=0.4) + split = layout.split(percentage=0.25) col = split.column() col.label(text="Axis:") @@ -408,11 +374,7 @@ class DATA_PT_modifiers(DataButtonsPanel): col.prop(md, "y") col.prop(md, "z") - if wide_ui: - col = split.column() - else: - subsplit = layout.split() - col = subsplit.column() + col = split.column() col.label(text="Options:") col.prop(md, "clip", text="Clipping") col.prop(md, "mirror_vertex_groups", text="Vertex Groups") @@ -426,11 +388,8 @@ class DATA_PT_modifiers(DataButtonsPanel): col.label(text="Mirror Object:") col.prop(md, "mirror_object", text="") - def MULTIRES(self, layout, ob, md, wide_ui): - if wide_ui: - layout.row().prop(md, "subdivision_type", expand=True) - else: - layout.row().prop(md, "subdivision_type", text="") + def MULTIRES(self, layout, ob, md): + layout.row().prop(md, "subdivision_type", expand=True) split = layout.split() col = split.column() @@ -438,8 +397,7 @@ class DATA_PT_modifiers(DataButtonsPanel): col.prop(md, "sculpt_levels", text="Sculpt") col.prop(md, "render_levels", text="Render") - if wide_ui: - col = split.column() + col = split.column() col.enabled = ob.mode != 'EDIT' col.operator("object.multires_subdivide", text="Subdivide") @@ -460,7 +418,7 @@ class DATA_PT_modifiers(DataButtonsPanel): row.operator("object.multires_external_save", text="Save External...") row.label() - def PARTICLE_INSTANCE(self, layout, ob, md, wide_ui): + def PARTICLE_INSTANCE(self, layout, ob, md): layout.prop(md, "object") layout.prop(md, "particle_system_number", text="Particle System") @@ -471,8 +429,7 @@ class DATA_PT_modifiers(DataButtonsPanel): col.prop(md, "children") col.prop(md, "size") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Show Particles When:") col.prop(md, "alive") col.prop(md, "unborn") @@ -488,15 +445,14 @@ class DATA_PT_modifiers(DataButtonsPanel): col.row().prop(md, "axis", expand=True) col.prop(md, "keep_shape") - if wide_ui: - col = split.column() + col = split.column() col.prop(md, "position", slider=True) col.prop(md, "random_position", text="Random", slider=True) - def PARTICLE_SYSTEM(self, layout, ob, md, wide_ui): + def PARTICLE_SYSTEM(self, layout, ob, md): layout.label(text="See Particle panel.") - def SCREW(self, layout, ob, md, wide_ui): + def SCREW(self, layout, ob, md): split = layout.split() col = split.column() @@ -506,8 +462,7 @@ class DATA_PT_modifiers(DataButtonsPanel): col.prop(md, "steps") col.prop(md, "render_steps") - if wide_ui: - col = split.column() + col = split.column() row = col.row() row.active = (md.object is None or md.use_object_screw_offset == False) row.prop(md, "screw_offset") @@ -518,13 +473,12 @@ class DATA_PT_modifiers(DataButtonsPanel): col.prop(md, "use_normal_flip") col.prop(md, "iterations") - def SHRINKWRAP(self, layout, ob, md, wide_ui): + def SHRINKWRAP(self, layout, ob, md): split = layout.split() col = split.column() col.label(text="Target:") col.prop(md, "target", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Vertex Group:") col.prop_object(md, "vertex_group", ob, "vertex_groups", text="") @@ -534,15 +488,12 @@ class DATA_PT_modifiers(DataButtonsPanel): col.prop(md, "offset") col.prop(md, "subsurf_levels") - if wide_ui: - col = split.column() - col.label(text="Mode:") + col = split.column() + col.label(text="Mode:") col.prop(md, "mode", text="") - if wide_ui: - split = layout.split(percentage=0.25) - else: - split = layout.split(percentage=0.35) + split = layout.split(percentage=0.25) + col = split.column() if md.mode == 'PROJECT': @@ -556,11 +507,8 @@ class DATA_PT_modifiers(DataButtonsPanel): col.prop(md, "negative") col.prop(md, "positive") - if wide_ui: - col = split.column() - else: - subsplit = layout.split() - col = subsplit.column() + col = split.column() + col.label(text="Cull Faces:") col.prop(md, "cull_front_faces", text="Front") col.prop(md, "cull_back_faces", text="Back") @@ -571,15 +519,14 @@ class DATA_PT_modifiers(DataButtonsPanel): elif md.mode == 'NEAREST_SURFACEPOINT': layout.prop(md, "keep_above_surface") - def SIMPLE_DEFORM(self, layout, ob, md, wide_ui): + def SIMPLE_DEFORM(self, layout, ob, md): split = layout.split() col = split.column() col.label(text="Mode:") col.prop(md, "mode", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Vertex Group:") col.prop_object(md, "vertex_group", ob, "vertex_groups", text="") @@ -592,8 +539,7 @@ class DATA_PT_modifiers(DataButtonsPanel): sub.active = (md.origin != "") sub.prop(md, "relative") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Deform:") col.prop(md, "factor") col.prop(md, "limits", slider=True) @@ -601,10 +547,10 @@ class DATA_PT_modifiers(DataButtonsPanel): col.prop(md, "lock_x_axis") col.prop(md, "lock_y_axis") - def SMOKE(self, layout, ob, md, wide_ui): + def SMOKE(self, layout, ob, md): layout.label(text="See Smoke panel.") - def SMOOTH(self, layout, ob, md, wide_ui): + def SMOOTH(self, layout, ob, md): split = layout.split(percentage=0.25) col = split.column() @@ -619,10 +565,10 @@ class DATA_PT_modifiers(DataButtonsPanel): col.label(text="Vertex Group:") col.prop_object(md, "vertex_group", ob, "vertex_groups", text="") - def SOFT_BODY(self, layout, ob, md, wide_ui): + def SOFT_BODY(self, layout, ob, md): layout.label(text="See Soft Body panel.") - def SOLIDIFY(self, layout, ob, md, wide_ui): + def SOLIDIFY(self, layout, ob, md): split = layout.split() @@ -635,8 +581,7 @@ class DATA_PT_modifiers(DataButtonsPanel): col.prop(md, "edge_crease_outer", text="Outer") col.prop(md, "edge_crease_rim", text="Rim") - if wide_ui: - col = split.column() + col = split.column() col.prop(md, "offset") colsub = col.column() @@ -655,11 +600,8 @@ class DATA_PT_modifiers(DataButtonsPanel): # col.label(text="Vertex Group:") # col.prop_object(md, "vertex_group", ob, "vertex_groups", text="") - def SUBSURF(self, layout, ob, md, wide_ui): - if wide_ui: - layout.row().prop(md, "subdivision_type", expand=True) - else: - layout.row().prop(md, "subdivision_type", text="") + def SUBSURF(self, layout, ob, md): + layout.row().prop(md, "subdivision_type", expand=True) split = layout.split() col = split.column() @@ -667,16 +609,15 @@ class DATA_PT_modifiers(DataButtonsPanel): col.prop(md, "levels", text="View") col.prop(md, "render_levels", text="Render") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Options:") col.prop(md, "subsurf_uv") col.prop(md, "optimal_display") - def SURFACE(self, layout, ob, md, wide_ui): + def SURFACE(self, layout, ob, md): layout.label(text="See Fields panel.") - def UV_PROJECT(self, layout, ob, md, wide_ui): + def UV_PROJECT(self, layout, ob, md): if ob.type == 'MESH': split = layout.split() @@ -684,8 +625,7 @@ class DATA_PT_modifiers(DataButtonsPanel): col.label(text="Image:") col.prop(md, "image", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="UV Layer:") col.prop_object(md, "uv_layer", ob.data, "uv_textures", text="") @@ -696,8 +636,7 @@ class DATA_PT_modifiers(DataButtonsPanel): for proj in md.projectors: col.prop(proj, "object", text="") - if wide_ui: - col = split.column() + col = split.column() sub = col.column(align=True) sub.prop(md, "aspect_x", text="Aspect X") sub.prop(md, "aspect_y", text="Aspect Y") @@ -706,7 +645,7 @@ class DATA_PT_modifiers(DataButtonsPanel): sub.prop(md, "scale_x", text="Scale X") sub.prop(md, "scale_y", text="Scale Y") - def WAVE(self, layout, ob, md, wide_ui): + def WAVE(self, layout, ob, md): split = layout.split() col = split.column() @@ -715,8 +654,7 @@ class DATA_PT_modifiers(DataButtonsPanel): col.prop(md, "y") col.prop(md, "cyclic") - if wide_ui: - col = split.column() + col = split.column() col.prop(md, "normals") sub = col.column() sub.active = md.normals @@ -733,8 +671,7 @@ class DATA_PT_modifiers(DataButtonsPanel): sub.prop(md, "lifetime", text="Life") col.prop(md, "damping_time", text="Damping") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Position:") sub = col.column(align=True) sub.prop(md, "start_position_x", text="X") @@ -760,26 +697,17 @@ class DATA_PT_modifiers(DataButtonsPanel): col.prop(md, "speed", slider=True) col.prop(md, "height", slider=True) - if wide_ui: - col = split.column() + col = split.column() col.prop(md, "width", slider=True) col.prop(md, "narrowness", slider=True) -classes = [ - DATA_PT_modifiers] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_game.py b/release/scripts/ui/properties_game.py index 88803993c92..608976f373c 100644 --- a/release/scripts/ui/properties_game.py +++ b/release/scripts/ui/properties_game.py @@ -19,36 +19,31 @@ # <pep8 compliant> import bpy -narrowui = bpy.context.user_preferences.view.properties_width_check - -class PhysicsButtonsPanel(bpy.types.Panel): +class PhysicsButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "physics" - def poll(self, context): - ob = context.active_object - rd = context.scene.render - return ob and ob.game and (rd.engine in self.COMPAT_ENGINES) - -class PHYSICS_PT_game_physics(PhysicsButtonsPanel): +class PHYSICS_PT_game_physics(PhysicsButtonsPanel, bpy.types.Panel): bl_label = "Physics" COMPAT_ENGINES = {'BLENDER_GAME'} + @classmethod + def poll(cls, context): + ob = context.active_object + rd = context.scene.render + return ob and ob.game and (rd.engine in cls.COMPAT_ENGINES) + def draw(self, context): layout = self.layout ob = context.active_object game = ob.game soft = ob.game.soft_body - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(game, "physics_type") - else: - layout.prop(game, "physics_type", text="") + layout.prop(game, "physics_type") layout.separator() #if game.physics_type == 'DYNAMIC': @@ -60,8 +55,7 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel): col.prop(game, "ghost") col.prop(ob, "hide_render", text="Invisible") # out of place but useful - if wide_ui: - col = split.column() + col = split.column() col.prop(game, "material_physics") col.prop(game, "rotate_from_normal") col.prop(game, "no_sleeping") @@ -76,8 +70,7 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel): col.prop(game, "radius") col.prop(game, "form_factor") - if wide_ui: - col = split.column() + col = split.column() sub = col.column() sub.active = (game.physics_type == 'RIGID_BODY') sub.prop(game, "anisotropic_friction") @@ -93,8 +86,7 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel): sub.prop(game, "minimum_velocity", text="Minimum") sub.prop(game, "maximum_velocity", text="Maximum") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Damping:") sub = col.column(align=True) sub.prop(game, "damping", text="Translation", slider=True) @@ -136,8 +128,7 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel): col.prop(soft, "margin", slider=True) col.prop(soft, "bending_const", text="Bending Constraints") - if wide_ui: - col = split.column() + col = split.column() col.prop(soft, "shape_match") sub = col.column() sub.active = soft.shape_match @@ -162,14 +153,15 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel): layout.prop(ob, "hide_render", text="Invisible") -class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel): +class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel, bpy.types.Panel): bl_label = "Collision Bounds" COMPAT_ENGINES = {'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): game = context.object.game rd = context.scene.render - return (game.physics_type in ('DYNAMIC', 'RIGID_BODY', 'SENSOR', 'SOFT_BODY', 'STATIC')) and (rd.engine in self.COMPAT_ENGINES) + return (game.physics_type in ('DYNAMIC', 'RIGID_BODY', 'SENSOR', 'SOFT_BODY', 'STATIC')) and (rd.engine in cls.COMPAT_ENGINES) def draw_header(self, context): game = context.active_object.game @@ -180,35 +172,31 @@ class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel): layout = self.layout game = context.active_object.game - wide_ui = context.region.width > narrowui layout.active = game.use_collision_bounds - if wide_ui: - layout.prop(game, "collision_bounds", text="Bounds") - else: - layout.prop(game, "collision_bounds", text="") + layout.prop(game, "collision_bounds", text="Bounds") split = layout.split() col = split.column() col.prop(game, "collision_margin", text="Margin", slider=True) - if wide_ui: - col = split.column() + col = split.column() col.prop(game, "collision_compound", text="Compound") -class RenderButtonsPanel(bpy.types.Panel): +class RenderButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "render" - def poll(self, context): + @classmethod + def poll(cls, context): rd = context.scene.render - return (rd.engine in self.COMPAT_ENGINES) + return (rd.engine in cls.COMPAT_ENGINES) -class RENDER_PT_game(RenderButtonsPanel): +class RENDER_PT_game(RenderButtonsPanel, bpy.types.Panel): bl_label = "Game" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -220,7 +208,7 @@ class RENDER_PT_game(RenderButtonsPanel): row.label() -class RENDER_PT_game_player(RenderButtonsPanel): +class RENDER_PT_game_player(RenderButtonsPanel, bpy.types.Panel): bl_label = "Standalone Player" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -228,7 +216,6 @@ class RENDER_PT_game_player(RenderButtonsPanel): layout = self.layout gs = context.scene.game_data - wide_ui = context.region.width > narrowui layout.prop(gs, "fullscreen") @@ -240,8 +227,7 @@ class RENDER_PT_game_player(RenderButtonsPanel): sub.prop(gs, "resolution_x", slider=False, text="X") sub.prop(gs, "resolution_y", slider=False, text="Y") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Quality:") sub = col.column(align=True) sub.prop(gs, "depth", text="Bit Depth", slider=False) @@ -250,15 +236,12 @@ class RENDER_PT_game_player(RenderButtonsPanel): # framing: col = layout.column() col.label(text="Framing:") - if wide_ui: - col.row().prop(gs, "framing_type", expand=True) - else: - col.prop(gs, "framing_type", text="") + col.row().prop(gs, "framing_type", expand=True) if gs.framing_type == 'LETTERBOX': col.prop(gs, "framing_color", text="") -class RENDER_PT_game_stereo(RenderButtonsPanel): +class RENDER_PT_game_stereo(RenderButtonsPanel, bpy.types.Panel): bl_label = "Stereo" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -267,7 +250,6 @@ class RENDER_PT_game_stereo(RenderButtonsPanel): gs = context.scene.game_data stereo_mode = gs.stereo - wide_ui = context.region.width > narrowui # stereo options: layout.prop(gs, "stereo", expand=True) @@ -279,10 +261,7 @@ class RENDER_PT_game_stereo(RenderButtonsPanel): # dome: elif stereo_mode == 'DOME': - if wide_ui: - layout.prop(gs, "dome_mode", text="Dome Type") - else: - layout.prop(gs, "dome_mode", text="") + layout.prop(gs, "dome_mode", text="Dome Type") dome_type = gs.dome_mode @@ -296,8 +275,7 @@ class RENDER_PT_game_stereo(RenderButtonsPanel): col.prop(gs, "dome_buffer_resolution", text="Resolution", slider=True) col.prop(gs, "dome_angle", slider=True) - if wide_ui: - col = split.column() + col = split.column() col.prop(gs, "dome_tesselation", text="Tesselation") col.prop(gs, "dome_tilt") @@ -305,20 +283,19 @@ class RENDER_PT_game_stereo(RenderButtonsPanel): col = split.column() col.prop(gs, "dome_buffer_resolution", text="Resolution", slider=True) - if wide_ui: - col = split.column() + col = split.column() col.prop(gs, "dome_tesselation", text="Tesselation") else: # cube map col = split.column() col.prop(gs, "dome_buffer_resolution", text="Resolution", slider=True) - if wide_ui: - col = split.column() + + col = split.column() layout.prop(gs, "dome_text") -class RENDER_PT_game_shading(RenderButtonsPanel): +class RENDER_PT_game_shading(RenderButtonsPanel, bpy.types.Panel): bl_label = "Shading" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -326,12 +303,8 @@ class RENDER_PT_game_shading(RenderButtonsPanel): layout = self.layout gs = context.scene.game_data - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(gs, "material_mode", expand=True) - else: - layout.prop(gs, "material_mode", text="") + layout.prop(gs, "material_mode", expand=True) if gs.material_mode == 'GLSL': split = layout.split() @@ -347,7 +320,7 @@ class RENDER_PT_game_shading(RenderButtonsPanel): col.prop(gs, "glsl_extra_textures", text="Extra Textures") -class RENDER_PT_game_performance(RenderButtonsPanel): +class RENDER_PT_game_performance(RenderButtonsPanel, bpy.types.Panel): bl_label = "Performance" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -355,7 +328,6 @@ class RENDER_PT_game_performance(RenderButtonsPanel): layout = self.layout gs = context.scene.game_data - wide_ui = context.region.width > narrowui split = layout.split() @@ -366,14 +338,14 @@ class RENDER_PT_game_performance(RenderButtonsPanel): col.prop(gs, "show_physics_visualization", text="Physics Visualization") col.prop(gs, "use_deprecation_warnings") - if wide_ui: - col = split.column() + col = split.column() + col.label(text="Render:") col.prop(gs, "use_frame_rate") col.prop(gs, "use_display_lists") -class RENDER_PT_game_sound(RenderButtonsPanel): +class RENDER_PT_game_sound(RenderButtonsPanel, bpy.types.Panel): bl_label = "Sound" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -381,32 +353,26 @@ class RENDER_PT_game_sound(RenderButtonsPanel): layout = self.layout scene = context.scene - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(scene, "distance_model") - else: - layout.prop(scene, "distance_model", text="") + layout.prop(scene, "distance_model") + layout.prop(scene, "speed_of_sound", text="Speed") layout.prop(scene, "doppler_factor") -class WorldButtonsPanel(bpy.types.Panel): +class WorldButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "world" - def poll(self, context): - scene = context.scene - return (scene.render.engine in self.COMPAT_ENGINES) and (scene.world is not None) - -class WORLD_PT_game_context_world(WorldButtonsPanel): +class WORLD_PT_game_context_world(WorldButtonsPanel, bpy.types.Panel): bl_label = "" bl_show_header = False COMPAT_ENGINES = {'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): rd = context.scene.render return (context.scene) and (rd.use_game_engine) @@ -416,45 +382,46 @@ class WORLD_PT_game_context_world(WorldButtonsPanel): scene = context.scene world = context.world space = context.space_data - wide_ui = context.region.width > narrowui - - if wide_ui: - split = layout.split(percentage=0.65) - if scene: - split.template_ID(scene, "world", new="world.new") - elif world: - split.template_ID(space, "pin_id") - else: - if scene: - layout.template_ID(scene, "world", new="world.new") - elif world: - layout.template_ID(space, "pin_id") + + split = layout.split(percentage=0.65) + if scene: + split.template_ID(scene, "world", new="world.new") + elif world: + split.template_ID(space, "pin_id") -class WORLD_PT_game_world(WorldButtonsPanel): +class WORLD_PT_game_world(WorldButtonsPanel, bpy.types.Panel): bl_label = "World" COMPAT_ENGINES = {'BLENDER_GAME'} + @classmethod + def poll(cls, context): + scene = context.scene + return (scene.world and scene.render.engine in cls.COMPAT_ENGINES) + def draw(self, context): layout = self.layout world = context.world - wide_ui = context.region.width > narrowui split = layout.split() col = split.column() col.prop(world, "horizon_color") - if wide_ui: - col = split.column() + col = split.column() col.prop(world, "ambient_color") -class WORLD_PT_game_mist(WorldButtonsPanel): +class WORLD_PT_game_mist(WorldButtonsPanel, bpy.types.Panel): bl_label = "Mist" COMPAT_ENGINES = {'BLENDER_GAME'} + @classmethod + def poll(cls, context): + scene = context.scene + return (scene.world and scene.render.engine in cls.COMPAT_ENGINES) + def draw_header(self, context): world = context.world @@ -464,7 +431,6 @@ class WORLD_PT_game_mist(WorldButtonsPanel): layout = self.layout world = context.world - wide_ui = context.region.width > narrowui layout.active = world.mist.use_mist split = layout.split() @@ -472,20 +438,23 @@ class WORLD_PT_game_mist(WorldButtonsPanel): col = split.column() col.prop(world.mist, "start") - if wide_ui: - col = split.column() + col = split.column() col.prop(world.mist, "depth") -class WORLD_PT_game_physics(WorldButtonsPanel): +class WORLD_PT_game_physics(WorldButtonsPanel, bpy.types.Panel): bl_label = "Physics" COMPAT_ENGINES = {'BLENDER_GAME'} + @classmethod + def poll(cls, context): + scene = context.scene + return (scene.world and scene.render.engine in cls.COMPAT_ENGINES) + def draw(self, context): layout = self.layout gs = context.scene.game_data - wide_ui = context.region.width > narrowui layout.prop(gs, "physics_engine") if gs.physics_engine != 'NONE': @@ -500,8 +469,7 @@ class WORLD_PT_game_physics(WorldButtonsPanel): sub.prop(gs, "physics_step_sub", text="Substeps") col.prop(gs, "fps", text="FPS") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Logic Steps:") col.prop(gs, "logic_step_max", text="Max") @@ -523,33 +491,12 @@ class WORLD_PT_game_physics(WorldButtonsPanel): col.prop(gs, "logic_step_max", text="Max") -classes = [ - PHYSICS_PT_game_physics, - PHYSICS_PT_game_collision_bounds, - - RENDER_PT_game, - RENDER_PT_game_player, - RENDER_PT_game_stereo, - RENDER_PT_game_shading, - RENDER_PT_game_performance, - RENDER_PT_game_sound, - - WORLD_PT_game_context_world, - WORLD_PT_game_world, - WORLD_PT_game_mist, - WORLD_PT_game_physics] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_material.py b/release/scripts/ui/properties_material.py index 8d379491983..d14c8c05c63 100644 --- a/release/scripts/ui/properties_material.py +++ b/release/scripts/ui/properties_material.py @@ -20,8 +20,6 @@ import bpy from rna_prop_ui import PropertyPanel -narrowui = bpy.context.user_preferences.view.properties_width_check - def active_node_mat(mat): # TODO, 2.4x has a pipeline section, for 2.5 we need to communicate @@ -54,19 +52,18 @@ class MATERIAL_MT_specials(bpy.types.Menu): layout.operator("material.paste", icon='PASTEDOWN') -class MaterialButtonsPanel(bpy.types.Panel): +class MaterialButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "material" # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here - def poll(self, context): - mat = context.material - engine = context.scene.render.engine - return mat and (engine in self.COMPAT_ENGINES) + @classmethod + def poll(cls, context): + return context.material and (context.scene.render.engine in cls.COMPAT_ENGINES) -class MATERIAL_PT_preview(MaterialButtonsPanel): +class MATERIAL_PT_preview(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Preview" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -74,17 +71,18 @@ class MATERIAL_PT_preview(MaterialButtonsPanel): self.layout.template_preview(context.material) -class MATERIAL_PT_context_material(MaterialButtonsPanel): +class MATERIAL_PT_context_material(MaterialButtonsPanel, bpy.types.Panel): bl_label = "" bl_show_header = False COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): # An exception, dont call the parent poll func because # this manages materials for all engine types engine = context.scene.render.engine - return (context.material or context.object) and (engine in self.COMPAT_ENGINES) + return (context.material or context.object) and (engine in cls.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -93,7 +91,6 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel): ob = context.object slot = context.material_slot space = context.space_data - wide_ui = context.region.width > narrowui if ob: row = layout.row() @@ -112,54 +109,45 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel): row.operator("object.material_slot_select", text="Select") row.operator("object.material_slot_deselect", text="Deselect") - if wide_ui: - split = layout.split(percentage=0.65) - - if ob: - split.template_ID(ob, "active_material", new="material.new") - row = split.row() - if mat: - row.prop(mat, "use_nodes", icon="NODETREE", text="") - - if slot: - row.prop(slot, "link", text="") - else: - row.label() - elif mat: - split.template_ID(space, "pin_id") - split.separator() - else: - if ob: - layout.template_ID(ob, "active_material", new="material.new") - elif mat: - layout.template_ID(space, "pin_id") + split = layout.split(percentage=0.65) - if mat: - if wide_ui: - layout.prop(mat, "type", expand=True) + if ob: + split.template_ID(ob, "active_material", new="material.new") + row = split.row() + if mat: + row.prop(mat, "use_nodes", icon="NODETREE", text="") + + if slot: + row.prop(slot, "link", text="") else: - layout.prop(mat, "type", text="") + row.label() + elif mat: + split.template_ID(space, "pin_id") + split.separator() + if mat: + layout.prop(mat, "type", expand=True) -class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel): - COMPAT_ENGINES = {'BLENDER_RENDER'} + +class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel, bpy.types.Panel): + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "material" -class MATERIAL_PT_shading(MaterialButtonsPanel): +class MATERIAL_PT_shading(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Shading" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in cls.COMPAT_ENGINES) def draw(self, context): layout = self.layout mat = active_node_mat(context.material) - wide_ui = context.region.width > narrowui if mat.type in ('SURFACE', 'WIRE'): split = layout.split() @@ -172,8 +160,7 @@ class MATERIAL_PT_shading(MaterialButtonsPanel): sub = col.column() sub.prop(mat, "translucency") - if wide_ui: - col = split.column() + col = split.column() col.prop(mat, "shadeless") sub = col.column() sub.active = not mat.shadeless @@ -184,22 +171,22 @@ class MATERIAL_PT_shading(MaterialButtonsPanel): layout.prop(mat, "alpha") -class MATERIAL_PT_strand(MaterialButtonsPanel): +class MATERIAL_PT_strand(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Strand" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): mat = context.material engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in cls.COMPAT_ENGINES) def draw(self, context): layout = self.layout mat = context.material # dont use node material tan = mat.strand - wide_ui = context.region.width > narrowui split = layout.split() @@ -215,8 +202,7 @@ class MATERIAL_PT_strand(MaterialButtonsPanel): sub.prop(tan, "tangent_shading") col.prop(tan, "shape") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Shading:") col.prop(tan, "width_fade") ob = context.object @@ -233,15 +219,18 @@ class MATERIAL_PT_strand(MaterialButtonsPanel): sub.prop(tan, "blend_distance", text="Distance") -class MATERIAL_PT_physics(MaterialButtonsPanel): +class MATERIAL_PT_physics(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Physics" COMPAT_ENGINES = {'BLENDER_GAME'} + @classmethod + def poll(cls, context): + return context.material and (context.scene.render.engine in cls.COMPAT_ENGINES) + def draw(self, context): layout = self.layout phys = context.material.physics # dont use node material - wide_ui = context.region.width > narrowui split = layout.split() @@ -250,27 +239,26 @@ class MATERIAL_PT_physics(MaterialButtonsPanel): col.prop(phys, "friction") col.prop(phys, "align_to_normal") - if wide_ui: - col = split.column() + col = split.column() col.prop(phys, "force", slider=True) col.prop(phys, "elasticity", slider=True) col.prop(phys, "damp", slider=True) -class MATERIAL_PT_options(MaterialButtonsPanel): +class MATERIAL_PT_options(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Options" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in cls.COMPAT_ENGINES) def draw(self, context): layout = self.layout mat = active_node_mat(context.material) - wide_ui = context.region.width > narrowui split = layout.split() @@ -290,8 +278,7 @@ class MATERIAL_PT_options(MaterialButtonsPanel): row.active = bool(mat.light_group) row.prop(mat, "light_group_exclusive", text="Exclusive") - if wide_ui: - col = split.column() + col = split.column() col.prop(mat, "face_texture") sub = col.column() sub.active = mat.face_texture @@ -302,21 +289,21 @@ class MATERIAL_PT_options(MaterialButtonsPanel): col.prop(mat, "object_color") -class MATERIAL_PT_shadow(MaterialButtonsPanel): +class MATERIAL_PT_shadow(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Shadow" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in cls.COMPAT_ENGINES) def draw(self, context): layout = self.layout mat = active_node_mat(context.material) - wide_ui = context.region.width > narrowui split = layout.split() @@ -327,8 +314,7 @@ class MATERIAL_PT_shadow(MaterialButtonsPanel): col.prop(mat, "cast_shadows_only", text="Cast Only") col.prop(mat, "shadow_casting_alpha", text="Casting Alpha") - if wide_ui: - col = split.column() + col = split.column() col.prop(mat, "cast_buffer_shadows") sub = col.column() sub.active = mat.cast_buffer_shadows @@ -339,21 +325,20 @@ class MATERIAL_PT_shadow(MaterialButtonsPanel): sub.prop(mat, "shadow_ray_bias", text="Ray Bias") col.prop(mat, "cast_approximate") - -class MATERIAL_PT_diffuse(MaterialButtonsPanel): +class MATERIAL_PT_diffuse(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Diffuse" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in cls.COMPAT_ENGINES) def draw(self, context): layout = self.layout mat = active_node_mat(context.material) - wide_ui = context.region.width > narrowui split = layout.split() @@ -363,8 +348,7 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel): sub.active = (not mat.shadeless) sub.prop(mat, "diffuse_intensity", text="Intensity") - if wide_ui: - col = split.column() + col = split.column() col.active = (not mat.shadeless) col.prop(mat, "diffuse_shader", text="") col.prop(mat, "use_diffuse_ramp", text="Ramp") @@ -381,8 +365,7 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel): col = split.column() col.prop(mat, "diffuse_toon_size", text="Size") - if wide_ui: - col = split.column() + col = split.column() col.prop(mat, "diffuse_toon_smooth", text="Smooth") elif mat.diffuse_shader == 'FRESNEL': split = col.split() @@ -390,8 +373,7 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel): col = split.column() col.prop(mat, "diffuse_fresnel", text="Fresnel") - if wide_ui: - col = split.column() + col = split.column() col.prop(mat, "diffuse_fresnel_factor", text="Factor") if mat.use_diffuse_ramp: @@ -404,27 +386,26 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel): col = split.column() col.prop(mat, "diffuse_ramp_input", text="Input") - if wide_ui: - col = split.column() + col = split.column() col.prop(mat, "diffuse_ramp_blend", text="Blend") row = layout.row() row.prop(mat, "diffuse_ramp_factor", text="Factor") -class MATERIAL_PT_specular(MaterialButtonsPanel): +class MATERIAL_PT_specular(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Specular" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in cls.COMPAT_ENGINES) def draw(self, context): layout = self.layout mat = active_node_mat(context.material) - wide_ui = context.region.width > narrowui layout.active = (not mat.shadeless) @@ -434,8 +415,7 @@ class MATERIAL_PT_specular(MaterialButtonsPanel): col.prop(mat, "specular_color", text="") col.prop(mat, "specular_intensity", text="Intensity") - if wide_ui: - col = split.column() + col = split.column() col.prop(mat, "specular_shader", text="") col.prop(mat, "use_specular_ramp", text="Ramp") @@ -448,8 +428,7 @@ class MATERIAL_PT_specular(MaterialButtonsPanel): col = split.column() col.prop(mat, "specular_hardness", text="Hardness") - if wide_ui: - col = split.column() + col = split.column() col.prop(mat, "specular_ior", text="IOR") elif mat.specular_shader == 'WARDISO': col.prop(mat, "specular_slope", text="Slope") @@ -459,8 +438,7 @@ class MATERIAL_PT_specular(MaterialButtonsPanel): col = split.column() col.prop(mat, "specular_toon_size", text="Size") - if wide_ui: - col = split.column() + col = split.column() col.prop(mat, "specular_toon_smooth", text="Smooth") if mat.use_specular_ramp: @@ -472,23 +450,23 @@ class MATERIAL_PT_specular(MaterialButtonsPanel): col = split.column() col.prop(mat, "specular_ramp_input", text="Input") - if wide_ui: - col = split.column() + col = split.column() col.prop(mat, "specular_ramp_blend", text="Blend") row = layout.row() row.prop(mat, "specular_ramp_factor", text="Factor") -class MATERIAL_PT_sss(MaterialButtonsPanel): +class MATERIAL_PT_sss(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Subsurface Scattering" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in cls.COMPAT_ENGINES) def draw_header(self, context): mat = active_node_mat(context.material) @@ -502,7 +480,6 @@ class MATERIAL_PT_sss(MaterialButtonsPanel): mat = active_node_mat(context.material) sss = mat.subsurface_scattering - wide_ui = context.region.width > narrowui layout.active = (sss.enabled) and (not mat.shadeless) @@ -519,8 +496,7 @@ class MATERIAL_PT_sss(MaterialButtonsPanel): col.prop(sss, "color", text="") col.prop(sss, "radius", text="RGB Radius", expand=True) - if wide_ui: - col = split.column() + col = split.column() sub = col.column(align=True) sub.label(text="Blend:") sub.prop(sss, "color_factor", text="Color") @@ -532,15 +508,16 @@ class MATERIAL_PT_sss(MaterialButtonsPanel): col.prop(sss, "error_tolerance", text="Error") -class MATERIAL_PT_mirror(MaterialButtonsPanel): +class MATERIAL_PT_mirror(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Mirror" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in cls.COMPAT_ENGINES) def draw_header(self, context): raym = active_node_mat(context.material).raytrace_mirror @@ -552,7 +529,6 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel): mat = active_node_mat(context.material) raym = mat.raytrace_mirror - wide_ui = context.region.width > narrowui layout.active = raym.enabled @@ -562,8 +538,7 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel): col.prop(raym, "reflect_factor") col.prop(mat, "mirror_color", text="") - if wide_ui: - col = split.column() + col = split.column() col.prop(raym, "fresnel") sub = col.column() sub.active = raym.fresnel > 0 @@ -581,8 +556,7 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel): sub.label(text="Fade To:") sub.prop(raym, "fade_to", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Gloss:") col.prop(raym, "gloss_factor", text="Amount") sub = col.column() @@ -592,15 +566,16 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel): sub.prop(raym, "gloss_anisotropic", text="Anisotropic") -class MATERIAL_PT_transp(MaterialButtonsPanel): +class MATERIAL_PT_transp(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Transparency" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES) + return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in cls.COMPAT_ENGINES) def draw_header(self, context): mat = active_node_mat(context.material) @@ -612,14 +587,10 @@ class MATERIAL_PT_transp(MaterialButtonsPanel): mat = active_node_mat(context.material) rayt = mat.raytrace_transparency - wide_ui = context.region.width > narrowui row = layout.row() row.active = mat.transparency and (not mat.shadeless) - if wide_ui: - row.prop(mat, "transparency_method", expand=True) - else: - row.prop(mat, "transparency_method", text="") + row.prop(mat, "transparency_method", expand=True) split = layout.split() @@ -629,8 +600,7 @@ class MATERIAL_PT_transp(MaterialButtonsPanel): row.active = mat.transparency and (not mat.shadeless) row.prop(mat, "specular_alpha", text="Specular") - if wide_ui: - col = split.column() + col = split.column() col.active = (not mat.shadeless) col.prop(rayt, "fresnel") sub = col.column() @@ -649,8 +619,7 @@ class MATERIAL_PT_transp(MaterialButtonsPanel): col.prop(rayt, "limit") col.prop(rayt, "depth") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Gloss:") col.prop(rayt, "gloss_factor", text="Amount") sub = col.column() @@ -659,15 +628,16 @@ class MATERIAL_PT_transp(MaterialButtonsPanel): sub.prop(rayt, "gloss_samples", text="Samples") -class MATERIAL_PT_transp_game(MaterialButtonsPanel): +class MATERIAL_PT_transp_game(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Transparency" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): mat = active_node_mat(context.material) engine = context.scene.render.engine - return mat and (engine in self.COMPAT_ENGINES) + return mat and (engine in cls.COMPAT_ENGINES) def draw_header(self, context): mat = active_node_mat(context.material) @@ -679,14 +649,10 @@ class MATERIAL_PT_transp_game(MaterialButtonsPanel): mat = active_node_mat(context.material) rayt = mat.raytrace_transparency - wide_ui = context.region.width > narrowui row = layout.row() row.active = mat.transparency and (not mat.shadeless) - if wide_ui: - row.prop(mat, "transparency_method", expand=True) - else: - row.prop(mat, "transparency_method", text="") + row.prop(mat, "transparency_method", expand=True) split = layout.split() @@ -694,21 +660,21 @@ class MATERIAL_PT_transp_game(MaterialButtonsPanel): col.prop(mat, "alpha") -class MATERIAL_PT_halo(MaterialButtonsPanel): +class MATERIAL_PT_halo(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Halo" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): mat = context.material engine = context.scene.render.engine - return mat and (mat.type == 'HALO') and (engine in self.COMPAT_ENGINES) + return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES) def draw(self, context): layout = self.layout mat = context.material # dont use node material halo = mat.halo - wide_ui = context.region.width > narrowui split = layout.split() @@ -724,8 +690,7 @@ class MATERIAL_PT_halo(MaterialButtonsPanel): col.prop(halo, "shaded") col.prop(halo, "soft") - if wide_ui: - col = split.column() + col = split.column() col.prop(halo, "ring") sub = col.column() sub.active = halo.ring @@ -744,14 +709,15 @@ class MATERIAL_PT_halo(MaterialButtonsPanel): sub.prop(halo, "star_tips") -class MATERIAL_PT_flare(MaterialButtonsPanel): +class MATERIAL_PT_flare(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Flare" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): mat = context.material engine = context.scene.render.engine - return mat and (mat.type == 'HALO') and (engine in self.COMPAT_ENGINES) + return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES) def draw_header(self, context): halo = context.material.halo @@ -763,7 +729,6 @@ class MATERIAL_PT_flare(MaterialButtonsPanel): mat = context.material # dont use node material halo = mat.halo - wide_ui = context.region.width > narrowui layout.active = halo.flare_mode @@ -773,24 +738,26 @@ class MATERIAL_PT_flare(MaterialButtonsPanel): col.prop(halo, "flare_size", text="Size") col.prop(halo, "flare_boost", text="Boost") col.prop(halo, "flare_seed", text="Seed") - if wide_ui: - col = split.column() + + col = split.column() col.prop(halo, "flares_sub", text="Subflares") col.prop(halo, "flare_subsize", text="Subsize") -class VolumeButtonsPanel(bpy.types.Panel): +class VolumeButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "material" + COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): mat = context.material engine = context.scene.render.engine - return mat and (mat.type == 'VOLUME') and (engine in self.COMPAT_ENGINES) + return mat and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES) -class MATERIAL_PT_volume_density(VolumeButtonsPanel): +class MATERIAL_PT_volume_density(VolumeButtonsPanel, bpy.types.Panel): bl_label = "Density" bl_default_closed = False COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -799,18 +766,16 @@ class MATERIAL_PT_volume_density(VolumeButtonsPanel): layout = self.layout vol = context.material.volume # dont use node material - wide_ui = context.region.width > narrowui split = layout.split() col = split.column() col.prop(vol, "density") - if wide_ui: - col = split.column() + col = split.column() col.prop(vol, "density_scale") -class MATERIAL_PT_volume_shading(VolumeButtonsPanel): +class MATERIAL_PT_volume_shading(VolumeButtonsPanel, bpy.types.Panel): bl_label = "Shading" bl_default_closed = False COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -819,7 +784,6 @@ class MATERIAL_PT_volume_shading(VolumeButtonsPanel): layout = self.layout vol = context.material.volume # dont use node material - wide_ui = context.region.width > narrowui split = layout.split() @@ -828,8 +792,7 @@ class MATERIAL_PT_volume_shading(VolumeButtonsPanel): col.prop(vol, "asymmetry") col.prop(vol, "transmission_color") - if wide_ui: - col = split.column() + col = split.column() sub = col.column(align=True) sub.prop(vol, "emission") sub.prop(vol, "emission_color", text="") @@ -838,7 +801,7 @@ class MATERIAL_PT_volume_shading(VolumeButtonsPanel): sub.prop(vol, "reflection_color", text="") -class MATERIAL_PT_volume_lighting(VolumeButtonsPanel): +class MATERIAL_PT_volume_lighting(VolumeButtonsPanel, bpy.types.Panel): bl_label = "Lighting" bl_default_closed = False COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -847,15 +810,13 @@ class MATERIAL_PT_volume_lighting(VolumeButtonsPanel): layout = self.layout vol = context.material.volume # dont use node material - wide_ui = context.region.width > narrowui split = layout.split() col = split.column() col.prop(vol, "lighting_mode", text="") - if wide_ui: - col = split.column() + col = split.column() if vol.lighting_mode == 'SHADED': col.prop(vol, "external_shadows") @@ -876,7 +837,7 @@ class MATERIAL_PT_volume_lighting(VolumeButtonsPanel): sub.prop(vol, "ms_intensity") -class MATERIAL_PT_volume_transp(VolumeButtonsPanel): +class MATERIAL_PT_volume_transp(VolumeButtonsPanel, bpy.types.Panel): bl_label = "Transparency" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -884,15 +845,11 @@ class MATERIAL_PT_volume_transp(VolumeButtonsPanel): layout = self.layout mat = context.material # dont use node material - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(mat, "transparency_method", expand=True) - else: - layout.prop(mat, "transparency_method", text="") + layout.prop(mat, "transparency_method", expand=True) -class MATERIAL_PT_volume_integration(VolumeButtonsPanel): +class MATERIAL_PT_volume_integration(VolumeButtonsPanel, bpy.types.Panel): bl_label = "Integration" bl_default_closed = False COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -901,7 +858,6 @@ class MATERIAL_PT_volume_integration(VolumeButtonsPanel): layout = self.layout vol = context.material.volume # dont use node material - wide_ui = context.region.width > narrowui split = layout.split() @@ -911,13 +867,12 @@ class MATERIAL_PT_volume_integration(VolumeButtonsPanel): col = col.column(align=True) col.prop(vol, "step_size") - if wide_ui: - col = split.column() + col = split.column() col.label() col.prop(vol, "depth_cutoff") -class MATERIAL_PT_volume_options(VolumeButtonsPanel): +class MATERIAL_PT_volume_options(VolumeButtonsPanel, bpy.types.Panel): bl_label = "Options" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} bl_default_closed = True @@ -926,7 +881,6 @@ class MATERIAL_PT_volume_options(VolumeButtonsPanel): layout = self.layout mat = active_node_mat(context.material) - wide_ui = context.region.width > narrowui split = layout.split() @@ -943,46 +897,12 @@ class MATERIAL_PT_volume_options(VolumeButtonsPanel): row.prop(mat, "light_group_exclusive", text="Exclusive") -classes = [ - MATERIAL_PT_context_material, - MATERIAL_PT_preview, - MATERIAL_PT_diffuse, - MATERIAL_PT_specular, - MATERIAL_PT_shading, - MATERIAL_PT_transp, - MATERIAL_PT_mirror, - MATERIAL_PT_sss, - MATERIAL_PT_halo, - MATERIAL_PT_flare, - MATERIAL_PT_physics, - MATERIAL_PT_strand, - MATERIAL_PT_options, - MATERIAL_PT_shadow, - MATERIAL_PT_transp_game, - - MATERIAL_MT_sss_presets, - MATERIAL_MT_specials, - - MATERIAL_PT_volume_density, - MATERIAL_PT_volume_shading, - MATERIAL_PT_volume_lighting, - MATERIAL_PT_volume_transp, - MATERIAL_PT_volume_integration, - MATERIAL_PT_volume_options, - - MATERIAL_PT_custom_props] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_object.py b/release/scripts/ui/properties_object.py index 4e60879d665..6923e60a3df 100644 --- a/release/scripts/ui/properties_object.py +++ b/release/scripts/ui/properties_object.py @@ -20,16 +20,14 @@ import bpy from rna_prop_ui import PropertyPanel -narrowui = bpy.context.user_preferences.view.properties_width_check - -class ObjectButtonsPanel(bpy.types.Panel): +class ObjectButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "object" -class OBJECT_PT_context_object(ObjectButtonsPanel): +class OBJECT_PT_context_object(ObjectButtonsPanel, bpy.types.Panel): bl_label = "" bl_show_header = False @@ -46,51 +44,33 @@ class OBJECT_PT_context_object(ObjectButtonsPanel): row.prop(ob, "name", text="") -class OBJECT_PT_custom_props(ObjectButtonsPanel, PropertyPanel): - _context_path = "object" - - -class OBJECT_PT_transform(ObjectButtonsPanel): +class OBJECT_PT_transform(ObjectButtonsPanel, bpy.types.Panel): bl_label = "Transform" def draw(self, context): layout = self.layout ob = context.object - wide_ui = context.region.width > narrowui - if wide_ui: - row = layout.row() + row = layout.row() - row.column().prop(ob, "location") - if ob.rotation_mode == 'QUATERNION': - row.column().prop(ob, "rotation_quaternion", text="Rotation") - elif ob.rotation_mode == 'AXIS_ANGLE': - #row.column().label(text="Rotation") - #row.column().prop(pchan, "rotation_angle", text="Angle") - #row.column().prop(pchan, "rotation_axis", text="Axis") - row.column().prop(ob, "rotation_axis_angle", text="Rotation") - else: - row.column().prop(ob, "rotation_euler", text="Rotation") + row.column().prop(ob, "location") + if ob.rotation_mode == 'QUATERNION': + row.column().prop(ob, "rotation_quaternion", text="Rotation") + elif ob.rotation_mode == 'AXIS_ANGLE': + #row.column().label(text="Rotation") + #row.column().prop(pchan, "rotation_angle", text="Angle") + #row.column().prop(pchan, "rotation_axis", text="Axis") + row.column().prop(ob, "rotation_axis_angle", text="Rotation") + else: + row.column().prop(ob, "rotation_euler", text="Rotation") - row.column().prop(ob, "scale") + row.column().prop(ob, "scale") - layout.prop(ob, "rotation_mode") - else: - col = layout.column() - col.prop(ob, "location") - col.label(text="Rotation:") - col.prop(ob, "rotation_mode", text="") - if ob.rotation_mode == 'QUATERNION': - col.prop(ob, "rotation_quaternion", text="") - elif ob.rotation_mode == 'AXIS_ANGLE': - col.prop(ob, "rotation_axis_angle", text="") - else: - col.prop(ob, "rotation_euler", text="") - col.prop(ob, "scale") - - -class OBJECT_PT_transform_locks(ObjectButtonsPanel): + layout.prop(ob, "rotation_mode") + + +class OBJECT_PT_transform_locks(ObjectButtonsPanel, bpy.types.Panel): bl_label = "Transform Locks" bl_default_closed = True @@ -98,7 +78,6 @@ class OBJECT_PT_transform_locks(ObjectButtonsPanel): layout = self.layout ob = context.object - # wide_ui = context.region.width > narrowui row = layout.row() @@ -117,14 +96,13 @@ class OBJECT_PT_transform_locks(ObjectButtonsPanel): row.column().prop(ob, "lock_scale", text="Scale") -class OBJECT_PT_relations(ObjectButtonsPanel): +class OBJECT_PT_relations(ObjectButtonsPanel, bpy.types.Panel): bl_label = "Relations" def draw(self, context): layout = self.layout ob = context.object - wide_ui = context.region.width > narrowui split = layout.split() @@ -133,8 +111,7 @@ class OBJECT_PT_relations(ObjectButtonsPanel): col.separator() col.prop(ob, "pass_index") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Parent:") col.prop(ob, "parent", text="") @@ -146,14 +123,13 @@ class OBJECT_PT_relations(ObjectButtonsPanel): sub.active = (parent is not None) -class OBJECT_PT_groups(ObjectButtonsPanel): +class OBJECT_PT_groups(ObjectButtonsPanel, bpy.types.Panel): bl_label = "Groups" def draw(self, context): layout = self.layout ob = context.object - wide_ui = context.region.width > narrowui row = layout.row(align=True) row.operator("object.group_link", text="Add to Group") @@ -177,8 +153,7 @@ class OBJECT_PT_groups(ObjectButtonsPanel): col = split.column() col.prop(group, "layer", text="Dupli") - if wide_ui: - col = split.column() + col = split.column() col.prop(group, "dupli_offset", text="") prop = col.operator("wm.context_set_value", text="From Cursor") @@ -187,21 +162,19 @@ class OBJECT_PT_groups(ObjectButtonsPanel): index += 1 -class OBJECT_PT_display(ObjectButtonsPanel): +class OBJECT_PT_display(ObjectButtonsPanel, bpy.types.Panel): bl_label = "Display" def draw(self, context): layout = self.layout ob = context.object - wide_ui = context.region.width > narrowui split = layout.split() col = split.column() col.prop(ob, "max_draw_type", text="Type") - if wide_ui: - col = split.column() + col = split.column() row = col.row() row.prop(ob, "draw_bounds", text="Bounds") sub = row.row() @@ -216,26 +189,21 @@ class OBJECT_PT_display(ObjectButtonsPanel): col.prop(ob, "draw_wire", text="Wire") col.prop(ob, "color", text="Object Color") - if wide_ui: - col = split.column() + col = split.column() col.prop(ob, "draw_texture_space", text="Texture Space") col.prop(ob, "x_ray", text="X-Ray") col.prop(ob, "draw_transparent", text="Transparency") -class OBJECT_PT_duplication(ObjectButtonsPanel): +class OBJECT_PT_duplication(ObjectButtonsPanel, bpy.types.Panel): bl_label = "Duplication" def draw(self, context): layout = self.layout ob = context.object - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(ob, "dupli_type", expand=True) - else: - layout.prop(ob, "dupli_type", text="") + layout.prop(ob, "dupli_type", expand=True) if ob.dupli_type == 'FRAMES': split = layout.split() @@ -244,8 +212,7 @@ class OBJECT_PT_duplication(ObjectButtonsPanel): col.prop(ob, "dupli_frames_start", text="Start") col.prop(ob, "dupli_frames_end", text="End") - if wide_ui: - col = split.column(align=True) + col = split.column(align=True) col.prop(ob, "dupli_frames_on", text="On") col.prop(ob, "dupli_frames_off", text="Off") @@ -260,20 +227,16 @@ class OBJECT_PT_duplication(ObjectButtonsPanel): col = split.column() col.prop(ob, "use_dupli_faces_scale", text="Scale") - if wide_ui: - col = split.column() + col = split.column() col.prop(ob, "dupli_faces_scale", text="Inherit Scale") elif ob.dupli_type == 'GROUP': - if wide_ui: - layout.prop(ob, "dupli_group", text="Group") - else: - layout.prop(ob, "dupli_group", text="") + layout.prop(ob, "dupli_group", text="Group") -# XXX: the following options are all quite buggy, ancient hacks that should be dropped +# XXX: the following options are all quite buggy, ancient hacks that should be dropped -class OBJECT_PT_animation(ObjectButtonsPanel): +class OBJECT_PT_animation(ObjectButtonsPanel, bpy.types.Panel): bl_label = "Animation Hacks" bl_default_closed = True @@ -281,7 +244,6 @@ class OBJECT_PT_animation(ObjectButtonsPanel): layout = self.layout ob = context.object - wide_ui = context.region.width > narrowui split = layout.split() @@ -300,42 +262,67 @@ class OBJECT_PT_animation(ObjectButtonsPanel): col.prop(ob, "time_offset", text="Offset") # XXX: these are still used for a few curve-related tracking features - if wide_ui: - col = split.column() + col = split.column() col.label(text="Tracking Axes:") col.prop(ob, "track_axis", text="Axis") col.prop(ob, "up_axis", text="Up Axis") +from properties_animviz import MotionPathButtonsPanel, OnionSkinButtonsPanel + -# import generic panels from other files -from properties_animviz import OBJECT_PT_motion_paths, OBJECT_PT_onion_skinning +class OBJECT_PT_motion_paths(MotionPathButtonsPanel, bpy.types.Panel): + #bl_label = "Object Motion Paths" + bl_context = "object" + + @classmethod + def poll(cls, context): + return (context.object) + + def draw(self, context): + layout = self.layout + + ob = context.object -classes = [ - OBJECT_PT_context_object, - OBJECT_PT_transform, - OBJECT_PT_transform_locks, - OBJECT_PT_relations, - OBJECT_PT_groups, - OBJECT_PT_display, - OBJECT_PT_duplication, - OBJECT_PT_animation, # XXX: panel of old hacks pending to be removed... + self.draw_settings(context, ob.animation_visualisation) - OBJECT_PT_motion_paths, - #OBJECT_PT_onion_skinning, + layout.separator() + + split = layout.split() + + col = split.column() + col.operator("object.paths_calculate", text="Calculate Paths") + + col = split.column() + col.operator("object.paths_clear", text="Clear Paths") - OBJECT_PT_custom_props] + +class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel): #, bpy.types.Panel): # inherit from panel when ready + #bl_label = "Object Onion Skinning" + bl_context = "object" + + @classmethod + def poll(cls, context): + return (context.object) + + def draw(self, context): + layout = self.layout + + ob = context.object + + self.draw_settings(context, ob.animation_visualisation) + + +class OBJECT_PT_custom_props(ObjectButtonsPanel, PropertyPanel, bpy.types.Panel): + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + _context_path = "object" def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_object_constraint.py b/release/scripts/ui/properties_object_constraint.py index edeadb9326b..b3a96841d71 100644 --- a/release/scripts/ui/properties_object_constraint.py +++ b/release/scripts/ui/properties_object_constraint.py @@ -19,11 +19,8 @@ # <pep8 compliant> import bpy -narrowui = bpy.context.user_preferences.view.properties_width_check -narrowcon = 260 - -class ConstraintButtonsPanel(bpy.types.Panel): +class ConstraintButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "constraint" @@ -31,52 +28,38 @@ class ConstraintButtonsPanel(bpy.types.Panel): def draw_constraint(self, context, con): layout = self.layout - wide_ui = context.region.width > narrowui - compact_con = context.region.width < narrowcon - box = layout.template_constraint(con, compact=compact_con) + box = layout.template_constraint(con) if box: # match enum type to our functions, avoids a lookup table. - getattr(self, con.type)(context, box, con, wide_ui) + getattr(self, con.type)(context, box, con) if con.type not in ('RIGID_BODY_JOINT', 'NULL'): box.prop(con, "influence") - def space_template(self, layout, con, wide_ui, target=True, owner=True): + def space_template(self, layout, con, target=True, owner=True): if target or owner: split = layout.split(percentage=0.2) - if wide_ui: - split.label(text="Space:") - row = split.row() - else: - row = layout.row() - + split.label(text="Space:") + row = split.row() if target: row.prop(con, "target_space", text="") - if wide_ui: - if target and owner: - row.label(icon='ARROW_LEFTRIGHT') - else: - row = layout.row() + if target and owner: + row.label(icon='ARROW_LEFTRIGHT') + if owner: row.prop(con, "owner_space", text="") - def target_template(self, layout, con, wide_ui, subtargets=True): - if wide_ui: - layout.prop(con, "target") # XXX limiting settings for only 'curves' or some type of object - else: - layout.prop(con, "target", text="") + def target_template(self, layout, con, subtargets=True): + layout.prop(con, "target") # XXX limiting settings for only 'curves' or some type of object if con.target and subtargets: if con.target.type == 'ARMATURE': - if wide_ui: - layout.prop_object(con, "subtarget", con.target.data, "bones", text="Bone") - else: - layout.prop_object(con, "subtarget", con.target.data, "bones", text="") + layout.prop_object(con, "subtarget", con.target.data, "bones", text="Bone") if con.type in ('COPY_LOCATION', 'STRETCH_TO', 'TRACK_TO', 'PIVOT'): row = layout.row() @@ -85,7 +68,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): elif con.target.type in ('MESH', 'LATTICE'): layout.prop_object(con, "subtarget", con.target, "vertex_groups", text="Vertex Group") - def ik_template(self, layout, con, wide_ui): + def ik_template(self, layout, con): # only used for iTaSC layout.prop(con, "pole_target") @@ -106,8 +89,8 @@ class ConstraintButtonsPanel(bpy.types.Panel): col.prop(con, "chain_length") col.prop(con, "use_target") - def CHILD_OF(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def CHILD_OF(self, context, layout, con): + self.target_template(layout, con) split = layout.split() @@ -134,16 +117,14 @@ class ConstraintButtonsPanel(bpy.types.Panel): col = split.column() col.operator("constraint.childof_set_inverse") - if wide_ui: - col = split.column() + col = split.column() col.operator("constraint.childof_clear_inverse") - def TRACK_TO(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def TRACK_TO(self, context, layout, con): + self.target_template(layout, con) row = layout.row() - if wide_ui: - row.label(text="To:") + row.label(text="To:") row.prop(con, "track", expand=True) split = layout.split() @@ -151,34 +132,27 @@ class ConstraintButtonsPanel(bpy.types.Panel): col = split.column() col.prop(con, "up", text="Up") - if wide_ui: - col = split.column() + col = split.column() col.prop(con, "target_z") - self.space_template(layout, con, wide_ui) + self.space_template(layout, con) - def IK(self, context, layout, con, wide_ui): + def IK(self, context, layout, con): if context.object.pose.ik_solver == "ITASC": layout.prop(con, "ik_type") - getattr(self, 'IK_' + con.ik_type)(context, layout, con, wide_ui) + getattr(self, 'IK_' + con.ik_type)(context, layout, con) else: # Legacy IK constraint - self.target_template(layout, con, wide_ui) - if wide_ui: - layout.prop(con, "pole_target") - else: - layout.prop(con, "pole_target", text="") + self.target_template(layout, con) + layout.prop(con, "pole_target") + if con.pole_target and con.pole_target.type == 'ARMATURE': - if wide_ui: - layout.prop_object(con, "pole_subtarget", con.pole_target.data, "bones", text="Bone") - else: - layout.prop_object(con, "pole_subtarget", con.pole_target.data, "bones", text="") + layout.prop_object(con, "pole_subtarget", con.pole_target.data, "bones", text="Bone") if con.pole_target: row = layout.row() row.prop(con, "pole_angle") - if wide_ui: - row.label() + row.label() split = layout.split() col = split.column() @@ -191,17 +165,16 @@ class ConstraintButtonsPanel(bpy.types.Panel): sub.active = con.use_rotation sub.prop(con, "orient_weight", text="Rotation", slider=True) - if wide_ui: - col = split.column() + col = split.column() col.prop(con, "use_tail") col.prop(con, "use_stretch") col.separator() col.prop(con, "use_target") col.prop(con, "use_rotation") - def IK_COPY_POSE(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) - self.ik_template(layout, con, wide_ui) + def IK_COPY_POSE(self, context, layout, con): + self.target_template(layout, con) + self.ik_template(layout, con) row = layout.row() row.label(text="Axis Ref:") @@ -234,17 +207,17 @@ class ConstraintButtonsPanel(bpy.types.Panel): row.prop(con, "rot_lock_z", text="Z") split.active = con.use_rotation - def IK_DISTANCE(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) - self.ik_template(layout, con, wide_ui) + def IK_DISTANCE(self, context, layout, con): + self.target_template(layout, con) + self.ik_template(layout, con) layout.prop(con, "limit_mode") row = layout.row() row.prop(con, "weight", text="Weight", slider=True) row.prop(con, "distance", text="Distance", slider=True) - def FOLLOW_PATH(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def FOLLOW_PATH(self, context, layout, con): + self.target_template(layout, con) split = layout.split() @@ -252,8 +225,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): col.prop(con, "use_curve_follow") col.prop(con, "use_curve_radius") - if wide_ui: - col = split.column() + col = split.column() col.prop(con, "use_fixed_position") if con.use_fixed_position: col.prop(con, "offset_factor", text="Offset") @@ -261,16 +233,14 @@ class ConstraintButtonsPanel(bpy.types.Panel): col.prop(con, "offset") row = layout.row() - if wide_ui: - row.label(text="Forward:") + row.label(text="Forward:") row.prop(con, "forward", expand=True) row = layout.row() row.prop(con, "up", text="Up") - if wide_ui: - row.label() + row.label() - def LIMIT_ROTATION(self, context, layout, con, wide_ui): + def LIMIT_ROTATION(self, context, layout, con): split = layout.split() @@ -281,16 +251,14 @@ class ConstraintButtonsPanel(bpy.types.Panel): sub.prop(con, "minimum_x", text="Min") sub.prop(con, "maximum_x", text="Max") - if wide_ui: - col = split.column(align=True) + col = split.column(align=True) col.prop(con, "use_limit_y") sub = col.column() sub.active = con.use_limit_y sub.prop(con, "minimum_y", text="Min") sub.prop(con, "maximum_y", text="Max") - if wide_ui: - col = split.column(align=True) + col = split.column(align=True) col.prop(con, "use_limit_z") sub = col.column() sub.active = con.use_limit_z @@ -299,15 +267,13 @@ class ConstraintButtonsPanel(bpy.types.Panel): row = layout.row() row.prop(con, "limit_transform") - if wide_ui: - row.label() + row.label() row = layout.row() - if wide_ui: - row.label(text="Convert:") + row.label(text="Convert:") row.prop(con, "owner_space", text="") - def LIMIT_LOCATION(self, context, layout, con, wide_ui): + def LIMIT_LOCATION(self, context, layout, con): split = layout.split() col = split.column() @@ -320,8 +286,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): sub.active = con.use_maximum_x sub.prop(con, "maximum_x", text="") - if wide_ui: - col = split.column() + col = split.column() col.prop(con, "use_minimum_y") sub = col.column() sub.active = con.use_minimum_y @@ -331,8 +296,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): sub.active = con.use_maximum_y sub.prop(con, "maximum_y", text="") - if wide_ui: - col = split.column() + col = split.column() col.prop(con, "use_minimum_z") sub = col.column() sub.active = con.use_minimum_z @@ -344,15 +308,13 @@ class ConstraintButtonsPanel(bpy.types.Panel): row = layout.row() row.prop(con, "limit_transform") - if wide_ui: - row.label() + row.label() row = layout.row() - if wide_ui: - row.label(text="Convert:") + row.label(text="Convert:") row.prop(con, "owner_space", text="") - def LIMIT_SCALE(self, context, layout, con, wide_ui): + def LIMIT_SCALE(self, context, layout, con): split = layout.split() col = split.column() @@ -365,8 +327,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): sub.active = con.use_maximum_x sub.prop(con, "maximum_x", text="") - if wide_ui: - col = split.column() + col = split.column() col.prop(con, "use_minimum_y") sub = col.column() sub.active = con.use_minimum_y @@ -376,8 +337,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): sub.active = con.use_maximum_y sub.prop(con, "maximum_y", text="") - if wide_ui: - col = split.column() + col = split.column() col.prop(con, "use_minimum_z") sub = col.column() sub.active = con.use_minimum_z @@ -389,16 +349,14 @@ class ConstraintButtonsPanel(bpy.types.Panel): row = layout.row() row.prop(con, "limit_transform") - if wide_ui: - row.label() + row.label() row = layout.row() - if wide_ui: - row.label(text="Convert:") + row.label(text="Convert:") row.prop(con, "owner_space", text="") - def COPY_ROTATION(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def COPY_ROTATION(self, context, layout, con): + self.target_template(layout, con) split = layout.split() @@ -422,10 +380,10 @@ class ConstraintButtonsPanel(bpy.types.Panel): layout.prop(con, "use_offset") - self.space_template(layout, con, wide_ui) + self.space_template(layout, con) - def COPY_LOCATION(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def COPY_LOCATION(self, context, layout, con): + self.target_template(layout, con) split = layout.split() @@ -449,10 +407,10 @@ class ConstraintButtonsPanel(bpy.types.Panel): layout.prop(con, "use_offset") - self.space_template(layout, con, wide_ui) + self.space_template(layout, con) - def COPY_SCALE(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def COPY_SCALE(self, context, layout, con): + self.target_template(layout, con) row = layout.row(align=True) row.prop(con, "use_x", text="X") @@ -461,38 +419,31 @@ class ConstraintButtonsPanel(bpy.types.Panel): layout.prop(con, "use_offset") - self.space_template(layout, con, wide_ui) + self.space_template(layout, con) - def MAINTAIN_VOLUME(self, context, layout, con, wide_ui): + def MAINTAIN_VOLUME(self, context, layout, con): row = layout.row() - if wide_ui: - row.label(text="Free:") + row.label(text="Free:") row.prop(con, "axis", expand=True) layout.prop(con, "volume") - self.space_template(layout, con, wide_ui) + self.space_template(layout, con) - def COPY_TRANSFORMS(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def COPY_TRANSFORMS(self, context, layout, con): + self.target_template(layout, con) - self.space_template(layout, con, wide_ui) + self.space_template(layout, con) #def SCRIPT(self, context, layout, con): - def ACTION(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def ACTION(self, context, layout, con): + self.target_template(layout, con) - if wide_ui: - layout.prop(con, "action") - else: - layout.prop(con, "action", text="") + layout.prop(con, "action") - if wide_ui: - layout.prop(con, "transform_channel") - else: - layout.prop(con, "transform_channel", text="") + layout.prop(con, "transform_channel") split = layout.split() @@ -501,32 +452,28 @@ class ConstraintButtonsPanel(bpy.types.Panel): col.prop(con, "frame_start", text="Start") col.prop(con, "frame_end", text="End") - if wide_ui: - col = split.column(align=True) + col = split.column(align=True) col.label(text="Target Range:") col.prop(con, "minimum", text="Min") col.prop(con, "maximum", text="Max") row = layout.row() - if wide_ui: - row.label(text="Convert:") + row.label(text="Convert:") row.prop(con, "target_space", text="") - def LOCKED_TRACK(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def LOCKED_TRACK(self, context, layout, con): + self.target_template(layout, con) row = layout.row() - if wide_ui: - row.label(text="To:") + row.label(text="To:") row.prop(con, "track", expand=True) row = layout.row() - if wide_ui: - row.label(text="Lock:") + row.label(text="Lock:") row.prop(con, "lock", expand=True) - def LIMIT_DISTANCE(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def LIMIT_DISTANCE(self, context, layout, con): + self.target_template(layout, con) col = layout.column(align=True) col.prop(con, "distance") @@ -536,70 +483,58 @@ class ConstraintButtonsPanel(bpy.types.Panel): row.label(text="Clamp Region:") row.prop(con, "limit_mode", text="") - def STRETCH_TO(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def STRETCH_TO(self, context, layout, con): + self.target_template(layout, con) split = layout.split() col = split.column() col.prop(con, "original_length", text="Rest Length") - if wide_ui: - col = split.column() + col = split.column() col.operator("constraint.stretchto_reset", text="Reset") col = layout.column() col.prop(con, "bulge", text="Volume Variation") row = layout.row() - if wide_ui: - row.label(text="Volume:") + row.label(text="Volume:") row.prop(con, "volume", expand=True) - if not wide_ui: - row = layout.row() + row.label(text="Plane:") row.prop(con, "keep_axis", expand=True) - def FLOOR(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def FLOOR(self, context, layout, con): + self.target_template(layout, con) split = layout.split() col = split.column() col.prop(con, "sticky") - if wide_ui: - col = split.column() + col = split.column() col.prop(con, "use_rotation") layout.prop(con, "offset") row = layout.row() - if wide_ui: - row.label(text="Min/Max:") + row.label(text="Min/Max:") row.prop(con, "floor_location", expand=True) - self.space_template(layout, con, wide_ui) + self.space_template(layout, con) - def RIGID_BODY_JOINT(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def RIGID_BODY_JOINT(self, context, layout, con): + self.target_template(layout, con) - if wide_ui: - layout.prop(con, "pivot_type") - else: - layout.prop(con, "pivot_type", text="") - if wide_ui: - layout.prop(con, "child") - else: - layout.prop(con, "child", text="") + layout.prop(con, "pivot_type") + layout.prop(con, "child") split = layout.split() col = split.column() col.prop(con, "disable_linked_collision", text="No Collision") - if wide_ui: - col = split.column() + col = split.column() col.prop(con, "draw_pivot", text="Display Pivot") split = layout.split() @@ -610,8 +545,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): col.prop(con, "pivot_y", text="Y") col.prop(con, "pivot_z", text="Z") - if wide_ui: - col = split.column(align=True) + col = split.column(align=True) col.label(text="Axis:") col.prop(con, "axis_x", text="X") col.prop(con, "axis_y", text="Y") @@ -619,19 +553,18 @@ class ConstraintButtonsPanel(bpy.types.Panel): #Missing: Limit arrays (not wrapped in RNA yet) - def CLAMP_TO(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def CLAMP_TO(self, context, layout, con): + self.target_template(layout, con) row = layout.row() - if wide_ui: - row.label(text="Main Axis:") + row.label(text="Main Axis:") row.prop(con, "main_axis", expand=True) row = layout.row() row.prop(con, "cyclic") - def TRANSFORM(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def TRANSFORM(self, context, layout, con): + self.target_template(layout, con) layout.prop(con, "extrapolate_motion", text="Extrapolate") @@ -646,14 +579,12 @@ class ConstraintButtonsPanel(bpy.types.Panel): sub.prop(con, "from_min_x", text="Min") sub.prop(con, "from_max_x", text="Max") - if wide_ui: - sub = split.column(align=True) + sub = split.column(align=True) sub.label(text="Y:") sub.prop(con, "from_min_y", text="Min") sub.prop(con, "from_max_y", text="Max") - if wide_ui: - sub = split.column(align=True) + sub = split.column(align=True) sub.label(text="Z:") sub.prop(con, "from_min_z", text="Min") sub.prop(con, "from_max_z", text="Max") @@ -674,8 +605,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): sub.prop(con, "to_min_x", text="Min") sub.prop(con, "to_max_x", text="Max") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Y:") col.row().prop(con, "map_to_y_from", expand=True) @@ -683,8 +613,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): sub.prop(con, "to_min_y", text="Min") sub.prop(con, "to_max_y", text="Max") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Z:") col.row().prop(con, "map_to_z_from", expand=True) @@ -692,10 +621,10 @@ class ConstraintButtonsPanel(bpy.types.Panel): sub.prop(con, "to_min_z", text="Min") sub.prop(con, "to_max_z", text="Max") - self.space_template(layout, con, wide_ui) + self.space_template(layout, con) - def SHRINKWRAP(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def SHRINKWRAP(self, context, layout, con): + self.target_template(layout, con) layout.prop(con, "distance") layout.prop(con, "shrinkwrap_type") @@ -706,16 +635,15 @@ class ConstraintButtonsPanel(bpy.types.Panel): row.prop(con, "use_y") row.prop(con, "use_z") - def DAMPED_TRACK(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def DAMPED_TRACK(self, context, layout, con): + self.target_template(layout, con) row = layout.row() - if wide_ui: - row.label(text="To:") + row.label(text="To:") row.prop(con, "track", expand=True) - def SPLINE_IK(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def SPLINE_IK(self, context, layout, con): + self.target_template(layout, con) col = layout.column() col.label(text="Spline Fitting:") @@ -726,14 +654,11 @@ class ConstraintButtonsPanel(bpy.types.Panel): col = layout.column() col.label(text="Chain Scaling:") col.prop(con, "y_stretch") - if wide_ui: - col.prop(con, "xz_scaling_mode") - else: - col.prop(con, "xz_scaling_mode", text="") + col.prop(con, "xz_scaling_mode") col.prop(con, "use_curve_radius") - def PIVOT(self, context, layout, con, wide_ui): - self.target_template(layout, con, wide_ui) + def PIVOT(self, context, layout, con): + self.target_template(layout, con) if con.target: col = layout.column() @@ -749,12 +674,12 @@ class ConstraintButtonsPanel(bpy.types.Panel): col = layout.column() col.prop(con, "enabled_rotation_range", text="Pivot When") - -class OBJECT_PT_constraints(ConstraintButtonsPanel): +class OBJECT_PT_constraints(ConstraintButtonsPanel, bpy.types.Panel): bl_label = "Object Constraints" bl_context = "constraint" - def poll(self, context): + @classmethod + def poll(cls, context): return (context.object) def draw(self, context): @@ -768,11 +693,12 @@ class OBJECT_PT_constraints(ConstraintButtonsPanel): self.draw_constraint(context, con) -class BONE_PT_constraints(ConstraintButtonsPanel): +class BONE_PT_constraints(ConstraintButtonsPanel, bpy.types.Panel): bl_label = "Bone Constraints" bl_context = "bone_constraint" - def poll(self, context): + @classmethod + def poll(cls, context): return (context.pose_bone) def draw(self, context): @@ -784,21 +710,12 @@ class BONE_PT_constraints(ConstraintButtonsPanel): self.draw_constraint(context, con) -classes = [ - OBJECT_PT_constraints, - BONE_PT_constraints] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_particle.py b/release/scripts/ui/properties_particle.py index f858c9b8511..72e804a1cef 100644 --- a/release/scripts/ui/properties_particle.py +++ b/release/scripts/ui/properties_particle.py @@ -25,40 +25,40 @@ from properties_physics_common import effector_weights_ui from properties_physics_common import basic_force_field_settings_ui from properties_physics_common import basic_force_field_falloff_ui -narrowui = bpy.context.user_preferences.view.properties_width_check - def particle_panel_enabled(context, psys): return (psys.point_cache.baked is False) and (not psys.edited) and (not context.particle_system_editable) -def particle_panel_poll(panel, context): +def particle_panel_poll(cls, context): psys = context.particle_system engine = context.scene.render.engine if psys is None: return False if psys.settings is None: return False - return psys.settings.type in ('EMITTER', 'REACTOR', 'HAIR') and (engine in panel.COMPAT_ENGINES) + return psys.settings.type in ('EMITTER', 'REACTOR', 'HAIR') and (engine in cls.COMPAT_ENGINES) -class ParticleButtonsPanel(bpy.types.Panel): +class ParticleButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "particle" - def poll(self, context): - return particle_panel_poll(self, context) + @classmethod + def poll(cls, context): + return particle_panel_poll(cls, context) -class PARTICLE_PT_context_particles(ParticleButtonsPanel): +class PARTICLE_PT_context_particles(ParticleButtonsPanel, bpy.types.Panel): bl_label = "" bl_show_header = False COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): engine = context.scene.render.engine - return (context.particle_system or context.object) and (engine in self.COMPAT_ENGINES) + return (context.particle_system or context.object) and (engine in cls.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -136,17 +136,18 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel): split.prop(psys, "reactor_target_particle_system", text="Particle System") -class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel): +class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel, bpy.types.Panel): COMPAT_ENGINES = {'BLENDER_RENDER'} _context_path = "particle_system.settings" -class PARTICLE_PT_emission(ParticleButtonsPanel): +class PARTICLE_PT_emission(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Emission" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): - if particle_panel_poll(self, context): + @classmethod + def poll(cls, context): + if particle_panel_poll(PARTICLE_PT_emission, context): return not context.particle_system.point_cache.external else: return False @@ -156,7 +157,6 @@ class PARTICLE_PT_emission(ParticleButtonsPanel): psys = context.particle_system part = psys.settings - wide_ui = context.region.width > narrowui layout.enabled = particle_panel_enabled(context, psys) and not psys.multiple_caches @@ -178,10 +178,8 @@ class PARTICLE_PT_emission(ParticleButtonsPanel): layout.row().label(text="Emit From:") row = layout.row() - if wide_ui: - row.prop(part, "emit_from", expand=True) - else: - row.prop(part, "emit_from", text="") + row.prop(part, "emit_from", expand=True) + row = layout.row() row.prop(part, "trand") if part.distribution != 'GRID': @@ -189,10 +187,8 @@ class PARTICLE_PT_emission(ParticleButtonsPanel): if part.emit_from == 'FACE' or part.emit_from == 'VOLUME': row = layout.row() - if wide_ui: - row.prop(part, "distribution", expand=True) - else: - row.prop(part, "distribution", text="") + + row.prop(part, "distribution", expand=True) row = layout.row() @@ -203,19 +199,20 @@ class PARTICLE_PT_emission(ParticleButtonsPanel): row.prop(part, "grid_resolution") -class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel): +class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Hair dynamics" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): psys = context.particle_system engine = context.scene.render.engine if psys is None: return False if psys.settings is None: return False - return psys.settings.type == 'HAIR' and (engine in self.COMPAT_ENGINES) + return psys.settings.type == 'HAIR' and (engine in cls.COMPAT_ENGINES) def draw_header(self, context): #cloth = context.cloth.collision_settings @@ -260,12 +257,13 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel): col.prop(cloth, "quality", text="Steps", slider=True) -class PARTICLE_PT_cache(ParticleButtonsPanel): +class PARTICLE_PT_cache(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Cache" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): psys = context.particle_system engine = context.scene.render.engine if psys is None: @@ -275,7 +273,7 @@ class PARTICLE_PT_cache(ParticleButtonsPanel): phystype = psys.settings.physics_type if phystype == 'NO' or phystype == 'KEYED': return False - return (psys.settings.type in ('EMITTER', 'REACTOR') or (psys.settings.type == 'HAIR' and psys.hair_dynamics)) and engine in self.COMPAT_ENGINES + return (psys.settings.type in ('EMITTER', 'REACTOR') or (psys.settings.type == 'HAIR' and psys.hair_dynamics)) and engine in cls.COMPAT_ENGINES def draw(self, context): psys = context.particle_system @@ -283,12 +281,13 @@ class PARTICLE_PT_cache(ParticleButtonsPanel): point_cache_ui(self, context, psys.point_cache, True, 'HAIR' if psys.hair_dynamics else 'PSYS') -class PARTICLE_PT_velocity(ParticleButtonsPanel): +class PARTICLE_PT_velocity(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Velocity" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): - if particle_panel_poll(self, context): + @classmethod + def poll(cls, context): + if particle_panel_poll(PARTICLE_PT_velocity, context): psys = context.particle_system return psys.settings.physics_type != 'BOIDS' and not psys.point_cache.external else: @@ -330,12 +329,13 @@ class PARTICLE_PT_velocity(ParticleButtonsPanel): # sub.prop(part, "reaction_shape", slider=True) -class PARTICLE_PT_rotation(ParticleButtonsPanel): +class PARTICLE_PT_rotation(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Rotation" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): - if particle_panel_poll(self, context): + @classmethod + def poll(cls, context): + if particle_panel_poll(PARTICLE_PT_rotation, context): psys = context.particle_system return psys.settings.physics_type != 'BOIDS' and not psys.point_cache.external else: @@ -346,7 +346,6 @@ class PARTICLE_PT_rotation(ParticleButtonsPanel): psys = context.particle_system part = psys.settings - wide_ui = context.region.width > narrowui layout.enabled = particle_panel_enabled(context, psys) @@ -364,10 +363,7 @@ class PARTICLE_PT_rotation(ParticleButtonsPanel): sub.prop(part, "random_phase_factor", text="Random", slider=True) layout.row().label(text="Angular Velocity:") - if wide_ui: - layout.row().prop(part, "angular_velocity_mode", expand=True) - else: - layout.row().prop(part, "angular_velocity_mode", text="") + layout.row().prop(part, "angular_velocity_mode", expand=True) split = layout.split() sub = split.column() @@ -376,12 +372,13 @@ class PARTICLE_PT_rotation(ParticleButtonsPanel): sub.prop(part, "angular_velocity_factor", text="") -class PARTICLE_PT_physics(ParticleButtonsPanel): +class PARTICLE_PT_physics(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Physics" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): - if particle_panel_poll(self, context): + @classmethod + def poll(cls, context): + if particle_panel_poll(PARTICLE_PT_physics, context): return not context.particle_system.point_cache.external else: return False @@ -391,15 +388,11 @@ class PARTICLE_PT_physics(ParticleButtonsPanel): psys = context.particle_system part = psys.settings - wide_ui = context.region.width > narrowui layout.enabled = particle_panel_enabled(context, psys) row = layout.row() - if wide_ui: - row.prop(part, "physics_type", expand=True) - else: - row.prop(part, "physics_type", text="") + row.prop(part, "physics_type", expand=True) row = layout.row() col = row.column(align=True) @@ -573,11 +566,12 @@ class PARTICLE_PT_physics(ParticleButtonsPanel): sub.prop(key, "system", text="System") -class PARTICLE_PT_boidbrain(ParticleButtonsPanel): +class PARTICLE_PT_boidbrain(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Boid Brain" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): psys = context.particle_system engine = context.scene.render.engine if psys is None: @@ -586,7 +580,7 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel): return False if psys.point_cache.external: return False - return psys.settings.physics_type == 'BOIDS' and engine in self.COMPAT_ENGINES + return psys.settings.physics_type == 'BOIDS' and engine in cls.COMPAT_ENGINES def draw(self, context): layout = self.layout @@ -673,25 +667,25 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel): row.prop(rule, "flee_distance") -class PARTICLE_PT_render(ParticleButtonsPanel): +class PARTICLE_PT_render(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Render" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): psys = context.particle_system engine = context.scene.render.engine if psys is None: return False if psys.settings is None: return False - return engine in self.COMPAT_ENGINES + return engine in cls.COMPAT_ENGINES def draw(self, context): layout = self.layout psys = context.particle_system part = psys.settings - wide_ui = context.region.width > narrowui row = layout.row() row.prop(part, "material") @@ -707,10 +701,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel): sub.prop(part, "died") row = layout.row() - if wide_ui: - row.prop(part, "ren_as", expand=True) - else: - row.prop(part, "ren_as", text="") + row.prop(part, "ren_as", expand=True) split = layout.split() @@ -797,10 +788,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel): sub.label(text="Align:") row = layout.row() - if wide_ui: - row.prop(part, "billboard_align", expand=True) - else: - row.prop(part, "billboard_align", text="") + row.prop(part, "billboard_align", expand=True) row.prop(part, "billboard_lock", text="Lock") row = layout.row() row.prop(part, "billboard_object") @@ -843,32 +831,29 @@ class PARTICLE_PT_render(ParticleButtonsPanel): col.label(text="") -class PARTICLE_PT_draw(ParticleButtonsPanel): +class PARTICLE_PT_draw(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Display" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): psys = context.particle_system engine = context.scene.render.engine if psys is None: return False if psys.settings is None: return False - return engine in self.COMPAT_ENGINES + return engine in cls.COMPAT_ENGINES def draw(self, context): layout = self.layout psys = context.particle_system part = psys.settings - wide_ui = context.region.width > narrowui row = layout.row() - if wide_ui: - row.prop(part, "draw_as", expand=True) - else: - row.prop(part, "draw_as", text="") + row.prop(part, "draw_as", expand=True) if part.draw_as == 'NONE' or (part.ren_as == 'NONE' and part.draw_as == 'RENDER'): return @@ -902,22 +887,22 @@ class PARTICLE_PT_draw(ParticleButtonsPanel): #sub.label(text="Override material color") -class PARTICLE_PT_children(ParticleButtonsPanel): +class PARTICLE_PT_children(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Children" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} + @classmethod + def poll(cls, context): + return particle_panel_poll(cls, context) + def draw(self, context): layout = self.layout psys = context.particle_system part = psys.settings - wide_ui = context.region.width > narrowui - if wide_ui: - layout.row().prop(part, "child_type", expand=True) - else: - layout.row().prop(part, "child_type", text="") + layout.row().prop(part, "child_type", expand=True) if part.child_type == 'NONE': return @@ -973,10 +958,7 @@ class PARTICLE_PT_children(ParticleButtonsPanel): col.label(text="hair parting controls") layout.row().label(text="Kink:") - if wide_ui: - layout.row().prop(part, "kink", expand=True) - else: - layout.row().prop(part, "kink", text="") + layout.row().prop(part, "kink", expand=True) split = layout.split() @@ -987,7 +969,7 @@ class PARTICLE_PT_children(ParticleButtonsPanel): col.prop(part, "kink_shape", slider=True) -class PARTICLE_PT_field_weights(ParticleButtonsPanel): +class PARTICLE_PT_field_weights(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Field Weights" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -1000,7 +982,7 @@ class PARTICLE_PT_field_weights(ParticleButtonsPanel): self.layout.prop(part.effector_weights, "do_growing_hair") -class PARTICLE_PT_force_fields(ParticleButtonsPanel): +class PARTICLE_PT_force_fields(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Force Field Settings" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -1028,7 +1010,7 @@ class PARTICLE_PT_force_fields(ParticleButtonsPanel): basic_force_field_falloff_ui(self, context, part.force_field_2) -class PARTICLE_PT_vertexgroups(ParticleButtonsPanel): +class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, bpy.types.Panel): bl_label = "Vertexgroups" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -1096,35 +1078,12 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel): row.prop(psys, "vertex_group_field_negate", text="") -classes = [ - PARTICLE_PT_context_particles, - PARTICLE_PT_hair_dynamics, - PARTICLE_PT_cache, - PARTICLE_PT_emission, - PARTICLE_PT_velocity, - PARTICLE_PT_rotation, - PARTICLE_PT_physics, - PARTICLE_PT_boidbrain, - PARTICLE_PT_render, - PARTICLE_PT_draw, - PARTICLE_PT_children, - PARTICLE_PT_field_weights, - PARTICLE_PT_force_fields, - PARTICLE_PT_vertexgroups, - - PARTICLE_PT_custom_props] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_physics_cloth.py b/release/scripts/ui/properties_physics_cloth.py index 61e1fe81812..0755b9be603 100644 --- a/release/scripts/ui/properties_physics_cloth.py +++ b/release/scripts/ui/properties_physics_cloth.py @@ -19,8 +19,6 @@ # <pep8 compliant> import bpy -narrowui = bpy.context.user_preferences.view.properties_width_check - from properties_physics_common import point_cache_ui from properties_physics_common import effector_weights_ui @@ -40,18 +38,19 @@ class CLOTH_MT_presets(bpy.types.Menu): draw = bpy.types.Menu.draw_preset -class PhysicButtonsPanel(bpy.types.Panel): +class PhysicButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "physics" - def poll(self, context): + @classmethod + def poll(cls, context): ob = context.object rd = context.scene.render return (ob and ob.type == 'MESH') and (not rd.use_game_engine) -class PHYSICS_PT_cloth(PhysicButtonsPanel): +class PHYSICS_PT_cloth(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Cloth" def draw(self, context): @@ -59,7 +58,6 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel): md = context.cloth ob = context.object - wide_ui = context.region.width > narrowui split = layout.split() @@ -74,8 +72,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel): else: # add modifier split.operator("object.modifier_add", text="Add").type = 'CLOTH' - if wide_ui: - split.label() + split.label() if md: cloth = md.settings @@ -99,8 +96,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel): col.prop(cloth, "structural_stiffness", text="Structural") col.prop(cloth, "bending_stiffness", text="Bending") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Damping:") col.prop(cloth, "spring_damping", text="Spring") @@ -133,11 +129,12 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel): col.prop_object(cloth, "rest_shape_key", key, "keys", text="") -class PHYSICS_PT_cloth_cache(PhysicButtonsPanel): +class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Cloth Cache" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): return context.cloth def draw(self, context): @@ -145,11 +142,12 @@ class PHYSICS_PT_cloth_cache(PhysicButtonsPanel): point_cache_ui(self, context, md.point_cache, cloth_panel_enabled(md), 'CLOTH') -class PHYSICS_PT_cloth_collision(PhysicButtonsPanel): +class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Cloth Collision" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): return context.cloth def draw_header(self, context): @@ -163,7 +161,6 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel): cloth = context.cloth.collision_settings md = context.cloth - wide_ui = context.region.width > narrowui layout.active = cloth.enable_collision and cloth_panel_enabled(md) @@ -174,8 +171,7 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel): col.prop(cloth, "min_distance", slider=True, text="Distance") col.prop(cloth, "friction") - if wide_ui: - col = split.column() + col = split.column() col.prop(cloth, "enable_self_collision", text="Self Collision") sub = col.column() sub.active = cloth.enable_self_collision @@ -185,11 +181,12 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel): layout.prop(cloth, "group") -class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel): +class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Cloth Stiffness Scaling" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): return context.cloth def draw_header(self, context): @@ -204,7 +201,6 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel): md = context.cloth ob = context.object cloth = context.cloth.settings - wide_ui = context.region.width > narrowui layout.active = cloth.stiffness_scaling and cloth_panel_enabled(md) @@ -215,18 +211,18 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel): col.prop_object(cloth, "structural_stiffness_vertex_group", ob, "vertex_groups", text="") col.prop(cloth, "structural_stiffness_max", text="Max") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Bending Stiffness:") col.prop_object(cloth, "bending_vertex_group", ob, "vertex_groups", text="") col.prop(cloth, "bending_stiffness_max", text="Max") -class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel): +class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Cloth Field Weights" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): return (context.cloth) def draw(self, context): @@ -234,26 +230,12 @@ class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel): effector_weights_ui(self, context, cloth.effector_weights) -classes = [ - CLOTH_MT_presets, - - PHYSICS_PT_cloth, - PHYSICS_PT_cloth_cache, - PHYSICS_PT_cloth_collision, - PHYSICS_PT_cloth_stiffness, - PHYSICS_PT_cloth_field_weights] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_physics_common.py b/release/scripts/ui/properties_physics_common.py index be8972e4fe6..340cd88251c 100644 --- a/release/scripts/ui/properties_physics_common.py +++ b/release/scripts/ui/properties_physics_common.py @@ -20,15 +20,12 @@ import bpy -narrowui = bpy.context.user_preferences.view.properties_width_check - #cachetype can be 'PSYS' 'HAIR' 'SMOKE' etc def point_cache_ui(self, context, cache, enabled, cachetype): layout = self.layout - wide_ui = context.region.width > narrowui layout.set_context_pointer("point_cache", cache) row = layout.row() @@ -66,8 +63,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype): if cachetype != 'SMOKE': col.prop(cache, "step") - if wide_ui: - col = split.column() + col = split.column() if cachetype != 'SMOKE': sub = col.column() @@ -102,8 +98,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype): sub.operator("ptcache.bake_from_cache", text="Current Cache to Bake") - if wide_ui: - col = split.column() + col = split.column() col.operator("ptcache.bake_all", text="Bake All Dynamics").bake = True col.operator("ptcache.free_bake_all", text="Free All Bakes") col.operator("ptcache.bake_all", text="Update All To Frame").bake = False @@ -112,7 +107,6 @@ def point_cache_ui(self, context, cache, enabled, cachetype): def effector_weights_ui(self, context, weights): layout = self.layout - wide_ui = context.region.width > narrowui layout.prop(weights, "group") @@ -121,8 +115,7 @@ def effector_weights_ui(self, context, weights): col = split.column() col.prop(weights, "gravity", slider=True) - if wide_ui: - col = split.column() + col = split.column() col.prop(weights, "all", slider=True) layout.separator() @@ -137,8 +130,7 @@ def effector_weights_ui(self, context, weights): col.prop(weights, "curveguide", slider=True) col.prop(weights, "texture", slider=True) - if wide_ui: - col = split.column() + col = split.column() col.prop(weights, "harmonic", slider=True) col.prop(weights, "charge", slider=True) col.prop(weights, "lennardjones", slider=True) @@ -150,7 +142,6 @@ def effector_weights_ui(self, context, weights): def basic_force_field_settings_ui(self, context, field): layout = self.layout - wide_ui = context.region.width > narrowui split = layout.split() @@ -177,8 +168,7 @@ def basic_force_field_settings_ui(self, context, field): else: col.prop(field, "flow") - if wide_ui: - col = split.column() + col = split.column() col.prop(field, "noise") col.prop(field, "seed") if field.type == 'TURBULENCE': @@ -193,8 +183,7 @@ def basic_force_field_settings_ui(self, context, field): col.prop(field, "do_location") col.prop(field, "do_rotation") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Collision:") col.prop(field, "do_absorption") @@ -202,12 +191,9 @@ def basic_force_field_settings_ui(self, context, field): def basic_force_field_falloff_ui(self, context, field): layout = self.layout - wide_ui = context.region.width > narrowui # XXX: This doesn't update for some reason. - #if wide_ui: - # split = layout.split() - #else: + #split = layout.split() split = layout.split(percentage=0.35) if not field or field.type == 'NONE': @@ -218,8 +204,7 @@ def basic_force_field_falloff_ui(self, context, field): col.prop(field, "use_min_distance", text="Use Minimum") col.prop(field, "use_max_distance", text="Use Maximum") - if wide_ui: - col = split.column() + col = split.column() col.prop(field, "falloff_power", text="Power") sub = col.column() diff --git a/release/scripts/ui/properties_physics_field.py b/release/scripts/ui/properties_physics_field.py index 57fa40e4c5d..b67232f888d 100644 --- a/release/scripts/ui/properties_physics_field.py +++ b/release/scripts/ui/properties_physics_field.py @@ -19,24 +19,23 @@ # <pep8 compliant> import bpy -narrowui = bpy.context.user_preferences.view.properties_width_check - from properties_physics_common import basic_force_field_settings_ui from properties_physics_common import basic_force_field_falloff_ui -class PhysicButtonsPanel(bpy.types.Panel): +class PhysicButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "physics" - def poll(self, context): + @classmethod + def poll(cls, context): rd = context.scene.render return (context.object) and (not rd.use_game_engine) -class PHYSICS_PT_field(PhysicButtonsPanel): +class PHYSICS_PT_field(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Force Fields" def draw(self, context): @@ -44,22 +43,15 @@ class PHYSICS_PT_field(PhysicButtonsPanel): ob = context.object field = ob.field - wide_ui = context.region.width > narrowui - if wide_ui: - split = layout.split(percentage=0.2) - split.label(text="Type:") - else: - split = layout.split() + split = layout.split(percentage=0.2) + split.label(text="Type:") split.prop(field, "type", text="") if field.type not in ('NONE', 'GUIDE', 'TEXTURE'): - if wide_ui: - split = layout.split(percentage=0.2) - split.label(text="Shape:") - else: - split = layout.split() + split = layout.split(percentage=0.2) + split.label(text="Shape:") split.prop(field, "shape", text="") split = layout.split() @@ -74,8 +66,7 @@ class PHYSICS_PT_field(PhysicButtonsPanel): col.prop(field, "guide_path_add") col.prop(field, "use_guide_path_weight") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Clumping:") col.prop(field, "guide_clump_amount") col.prop(field, "guide_clump_shape") @@ -98,8 +89,7 @@ class PHYSICS_PT_field(PhysicButtonsPanel): col.prop(field, "guide_kink_frequency") col.prop(field, "guide_kink_shape") - if wide_ui: - col = split.column() + col = split.column() col.prop(field, "guide_kink_amplitude") elif field.type == 'TEXTURE': @@ -109,8 +99,7 @@ class PHYSICS_PT_field(PhysicButtonsPanel): col.prop(field, "texture_mode", text="") col.prop(field, "texture_nabla") - if wide_ui: - col = split.column() + col = split.column() col.prop(field, "use_coordinates") col.prop(field, "root_coordinates") col.prop(field, "force_2d") @@ -134,8 +123,7 @@ class PHYSICS_PT_field(PhysicButtonsPanel): col.prop(field, "use_radial_min", text="Use Minimum") col.prop(field, "use_radial_max", text="Use Maximum") - if wide_ui: - col = split.column() + col = split.column() col.prop(field, "radial_falloff", text="Power") sub = col.column() @@ -156,8 +144,7 @@ class PHYSICS_PT_field(PhysicButtonsPanel): col.prop(field, "use_radial_min", text="Use Minimum") col.prop(field, "use_radial_max", text="Use Maximum") - if wide_ui: - col = split.column() + col = split.column() col.prop(field, "radial_falloff", text="Power") sub = col.column() @@ -169,11 +156,12 @@ class PHYSICS_PT_field(PhysicButtonsPanel): sub.prop(field, "radial_maximum", text="Distance") -class PHYSICS_PT_collision(PhysicButtonsPanel): +class PHYSICS_PT_collision(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Collision" #bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): ob = context.object rd = context.scene.render return (ob and ob.type == 'MESH') and (not rd.use_game_engine) @@ -182,7 +170,6 @@ class PHYSICS_PT_collision(PhysicButtonsPanel): layout = self.layout md = context.collision - wide_ui = context.region.width > narrowui split = layout.split() @@ -190,8 +177,7 @@ class PHYSICS_PT_collision(PhysicButtonsPanel): # remove modifier + settings split.set_context_pointer("modifier", md) split.operator("object.modifier_remove", text="Remove") - if wide_ui: - col = split.column() + col = split.column() #row = split.row(align=True) #row.prop(md, "render", text="") @@ -202,8 +188,7 @@ class PHYSICS_PT_collision(PhysicButtonsPanel): else: # add modifier split.operator("object.modifier_add", text="Add").type = 'COLLISION' - if wide_ui: - split.label() + split.label() coll = None @@ -229,8 +214,7 @@ class PHYSICS_PT_collision(PhysicButtonsPanel): sub.prop(settings, "friction_factor", text="Factor", slider=True) sub.prop(settings, "random_friction", text="Random", slider=True) - if wide_ui: - col = split.column() + col = split.column() col.label(text="Soft Body and Cloth:") sub = col.column(align=True) sub.prop(settings, "outer_thickness", text="Outer", slider=True) @@ -243,21 +227,12 @@ class PHYSICS_PT_collision(PhysicButtonsPanel): col.prop(settings, "absorption", text="Absorption") -classes = [ - PHYSICS_PT_field, - PHYSICS_PT_collision] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_physics_fluid.py b/release/scripts/ui/properties_physics_fluid.py index 32acd88654d..2c25270eb39 100644 --- a/release/scripts/ui/properties_physics_fluid.py +++ b/release/scripts/ui/properties_physics_fluid.py @@ -19,28 +19,26 @@ # <pep8 compliant> import bpy -narrowui = bpy.context.user_preferences.view.properties_width_check - -class PhysicButtonsPanel(bpy.types.Panel): +class PhysicButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "physics" - def poll(self, context): + @classmethod + def poll(cls, context): ob = context.object rd = context.scene.render return (ob and ob.type == 'MESH') and (not rd.use_game_engine) -class PHYSICS_PT_fluid(PhysicButtonsPanel): +class PHYSICS_PT_fluid(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Fluid" def draw(self, context): layout = self.layout md = context.fluid - wide_ui = context.region.width > narrowui split = layout.split() @@ -58,22 +56,16 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel): else: # add modifier split.operator("object.modifier_add", text="Add").type = 'FLUID_SIMULATION' - if wide_ui: - split.label() + split.label() fluid = None if fluid: - if wide_ui: - row = layout.row() - row.prop(fluid, "type") - if fluid.type not in ('NONE', 'DOMAIN', 'PARTICLE'): - row.prop(fluid, "active", text="") - else: - layout.prop(fluid, "type", text="") - if fluid.type not in ('NONE', 'DOMAIN', 'PARTICLE'): - layout.prop(fluid, "active", text="") + row = layout.row() + row.prop(fluid, "type") + if fluid.type not in ('NONE', 'DOMAIN', 'PARTICLE'): + row.prop(fluid, "active", text="") layout = layout.column() if fluid.type not in ('NONE', 'DOMAIN', 'PARTICLE'): @@ -89,8 +81,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel): col.label(text="Render Display:") col.prop(fluid, "render_display_mode", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Required Memory: " + fluid.memory_estimate) col.prop(fluid, "preview_resolution", text="Preview") col.label(text="Viewport Display:") @@ -104,9 +95,8 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel): sub.prop(fluid, "start_time", text="Start") sub.prop(fluid, "end_time", text="End") - if wide_ui: - col = split.column() - col.label() + col = split.column() + col.label() col.prop(fluid, "generate_speed_vectors") col.prop(fluid, "reverse_frames") @@ -120,8 +110,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel): col.prop(fluid, "volume_initialization", text="") col.prop(fluid, "export_animated_mesh") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Initial Velocity:") col.prop(fluid, "initial_velocity", text="") @@ -133,8 +122,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel): col.prop(fluid, "volume_initialization", text="") col.prop(fluid, "export_animated_mesh") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Slip Type:") col.prop(fluid, "slip_type", text="") if fluid.slip_type == 'PARTIALSLIP': @@ -152,8 +140,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel): col.prop(fluid, "export_animated_mesh") col.prop(fluid, "local_coordinates") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Inflow Velocity:") col.prop(fluid, "inflow_velocity", text="") @@ -165,8 +152,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel): col.prop(fluid, "volume_initialization", text="") col.prop(fluid, "export_animated_mesh") - if wide_ui: - split.column() + split.column() elif fluid.type == 'PARTICLE': split = layout.split() @@ -176,8 +162,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel): col.prop(fluid, "particle_influence", text="Size") col.prop(fluid, "alpha_influence", text="Alpha") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Type:") col.prop(fluid, "drops") col.prop(fluid, "floats") @@ -193,8 +178,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel): col.prop(fluid, "quality", slider=True) col.prop(fluid, "reverse_frames") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Time:") sub = col.column(align=True) sub.prop(fluid, "start_time", text="Start") @@ -208,28 +192,27 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel): sub.prop(fluid, "attraction_strength", text="Strength") sub.prop(fluid, "attraction_radius", text="Radius") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Velocity Force:") sub = col.column(align=True) sub.prop(fluid, "velocity_strength", text="Strength") sub.prop(fluid, "velocity_radius", text="Radius") -class PHYSICS_PT_domain_gravity(PhysicButtonsPanel): +class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Domain World" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): md = context.fluid - return md and (md.settings.type == 'DOMAIN') + return md and md.settings and (md.settings.type == 'DOMAIN') def draw(self, context): layout = self.layout fluid = context.fluid.settings scene = context.scene - wide_ui = context.region.width > narrowui split = layout.split() @@ -252,8 +235,7 @@ class PHYSICS_PT_domain_gravity(PhysicButtonsPanel): col.label(text="Real World Size:") col.prop(fluid, "real_world_size", text="Metres") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Viscosity Presets:") sub = col.column(align=True) sub.prop(fluid, "viscosity_preset", text="") @@ -267,19 +249,19 @@ class PHYSICS_PT_domain_gravity(PhysicButtonsPanel): col.prop(fluid, "compressibility", slider=True) -class PHYSICS_PT_domain_boundary(PhysicButtonsPanel): +class PHYSICS_PT_domain_boundary(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Domain Boundary" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): md = context.fluid - return md and (md.settings.type == 'DOMAIN') + return md and md.settings and (md.settings.type == 'DOMAIN') def draw(self, context): layout = self.layout fluid = context.fluid.settings - wide_ui = context.region.width > narrowui split = layout.split() @@ -289,20 +271,20 @@ class PHYSICS_PT_domain_boundary(PhysicButtonsPanel): if fluid.slip_type == 'PARTIALSLIP': col.prop(fluid, "partial_slip_factor", slider=True, text="Amount") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Surface:") col.prop(fluid, "surface_smoothing", text="Smoothing") col.prop(fluid, "surface_subdivisions", text="Subdivisions") -class PHYSICS_PT_domain_particles(PhysicButtonsPanel): +class PHYSICS_PT_domain_particles(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Domain Particles" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): md = context.fluid - return md and (md.settings.type == 'DOMAIN') + return md and md.settings and (md.settings.type == 'DOMAIN') def draw(self, context): layout = self.layout @@ -314,23 +296,12 @@ class PHYSICS_PT_domain_particles(PhysicButtonsPanel): col.prop(fluid, "generate_particles") -classes = [ - PHYSICS_PT_fluid, - PHYSICS_PT_domain_gravity, - PHYSICS_PT_domain_boundary, - PHYSICS_PT_domain_particles] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_physics_smoke.py b/release/scripts/ui/properties_physics_smoke.py index 9bae4c5b63f..3538b88afcf 100644 --- a/release/scripts/ui/properties_physics_smoke.py +++ b/release/scripts/ui/properties_physics_smoke.py @@ -19,25 +19,24 @@ # <pep8 compliant> import bpy -narrowui = bpy.context.user_preferences.view.properties_width_check - from properties_physics_common import point_cache_ui from properties_physics_common import effector_weights_ui -class PhysicButtonsPanel(bpy.types.Panel): +class PhysicButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "physics" - def poll(self, context): + @classmethod + def poll(cls, context): ob = context.object rd = context.scene.render return (ob and ob.type == 'MESH') and (not rd.use_game_engine) -class PHYSICS_PT_smoke(PhysicButtonsPanel): +class PHYSICS_PT_smoke(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Smoke" def draw(self, context): @@ -45,7 +44,6 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel): md = context.smoke ob = context.object - wide_ui = context.region.width > narrowui split = layout.split() @@ -61,14 +59,10 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel): else: # add modifier split.operator("object.modifier_add", text="Add").type = 'SMOKE' - if wide_ui: - split.label() + split.label() if md: - if wide_ui: - layout.prop(md, "smoke_type", expand=True) - else: - layout.prop(md, "smoke_type", text="") + layout.prop(md, "smoke_type", expand=True) if md.smoke_type == 'DOMAIN': domain = md.domain_settings @@ -83,8 +77,7 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel): col.label(text="Border Collisions:") col.prop(domain, "smoke_domain_colli", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Behavior:") col.prop(domain, "alpha") col.prop(domain, "beta") @@ -114,8 +107,8 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel): sub.active = flow.initial_velocity sub.prop(flow, "velocity_multiplier", text="Multiplier") - if wide_ui: - sub = split.column() + + sub = split.column() sub.active = not md.flow_settings.outflow sub.label(text="Behavior:") sub.prop(flow, "temperature") @@ -126,11 +119,12 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel): # layout.separator() -class PHYSICS_PT_smoke_groups(PhysicButtonsPanel): +class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Smoke Groups" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): md = context.smoke return md and (md.smoke_type == 'DOMAIN') @@ -138,7 +132,6 @@ class PHYSICS_PT_smoke_groups(PhysicButtonsPanel): layout = self.layout group = context.smoke.domain_settings - wide_ui = context.region.width > narrowui split = layout.split() @@ -149,17 +142,17 @@ class PHYSICS_PT_smoke_groups(PhysicButtonsPanel): #col.label(text="Effector Group:") #col.prop(group, "eff_group", text="") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Collision Group:") col.prop(group, "coll_group", text="") -class PHYSICS_PT_smoke_cache(PhysicButtonsPanel): +class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Smoke Cache" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): md = context.smoke return md and (md.smoke_type == 'DOMAIN') @@ -175,11 +168,12 @@ class PHYSICS_PT_smoke_cache(PhysicButtonsPanel): point_cache_ui(self, context, cache, (cache.baked is False), 'SMOKE') -class PHYSICS_PT_smoke_highres(PhysicButtonsPanel): +class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Smoke High Resolution" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): md = context.smoke return md and (md.smoke_type == 'DOMAIN') @@ -192,7 +186,6 @@ class PHYSICS_PT_smoke_highres(PhysicButtonsPanel): layout = self.layout md = context.smoke.domain_settings - wide_ui = context.region.width > narrowui layout.active = md.highres @@ -204,18 +197,18 @@ class PHYSICS_PT_smoke_highres(PhysicButtonsPanel): col.prop(md, "smoothemitter") col.prop(md, "viewhighres") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Noise Method:") col.row().prop(md, "noise_type", text="") col.prop(md, "strength") -class PHYSICS_PT_smoke_cache_highres(PhysicButtonsPanel): +class PHYSICS_PT_smoke_cache_highres(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Smoke High Resolution Cache" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): md = context.smoke return md and (md.smoke_type == 'DOMAIN') and md.domain_settings.highres @@ -231,11 +224,12 @@ class PHYSICS_PT_smoke_cache_highres(PhysicButtonsPanel): point_cache_ui(self, context, cache, (cache.baked is False), 'SMOKE') -class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel): +class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Smoke Field Weights" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): smoke = context.smoke return (smoke and smoke.smoke_type == 'DOMAIN') @@ -244,25 +238,12 @@ class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel): effector_weights_ui(self, context, domain.effector_weights) -classes = [ - PHYSICS_PT_smoke, - PHYSICS_PT_smoke_field_weights, - PHYSICS_PT_smoke_cache, - PHYSICS_PT_smoke_highres, - PHYSICS_PT_smoke_groups, - PHYSICS_PT_smoke_cache_highres] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_physics_softbody.py b/release/scripts/ui/properties_physics_softbody.py index 60149cf533b..5240e6477d8 100644 --- a/release/scripts/ui/properties_physics_softbody.py +++ b/release/scripts/ui/properties_physics_softbody.py @@ -19,8 +19,6 @@ # <pep8 compliant> import bpy -narrowui = bpy.context.user_preferences.view.properties_width_check - from properties_physics_common import point_cache_ui from properties_physics_common import effector_weights_ui @@ -30,12 +28,13 @@ def softbody_panel_enabled(md): return (md.point_cache.baked is False) -class PhysicButtonsPanel(bpy.types.Panel): +class PhysicButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "physics" - def poll(self, context): + @classmethod + def poll(cls, context): ob = context.object rd = context.scene.render # return (ob and ob.type == 'MESH') and (not rd.use_game_engine) @@ -43,7 +42,7 @@ class PhysicButtonsPanel(bpy.types.Panel): return (ob and (ob.type == 'MESH' or ob.type == 'LATTICE'or ob.type == 'CURVE')) and (not rd.use_game_engine) -class PHYSICS_PT_softbody(PhysicButtonsPanel): +class PHYSICS_PT_softbody(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Soft Body" def draw(self, context): @@ -51,7 +50,6 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel): md = context.soft_body ob = context.object - wide_ui = context.region.width > narrowui split = layout.split() @@ -66,8 +64,7 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel): else: # add modifier split.operator("object.modifier_add", text="Add").type = 'SOFT_BODY' - if wide_ui: - split.column() + split.column() if md: softbody = md.settings @@ -82,17 +79,17 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel): col.prop(softbody, "mass") col.prop_object(softbody, "mass_vertex_group", ob, "vertex_groups", text="Mass:") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Simulation:") col.prop(softbody, "speed") -class PHYSICS_PT_softbody_cache(PhysicButtonsPanel): +class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Soft Body Cache" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): return context.soft_body def draw(self, context): @@ -100,11 +97,12 @@ class PHYSICS_PT_softbody_cache(PhysicButtonsPanel): point_cache_ui(self, context, md.point_cache, softbody_panel_enabled(md), 'SOFTBODY') -class PHYSICS_PT_softbody_goal(PhysicButtonsPanel): +class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Soft Body Goal" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): return context.soft_body def draw_header(self, context): @@ -119,7 +117,6 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel): md = context.soft_body softbody = md.settings ob = context.object - wide_ui = context.region.width > narrowui layout.active = softbody.use_goal and softbody_panel_enabled(md) @@ -135,8 +132,7 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel): sub.prop(softbody, "goal_min", text="Minimum") sub.prop(softbody, "goal_max", text="Maximum") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Goal Settings:") col.prop(softbody, "goal_spring", text="Stiffness") col.prop(softbody, "goal_friction", text="Damping") @@ -144,11 +140,12 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel): layout.prop_object(softbody, "goal_vertex_group", ob, "vertex_groups", text="Vertex Group") -class PHYSICS_PT_softbody_edge(PhysicButtonsPanel): +class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Soft Body Edges" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): return context.soft_body def draw_header(self, context): @@ -163,7 +160,6 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel): md = context.soft_body softbody = md.settings ob = context.object - wide_ui = context.region.width > narrowui layout.active = softbody.use_edges and softbody_panel_enabled(md) @@ -179,8 +175,7 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel): col.prop(softbody, "spring_length", text="Length") col.prop_object(softbody, "spring_vertex_group", ob, "vertex_groups", text="Springs:") - if wide_ui: - col = split.column() + col = split.column() col.prop(softbody, "stiff_quads") sub = col.column() sub.active = softbody.stiff_quads @@ -199,11 +194,12 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel): col.prop(softbody, "face_collision", text="Face") -class PHYSICS_PT_softbody_collision(PhysicButtonsPanel): +class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Soft Body Self Collision" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): return context.soft_body def draw_header(self, context): @@ -217,15 +213,11 @@ class PHYSICS_PT_softbody_collision(PhysicButtonsPanel): md = context.soft_body softbody = md.settings - wide_ui = context.region.width > narrowui layout.active = softbody.self_collision and softbody_panel_enabled(md) layout.label(text="Collision Ball Size Calculation:") - if wide_ui: - layout.prop(softbody, "collision_type", expand=True) - else: - layout.prop(softbody, "collision_type", text="") + layout.prop(softbody, "collision_type", expand=True) col = layout.column(align=True) col.label(text="Ball:") @@ -234,11 +226,12 @@ class PHYSICS_PT_softbody_collision(PhysicButtonsPanel): col.prop(softbody, "ball_damp", text="Dampening") -class PHYSICS_PT_softbody_solver(PhysicButtonsPanel): +class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Soft Body Solver" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): return context.soft_body def draw(self, context): @@ -246,7 +239,6 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel): md = context.soft_body softbody = md.settings - wide_ui = context.region.width > narrowui layout.active = softbody_panel_enabled(md) @@ -259,8 +251,7 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel): col.prop(softbody, "maxstep") col.prop(softbody, "auto_step", text="Auto-Step") - if wide_ui: - col = split.column() + col = split.column() col.prop(softbody, "error_limit") col.label(text="Helpers:") col.prop(softbody, "choke") @@ -271,11 +262,12 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel): layout.prop(softbody, "estimate_matrix") -class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel): +class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel, bpy.types.Panel): bl_label = "Soft Body Field Weights" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): return (context.soft_body) def draw(self, context): @@ -285,26 +277,12 @@ class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel): effector_weights_ui(self, context, softbody.effector_weights) -classes = [ - PHYSICS_PT_softbody, - PHYSICS_PT_softbody_cache, - PHYSICS_PT_softbody_goal, - PHYSICS_PT_softbody_edge, - PHYSICS_PT_softbody_collision, - PHYSICS_PT_softbody_solver, - PHYSICS_PT_softbody_field_weights] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_render.py b/release/scripts/ui/properties_render.py index e446767fa01..6856e73dc2f 100644 --- a/release/scripts/ui/properties_render.py +++ b/release/scripts/ui/properties_render.py @@ -19,8 +19,6 @@ # <pep8 compliant> import bpy -narrowui = bpy.context.user_preferences.view.properties_width_check - class RENDER_MT_presets(bpy.types.Menu): bl_label = "Render Presets" @@ -36,18 +34,19 @@ class RENDER_MT_ffmpeg_presets(bpy.types.Menu): draw = bpy.types.Menu.draw_preset -class RenderButtonsPanel(bpy.types.Panel): +class RenderButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "render" # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here - def poll(self, context): + @classmethod + def poll(cls, context): rd = context.scene.render - return (context.scene and rd.use_game_engine is False) and (rd.engine in self.COMPAT_ENGINES) + return (context.scene and rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES) -class RENDER_PT_render(RenderButtonsPanel): +class RENDER_PT_render(RenderButtonsPanel, bpy.types.Panel): bl_label = "Render" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -55,21 +54,19 @@ class RENDER_PT_render(RenderButtonsPanel): layout = self.layout rd = context.scene.render - wide_ui = context.region.width > narrowui split = layout.split() col = split.column() col.operator("render.render", text="Image", icon='RENDER_STILL') - if wide_ui: - col = split.column() + col = split.column() col.operator("render.render", text="Animation", icon='RENDER_ANIMATION').animation = True layout.prop(rd, "display_mode", text="Display") -class RENDER_PT_layers(RenderButtonsPanel): +class RENDER_PT_layers(RenderButtonsPanel, bpy.types.Panel): bl_label = "Layers" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -79,7 +76,6 @@ class RENDER_PT_layers(RenderButtonsPanel): scene = context.scene rd = scene.render - wide_ui = context.region.width > narrowui row = layout.row() row.template_list(rd, "layers", rd, "active_layer_index", rows=2) @@ -100,8 +96,8 @@ class RENDER_PT_layers(RenderButtonsPanel): col.label(text="") col.prop(rl, "light_override", text="Light") col.prop(rl, "material_override", text="Material") - if wide_ui: - col = split.column() + + col = split.column() col.prop(rl, "visible_layers", text="Layer") col.label(text="Mask Layers:") col.prop(rl, "zmask_layers", text="") @@ -145,8 +141,7 @@ class RENDER_PT_layers(RenderButtonsPanel): col.prop(rl, "pass_object_index") col.prop(rl, "pass_color") - if wide_ui: - col = split.column() + col = split.column() col.label() col.prop(rl, "pass_diffuse") row = col.row() @@ -175,11 +170,12 @@ class RENDER_PT_layers(RenderButtonsPanel): row.prop(rl, "pass_refraction_exclude", text="") -class RENDER_PT_freestyle(RenderButtonsPanel): +class RENDER_PT_freestyle(RenderButtonsPanel, bpy.types.Panel): bl_label = "Freestyle" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): rd = context.scene.render rl = rd.layers[rd.active_layer_index] return rl and rl.freestyle @@ -279,11 +275,12 @@ class RENDER_PT_freestyle(RenderButtonsPanel): row.operator("scene.freestyle_module_move", icon='TRIA_DOWN', text="").direction = 'DOWN' -class RENDER_PT_freestyle_linestyle(RenderButtonsPanel): +class RENDER_PT_freestyle_linestyle(RenderButtonsPanel, bpy.types.Panel): bl_label = "Freestyle: Line Style" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): rd = context.scene.render rl = rd.layers[rd.active_layer_index] if rl and rl.freestyle: @@ -421,7 +418,7 @@ class RENDER_PT_freestyle_linestyle(RenderButtonsPanel): pass -class RENDER_PT_shading(RenderButtonsPanel): +class RENDER_PT_shading(RenderButtonsPanel, bpy.types.Panel): bl_label = "Shading" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -429,7 +426,6 @@ class RENDER_PT_shading(RenderButtonsPanel): layout = self.layout rd = context.scene.render - wide_ui = context.region.width > narrowui split = layout.split() @@ -439,14 +435,13 @@ class RENDER_PT_shading(RenderButtonsPanel): col.prop(rd, "use_sss", text="Subsurface Scattering") col.prop(rd, "use_envmaps", text="Environment Map") - if wide_ui: - col = split.column() + col = split.column() col.prop(rd, "use_raytracing", text="Ray Tracing") col.prop(rd, "color_management") col.prop(rd, "alpha_mode", text="Alpha") -class RENDER_PT_performance(RenderButtonsPanel): +class RENDER_PT_performance(RenderButtonsPanel, bpy.types.Panel): bl_label = "Performance" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -455,7 +450,6 @@ class RENDER_PT_performance(RenderButtonsPanel): layout = self.layout rd = context.scene.render - wide_ui = context.region.width > narrowui split = layout.split() @@ -470,8 +464,7 @@ class RENDER_PT_performance(RenderButtonsPanel): sub.prop(rd, "parts_x", text="X") sub.prop(rd, "parts_y", text="Y") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Memory:") sub = col.column() sub.enabled = not (rd.use_border or rd.full_sample) @@ -490,7 +483,7 @@ class RENDER_PT_performance(RenderButtonsPanel): sub.prop(rd, "use_local_coords", text="Local Coordinates") -class RENDER_PT_post_processing(RenderButtonsPanel): +class RENDER_PT_post_processing(RenderButtonsPanel, bpy.types.Panel): bl_label = "Post Processing" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -499,7 +492,6 @@ class RENDER_PT_post_processing(RenderButtonsPanel): layout = self.layout rd = context.scene.render - wide_ui = context.region.width > narrowui split = layout.split() @@ -507,8 +499,7 @@ class RENDER_PT_post_processing(RenderButtonsPanel): col.prop(rd, "use_compositing") col.prop(rd, "use_sequencer") - if wide_ui: - col = split.column() + col = split.column() col.prop(rd, "dither_intensity", text="Dither", slider=True) layout.separator() @@ -523,10 +514,7 @@ class RENDER_PT_post_processing(RenderButtonsPanel): sub.prop(rd, "fields_still", text="Still") - if wide_ui: - col = split.column() - else: - col.separator() + col = split.column() col.prop(rd, "edge") sub = col.column() sub.active = rd.edge @@ -540,7 +528,7 @@ class RENDER_PT_post_processing(RenderButtonsPanel): col.prop(rd, "freestyle", text="Freestyle") -class RENDER_PT_output(RenderButtonsPanel): +class RENDER_PT_output(RenderButtonsPanel, bpy.types.Panel): bl_label = "Output" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -549,7 +537,6 @@ class RENDER_PT_output(RenderButtonsPanel): rd = context.scene.render file_format = rd.file_format - wide_ui = context.region.width > narrowui layout.prop(rd, "output_path", text="") @@ -558,8 +545,7 @@ class RENDER_PT_output(RenderButtonsPanel): col.prop(rd, "file_format", text="") col.row().prop(rd, "color_mode", text="Color", expand=True) - if wide_ui: - col = split.column() + col = split.column() col.prop(rd, "use_file_extension") col.prop(rd, "use_overwrite") col.prop(rd, "use_placeholder") @@ -578,8 +564,7 @@ class RENDER_PT_output(RenderButtonsPanel): col = split.column() col.label(text="Codec:") col.prop(rd, "exr_codec", text="") - if wide_ui: - col = split.column() + col = split.column() elif file_format == 'OPEN_EXR': split = layout.split() @@ -588,14 +573,12 @@ class RENDER_PT_output(RenderButtonsPanel): col.label(text="Codec:") col.prop(rd, "exr_codec", text="") - if wide_ui: - subsplit = split.split() - col = subsplit.column() + subsplit = split.split() + col = subsplit.column() col.prop(rd, "exr_half") col.prop(rd, "exr_zbuf") - if wide_ui: - col = subsplit.column() + col = subsplit.column() col.prop(rd, "exr_preview") elif file_format == 'JPEG2000': @@ -604,8 +587,7 @@ class RENDER_PT_output(RenderButtonsPanel): col.label(text="Depth:") col.row().prop(rd, "jpeg2k_depth", expand=True) - if wide_ui: - col = split.column() + col = split.column() col.prop(rd, "jpeg2k_preset", text="") col.prop(rd, "jpeg2k_ycc") @@ -614,8 +596,7 @@ class RENDER_PT_output(RenderButtonsPanel): col = split.column() col.prop(rd, "cineon_log", text="Convert to Log") - if wide_ui: - col = split.column(align=True) + col = split.column(align=True) col.active = rd.cineon_log col.prop(rd, "cineon_black", text="Black") col.prop(rd, "cineon_white", text="White") @@ -642,30 +623,32 @@ class RENDER_PT_output(RenderButtonsPanel): col = split.column() if rd.quicktime_audiocodec_type == 'LPCM': col.prop(rd, "quicktime_audio_bitdepth", text="") - if wide_ui: - col = split.column() + + col = split.column() col.prop(rd, "quicktime_audio_samplerate", text="") split = layout.split() col = split.column() if rd.quicktime_audiocodec_type == 'AAC': col.prop(rd, "quicktime_audio_bitrate") - if wide_ui: - subsplit = split.split() - col = subsplit.column() + + subsplit = split.split() + col = subsplit.column() + if rd.quicktime_audiocodec_type == 'AAC': col.prop(rd, "quicktime_audio_codec_isvbr") - if wide_ui: - col = subsplit.column() + + col = subsplit.column() col.prop(rd, "quicktime_audio_resampling_hq") -class RENDER_PT_encoding(RenderButtonsPanel): +class RENDER_PT_encoding(RenderButtonsPanel, bpy.types.Panel): bl_label = "Encoding" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): rd = context.scene.render return rd.file_format in ('FFMPEG', 'XVID', 'H264', 'THEORA') @@ -673,7 +656,6 @@ class RENDER_PT_encoding(RenderButtonsPanel): layout = self.layout rd = context.scene.render - wide_ui = context.region.width > narrowui layout.menu("RENDER_MT_ffmpeg_presets", text="Presets") @@ -682,19 +664,17 @@ class RENDER_PT_encoding(RenderButtonsPanel): col = split.column() col.prop(rd, "ffmpeg_format") if rd.ffmpeg_format in ('AVI', 'QUICKTIME', 'MKV', 'OGG'): - if wide_ui: - col = split.column() + col = split.column() col.prop(rd, "ffmpeg_codec") else: - if wide_ui: - split.label() + split.label() split = layout.split() col = split.column() col.prop(rd, "ffmpeg_video_bitrate") - if wide_ui: - col = split.column() + + col = split.column() col.prop(rd, "ffmpeg_gopsize") split = layout.split() @@ -705,8 +685,7 @@ class RENDER_PT_encoding(RenderButtonsPanel): col.prop(rd, "ffmpeg_maxrate", text="Maximum") col.prop(rd, "ffmpeg_buffersize", text="Buffer") - if wide_ui: - col = split.column() + col = split.column() col.prop(rd, "ffmpeg_autosplit") col.label(text="Mux:") @@ -727,12 +706,11 @@ class RENDER_PT_encoding(RenderButtonsPanel): col.prop(rd, "ffmpeg_audio_bitrate") col.prop(rd, "ffmpeg_audio_mixrate") - if wide_ui: - col = split.column() + col = split.column() col.prop(rd, "ffmpeg_audio_volume", slider=True) -class RENDER_PT_antialiasing(RenderButtonsPanel): +class RENDER_PT_antialiasing(RenderButtonsPanel, bpy.types.Panel): bl_label = "Anti-Aliasing" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -745,7 +723,6 @@ class RENDER_PT_antialiasing(RenderButtonsPanel): layout = self.layout rd = context.scene.render - wide_ui = context.region.width > narrowui layout.active = rd.render_antialiasing split = layout.split() @@ -756,13 +733,12 @@ class RENDER_PT_antialiasing(RenderButtonsPanel): sub.enabled = not rd.use_border sub.prop(rd, "full_sample") - if wide_ui: - col = split.column() + col = split.column() col.prop(rd, "pixel_filter", text="") col.prop(rd, "filter_size", text="Size") -class RENDER_PT_motion_blur(RenderButtonsPanel): +class RENDER_PT_motion_blur(RenderButtonsPanel, bpy.types.Panel): bl_label = "Full Sample Motion Blur" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -782,8 +758,7 @@ class RENDER_PT_motion_blur(RenderButtonsPanel): row.prop(rd, "motion_blur_samples") row.prop(rd, "motion_blur_shutter") - -class RENDER_PT_dimensions(RenderButtonsPanel): +class RENDER_PT_dimensions(RenderButtonsPanel, bpy.types.Panel): bl_label = "Dimensions" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -792,7 +767,6 @@ class RENDER_PT_dimensions(RenderButtonsPanel): scene = context.scene rd = scene.render - wide_ui = context.region.width > narrowui row = layout.row(align=True) row.menu("RENDER_MT_presets", text=bpy.types.RENDER_MT_presets.bl_label) @@ -817,8 +791,7 @@ class RENDER_PT_dimensions(RenderButtonsPanel): sub.active = rd.use_border sub.prop(rd, "crop_to_border", text="Crop") - if wide_ui: - col = split.column() + col = split.column() sub = col.column(align=True) sub.label(text="Frame Range:") sub.prop(scene, "frame_start", text="Start") @@ -830,7 +803,7 @@ class RENDER_PT_dimensions(RenderButtonsPanel): sub.prop(rd, "fps_base", text="/") -class RENDER_PT_stamp(RenderButtonsPanel): +class RENDER_PT_stamp(RenderButtonsPanel, bpy.types.Panel): bl_label = "Stamp" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -844,7 +817,6 @@ class RENDER_PT_stamp(RenderButtonsPanel): layout = self.layout rd = context.scene.render - wide_ui = context.region.width > narrowui layout.active = rd.render_stamp @@ -861,8 +833,7 @@ class RENDER_PT_stamp(RenderButtonsPanel): col.prop(rd, "stamp_marker", text="Marker") col.prop(rd, "stamp_sequencer_strip", text="Seq. Strip") - if wide_ui: - col = split.column() + col = split.column() col.active = rd.render_stamp col.prop(rd, "stamp_foreground", slider=True) col.prop(rd, "stamp_background", slider=True) @@ -876,7 +847,7 @@ class RENDER_PT_stamp(RenderButtonsPanel): sub.prop(rd, "stamp_note_text", text="") -class RENDER_PT_bake(RenderButtonsPanel): +class RENDER_PT_bake(RenderButtonsPanel, bpy.types.Panel): bl_label = "Bake" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -885,20 +856,13 @@ class RENDER_PT_bake(RenderButtonsPanel): layout = self.layout rd = context.scene.render - wide_ui = context.region.width > narrowui layout.operator("object.bake_image", icon='RENDER_STILL') - if wide_ui: - layout.prop(rd, "bake_type") - else: - layout.prop(rd, "bake_type", text="") + layout.prop(rd, "bake_type") if rd.bake_type == 'NORMALS': - if wide_ui: - layout.prop(rd, "bake_normal_space") - else: - layout.prop(rd, "bake_normal_space", text="") + layout.prop(rd, "bake_normal_space") elif rd.bake_type in ('DISPLACEMENT', 'AO'): layout.prop(rd, "bake_normalized") @@ -914,8 +878,7 @@ class RENDER_PT_bake(RenderButtonsPanel): col.prop(rd, "bake_margin") col.prop(rd, "bake_quad_split", text="Split") - if wide_ui: - col = split.column() + col = split.column() col.prop(rd, "bake_active") sub = col.column() sub.active = rd.bake_active @@ -923,35 +886,12 @@ class RENDER_PT_bake(RenderButtonsPanel): sub.prop(rd, "bake_bias") -classes = [ - RENDER_MT_presets, - RENDER_MT_ffmpeg_presets, - RENDER_PT_render, - RENDER_PT_layers, - RENDER_PT_freestyle, - RENDER_PT_freestyle_linestyle, - RENDER_PT_dimensions, - RENDER_PT_antialiasing, - RENDER_PT_motion_blur, - RENDER_PT_shading, - RENDER_PT_output, - RENDER_PT_encoding, - RENDER_PT_performance, - RENDER_PT_post_processing, - RENDER_PT_stamp, - RENDER_PT_bake] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_render_test.xml b/release/scripts/ui/properties_render_test.xml new file mode 100644 index 00000000000..f8a77e37e21 --- /dev/null +++ b/release/scripts/ui/properties_render_test.xml @@ -0,0 +1,79 @@ +<ui> + <panel identifier="RENDER_PT_stamp_test" label="Stamp (XML)" space_type="PROPERTIES" region_type="WINDOW" context="render" default_closed="true"> + <draw_header> + <prop data="context.scene.render" property="render_stamp" text=""/> + </draw_header> + + <draw> + <split> + <column> + <prop data="context.scene.render" property="stamp_time" text="Time"/> + <prop data="context.scene.render" property="stamp_date" text="Date"/> + <prop data="context.scene.render" property="stamp_render_time" text="RenderTime"/> + <prop data="context.scene.render" property="stamp_frame" text="Frame"/> + <prop data="context.scene.render" property="stamp_scene" text="Scene"/> + <prop data="context.scene.render" property="stamp_camera" text="Camera"/> + <prop data="context.scene.render" property="stamp_filename" text="Filename"/> + <prop data="context.scene.render" property="stamp_marker" text="Marker"/> + <prop data="context.scene.render" property="stamp_sequencer_strip" text="Seq. Strip"/> + </column> + <column> + <active expr="context.scene.render.render_stamp"/> + <prop data="context.scene.render" property="stamp_foreground" slider="true"/> + <prop data="context.scene.render" property="stamp_background" slider="true"/> + <separator/> + <prop data="context.scene.render" property="stamp_font_size" text="Font Size"/> + </column> + </split> + <split percentage="0.2"> + <prop data="context.scene.render" property="stamp_note" text="Note"/> + <row> + <active expr="context.scene.render.stamp_note"/> + <prop data="context.scene.render" property="stamp_note_text" text=""/> + </row> + </split> + </draw> + </panel> + + <panel identifier="RENDER_PT_dimensions_test" label="Dimensions (XML)" space_type="PROPERTIES" region_type="WINDOW" context="render"> + <draw> + <row align="true"> + <menu menu="RENDER_MT_presets"/> + <operator operator="render.preset_add" text="" icon="ZOOMIN"/> + </row> + <split> + <column> + <column align="true"> + <label text="Resolution:"/> + <prop data="context.scene.render" property="resolution_x" text="X"/> + <prop data="context.scene.render" property="resolution_y" text="Y"/> + <prop data="context.scene.render" property="resolution_percentage" text=""/> + + <label text="Aspect Ratio:"/> + <prop data="context.scene.render" property="pixel_aspect_x" text="X"/> + <prop data="context.scene.render" property="pixel_aspect_y" text="Y"/> + </column> + <row> + <prop data="context.scene.render" property="use_border" text="Border"/> + <row> + <active expr="context.scene.render.use_border"/> + <prop data="context.scene.render" property="crop_to_border" text="Crop"/> + </row> + </row> + </column> + <column> + <column align="true"> + <label text="Frame Range:"/> + <prop data="context.scene" property="frame_start" text="Start"/> + <prop data="context.scene" property="frame_end" text="End"/> + <prop data="context.scene" property="frame_step" text="Step"/> + + <label text="Frame Rate:"/> + <prop data="context.scene.render" property="fps"/> + <prop data="context.scene.render" property="fps_base" text="/"/> + </column> + </column> + </split> + </draw> + </panel> +</ui> diff --git a/release/scripts/ui/properties_scene.py b/release/scripts/ui/properties_scene.py index 06ad1eda835..3ed8dfb72b8 100644 --- a/release/scripts/ui/properties_scene.py +++ b/release/scripts/ui/properties_scene.py @@ -20,46 +20,40 @@ import bpy from rna_prop_ui import PropertyPanel -narrowui = bpy.context.user_preferences.view.properties_width_check - -class SceneButtonsPanel(bpy.types.Panel): +class SceneButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "scene" - def poll(self, context): + @classmethod + def poll(cls, context): return context.scene -class SCENE_PT_scene(SceneButtonsPanel): +class SCENE_PT_scene(SceneButtonsPanel, bpy.types.Panel): bl_label = "Scene" COMPAT_ENGINES = {'BLENDER_RENDER'} def draw(self, context): layout = self.layout - wide_ui = context.region.width > narrowui scene = context.scene - if wide_ui: - layout.prop(scene, "camera") - layout.prop(scene, "set", text="Background") - else: - layout.prop(scene, "camera", text="") - layout.prop(scene, "set", text="") + layout.prop(scene, "camera") + layout.prop(scene, "set", text="Background") -class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel): +class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, bpy.types.Panel): + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "scene" -class SCENE_PT_unit(SceneButtonsPanel): +class SCENE_PT_unit(SceneButtonsPanel, bpy.types.Panel): bl_label = "Units" COMPAT_ENGINES = {'BLENDER_RENDER'} def draw(self, context): layout = self.layout - wide_ui = context.region.width > narrowui unit = context.scene.unit_settings col = layout.column() @@ -71,21 +65,19 @@ class SCENE_PT_unit(SceneButtonsPanel): col = split.column() col.prop(unit, "scale_length", text="Scale") - if wide_ui: - col = split.column() + col = split.column() col.prop(unit, "use_separate") layout.column().prop(unit, "rotation_units") -class SCENE_PT_keying_sets(SceneButtonsPanel): +class SCENE_PT_keying_sets(SceneButtonsPanel, bpy.types.Panel): bl_label = "Keying Sets" def draw(self, context): layout = self.layout scene = context.scene - wide_ui = context.region.width > narrowui row = layout.row() col = row.column() @@ -107,18 +99,18 @@ class SCENE_PT_keying_sets(SceneButtonsPanel): op = subcol.operator("anim.keying_set_export", text="Export to File") op.filepath = "keyingset.py" - if wide_ui: - col = row.column() + col = row.column() col.label(text="Keyframing Settings:") col.prop(ks, "insertkey_needed", text="Needed") col.prop(ks, "insertkey_visual", text="Visual") col.prop(ks, "insertkey_xyz_to_rgb", text="XYZ to RGB") -class SCENE_PT_keying_set_paths(SceneButtonsPanel): +class SCENE_PT_keying_set_paths(SceneButtonsPanel, bpy.types.Panel): bl_label = "Active Keying Set" - def poll(self, context): + @classmethod + def poll(cls, context): return (context.scene.active_keying_set and context.scene.active_keying_set.absolute) def draw(self, context): @@ -126,7 +118,6 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel): scene = context.scene ks = scene.active_keying_set - wide_ui = context.region.width > narrowui row = layout.row() row.label(text="Paths:") @@ -156,8 +147,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel): if ksp.entire_array is False: col.prop(ksp, "array_index") - if wide_ui: - col = row.column() + col = row.column() col.label(text="F-Curve Grouping:") col.prop(ksp, "grouping") if ksp.grouping == 'NAMED': @@ -169,7 +159,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel): col.prop(ksp, "insertkey_xyz_to_rgb", text="XYZ to RGB") -class SCENE_PT_physics(SceneButtonsPanel): +class SCENE_PT_physics(SceneButtonsPanel, bpy.types.Panel): bl_label = "Gravity" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -180,17 +170,13 @@ class SCENE_PT_physics(SceneButtonsPanel): layout = self.layout scene = context.scene - wide_ui = context.region.width > narrowui layout.active = scene.use_gravity - if wide_ui: - layout.prop(scene, "gravity", text="") - else: - layout.column().prop(scene, "gravity", text="") + layout.prop(scene, "gravity", text="") -class SCENE_PT_simplify(SceneButtonsPanel): +class SCENE_PT_simplify(SceneButtonsPanel, bpy.types.Panel): bl_label = "Simplify" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -203,7 +189,6 @@ class SCENE_PT_simplify(SceneButtonsPanel): layout = self.layout scene = context.scene rd = scene.render - wide_ui = context.region.width > narrowui layout.active = rd.use_simplify @@ -215,8 +200,7 @@ class SCENE_PT_simplify(SceneButtonsPanel): col.prop(rd, "simplify_triangulate") - if wide_ui: - col = split.column() + col = split.column() col.prop(rd, "simplify_shadow_samples", text="Shadow Samples") col.prop(rd, "simplify_ao_sss", text="AO and SSS") @@ -334,29 +318,12 @@ class ANIM_OT_keying_set_export(bpy.types.Operator): return {'RUNNING_MODAL'} -classes = [ - SCENE_PT_scene, - SCENE_PT_unit, - SCENE_PT_keying_sets, - SCENE_PT_keying_set_paths, - SCENE_PT_physics, - SCENE_PT_simplify, - - SCENE_PT_custom_props, - - ANIM_OT_keying_set_export] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_texture.py b/release/scripts/ui/properties_texture.py index 2bfbe188c9e..b675576ec3f 100644 --- a/release/scripts/ui/properties_texture.py +++ b/release/scripts/ui/properties_texture.py @@ -20,8 +20,6 @@ import bpy from rna_prop_ui import PropertyPanel -narrowui = bpy.context.user_preferences.view.properties_width_check - class TEXTURE_MT_specials(bpy.types.Menu): bl_label = "Texture Specials" @@ -65,20 +63,18 @@ def context_tex_datablock(context): return idblock -class TextureButtonsPanel(bpy.types.Panel): +class TextureButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "texture" - def poll(self, context): + @classmethod + def poll(cls, context): tex = context.texture - if not tex: - return False - engine = context.scene.render.engine - return (tex.type != 'NONE' or tex.use_nodes) and (engine in self.COMPAT_ENGINES) + return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.scene.render.engine in cls.COMPAT_ENGINES) -class TEXTURE_PT_preview(TextureButtonsPanel): +class TEXTURE_PT_preview(TextureButtonsPanel, bpy.types.Panel): bl_label = "Preview" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -95,17 +91,18 @@ class TEXTURE_PT_preview(TextureButtonsPanel): layout.template_preview(tex, slot=slot) -class TEXTURE_PT_context_texture(TextureButtonsPanel): +class TEXTURE_PT_context_texture(TextureButtonsPanel, bpy.types.Panel): bl_label = "" bl_show_header = False COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): engine = context.scene.render.engine if not hasattr(context, "texture_slot"): return False return ((context.material or context.world or context.lamp or context.brush or context.texture) - and (engine in self.COMPAT_ENGINES)) + and (engine in cls.COMPAT_ENGINES)) def draw(self, context): layout = self.layout @@ -113,7 +110,6 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel): node = context.texture_node space = context.space_data tex = context.texture - wide_ui = context.region.width > narrowui idblock = context_tex_datablock(context) tex_collection = space.pin_id == None and type(idblock) != bpy.types.Brush and not node @@ -127,11 +123,8 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel): col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN' col.menu("TEXTURE_MT_specials", icon='DOWNARROW_HLT', text="") - if wide_ui: - split = layout.split(percentage=0.65) - col = split.column() - else: - col = layout.column() + split = layout.split(percentage=0.65) + col = split.column() if tex_collection: col.template_ID(idblock, "active_texture", new="texture.new") @@ -143,8 +136,7 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel): if space.pin_id: col.template_ID(space, "pin_id") - if wide_ui: - col = split.column() + col = split.column() if not space.pin_id: col.prop(space, "brush_texture", text="Brush", toggle=True) @@ -159,23 +151,16 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel): split.prop(slot, "output_node", text="") else: - if wide_ui: - split.label(text="Type:") - split.prop(tex, "type", text="") - else: - layout.prop(tex, "type", text="") + split.label(text="Type:") + split.prop(tex, "type", text="") -class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel): - _context_path = "texture" +class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, bpy.types.Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - - def poll(self, context): # use alternate poll since NONE texture type is ok - engine = context.scene.render.engine - return context.texture and (engine in self.COMPAT_ENGINES) + _context_path = "texture" -class TEXTURE_PT_colors(TextureButtonsPanel): +class TEXTURE_PT_colors(TextureButtonsPanel, bpy.types.Panel): bl_label = "Colors" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -184,7 +169,6 @@ class TEXTURE_PT_colors(TextureButtonsPanel): layout = self.layout tex = context.texture - wide_ui = context.region.width > narrowui layout.prop(tex, "use_color_ramp", text="Ramp") if tex.use_color_ramp: @@ -199,8 +183,7 @@ class TEXTURE_PT_colors(TextureButtonsPanel): sub.prop(tex, "factor_green", text="G") sub.prop(tex, "factor_blue", text="B") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Adjust:") col.prop(tex, "brightness") col.prop(tex, "contrast") @@ -212,19 +195,21 @@ class TEXTURE_PT_colors(TextureButtonsPanel): class TextureSlotPanel(TextureButtonsPanel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): if not hasattr(context, "texture_slot"): return False engine = context.scene.render.engine - return TextureButtonsPanel.poll(self, context) and (engine in self.COMPAT_ENGINES) + return TextureButtonsPanel.poll(self, context) and (engine in cls.COMPAT_ENGINES) -class TEXTURE_PT_mapping(TextureSlotPanel): +class TEXTURE_PT_mapping(TextureSlotPanel, bpy.types.Panel): bl_label = "Mapping" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): idblock = context_tex_datablock(context) if type(idblock) == bpy.types.Brush and not context.sculpt_object: return False @@ -233,7 +218,7 @@ class TEXTURE_PT_mapping(TextureSlotPanel): return False engine = context.scene.render.engine - return (engine in self.COMPAT_ENGINES) + return (engine in cls.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -242,7 +227,6 @@ class TEXTURE_PT_mapping(TextureSlotPanel): tex = context.texture_slot # textype = context.texture - wide_ui = context.region.width > narrowui if type(idblock) != bpy.types.Brush: split = layout.split(percentage=0.3) @@ -294,11 +278,10 @@ class TEXTURE_PT_mapping(TextureSlotPanel): col.prop(tex, "from_dupli") elif tex.texture_coordinates == 'OBJECT': col.prop(tex, "from_original") - elif wide_ui: + else: col.label() - if wide_ui: - col = split.column() + col = split.column() row = col.row() row.prop(tex, "x_mapping", text="") row.prop(tex, "y_mapping", text="") @@ -309,19 +292,17 @@ class TEXTURE_PT_mapping(TextureSlotPanel): col = split.column() col.prop(tex, "offset") - if wide_ui: - col = split.column() - else: - col.separator() + col = split.column() col.prop(tex, "size") -class TEXTURE_PT_influence(TextureSlotPanel): +class TEXTURE_PT_influence(TextureSlotPanel, bpy.types.Panel): bl_label = "Influence" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): idblock = context_tex_datablock(context) if type(idblock) == bpy.types.Brush: return False @@ -330,7 +311,7 @@ class TEXTURE_PT_influence(TextureSlotPanel): return False engine = context.scene.render.engine - return (engine in self.COMPAT_ENGINES) + return (engine in cls.COMPAT_ENGINES) def draw(self, context): @@ -340,7 +321,6 @@ class TEXTURE_PT_influence(TextureSlotPanel): # textype = context.texture tex = context.texture_slot - wide_ui = context.region.width > narrowui def factor_but(layout, active, toggle, factor, name): row = layout.row(align=True) @@ -365,8 +345,7 @@ class TEXTURE_PT_influence(TextureSlotPanel): factor_but(col, tex.map_colorspec, "map_colorspec", "colorspec_factor", "Color") factor_but(col, tex.map_hardness, "map_hardness", "hardness_factor", "Hardness") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Shading:") factor_but(col, tex.map_ambient, "map_ambient", "ambient_factor", "Ambient") factor_but(col, tex.map_emit, "map_emit", "emit_factor", "Emit") @@ -391,9 +370,8 @@ class TEXTURE_PT_influence(TextureSlotPanel): factor_but(col, tex.map_scattering, "map_scattering", "scattering_factor", "Scattering") factor_but(col, tex.map_reflection, "map_reflection", "reflection_factor", "Reflection") - if wide_ui: - col = split.column() - col.label(text=" ") + col = split.column() + col.label(text=" ") factor_but(col, tex.map_coloremission, "map_coloremission", "coloremission_factor", "Emission Color") factor_but(col, tex.map_colortransmission, "map_colortransmission", "colortransmission_factor", "Transmission Color") factor_but(col, tex.map_colorreflection, "map_colorreflection", "colorreflection_factor", "Reflection Color") @@ -404,8 +382,7 @@ class TEXTURE_PT_influence(TextureSlotPanel): col = split.column() factor_but(col, tex.map_color, "map_color", "color_factor", "Color") - if wide_ui: - col = split.column() + col = split.column() factor_but(col, tex.map_shadow, "map_shadow", "shadow_factor", "Shadow") elif type(idblock) == bpy.types.World: @@ -415,8 +392,7 @@ class TEXTURE_PT_influence(TextureSlotPanel): factor_but(col, tex.map_blend, "map_blend", "blend_factor", "Blend") factor_but(col, tex.map_horizon, "map_horizon", "horizon_factor", "Horizon") - if wide_ui: - col = split.column() + col = split.column() factor_but(col, tex.map_zenith_up, "map_zenith_up", "zenith_up_factor", "Zenith Up") factor_but(col, tex.map_zenith_down, "map_zenith_down", "zenith_down_factor", "Zenith Down") @@ -431,8 +407,7 @@ class TEXTURE_PT_influence(TextureSlotPanel): sub.active = tex.rgb_to_intensity sub.prop(tex, "color", text="") - if wide_ui: - col = split.column() + col = split.column() col.prop(tex, "negate", text="Negative") col.prop(tex, "stencil") @@ -443,15 +418,15 @@ class TEXTURE_PT_influence(TextureSlotPanel): class TextureTypePanel(TextureButtonsPanel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): tex = context.texture engine = context.scene.render.engine - return ((tex and tex.type == self.tex_type and not tex.use_nodes) and (engine in self.COMPAT_ENGINES)) + return tex and ((tex.type == cls.tex_type and not tex.use_nodes) and (engine in cls.COMPAT_ENGINES)) -class TEXTURE_PT_clouds(TextureTypePanel): +class TEXTURE_PT_clouds(TextureTypePanel, bpy.types.Panel): bl_label = "Clouds" tex_type = 'CLOUDS' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -460,15 +435,11 @@ class TEXTURE_PT_clouds(TextureTypePanel): layout = self.layout tex = context.texture - wide_ui = context.region.width > narrowui layout.prop(tex, "stype", expand=True) layout.label(text="Noise:") layout.prop(tex, "noise_type", text="Type", expand=True) - if wide_ui: - layout.prop(tex, "noise_basis", text="Basis") - else: - layout.prop(tex, "noise_basis", text="") + layout.prop(tex, "noise_basis", text="Basis") split = layout.split() @@ -476,12 +447,11 @@ class TEXTURE_PT_clouds(TextureTypePanel): col.prop(tex, "noise_size", text="Size") col.prop(tex, "noise_depth", text="Depth") - if wide_ui: - col = split.column() + col = split.column() col.prop(tex, "nabla", text="Nabla") -class TEXTURE_PT_wood(TextureTypePanel): +class TEXTURE_PT_wood(TextureTypePanel, bpy.types.Panel): bl_label = "Wood" tex_type = 'WOOD' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -490,22 +460,15 @@ class TEXTURE_PT_wood(TextureTypePanel): layout = self.layout tex = context.texture - wide_ui = context.region.width > narrowui layout.prop(tex, "noisebasis2", expand=True) - if wide_ui: - layout.prop(tex, "stype", expand=True) - else: - layout.prop(tex, "stype", text="") + layout.prop(tex, "stype", expand=True) col = layout.column() col.active = tex.stype in ('RINGNOISE', 'BANDNOISE') col.label(text="Noise:") col.row().prop(tex, "noise_type", text="Type", expand=True) - if wide_ui: - layout.prop(tex, "noise_basis", text="Basis") - else: - layout.prop(tex, "noise_basis", text="") + layout.prop(tex, "noise_basis", text="Basis") split = layout.split() split.active = tex.stype in ('RINGNOISE', 'BANDNOISE') @@ -518,7 +481,7 @@ class TEXTURE_PT_wood(TextureTypePanel): col.prop(tex, "nabla") -class TEXTURE_PT_marble(TextureTypePanel): +class TEXTURE_PT_marble(TextureTypePanel, bpy.types.Panel): bl_label = "Marble" tex_type = 'MARBLE' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -527,16 +490,12 @@ class TEXTURE_PT_marble(TextureTypePanel): layout = self.layout tex = context.texture - wide_ui = context.region.width > narrowui layout.prop(tex, "stype", expand=True) layout.prop(tex, "noisebasis2", expand=True) layout.label(text="Noise:") layout.prop(tex, "noise_type", text="Type", expand=True) - if wide_ui: - layout.prop(tex, "noise_basis", text="Basis") - else: - layout.prop(tex, "noise_basis", text="") + layout.prop(tex, "noise_basis", text="Basis") split = layout.split() @@ -544,13 +503,12 @@ class TEXTURE_PT_marble(TextureTypePanel): col.prop(tex, "noise_size", text="Size") col.prop(tex, "noise_depth", text="Depth") - if wide_ui: - col = split.column() + col = split.column() col.prop(tex, "turbulence") col.prop(tex, "nabla") -class TEXTURE_PT_magic(TextureTypePanel): +class TEXTURE_PT_magic(TextureTypePanel, bpy.types.Panel): bl_label = "Magic" tex_type = 'MAGIC' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -559,19 +517,17 @@ class TEXTURE_PT_magic(TextureTypePanel): layout = self.layout tex = context.texture - wide_ui = context.region.width > narrowui split = layout.split() col = split.column() col.prop(tex, "noise_depth", text="Depth") - if wide_ui: - col = split.column() + col = split.column() col.prop(tex, "turbulence") -class TEXTURE_PT_blend(TextureTypePanel): +class TEXTURE_PT_blend(TextureTypePanel, bpy.types.Panel): bl_label = "Blend" tex_type = 'BLEND' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -580,12 +536,8 @@ class TEXTURE_PT_blend(TextureTypePanel): layout = self.layout tex = context.texture - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(tex, "progression") - else: - layout.prop(tex, "progression", text="") + layout.prop(tex, "progression") sub = layout.row() @@ -593,7 +545,7 @@ class TEXTURE_PT_blend(TextureTypePanel): sub.prop(tex, "flip_axis", expand=True) -class TEXTURE_PT_stucci(TextureTypePanel): +class TEXTURE_PT_stucci(TextureTypePanel, bpy.types.Panel): bl_label = "Stucci" tex_type = 'STUCCI' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -602,27 +554,22 @@ class TEXTURE_PT_stucci(TextureTypePanel): layout = self.layout tex = context.texture - wide_ui = context.region.width > narrowui layout.prop(tex, "stype", expand=True) layout.label(text="Noise:") layout.prop(tex, "noise_type", text="Type", expand=True) - if wide_ui: - layout.prop(tex, "noise_basis", text="Basis") - else: - layout.prop(tex, "noise_basis", text="") + layout.prop(tex, "noise_basis", text="Basis") split = layout.split() col = split.column() col.prop(tex, "noise_size", text="Size") - if wide_ui: - col = split.column() + col = split.column() col.prop(tex, "turbulence") -class TEXTURE_PT_image(TextureTypePanel): +class TEXTURE_PT_image(TextureTypePanel, bpy.types.Panel): bl_label = "Image" tex_type = 'IMAGE' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -648,7 +595,7 @@ def texture_filter_common(tex, layout): layout.prop(tex, "filter_size_minimum") -class TEXTURE_PT_image_sampling(TextureTypePanel): +class TEXTURE_PT_image_sampling(TextureTypePanel, bpy.types.Panel): bl_label = "Image Sampling" bl_default_closed = True tex_type = 'IMAGE' @@ -659,7 +606,6 @@ class TEXTURE_PT_image_sampling(TextureTypePanel): tex = context.texture # slot = context.texture_slot - wide_ui = context.region.width > narrowui split = layout.split() @@ -671,10 +617,8 @@ class TEXTURE_PT_image_sampling(TextureTypePanel): col.separator() col.prop(tex, "flip_axis", text="Flip X/Y Axis") - if wide_ui: - col = split.column() - else: - col.separator() + col = split.column() + col.prop(tex, "normal_map") row = col.row() row.active = tex.normal_map @@ -689,7 +633,7 @@ class TEXTURE_PT_image_sampling(TextureTypePanel): texture_filter_common(tex, col) -class TEXTURE_PT_image_mapping(TextureTypePanel): +class TEXTURE_PT_image_mapping(TextureTypePanel, bpy.types.Panel): bl_label = "Image Mapping" bl_default_closed = True tex_type = 'IMAGE' @@ -699,12 +643,8 @@ class TEXTURE_PT_image_mapping(TextureTypePanel): layout = self.layout tex = context.texture - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(tex, "extension") - else: - layout.prop(tex, "extension", text="") + layout.prop(tex, "extension") split = layout.split() @@ -714,8 +654,7 @@ class TEXTURE_PT_image_mapping(TextureTypePanel): col.prop(tex, "repeat_x", text="X") col.prop(tex, "repeat_y", text="Y") - if wide_ui: - col = split.column(align=True) + col = split.column(align=True) col.label(text="Mirror:") col.prop(tex, "mirror_x", text="X") col.prop(tex, "mirror_y", text="Y") @@ -727,8 +666,7 @@ class TEXTURE_PT_image_mapping(TextureTypePanel): row.prop(tex, "checker_even", text="Even") row.prop(tex, "checker_odd", text="Odd") - if wide_ui: - col = split.column() + col = split.column() col.prop(tex, "checker_distance", text="Distance") layout.separator() @@ -741,14 +679,13 @@ class TEXTURE_PT_image_mapping(TextureTypePanel): col.prop(tex, "crop_min_x", text="X") col.prop(tex, "crop_min_y", text="Y") - if wide_ui: - col = split.column(align=True) + col = split.column(align=True) col.label(text="Crop Maximum:") col.prop(tex, "crop_max_x", text="X") col.prop(tex, "crop_max_y", text="Y") -class TEXTURE_PT_plugin(TextureTypePanel): +class TEXTURE_PT_plugin(TextureTypePanel, bpy.types.Panel): bl_label = "Plugin" tex_type = 'PLUGIN' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -761,7 +698,7 @@ class TEXTURE_PT_plugin(TextureTypePanel): layout.label(text="Nothing yet") -class TEXTURE_PT_envmap(TextureTypePanel): +class TEXTURE_PT_envmap(TextureTypePanel, bpy.types.Panel): bl_label = "Environment Map" tex_type = 'ENVIRONMENT_MAP' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -772,7 +709,6 @@ class TEXTURE_PT_envmap(TextureTypePanel): tex = context.texture env = tex.environment_map - wide_ui = context.region.width > narrowui row = layout.row() row.prop(env, "source", expand=True) @@ -794,15 +730,14 @@ class TEXTURE_PT_envmap(TextureTypePanel): col.prop(env, "resolution") col.prop(env, "depth") - if wide_ui: - col = split.column(align=True) + col = split.column(align=True) col.label(text="Clipping:") col.prop(env, "clip_start", text="Start") col.prop(env, "clip_end", text="End") -class TEXTURE_PT_envmap_sampling(TextureTypePanel): +class TEXTURE_PT_envmap_sampling(TextureTypePanel, bpy.types.Panel): bl_label = "Environment Map Sampling" bl_default_closed = True tex_type = 'ENVIRONMENT_MAP' @@ -816,7 +751,7 @@ class TEXTURE_PT_envmap_sampling(TextureTypePanel): texture_filter_common(tex, layout) -class TEXTURE_PT_musgrave(TextureTypePanel): +class TEXTURE_PT_musgrave(TextureTypePanel, bpy.types.Panel): bl_label = "Musgrave" tex_type = 'MUSGRAVE' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -825,12 +760,8 @@ class TEXTURE_PT_musgrave(TextureTypePanel): layout = self.layout tex = context.texture - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(tex, "musgrave_type") - else: - layout.prop(tex, "musgrave_type", text="") + layout.prop(tex, "musgrave_type") split = layout.split() @@ -839,8 +770,7 @@ class TEXTURE_PT_musgrave(TextureTypePanel): col.prop(tex, "lacunarity") col.prop(tex, "octaves") - if wide_ui: - col = split.column() + col = split.column() if (tex.musgrave_type in ('HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')): col.prop(tex, "offset") if (tex.musgrave_type in ('RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')): @@ -849,22 +779,18 @@ class TEXTURE_PT_musgrave(TextureTypePanel): layout.label(text="Noise:") - if wide_ui: - layout.prop(tex, "noise_basis", text="Basis") - else: - layout.prop(tex, "noise_basis", text="") + layout.prop(tex, "noise_basis", text="Basis") split = layout.split() col = split.column() col.prop(tex, "noise_size", text="Size") - if wide_ui: - col = split.column() + col = split.column() col.prop(tex, "nabla") -class TEXTURE_PT_voronoi(TextureTypePanel): +class TEXTURE_PT_voronoi(TextureTypePanel, bpy.types.Panel): bl_label = "Voronoi" tex_type = 'VORONOI' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -873,7 +799,6 @@ class TEXTURE_PT_voronoi(TextureTypePanel): layout = self.layout tex = context.texture - wide_ui = context.region.width > narrowui split = layout.split() @@ -887,8 +812,7 @@ class TEXTURE_PT_voronoi(TextureTypePanel): col.prop(tex, "coloring", text="") col.prop(tex, "noise_intensity", text="Intensity") - if wide_ui: - col = split.column() + col = split.column() sub = col.column(align=True) sub.label(text="Feature Weights:") sub.prop(tex, "weight_1", text="1", slider=True) @@ -903,12 +827,11 @@ class TEXTURE_PT_voronoi(TextureTypePanel): col = split.column() col.prop(tex, "noise_size", text="Size") - if wide_ui: - col = split.column() + col = split.column() col.prop(tex, "nabla") -class TEXTURE_PT_distortednoise(TextureTypePanel): +class TEXTURE_PT_distortednoise(TextureTypePanel, bpy.types.Panel): bl_label = "Distorted Noise" tex_type = 'DISTORTED_NOISE' COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} @@ -917,14 +840,9 @@ class TEXTURE_PT_distortednoise(TextureTypePanel): layout = self.layout tex = context.texture - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(tex, "noise_distortion") - layout.prop(tex, "noise_basis", text="Basis") - else: - layout.prop(tex, "noise_distortion", text="") - layout.prop(tex, "noise_basis", text="") + layout.prop(tex, "noise_distortion") + layout.prop(tex, "noise_basis", text="Basis") split = layout.split() @@ -932,19 +850,19 @@ class TEXTURE_PT_distortednoise(TextureTypePanel): col.prop(tex, "distortion", text="Distortion") col.prop(tex, "noise_size", text="Size") - if wide_ui: - col = split.column() + col = split.column() col.prop(tex, "nabla") -class TEXTURE_PT_voxeldata(TextureButtonsPanel): +class TEXTURE_PT_voxeldata(TextureButtonsPanel, bpy.types.Panel): bl_label = "Voxel Data" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): tex = context.texture engine = context.scene.render.engine - return (tex and tex.type == 'VOXEL_DATA' and (engine in self.COMPAT_ENGINES)) + return tex and (tex.type == 'VOXEL_DATA' and (engine in cls.COMPAT_ENGINES)) def draw(self, context): layout = self.layout @@ -975,26 +893,23 @@ class TEXTURE_PT_voxeldata(TextureButtonsPanel): layout.prop(vd, "intensity") -class TEXTURE_PT_pointdensity(TextureButtonsPanel): +class TEXTURE_PT_pointdensity(TextureButtonsPanel, bpy.types.Panel): bl_label = "Point Density" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): tex = context.texture engine = context.scene.render.engine - return (tex and tex.type == 'POINT_DENSITY' and (engine in self.COMPAT_ENGINES)) + return tex and (tex.type == 'POINT_DENSITY' and (engine in cls.COMPAT_ENGINES)) def draw(self, context): layout = self.layout tex = context.texture pd = tex.pointdensity - wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(pd, "point_source", expand=True) - else: - layout.prop(pd, "point_source", text="") + layout.prop(pd, "point_source", expand=True) split = layout.split() @@ -1025,8 +940,7 @@ class TEXTURE_PT_pointdensity(TextureButtonsPanel): if pd.color_source in ('PARTICLE_SPEED', 'PARTICLE_AGE'): layout.template_color_ramp(pd, "color_ramp", expand=True) - if wide_ui: - col = split.column() + col = split.column() col.label() col.prop(pd, "radius") col.label(text="Falloff:") @@ -1035,14 +949,15 @@ class TEXTURE_PT_pointdensity(TextureButtonsPanel): col.prop(pd, "falloff_softness") -class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel): +class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel, bpy.types.Panel): bl_label = "Turbulence" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - def poll(self, context): + @classmethod + def poll(cls, context): tex = context.texture engine = context.scene.render.engine - return (tex and tex.type == 'POINT_DENSITY' and (engine in self.COMPAT_ENGINES)) + return tex and (tex.type == 'POINT_DENSITY' and (engine in cls.COMPAT_ENGINES)) def draw_header(self, context): layout = self.layout @@ -1058,7 +973,6 @@ class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel): tex = context.texture pd = tex.pointdensity layout.active = pd.turbulence - wide_ui = context.region.width > narrowui split = layout.split() @@ -1068,57 +982,19 @@ class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel): col.label(text="Noise Basis:") col.prop(pd, "noise_basis", text="") - if wide_ui: - col = split.column() - col.label() + col = split.column() + col.label() col.prop(pd, "turbulence_size") col.prop(pd, "turbulence_depth") col.prop(pd, "turbulence_strength") -classes = [ - TEXTURE_MT_specials, - TEXTURE_MT_envmap_specials, - - TEXTURE_PT_context_texture, - TEXTURE_PT_preview, - - TEXTURE_PT_clouds, # Texture Type Panels - TEXTURE_PT_wood, - TEXTURE_PT_marble, - TEXTURE_PT_magic, - TEXTURE_PT_blend, - TEXTURE_PT_stucci, - TEXTURE_PT_image, - TEXTURE_PT_image_sampling, - TEXTURE_PT_image_mapping, - TEXTURE_PT_plugin, - TEXTURE_PT_envmap, - TEXTURE_PT_envmap_sampling, - TEXTURE_PT_musgrave, - TEXTURE_PT_voronoi, - TEXTURE_PT_distortednoise, - TEXTURE_PT_voxeldata, - TEXTURE_PT_pointdensity, - TEXTURE_PT_pointdensity_turbulence, - - TEXTURE_PT_colors, - TEXTURE_PT_mapping, - TEXTURE_PT_influence, - - TEXTURE_PT_custom_props] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/properties_world.py b/release/scripts/ui/properties_world.py index 22acd49f897..eec1caf58f7 100644 --- a/release/scripts/ui/properties_world.py +++ b/release/scripts/ui/properties_world.py @@ -20,36 +20,41 @@ import bpy from rna_prop_ui import PropertyPanel -narrowui = bpy.context.user_preferences.view.properties_width_check - -class WorldButtonsPanel(bpy.types.Panel): +class WorldButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "world" # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here - def poll(self, context): + @classmethod + def poll(cls, context): rd = context.scene.render - return (context.world) and (not rd.use_game_engine) and (rd.engine in self.COMPAT_ENGINES) + return (rd.engine in cls.COMPAT_ENGINES) -class WORLD_PT_preview(WorldButtonsPanel): +class WORLD_PT_preview(WorldButtonsPanel, bpy.types.Panel): bl_label = "Preview" COMPAT_ENGINES = {'BLENDER_RENDER'} + @classmethod + def poll(cls, context): + rd = context.scene.render + return (context.world) and (not rd.use_game_engine) and (rd.engine in cls.COMPAT_ENGINES) + def draw(self, context): self.layout.template_preview(context.world) -class WORLD_PT_context_world(WorldButtonsPanel): +class WORLD_PT_context_world(WorldButtonsPanel, bpy.types.Panel): bl_label = "" bl_show_header = False COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): rd = context.scene.render - return (not rd.use_game_engine) and (rd.engine in self.COMPAT_ENGINES) + return (not rd.use_game_engine) and (rd.engine in cls.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -57,43 +62,31 @@ class WORLD_PT_context_world(WorldButtonsPanel): scene = context.scene world = context.world space = context.space_data - wide_ui = context.region.width > narrowui - - if wide_ui: - split = layout.split(percentage=0.65) - if scene: - split.template_ID(scene, "world", new="world.new") - elif world: - split.template_ID(space, "pin_id") - else: - layout.template_ID(scene, "world", new="world.new") + split = layout.split(percentage=0.65) + if scene: + split.template_ID(scene, "world", new="world.new") + elif world: + split.template_ID(space, "pin_id") -class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel): - COMPAT_ENGINES = {'BLENDER_RENDER'} +class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel, bpy.types.Panel): + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "world" -class WORLD_PT_world(WorldButtonsPanel): +class WORLD_PT_world(WorldButtonsPanel, bpy.types.Panel): bl_label = "World" COMPAT_ENGINES = {'BLENDER_RENDER'} def draw(self, context): layout = self.layout - wide_ui = context.region.width > narrowui world = context.world - if wide_ui: - row = layout.row() - row.prop(world, "paper_sky") - row.prop(world, "blend_sky") - row.prop(world, "real_sky") - else: - col = layout.column() - col.prop(world, "paper_sky") - col.prop(world, "blend_sky") - col.prop(world, "real_sky") + row = layout.row() + row.prop(world, "paper_sky") + row.prop(world, "blend_sky") + row.prop(world, "real_sky") row = layout.row() row.column().prop(world, "horizon_color") @@ -103,7 +96,7 @@ class WORLD_PT_world(WorldButtonsPanel): row.column().prop(world, "ambient_color") -class WORLD_PT_mist(WorldButtonsPanel): +class WORLD_PT_mist(WorldButtonsPanel, bpy.types.Panel): bl_label = "Mist" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -115,7 +108,6 @@ class WORLD_PT_mist(WorldButtonsPanel): def draw(self, context): layout = self.layout - wide_ui = context.region.width > narrowui world = context.world layout.active = world.mist.use_mist @@ -126,15 +118,14 @@ class WORLD_PT_mist(WorldButtonsPanel): col.prop(world.mist, "intensity", slider=True) col.prop(world.mist, "start") - if wide_ui: - col = split.column() + col = split.column() col.prop(world.mist, "depth") col.prop(world.mist, "height") layout.prop(world.mist, "falloff") -class WORLD_PT_stars(WorldButtonsPanel): +class WORLD_PT_stars(WorldButtonsPanel, bpy.types.Panel): bl_label = "Stars" bl_default_closed = True COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -146,7 +137,6 @@ class WORLD_PT_stars(WorldButtonsPanel): def draw(self, context): layout = self.layout - wide_ui = context.region.width > narrowui world = context.world layout.active = world.stars.use_stars @@ -157,13 +147,12 @@ class WORLD_PT_stars(WorldButtonsPanel): col.prop(world.stars, "size") col.prop(world.stars, "color_randomization", text="Colors") - if wide_ui: - col = split.column() + col = split.column() col.prop(world.stars, "min_distance", text="Min. Dist") col.prop(world.stars, "average_separation", text="Separation") -class WORLD_PT_ambient_occlusion(WorldButtonsPanel): +class WORLD_PT_ambient_occlusion(WorldButtonsPanel, bpy.types.Panel): bl_label = "Ambient Occlusion" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -182,7 +171,7 @@ class WORLD_PT_ambient_occlusion(WorldButtonsPanel): split.prop(light, "ao_blend_mode", text="") -class WORLD_PT_environment_lighting(WorldButtonsPanel): +class WORLD_PT_environment_lighting(WorldButtonsPanel, bpy.types.Panel): bl_label = "Environment Lighting" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -201,11 +190,12 @@ class WORLD_PT_environment_lighting(WorldButtonsPanel): split.prop(light, "environment_color", text="") -class WORLD_PT_indirect_lighting(WorldButtonsPanel): +class WORLD_PT_indirect_lighting(WorldButtonsPanel, bpy.types.Panel): bl_label = "Indirect Lighting" COMPAT_ENGINES = {'BLENDER_RENDER'} - def poll(self, context): + @classmethod + def poll(cls, context): light = context.world.lighting return light.gather_method == 'APPROXIMATE' @@ -224,7 +214,7 @@ class WORLD_PT_indirect_lighting(WorldButtonsPanel): split.prop(light, "indirect_bounces", text="Bounces") -class WORLD_PT_gather(WorldButtonsPanel): +class WORLD_PT_gather(WorldButtonsPanel, bpy.types.Panel): bl_label = "Gather" COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -272,30 +262,12 @@ class WORLD_PT_gather(WorldButtonsPanel): col.prop(light, "correction") -classes = [ - WORLD_PT_context_world, - WORLD_PT_preview, - WORLD_PT_world, - WORLD_PT_ambient_occlusion, - WORLD_PT_environment_lighting, - WORLD_PT_indirect_lighting, - WORLD_PT_gather, - WORLD_PT_mist, - WORLD_PT_stars, - - WORLD_PT_custom_props] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/space_console.py b/release/scripts/ui/space_console.py index 512af350a47..feda3a54b41 100644 --- a/release/scripts/ui/space_console.py +++ b/release/scripts/ui/space_console.py @@ -138,7 +138,8 @@ class ConsoleAutocomplete(bpy.types.Operator): bl_idname = "console.autocomplete" bl_label = "Console Autocomplete" - def poll(self, context): + @classmethod + def poll(cls, context): return context.space_data.console_type != 'REPORT' def execute(self, context): @@ -196,31 +197,12 @@ class ConsoleLanguage(bpy.types.Operator): return {'FINISHED'} -classes = [ - CONSOLE_HT_header, - CONSOLE_MT_console, - CONSOLE_MT_report, - CONSOLE_MT_language, - - # Stubs that call the language operators - ConsoleExec, - ConsoleAutocomplete, - ConsoleBanner, - - # Set the language and call the banner - ConsoleLanguage] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/space_dopesheet.py b/release/scripts/ui/space_dopesheet.py index 41917acd997..f7e7ee724d7 100644 --- a/release/scripts/ui/space_dopesheet.py +++ b/release/scripts/ui/space_dopesheet.py @@ -196,25 +196,12 @@ class DOPESHEET_MT_key_transform(bpy.types.Menu): layout.operator("transform.transform", text="Scale").mode = 'TIME_SCALE' -classes = [ - DOPESHEET_HT_header, # header/menu classes - DOPESHEET_MT_view, - DOPESHEET_MT_select, - DOPESHEET_MT_channel, - DOPESHEET_MT_key, - DOPESHEET_MT_key_transform] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/space_filebrowser.py b/release/scripts/ui/space_filebrowser.py index 39bae6ca59b..a67bffc37c5 100644 --- a/release/scripts/ui/space_filebrowser.py +++ b/release/scripts/ui/space_filebrowser.py @@ -65,20 +65,12 @@ class FILEBROWSER_HT_header(bpy.types.Header): row.prop(params, "filter_text", text="") -classes = [ - FILEBROWSER_HT_header] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/space_graph.py b/release/scripts/ui/space_graph.py index 1533b891202..7eb728cc668 100644 --- a/release/scripts/ui/space_graph.py +++ b/release/scripts/ui/space_graph.py @@ -204,25 +204,12 @@ class GRAPH_MT_key_transform(bpy.types.Menu): layout.operator("transform.resize", text="Scale") -classes = [ - GRAPH_HT_header, # header/menu classes - GRAPH_MT_view, - GRAPH_MT_select, - GRAPH_MT_channel, - GRAPH_MT_key, - GRAPH_MT_key_transform] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/space_image.py b/release/scripts/ui/space_image.py index a28ddb90a40..99d41244431 100644 --- a/release/scripts/ui/space_image.py +++ b/release/scripts/ui/space_image.py @@ -19,7 +19,16 @@ # <pep8 compliant> import bpy -narrowui = bpy.context.user_preferences.view.properties_width_check + +class BrushButtonsPanel(): + bl_space_type = 'IMAGE_EDITOR' + bl_region_type = 'UI' + + @classmethod + def poll(cls, context): + sima = context.space_data + toolsettings = context.tool_settings.image_paint + return sima.show_paint and toolsettings.brush class IMAGE_MT_view(bpy.types.Menu): @@ -335,7 +344,8 @@ class IMAGE_PT_image_properties(bpy.types.Panel): bl_region_type = 'UI' bl_label = "Image" - def poll(self, context): + @classmethod + def poll(cls, context): sima = context.space_data return (sima.image) @@ -354,7 +364,8 @@ class IMAGE_PT_game_properties(bpy.types.Panel): bl_region_type = 'UI' bl_label = "Game Properties" - def poll(self, context): + @classmethod + def poll(cls, context): rd = context.scene.render sima = context.space_data return (sima and sima.image) and (rd.engine == 'BLENDER_GAME') @@ -364,7 +375,6 @@ class IMAGE_PT_game_properties(bpy.types.Panel): sima = context.space_data ima = sima.image - wide_ui = context.region.width > narrowui split = layout.split() @@ -385,8 +395,7 @@ class IMAGE_PT_game_properties(bpy.types.Panel): sub.prop(ima, "tiles_x", text="X") sub.prop(ima, "tiles_y", text="Y") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Clamp:") col.prop(ima, "clamp_x", text="X") col.prop(ima, "clamp_y", text="Y") @@ -399,7 +408,8 @@ class IMAGE_PT_view_histogram(bpy.types.Panel): bl_region_type = 'PREVIEW' bl_label = "Histogram" - def poll(self, context): + @classmethod + def poll(cls, context): sima = context.space_data return (sima and sima.image) @@ -417,7 +427,8 @@ class IMAGE_PT_view_waveform(bpy.types.Panel): bl_region_type = 'PREVIEW' bl_label = "Waveform" - def poll(self, context): + @classmethod + def poll(cls, context): sima = context.space_data return (sima and sima.image) @@ -436,7 +447,8 @@ class IMAGE_PT_view_vectorscope(bpy.types.Panel): bl_region_type = 'PREVIEW' bl_label = "Vectorscope" - def poll(self, context): + @classmethod + def poll(cls, context): sima = context.space_data return (sima and sima.image) @@ -453,7 +465,8 @@ class IMAGE_PT_sample_line(bpy.types.Panel): bl_region_type = 'PREVIEW' bl_label = "Sample Line" - def poll(self, context): + @classmethod + def poll(cls, context): sima = context.space_data return (sima and sima.image) @@ -470,7 +483,8 @@ class IMAGE_PT_scope_sample(bpy.types.Panel): bl_region_type = 'PREVIEW' bl_label = "Scope Samples" - def poll(self, context): + @classmethod + def poll(cls, context): sima = context.space_data return sima @@ -490,7 +504,8 @@ class IMAGE_PT_view_properties(bpy.types.Panel): bl_region_type = 'UI' bl_label = "Display" - def poll(self, context): + @classmethod + def poll(cls, context): sima = context.space_data return (sima and (sima.image or sima.show_uvedit)) @@ -501,7 +516,6 @@ class IMAGE_PT_view_properties(bpy.types.Panel): ima = sima.image show_uvedit = sima.show_uvedit uvedit = sima.uv_editor - wide_ui = context.region.width > narrowui split = layout.split() @@ -509,8 +523,7 @@ class IMAGE_PT_view_properties(bpy.types.Panel): if ima: col.prop(ima, "display_aspect", text="Aspect Ratio") - if wide_ui: - col = split.column() + col = split.column() col.label(text="Coordinates:") col.prop(sima, "draw_repeated", text="Repeat") if show_uvedit: @@ -528,10 +541,7 @@ class IMAGE_PT_view_properties(bpy.types.Panel): col = layout.column() col.label(text="UVs:") row = col.row() - if wide_ui: - row.prop(uvedit, "edge_draw_type", expand=True) - else: - row.prop(uvedit, "edge_draw_type", text="") + row.prop(uvedit, "edge_draw_type", expand=True) split = layout.split() col = split.column() @@ -540,8 +550,7 @@ class IMAGE_PT_view_properties(bpy.types.Panel): #col.prop(uvedit, "draw_edges") #col.prop(uvedit, "draw_faces") - if wide_ui: - col = split.column() + col = split.column() col.prop(uvedit, "draw_stretch", text="Stretch") sub = col.column() sub.active = uvedit.draw_stretch @@ -553,7 +562,8 @@ class IMAGE_PT_paint(bpy.types.Panel): bl_region_type = 'UI' bl_label = "Paint" - def poll(self, context): + @classmethod + def poll(cls, context): sima = context.space_data return sima.show_paint @@ -592,17 +602,10 @@ class IMAGE_PT_paint(bpy.types.Panel): col.prop(brush, "clone_alpha", text="Alpha") -class IMAGE_PT_tools_brush_texture(bpy.types.Panel): - bl_space_type = 'IMAGE_EDITOR' - bl_region_type = 'UI' +class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, bpy.types.Panel): bl_label = "Texture" bl_default_closed = True - def poll(self, context): - sima = context.space_data - toolsettings = context.tool_settings.image_paint - return sima.show_paint and toolsettings.brush - def draw(self, context): layout = self.layout @@ -616,17 +619,10 @@ class IMAGE_PT_tools_brush_texture(bpy.types.Panel): col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8) -class IMAGE_PT_paint_stroke(bpy.types.Panel): - bl_space_type = 'IMAGE_EDITOR' - bl_region_type = 'UI' +class IMAGE_PT_paint_stroke(BrushButtonsPanel, bpy.types.Panel): bl_label = "Paint Stroke" bl_default_closed = True - def poll(self, context): - sima = context.space_data - toolsettings = context.tool_settings.image_paint - return sima.show_paint and toolsettings.brush - def draw(self, context): layout = self.layout @@ -647,17 +643,10 @@ class IMAGE_PT_paint_stroke(bpy.types.Panel): layout.prop(brush, "use_wrap") -class IMAGE_PT_paint_curve(bpy.types.Panel): - bl_space_type = 'IMAGE_EDITOR' - bl_region_type = 'UI' +class IMAGE_PT_paint_curve(BrushButtonsPanel, bpy.types.Panel): bl_label = "Paint Curve" bl_default_closed = True - def poll(self, context): - sima = context.space_data - toolsettings = context.tool_settings.image_paint - return sima.show_paint and toolsettings.brush - def draw(self, context): layout = self.layout @@ -674,41 +663,12 @@ class IMAGE_PT_paint_curve(bpy.types.Panel): row.operator("brush.curve_preset", icon="LINCURVE", text="").shape = 'LINE' row.operator("brush.curve_preset", icon="NOCURVE", text="").shape = 'MAX' -classes = [ - IMAGE_MT_view, - IMAGE_MT_select, - IMAGE_MT_image, - IMAGE_MT_uvs_showhide, - IMAGE_MT_uvs_transform, - IMAGE_MT_uvs_snap, - IMAGE_MT_uvs_mirror, - IMAGE_MT_uvs_weldalign, - IMAGE_MT_uvs, - IMAGE_HT_header, - IMAGE_PT_image_properties, - IMAGE_PT_paint, - IMAGE_PT_tools_brush_texture, - IMAGE_PT_paint_stroke, - IMAGE_PT_paint_curve, - IMAGE_PT_game_properties, - IMAGE_PT_view_properties, - IMAGE_PT_view_histogram, - IMAGE_PT_view_waveform, - IMAGE_PT_view_vectorscope, - IMAGE_PT_sample_line, - IMAGE_PT_scope_sample] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/space_info.py b/release/scripts/ui/space_info.py index 25f4e8b2097..618cd3c51c9 100644 --- a/release/scripts/ui/space_info.py +++ b/release/scripts/ui/space_info.py @@ -354,34 +354,13 @@ class HELP_OT_operator_cheat_sheet(bpy.types.Operator): return {'FINISHED'} -classes = [ - INFO_HT_header, - INFO_MT_file, - INFO_MT_file_import, - INFO_MT_file_export, - INFO_MT_file_external_data, - INFO_MT_add, - INFO_MT_mesh_add, - INFO_MT_curve_add, - INFO_MT_surface_add, - INFO_MT_armature_add, - INFO_MT_game, - INFO_MT_render, - INFO_MT_help, - - HELP_OT_operator_cheat_sheet] - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/space_logic.py b/release/scripts/ui/space_logic.py index 6003c4d4bd7..f2d99c6e447 100644 --- a/release/scripts/ui/space_logic.py +++ b/release/scripts/ui/space_logic.py @@ -25,7 +25,8 @@ class LOGIC_PT_properties(bpy.types.Panel): bl_region_type = 'UI' bl_label = "Properties" - def poll(self, context): + @classmethod + def poll(cls, context): ob = context.active_object return ob and ob.game @@ -88,24 +89,12 @@ class LOGIC_MT_view(bpy.types.Menu): layout.operator("logic.properties", icon='MENU_PANEL') -classes = [ - LOGIC_HT_header, - LOGIC_MT_view, - - LOGIC_PT_properties, - LOGIC_MT_logicbricks_add] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/space_nla.py b/release/scripts/ui/space_nla.py index 0eb342d4b15..1141a640534 100644 --- a/release/scripts/ui/space_nla.py +++ b/release/scripts/ui/space_nla.py @@ -159,25 +159,12 @@ class NLA_MT_edit_transform(bpy.types.Menu): layout.operator("transform.resize", text="Scale") -classes = [ - NLA_HT_header, # header/menu classes - NLA_MT_view, - NLA_MT_select, - NLA_MT_edit, - NLA_MT_add, - NLA_MT_edit_transform] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/space_node.py b/release/scripts/ui/space_node.py index 21b2ebc5390..0a3cebf5faa 100644 --- a/release/scripts/ui/space_node.py +++ b/release/scripts/ui/space_node.py @@ -160,23 +160,12 @@ class NODE_MT_node(bpy.types.Menu): layout.operator("node.show_cyclic_dependencies") -classes = [ - NODE_HT_header, - NODE_MT_view, - NODE_MT_select, - NODE_MT_node] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/space_outliner.py b/release/scripts/ui/space_outliner.py index ec3c430feaa..6b2743027ba 100644 --- a/release/scripts/ui/space_outliner.py +++ b/release/scripts/ui/space_outliner.py @@ -117,23 +117,12 @@ class OUTLINER_MT_edit_datablocks(bpy.types.Menu): col.operator("outliner.drivers_delete_selected") -classes = [ - OUTLINER_HT_header, - OUTLINER_MT_view, - OUTLINER_MT_search, - OUTLINER_MT_edit_datablocks] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/space_sequencer.py b/release/scripts/ui/space_sequencer.py index adf80635bc1..3a828bfb6d0 100644 --- a/release/scripts/ui/space_sequencer.py +++ b/release/scripts/ui/space_sequencer.py @@ -312,29 +312,33 @@ class SEQUENCER_MT_strip(bpy.types.Menu): layout.operator("sequencer.swap_data") -class SequencerButtonsPanel(bpy.types.Panel): +class SequencerButtonsPanel(): bl_space_type = 'SEQUENCE_EDITOR' bl_region_type = 'UI' - def has_sequencer(self, context): + @staticmethod + def has_sequencer(context): return (context.space_data.view_type == 'SEQUENCER') or (context.space_data.view_type == 'SEQUENCER_PREVIEW') - def poll(self, context): - return self.has_sequencer(context) and (act_strip(context) is not None) + @classmethod + def poll(cls, context): + return cls.has_sequencer(context) and (act_strip(context) is not None) -class SequencerButtonsPanel_Output(bpy.types.Panel): +class SequencerButtonsPanel_Output(): bl_space_type = 'SEQUENCE_EDITOR' bl_region_type = 'UI' - def has_preview(self, context): + @staticmethod + def has_preview(context): return (context.space_data.view_type == 'PREVIEW') or (context.space_data.view_type == 'SEQUENCER_PREVIEW') - def poll(self, context): - return self.has_preview(context) + @classmethod + def poll(cls, context): + return cls.has_preview(context) -class SEQUENCER_PT_edit(SequencerButtonsPanel): +class SEQUENCER_PT_edit(SequencerButtonsPanel, bpy.types.Panel): bl_label = "Edit Strip" def draw(self, context): @@ -381,11 +385,12 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel): col.label(text="Frame Still %d:%d" % (strip.frame_still_start, strip.frame_still_end)) -class SEQUENCER_PT_effect(SequencerButtonsPanel): +class SEQUENCER_PT_effect(SequencerButtonsPanel, bpy.types.Panel): bl_label = "Effect Strip" - def poll(self, context): - if not self.has_sequencer(context): + @classmethod + def poll(cls, context): + if not cls.has_sequencer(context): return False strip = act_strip(context) @@ -510,11 +515,12 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel): col.prop(strip, "rotation_start", text="Rotation") -class SEQUENCER_PT_input(SequencerButtonsPanel): +class SEQUENCER_PT_input(SequencerButtonsPanel, bpy.types.Panel): bl_label = "Strip Input" - def poll(self, context): - if not self.has_sequencer(context): + @classmethod + def poll(cls, context): + if not cls.has_sequencer(context): return False strip = act_strip(context) @@ -528,15 +534,41 @@ class SEQUENCER_PT_input(SequencerButtonsPanel): 'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'MULTICAM', 'SPEED') - def draw_filename(self, context): - pass - def draw(self, context): layout = self.layout strip = act_strip(context) - self.draw_filename(context) + seq_type = strip.type + + # draw a filename if we have one + if seq_type == 'IMAGE': + split = layout.split(percentage=0.2) + col = split.column() + col.label(text="Path:") + col = split.column() + col.prop(strip, "directory", text="") + + # Current element for the filename + + elem = strip.getStripElem(context.scene.frame_current) + if elem: + split = layout.split(percentage=0.2) + col = split.column() + col.label(text="File:") + col = split.column() + col.prop(elem, "filename", text="") # strip.elements[0] could be a fallback + + elif seq_type == 'MOVIE': + split = layout.split(percentage=0.2) + col = split.column() + col.label(text="Path:") + col = split.column() + col.prop(strip, "filepath", text="") + col.prop(strip, "mpeg_preseek", text="MPEG Preseek") + # TODO, sound??? + # end drawing filename + layout.prop(strip, "use_translation", text="Image Offset:") if strip.use_translation: @@ -554,93 +586,16 @@ class SEQUENCER_PT_input(SequencerButtonsPanel): col = layout.column(align=True) col.label(text="Trim Duration:") - col.prop(strip, "animation_start_offset", text="Start") - col.prop(strip, "animation_end_offset", text="End") - - -class SEQUENCER_PT_input_movie(SEQUENCER_PT_input): - bl_label = "Strip Input" - - def poll(self, context): - if not self.has_sequencer(context): - return False - - strip = act_strip(context) - if not strip: - return False - - return strip.type == 'MOVIE' - - def draw_filename(self, context): - layout = self.layout - - strip = act_strip(context) - - split = layout.split(percentage=0.2) - col = split.column() - col.label(text="Path:") - col = split.column() - col.prop(strip, "filepath", text="") - col.prop(strip, "mpeg_preseek", text="MPEG Preseek") - - -class SEQUENCER_PT_input_image(SEQUENCER_PT_input): - bl_label = "Strip Input" - - def poll(self, context): - if not self.has_sequencer(context): - return False - - strip = act_strip(context) - if not strip: - return False - - return strip.type == 'IMAGE' + col.prop(strip, "frame_offset_start", text="Start") + col.prop(strip, "frame_offset_end", text="End") - def draw_filename(self, context): - layout = self.layout - - strip = act_strip(context) - - split = layout.split(percentage=0.2) - col = split.column() - col.label(text="Path:") - col = split.column() - col.prop(strip, "directory", text="") - # Current element for the filename - - elem = strip.getStripElem(context.scene.frame_current) - if elem: - split = layout.split(percentage=0.2) - col = split.column() - col.label(text="File:") - col = split.column() - col.prop(elem, "filename", text="") # strip.elements[0] could be a fallback - - -class SEQUENCER_PT_input_secondary(SEQUENCER_PT_input): - bl_label = "Strip Input" - - def poll(self, context): - if not self.has_sequencer(context): - return False - - strip = act_strip(context) - if not strip: - return False - - return strip.type in ('SCENE', 'META') - - def draw_filename(self, context): - pass - - -class SEQUENCER_PT_sound(SequencerButtonsPanel): +class SEQUENCER_PT_sound(SequencerButtonsPanel, bpy.types.Panel): bl_label = "Sound" - def poll(self, context): - if not self.has_sequencer(context): + @classmethod + def poll(cls, context): + if not cls.has_sequencer(context): return False strip = act_strip(context) @@ -676,11 +631,12 @@ class SEQUENCER_PT_sound(SequencerButtonsPanel): col.prop(strip, "animation_end_offset", text="End") -class SEQUENCER_PT_scene(SequencerButtonsPanel): +class SEQUENCER_PT_scene(SequencerButtonsPanel, bpy.types.Panel): bl_label = "Scene" - def poll(self, context): - if not self.has_sequencer(context): + @classmethod + def poll(cls, context): + if not cls.has_sequencer(context): return False strip = act_strip(context) @@ -700,11 +656,12 @@ class SEQUENCER_PT_scene(SequencerButtonsPanel): layout.template_ID(strip, "scene_camera") -class SEQUENCER_PT_filter(SequencerButtonsPanel): +class SEQUENCER_PT_filter(SequencerButtonsPanel, bpy.types.Panel): bl_label = "Filter" - def poll(self, context): - if not self.has_sequencer(context): + @classmethod + def poll(cls, context): + if not cls.has_sequencer(context): return False strip = act_strip(context) @@ -761,11 +718,12 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel): col.prop(strip.color_balance, "inverse_gain", text="Inverse") -class SEQUENCER_PT_proxy(SequencerButtonsPanel): +class SEQUENCER_PT_proxy(SequencerButtonsPanel, bpy.types.Panel): bl_label = "Proxy" - def poll(self, context): - if not self.has_sequencer(context): + @classmethod + def poll(cls, context): + if not cls.has_sequencer(context): return False strip = act_strip(context) @@ -794,7 +752,7 @@ class SEQUENCER_PT_proxy(SequencerButtonsPanel): flow.prop(strip.proxy, "filepath") -class SEQUENCER_PT_preview(SequencerButtonsPanel_Output): +class SEQUENCER_PT_preview(SequencerButtonsPanel_Output, bpy.types.Panel): bl_label = "Scene Preview/Render" bl_space_type = 'SEQUENCE_EDITOR' bl_region_type = 'UI' @@ -818,7 +776,7 @@ class SEQUENCER_PT_preview(SequencerButtonsPanel_Output): ''' -class SEQUENCER_PT_view(SequencerButtonsPanel_Output): +class SEQUENCER_PT_view(SequencerButtonsPanel_Output, bpy.types.Panel): bl_label = "View Settings" def draw(self, context): @@ -834,40 +792,12 @@ class SEQUENCER_PT_view(SequencerButtonsPanel_Output): col.prop(st, "separate_color_preview") col.prop(st, "proxy_render_size") -classes = [ - SEQUENCER_HT_header, # header/menu classes - SEQUENCER_MT_view, - SEQUENCER_MT_view_toggle, - SEQUENCER_MT_select, - SEQUENCER_MT_marker, - SEQUENCER_MT_add, - SEQUENCER_MT_add_effect, - SEQUENCER_MT_strip, - - SEQUENCER_PT_edit, # sequencer panels - SEQUENCER_PT_effect, - SEQUENCER_PT_input_movie, - SEQUENCER_PT_input_image, - SEQUENCER_PT_input_secondary, - SEQUENCER_PT_sound, - SEQUENCER_PT_scene, - SEQUENCER_PT_filter, - SEQUENCER_PT_proxy, - - SEQUENCER_PT_preview, - SEQUENCER_PT_view] # view panels - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/space_text.py b/release/scripts/ui/space_text.py index 552621d87c6..71ab6540132 100644 --- a/release/scripts/ui/space_text.py +++ b/release/scripts/ui/space_text.py @@ -140,6 +140,11 @@ class TEXT_MT_view(bpy.types.Menu): layout.operator("screen.area_dupli") layout.operator("screen.screen_full_area") + + layout.separator() + + layout.operator("text.move", text="Top of File").type = 'FILE_TOP' + layout.operator("text.move", text="Bottom of File").type = 'FILE_BOTTOM' class TEXT_MT_text(bpy.types.Menu): @@ -188,16 +193,6 @@ class TEXT_MT_templates(bpy.types.Menu): self.path_menu(bpy.utils.script_paths("templates"), "text.open", {"internal": True}) -class TEXT_MT_edit_view(bpy.types.Menu): - bl_label = "View" - - def draw(self, context): - layout = self.layout - - layout.operator("text.move", text="Top of File").type = 'FILE_TOP' - layout.operator("text.move", text="Bottom of File").type = 'FILE_BOTTOM' - - class TEXT_MT_edit_select(bpy.types.Menu): bl_label = "Select" @@ -251,7 +246,8 @@ class TEXT_MT_edit_to3d(bpy.types.Menu): class TEXT_MT_edit(bpy.types.Menu): bl_label = "Edit" - def poll(self, context): + @classmethod + def poll(cls, context): return (context.space_data.text) def draw(self, context): @@ -268,7 +264,6 @@ class TEXT_MT_edit(bpy.types.Menu): layout.separator() - layout.menu("TEXT_MT_edit_view") layout.menu("TEXT_MT_edit_select") layout.menu("TEXT_MT_edit_markers") @@ -297,33 +292,12 @@ class TEXT_MT_toolbox(bpy.types.Menu): layout.operator("text.run_script") - -classes = [ - TEXT_HT_header, - TEXT_PT_properties, - TEXT_PT_find, - TEXT_MT_view, - TEXT_MT_text, - TEXT_MT_templates, - TEXT_MT_format, - TEXT_MT_edit, - TEXT_MT_edit_view, - TEXT_MT_edit_select, - TEXT_MT_edit_markers, - TEXT_MT_edit_to3d, - TEXT_MT_toolbox] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/space_time.py b/release/scripts/ui/space_time.py index 8c24dbc2d9c..3825d774f1e 100644 --- a/release/scripts/ui/space_time.py +++ b/release/scripts/ui/space_time.py @@ -192,25 +192,12 @@ class TIME_MT_autokey(bpy.types.Menu): layout.prop_enum(tools, "autokey_mode", 'ADD_REPLACE_KEYS') layout.prop_enum(tools, "autokey_mode", 'REPLACE_KEYS') -classes = [ - TIME_HT_header, - TIME_MT_view, - TIME_MT_cache, - TIME_MT_frame, - TIME_MT_autokey, - TIME_MT_playback] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py index c083a62a98e..1bd83e11b71 100644 --- a/release/scripts/ui/space_userpref.py +++ b/release/scripts/ui/space_userpref.py @@ -142,7 +142,8 @@ class USERPREF_PT_interface(bpy.types.Panel): bl_region_type = 'WINDOW' bl_show_header = False - def poll(self, context): + @classmethod + def poll(cls, context): userpref = context.user_preferences return (userpref.active_section == 'INTERFACE') @@ -175,12 +176,6 @@ class USERPREF_PT_interface(bpy.types.Panel): sub.prop(view, "mini_axis_brightness", text="Brightness") col.separator() - col.separator() - col.separator() - - col.label(text="Properties Window:") - col.prop(view, "properties_width_check") - row.separator() row.separator() @@ -249,7 +244,8 @@ class USERPREF_PT_edit(bpy.types.Panel): bl_region_type = 'WINDOW' bl_show_header = False - def poll(self, context): + @classmethod + def poll(cls, context): userpref = context.user_preferences return (userpref.active_section == 'EDITING') @@ -363,7 +359,8 @@ class USERPREF_PT_system(bpy.types.Panel): bl_region_type = 'WINDOW' bl_show_header = False - def poll(self, context): + @classmethod + def poll(cls, context): userpref = context.user_preferences return (userpref.active_section == 'SYSTEM') @@ -527,7 +524,8 @@ class USERPREF_PT_theme(bpy.types.Panel): for i, attr in enumerate(props_ls): colsub_pair[i % 2].row().prop(themedata, attr) - def poll(self, context): + @classmethod + def poll(cls, context): userpref = context.user_preferences return (userpref.active_section == 'THEMES') @@ -659,7 +657,8 @@ class USERPREF_PT_file(bpy.types.Panel): bl_region_type = 'WINDOW' bl_show_header = False - def poll(self, context): + @classmethod + def poll(cls, context): userpref = context.user_preferences return (userpref.active_section == 'FILES') @@ -730,7 +729,8 @@ class USERPREF_PT_input(InputKeyMapPanel): bl_space_type = 'USER_PREFERENCES' bl_label = "Input" - def poll(self, context): + @classmethod + def poll(cls, context): userpref = context.user_preferences return (userpref.active_section == 'INPUT') @@ -821,33 +821,112 @@ class USERPREF_PT_addons(bpy.types.Panel): bl_label = "Addons" bl_region_type = 'WINDOW' bl_show_header = False + + _addons_fake_modules = {} - def poll(self, context): + @classmethod + def poll(cls, context): userpref = context.user_preferences return (userpref.active_section == 'ADDONS') @staticmethod + def module_get(mod_name): + return USERPREF_PT_addons._addons_fake_modules[mod_name] + + @staticmethod def _addon_list(): + import os import sys import time modules = [] loaded_modules = set() paths = bpy.utils.script_paths("addons") + # if folder addons_contrib/ exists, scripts in there will be loaded + paths += bpy.utils.script_paths("addons_contrib") if bpy.app.debug: t_main = time.time() - # sys.path.insert(0, None) - for path in paths: - # sys.path[0] = path - modules.extend(bpy.utils.modules_from_path(path, loaded_modules)) + # fake module importing + def fake_module(mod_name, mod_path, speedy=True): + if bpy.app.debug: + print("fake_module", mod_name, mod_path) + import ast + ModuleType = type(ast) + if speedy: + lines = [] + line_iter = iter(open(mod_path, "r")) + l = "" + while not l.startswith("bl_addon_info"): + l = line_iter.readline() + if len(l) == 0: + break + while l.rstrip(): + lines.append(l) + l = line_iter.readline() + del line_iter + data = "".join(lines) + + else: + data = open(mod_path, "r").read() + + ast_data = ast.parse(data, filename=mod_path) + body_info = None + for body in ast_data.body: + if body.__class__ == ast.Assign: + if len(body.targets) == 1: + if getattr(body.targets[0], "id", "") == "bl_addon_info": + body_info = body + break + + if body_info: + mod = ModuleType(mod_name) + mod.bl_addon_info = ast.literal_eval(body.value) + mod.__file__ = mod_path + mod.__time__ = os.path.getmtime(mod_path) + return mod + else: + return None + + modules_stale = set(USERPREF_PT_addons._addons_fake_modules.keys()) - if bpy.app.debug: - print("Addon Script Load Time %.4f" % (time.time() - t_main)) + for path in paths: + for f in sorted(os.listdir(path)): + if f.endswith(".py"): + mod_name = f[0:-3] + mod_path = os.path.join(path, f) + elif ("." not in f) and (os.path.isfile(os.path.join(path, f, "__init__.py"))): + mod_name = f + mod_path = os.path.join(path, f, "__init__.py") + else: + mod_name = "" + mod_path = "" + + if mod_name: + if mod_name in modules_stale: + modules_stale.remove(mod_name) + mod = USERPREF_PT_addons._addons_fake_modules.get(mod_name) + if mod: + if mod.__time__ != os.path.getmtime(mod_path): + print("Reloading", mod_name) + del USERPREF_PT_addons._addons_fake_modules[mod_name] + mod = None + + if mod is None: + mod = fake_module(mod_name, mod_path) + if mod: + USERPREF_PT_addons._addons_fake_modules[mod_name] = mod + + + # just incase we get stale modules, not likely + for mod_stale in modules_stale: + del USERPREF_PT_addons._addons_fake_modules[mod_stale] + del modules_stale - # del sys.path[0] - return modules + mod_list = list(USERPREF_PT_addons._addons_fake_modules.values()) + mod_list.sort(key=lambda mod: (mod.bl_addon_info['category'], mod.bl_addon_info['name'])) + return mod_list def draw(self, context): layout = self.layout @@ -1001,8 +1080,13 @@ class WM_OT_addon_enable(bpy.types.Operator): def execute(self, context): module_name = self.properties.module + # note, this still gets added to _bpy_types.TypeMap + import bpy_types as _bpy_types + _bpy_types._register_immediate = False + try: mod = __import__(module_name) + _bpy_types._register_module(module_name) mod.register() except: import traceback @@ -1017,7 +1101,9 @@ class WM_OT_addon_enable(bpy.types.Operator): if info.get("blender", (0, 0, 0)) > bpy.app.version: self.report("WARNING','This script was written for a newer version of Blender and might not function (correctly).\nThe script is enabled though.") - + + _bpy_types._register_immediate = True + return {'FINISHED'} @@ -1029,13 +1115,15 @@ class WM_OT_addon_disable(bpy.types.Operator): module = StringProperty(name="Module", description="Module name of the addon to disable") def execute(self, context): - import traceback + import bpy_types as _bpy_types module_name = self.properties.module try: mod = __import__(module_name) + _bpy_types._unregister_module(module_name, free=False) # dont free because we may want to enable again. mod.unregister() except: + import traceback traceback.print_exc() addons = context.user_preferences.addons @@ -1123,7 +1211,8 @@ class WM_OT_addon_expand(bpy.types.Operator): # unlikely to fail, module should have already been imported try: - mod = __import__(module_name) + # mod = __import__(module_name) + mod = USERPREF_PT_addons.module_get(module_name) except: import traceback traceback.print_exc() @@ -1134,36 +1223,11 @@ class WM_OT_addon_expand(bpy.types.Operator): return {'FINISHED'} -classes = [ - USERPREF_HT_header, - USERPREF_PT_tabs, - USERPREF_PT_interface, - USERPREF_PT_theme, - USERPREF_PT_edit, - USERPREF_PT_system, - USERPREF_PT_file, - USERPREF_PT_input, - USERPREF_PT_addons, - - USERPREF_MT_interaction_presets, - USERPREF_MT_splash, - - WM_OT_addon_enable, - WM_OT_addon_disable, - WM_OT_addon_install, - WM_OT_addon_expand] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) - + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/space_userpref_keymap.py b/release/scripts/ui/space_userpref_keymap.py index c93b24d5cb2..9a482b89652 100644 --- a/release/scripts/ui/space_userpref_keymap.py +++ b/release/scripts/ui/space_userpref_keymap.py @@ -763,7 +763,8 @@ class WM_OT_keyconfig_remove(bpy.types.Operator): bl_idname = "wm.keyconfig_remove" bl_label = "Remove Key Config" - def poll(self, context): + @classmethod + def poll(cls, context): wm = context.manager return wm.active_keyconfig.user_defined @@ -784,29 +785,11 @@ class WM_OT_keyconfig_remove(bpy.types.Operator): wm.remove_keyconfig(keyconfig) return {'FINISHED'} - -classes = [ - WM_OT_keyconfig_export, - WM_OT_keyconfig_import, - WM_OT_keyconfig_test, - WM_OT_keyconfig_remove, - WM_OT_keymap_edit, - WM_OT_keymap_restore, - WM_OT_keyitem_add, - WM_OT_keyitem_remove, - WM_OT_keyitem_restore] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) - + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index 7b59b00dc56..a3e945f460a 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -75,11 +75,16 @@ class VIEW3D_HT_header(bpy.types.Header): row.prop(view, "occlude_geometry", text="") # Proportional editing - if obj.mode in ('OBJECT', 'EDIT', 'PARTICLE_EDIT'): + if obj.mode in ('EDIT', 'PARTICLE_EDIT'): row = layout.row(align=True) row.prop(toolsettings, "proportional_editing", text="", icon_only=True) if toolsettings.proportional_editing != 'DISABLED': row.prop(toolsettings, "proportional_editing_falloff", text="", icon_only=True) + elif obj.mode == 'OBJECT': + row = layout.row(align=True) + row.prop(toolsettings, "proportional_editing_objects", text="", icon_only=True) + if toolsettings.proportional_editing_objects: + row.prop(toolsettings, "proportional_editing_falloff", text="", icon_only=True) # Snap row = layout.row(align=True) @@ -114,7 +119,7 @@ class VIEW3D_HT_header(bpy.types.Header): # ********** Utilities ********** -class VIEW3D_MT_showhide(bpy.types.Menu): +class ShowHideMenu(): bl_label = "Show/Hide" _operator_name = "" @@ -709,7 +714,8 @@ class VIEW3D_MT_object_clear(bpy.types.Menu): class VIEW3D_MT_object_specials(bpy.types.Menu): bl_label = "Specials" - def poll(self, context): + @classmethod + def poll(cls, context): # add more special types return context.object @@ -1025,7 +1031,7 @@ class VIEW3D_MT_sculpt(bpy.types.Menu): layout.prop(brush, "use_anchor") if sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'): - layout.prop(brush, "direction") + layout.prop_menu_enum(brush, "direction") if sculpt_tool == 'LAYER': layout.prop(brush, "use_persistent") @@ -1086,7 +1092,7 @@ class VIEW3D_MT_particle_specials(bpy.types.Menu): layout.operator("particle.remove_doubles") -class VIEW3D_MT_particle_showhide(VIEW3D_MT_showhide): +class VIEW3D_MT_particle_showhide(ShowHideMenu, bpy.types.Menu): _operator_name = "particle" # ********** Pose Menu ********** @@ -1236,7 +1242,7 @@ class VIEW3D_MT_pose_constraints(bpy.types.Menu): layout.operator("pose.constraints_clear") -class VIEW3D_MT_pose_showhide(VIEW3D_MT_showhide): +class VIEW3D_MT_pose_showhide(ShowHideMenu, bpy.types.Menu): _operator_name = "pose" @@ -1602,7 +1608,7 @@ class VIEW3D_MT_edit_mesh_normals(bpy.types.Menu): layout.operator("mesh.flip_normals") -class VIEW3D_MT_edit_mesh_showhide(VIEW3D_MT_showhide): +class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, bpy.types.Menu): _operator_name = "mesh" # Edit Curve @@ -1694,7 +1700,7 @@ class VIEW3D_MT_edit_curve_specials(bpy.types.Menu): layout.operator("curve.smooth_radius") -class VIEW3D_MT_edit_curve_showhide(VIEW3D_MT_showhide): +class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, bpy.types.Menu): _operator_name = "curve" @@ -1934,7 +1940,8 @@ class VIEW3D_PT_view3d_properties(bpy.types.Panel): bl_region_type = 'UI' bl_label = "View" - def poll(self, context): + @classmethod + def poll(cls, context): view = context.space_data return (view) @@ -1970,7 +1977,8 @@ class VIEW3D_PT_view3d_name(bpy.types.Panel): bl_region_type = 'UI' bl_label = "Item" - def poll(self, context): + @classmethod + def poll(cls, context): return (context.space_data and context.active_object) def draw(self, context): @@ -1995,7 +2003,8 @@ class VIEW3D_PT_view3d_display(bpy.types.Panel): bl_label = "Display" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): view = context.space_data return (view) @@ -2062,7 +2071,8 @@ class VIEW3D_PT_view3d_meshdisplay(bpy.types.Panel): bl_region_type = 'UI' bl_label = "Mesh Display" - def poll(self, context): + @classmethod + def poll(cls, context): # The active object check is needed because of localmode return (context.active_object and (context.mode == 'EDIT_MESH')) @@ -2098,7 +2108,8 @@ class VIEW3D_PT_view3d_curvedisplay(bpy.types.Panel): bl_region_type = 'UI' bl_label = "Curve Display" - def poll(self, context): + @classmethod + def poll(cls, context): editmesh = context.mode == 'EDIT_CURVE' return (editmesh) @@ -2120,7 +2131,8 @@ class VIEW3D_PT_background_image(bpy.types.Panel): bl_label = "Background Images" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): view = context.space_data # bg = context.space_data.background_image return (view) @@ -2169,7 +2181,8 @@ class VIEW3D_PT_transform_orientations(bpy.types.Panel): bl_label = "Transform Orientations" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): view = context.space_data return (view) @@ -2196,7 +2209,8 @@ class VIEW3D_PT_etch_a_ton(bpy.types.Panel): bl_label = "Skeleton Sketching" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): scene = context.space_data ob = context.active_object return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT' @@ -2239,7 +2253,7 @@ class VIEW3D_PT_context_properties(bpy.types.Panel): bl_label = "Properties" bl_default_closed = True - def _active_context_member(self, context): + def _active_context_member(context): obj = context.object if obj: mode = obj.mode @@ -2252,8 +2266,9 @@ class VIEW3D_PT_context_properties(bpy.types.Panel): return "" - def poll(self, context): - member = self._active_context_member(context) + @classmethod + def poll(cls, context): + member = cls._active_context_member(context) if member: context_member = getattr(context, member) return context_member and context_member.keys() @@ -2263,129 +2278,19 @@ class VIEW3D_PT_context_properties(bpy.types.Panel): def draw(self, context): import rna_prop_ui # reload(rna_prop_ui) - member = self._active_context_member(context) + member = __class__._active_context_member(context) if member: # Draw with no edit button rna_prop_ui.draw(self.layout, context, member, False) -classes = [ - VIEW3D_OT_edit_mesh_extrude_move, # detects constraints setup and extrude region - VIEW3D_OT_edit_mesh_extrude_individual_move, - - VIEW3D_HT_header, # Header - - VIEW3D_MT_view, #View Menus - VIEW3D_MT_view_navigation, - VIEW3D_MT_view_align, - VIEW3D_MT_view_align_selected, - VIEW3D_MT_view_cameras, - - VIEW3D_MT_select_object, # Select Menus - VIEW3D_MT_select_pose, - VIEW3D_MT_select_particle, - VIEW3D_MT_select_edit_mesh, - VIEW3D_MT_select_edit_curve, - VIEW3D_MT_select_edit_surface, - VIEW3D_MT_select_edit_metaball, - VIEW3D_MT_select_edit_lattice, - VIEW3D_MT_select_edit_armature, - VIEW3D_MT_select_face, # XXX todo - - VIEW3D_MT_transform, # Object/Edit Menus - VIEW3D_MT_mirror, # Object/Edit Menus - VIEW3D_MT_snap, # Object/Edit Menus - VIEW3D_MT_uv_map, # Edit Menus - - VIEW3D_MT_object, # Object Menu - VIEW3D_MT_object_specials, - VIEW3D_MT_object_apply, - VIEW3D_MT_object_clear, - VIEW3D_MT_object_parent, - VIEW3D_MT_object_track, - VIEW3D_MT_object_group, - VIEW3D_MT_object_constraints, - VIEW3D_MT_object_showhide, - VIEW3D_MT_make_single_user, - VIEW3D_MT_make_links, - VIEW3D_MT_object_game_properties, - VIEW3D_MT_object_game_logicbricks, - - VIEW3D_MT_hook, - VIEW3D_MT_vertex_group, - - VIEW3D_MT_sculpt, # Sculpt Menu - VIEW3D_MT_paint_vertex, - VIEW3D_MT_paint_weight, - - VIEW3D_MT_particle, # Particle Menu - VIEW3D_MT_particle_specials, - VIEW3D_MT_particle_showhide, - - VIEW3D_MT_pose, # POSE Menu - VIEW3D_MT_pose_transform, - VIEW3D_MT_pose_pose, - VIEW3D_MT_pose_motion, - VIEW3D_MT_pose_group, - VIEW3D_MT_pose_ik, - VIEW3D_MT_pose_constraints, - VIEW3D_MT_pose_showhide, - VIEW3D_MT_pose_apply, - - VIEW3D_MT_edit_mesh, - VIEW3D_MT_edit_mesh_specials, # Only as a menu for keybindings - VIEW3D_MT_edit_mesh_selection_mode, # Only as a menu for keybindings - VIEW3D_MT_edit_mesh_vertices, - VIEW3D_MT_edit_mesh_edges, - VIEW3D_MT_edit_mesh_faces, - VIEW3D_MT_edit_mesh_normals, - VIEW3D_MT_edit_mesh_showhide, - VIEW3D_MT_edit_mesh_extrude, # use with VIEW3D_OT_edit_mesh_extrude_menu - - VIEW3D_MT_edit_curve, - VIEW3D_MT_edit_curve_ctrlpoints, - VIEW3D_MT_edit_curve_segments, - VIEW3D_MT_edit_curve_specials, - VIEW3D_MT_edit_curve_showhide, - - VIEW3D_MT_edit_surface, - - VIEW3D_MT_edit_text, - VIEW3D_MT_edit_text_chars, - - VIEW3D_MT_edit_meta, - VIEW3D_MT_edit_meta_showhide, - - VIEW3D_MT_edit_lattice, - - VIEW3D_MT_edit_armature, - VIEW3D_MT_edit_armature_parent, - VIEW3D_MT_edit_armature_roll, - - VIEW3D_MT_armature_specials, # Only as a menu for keybindings - - # Panels - VIEW3D_PT_view3d_properties, - VIEW3D_PT_view3d_display, - VIEW3D_PT_view3d_name, - VIEW3D_PT_view3d_meshdisplay, - VIEW3D_PT_view3d_curvedisplay, - VIEW3D_PT_background_image, - VIEW3D_PT_transform_orientations, - VIEW3D_PT_etch_a_ton, - VIEW3D_PT_context_properties] - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": - register()
\ No newline at end of file + register() diff --git a/release/scripts/ui/space_view3d_toolbar.py b/release/scripts/ui/space_view3d_toolbar.py index ebf9f8e5af3..56abbb3cb14 100644 --- a/release/scripts/ui/space_view3d_toolbar.py +++ b/release/scripts/ui/space_view3d_toolbar.py @@ -19,9 +19,8 @@ # <pep8 compliant> import bpy -narrowui = bpy.context.user_preferences.view.properties_width_check -class View3DPanel(bpy.types.Panel): +class View3DPanel(): bl_space_type = 'VIEW_3D' bl_region_type = 'TOOLS' @@ -29,7 +28,7 @@ class View3DPanel(bpy.types.Panel): # ********** default tools for objectmode **************** -class VIEW3D_PT_tools_objectmode(View3DPanel): +class VIEW3D_PT_tools_objectmode(View3DPanel, bpy.types.Panel): bl_context = "objectmode" bl_label = "Object Tools" @@ -79,7 +78,7 @@ class VIEW3D_PT_tools_objectmode(View3DPanel): # ********** default tools for editmode_mesh **************** -class VIEW3D_PT_tools_meshedit(View3DPanel): +class VIEW3D_PT_tools_meshedit(View3DPanel, bpy.types.Panel): bl_context = "mesh_edit" bl_label = "Mesh Tools" @@ -147,7 +146,7 @@ class VIEW3D_PT_tools_meshedit(View3DPanel): row.operator("gpencil.draw", text="Erase").mode = 'ERASER' -class VIEW3D_PT_tools_meshedit_options(View3DPanel): +class VIEW3D_PT_tools_meshedit_options(View3DPanel, bpy.types.Panel): bl_context = "mesh_edit" bl_label = "Mesh Options" @@ -166,7 +165,7 @@ class VIEW3D_PT_tools_meshedit_options(View3DPanel): # ********** default tools for editmode_curve **************** -class VIEW3D_PT_tools_curveedit(View3DPanel): +class VIEW3D_PT_tools_curveedit(View3DPanel, bpy.types.Panel): bl_context = "curve_edit" bl_label = "Curve Tools" @@ -220,7 +219,7 @@ class VIEW3D_PT_tools_curveedit(View3DPanel): # ********** default tools for editmode_surface **************** -class VIEW3D_PT_tools_surfaceedit(View3DPanel): +class VIEW3D_PT_tools_surfaceedit(View3DPanel, bpy.types.Panel): bl_context = "surface_edit" bl_label = "Surface Tools" @@ -260,7 +259,7 @@ class VIEW3D_PT_tools_surfaceedit(View3DPanel): # ********** default tools for editmode_text **************** -class VIEW3D_PT_tools_textedit(View3DPanel): +class VIEW3D_PT_tools_textedit(View3DPanel, bpy.types.Panel): bl_context = "text_edit" bl_label = "Text Tools" @@ -293,7 +292,7 @@ class VIEW3D_PT_tools_textedit(View3DPanel): # ********** default tools for editmode_armature **************** -class VIEW3D_PT_tools_armatureedit(View3DPanel): +class VIEW3D_PT_tools_armatureedit(View3DPanel, bpy.types.Panel): bl_context = "armature_edit" bl_label = "Armature Tools" @@ -330,7 +329,7 @@ class VIEW3D_PT_tools_armatureedit(View3DPanel): row.operator("gpencil.draw", text="Erase").mode = 'ERASER' -class VIEW3D_PT_tools_armatureedit_options(View3DPanel): +class VIEW3D_PT_tools_armatureedit_options(View3DPanel, bpy.types.Panel): bl_context = "armature_edit" bl_label = "Armature Options" @@ -345,7 +344,7 @@ class VIEW3D_PT_tools_armatureedit_options(View3DPanel): # ********** default tools for editmode_mball **************** -class VIEW3D_PT_tools_mballedit(View3DPanel): +class VIEW3D_PT_tools_mballedit(View3DPanel, bpy.types.Panel): bl_context = "mball_edit" bl_label = "Meta Tools" @@ -373,7 +372,7 @@ class VIEW3D_PT_tools_mballedit(View3DPanel): # ********** default tools for editmode_lattice **************** -class VIEW3D_PT_tools_latticeedit(View3DPanel): +class VIEW3D_PT_tools_latticeedit(View3DPanel, bpy.types.Panel): bl_context = "lattice_edit" bl_label = "Lattice Tools" @@ -405,7 +404,7 @@ class VIEW3D_PT_tools_latticeedit(View3DPanel): # ********** default tools for posemode **************** -class VIEW3D_PT_tools_posemode(View3DPanel): +class VIEW3D_PT_tools_posemode(View3DPanel, bpy.types.Panel): bl_context = "posemode" bl_label = "Pose Tools" @@ -453,7 +452,7 @@ class VIEW3D_PT_tools_posemode(View3DPanel): row.operator("gpencil.draw", text="Erase").mode = 'ERASER' -class VIEW3D_PT_tools_posemode_options(View3DPanel): +class VIEW3D_PT_tools_posemode_options(View3DPanel, bpy.types.Panel): bl_context = "posemode" bl_label = "Pose Options" @@ -469,11 +468,12 @@ class VIEW3D_PT_tools_posemode_options(View3DPanel): # ********** default tools for paint modes **************** -class PaintPanel(bpy.types.Panel): +class PaintPanel(): bl_space_type = 'VIEW_3D' bl_region_type = 'TOOLS' - def paint_settings(self, context): + @staticmethod + def paint_settings(context): ts = context.tool_settings if context.sculpt_object: @@ -490,40 +490,22 @@ class PaintPanel(bpy.types.Panel): return False -class VIEW3D_PT_tools_brush(PaintPanel): +class VIEW3D_PT_tools_brush(PaintPanel, bpy.types.Panel): bl_label = "Brush" - def poll(self, context): - return self.paint_settings(context) + @classmethod + def poll(cls, context): + return cls.paint_settings(context) def draw(self, context): layout = self.layout - settings = self.paint_settings(context) + settings = __class__.paint_settings(context) brush = settings.brush if not context.particle_edit_object: col = layout.split().column() - - if context.sculpt_object and context.tool_settings.sculpt: - col.template_ID_preview(settings, "brush", new="brush.add", filter="is_sculpt_brush", rows=3, cols=8) - elif context.texture_paint_object and context.tool_settings.image_paint: - col.template_ID_preview(settings, "brush", new="brush.add", filter="is_imapaint_brush", rows=3, cols=8) - elif context.vertex_paint_object and context.tool_settings.vertex_paint: - col.template_ID_preview(settings, "brush", new="brush.add", filter="is_vpaint_brush", rows=3, cols=8) - elif context.weight_paint_object and context.tool_settings.weight_paint: - col.template_ID_preview(settings, "brush", new="brush.add", filter="is_wpaint_brush", rows=3, cols=8) - else: - row = col.row() - - if context.sculpt_object and brush: - defaultbrushes = 8 - elif context.texture_paint_object and brush: - defaultbrushes = 4 - else: - defaultbrushes = 7 - - row.template_list(settings, "brushes", settings, "active_brush_index", rows=2, maxrows=defaultbrushes) + col.template_ID_preview(settings, "brush", new="brush.add", rows=3, cols=8) # Particle Mode # @@ -735,19 +717,20 @@ class VIEW3D_PT_tools_brush(PaintPanel): #row.prop(brush, "use_jitter_pressure", toggle=True, text="") -class VIEW3D_PT_tools_brush_texture(PaintPanel): +class VIEW3D_PT_tools_brush_texture(PaintPanel, bpy.types.Panel): bl_label = "Texture" bl_default_closed = True - def poll(self, context): - settings = self.paint_settings(context) + @classmethod + def poll(cls, context): + settings = cls.paint_settings(context) return (settings and settings.brush and (context.sculpt_object or context.texture_paint_object)) def draw(self, context): layout = self.layout - settings = self.paint_settings(context) + settings = __class__.paint_settings(context) brush = settings.brush tex_slot = brush.texture_slot @@ -758,7 +741,6 @@ class VIEW3D_PT_tools_brush_texture(PaintPanel): if context.sculpt_object: #XXX duplicated from properties_texture.py - wide_ui = context.region.width > narrowui col.separator() @@ -803,10 +785,7 @@ class VIEW3D_PT_tools_brush_texture(PaintPanel): col = split.column() col.prop(tex_slot, "offset") - if wide_ui: - col = split.column() - else: - col.separator() + col = split.column() col.prop(tex_slot, "size") @@ -837,12 +816,13 @@ class VIEW3D_PT_tools_brush_texture(PaintPanel): col.active = tex_slot.map_mode in ('FIXED', 'TILED') and brush.use_texture_overlay -class VIEW3D_PT_tools_brush_tool(PaintPanel): +class VIEW3D_PT_tools_brush_tool(PaintPanel, bpy.types.Panel): bl_label = "Tool" bl_default_closed = True - def poll(self, context): - settings = self.paint_settings(context) + @classmethod + def poll(cls, context): + settings = cls.paint_settings(context) return (settings and settings.brush and (context.sculpt_object or context.texture_paint_object or context.vertex_paint_object or context.weight_paint_object)) @@ -850,7 +830,7 @@ class VIEW3D_PT_tools_brush_tool(PaintPanel): def draw(self, context): layout = self.layout - settings = self.paint_settings(context) + settings = __class__.paint_settings(context) brush = settings.brush texture_paint = context.texture_paint_object sculpt = context.sculpt_object @@ -865,13 +845,20 @@ class VIEW3D_PT_tools_brush_tool(PaintPanel): elif context.vertex_paint_object or context.weight_paint_object: col.prop(brush, "vertexpaint_tool", expand=False, text="") + row = layout.row(align=True) + row.prop(brush, "use_paint_sculpt", text="", icon='SCULPTMODE_HLT') + row.prop(brush, "use_paint_vertex", text="", icon='VPAINT_HLT') + row.prop(brush, "use_paint_weight", text="", icon='WPAINT_HLT') + row.prop(brush, "use_paint_texture", text="", icon='TPAINT_HLT') + -class VIEW3D_PT_tools_brush_stroke(PaintPanel): +class VIEW3D_PT_tools_brush_stroke(PaintPanel, bpy.types.Panel): bl_label = "Stroke" bl_default_closed = True - def poll(self, context): - settings = self.paint_settings(context) + @classmethod + def poll(cls, context): + settings = cls.paint_settings(context) return (settings and settings.brush and (context.sculpt_object or context.vertex_paint_object or context.weight_paint_object or @@ -880,7 +867,7 @@ class VIEW3D_PT_tools_brush_stroke(PaintPanel): def draw(self, context): layout = self.layout - settings = self.paint_settings(context) + settings = __class__.paint_settings(context) brush = settings.brush texture_paint = context.texture_paint_object @@ -963,12 +950,13 @@ class VIEW3D_PT_tools_brush_stroke(PaintPanel): # row.prop(brush, "use_spacing_pressure", toggle=True, text="") -class VIEW3D_PT_tools_brush_curve(PaintPanel): +class VIEW3D_PT_tools_brush_curve(PaintPanel, bpy.types.Panel): bl_label = "Curve" bl_default_closed = True - def poll(self, context): - settings = self.paint_settings(context) + @classmethod + def poll(cls, context): + settings = cls.paint_settings(context) return (settings and settings.brush and settings.brush.curve) def draw(self, context): @@ -987,21 +975,22 @@ class VIEW3D_PT_tools_brush_curve(PaintPanel): row.operator("brush.curve_preset", icon="LINCURVE", text="").shape = 'LINE' row.operator("brush.curve_preset", icon="NOCURVE", text="").shape = 'MAX' -class VIEW3D_PT_sculpt_options(PaintPanel): + +class VIEW3D_PT_sculpt_options(PaintPanel, bpy.types.Panel): bl_label = "Options" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): return (context.sculpt_object and context.tool_settings.sculpt) def draw(self, context): layout = self.layout - wide_ui = context.region.width > narrowui tool_settings = context.tool_settings sculpt = tool_settings.sculpt - settings = self.paint_settings(context) + settings = __class__.paint_settings(context) brush = settings.brush split = layout.split() @@ -1016,10 +1005,7 @@ class VIEW3D_PT_sculpt_options(PaintPanel): col.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size") col.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength") - if wide_ui: - col = split.column() - else: - col.separator() + col = split.column() col.label(text="Lock:") row = col.row(align=True) @@ -1029,20 +1015,20 @@ class VIEW3D_PT_sculpt_options(PaintPanel): -class VIEW3D_PT_sculpt_symmetry(PaintPanel): +class VIEW3D_PT_sculpt_symmetry(PaintPanel, bpy.types.Panel): bl_label = "Symmetry" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): return (context.sculpt_object and context.tool_settings.sculpt) def draw(self, context): - wide_ui = context.region.width > narrowui layout = self.layout sculpt = context.tool_settings.sculpt - settings = self.paint_settings(context) + settings = __class__.paint_settings(context) brush = settings.brush split = layout.split() @@ -1054,10 +1040,7 @@ class VIEW3D_PT_sculpt_symmetry(PaintPanel): col.prop(sculpt, "symmetry_y", text="Y") col.prop(sculpt, "symmetry_z", text="Z") - if wide_ui: - col = split.column() - else: - col.separator() + col = split.column() col.prop(sculpt, "radial_symm", text="Radial") @@ -1067,18 +1050,19 @@ class VIEW3D_PT_sculpt_symmetry(PaintPanel): col.prop(sculpt, "use_symmetry_feather", text="Feather") -class VIEW3D_PT_tools_brush_appearance(PaintPanel): +class VIEW3D_PT_tools_brush_appearance(PaintPanel, bpy.types.Panel): bl_label = "Appearance" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): return (context.sculpt_object and context.tool_settings.sculpt) or (context.vertex_paint_object and context.tool_settings.vertex_paint) or (context.weight_paint_object and context.tool_settings.weight_paint) or (context.texture_paint_object and context.tool_settings.image_paint) def draw(self, context): layout = self.layout sculpt = context.tool_settings.sculpt - settings = self.paint_settings(context) + settings = __class__.paint_settings(context) brush = settings.brush col = layout.column(); @@ -1105,7 +1089,7 @@ class VIEW3D_PT_tools_brush_appearance(PaintPanel): # ********** default tools for weightpaint **************** -class VIEW3D_PT_tools_weightpaint(View3DPanel): +class VIEW3D_PT_tools_weightpaint(View3DPanel, bpy.types.Panel): bl_context = "weightpaint" bl_label = "Weight Tools" @@ -1120,7 +1104,7 @@ class VIEW3D_PT_tools_weightpaint(View3DPanel): col.operator("object.vertex_group_levels", text="Levels") -class VIEW3D_PT_tools_weightpaint_options(View3DPanel): +class VIEW3D_PT_tools_weightpaint_options(View3DPanel, bpy.types.Panel): bl_context = "weightpaint" bl_label = "Options" @@ -1157,7 +1141,7 @@ class VIEW3D_PT_tools_weightpaint_options(View3DPanel): # ********** default tools for vertexpaint **************** -class VIEW3D_PT_tools_vertexpaint(View3DPanel): +class VIEW3D_PT_tools_vertexpaint(View3DPanel, bpy.types.Panel): bl_context = "vertexpaint" bl_label = "Options" @@ -1186,12 +1170,14 @@ class VIEW3D_PT_tools_vertexpaint(View3DPanel): # ********** default tools for texturepaint **************** -class VIEW3D_PT_tools_projectpaint(View3DPanel): +class VIEW3D_PT_tools_projectpaint(View3DPanel, bpy.types.Panel): bl_context = "texturepaint" bl_label = "Project Paint" - def poll(self, context): - return context.tool_settings.image_paint.brush.imagepaint_tool != 'SMEAR' + @classmethod + def poll(cls, context): + brush = context.tool_settings.image_paint.brush + return (brush and brush.imagepaint_tool != 'SMEAR') def draw_header(self, context): ipaint = context.tool_settings.image_paint @@ -1259,7 +1245,8 @@ class VIEW3D_PT_imagepaint_options(PaintPanel): bl_label = "Options" bl_default_closed = True - def poll(self, context): + @classmethod + def poll(cls, context): return (context.texture_paint_object and context.tool_settings.image_paint) def draw(self, context): @@ -1294,7 +1281,7 @@ class VIEW3D_MT_tools_projectpaint_stencil(bpy.types.Menu): prop.value = i -class VIEW3D_PT_tools_particlemode(View3DPanel): +class VIEW3D_PT_tools_particlemode(View3DPanel, bpy.types.Panel): '''default tools for particle mode''' bl_context = "particlemode" bl_label = "Options" @@ -1361,49 +1348,12 @@ class VIEW3D_PT_tools_particlemode(View3DPanel): sub.prop(pe, "fade_frames", slider=True) -classes = [ - VIEW3D_PT_tools_weightpaint, - VIEW3D_PT_tools_objectmode, - VIEW3D_PT_tools_meshedit, - VIEW3D_PT_tools_meshedit_options, - VIEW3D_PT_tools_curveedit, - VIEW3D_PT_tools_surfaceedit, - VIEW3D_PT_tools_textedit, - VIEW3D_PT_tools_armatureedit, - VIEW3D_PT_tools_armatureedit_options, - VIEW3D_PT_tools_mballedit, - VIEW3D_PT_tools_latticeedit, - VIEW3D_PT_tools_posemode, - VIEW3D_PT_tools_posemode_options, - VIEW3D_PT_tools_brush, - VIEW3D_PT_tools_brush_texture, - VIEW3D_PT_tools_brush_stroke, - VIEW3D_PT_tools_brush_curve, - VIEW3D_PT_tools_brush_appearance, - VIEW3D_PT_tools_brush_tool, - VIEW3D_PT_sculpt_symmetry, - VIEW3D_PT_sculpt_options, - VIEW3D_PT_tools_vertexpaint, - VIEW3D_PT_tools_weightpaint_options, - VIEW3D_PT_imagepaint_options, - - VIEW3D_PT_tools_projectpaint, - VIEW3D_MT_tools_projectpaint_clone, - VIEW3D_MT_tools_projectpaint_stencil, - - VIEW3D_PT_tools_particlemode] - - def register(): - register = bpy.types.register - for cls in classes: - register(cls) + pass def unregister(): - unregister = bpy.types.unregister - for cls in classes: - unregister(cls) + pass if __name__ == "__main__": register() |