From adfe68e2025b6d85312361a3d1b4d1397c1ce2a9 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 20 Sep 2019 17:36:38 +0200 Subject: UI: Replace big options button in file browser The big options button in the lower left is now gone, it's replaced by a smaller icon toggle button in the upper right. That means I could also remove code for the region we had just for this button. I also added versioning code for the removal, to make sure the region is removed cleanly when reading old files. --- source/blender/blenloader/intern/versioning_280.c | 15 ++++++++--- source/blender/editors/space_file/space_file.c | 32 +++-------------------- 2 files changed, 15 insertions(+), 32 deletions(-) (limited to 'source') diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 257f43f4b9f..ff088d83358 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -3879,11 +3879,20 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } else if (sl->spacetype == SPACE_FILE) { ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + ARegion *ar_tools = do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOLS); - if (!do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOLS)) { + if (ar_tools) { + ARegion *ar_next = ar_tools->next; + + /* We temporarily had two tools regions, get rid of the second one. */ + if (ar_next && ar_next->regiontype == RGN_TYPE_TOOLS) { + do_versions_remove_region(regionbase, RGN_TYPE_TOOLS); + } + } + else { ARegion *ar_ui = do_versions_find_region(regionbase, RGN_TYPE_UI); - ARegion *ar_tools = do_versions_add_region(RGN_TYPE_TOOLS, - "versioning file tools region"); + + ar_tools = do_versions_add_region(RGN_TYPE_TOOLS, "versioning file tools region"); BLI_insertlinkafter(regionbase, ar_ui, ar_tools); ar_tools->alignment = RGN_ALIGN_LEFT; } diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 141036f856a..2f0e796d500 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -55,25 +55,6 @@ #include "filelist.h" #include "GPU_framebuffer.h" -static ARegion *file_tools_options_toggle_region_ensure(ScrArea *sa, ARegion *ar_prev) -{ - ARegion *ar; - - if ((ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS)) != NULL && (ar->next != NULL) && - (ar->next->regiontype == RGN_TYPE_TOOLS)) { - BLI_assert(ar->alignment == (RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV)); - return ar; - } - - ar = MEM_callocN(sizeof(ARegion), "options toggle region for file"); - BLI_insertlinkafter(&sa->regionbase, ar_prev, ar); - ar->regiontype = RGN_TYPE_TOOLS; - ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; - ar->flag |= RGN_FLAG_DYNAMIC_SIZE; - - return ar; -} - static ARegion *file_execute_region_ensure(ScrArea *sa, ARegion *ar_prev) { ARegion *ar; @@ -138,7 +119,7 @@ static SpaceLink *file_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen ar->regiontype = RGN_TYPE_TOOLS; ar->alignment = RGN_ALIGN_LEFT; - /* Options toggle, tool props and execute region are added as needed, see file_refresh(). */ + /* Tool props and execute region are added as needed, see file_refresh(). */ /* main region */ ar = MEM_callocN(sizeof(ARegion), "main region for file"); @@ -258,16 +239,14 @@ static void file_ensure_valid_region_state(bContext *C, SpaceFile *sfile, FileSelectParams *params) { - ARegion *ar_tools_upper = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS); + ARegion *ar_tools = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS); ARegion *ar_props = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS); ARegion *ar_execute = BKE_area_find_region_type(sa, RGN_TYPE_EXECUTE); - ARegion *ar_tools_lower; bool needs_init = false; /* To avoid multiple ED_area_initialize() calls. */ /* If there's an file-operation, ensure we have the option and execute region */ if (sfile->op && (ar_props == NULL)) { - ar_tools_lower = file_tools_options_toggle_region_ensure(sa, ar_tools_upper); - ar_execute = file_execute_region_ensure(sa, ar_tools_lower); + ar_execute = file_execute_region_ensure(sa, ar_tools); ar_props = file_tool_props_region_ensure(sa, ar_execute); if (params->flag & FILE_HIDE_TOOL_PROPS) { @@ -281,15 +260,10 @@ static void file_ensure_valid_region_state(bContext *C, } /* If there's _no_ file-operation, ensure we _don't_ have the option and execute region */ else if ((sfile->op == NULL) && (ar_props != NULL)) { - ar_tools_lower = ar_tools_upper->next; - BLI_assert(ar_execute != NULL); - BLI_assert(ar_tools_lower != NULL); - BLI_assert(ar_tools_lower->regiontype == RGN_TYPE_TOOLS); ED_region_remove(C, sa, ar_props); ED_region_remove(C, sa, ar_execute); - ED_region_remove(C, sa, ar_tools_lower); needs_init = true; } -- cgit v1.2.3