[Bf-blender-cvs] [90220334126] temp-lanpr-cleanup: UI: Replace big options button in file browser

Julian Eisel noreply at git.blender.org
Wed Sep 25 03:49:22 CEST 2019


Commit: 902203341263e65c384414758ae41a57c8d0a74d
Author: Julian Eisel
Date:   Fri Sep 20 17:36:38 2019 +0200
Branches: temp-lanpr-cleanup
https://developer.blender.org/rB902203341263e65c384414758ae41a57c8d0a74d

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.

===================================================================

M	release/scripts/startup/bl_ui/space_filebrowser.py
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/editors/space_file/space_file.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index 054ed93d6d2..3279271b5e8 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -328,36 +328,6 @@ class FILEBROWSER_PT_advanced_filter(Panel):
                 col.prop(params, "filter_id")
 
 
-class FILEBROWSER_PT_options_toggle(Panel):
-    bl_space_type = 'FILE_BROWSER'
-    bl_region_type = 'TOOLS'
-    bl_label = "Options Toggle"
-    bl_options = {'HIDE_HEADER'}
-
-    @classmethod
-    def poll(cls, context):
-        sfile = context.space_data
-        return context.region.alignment == 'BOTTOM' and sfile.active_operator
-
-    def is_option_region_visible(self, context):
-        for region in context.area.regions:
-            if region.type == 'TOOL_PROPS' and region.width <= 1:
-                return False
-
-        return True
-
-    def draw(self, context):
-        layout = self.layout
-        label = "Hide Options" if self.is_option_region_visible(
-            context) else "Options"
-
-        layout.scale_x = 1.3
-        layout.scale_y = 1.3
-
-        layout.operator("screen.region_toggle",
-                        text=label).region_type = 'TOOL_PROPS'
-
-
 class FILEBROWSER_PT_directory_path(Panel):
     bl_space_type = 'FILE_BROWSER'
     bl_region_type = 'UI'
@@ -372,6 +342,16 @@ class FILEBROWSER_PT_directory_path(Panel):
 
         return True
 
+    def is_option_region_visible(self, context, space):
+        if not space.active_operator:
+            return False
+
+        for region in context.area.regions:
+            if region.type == 'TOOL_PROPS' and region.width <= 1:
+                return False
+
+        return True
+
     def draw(self, context):
         layout = self.layout
         space = context.space_data
@@ -414,6 +394,14 @@ class FILEBROWSER_PT_directory_path(Panel):
             icon_only=True,
         )
 
+        if space.active_operator:
+            row.operator(
+                "screen.region_toggle",
+                text="",
+                icon='PREFERENCES',
+                depress=self.is_option_region_visible(context, space)
+            ).region_type = 'TOOL_PROPS'
+
 
 class FILEBROWSER_MT_view(Menu):
     bl_label = "View"
@@ -500,7 +488,6 @@ classes = (
     FILEBROWSER_PT_bookmarks_recents,
     FILEBROWSER_PT_advanced_filter,
     FILEBROWSER_PT_directory_path,
-    FILEBROWSER_PT_options_toggle,
     FILEBROWSER_MT_view,
     FILEBROWSER_MT_select,
     FILEBROWSER_MT_context_menu,
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 84adccde37b..3f832d54391 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -3909,11 +3909,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;
   }



More information about the Bf-blender-cvs mailing list