[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24520] trunk/blender: Added single column UI layouts
William Reynish
william at reynish.com
Thu Nov 12 13:35:38 CET 2009
Revision: 24520
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24520
Author: billrey
Date: 2009-11-12 13:35:37 +0100 (Thu, 12 Nov 2009)
Log Message:
-----------
Added single column UI layouts
This changes the layout when the properties window gets too narrow to render the contents properly.
Currently implemented for render, scene, world, object and materials, but the rest can be done easily.
Here's a video for demonstration:
http://www.reynish.com/files/blender25/properties_resize.mov
It automatically detects the window width and then skips the indicators that tells the layout to go to the next column. It requires very minimal changes to the UI scripts so we don't have to maintain two versions of the layouts.
Modified Paths:
--------------
trunk/blender/release/scripts/ui/properties_material.py
trunk/blender/release/scripts/ui/properties_object.py
trunk/blender/release/scripts/ui/properties_render.py
trunk/blender/release/scripts/ui/properties_scene.py
trunk/blender/release/scripts/ui/properties_world.py
trunk/blender/source/blender/makesrna/intern/rna_userdef.c
Modified: trunk/blender/release/scripts/ui/properties_material.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_material.py 2009-11-12 12:20:57 UTC (rev 24519)
+++ trunk/blender/release/scripts/ui/properties_material.py 2009-11-12 12:35:37 UTC (rev 24520)
@@ -19,6 +19,7 @@
# <pep8 compliant>
import bpy
+narrowui = 180
def active_node_mat(mat):
# TODO, 2.4x has a pipeline section, for 2.5 we need to communicate
@@ -89,23 +90,29 @@
row.itemO("object.material_slot_select", text="Select")
row.itemO("object.material_slot_deselect", text="Deselect")
- split = layout.split(percentage=0.65)
+ if (context.region.width > narrowui):
+ split = layout.split(percentage=0.65)
+
+ if ob:
+ split.template_ID(ob, "active_material", new="material.new")
+ row = split.row()
+ if slot:
+ row.itemR(slot, "link", text="")
+ else:
+ row.itemL()
+ elif mat:
+ split.template_ID(space, "pin_id")
+ split.itemS()
+ else:
+ layout.template_ID(ob, "active_material", new="material.new")
- if ob:
- split.template_ID(ob, "active_material", new="material.new")
- row = split.row()
- if slot:
- row.itemR(slot, "link", text="")
+ if mat:
+ if (context.region.width > narrowui):
+ layout.itemR(mat, "type", expand=True)
else:
- row.itemL()
- elif mat:
- split.template_ID(space, "pin_id")
- split.itemS()
+ layout.itemR(mat, "type", text="")
+
- if mat:
- layout.itemR(mat, "type", expand=True)
-
-
class MATERIAL_PT_shading(MaterialButtonsPanel):
bl_label = "Shading"
COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
@@ -131,7 +138,8 @@
sub = col.column()
sub.itemR(mat, "translucency")
- col = split.column()
+ if (context.region.width > narrowui):
+ col = split.column()
col.itemR(mat, "shadeless")
sub = col.column()
sub.active = not mat.shadeless
@@ -160,18 +168,20 @@
split = layout.split()
- col = split.column(align=True)
- col.itemL(text="Size:")
- col.itemR(tan, "root_size", text="Root")
- col.itemR(tan, "tip_size", text="Tip")
- col.itemR(tan, "min_size", text="Minimum")
- col.itemR(tan, "blender_units")
+ col = split.column()
+ sub = col.column(align=True)
+ sub.itemL(text="Size:")
+ sub.itemR(tan, "root_size", text="Root")
+ sub.itemR(tan, "tip_size", text="Tip")
+ sub.itemR(tan, "min_size", text="Minimum")
+ sub.itemR(tan, "blender_units")
sub = col.column()
sub.active = (not mat.shadeless)
sub.itemR(tan, "tangent_shading")
col.itemR(tan, "shape")
- col = split.column()
+ if (context.region.width > narrowui):
+ col = split.column()
col.itemL(text="Shading:")
col.itemR(tan, "width_fade")
ob = context.object
@@ -204,7 +214,8 @@
col.itemR(phys, "friction")
col.itemR(phys, "align_to_normal")
- col = split.column()
+ if (context.region.width > narrowui):
+ col = split.column()
col.itemR(phys, "force", slider=True)
col.itemR(phys, "elasticity", slider=True)
col.itemR(phys, "damp", slider=True)
@@ -242,7 +253,8 @@
row.active = mat.light_group
row.itemR(mat, "light_group_exclusive", text="Exclusive")
- col = split.column()
+ if (context.region.width > narrowui):
+ col = split.column()
col.itemR(mat, "face_texture")
sub = col.column()
sub.active = mat.face_texture
@@ -277,7 +289,8 @@
col.itemR(mat, "cast_shadows_only", text="Cast Only")
col.itemR(mat, "shadow_casting_alpha", text="Casting Alpha")
- col = split.column()
+ if (context.region.width > narrowui):
+ col = split.column()
col.itemR(mat, "cast_buffer_shadows")
sub = col.column()
sub.active = mat.cast_buffer_shadows
@@ -310,7 +323,8 @@
sub.active = (not mat.shadeless)
sub.itemR(mat, "diffuse_intensity", text="Intensity")
- col = split.column()
+ if (context.region.width > narrowui):
+ col = split.column()
col.active = (not mat.shadeless)
col.itemR(mat, "diffuse_shader", text="")
col.itemR(mat, "use_diffuse_ramp", text="Ramp")
@@ -322,26 +336,38 @@
elif mat.diffuse_shader == 'MINNAERT':
col.itemR(mat, "darkness")
elif mat.diffuse_shader == 'TOON':
- row = col.row()
- row.itemR(mat, "diffuse_toon_size", text="Size")
- row.itemR(mat, "diffuse_toon_smooth", text="Smooth")
+ split = col.split()
+
+ col = split.column()
+ col.itemR(mat, "diffuse_toon_size", text="Size")
+
+ if (context.region.width > narrowui):
+ col = split.column()
+ col.itemR(mat, "diffuse_toon_smooth", text="Smooth")
elif mat.diffuse_shader == 'FRESNEL':
- row = col.row()
- row.itemR(mat, "diffuse_fresnel", text="Fresnel")
- row.itemR(mat, "diffuse_fresnel_factor", text="Factor")
+ split = col.split()
+
+ col = split.column()
+ col.itemR(mat, "diffuse_fresnel", text="Fresnel")
+
+ if (context.region.width > narrowui):
+ col = split.column()
+ col.itemR(mat, "diffuse_fresnel_factor", text="Factor")
if mat.use_diffuse_ramp:
layout.itemS()
layout.template_color_ramp(mat, "diffuse_ramp", expand=True)
layout.itemS()
+
+ split = layout.split()
+
+ col = split.column()
+ col.itemR(mat, "diffuse_ramp_input", text="Input")
+
+ if (context.region.width > narrowui):
+ col = split.column()
+ col.itemR(mat, "diffuse_ramp_blend", text="Blend")
row = layout.row()
- split = row.split(percentage=0.3)
- split.itemL(text="Input:")
- split.itemR(mat, "diffuse_ramp_input", text="")
- split = row.split(percentage=0.3)
- split.itemL(text="Blend:")
- split.itemR(mat, "diffuse_ramp_blend", text="")
- row = layout.row()
row.itemR(mat, "diffuse_ramp_factor", text="Factor")
@@ -367,7 +393,8 @@
col.itemR(mat, "specular_color", text="")
col.itemR(mat, "specular_intensity", text="Intensity")
- col = split.column()
+ if (context.region.width > narrowui):
+ col = split.column()
col.itemR(mat, "specular_shader", text="")
col.itemR(mat, "use_specular_ramp", text="Ramp")
@@ -375,28 +402,40 @@
if mat.specular_shader in ('COOKTORR', 'PHONG'):
col.itemR(mat, "specular_hardness", text="Hardness")
elif mat.specular_shader == 'BLINN':
- row = col.row()
- row.itemR(mat, "specular_hardness", text="Hardness")
- row.itemR(mat, "specular_ior", text="IOR")
+ split = layout.split()
+
+ col = split.column()
+ col.itemR(mat, "specular_hardness", text="Hardness")
+
+ if (context.region.width > narrowui):
+ col = split.column()
+ col.itemR(mat, "specular_ior", text="IOR")
elif mat.specular_shader == 'WARDISO':
col.itemR(mat, "specular_slope", text="Slope")
elif mat.specular_shader == 'TOON':
- row = col.row()
- row.itemR(mat, "specular_toon_size", text="Size")
- row.itemR(mat, "specular_toon_smooth", text="Smooth")
+ split = layout.split()
+
+ col = split.column()
+ col.itemR(mat, "specular_toon_size", text="Size")
+
+ if (context.region.width > narrowui):
+ col = split.column()
+ col.itemR(mat, "specular_toon_smooth", text="Smooth")
if mat.use_specular_ramp:
layout.itemS()
layout.template_color_ramp(mat, "specular_ramp", expand=True)
layout.itemS()
+ split = layout.split()
+
+ col = split.column()
+ col.itemR(mat, "specular_ramp_input", text="Input")
+
+ if (context.region.width > narrowui):
+ col = split.column()
+ col.itemR(mat, "specular_ramp_blend", text="Blend")
+
row = layout.row()
- split = row.split(percentage=0.3)
- split.itemL(text="Input:")
- split.itemR(mat, "specular_ramp_input", text="")
- split = row.split(percentage=0.3)
- split.itemL(text="Blend:")
- split.itemR(mat, "specular_ramp_blend", text="")
- row = layout.row()
row.itemR(mat, "specular_ramp_factor", text="Factor")
@@ -434,7 +473,8 @@
col.itemR(sss, "color", text="")
col.itemR(sss, "radius", text="RGB Radius")
- col = split.column()
+ if (context.region.width > narrowui):
+ col = split.column()
sub = col.column(align=True)
sub.itemL(text="Blend:")
sub.itemR(sss, "color_factor", text="Color")
@@ -475,7 +515,8 @@
col.itemR(raym, "reflect_factor")
col.itemR(mat, "mirror_color", text="")
- col = split.column()
+ if (context.region.width > narrowui):
+ col = split.column()
col.itemR(raym, "fresnel")
sub = col.column()
sub.active = raym.fresnel > 0
@@ -492,7 +533,8 @@
sub.itemL(text="Fade To:")
sub.itemR(raym, "fade_to", text="")
- col = split.column()
+ if (context.region.width > narrowui):
+ col = split.column()
col.itemL(text="Gloss:")
col.itemR(raym, "gloss_factor", text="Amount")
sub = col.column()
@@ -525,7 +567,10 @@
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list