2.5 Buttons
[blender-staging.git] / release / ui / buttons_objects.py
index 9e4cb9340a41689023bb62a2dd307d00b9fa367c..a5074614515880906bbba711d7ce492296b6aa14 100644 (file)
+
 import bpy
 
-class OBJECT_PT_transform(bpy.types.Panel):
-       __label__ = "Transform"
+class ObjectButtonsPanel(bpy.types.Panel):
+       __space_type__ = "BUTTONS_WINDOW"
+       __region_type__ = "WINDOW"
        __context__ = "object"
 
+       def poll(self, context):
+               return (context.active_object != None)
+
+class OBJECT_PT_transform(ObjectButtonsPanel):
+       __idname__ = "OBJECT_PT_transform"
+       __label__ = "Transform"
+
        def draw(self, context):
                ob = context.active_object
                layout = self.layout
 
-               if not ob:
-                       return
-
-               layout.template_column_flow(3)
-               layout.itemR(ob, "location")
-               layout.itemR(ob, "rotation")
-               layout.itemR(ob, "scale")
+               row = layout.row()
+               row.column().itemR(ob, "location")
+               row.column().itemR(ob, "rotation")
+               row.column().itemR(ob, "scale")
 
-class OBJECT_PT_groups(bpy.types.Panel):
+class OBJECT_PT_groups(ObjectButtonsPanel):
+       __idname__ = "OBJECT_PT_groups"
        __label__ = "Groups"
-       __context__ = "object"
 
        def draw(self, context):
                ob = context.active_object
                layout = self.layout
 
-               if not ob:
-                       return
-
-               layout.template_column_flow(2)
-               layout.itemR(ob, "pass_index")
-               layout.itemR(ob, "parent")
+               row = layout.row()
+               row.itemR(ob, "pass_index")
+               row.itemR(ob, "parent")
 
-               # layout.template_left_right()
+               # layout.left_right()
                # layout.itemO("OBJECT_OT_add_group");
 
                for group in bpy.data.groups:
                        if ob in group.objects:
-                               sublayout = layout.template_stack()
+                               col = layout.column(align=True)
 
-                               sublayout.template_left_right()
-                               sublayout.itemR(group, "name")
-                               # sublayout.itemO("OBJECT_OT_remove_group")
+                               row = col.box().row()
+                               row.itemR(group, "name", text="")
+                               #row.itemO("OBJECT_OT_remove_group")
 
-                               sublayout.template_column_flow(2)
-                               sublayout.itemR(group, "layer")
-                               sublayout.itemR(group, "dupli_offset")
+                               split = col.box().split()
+                               split.column().itemR(group, "layer")
+                               split.column().itemR(group, "dupli_offset")
 
-class OBJECT_PT_display(bpy.types.Panel):
+class OBJECT_PT_display(ObjectButtonsPanel):
+       __idname__ = "OBJECT_PT_display"
        __label__ = "Display"
-       __context__ = "object"
 
        def draw(self, context):
                ob = context.active_object
                layout = self.layout
-
-               if not ob:
-                       return
-
-               layout.template_column_flow(2)
-               layout.itemR(ob, "max_draw_type", text="Type")
-               layout.itemR(ob, "draw_bounds_type", text="Bounds")
-
-               layout.template_column_flow(2)
-               layout.itemR(ob, "draw_name", text="Name")
-               layout.itemR(ob, "draw_axis", text="Axis")
-               layout.itemR(ob, "draw_wire", text="Wire")
-               layout.itemR(ob, "draw_texture_space", text="Texture Space")
-               layout.itemR(ob, "x_ray", text="X-Ray")
-               layout.itemR(ob, "draw_transparent", text="Transparency")
-
-class OBJECT_PT_duplication(bpy.types.Panel):
+                       
+               row = layout.row()
+               row.itemR(ob, "max_draw_type", text="Type")
+               row.itemR(ob, "draw_bounds_type", text="Bounds")
+
+               flow = layout.column_flow()
+               flow.itemR(ob, "draw_name", text="Name")
+               flow.itemR(ob, "draw_axis", text="Axis")
+               flow.itemR(ob, "draw_wire", text="Wire")
+               flow.itemR(ob, "draw_texture_space", text="Texture Space")
+               flow.itemR(ob, "x_ray", text="X-Ray")
+               flow.itemR(ob, "draw_transparent", text="Transparency")
+
+class OBJECT_PT_duplication(ObjectButtonsPanel):
+       __idname__ = "OBJECT_PT_duplication"
        __label__ = "Duplication"
