UI Buttons:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sun, 7 Jun 2009 13:36:12 +0000 (13:36 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sun, 7 Jun 2009 13:36:12 +0000 (13:36 +0000)
* Context now allows pinning a datablock, independent of
  selection.
* Initial ID browse buttons for most buttons tabs.
* Browsing from world to texture now displays world textures
  again, but is a bit of a hack, not sure there is a right
  way to do this.
* There's a button to switch between active materials and
  textures now, only temporary though.
* There's some code to put context part in own region,
  disabled still because it doesn't work that well yet.

19 files changed:
release/ui/buttons_data_armature.py
release/ui/buttons_data_camera.py
release/ui/buttons_data_curve.py
release/ui/buttons_data_lamp.py
release/ui/buttons_data_lattice.py
release/ui/buttons_data_mesh.py
release/ui/buttons_data_text.py
release/ui/buttons_material.py
release/ui/buttons_particle.py
release/ui/buttons_texture.py
release/ui/buttons_world.py
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_buttons/buttons_context.c
source/blender/editors/space_buttons/buttons_header.c
source/blender/editors/space_buttons/buttons_intern.h
source/blender/editors/space_buttons/buttons_ops.c [new file with mode: 0644]
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_image/image_header.c
source/blender/makesdna/DNA_space_types.h

index 46a077ebfdb7b51db74b616e490040afd52df940..fd317baf86110fa0df6639f2010495e5dce2c4c7 100644 (file)
@@ -14,27 +14,40 @@ class DATA_PT_skeleton(DataButtonsPanel):
        __label__ = "Skeleton"
 
        def draw(self, context):
+               ob = context.object
                arm = context.armature
+               space = context.space_data
                layout = self.layout
-               
-               layout.itemR(arm, "rest_position")
-
-               split = layout.split()
 
-               sub = split.column()
-               sub.itemL(text="Deform:")
-               sub.itemR(arm, "deform_vertexgroups", text="Vertes Groups")
-               sub.itemR(arm, "deform_envelope", text="Envelopes")
-               sub.itemR(arm, "deform_quaternion", text="Quaternion")
-               sub.itemR(arm, "deform_bbone_rest", text="B-Bones Rest")
-               #sub.itemR(arm, "x_axis_mirror")
-               #sub.itemR(arm, "auto_ik")
-               
-               sub = split.column()
-               sub.itemL(text="Layers:")
-               sub.itemL(text="LAYERS")
-               #sub.itemR(arm, "layer")
-               #sub.itemR(arm, "layer_protection")
+               split = layout.split(percentage=0.65)
+
+               if ob:
+                       split.template_ID(context, ob, "data")
+                       split.itemS()
+               elif arm:
+                       split.template_ID(context, space, "pin_id")
+                       split.itemS()
+
+               if arm:
+                       layout.itemS()
+                       layout.itemR(arm, "rest_position")
+
+                       split = layout.split()
+
+                       sub = split.column()
+                       sub.itemL(text="Deform:")
+                       sub.itemR(arm, "deform_vertexgroups", text="Vertes Groups")
+                       sub.itemR(arm, "deform_envelope", text="Envelopes")
+                       sub.itemR(arm, "deform_quaternion", text="Quaternion")
+                       sub.itemR(arm, "deform_bbone_rest", text="B-Bones Rest")
+                       #sub.itemR(arm, "x_axis_mirror")
+                       #sub.itemR(arm, "auto_ik")
+                       
+                       sub = split.column()
+                       sub.itemL(text="Layers:")
+                       sub.itemL(text="LAYERS")
+                       #sub.itemR(arm, "layer")
+                       #sub.itemR(arm, "layer_protection")
 
 class DATA_PT_display(DataButtonsPanel):
        __idname__ = "DATA_PT_display"
index 7f3682b1c942545ef0be79a8c3af8b895d3cc648..362e4f96aa241aa059cb185a71dd34db97ec5b65 100644 (file)
@@ -9,45 +9,58 @@ class DataButtonsPanel(bpy.types.Panel):
        def poll(self, context):
                return (context.camera != None)
                
-class DATA_PT_cameralens(DataButtonsPanel):
+class DATA_PT_camera(DataButtonsPanel):
        __idname__ = "DATA_PT_camera"
        __label__ = "Lens"
 
        def draw(self, context):
+               ob = context.object
                cam = context.camera
+               space = context.space_data
                layout = self.layout
 
-               layout.itemR(cam, "type", expand=True)
-               
-               row = layout.row(align=True)
-               if cam.type == 'PERSP':
-                       row.itemR(cam, "lens_unit", text="")
-                       if cam.lens_unit == 'MILLIMETERS':
-                               row.itemR(cam, "lens", text="Angle")
-                       elif cam.lens_unit == 'DEGREES':
-                               row.itemR(cam, "angle")
+               split = layout.split(percentage=0.65)
+
+               if ob:
+                       split.template_ID(context, ob, "data")
+                       split.itemS()
+               elif arm:
+                       split.template_ID(context, space, "pin_id")
+                       split.itemS()
 
-               elif cam.type == 'ORTHO':
-                       row.itemR(cam, "ortho_scale")
+               if cam:
+                       layout.itemS()
+                       layout.itemR(cam, "type", expand=True)
                        
-               split = layout.split()
-               
-               sub = split.column(align=True)
-               sub.itemL(text="Shift:")
-               sub.itemR(cam, "shift_x", text="X")
-               sub.itemR(cam, "shift_y", text="Y")
-               
-               sub = split.column(align=True)
-               sub.itemL(text="Clipping:")
-               sub.itemR(cam, "clip_start", text="Start")
-               sub.itemR(cam, "clip_end", text="End")
-               
-               row = layout.row()
-               row.itemR(cam, "dof_object")
-               row.itemR(cam, "dof_distance")
+                       row = layout.row(align=True)
+                       if cam.type == 'PERSP':
+                               row.itemR(cam, "lens_unit", text="")
+                               if cam.lens_unit == 'MILLIMETERS':
+                                       row.itemR(cam, "lens", text="Angle")
+                               elif cam.lens_unit == 'DEGREES':
+                                       row.itemR(cam, "angle")
+
+                       elif cam.type == 'ORTHO':
+                               row.itemR(cam, "ortho_scale")
+                               
+                       split = layout.split()
+                       
+                       sub = split.column(align=True)
+                       sub.itemL(text="Shift:")
+                       sub.itemR(cam, "shift_x", text="X")
+                       sub.itemR(cam, "shift_y", text="Y")
+                       
+                       sub = split.column(align=True)
+                       sub.itemL(text="Clipping:")
+                       sub.itemR(cam, "clip_start", text="Start")
+                       sub.itemR(cam, "clip_end", text="End")
+                       
+                       row = layout.row()
+                       row.itemR(cam, "dof_object")
+                       row.itemR(cam, "dof_distance")
                
-class DATA_PT_cameradisplay(DataButtonsPanel):
-       __idname__ = "DATA_PT_cameradisplay"
+class DATA_PT_camera_display(DataButtonsPanel):
+       __idname__ = "DATA_PT_camera_display"
        __label__ = "Display"
        
        def draw(self, context):
@@ -69,5 +82,5 @@ class DATA_PT_cameradisplay(DataButtonsPanel):
                colsub.itemR(cam, "passepartout_alpha", text="Alpha", slider=True)
                col.itemR(cam, "draw_size", text="Size")
                
-bpy.types.register(DATA_PT_cameralens)
-bpy.types.register(DATA_PT_cameradisplay)
+bpy.types.register(DATA_PT_camera)
+bpy.types.register(DATA_PT_camera_display)
index 9baee5516bed9c7a4e5599ff334cec3f3d30f1f0..b8b7d6a324f2126305282131751982d6af292a1b 100644 (file)
@@ -11,13 +11,26 @@ class DataButtonsPanel(bpy.types.Panel):
                return (ob and ob.type == 'CURVE' and context.curve)
 
 class DATA_PT_shape_curve(DataButtonsPanel):
-               __idname__ = "DATA_PT_shape_curve"
-               __label__ = "Shape"
+       __idname__ = "DATA_PT_shape_curve"
+       __label__ = "Shape"
 
-               def draw(self, context):
-                       curve = context.curve
-                       layout = self.layout
+       def draw(self, context):
+               ob = context.object
+               curve = context.curve
+               space = context.space_data
+               layout = self.layout
+
+               split = layout.split(percentage=0.65)
+
+               if ob:
+                       split.template_ID(context, ob, "data")
+                       split.itemS()
+               elif curve:
+                       split.template_ID(context, space, "pin_id")
+                       split.itemS()
 
+               if curve:
+                       layout.itemS()
                        layout.itemR(curve, "curve_2d")                 
                                                        
                        split = layout.split()
@@ -46,85 +59,85 @@ class DATA_PT_shape_curve(DataButtonsPanel):
                        sub.itemR(curve, "vertex_normal_flip")
 
 class DATA_PT_geometry(DataButtonsPanel):
-               __idname__ = "DATA_PT_geometry"
-               __label__ = "Geometry"
+       __idname__ = "DATA_PT_geometry"
+       __label__ = "Geometry"
 
-               def draw(self, context):
-                       curve = context.curve
-                       layout = self.layout
+       def draw(self, context):
+               curve = context.curve
+               layout = self.layout
 
-                       split = layout.split()
+               split = layout.split()
+       
+               sub = split.column()
+               sub.itemL(text="Modification:")
+               sub.itemR(curve, "width")
+               sub.itemR(curve, "extrude")
+               sub.itemR(curve, "taper_object")
                
-                       sub = split.column()
-                       sub.itemL(text="Modification:")
-                       sub.itemR(curve, "width")
-                       sub.itemR(curve, "extrude")
-                       sub.itemR(curve, "taper_object")
-                       
-                       sub = split.column()
-                       sub.itemL(text="Bevel:")
-                       sub.itemR(curve, "bevel_depth", text="Depth")
-                       sub.itemR(curve, "bevel_resolution", text="Resolution")
-                       sub.itemR(curve, "bevel_object")
+               sub = split.column()
+               sub.itemL(text="Bevel:")
+               sub.itemR(curve, "bevel_depth", text="Depth")
+               sub.itemR(curve, "bevel_resolution", text="Resolution")
+               sub.itemR(curve, "bevel_object")
        
 class DATA_PT_pathanim(DataButtonsPanel):
-               __idname__ = "DATA_PT_pathanim"
-               __label__ = "Path Animation"
-               
-               def draw_header(self, context):
-                       curve = context.curve
+       __idname__ = "DATA_PT_pathanim"
+       __label__ = "Path Animation"
+       
+       def draw_header(self, context):
+               curve = context.curve
 
-                       layout = self.layout
-                       layout.itemR(curve, "path", text="")
+               layout = self.layout
+               layout.itemR(curve, "path", text="")
 
-               def draw(self, context):
-                       curve = context.curve
-                       layout = self.layout
-                       layout.active = curve.path      
-                       
-                       split = layout.split()          
-                       
-                       sub = split.column()
-                       sub.itemR(curve, "path_length", text="Frames")
-                       sub.itemR(curve, "follow")
+       def draw(self, context):
+               curve = context.curve
+               layout = self.layout
+               layout.active = curve.path      
+               
+               split = layout.split()          
+               
+               sub = split.column()
+               sub.itemR(curve, "path_length", text="Frames")
+               sub.itemR(curve, "follow")
 
-                       sub = split.column()
-                       sub.itemR(curve, "stretch")
-                       sub.itemR(curve, "offset_path_distance", text="Offset Children")
+               sub = split.column()
+               sub.itemR(curve, "stretch")
+               sub.itemR(curve, "offset_path_distance", text="Offset Children")
        
 class DATA_PT_current_curve(DataButtonsPanel):
-               __idname__ = "DATA_PT_current_curve"
-               __label__ = "Current Curve"
+       __idname__ = "DATA_PT_current_curve"
+       __label__ = "Current Curve"
 
-               def draw(self, context):
-                       currentcurve = context.curve.curves[0] # XXX
-                       layout = self.layout
+       def draw(self, context):
+               currentcurve = context.curve.curves[0] # XXX
+               layout = self.layout
 
-                       split = layout.split()
+               split = layout.split()
+       
+               sub = split.column()
+               sub.itemL(text="Cyclic:")
+               sub.itemR(currentcurve, "cyclic_u", text="U")
+               sub.itemR(currentcurve, "cyclic_v", text="V")
+               sub.itemL(text="Order:")
+               sub.itemR(currentcurve, "order_u", text="U")
+               sub.itemR(currentcurve, "order_v", text="V")
+               sub.itemL(text="Endpoints:")
+               sub.itemR(currentcurve, "endpoint_u", text="U")
+               sub.itemR(currentcurve, "endpoint_v", text="V")
+               
+               sub = split.column()
+               sub.itemL(text="Bezier:")
+               sub.itemR(currentcurve, "bezier_u", text="U")
+               sub.itemR(currentcurve, "bezier_v", text="V")
+               sub.itemL(text="Resolution:")
+               sub.itemR(currentcurve, "resolution_u", text="U")
+               sub.itemR(currentcurve, "resolution_v", text="V")
+               sub.itemL(text="Interpolation:")
+               sub.itemR(currentcurve, "tilt_interpolation", text="Tilt")
+               sub.itemR(currentcurve, "radius_interpolation", text="Tilt")
+               sub.itemR(currentcurve, "smooth")
                
-                       sub = split.column()
-                       sub.itemL(text="Cyclic:")
-                       sub.itemR(currentcurve, "cyclic_u", text="U")
-                       sub.itemR(currentcurve, "cyclic_v", text="V")
-                       sub.itemL(text="Order:")
-                       sub.itemR(currentcurve, "order_u", text="U")
-                       sub.itemR(currentcurve, "order_v", text="V")
-                       sub.itemL(text="Endpoints:")
-                       sub.itemR(currentcurve, "endpoint_u", text="U")
-                       sub.itemR(currentcurve, "endpoint_v", text="V")
-                       
-                       sub = split.column()
-                       sub.itemL(text="Bezier:")
-                       sub.itemR(currentcurve, "bezier_u", text="U")
-                       sub.itemR(currentcurve, "bezier_v", text="V")
-                       sub.itemL(text="Resolution:")
-                       sub.itemR(currentcurve, "resolution_u", text="U")
-                       sub.itemR(currentcurve, "resolution_v", text="V")
-                       sub.itemL(text="Interpolation:")
-                       sub.itemR(currentcurve, "tilt_interpolation", text="Tilt")
-                       sub.itemR(currentcurve, "radius_interpolation", text="Tilt")
-                       sub.itemR(currentcurve, "smooth")
-                       
 bpy.types.register(DATA_PT_shape_curve)
 bpy.types.register(DATA_PT_geometry)
 bpy.types.register(DATA_PT_pathanim)
index 532098cf786ca99e356b6fbae7ff18973f57f7a8..f626eb45ed66360f4b94d1688e142e29c69d985f 100644 (file)
@@ -24,9 +24,22 @@ class DATA_PT_lamp(DataButtonsPanel):
        __label__ = "Lamp"
 
        def draw(self, context):
+               ob = context.object
                lamp = context.lamp
+               space = context.space_data
                layout = self.layout
 
+               split = layout.split(percentage=0.65)
+
+               if ob:
+                       split.template_ID(context, ob, "data")
+                       split.itemS()
+               elif lamp:
+                       split.template_ID(context, space, "pin_id")
+                       split.itemS()
+
+               layout.itemS()
+
                layout.itemR(lamp, "type", expand=True)
                
                split = layout.split()
index 6172c255d154c89d21bf82668385c5d7fbf8bb9b..8f83cbb45f9a3a391b9fc9b2b6198e51b972eaaa 100644 (file)
@@ -14,23 +14,37 @@ class DATA_PT_lattice(DataButtonsPanel):
        __label__ = "Lattice"
 
        def draw(self, context):
+               ob = context.object
                lat = context.lattice
+               space = context.space_data
                layout = self.layout
 
-               row = layout.row()
-               row.itemR(lat, "points_u")
-               row.itemR(lat, "interpolation_type_u", expand=True)
-               
-               row = layout.row()
-               row.itemR(lat, "points_v")
-               row.itemR(lat, "interpolation_type_v", expand=True)
-               
-               row = layout.row()
-               row.itemR(lat, "points_w")
-               row.itemR(lat, "interpolation_type_w", expand=True)
-               
-               row = layout.row()
-               row.itemR(lat, "outside")
-               row.itemR(lat, "shape_keys")
+               split = layout.split(percentage=0.65)
+
+               if ob:
+                       split.template_ID(context, ob, "data")
+                       split.itemS()
+               elif lat:
+                       split.template_ID(context, space, "pin_id")
+                       split.itemS()
+
+               if lat:
+                       layout.itemS()
+
+                       row = layout.row()
+                       row.itemR(lat, "points_u")
+                       row.itemR(lat, "interpolation_type_u", expand=True)
+                       
+                       row = layout.row()
+                       row.itemR(lat, "points_v")
+                       row.itemR(lat, "interpolation_type_v", expand=True)
+                       
+                       row = layout.row()
+                       row.itemR(lat, "points_w")
+                       row.itemR(lat, "interpolation_type_w", expand=True)
+                       
+                       row = layout.row()
+                       row.itemR(lat, "outside")
+                       row.itemR(lat, "shape_keys")
 
 bpy.types.register(DATA_PT_lattice)
index fceb235343a5471da7c7f4ad3d15b492b9d14773..c3742b38cc17ec9834d12a3b687a38b959cf4abb 100644 (file)
@@ -9,13 +9,27 @@ class DataButtonsPanel(bpy.types.Panel):
        def poll(self, context):
                return (context.mesh != None)
 
-class DATA_PT_surface(DataButtonsPanel):
-               __idname__ = "DATA_PT_surface"
-               __label__ = "Mesh"
+class DATA_PT_mesh(DataButtonsPanel):
+       __idname__ = "DATA_PT_mesh"
+       __label__ = "Mesh"
 
-               def draw(self, context):
-                       mesh = context.mesh
-                       layout = self.layout
+       def draw(self, context):
+               ob = context.object
+               mesh = context.mesh
+               space = context.space_data
+               layout = self.layout
+
+               split = layout.split(percentage=0.65)
+
+               if ob:
+                       split.template_ID(context, ob, "data")
+                       split.itemS()
+               elif mesh:
+                       split.template_ID(context, space, "pin_id")
+                       split.itemS()
+
+               if mesh:
+                       layout.itemS()
 
                        split = layout.split()
                
@@ -29,5 +43,5 @@ class DATA_PT_surface(DataButtonsPanel):
                        sub.itemR(mesh, "double_sided")
                        
                        layout.itemR(mesh, "texco_mesh")                        
-                                               
-bpy.types.register(DATA_PT_surface)
+                                       
+bpy.types.register(DATA_PT_mesh)
index 9683dbee22bc84c09b536c1a7c89d59c247677e6..20503d8d2fd45d30cfb6c09b085e49679c42c032 100644 (file)
@@ -11,13 +11,26 @@ class DataButtonsPanel(bpy.types.Panel):
                return (ob and ob.type == 'TEXT')
                
 class DATA_PT_shape_text(DataButtonsPanel):
-               __idname__ = "DATA_PT_shape_text"
-               __label__ = "Shape"
+       __idname__ = "DATA_PT_shape_text"
+       __label__ = "Shape"
 
-               def draw(self, context):
-                       curve = context.curve
-                       layout = self.layout
+       def draw(self, context):
+               ob = context.object
+               curve = context.curve
+               space = context.space_data
+               layout = self.layout
+
+               split = layout.split(percentage=0.65)
+
+               if ob:
+                       split.template_ID(context, ob, "data")
+                       split.itemS()
+               elif curve:
+                       split.template_ID(context, space, "pin_id")
+                       split.itemS()
 
+               if curve:
+                       layout.itemS()
                        layout.itemR(curve, "curve_2d")                 
                                                        
                        split = layout.split()
index 7cffb5b18cf9b11c5e07c6a9d6ca84d7e76dee75..b9816e36dd78e149703dcb067b13380a49ec8c6c 100644 (file)
@@ -13,6 +13,9 @@ class MATERIAL_PT_preview(MaterialButtonsPanel):
        __idname__= "MATERIAL_PT_preview"
        __label__ = "Preview"
 
+       def poll(self, context):
+               return (context.material or context.object)
+
        def draw(self, context):
                layout = self.layout
 
@@ -23,18 +26,36 @@ class MATERIAL_PT_material(MaterialButtonsPanel):
        __idname__= "MATERIAL_PT_material"
        __label__ = "Material"
 
+       def poll(self, context):
+               return (context.material or context.object)
+
        def draw(self, context):
                layout = self.layout
                mat = context.material
-       
-               layout.itemR(mat, "type", expand=True)
+               ob = context.object
+               slot = context.material_slot
+               space = context.space_data
 
-               row = layout.row()
-               row.column().itemR(mat, "diffuse_color")
-               row.column().itemR(mat, "specular_color")
-               row.column().itemR(mat, "mirror_color")
+               split = layout.split(percentage=0.65)
+
+               if ob and slot:
+                       split.template_ID(context, slot, "material", new="MATERIAL_OT_new")
+                       split.itemR(ob, "active_material_index", text="Active")
+               elif mat:
+                       split.template_ID(context, space, "pin_id")
+                       split.itemS()
+
+               if mat:
+                       layout.itemS()
                
-               layout.itemR(mat, "alpha", slider=True)
+                       layout.itemR(mat, "type", expand=True)
+
+                       row = layout.row()
+                       row.column().itemR(mat, "diffuse_color")
+                       row.column().itemR(mat, "specular_color")
+                       row.column().itemR(mat, "mirror_color")
+                       
+                       layout.itemR(mat, "alpha", slider=True)
                        
 class MATERIAL_PT_sss(MaterialButtonsPanel):
        __idname__= "MATERIAL_PT_sss"
index 505114e3ac545f651a04c246d976cf0877ec3269..571cafb709d0727e3ae2a6f616bc396c9dce5085 100644 (file)
@@ -19,45 +19,85 @@ class ParticleButtonsPanel(bpy.types.Panel):
 
 class PARTICLE_PT_particles(ParticleButtonsPanel):
        __idname__= "PARTICLE_PT_particles"
-       __label__ = "ParticleSystem"
+       __label__ = "Particle System"
 
        def poll(self, context):
-               return (context.particle_system != None)
-       
+               return (context.particle_system or context.object)
+
        def draw(self, context):
                layout = self.layout
-
+               ob = context.object
                psys = context.particle_system
-               part = psys.settings
-               
-               #row = layout.row()
-               #row.itemL(text="Particle system datablock")
-               #row.itemL(text="Viewport")
-               #row.itemL(text="Render")
-               
-               ptype = psys.settings.type
-               
-               if ptype not in ('EMITTER', 'REACTOR', 'HAIR'):
-                       layout.itemL(text="No settings for fluid particles")
-                       return
-               
-               row = layout.row()
-               row.enabled = particle_panel_enabled(psys)
-               row.itemR(part, "type", expand=True)
-               
-               
-               row = layout.row()
-               if part.type=='HAIR':
-                       if psys.editable==True:
-                               row.itemO("PARTICLE_OT_editable_set", text="Free Edit")
-                       else:
-                               row.itemO("PARTICLE_OT_editable_set", text="Make Editable")
-                       subrow = row.row()
-                       subrow.enabled = particle_panel_enabled(psys)
-                       subrow.itemR(part, "hair_step")
-               elif part.type=='REACTOR':
-                       row.itemR(psys, "reactor_target_object")
-                       row.itemR(psys, "reactor_target_particle_system", text="Particle System")
+
+               split = layout.split(percentage=0.65)
+
+               if psys:
+                       split.template_ID(context, psys, "settings")
+
+                       #if ob:
+                       #       split.itemR(ob, "active_particle_system_index", text="Active")
+
+               if psys:
+                       #row = layout.row()
+                       #row.itemL(text="Particle system datablock")
+                       #row.itemL(text="Viewport")
+                       #row.itemL(text="Render")
+                       
+                       part = psys.settings
+                       ptype = psys.settings.type
+                       
+                       if ptype not in ('EMITTER', 'REACTOR', 'HAIR'):
+                               layout.itemL(text="No settings for fluid particles")
+                               return
+                       
+                       row = layout.row()
+                       row.enabled = particle_panel_enabled(psys)
+                       row.itemR(part, "type")
+                       row.itemR(psys, "seed")
+                       
+                       row = layout.row()
+                       if part.type=='HAIR':
+                               if psys.editable==True:
+                                       row.itemO("PARTICLE_OT_editable_set", text="Free Edit")
+                               else:
+                                       row.itemO("PARTICLE_OT_editable_set", text="Make Editable")
+                               subrow = row.row()
+                               subrow.enabled = particle_panel_enabled(psys)
+                               subrow.itemR(part, "hair_step")
+                       elif part.type=='REACTOR':
+                               row.itemR(psys, "reactor_target_object")
+                               row.itemR(psys, "reactor_target_particle_system", text="Particle System")
+               
+               if psys:
+                       #row = layout.row()
+                       #row.itemL(text="Particle system datablock")
+                       #row.itemL(text="Viewport")
+                       #row.itemL(text="Render")
+                       
+                       part = psys.settings
+                       ptype = psys.settings.type
+                       
+                       if ptype not in ('EMITTER', 'REACTOR', 'HAIR'):
+                               layout.itemL(text="No settings for fluid particles")
+                               return
+                       
+                       row = layout.row()
+                       row.enabled = particle_panel_enabled(psys)
+                       row.itemR(part, "type", expand=True)
+                       
+                       
+                       row = layout.row()
+                       if part.type=='HAIR':
+                               if psys.editable==True:
+                                       row.itemO("PARTICLE_OT_editable_set", text="Free Edit")
+                               else:
+                                       row.itemO("PARTICLE_OT_editable_set", text="Make Editable")
+                               subrow = row.row()
+                               subrow.enabled = particle_panel_enabled(psys)
+                               subrow.itemR(part, "hair_step")
+                       elif part.type=='REACTOR':
+                               row.itemR(psys, "reactor_target_object")
+                               row.itemR(psys, "reactor_target_particle_system", text="Particle System")
                
 class PARTICLE_PT_emission(ParticleButtonsPanel):
        __idname__= "PARTICLE_PT_emission"
@@ -587,4 +627,4 @@ bpy.types.register(PARTICLE_PT_physics)
 bpy.types.register(PARTICLE_PT_render)
 bpy.types.register(PARTICLE_PT_draw)
 bpy.types.register(PARTICLE_PT_children)
-bpy.types.register(PARTICLE_PT_vertexgroups)
\ No newline at end of file
+bpy.types.register(PARTICLE_PT_vertexgroups)
index 7d0ef9371d7563f69bd8c5d46a0438a788bb5d64..e47c775d7fd7f2d1a80417acc1e95245a07a2259 100644 (file)
@@ -13,6 +13,9 @@ class TEXTURE_PT_preview(TextureButtonsPanel):
        __idname__= "TEXTURE_PT_preview"
        __label__ = "Preview"
 
+       def poll(self, context):
+               return (context.texture or context.material)
+
        def draw(self, context):
                layout = self.layout
 
@@ -23,11 +26,40 @@ class TEXTURE_PT_texture(TextureButtonsPanel):
        __idname__= "TEXTURE_PT_texture"
        __label__ = "Texture"
 
+       def poll(self, context):
+               return (context.texture or context.material or context.world or context.lamp)
+
        def draw(self, context):
                layout = self.layout
                tex = context.texture
-               
-               layout.itemR(tex, "type")
+               ma = context.material
+               la = context.lamp
+               wo = context.world
+               space = context.space_data
+               slot = context.texture_slot
+
+               split = layout.split(percentage=0.65)
+
+               if ma or la or wo:
+                       if slot:
+                               split.template_ID(context, slot, "texture", new="TEXTURE_OT_new")
+                       else:
+                               split.itemS()
+
+                       if ma:
+                               split.itemR(ma, "active_texture_index", text="Active")
+                       elif la:
+                               split.itemR(la, "active_texture_index", text="Active")
+                       elif wo:
+                               split.itemR(wo, "active_texture_index", text="Active")
+               elif tex:
+                       split.template_ID(context, space, "pin_id")
+                       split.itemS()
+
+               layout.itemS()
+               
+               if tex:
+                       layout.itemR(tex, "type")
 
 class TEXTURE_PT_colors(TextureButtonsPanel):
        __idname__= "TEXTURE_PT_colors"
index 79826e04dfce4d2539b0592f0b372acbedb14446..8298c0c9b13c366ea4fb1e30f540a74c4b73a095 100644 (file)
@@ -12,6 +12,9 @@ class WorldButtonsPanel(bpy.types.Panel):
 class WORLD_PT_preview(WorldButtonsPanel):
        __label__ = "Preview"
 
+       def poll(self, context):
+               return (context.scene or context.world)
+
        def draw(self, context):
                layout = self.layout
 
@@ -21,21 +24,38 @@ class WORLD_PT_preview(WorldButtonsPanel):
 class WORLD_PT_world(WorldButtonsPanel):
        __label__ = "World"
 
+       def poll(self, context):
+               return (context.scene or context.world)
+
        def draw(self, context):
+               scene = context.scene
                world = context.world
+               space = context.space_data
                layout = self.layout
-               
-               row = layout.row()
-               row.itemR(world, "blend_sky")
-               row.itemR(world, "paper_sky")
-               row.itemR(world, "real_sky")
-               
-               row = layout.row()
-               row.column().itemR(world, "horizon_color")
-               col = row.column()
-               col.itemR(world, "zenith_color")
-               col.active = world.blend_sky
-               row.column().itemR(world, "ambient_color")
+
+               split = layout.split(percentage=0.65)
+
+               if scene:
+                       split.template_ID(context, scene, "world", new="WORLD_OT_new")
+               elif world:
+                       split.template_ID(context, space, "pin_id")
+
+               split.itemS()
+
+               if world:
+                       layout.itemS()
+                       
+                       row = layout.row()
+                       row.itemR(world, "blend_sky")
+                       row.itemR(world, "paper_sky")
+                       row.itemR(world, "real_sky")
+                       
+                       row = layout.row()
+                       row.column().itemR(world, "horizon_color")
+                       col = row.column()
+                       col.itemR(world, "zenith_color")
+                       col.active = world.blend_sky
+                       row.column().itemR(world, "ambient_color")
                
 class WORLD_PT_color_correction(WorldButtonsPanel):
        __label__ = "Color Correction"
@@ -89,7 +109,7 @@ class WORLD_PT_stars(WorldButtonsPanel):
                flow.itemR(world.stars, "size")
                flow.itemR(world.stars, "min_distance", text="Min. Dist")
                flow.itemR(world.stars, "average_separation", text="Separation")
-               flow.itemR(world.stars, "color_randomization", text="Random:")
+               flow.itemR(world.stars, "color_randomization", text="Random")
                
 class WORLD_PT_ambient_occlusion(WorldButtonsPanel):
        __label__ = "Ambient Occlusion"
index c459d7669374db081b70239c5dc6a84d2e0a2e6c..ef2f60c180345b97a71ba9cbbfacdc8b2c9f2879 100644 (file)
@@ -5528,6 +5528,16 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
                                ar->regiontype= RGN_TYPE_UI;
                                ar->alignment= RGN_ALIGN_TOP;
                                break;
+
+#if 0
+                       case SPACE_BUTS:
+                               /* context UI region */
+                               ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
+                               BLI_addtail(lb, ar);
+                               ar->regiontype= RGN_TYPE_CHANNELS;
+                               ar->alignment= RGN_ALIGN_TOP;
+                               break;
+#endif
                }
        }
 
