Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_workspace.c
| Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| static void rna_window_update_all(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) | |||||
| { | |||||
| WM_main_add_notifier(NC_WINDOW, NULL); | |||||
| } | |||||
| void rna_workspace_screens_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) | void rna_workspace_screens_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) | ||||
| { | { | ||||
| WorkSpace *workspace = ptr->id.data; | WorkSpace *workspace = ptr->id.data; | ||||
| rna_iterator_listbase_begin(iter, BKE_workspace_layouts_get(workspace), NULL); | rna_iterator_listbase_begin(iter, BKE_workspace_layouts_get(workspace), NULL); | ||||
| } | } | ||||
| static PointerRNA rna_workspace_screens_item_get(CollectionPropertyIterator *iter) | static PointerRNA rna_workspace_screens_item_get(CollectionPropertyIterator *iter) | ||||
| Show All 11 Lines | |||||
| } | } | ||||
| static PointerRNA rna_workspace_transform_orientations_item_get(CollectionPropertyIterator *iter) | static PointerRNA rna_workspace_transform_orientations_item_get(CollectionPropertyIterator *iter) | ||||
| { | { | ||||
| TransformOrientation *transform_orientation = rna_iterator_listbase_get(iter); | TransformOrientation *transform_orientation = rna_iterator_listbase_get(iter); | ||||
| return rna_pointer_inherit_refine(&iter->parent, &RNA_TransformOrientation, transform_orientation); | return rna_pointer_inherit_refine(&iter->parent, &RNA_TransformOrientation, transform_orientation); | ||||
| } | } | ||||
| /* workspace.ui_tags */ | |||||
| static WorkSpaceUITag *rna_WorkSpace_ui_tags_new( | |||||
| WorkSpace *workspace, const char *name) | |||||
| { | |||||
| WorkSpaceUITag *wstag = MEM_callocN(sizeof(*wstag), __func__); | |||||
| BLI_addtail(&workspace->ui_tags, wstag); | |||||
| BLI_strncpy(wstag->name, name, sizeof(wstag->name)); | |||||
| WM_main_add_notifier(NC_WINDOW, NULL); | |||||
| return wstag; | |||||
| } | |||||
| static void rna_WorkSpace_ui_tags_remove( | |||||
| WorkSpace *workspace, ReportList *reports, PointerRNA *wstag_ptr) | |||||
| { | |||||
| WorkSpaceUITag *wstag = wstag_ptr->data; | |||||
| if (BLI_remlink_safe(&workspace->ui_tags, wstag) == false) { | |||||
| BKE_reportf(reports, RPT_ERROR, | |||||
| "WorkSpaceUITag '%s' not in workspace '%s'", | |||||
| wstag->name, workspace->id.name + 2); | |||||
| return; | |||||
| } | |||||
| RNA_POINTER_INVALIDATE(wstag_ptr); | |||||
| WM_main_add_notifier(NC_WINDOW, NULL); | |||||
| } | |||||
| static void rna_WorkSpace_ui_tags_clear( | |||||
| WorkSpace *workspace) | |||||
| { | |||||
| BLI_freelistN(&workspace->ui_tags); | |||||
| WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, workspace); | |||||
| } | |||||
| #else /* RNA_RUNTIME */ | #else /* RNA_RUNTIME */ | ||||
| static void rna_def_workspace_ui_tag(BlenderRNA *brna) | |||||
| { | |||||
| StructRNA *srna; | |||||
| PropertyRNA *prop; | |||||
| srna = RNA_def_struct(brna, "WorkSpaceUITag", NULL); | |||||
| RNA_def_struct_sdna(srna, "WorkSpaceUITag"); | |||||
| RNA_def_struct_clear_flag(srna, STRUCT_UNDO); | |||||
| RNA_def_struct_ui_text(srna, "Work Space UI Tag", ""); | |||||
| prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); | |||||
| RNA_def_property_ui_text(prop, "Name", ""); | |||||
| RNA_def_struct_name_property(srna, prop); | |||||
| } | |||||
| static void rna_def_workspace_ui_tags(BlenderRNA *brna, PropertyRNA *cprop) | |||||
| { | |||||
| StructRNA *srna; | |||||
| FunctionRNA *func; | |||||
| PropertyRNA *parm; | |||||
| RNA_def_property_srna(cprop, "WorkSpaceUITags"); | |||||
| srna = RNA_def_struct(brna, "WorkSpaceUITags", NULL); | |||||
| RNA_def_struct_sdna(srna, "WorkSpace"); | |||||
| RNA_def_struct_ui_text(srna, "WorkSpace UI Tags", ""); | |||||
| /* add ui_tag */ | |||||
| func = RNA_def_function(srna, "new", "rna_WorkSpace_ui_tags_new"); | |||||
| RNA_def_function_ui_description(func, "Add ui tag"); | |||||
| parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the tag"); | |||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | |||||
| /* return type */ | |||||
| parm = RNA_def_pointer(func, "ui_tag", "WorkSpaceUITag", "", ""); | |||||
| RNA_def_function_return(func, parm); | |||||
| /* remove ui_tag */ | |||||
| func = RNA_def_function(srna, "remove", "rna_WorkSpace_ui_tags_remove"); | |||||
| RNA_def_function_flag(func, FUNC_USE_REPORTS); | |||||
| RNA_def_function_ui_description(func, "Remove ui tag"); | |||||
| /* ui_tag to remove */ | |||||
| parm = RNA_def_pointer(func, "ui_tag", "WorkSpaceUITag", "", "Tag to remove"); | |||||
| RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); | |||||
| RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); | |||||
| /* clear all modifiers */ | |||||
| func = RNA_def_function(srna, "clear", "rna_WorkSpace_ui_tags_clear"); | |||||
| RNA_def_function_ui_description(func, "Remove all tags"); | |||||
| } | |||||
| static void rna_def_workspace(BlenderRNA *brna) | static void rna_def_workspace(BlenderRNA *brna) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| srna = RNA_def_struct(brna, "WorkSpace", "ID"); | srna = RNA_def_struct(brna, "WorkSpace", "ID"); | ||||
| RNA_def_struct_sdna(srna, "WorkSpace"); | RNA_def_struct_sdna(srna, "WorkSpace"); | ||||
| RNA_def_struct_ui_text(srna, "Workspace", "Workspace data-block, defining the working environment for the user"); | RNA_def_struct_ui_text(srna, "Workspace", "Workspace data-block, defining the working environment for the user"); | ||||
| Show All 24 Lines | static void rna_def_workspace(BlenderRNA *brna) | ||||
| prop = RNA_def_property(srna, "orientations", PROP_COLLECTION, PROP_NONE); | prop = RNA_def_property(srna, "orientations", PROP_COLLECTION, PROP_NONE); | ||||
| RNA_def_property_collection_sdna(prop, NULL, "transform_orientations", NULL); | RNA_def_property_collection_sdna(prop, NULL, "transform_orientations", NULL); | ||||
| RNA_def_property_struct_type(prop, "TransformOrientation"); | RNA_def_property_struct_type(prop, "TransformOrientation"); | ||||
| RNA_def_property_collection_funcs(prop, "rna_workspace_transform_orientations_begin", NULL, NULL, | RNA_def_property_collection_funcs(prop, "rna_workspace_transform_orientations_begin", NULL, NULL, | ||||
| "rna_workspace_transform_orientations_item_get", NULL, NULL, NULL, NULL); | "rna_workspace_transform_orientations_item_get", NULL, NULL, NULL, NULL); | ||||
| RNA_def_property_ui_text(prop, "Transform Orientations", ""); | RNA_def_property_ui_text(prop, "Transform Orientations", ""); | ||||
| prop = RNA_def_property(srna, "ui_tags", PROP_COLLECTION, PROP_NONE); | |||||
| RNA_def_property_struct_type(prop, "WorkSpaceUITag"); | |||||
| RNA_def_property_ui_text(prop, "UI Tags", ""); | |||||
| rna_def_workspace_ui_tags(brna, prop); | |||||
| prop = RNA_def_property(srna, "object_mode", PROP_ENUM, PROP_NONE); | prop = RNA_def_property(srna, "object_mode", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_enum_items(prop, rna_enum_object_mode_items); | RNA_def_property_enum_items(prop, rna_enum_object_mode_items); | ||||
| RNA_def_property_ui_text(prop, "Mode", "Object interaction mode used in this window"); | RNA_def_property_ui_text(prop, "Mode", "Object interaction mode used in this window"); | ||||
| /* View Render */ | /* View Render */ | ||||
| prop = RNA_def_property(srna, "view_render", PROP_POINTER, PROP_NONE); | prop = RNA_def_property(srna, "view_render", PROP_POINTER, PROP_NONE); | ||||
| RNA_def_property_flag(prop, PROP_NEVER_NULL); | RNA_def_property_flag(prop, PROP_NEVER_NULL); | ||||
| RNA_def_property_struct_type(prop, "ViewRenderSettings"); | RNA_def_property_struct_type(prop, "ViewRenderSettings"); | ||||
| RNA_def_property_ui_text(prop, "View Render", ""); | RNA_def_property_ui_text(prop, "View Render", ""); | ||||
| /* Flags */ | /* Flags */ | ||||
| prop = RNA_def_property(srna, "use_scene_settings", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_scene_settings", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "flags", WORKSPACE_USE_SCENE_SETTINGS); | RNA_def_property_boolean_sdna(prop, NULL, "flags", WORKSPACE_USE_SCENE_SETTINGS); | ||||
| RNA_def_property_ui_text(prop, "Scene Settings", | RNA_def_property_ui_text(prop, "Scene Settings", | ||||
| "Use scene settings instead of workspace settings"); | "Use scene settings instead of workspace settings"); | ||||
| RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, NULL); | RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, NULL); | ||||
| prop = RNA_def_property(srna, "use_ui_tags", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "flags", WORKSPACE_USE_UI_TAGS); | |||||
| RNA_def_property_ui_text(prop, "Use UI Tags", | |||||
| "Filter the UI by tags"); | |||||
| RNA_def_property_update(prop, 0, "rna_window_update_all"); | |||||
| } | } | ||||
| static void rna_def_transform_orientation(BlenderRNA *brna) | static void rna_def_transform_orientation(BlenderRNA *brna) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| srna = RNA_def_struct(brna, "TransformOrientation", NULL); | srna = RNA_def_struct(brna, "TransformOrientation", NULL); | ||||
| prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); | prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); | ||||
| RNA_def_property_float_sdna(prop, NULL, "mat"); | RNA_def_property_float_sdna(prop, NULL, "mat"); | ||||
| RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_3x3); | RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_3x3); | ||||
| RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); | RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); | ||||
| prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); | prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); | ||||
| RNA_def_struct_name_property(srna, prop); | RNA_def_struct_name_property(srna, prop); | ||||
| RNA_def_property_ui_text(prop, "Name", "Name of the custom transform orientation"); | RNA_def_property_ui_text(prop, "Name", "Name of the custom transform orientation"); | ||||
| RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); | RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); | ||||
| } | } | ||||
| void RNA_def_workspace(BlenderRNA *brna) | void RNA_def_workspace(BlenderRNA *brna) | ||||
| { | { | ||||
| rna_def_workspace_ui_tag(brna); | |||||
| rna_def_workspace(brna); | rna_def_workspace(brna); | ||||
| rna_def_transform_orientation(brna); | rna_def_transform_orientation(brna); | ||||
| } | } | ||||
| #endif /* RNA_RUNTIME */ | #endif /* RNA_RUNTIME */ | ||||