UI: some API functions don't require explicit context passing anymore.

This commit is contained in:
Brecht Van Lommel 2009-06-23 00:19:10 +00:00
parent 333e231fa6
commit 272fac8fd6
17 changed files with 64 additions and 67 deletions

@ -26,10 +26,10 @@ class DATA_PT_skeleton(DataButtonsPanel):
split = layout.split(percentage=0.65)
if ob:
split.template_ID(context, ob, "data")
split.template_ID(ob, "data")
split.itemS()
elif arm:
split.template_ID(context, space, "pin_id")
split.template_ID(space, "pin_id")
split.itemS()
if arm:

@ -26,10 +26,10 @@ class DATA_PT_camera(DataButtonsPanel):
split = layout.split(percentage=0.65)
if ob:
split.template_ID(context, ob, "data")
split.template_ID(ob, "data")
split.itemS()
elif arm:
split.template_ID(context, space, "pin_id")
split.template_ID(space, "pin_id")
split.itemS()
if cam:

@ -26,10 +26,10 @@ class DATA_PT_shape_curve(DataButtonsPanel):
split = layout.split(percentage=0.65)
if ob:
split.template_ID(context, ob, "data")
split.template_ID(ob, "data")
split.itemS()
elif curve:
split.template_ID(context, space, "pin_id")
split.template_ID(space, "pin_id")
split.itemS()
if curve:

@ -36,10 +36,10 @@ class DATA_PT_lamp(DataButtonsPanel):
split = layout.split(percentage=0.65)
if ob:
split.template_ID(context, ob, "data")
split.template_ID(ob, "data")
split.itemS()
elif lamp:
split.template_ID(context, space, "pin_id")
split.template_ID(space, "pin_id")
split.itemS()
layout.itemS()

@ -26,10 +26,10 @@ class DATA_PT_lattice(DataButtonsPanel):
split = layout.split(percentage=0.65)
if ob:
split.template_ID(context, ob, "data")
split.template_ID(ob, "data")
split.itemS()
elif lat:
split.template_ID(context, space, "pin_id")
split.template_ID(space, "pin_id")
split.itemS()
if lat:

@ -26,10 +26,10 @@ class DATA_PT_mesh(DataButtonsPanel):
split = layout.split(percentage=0.65)
if ob:
split.template_ID(context, ob, "data")
split.template_ID(ob, "data")
split.itemS()
elif mesh:
split.template_ID(context, space, "pin_id")
split.template_ID(space, "pin_id")
split.itemS()
if mesh:

@ -27,10 +27,10 @@ class DATA_PT_shape_text(DataButtonsPanel):
split = layout.split(percentage=0.65)
if ob:
split.template_ID(context, ob, "data")
split.template_ID(ob, "data")
split.itemS()
elif curve:
split.template_ID(context, space, "pin_id")
split.template_ID(space, "pin_id")
split.itemS()
if curve:

@ -40,10 +40,10 @@ class MATERIAL_PT_material(MaterialButtonsPanel):
split = layout.split(percentage=0.65)
if ob and slot:
split.template_ID(context, slot, "material", new="MATERIAL_OT_new")
split.template_ID(slot, "material", new="MATERIAL_OT_new")
split.itemR(ob, "active_material_index", text="Active")
elif mat:
split.template_ID(context, space, "pin_id")
split.template_ID(space, "pin_id")
split.itemS()
if mat:

@ -32,7 +32,7 @@ class PARTICLE_PT_particles(ParticleButtonsPanel):
split = layout.split(percentage=0.65)
if psys:
split.template_ID(context, psys, "settings")
split.template_ID(psys, "settings")
if psys:
#row = layout.row()

@ -43,7 +43,7 @@ class TEXTURE_PT_texture(TextureButtonsPanel):
if ma or la or wo:
if slot:
split.template_ID(context, slot, "texture", new="TEXTURE_OT_new")
split.template_ID(slot, "texture", new="TEXTURE_OT_new")
else:
split.itemS()
@ -54,7 +54,7 @@ class TEXTURE_PT_texture(TextureButtonsPanel):
elif wo:
split.itemR(wo, "active_texture_index", text="Active")
elif tex:
split.template_ID(context, space, "pin_id")
split.template_ID(space, "pin_id")
split.itemS()
layout.itemS()

@ -37,9 +37,9 @@ class WORLD_PT_world(WorldButtonsPanel):
split = layout.split(percentage=0.65)
if scene:
split.template_ID(context, scene, "world", new="WORLD_OT_new")
split.template_ID(scene, "world", new="WORLD_OT_new")
elif world:
split.template_ID(context, space, "pin_id")
split.template_ID(space, "pin_id")
split.itemS()