index 17b8a5a39bba1d718564758540b7a830133ab5bf..d3653efd9f2a5106c12e12882d733ec083f27e4e 100644 (file)
 #include "BKE_particle.h"
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
+#include "BKE_world.h"
 
 #include "RNA_access.h"
 
+#include "ED_screen.h"
+
 #include "UI_interface.h"
 #include "UI_resources.h"
 
 typedef struct ButsContextPath {
        PointerRNA ptr[8];
        int len;
+       int worldtex;
 } ButsContextPath;
 
+static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type)
+{
+       PointerRNA *ptr;
+       int a;
+
+       for(a=0; a<path->len; a++) {
+               ptr= &path->ptr[a];
+
+               if(RNA_struct_is_a(ptr->type, type)) {
+                       CTX_data_pointer_set(result, ptr->id.data, ptr->type, ptr->data);
+                       return 1;
+               }
+       }
+
+       return 0;
+}
+
+static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type)
+{
+       PointerRNA *ptr;
+       int a;
+
+       for(a=0; a<path->len; a++) {
+               ptr= &path->ptr[a];
+
+               if(RNA_struct_is_a(ptr->type, type))
+                       return ptr;
+       }
+
+       return NULL;
+}
+
 /************************* Creating the Path ************************/
 
 static int buttons_context_path_scene(ButsContextPath *path)
