forked from bartvdbraak/blender
move dopesheet UI template from C to python
This commit is contained in:
parent
c15c223ccd
commit
9d2b1af0a1
@ -21,6 +21,53 @@
|
||||
import bpy
|
||||
|
||||
|
||||
def dopesheet_filter(layout, context):
|
||||
dopesheet = context.space_data.dopesheet
|
||||
is_nla = context.area.type == 'NLA_EDITOR'
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(dopesheet, "show_only_selected", text="")
|
||||
row.prop(dopesheet, "show_hidden", text="")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(dopesheet, "show_transforms", text="")
|
||||
|
||||
if is_nla:
|
||||
row.prop(dopesheet, "show_missing_nla", text="")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(dopesheet, "show_scenes", text="")
|
||||
row.prop(dopesheet, "show_worlds", text="")
|
||||
row.prop(dopesheet, "show_nodes", text="")
|
||||
|
||||
if bpy.data.meshes:
|
||||
row.prop(dopesheet, "show_meshes", text="")
|
||||
if bpy.data.shape_keys:
|
||||
row.prop(dopesheet, "show_shapekeys", text="")
|
||||
if bpy.data.materials:
|
||||
row.prop(dopesheet, "show_materials", text="")
|
||||
if bpy.data.lamps:
|
||||
row.prop(dopesheet, "show_lamps", text="")
|
||||
if bpy.data.textures:
|
||||
row.prop(dopesheet, "show_textures", text="")
|
||||
if bpy.data.cameras:
|
||||
row.prop(dopesheet, "show_cameras", text="")
|
||||
if bpy.data.curves:
|
||||
row.prop(dopesheet, "show_curves", text="")
|
||||
if bpy.data.metaballs:
|
||||
row.prop(dopesheet, "show_metaballs", text="")
|
||||
if bpy.data.armatures:
|
||||
row.prop(dopesheet, "show_armatures", text="")
|
||||
if bpy.data.particles:
|
||||
row.prop(dopesheet, "show_particles", text="")
|
||||
|
||||
if bpy.data.groups:
|
||||
row = layout.row(align=True)
|
||||
row.prop(dopesheet, "show_only_group_objects", text="")
|
||||
if dopesheet.show_only_group_objects:
|
||||
row.prop(dopesheet, "filter_group", text="")
|
||||
|
||||
|
||||
class DOPESHEET_HT_header(bpy.types.Header):
|
||||
bl_space_type = 'DOPESHEET_EDITOR'
|
||||
|
||||
@ -51,7 +98,8 @@ class DOPESHEET_HT_header(bpy.types.Header):
|
||||
layout.prop(st.dopesheet, "show_summary", text="Summary")
|
||||
|
||||
if st.mode == 'DOPESHEET':
|
||||
layout.template_dopesheet_filter(st.dopesheet)
|
||||
dopesheet_filter(layout, context)
|
||||
|
||||
elif st.mode == 'ACTION':
|
||||
layout.template_ID(st, "action", new="action.new")
|
||||
|
||||
|
@ -25,6 +25,8 @@ class GRAPH_HT_header(bpy.types.Header):
|
||||
bl_space_type = 'GRAPH_EDITOR'
|
||||
|
||||
def draw(self, context):
|
||||
from space_dopesheet import dopesheet_filter
|
||||
|
||||
layout = self.layout
|
||||
|
||||
st = context.space_data
|
||||
@ -42,7 +44,7 @@ class GRAPH_HT_header(bpy.types.Header):
|
||||
|
||||
layout.prop(st, "mode", text="")
|
||||
|
||||
layout.template_dopesheet_filter(st.dopesheet)
|
||||
dopesheet_filter(layout, context)
|
||||
|
||||
layout.prop(st, "auto_snap", text="")
|
||||
layout.prop(st, "pivot_point", text="", icon_only=True)
|
||||
|
@ -25,6 +25,8 @@ class NLA_HT_header(bpy.types.Header):
|
||||
bl_space_type = 'NLA_EDITOR'
|
||||
|
||||
def draw(self, context):
|
||||
from space_dopesheet import dopesheet_filter
|
||||
|
||||
layout = self.layout
|
||||
|
||||
st = context.space_data
|
||||
@ -40,7 +42,7 @@ class NLA_HT_header(bpy.types.Header):
|
||||
sub.menu("NLA_MT_edit")
|
||||
sub.menu("NLA_MT_add")
|
||||
|
||||
layout.template_dopesheet_filter(st.dopesheet)
|
||||
dopesheet_filter(layout, context)
|
||||
|
||||
layout.prop(st, "auto_snap", text="")
|
||||
|
||||
|
@ -69,68 +69,6 @@ void uiTemplateHeader(uiLayout *layout, bContext *C, int menus)
|
||||
else ED_area_header_switchbutton(C, block, 0);
|
||||
}
|
||||
|
||||
/********************** DopeSheet Filter Template *************************/
|
||||
|
||||
void uiTemplateDopeSheetFilter(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
||||
{
|
||||
Main *mainptr= CTX_data_main(C);
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
uiLayout *row= layout;
|
||||
short nlaActive= ((sa) && (sa->spacetype==SPACE_NLA));
|
||||
|
||||
/* most 'generic' filtering options */
|
||||
row= uiLayoutRow(layout, 1);
|
||||
|
||||
uiItemR(row, ptr, "show_only_selected", 0, "", 0);
|
||||
uiItemR(row, ptr, "show_hidden", 0, "", 0);
|
||||
|
||||
/* object-level filtering options */
|
||||
row= uiLayoutRow(layout, 1);
|
||||
uiItemR(row, ptr, "show_transforms", 0, "", 0);
|
||||
|
||||
if (nlaActive)
|
||||
uiItemR(row, ptr, "show_missing_nla", 0, "", 0);
|
||||
|
||||
/* datatype based - only available datatypes are shown */
|
||||
row= uiLayoutRow(layout, 1);
|
||||
|
||||
uiItemR(row, ptr, "show_scenes", 0, "", 0);
|
||||
uiItemR(row, ptr, "show_worlds", 0, "", 0);
|
||||
uiItemR(row, ptr, "show_nodes", 0, "", 0);
|
||||
|
||||
if (mainptr && mainptr->mesh.first)
|
||||
uiItemR(row, ptr, "show_meshes", 0, "", 0);
|
||||
if (mainptr && mainptr->key.first)
|
||||
uiItemR(row, ptr, "show_shapekeys", 0, "", 0);
|
||||
if (mainptr && mainptr->mat.first)
|
||||
uiItemR(row, ptr, "show_materials", 0, "", 0);
|
||||
if (mainptr && mainptr->lamp.first)
|
||||
uiItemR(row, ptr, "show_lamps", 0, "", 0);
|
||||
if (mainptr && mainptr->tex.first)
|
||||
uiItemR(row, ptr, "show_textures", 0, "", 0);
|
||||
if (mainptr && mainptr->camera.first)
|
||||
uiItemR(row, ptr, "show_cameras", 0, "", 0);
|
||||
if (mainptr && mainptr->curve.first)
|
||||
uiItemR(row, ptr, "show_curves", 0, "", 0);
|
||||
if (mainptr && mainptr->mball.first)
|
||||
uiItemR(row, ptr, "show_metaballs", 0, "", 0);
|
||||
if (mainptr && mainptr->armature.first)
|
||||
uiItemR(row, ptr, "show_armatures", 0, "", 0);
|
||||
if (mainptr && mainptr->particle.first)
|
||||
uiItemR(row, ptr, "show_particles", 0, "", 0);
|
||||
|
||||
/* group-based filtering (only when groups are available */
|
||||
if (mainptr && mainptr->group.first) {
|
||||
row= uiLayoutRow(layout, 1);
|
||||
|
||||
uiItemR(row, ptr, "show_only_group_objects", 0, "", 0);
|
||||
|
||||
/* if enabled, show the group selection field too */
|
||||
if (RNA_boolean_get(ptr, "show_only_group_objects"))
|
||||
uiItemR(row, ptr, "filter_group", 0, "", 0);
|
||||
}
|
||||
}
|
||||
|
||||
/********************** Search Callbacks *************************/
|
||||
|
||||
typedef struct TemplateID {
|
||||
|
@ -147,13 +147,11 @@ static void rna_Main_camera_begin(CollectionPropertyIterator *iter, PointerRNA *
|
||||
rna_iterator_listbase_begin(iter, &bmain->camera, NULL);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void rna_Main_key_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
||||
{
|
||||
Main *bmain= (Main*)ptr->data;
|
||||
rna_iterator_listbase_begin(iter, &bmain->key, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void rna_Main_world_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
||||
{
|
||||
@ -292,7 +290,7 @@ void RNA_def_main(BlenderRNA *brna)
|
||||
{"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks.", RNA_def_main_brushes},
|
||||
{"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks.", RNA_def_main_worlds},
|
||||
{"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks.", RNA_def_main_groups},
|
||||
/* {"keys", "Key", "rna_Main_key_begin", "Keys", "Key datablocks.", NULL}, */
|
||||
{"shape_keys", "Key", "rna_Main_key_begin", "Keys", "Key datablocks.", NULL},
|
||||
{"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks (DEPRECATED).", NULL},
|
||||
{"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks.", RNA_def_main_texts},
|
||||
{"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound datablocks.", RNA_def_main_sounds},
|
||||
|
@ -270,11 +270,6 @@ void RNA_api_ui_layout(StructRNA *srna)
|
||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
||||
RNA_def_boolean(func, "menus", 1, "", "The header has menus, and should show menu expander.");
|
||||
|
||||
func= RNA_def_function(srna, "template_dopesheet_filter", "uiTemplateDopeSheetFilter");
|
||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
||||
parm= RNA_def_pointer(func, "dopesheet", "DopeSheet", "", "DopeSheet settings holding filter options.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
|
||||
|
||||
func= RNA_def_function(srna, "template_ID", "uiTemplateID");
|
||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
||||
api_ui_item_rna_common(func);
|
||||
|
Loading…
Reference in New Issue
Block a user