diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_screen.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_screen.c | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index 97b89937081..61ec6339ce8 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -83,6 +83,12 @@ static int rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr)) return wm ? (ED_screen_animation_playing(wm) != NULL) : 0; } +static int rna_region_alignment_get(PointerRNA *ptr) +{ + ARegion *region = ptr->data; + return (region->alignment & ~RGN_SPLIT_PREV); +} + static void rna_Screen_layout_name_get(PointerRNA *ptr, char *value) { const bScreen *screen = ptr->data; @@ -130,10 +136,22 @@ static int rna_Screen_fullscreen_get(PointerRNA *ptr) /* UI compatible list: should not be needed, but for now we need to keep EMPTY * at least in the static version of this enum for python scripts. */ static const EnumPropertyItem *rna_Area_type_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), - PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) + PropertyRNA *UNUSED(prop), bool *r_free) { + EnumPropertyItem *item = NULL; + int totitem = 0; + /* +1 to skip SPACE_EMPTY */ - return rna_enum_space_type_items + 1; + for (const EnumPropertyItem *item_from = rna_enum_space_type_items + 1; item_from->identifier; item_from++) { + if (ELEM(item_from->value, SPACE_TOPBAR)) { + continue; + } + RNA_enum_item_add(&item, &totitem, item_from); + } + RNA_enum_item_end(&item, &totitem); + *r_free = true; + + return item; } static int rna_Area_type_get(PointerRNA *ptr) @@ -145,6 +163,13 @@ static int rna_Area_type_get(PointerRNA *ptr) static void rna_Area_type_set(PointerRNA *ptr, int value) { + if (ELEM(value, SPACE_TOPBAR)) { + /* Special case: An area can not be set to show the top-bar editor (or + * other global areas). However it should still be possible to identify + * its type from Python. */ + return; + } + ScrArea *sa = (ScrArea *)ptr->data; sa->butspacetype = value; } @@ -329,6 +354,19 @@ static void rna_def_region(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; + static const EnumPropertyItem alignment_types[] = { + {RGN_ALIGN_NONE, "NONE", 0, "None", "Don't use any fixed alignment, fill available space"}, + {RGN_ALIGN_TOP, "TOP", 0, "Top", ""}, + {RGN_ALIGN_BOTTOM, "BOTTOM", 0, "Bottom", ""}, + {RGN_ALIGN_LEFT, "LEFT", 0, "Left", ""}, + {RGN_ALIGN_RIGHT, "RIGHT", 0, "Right", ""}, + {RGN_ALIGN_HSPLIT, "HORIZONTAL_SPLIT", 0, "Horizontal Split", ""}, + {RGN_ALIGN_VSPLIT, "VERTICAL_SPLIT", 0, "Vertical Split", ""}, + {RGN_ALIGN_FLOAT, "FLOAT", 0, "Float", "Region floats on screen, doesn't use any fixed alignment"}, + {RGN_ALIGN_QSPLIT, "QUAD_SPLIT", 0, "Quad Split", "Region is split horizontally and vertically"}, + {0, NULL, 0, NULL, NULL} + }; + srna = RNA_def_struct(brna, "Region", NULL); RNA_def_struct_ui_text(srna, "Region", "Region in a subdivided screen area"); RNA_def_struct_sdna(srna, "ARegion"); @@ -365,6 +403,12 @@ static void rna_def_region(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_ui_text(prop, "View2D", "2D view of the region"); + prop = RNA_def_property(srna, "alignment", PROP_ENUM, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_enum_items(prop, alignment_types); + RNA_def_property_enum_funcs(prop, "rna_region_alignment_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Alignment", "Alignment of the region within the area"); + RNA_def_function(srna, "tag_redraw", "ED_region_tag_redraw"); } |