@@ -99,12 +135,19 @@ static int buttons_context_path_world(ButsContextPath *path)
 // XXX - place holder, need to get this working
 static int buttons_context_path_sequencer(ButsContextPath *path)
 {
-       PointerRNA *ptr= &path->ptr[path->len-1];
+       Scene *scene;
 
-       /* this one just verifies */
-       return RNA_struct_is_a(ptr->type, &RNA_Scene);
-}
+       if(buttons_context_path_scene(path)) {
+               scene= path->ptr[path->len-1].data;
 
+               RNA_pointer_create(&scene->id, &RNA_SequenceEditor, scene->ed, &path->ptr[path->len]);
+               path->len++;
+
+               return 1;
+       }
+
+       return 0;
+}
 
 static int buttons_context_path_object(ButsContextPath *path)
 {
@@ -136,12 +179,21 @@ static int buttons_context_path_object(ButsContextPath *path)
 static int buttons_context_path_data(ButsContextPath *path, int type)
 {
        Object *ob;
+       PointerRNA *ptr= &path->ptr[path->len-1];
 
+       /* if we already have a data, we're done */
+       if(RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) return 1;
+       else if(RNA_struct_is_a(ptr->type, &RNA_Curve) && (type == -1 || ELEM3(type, OB_CURVE, OB_SURF, OB_FONT))) return 1;
+       else if(RNA_struct_is_a(ptr->type, &RNA_Armature) && (type == -1 || type == OB_ARMATURE)) return 1;
+       else if(RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) return 1;
+       else if(RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) return 1;
+       else if(RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) return 1;
+       else if(RNA_struct_is_a(ptr->type, &RNA_Lamp) && (type == -1 || type == OB_LAMP)) return 1;
        /* try to get an object in the path, no pinning supported here */
-       if(buttons_context_path_object(path)) {
+       else if(buttons_context_path_object(path)) {
                ob= path->ptr[path->len-1].data;
 
-               if(type == -1 || type == ob->type) {
+               if(ob && (type == -1 || type == ob->type)) {
                        RNA_id_pointer_create(ob->data, &path->ptr[path->len]);
                        path->len++;
 
@@ -153,10 +205,25 @@ static int buttons_context_path_data(ButsContextPath *path, int type)
        return 0;
 }
 
+static int buttons_context_path_modifier(ButsContextPath *path)
+{
+       Object *ob;
+
+       if(buttons_context_path_object(path)) {
+               ob= path->ptr[path->len-1].data;
+
+               if(ob && ELEM4(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF))
+                       return 1;
+       }
+
+       return 0;
+}
+
 static int buttons_context_path_material(ButsContextPath *path)
 {
        Object *ob;
        PointerRNA *ptr= &path->ptr[path->len-1];
+       Material *ma;
 
        /* if we already have a (pinned) material, we're done */
        if(RNA_struct_is_a(ptr->type, &RNA_Material)) {
@@ -167,7 +234,8 @@ static int buttons_context_path_material(ButsContextPath *path)
                ob= path->ptr[path->len-1].data;
 
                if(ob && ob->type && (ob->type<OB_LAMP)) {
-                       RNA_pointer_create(&ob->id, &RNA_MaterialSlot, ob->mat+ob->actcol-1, &path->ptr[path->len]);
+                       ma= give_current_material(ob, ob->actcol);
+                       RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
                        path->len++;
                        return 1;
                }
@@ -222,11 +290,14 @@ static int buttons_context_path_particle(ButsContextPath *path)
        /* if we have an object, get the active particle system */
        if(buttons_context_path_object(path)) {
                ob= path->ptr[path->len-1].data;
-               psys= psys_get_current(ob);
 
-               RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &path->ptr[path->len]);
-               path->len++;
-               return 1;
+               if(ob && ob->type == OB_MESH) {
+                       psys= psys_get_current(ob);
+
+                       RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &path->ptr[path->len]);
+                       path->len++;
+                       return 1;
+               }
        }
 
        /* no path to a particle system possible */
@@ -235,58 +306,70 @@ static int buttons_context_path_particle(ButsContextPath *path)
 
 static int buttons_context_path_texture(ButsContextPath *path)
 {
-       Object *ob;
-       Lamp *la;
        Material *ma;
+       Lamp *la;
+       World *wo;
+       MTex *mtex;
+       Tex *tex;
        PointerRNA *ptr= &path->ptr[path->len-1];
 
        /* if we already have a (pinned) texture, we're done */
        if(RNA_struct_is_a(ptr->type, &RNA_Texture)) {
                return 1;
        }
-       /* try to get the active material */
-       else if(buttons_context_path_material(path)) {
-               ptr= &path->ptr[path->len-1];
+       /* try world */
+       else if(path->worldtex && buttons_context_path_world(path)) {
+               wo= path->ptr[path->len-1].data;
 
-               if(RNA_struct_is_a(ptr->type, &RNA_Material)) {
-                       ma= ptr->data;
-               }
-               else if(RNA_struct_is_a(ptr->type, &RNA_MaterialSlot)) {
-                       ob= ptr->id.data;
-                       ma= give_current_material(ob, (Material**)ptr->data - ob->mat);
+               if(wo) {
+                       mtex= wo->mtex[(int)wo->texact];
+                       tex= (mtex)? mtex->tex: NULL;
+
+                       RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
+                       path->len++;
+                       return 1;
                }
-               else
-                       ma= NULL;
+       }
+       /* try material */
+       else if(buttons_context_path_material(path)) {
+               ma= path->ptr[path->len-1].data;
 
                if(ma) {
-                       RNA_pointer_create(&ma->id, &RNA_TextureSlot, ma->mtex[(int)ma->texact], &path->ptr[path->len]);
+                       mtex= ma->mtex[(int)ma->texact];
+                       tex= (mtex)? mtex->tex: NULL;
+
+                       RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
                        path->len++;
                        return 1;
                }
        }
-       /* try to get the active lamp */
+       /* try lamp */
        else if(buttons_context_path_data(path, OB_LAMP)) {
                la= path->ptr[path->len-1].data;
 
                if(la) {
-                       RNA_pointer_create(&la->id, &RNA_TextureSlot, la->mtex[(int)la->texact], &path->ptr[path->len]);
+                       mtex= la->mtex[(int)la->texact];
+                       tex= (mtex)? mtex->tex: NULL;
+
+                       RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
                        path->len++;
                        return 1;
                }
        }
-       /* TODO: world, brush */
+       /* TODO: material nodes, brush */
 
        /* no path to a particle system possible */
        return 0;
 }
 
-static int buttons_context_path(const bContext *C, ButsContextPath *path)
+static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int worldtex)
 {
        SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
        ID *id;
        int found;
 
        memset(path, 0, sizeof(*path));
+       path->worldtex= worldtex;
 
        /* if some ID datablock is pinned, set the root pointer */
        if(sbuts->pinid) {
@@ -305,7 +388,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path)
 
        /* now for each buttons context type, we try to construct a path,
         * tracing back recursively */
-       switch(sbuts->mainb) {
+       switch(mainb) {
                case BCONTEXT_SCENE:
                        found= buttons_context_path_scene(path);
                        break;
@@ -318,9 +401,11 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path)
                case BCONTEXT_OBJECT:
                case BCONTEXT_PHYSICS:
                case BCONTEXT_CONSTRAINT:
-               case BCONTEXT_MODIFIER:
                        found= buttons_context_path_object(path);
                        break;
+               case BCONTEXT_MODIFIER:
+                       found= buttons_context_path_modifier(path);
+                       break;
                case BCONTEXT_DATA:
                        found= buttons_context_path_data(path, -1);
                        break;
@@ -346,46 +431,63 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path)
 
 void buttons_context_compute(const bContext *C, SpaceButs *sbuts)
 {
+       ButsContextPath *path;
+       PointerRNA *ptr;
+       int a, worldtex, flag= 0;
+
        if(!sbuts->path)
                sbuts->path= MEM_callocN(sizeof(ButsContextPath), "ButsContextPath");
        
-       buttons_context_path(C, sbuts->path);
-}
-
-/************************* Context Callback ************************/
-
-static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type)
-{
-       PointerRNA *ptr;
-       int a;
-
-       for(a=0; a<path->len; a++) {
-               ptr= &path->ptr[a];
-
-               if(RNA_struct_is_a(ptr->type, type)) {
-                       CTX_data_pointer_set(result, ptr->id.data, ptr->type, ptr->data);
-                       return 1;
+       path= sbuts->path;
+       worldtex= (sbuts->flag & SB_WORLD_TEX);
+       
+       /* for each context, see if we can compute a valid path to it, if
+        * this is the case, we know we have to display the button */
+       for(a=0; a<BCONTEXT_TOT; a++) {
+               if(buttons_context_path(C, path, a, worldtex)) {
+                       flag |= (1<<a);
+
+                       /* setting icon for data context */
+                       if(a == BCONTEXT_DATA) {
+                               ptr= &path->ptr[path->len-1];
+
+                               if(ptr->type)
+                                       sbuts->dataicon= RNA_struct_ui_icon(ptr->type);
+                               else
+                                       sbuts->dataicon= ICON_EMPTY_DATA;
+                       }
                }
        }
 
-       return 0;
-}
-
-static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type)
-{
-       PointerRNA *ptr;
-       int a;
+       /* in case something becomes invalid, change */
+       if((flag & (1 << sbuts->mainb)) == 0) {
+               if(flag & BCONTEXT_OBJECT) {
+                       sbuts->mainb= BCONTEXT_OBJECT;
+               }
+               else {
+                       for(a=0; a<BCONTEXT_TOT; a++) {
+                               if(flag & (1 << a)) {
+                                       sbuts->mainb= a;
+                                       break;
+                               }
+                       }
+               }
+       }
 
-       for(a=0; a<path->len; a++) {
-               ptr= &path->ptr[a];
+       buttons_context_path(C, path, sbuts->mainb, worldtex);
 
-               if(RNA_struct_is_a(ptr->type, type))
-                       return ptr;
+       if(!(flag & (1 << sbuts->mainb))) {
+               if(flag & (1 << BCONTEXT_OBJECT))
+                       sbuts->mainb= BCONTEXT_OBJECT;
+               else
+                       sbuts->mainb= BCONTEXT_SCENE;
        }
 
-       return NULL;
+       sbuts->pathflag= flag;
 }
 
+/************************* Context Callback ************************/
+
 int buttons_context(const bContext *C, const char *member, bContextDataResult *result)
 {
        SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
@@ -433,34 +535,53 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
                return 1;
        }
        else if(CTX_data_equals(member, "material")) {
-               if(!set_pointer_type(path, result, &RNA_Material)) {
-                       PointerRNA *ptr= get_pointer_type(path, &RNA_MaterialSlot);
-
-                       if(ptr && ptr->data) {
-                               Object *ob= ptr->id.data;
-                               Material *ma= give_current_material(ob, (Material**)ptr->data - ob->mat);
-                               CTX_data_id_pointer_set(result, &ma->id);
-                       }
-               }
-
+               set_pointer_type(path, result, &RNA_Material);
                return 1;
        }
        else if(CTX_data_equals(member, "texture")) {
-               if(!set_pointer_type(path, result, &RNA_Texture)) {
-                       PointerRNA *ptr= get_pointer_type(path, &RNA_TextureSlot);
-
-                       if(ptr && ptr->data)
-                               CTX_data_id_pointer_set(result, &((MTex*)ptr->data)->tex->id);
-               }
-
+               set_pointer_type(path, result, &RNA_Texture);
                return 1;
        }
        else if(CTX_data_equals(member, "material_slot")) {
-               set_pointer_type(path, result, &RNA_MaterialSlot);
+               PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
+
+               if(ptr) {
+                       Object *ob= ptr->data;
+
+                       if(ob && ob->type && (ob->type<OB_LAMP))
+                               CTX_data_pointer_set(result, &ob->id, &RNA_MaterialSlot, ob->mat+ob->actcol-1);
+               }
+
                return 1;
        }
        else if(CTX_data_equals(member, "texture_slot")) {
-               set_pointer_type(path, result, &RNA_TextureSlot);
+               PointerRNA *ptr;
+
+               if((ptr=get_pointer_type(path, &RNA_Material))) {
+                       Material *ma= ptr->data;
+
+                       if(ma)
+                               CTX_data_pointer_set(result, &ma->id, &RNA_TextureSlot, ma->mtex[(int)ma->texact]);
+               }
+               else if((ptr=get_pointer_type(path, &RNA_Lamp))) {
+                       Lamp *la= ptr->data;
+
+                       if(la)
+                               CTX_data_pointer_set(result, &la->id, &RNA_TextureSlot, la->mtex[(int)la->texact]);
+               }
+               else if((ptr=get_pointer_type(path, &RNA_World))) {
+                       World *wo= ptr->data;
+
+                       if(wo)
+                               CTX_data_pointer_set(result, &wo->id, &RNA_TextureSlot, wo->mtex[(int)wo->texact]);
+               }
+               else if((ptr=get_pointer_type(path, &RNA_Brush))) { /* how to get this into context? */
+                       Brush *br= ptr->data;
+
+                       if(br)
+                               CTX_data_pointer_set(result, &br->id, &RNA_TextureSlot, br->mtex[(int)br->texact]);
+               }
+
                return 1;
        }
        else if(CTX_data_equals(member, "bone")) {
@@ -500,11 +621,38 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
 
 /************************* Drawing the Path ************************/
 
-static void buttons_panel_context(const bContext *C, Panel *pa)
+static void pin_cb(bContext *C, void *arg1, void *arg2)
+{
+       SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
+       ButsContextPath *path= sbuts->path;
+       PointerRNA *ptr;
+       int a;
+
+       if(sbuts->flag & SB_PIN_CONTEXT) {
+               if(path->len) {
+                       for(a=path->len-1; a>=0; a--) {
+                               ptr= &path->ptr[a];
+
+                               if(ptr->id.data) {
+                                       sbuts->pinid= ptr->id.data;
+                                       break;
+                               }
+                       }
+               }
+       }
+       else
+               sbuts->pinid= NULL;
+       
+       ED_area_tag_redraw(CTX_wm_area(C));
+}
+
+void buttons_context_draw(const bContext *C, uiLayout *layout)
 {
        SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
        ButsContextPath *path= sbuts->path;
        uiLayout *row;
+       uiBlock *block;
+       uiBut *but;
        PointerRNA *ptr;
        PropertyRNA *nameprop;
        char namebuf[128], *name;
@@ -513,9 +661,14 @@ static void buttons_panel_context(const bContext *C, Panel *pa)
        if(!path)
                return;
 
-       row= uiLayoutRow(pa->layout, 0);
+       row= uiLayoutRow(layout, 0);
        uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT);
 
+       block= uiLayoutGetBlock(row);
+       uiBlockSetEmboss(block, UI_EMBOSSN);
+       but= uiDefIconButBitC(block, ICONTOG, SB_PIN_CONTEXT, 0, (sbuts->flag & SB_PIN_CONTEXT)? ICON_PINNED: ICON_UNPINNED, 0, 0, UI_UNIT_X, UI_UNIT_Y, &sbuts->flag, 0, 0, 0, 0, "Follow context or keep fixed datablock displayed.");
+       uiButSetFunc(but, pin_cb, NULL, NULL);
+
        for(a=0; a<path->len; a++) {
                ptr= &path->ptr[a];
 
@@ -523,6 +676,12 @@ static void buttons_panel_context(const bContext *C, Panel *pa)
                        icon= RNA_struct_ui_icon(ptr->type);
                        nameprop= RNA_struct_name_property(ptr->type);
 
+#if 0
+                       if(sbuts->mainb != BCONTEXT_SCENE && ptr->type == &RNA_Scene) {
+                               uiItemL(row, "", icon); /* save some space */
+                       }
+                       else
+#endif
                        if(nameprop) {
                                name= RNA_property_string_get_alloc(ptr, nameprop, namebuf, sizeof(namebuf));
 
@@ -537,6 +696,11 @@ static void buttons_panel_context(const bContext *C, Panel *pa)
        }
 }
 
+static void buttons_panel_context(const bContext *C, Panel *pa)
+{
+       buttons_context_draw(C, pa->layout);
+}
+
 void buttons_context_register(ARegionType *art)
 {
        PanelType *pt;
index 444db92265d0732862bd790b60491dace5fdd517..73f161e1130c74ad43c0e1e957db213489413072 100644 (file)
@@ -114,6 +114,8 @@ static uiBlock *dummy_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
 
 static void do_buttons_buttons(bContext *C, void *arg, int event)
 {
+       SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
+
        switch(event) {
                case B_NEWFRAME:
                        WM_event_add_notifier(C, NC_SCENE|ND_FRAME, NULL);
@@ -121,18 +123,25 @@ static void do_buttons_buttons(bContext *C, void *arg, int event)
                case B_CONTEXT_SWITCH:
                case B_BUTSPREVIEW:
                        ED_area_tag_redraw(CTX_wm_area(C));
+
+                       /* silly exception */
+                       if(sbuts->mainb == BCONTEXT_WORLD)
+                               sbuts->flag |= SB_WORLD_TEX;
+                       else if(sbuts->mainb != BCONTEXT_TEXTURE)
+                               sbuts->flag &= ~SB_WORLD_TEX;
+
                        break;
        }
 }
 
-
 void buttons_header_buttons(const bContext *C, ARegion *ar)
 {
        ScrArea *sa= CTX_wm_area(C);
        SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
-       Object *ob= CTX_data_active_object(C);
        uiBlock *block;
-       int xco, yco= 3, dataicon= ICON_OBJECT_DATA;
+       int xco, yco= 3;
+
+       buttons_context_compute(C, sbuts);
        
        block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS);
        uiBlockSetHandleFunc(block, do_buttons_buttons, NULL);
@@ -148,70 +157,38 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
                
                xco+=xmax;
        }
-       // DATA Icons
-       if(ob) {
-               switch(ob->type) {
-                       case OB_EMPTY: dataicon= ICON_EMPTY_DATA; break;
-                       case OB_MESH: dataicon= ICON_MESH_DATA; break;
-                       case OB_CURVE: dataicon= ICON_CURVE_DATA; break;
-                       case OB_SURF: dataicon= ICON_SURFACE_DATA; break;
-                       case OB_FONT: dataicon= ICON_FONT_DATA; break;
-                       case OB_MBALL: dataicon= ICON_META_DATA; break;
-                       case OB_LAMP: dataicon= ICON_LAMP_DATA; break;
-                       case OB_CAMERA: dataicon= ICON_CAMERA_DATA; break;
-                       case OB_LATTICE: dataicon= ICON_LATTICE_DATA; break;
-                       case OB_ARMATURE: dataicon= ICON_ARMATURE_DATA; break;
-                       default: break;
-               }
-       }
        
        uiBlockSetEmboss(block, UI_EMBOSS);
 
-       // if object selection changed, validate button selection
-       if(ob && (ob->type == OB_LAMP) && ELEM3(sbuts->mainb, (float)BCONTEXT_MATERIAL, (float)BCONTEXT_PARTICLE, (float)BCONTEXT_PHYSICS))
-               sbuts->mainb = (float)BCONTEXT_DATA;
-
-       if(ob && (ob->type == OB_EMPTY) && ELEM3(sbuts->mainb, (float)BCONTEXT_MATERIAL, (float)BCONTEXT_TEXTURE, (float)BCONTEXT_PARTICLE))
-               sbuts->mainb = (float)BCONTEXT_DATA;
-               
-       if((ob && ELEM(ob->type, OB_CAMERA, OB_ARMATURE)) && ELEM4(sbuts->mainb, (float)BCONTEXT_MATERIAL, (float)BCONTEXT_TEXTURE, (float)BCONTEXT_PARTICLE, (float)BCONTEXT_PHYSICS))
-               sbuts->mainb = (float)BCONTEXT_DATA;
-               
-       if((ob && (ob->type != OB_ARMATURE)) && (sbuts->mainb == (float)BCONTEXT_BONE))
-               sbuts->mainb = (float)BCONTEXT_DATA;
-       
-        if(!ob && !ELEM3(sbuts->mainb, (float)BCONTEXT_SCENE, (float)BCONTEXT_WORLD, (float)BCONTEXT_SEQUENCER))
-               sbuts->mainb = (float)BCONTEXT_WORLD;
-               
-       if((ob && ELEM5(ob->type, OB_EMPTY, OB_MBALL, OB_LAMP, OB_CAMERA, OB_ARMATURE)) && (sbuts->mainb == (float) BCONTEXT_MODIFIER))
-               sbuts->mainb = (float)BCONTEXT_DATA;
+       xco -= XIC;
        
        // Default panels
        uiBlockBeginAlign(block);
-       uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_SCENE,                     xco, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_SCENE, 0, 0, "Scene");
-       uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_WORLD,             xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_WORLD, 0, 0, "World");
-       uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_SEQUENCE,  xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_SEQUENCER, 0, 0, "Sequencer");
-       
-       // Specific panels, check on active object seletion
-       if(ob) {
+       if(sbuts->pathflag & (1<<BCONTEXT_SCENE))
+               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_SCENE,                     xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_SCENE, 0, 0, "Scene");
+       if(sbuts->pathflag & (1<<BCONTEXT_WORLD))
+               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_WORLD,             xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_WORLD, 0, 0, "World");
+       if(sbuts->pathflag & (1<<BCONTEXT_SEQUENCER))
+               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_SEQUENCE,          xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_SEQUENCER, 0, 0, "Sequencer");
+       if(sbuts->pathflag & (1<<BCONTEXT_OBJECT))
                uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_OBJECT_DATA,       xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_OBJECT, 0, 0, "Object");
-               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_CONSTRAINT,        xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_CONSTRAINT, 0, 0, "Constraint");
-               
-               if(ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE))
-                       uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_MODIFIER,  xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_MODIFIER, 0, 0, "Modifier");
-               
-               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     dataicon,               xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_DATA, 0, 0, "Object Data");
-               if((ob->type == OB_ARMATURE))
-                       uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_BONE_DATA, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_BONE, 0, 0, "Bone");
-               if(ELEM5(ob->type, OB_MESH, OB_SURF, OB_MBALL, OB_CURVE, OB_FONT))
-                       uiDefIconButS(block, ROW, B_BUTSPREVIEW,        ICON_MATERIAL,                  xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_MATERIAL, 0, 0, "Material");
-               if(ELEM6(ob->type, OB_MESH, OB_SURF, OB_MBALL, OB_CURVE, OB_FONT, OB_LAMP))
-                       uiDefIconButS(block, ROW, B_BUTSPREVIEW,        ICON_TEXTURE,   xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_TEXTURE, 0, 0, "Texture");
-               if(ELEM5(ob->type, OB_MESH, OB_SURF, OB_MBALL, OB_CURVE, OB_FONT))
-                       uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_PARTICLES, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_PARTICLE, 0, 0, "Particles");
-               if(ELEM6(ob->type, OB_MESH, OB_SURF, OB_MBALL, OB_CURVE, OB_FONT, OB_EMPTY))
-                       uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_PHYSICS,   xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_PHYSICS, 0, 0, "Physics");
-       }
+       if(sbuts->pathflag & (1<<BCONTEXT_CONSTRAINT))
+               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_CONSTRAINT,        xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_CONSTRAINT, 0, 0, "Modifier");
+       if(sbuts->pathflag & (1<<BCONTEXT_DATA))
+               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     sbuts->dataicon,        xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_DATA, 0, 0, "Object Data");
+       if(sbuts->pathflag & (1<<BCONTEXT_MODIFIER))
+               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_MODIFIER,  xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_MODIFIER, 0, 0, "Modifier");
+       if(sbuts->pathflag & (1<<BCONTEXT_BONE))
+               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_BONE_DATA, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_BONE, 0, 0, "Bone");
+       if(sbuts->pathflag & (1<<BCONTEXT_MATERIAL))
+               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_MATERIAL,  xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_MATERIAL, 0, 0, "Material");
+       if(sbuts->pathflag & (1<<BCONTEXT_TEXTURE))
+               uiDefIconButS(block, ROW, B_BUTSPREVIEW,        ICON_TEXTURE,   xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_TEXTURE, 0, 0, "Texture");
+       if(sbuts->pathflag & (1<<BCONTEXT_PARTICLE))
+               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_PARTICLES, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_PARTICLE, 0, 0, "Particles");
+       if(sbuts->pathflag & (1<<BCONTEXT_PHYSICS))
+               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_PHYSICS,   xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_PHYSICS, 0, 0, "Physics");
+
        xco+= XIC;
        
        uiBlockEndAlign(block);