@ -15,7 +15,7 @@ class Buttons_HT_header(bpy.types.Header):
if context.area.show_menus:
row = layout.row(align=True)
row.itemM(context, "Buttons_MT_view", text="View")
row.itemM("Buttons_MT_view", text="View")
row = layout.row()
row.itemR(so, "buttons_context", expand=True, text="")
@ -33,4 +33,4 @@ class Buttons_MT_view(bpy.types.Menu):
col.itemR(so, "panel_alignment", expand=True)
bpy.types.register(Buttons_HT_header)
bpy.types.register(Buttons_MT_view)
bpy.types.register(Buttons_MT_view)

@ -177,9 +177,9 @@ class IMAGE_MT_uvs(bpy.types.Menu):
layout.itemS()
layout.itemM(context, "IMAGE_MT_uvs_transform")
layout.itemM(context, "IMAGE_MT_uvs_mirror")
layout.itemM(context, "IMAGE_MT_uvs_weldalign")
layout.itemM("IMAGE_MT_uvs_transform")
layout.itemM("IMAGE_MT_uvs_mirror")
layout.itemM("IMAGE_MT_uvs_weldalign")
layout.itemS()
@ -188,7 +188,7 @@ class IMAGE_MT_uvs(bpy.types.Menu):
layout.itemS()
layout.itemM(context, "IMAGE_MT_uvs_showhide")
layout.itemM("IMAGE_MT_uvs_showhide")
class IMAGE_HT_header(bpy.types.Header):
__space_type__ = "IMAGE_EDITOR"
@ -202,23 +202,23 @@ class IMAGE_HT_header(bpy.types.Header):
show_paint = sima.show_paint
show_uvedit = sima.show_uvedit
layout.template_header(context)
layout.template_header()
# menus
if context.area.show_menus:
row = layout.row()
row.itemM(context, "IMAGE_MT_view")
row.itemM("IMAGE_MT_view")
if show_uvedit:
row.itemM(context, "IMAGE_MT_select")
row.itemM("IMAGE_MT_select")
# XXX menuname= (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))? "Image*": "Image";
row.itemM(context, "IMAGE_MT_image")
row.itemM("IMAGE_MT_image")
if show_uvedit:
row.itemM(context, "IMAGE_MT_uvs")
row.itemM("IMAGE_MT_uvs")
layout.template_ID(context, sima, "image", new="IMAGE_OT_new", open="IMAGE_OT_open")
layout.template_ID(sima, "image", new="IMAGE_OT_new", open="IMAGE_OT_open")
"""
/* image select */
@ -595,9 +595,9 @@ class IMAGE_MT_uvs(bpy.types.Menu):
layout.itemS()
layout.itemM(context, "IMAGE_MT_uvs_transform")
layout.itemM(context, "IMAGE_MT_uvs_mirror")
layout.itemM(context, "IMAGE_MT_uvs_weldalign")
layout.itemM("IMAGE_MT_uvs_transform")
layout.itemM("IMAGE_MT_uvs_mirror")
layout.itemM("IMAGE_MT_uvs_weldalign")
layout.itemS()
@ -606,7 +606,7 @@ class IMAGE_MT_uvs(bpy.types.Menu):
layout.itemS()
layout.itemM(context, "IMAGE_MT_uvs_showhide")
layout.itemM("IMAGE_MT_uvs_showhide")
class IMAGE_HT_header(bpy.types.Header):
__space_type__ = "IMAGE_EDITOR"
@ -620,23 +620,23 @@ class IMAGE_HT_header(bpy.types.Header):
show_paint = sima.show_paint
show_uvedit = sima.show_uvedit
layout.template_header(context)
layout.template_header()
# menus
if context.area.show_menus:
row = layout.row()
row.itemM(context, "IMAGE_MT_view")
row.itemM("IMAGE_MT_view")
if show_uvedit:
row.itemM(context, "IMAGE_MT_select")
row.itemM("IMAGE_MT_select")
# XXX menuname= (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))? "Image*": "Image";
row.itemM(context, "IMAGE_MT_image")
row.itemM("IMAGE_MT_image")
if show_uvedit:
row.itemM(context, "IMAGE_MT_uvs")
row.itemM("IMAGE_MT_uvs")
layout.template_ID(context, sima, "image", new="IMAGE_OT_new", open="IMAGE_OT_open")
layout.template_ID(sima, "image", new="IMAGE_OT_new", open="IMAGE_OT_open")
"""
/* image select */

@ -10,11 +10,11 @@ class OUTLINER_HT_header(bpy.types.Header):
sce = context.scene
layout = self.layout
layout.template_header(context)
layout.template_header()
if context.area.show_menus:
row = layout.row(align=True)
row.itemM(context, "OUTLINER_MT_view")
row.itemM("OUTLINER_MT_view")
row = layout.row()
row.itemR(so, "display_mode", text="")