-       __context__ = "object"
 
        def draw(self, context):
                ob = context.active_object
                layout = self.layout
 
-               if not ob:
-                       return
-
-               layout.template_column()
-               layout.itemR(ob, "dupli_type", text="")
-
-               if ob.dupli_type == "FRAMES":
-                       layout.template_column_flow(2)
-                       layout.itemR(ob, "dupli_frames_start", text="Start:")
-                       layout.itemR(ob, "dupli_frames_end", text="End:")
-                       layout.itemR(ob, "dupli_frames_on", text="On:")
-                       layout.itemR(ob, "dupli_frames_off", text="Off:")
-
-class OBJECT_PT_animation(bpy.types.Panel):
+               layout.itemR(ob, "dupli_type", expand=True)
+
+               if ob.dupli_type == 'FRAMES':
+                       split = layout.split()
+                       
+                       sub = split.column(align=True)
+                       sub.itemR(ob, "dupli_frames_start", text="Start")
+                       sub.itemR(ob, "dupli_frames_end", text="End")
+                       
+                       sub = split.column(align=True)
+                       sub.itemR(ob, "dupli_frames_on", text="On")
+                       sub.itemR(ob, "dupli_frames_off", text="Off")
+                       
+                       layout.itemR(ob, "dupli_frames_no_speed", text="No Speed")
+
+               elif ob.dupli_type == 'VERTS':
+                       layout.itemR(ob, "dupli_verts_rotation", text="Rotation")
+
+               elif ob.dupli_type == 'FACES':
+                       row = layout.row()
+                       row.itemR(ob, "dupli_faces_scale", text="Scale")
+                       row.itemR(ob, "dupli_faces_inherit_scale", text="Inherit Scale")
+
+               elif ob.dupli_type == 'GROUP':
+                       layout.itemR(ob, "dupli_group", text="Group")
+
+class OBJECT_PT_animation(ObjectButtonsPanel):
+       __idname__ = "OBJECT_PT_animation"
        __label__ = "Animation"
-       __context__ = "object"
 
        def draw(self, context):
                ob = context.active_object
                layout = self.layout
-
-               if not ob:
-                       return
-
-               layout.template_column()
                
-               layout.template_slot("COLUMN_1")
-               layout.itemL(text="Time Offset:")
-               layout.itemR(ob, "time_offset_edit", text="Edit")
-               layout.itemR(ob, "time_offset_particle", text="Particle")
-               layout.itemR(ob, "time_offset_parent", text="Parent")
-               layout.itemR(ob, "slow_parent")
-               layout.itemR(ob, "time_offset", text="Offset:")
+               split = layout.split()
+               
+               sub = split.column()
+               sub.itemL(text="Time Offset:")
+               sub.itemR(ob, "time_offset_edit", text="Edit")
+               sub.itemR(ob, "time_offset_particle", text="Particle")
+               sub.itemR(ob, "time_offset_parent", text="Parent")
+               sub.itemR(ob, "slow_parent")
+               sub.itemR(ob, "time_offset", text="Offset")
                
-               layout.template_slot("COLUMN_2")
-               layout.itemL(text="Tracking:")
-               layout.itemR(ob, "track_axis", text="Axis")
-               layout.itemR(ob, "up_axis", text="Up Axis")
-               layout.itemR(ob, "track_rotation", text="Rotation")
-
-bpy.ui.addPanel(OBJECT_PT_transform, "BUTTONS_WINDOW", "WINDOW")
-bpy.ui.addPanel(OBJECT_PT_groups, "BUTTONS_WINDOW", "WINDOW")
-bpy.ui.addPanel(OBJECT_PT_display, "BUTTONS_WINDOW", "WINDOW")
-bpy.ui.addPanel(OBJECT_PT_duplication, "BUTTONS_WINDOW", "WINDOW")
-bpy.ui.addPanel(OBJECT_PT_animation, "BUTTONS_WINDOW", "WINDOW")
+               sub = split.column()
+               sub.itemL(text="Tracking:")
+               sub.itemR(ob, "track_axis", text="Axis")
+               sub.itemR(ob, "up_axis", text="Up Axis")
+               sub.itemR(ob, "track_rotation", text="Rotation")
+
+bpy.types.register(OBJECT_PT_transform)
+bpy.types.register(OBJECT_PT_groups)
+bpy.types.register(OBJECT_PT_display)
+bpy.types.register(OBJECT_PT_duplication)
+bpy.types.register(OBJECT_PT_animation)