@@ -220,11 +197,6 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
        uiDefButI(block, NUM, B_NEWFRAME, "",   (xco+20),yco,60,YIC, &(CTX_data_scene(C)->r.cfra), 1.0, MAXFRAMEF, 0, 0, "Displays Current Frame of animation. Click to change.");
        xco+= 80;
        
-// XXX buttons_active_id(&id, &idfrom);
-//     sbuts->lockpoin= id;
-       
-       
-       
        /* always as last  */
        UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
        
index 04c7241c4654fc29f8b00e33433bbefd8e5f49e3..196647a37503eb73319da3bd3c77ea0a34d3fbee 100644 (file)
@@ -32,6 +32,9 @@ struct ARegion;
 struct ARegionType;
 struct bContext;
 struct bContextDataResult;
+struct SpaceButs;
+struct uiLayout;
+struct wmOperatorType;
 
 /* buts->scaflag */            
 #define BUTS_SENS_SEL          1
@@ -52,9 +55,15 @@ struct bContextDataResult;
 void buttons_header_buttons(const struct bContext *C, struct ARegion *ar);
 
 /* buttons_context.c */
-void buttons_context_compute(const struct bContext *C, SpaceButs *sbuts);
+void buttons_context_compute(const struct bContext *C, struct SpaceButs *sbuts);
 int buttons_context(const struct bContext *C, const char *member, struct bContextDataResult *result);