@ -15,21 +15,21 @@ class SEQUENCER_HT_header(bpy.types.Header):
st = context.space_data
layout = self.layout
layout.template_header(context)
layout.template_header()
if context.area.show_menus:
row = layout.row()
row.itemM(context, "SEQUENCER_MT_view")
row.itemM("SEQUENCER_MT_view")
row.itemR(st, "display_mode")
layout.itemS()
if st.display_mode == 'SEQUENCER':
row.itemM(context, "SEQUENCER_MT_select")
row.itemM(context, "SEQUENCER_MT_marker")
row.itemM(context, "SEQUENCER_MT_add")
row.itemM(context, "SEQUENCER_MT_strip")
row.itemM("SEQUENCER_MT_select")
row.itemM("SEQUENCER_MT_marker")
row.itemM("SEQUENCER_MT_add")
row.itemM("SEQUENCER_MT_strip")
layout.itemS()
row.itemO("SEQUENCER_OT_reload")
else:
@ -151,7 +151,7 @@ class SEQUENCER_MT_add(bpy.types.Menu):
layout.itemO("SEQUENCER_OT_sound_strip_add", text="Sound (Ram)")
layout.item_booleanO("SEQUENCER_OT_sound_strip_add", "hd", True, text="Sound (Streaming)") # FFMPEG ONLY
layout.itemM(context, "SEQUENCER_MT_add_effect")
layout.itemM("SEQUENCER_MT_add_effect")
class SEQUENCER_MT_add_effect(bpy.types.Menu):

@ -14,14 +14,14 @@ class TEXT_HT_header(bpy.types.Header):
text = st.text
layout = self.layout
layout.template_header(context)
layout.template_header()
if context.area.show_menus:
row = layout.row()
row.itemM(context, "TEXT_MT_text")
row.itemM("TEXT_MT_text")
if text:
row.itemM(context, "TEXT_MT_edit")
row.itemM(context, "TEXT_MT_format")
row.itemM("TEXT_MT_edit")
row.itemM("TEXT_MT_format")
if text and text.modified:
row = layout.row()
@ -33,7 +33,7 @@ class TEXT_HT_header(bpy.types.Header):
row.itemR(st, "word_wrap", text="")
row.itemR(st, "syntax_highlight", text="")
layout.template_ID(context, st, "text", new="TEXT_OT_new", open="TEXT_OT_open", unlink="TEXT_OT_unlink")
layout.template_ID(st, "text", new="TEXT_OT_new", open="TEXT_OT_open", unlink="TEXT_OT_unlink")
if text:
row = layout.row()
@ -217,9 +217,9 @@ class TEXT_MT_edit(bpy.types.Menu):
layout.itemS()
layout.itemM(context, "TEXT_MT_edit_view")
layout.itemM(context, "TEXT_MT_edit_select")
layout.itemM(context, "TEXT_MT_edit_markers")
layout.itemM("TEXT_MT_edit_view")
layout.itemM("TEXT_MT_edit_select")
layout.itemM("TEXT_MT_edit_markers")
layout.itemS()
@ -228,7 +228,7 @@ class TEXT_MT_edit(bpy.types.Menu):
layout.itemS()
layout.itemM(context, "TEXT_MT_edit_to3d")
layout.itemM("TEXT_MT_edit_to3d")
bpy.types.register(TEXT_HT_header)
bpy.types.register(TEXT_PT_properties)

@ -189,8 +189,7 @@ void RNA_api_ui_layout(StructRNA *srna)
api_ui_item_common(func);
func= RNA_def_function(srna, "itemM", "uiItemM");
parm= RNA_def_pointer(func, "context", "Context", "", "Current context.");
RNA_def_property_flag(parm, PROP_REQUIRED);
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
api_ui_item_common(func);
parm= RNA_def_string(func, "menu", "", 0, "", "Identifier of the menu.");
RNA_def_property_flag(parm, PROP_REQUIRED);
@ -206,12 +205,10 @@ void RNA_api_ui_layout(StructRNA *srna)
/* templates */
func= RNA_def_function(srna, "template_header", "uiTemplateHeader");
parm= RNA_def_pointer(func, "context", "Context", "", "Current context.");
RNA_def_property_flag(parm, PROP_REQUIRED);
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
func= RNA_def_function(srna, "template_ID", "uiTemplateID");
parm= RNA_def_pointer(func, "context", "Context", "", "Current context.");
RNA_def_property_flag(parm, PROP_REQUIRED);
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
api_ui_item_rna_common(func);
RNA_def_string(func, "new", "", 0, "", "Operator identifier to create a new ID block.");
RNA_def_string(func, "open", "", 0, "", "Operator identifier to open a new ID block.");