diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_space.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 216 |
1 files changed, 183 insertions, 33 deletions
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 2af8a58c137..2a513691762 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -34,6 +34,7 @@ #include "BKE_node.h" #include "BKE_studiolight.h" +#include "ED_spreadsheet.h" #include "ED_text.h" #include "BLI_listbase.h" @@ -3037,14 +3038,6 @@ static void rna_SpaceFileBrowser_browse_mode_update(Main *UNUSED(bmain), ED_area_tag_refresh(area); } -static void rna_SpaceSpreadsheet_pinned_id_set(PointerRNA *ptr, - PointerRNA value, - struct ReportList *UNUSED(reports)) -{ - SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)ptr->data; - sspreadsheet->pinned_id = value.data; -} - static void rna_SpaceSpreadsheet_geometry_component_type_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) @@ -3055,7 +3048,7 @@ static void rna_SpaceSpreadsheet_geometry_component_type_update(Main *UNUSED(bma } } -const EnumPropertyItem *rna_SpaceSpreadsheet_attribute_domain_itemf(bContext *C, +const EnumPropertyItem *rna_SpaceSpreadsheet_attribute_domain_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) @@ -3063,16 +3056,16 @@ const EnumPropertyItem *rna_SpaceSpreadsheet_attribute_domain_itemf(bContext *C, SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)ptr->data; GeometryComponentType component_type = sspreadsheet->geometry_component_type; if (sspreadsheet->object_eval_state == SPREADSHEET_OBJECT_EVAL_STATE_ORIGINAL) { - Object *active_object = CTX_data_active_object(C); - Object *used_object = (sspreadsheet->pinned_id && GS(sspreadsheet->pinned_id->name) == ID_OB) ? - (Object *)sspreadsheet->pinned_id : - active_object; - if (used_object != NULL) { - if (used_object->type == OB_POINTCLOUD) { - component_type = GEO_COMPONENT_TYPE_POINT_CLOUD; - } - else { - component_type = GEO_COMPONENT_TYPE_MESH; + ID *used_id = ED_spreadsheet_get_current_id(sspreadsheet); + if (used_id != NULL) { + if (GS(used_id->name) == ID_OB) { + Object *used_object = (Object *)used_id; + if (used_object->type == OB_POINTCLOUD) { + component_type = GEO_COMPONENT_TYPE_POINT_CLOUD; + } + else { + component_type = GEO_COMPONENT_TYPE_MESH; + } } } } @@ -3111,6 +3104,61 @@ const EnumPropertyItem *rna_SpaceSpreadsheet_attribute_domain_itemf(bContext *C, return item_array; } +static SpreadsheetContext *rna_SpaceSpreadsheet_context_path_append(SpaceSpreadsheet *sspreadsheet, + int type) +{ + SpreadsheetContext *context = ED_spreadsheet_context_new(type); + BLI_addtail(&sspreadsheet->context_path, context); + ED_spreadsheet_context_path_update_tag(sspreadsheet); + WM_main_add_notifier(NC_SPACE | ND_SPACE_SPREADSHEET, NULL); + return context; +} + +static void rna_SpaceSpreadsheet_context_path_clear(SpaceSpreadsheet *sspreadsheet) +{ + ED_spreadsheet_context_path_clear(sspreadsheet); + ED_spreadsheet_context_path_update_tag(sspreadsheet); + WM_main_add_notifier(NC_SPACE | ND_SPACE_SPREADSHEET, NULL); +} + +static StructRNA *rna_spreadsheet_context_refine(PointerRNA *ptr) +{ + SpreadsheetContext *context = ptr->data; + switch (context->type) { + case SPREADSHEET_CONTEXT_OBJECT: + return &RNA_SpreadsheetContextObject; + case SPREADSHEET_CONTEXT_MODIFIER: + return &RNA_SpreadsheetContextModifier; + case SPREADSHEET_CONTEXT_NODE: + return &RNA_SpreadsheetContextNode; + } + BLI_assert_unreachable(); + return NULL; +} + +static void rna_spreadsheet_context_update(Main *UNUSED(bmain), + Scene *UNUSED(scene), + PointerRNA *ptr) +{ + bScreen *screen = (bScreen *)ptr->owner_id; + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + SpaceLink *sl = area->spacedata.first; + if (sl->spacetype == SPACE_SPREADSHEET) { + SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl; + ED_spreadsheet_context_path_update_tag(sspreadsheet); + } + } +} + +static void rna_spreadsheet_set_geometry_node_context(SpaceSpreadsheet *sspreadsheet, + SpaceNode *snode, + bNode *node) +{ + ED_spreadsheet_set_geometry_node_context(sspreadsheet, snode, node); + ED_spreadsheet_context_path_update_tag(sspreadsheet); + WM_main_add_notifier(NC_SPACE | ND_SPACE_SPREADSHEET, NULL); +} + #else static const EnumPropertyItem dt_uv_items[] = { @@ -7338,10 +7386,93 @@ static void rna_def_space_clip(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL); } -static void rna_def_space_spreadsheet(BlenderRNA *brna) +static const EnumPropertyItem spreadsheet_context_type_items[] = { + {SPREADSHEET_CONTEXT_OBJECT, "OBJECT", ICON_NONE, "Object", ""}, + {SPREADSHEET_CONTEXT_MODIFIER, "MODIFIER", ICON_NONE, "Modifier", ""}, + {SPREADSHEET_CONTEXT_NODE, "NODE", ICON_NONE, "Node", ""}, + {0, NULL, 0, NULL, NULL}, +}; + +static void rna_def_space_spreadsheet_context(BlenderRNA *brna) { + StructRNA *srna; PropertyRNA *prop; + + srna = RNA_def_struct(brna, "SpreadsheetContext", NULL); + RNA_def_struct_ui_text(srna, "Spreadsheet Context", "Element of spreadsheet context path"); + RNA_def_struct_refine_func(srna, "rna_spreadsheet_context_refine"); + + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, spreadsheet_context_type_items); + RNA_def_property_ui_text(prop, "Type", "Type of the context"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); +} + +static void rna_def_space_spreadsheet_context_object(BlenderRNA *brna) +{ StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "SpreadsheetContextObject", "SpreadsheetContext"); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, "rna_spreadsheet_context_update"); +} + +static void rna_def_space_spreadsheet_context_modifier(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "SpreadsheetContextModifier", "SpreadsheetContext"); + + prop = RNA_def_property(srna, "modifier_name", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Modifier Name", ""); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, "rna_spreadsheet_context_update"); +} + +static void rna_def_space_spreadsheet_context_node(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "SpreadsheetContextNode", "SpreadsheetContext"); + + prop = RNA_def_property(srna, "node_name", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Node Name", ""); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, "rna_spreadsheet_context_update"); +} + +static void rna_def_space_spreadsheet_context_path(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + PropertyRNA *parm; + FunctionRNA *func; + + RNA_def_property_srna(cprop, "SpreadsheetContextPath"); + srna = RNA_def_struct(brna, "SpreadsheetContextPath", NULL); + RNA_def_struct_sdna(srna, "SpaceSpreadsheet"); + + func = RNA_def_function(srna, "append", "rna_SpaceSpreadsheet_context_path_append"); + RNA_def_function_ui_description(func, "Append a context path element"); + parm = RNA_def_property(func, "type", PROP_ENUM, PROP_NONE); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_property_enum_items(parm, spreadsheet_context_type_items); + parm = RNA_def_pointer( + func, "context", "SpreadsheetContext", "", "Newly created context path element"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "clear", "rna_SpaceSpreadsheet_context_path_clear"); + RNA_def_function_ui_description(func, "Clear entire context path"); +} + +static void rna_def_space_spreadsheet(BlenderRNA *brna) +{ + PropertyRNA *prop, *parm; + StructRNA *srna; + FunctionRNA *func; static const EnumPropertyItem geometry_component_type_items[] = { {GEO_COMPONENT_TYPE_MESH, @@ -7363,35 +7494,44 @@ static void rna_def_space_spreadsheet(BlenderRNA *brna) }; static const EnumPropertyItem object_eval_state_items[] = { - {SPREADSHEET_OBJECT_EVAL_STATE_FINAL, - "FINAL", + {SPREADSHEET_OBJECT_EVAL_STATE_EVALUATED, + "EVALUATED", ICON_NONE, - "Final", - "Use data from object with all modifiers applied"}, + "Evaluated", + "Use data from fully or partially evaluated object"}, {SPREADSHEET_OBJECT_EVAL_STATE_ORIGINAL, "ORIGINAL", ICON_NONE, "Original", "Use data from original object without any modifiers applied"}, - {SPREADSHEET_OBJECT_EVAL_STATE_NODE, - "NODE", - ICON_NONE, - "Node", - "Use data from the first geometry output of the node tagged for preview"}, {0, NULL, 0, NULL, NULL}, }; + rna_def_space_spreadsheet_context(brna); + rna_def_space_spreadsheet_context_object(brna); + rna_def_space_spreadsheet_context_modifier(brna); + rna_def_space_spreadsheet_context_node(brna); + srna = RNA_def_struct(brna, "SpaceSpreadsheet", "Space"); RNA_def_struct_ui_text(srna, "Space Spreadsheet", "Spreadsheet space data"); rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_FOOTER)); - prop = RNA_def_property(srna, "pinned_id", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceSpreadsheet_pinned_id_set", NULL, NULL); - RNA_def_property_ui_text(prop, "Pinned ID", "Data-block whose values are displayed"); + prop = RNA_def_property(srna, "is_pinned", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SPREADSHEET_FLAG_PINNED); + RNA_def_property_ui_text(prop, "Is Pinned", "Context path is pinned"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, NULL); + prop = RNA_def_property(srna, "display_context_path_collapsed", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SPREADSHEET_FLAG_CONTEXT_PATH_COLLAPSED); + RNA_def_property_ui_text(prop, "Display Context Path Collapsed", ""); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, NULL); + + prop = RNA_def_property(srna, "context_path", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "SpreadsheetContext"); + RNA_def_property_ui_text(prop, "Context Path", "Context path to the data being displayed"); + rna_def_space_spreadsheet_context_path(brna, prop); + prop = RNA_def_property(srna, "show_only_selected", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "filter_flag", SPREADSHEET_FILTER_SELECTED_ONLY); RNA_def_property_ui_text( @@ -7416,6 +7556,16 @@ static void rna_def_space_spreadsheet(BlenderRNA *brna) RNA_def_property_enum_items(prop, object_eval_state_items); RNA_def_property_ui_text(prop, "Object Evaluation State", ""); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, NULL); + + func = RNA_def_function( + srna, "set_geometry_node_context", "rna_spreadsheet_set_geometry_node_context"); + RNA_def_function_ui_description( + func, "Update context_path to point to a specific node in a node editor"); + parm = RNA_def_pointer( + func, "node_editor", "SpaceNodeEditor", "", "Editor to take the context from"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_pointer(func, "node", "Node", "", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); } void RNA_def_space(BlenderRNA *brna) |