+void buttons_context_draw(const struct bContext *C, struct uiLayout *layout);
 void buttons_context_register(struct ARegionType *art);
 
+/* buttons_ops.c */
+void MATERIAL_OT_new(struct wmOperatorType *ot);
+void TEXTURE_OT_new(struct wmOperatorType *ot);
+void WORLD_OT_new(struct wmOperatorType *ot);
+
 #endif /* ED_BUTTONS_INTERN_H */
 
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
new file mode 100644 (file)
index 0000000..63469a8
--- /dev/null
@@ -0,0 +1,194 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_object_types.h"
+#include "DNA_material_types.h"
+#include "DNA_texture_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_world_types.h"
+
+#include "BKE_context.h"
+#include "BKE_library.h"
+#include "BKE_material.h"
+#include "BKE_texture.h"
+#include "BKE_world.h"
+
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "buttons_intern.h"    // own include
+
+/********************** new material operator *********************/
+
+static int new_material_exec(bContext *C, wmOperator *op)
+{
+       PointerRNA ptr;
+       Material *ma;
+       Object *ob;
+       int index;
+
+       /* add or copy material */
+       ptr= CTX_data_pointer_get(C, "material");
+       ma= (RNA_struct_is_a(ptr.type, &RNA_Material))? ptr.data: NULL;
+
+       if(ma)
+               ma= copy_material(ma);
+       else
+               ma= add_material("Material");
+
+       ma->id.us--; /* compensating for us++ in assign_material */
+
+       /* attempt to assign to material slot */
+       ptr= CTX_data_pointer_get(C, "material_slot");
+
+       if(RNA_struct_is_a(ptr.type, &RNA_MaterialSlot)) {
+               ob= ptr.id.data;
+               index= (Material**)ptr.data - ob->mat;
+
+               assign_material(ob, ma, index+1);
+
+               WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+       }
+       
+       return OPERATOR_FINISHED;
+}
+
+void MATERIAL_OT_new(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "New Material";
+       ot->idname= "MATERIAL_OT_new";
+       
+       /* api callbacks */
+       ot->exec= new_material_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/********************** new texture operator *********************/
+
+static int new_texture_exec(bContext *C, wmOperator *op)
+{
+       PointerRNA ptr;
+       ID *id;
+       Tex *tex;
+       MTex *mtex;
+
+       /* add or copy texture */
+       ptr= CTX_data_pointer_get(C, "texture");
+       tex= (RNA_struct_is_a(ptr.type, &RNA_Texture))? ptr.data: NULL;
+
+       if(tex)
+               tex= copy_texture(tex);
+       else
+               tex= add_texture("Texture");
+
+       id_us_min(&tex->id);
+
+       /* attempt to assign to texture slot */
+       ptr= CTX_data_pointer_get(C, "texture_slot");
+
+       if(RNA_struct_is_a(ptr.type, &RNA_TextureSlot)) {
+               id= ptr.id.data;
+               mtex= ptr.data;
+
+               if(mtex) {
+                       if(mtex->tex)
+                               id_us_min(&mtex->tex->id);
+                       mtex->tex= tex;
+                       id_us_plus(&tex->id);
+               }
+
+               /* XXX nodes, notifier .. */
+       }
+       
+       return OPERATOR_FINISHED;
+}
+
+void TEXTURE_OT_new(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "New Texture";
+       ot->idname= "TEXTURE_OT_new";
+       
+       /* api callbacks */
+       ot->exec= new_texture_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/********************** new world operator *********************/
+
+static int new_world_exec(bContext *C, wmOperator *op)
+{
+       PointerRNA ptr;
+       Scene *scene;
+       World *wo;
+
+       /* add or copy world */
+       ptr= CTX_data_pointer_get(C, "world");
+       wo= (RNA_struct_is_a(ptr.type, &RNA_World))? ptr.data: NULL;
+
+       if(wo)
+               wo= copy_world(wo);
+       else
+               wo= add_world("World");
+
+       /* assign to scene */
+       scene= CTX_data_scene(C);
+
+       if(scene->world)
+               id_us_min(&scene->world->id);
+       scene->world= wo;
+
+       // XXX notifier
+       
+       return OPERATOR_FINISHED;
+}
+
+void WORLD_OT_new(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "New World";
+       ot->idname= "WORLD_OT_new";
+       
+       /* api callbacks */
+       ot->exec= new_world_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
index a6487fd5f63cb70acd7c5beb99e9d83f70ee8cb4..291519e963247348caea272709c45a3a3ce1e330 100644 (file)
@@ -33,6 +33,7 @@
 #include "DNA_space_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
+#include "DNA_userdef_types.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -79,6 +80,14 @@ static SpaceLink *buttons_new(const bContext *C)
        ar->regiontype= RGN_TYPE_HEADER;
        ar->alignment= RGN_ALIGN_BOTTOM;
        
+#if 0
+       /* context area */
+       ar= MEM_callocN(sizeof(ARegion), "context area for buts");
+       BLI_addtail(&sbuts->regionbase, ar);
+       ar->regiontype= RGN_TYPE_CHANNELS;
+       ar->alignment= RGN_ALIGN_TOP;
+#endif
+
        /* main area */
        ar= MEM_callocN(sizeof(ARegion), "main area for buts");
        
@@ -203,7 +212,9 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar)
 
 void buttons_operatortypes(void)
 {
-       
+       WM_operatortype_append(MATERIAL_OT_new);
+       WM_operatortype_append(TEXTURE_OT_new);
+       WM_operatortype_append(WORLD_OT_new);
 }
 
 void buttons_keymap(struct wmWindowManager *wm)
@@ -239,6 +250,58 @@ static void buttons_header_area_draw(const bContext *C, ARegion *ar)
        UI_view2d_view_restore(C);
 }
 
+#if 0
+/* add handlers, stuff you only do once or on area/region changes */
+static void buttons_context_area_init(wmWindowManager *wm, ARegion *ar)
+{
+       UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
+}
+
+#define CONTEXTY       30
+
+static void buttons_context_area_draw(const bContext *C, ARegion *ar)
+{
+       SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
+       uiStyle *style= U.uistyles.first;
+       uiBlock *block;
+       uiLayout *layout;
+       View2D *v2d= &ar->v2d;
+       float col[3];
+       int x, y, w, h;
+
+       buttons_context_compute(C, sbuts);
+
+       w= v2d->cur.xmax - v2d->cur.xmin;
+       h= v2d->cur.ymax - v2d->cur.ymin;
+       UI_view2d_view_ortho(C, v2d);
+
+       /* create UI */
+       block= uiBeginBlock(C, ar, "buttons_context", UI_EMBOSS);
+       layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_PANEL,
+               style->panelspace, h - (h-UI_UNIT_Y)/2, w, 20, style);
+
+       buttons_context_draw(C, layout);
+
+       uiBlockLayoutResolve(C, block, &x, &y);
+       uiEndBlock(C, block);
+
+       /* draw */
+       UI_SetTheme(SPACE_BUTS, RGN_TYPE_WINDOW); /* XXX */
+
+       UI_GetThemeColor3fv(TH_BACK, col);
+       glClearColor(col[0], col[1], col[2], 0.0);
+       glClear(GL_COLOR_BUFFER_BIT);
+
+       UI_view2d_totRect_set(v2d, x, -y);
+       UI_view2d_view_ortho(C, v2d);
+
+       uiDrawBlock(C, block);
+
+       /* restore view matrix */
+       UI_view2d_view_restore(C);
+}
+#endif
+
 /* reused! */
 static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn)
 {
@@ -328,17 +391,19 @@ void ED_spacetype_buttons(void)
        art->init= buttons_header_area_init;
        art->draw= buttons_header_area_draw;
        BLI_addhead(&st->regiontypes, art);
-       
-       /* regions: channels */
+
+#if 0
+       /* regions: context */
        art= MEM_callocN(sizeof(ARegionType), "spacetype buttons region");
        art->regionid = RGN_TYPE_CHANNELS;
-       art->minsizex= 80;
-       art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
-       
-//     art->init= buttons_channel_area_init;
-//     art->draw= buttons_channel_area_draw;
+       art->minsizey= CONTEXTY;
+       art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES;
+       art->init= buttons_context_area_init;
+       art->draw= buttons_context_area_draw;;
+       art->listener= buttons_area_listener;
        
        BLI_addhead(&st->regiontypes, art);
+#endif
        
        BKE_spacetype_register(st);
 }
index 9a61d3a7081684cbd76cf6da43ba302337aedb2f..adf4772efdee1ba8a03eadf94d7dd92cd9c53106 100644 (file)
@@ -140,13 +140,8 @@ static void image_viewmenu(bContext *C, uiLayout *layout, void *arg_unused)
        show_uvedit= ED_space_image_show_uvedit(sima, CTX_data_edit_object(C));
        
        /* create menu */
-       uiItemO(layout, NULL, ICON_MENU_PANEL, "IMAGE_OT_toggle_view_properties_panel"); // View Properties...
-       uiItemO(layout, NULL, ICON_MENU_PANEL, "IMAGE_OT_toggle_image_properties_panel"); // Image Properties...|N
-       uiItemO(layout, NULL, ICON_MENU_PANEL, "IMAGE_OT_toggle_realtime_properties_panel"); // Real-time properties...
-       if(show_paint) uiItemO(layout, NULL, ICON_MENU_PANEL, "IMAGE_OT_toggle_paint_panel"); // Paint Tool...|C
-       uiItemO(layout, NULL, ICON_MENU_PANEL, "IMAGE_OT_toggle_curves_panel"); // Curves Tool...
-       if(show_render) uiItemO(layout, NULL, ICON_MENU_PANEL, "IMAGE_OT_toggle_compositing_preview_panel"); // Compositing Preview...|Shift P
-       uiItemO(layout, NULL, ICON_MENU_PANEL, "IMAGE_OT_toggle_grease_pencil_panel"); // Grease Pencil...
+       uiItemO(layout, NULL, ICON_MENU_PANEL, "IMAGE_OT_properties");
+       //if(show_render) uiItemO(layout, NULL, ICON_MENU_PANEL, "IMAGE_OT_toggle_compositing_preview_panel"); // Compositing Preview...|Shift P
 
        uiItemS(layout);
 
index a7cd505f86e7ab0a7b2d809f5ba761b96f6202a2..c47bc70486414e15efd330eb4d9d8d7f01e120c3 100644 (file)
@@ -139,7 +139,8 @@ typedef struct SpaceButs {
        short oldkeypress;              /* for keeping track of the sub tab key cycling */
        char flag, texact;
        
-       void *path;             /* runtime */
+       void *path;                             /* runtime */
+       int pathflag, dataicon; /* runtime */
        ID *pinid;
 } SpaceButs;
 
@@ -464,7 +465,6 @@ typedef struct SpaceImaSel {
 #define TAB_SCENE_SEQUENCER    4
 
 
-/* warning: the values of these defines are used in sbuts->tabs[8] */
 /* buts->mainb new */
 #define BCONTEXT_SCENE         0
 #define BCONTEXT_WORLD         1
@@ -479,10 +479,12 @@ typedef struct SpaceImaSel {
 #define BCONTEXT_MODIFIER      10
 #define BCONTEXT_SEQUENCER     11
 #define BCONTEXT_CONSTRAINT 12
-
+#define BCONTEXT_TOT           13
 
 /* sbuts->flag */
 #define SB_PRV_OSA                     1
+#define SB_PIN_CONTEXT         2
+#define SB_WORLD_TEX           4
 
 /* sbuts->align */
 #define BUT_FREE               0