Commit: eb9055a572c391e707e6a300067740d7ad4e0197
Author: Hans Goudey
Date:   Wed Aug 19 11:37:21 2020 -0400
Branches: master
https://developer.blender.org/rBeb9055a572c391e707e6a300067740d7ad4e0197

UI: Remove panel X axis closing code

Horizontal panel alignment hasn't been used for years, and we have no
plans to use it in the future. It adds a fair amount of complexity to
the panel code which makes adding features take longer.

This code removes the X closing flag, and all of the logic / variables
unused without it.

This commit includes a file subversion bump.

Differential Revision: https://developer.blender.org/D8601

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

M       source/blender/blenkernel/BKE_blender_version.h
M       source/blender/blenloader/intern/versioning_290.c
M       source/blender/blenloader/intern/versioning_userdef.c
M       source/blender/editors/include/UI_interface.h
M       source/blender/editors/interface/interface_panel.c
M       source/blender/editors/screen/area.c
M       source/blender/makesdna/DNA_screen_types.h

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

diff --git a/source/blender/blenkernel/BKE_blender_version.h 
b/source/blender/blenkernel/BKE_blender_version.h
index 231cd0e53c5..5ad903a0119 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -39,7 +39,7 @@ extern "C" {
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 0
+#define BLENDER_FILE_SUBVERSION 1
 
 /* Minimum Blender version that supports reading file written with the current
  * version. Older Blender versions will test this and show a warning if the 
file
diff --git a/source/blender/blenloader/intern/versioning_290.c 
b/source/blender/blenloader/intern/versioning_290.c
index bc13e3b3a39..00214c16eb0 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -208,6 +208,17 @@ void do_versions_after_linking_290(Main *bmain, ReportList 
*UNUSED(reports))
     }
   }
 
+  if (!MAIN_VERSION_ATLEAST(bmain, 291, 1)) {
+    LISTBASE_FOREACH (Collection *, collection, &bmain->collections) {
+      if (BKE_collection_cycles_fix(bmain, collection)) {
+        printf(
+            "WARNING: Cycle detected in collection '%s', fixed as best as 
possible.\n"
+            "You may have to reconstruct your View Layers...\n",
+            collection->id.name);
+      }
+    }
+  }
+
   /**
    * Versioning code until next subversion bump goes here.
    *
@@ -219,18 +230,26 @@ void do_versions_after_linking_290(Main *bmain, 
ReportList *UNUSED(reports))
    * \note Keep this message at the bottom of the function.
    */
   {
-    LISTBASE_FOREACH (Collection *, collection, &bmain->collections) {
-      if (BKE_collection_cycles_fix(bmain, collection)) {
-        printf(
-            "WARNING: Cycle detected in collection '%s', fixed as best as 
possible.\n"
-            "You may have to reconstruct your View Layers...\n",
-            collection->id.name);
-      }
-    }
+
     /* Keep this block, even when empty. */
   }
 }
 
+static void panels_remove_x_closed_flag_recursive(Panel *panel)
+{
+  const bool was_closed_x = panel->flag & PNL_UNUSED_1;
+  const bool was_closed_y = panel->flag & PNL_CLOSED; /* That value was the Y 
closed flag. */
+
+  SET_FLAG_FROM_TEST(panel->flag, was_closed_x || was_closed_y, PNL_CLOSED);
+
+  /* Clear the old PNL_CLOSEDX flag. */
+  panel->flag &= ~PNL_UNUSED_1;
+
+  LISTBASE_FOREACH (Panel *, child_panel, &panel->children) {
+    panels_remove_x_closed_flag_recursive(child_panel);
+  }
+}
+
 void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
 {
   UNUSED_VARS(fd);
@@ -409,17 +428,7 @@ void blo_do_versions_290(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
     }
   }
 
-  /**
-   * Versioning code until next subversion bump goes here.
-   *
-   * \note Be sure to check when bumping the version:
-   * - "versioning_userdef.c", #BLO_version_defaults_userpref_blend
-   * - "versioning_userdef.c", #do_versions_theme
-   *
-   * \note Keep this message at the bottom of the function.
-   */
-  {
-    /* Keep this block, even when empty. */
+  if (!MAIN_VERSION_ATLEAST(bmain, 291, 1)) {
 
     /* Initialize additional parameter of the Nishita sky model and change 
altitude unit. */
     if (!DNA_struct_elem_find(fd->filesdna, "NodeTexSky", "float", 
"sun_intensity")) {
@@ -484,5 +493,29 @@ void blo_do_versions_290(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
         }
       }
     }
+
+    /* Remove panel X axis collapsing, a remnant of horizontal panel 
alignment. */
+    LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+      LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+        LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
+          LISTBASE_FOREACH (Panel *, panel, &region->panels) {
+            panels_remove_x_closed_flag_recursive(panel);
+          }
+        }
+      }
+    }
+  }
+
+  /**
+   * Versioning code until next subversion bump goes here.
+   *
+   * \note Be sure to check when bumping the version:
+   * - "versioning_userdef.c", #BLO_version_defaults_userpref_blend
+   * - "versioning_userdef.c", #do_versions_theme
+   *
+   * \note Keep this message at the bottom of the function.
+   */
+  {
+    /* Keep this block, even when empty. */
   }
 }
diff --git a/source/blender/blenloader/intern/versioning_userdef.c 
b/source/blender/blenloader/intern/versioning_userdef.c
index 0b116804481..1437d46bd8d 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -758,6 +758,12 @@ void BLO_version_defaults_userpref_blend(Main *bmain, 
UserDef *userdef)
     userdef->statusbar_flag = STATUSBAR_SHOW_VERSION;
   }
 
+  if (!USER_VERSION_ATLEAST(291, 1)) {
+    if (userdef->collection_instance_empty_size == 0) {
+      userdef->collection_instance_empty_size = 1.0f;
+    }
+  }
+
   /**
    * Versioning code until next subversion bump goes here.
    *
@@ -769,10 +775,6 @@ void BLO_version_defaults_userpref_blend(Main *bmain, 
UserDef *userdef)
    */
   {
     /* Keep this block, even when empty. */
-
-    if (userdef->collection_instance_empty_size == 0) {
-      userdef->collection_instance_empty_size = 1.0f;
-    }
   }
 
   if (userdef->pixelsize == 0.0f) {
diff --git a/source/blender/editors/include/UI_interface.h 
b/source/blender/editors/include/UI_interface.h
index 5d936cdfaa3..22e3fec172a 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1667,19 +1667,13 @@ void UI_panels_end(const struct bContext *C, struct 
ARegion *region, int *r_x, i
 void UI_panels_draw(const struct bContext *C, struct ARegion *region);
 
 struct Panel *UI_panel_find_by_type(struct ListBase *lb, struct PanelType *pt);
-struct Panel *UI_panel_begin(struct ScrArea *area,
-                             struct ARegion *region,
+struct Panel *UI_panel_begin(struct ARegion *region,
                              struct ListBase *lb,
                              uiBlock *block,
                              struct PanelType *pt,
                              struct Panel *panel,
                              bool *r_open);
-void UI_panel_end(const struct ScrArea *area,
-                  const struct ARegion *region,
-                  uiBlock *block,
-                  int width,
-                  int height,
-                  bool open);
+void UI_panel_end(const struct ARegion *region, uiBlock *block, int width, int 
height, bool open);
 
 void UI_panels_scale(struct ARegion *region, float new_width);
 void UI_panel_label_offset(struct uiBlock *block, int *r_x, int *r_y);
diff --git a/source/blender/editors/interface/interface_panel.c 
b/source/blender/editors/interface/interface_panel.c
index a70bcd208ab..4982a27316c 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -134,43 +134,6 @@ static void panel_title_color_get(bool show_background, 
uchar color[4])
   }
 }
 
-/*********************** space specific code ************************/
-/* temporary code to remove all sbuts stuff from panel code         */
-
-/* SpaceProperties.align */
-typedef enum eSpaceButtons_Align {
-  BUT_HORIZONTAL = 0,
-  BUT_VERTICAL = 1,
-  BUT_AUTO = 2,
-} eSpaceButtons_Align;
-
-static int panel_aligned(const ScrArea *area, const ARegion *region)
-{
-  if (area->spacetype == SPACE_PROPERTIES && region->regiontype == 
RGN_TYPE_WINDOW) {
-    return BUT_VERTICAL;
-  }
-  if (area->spacetype == SPACE_USERPREF && region->regiontype == 
RGN_TYPE_WINDOW) {
-    return BUT_VERTICAL;
-  }
-  if (area->spacetype == SPACE_FILE && region->regiontype == 
RGN_TYPE_CHANNELS) {
-    return BUT_VERTICAL;
-  }
-  if (area->spacetype == SPACE_IMAGE && region->regiontype == 
RGN_TYPE_PREVIEW) {
-    return BUT_VERTICAL;
-  }
-  if (ELEM(region->regiontype,
-           RGN_TYPE_UI,
-           RGN_TYPE_TOOLS,
-           RGN_TYPE_TOOL_PROPS,
-           RGN_TYPE_HUD,
-           RGN_TYPE_NAV_BAR,
-           RGN_TYPE_EXECUTE)) {
-    return BUT_VERTICAL;
-  }
-
-  return 0;
-}
-
 static bool panel_active_animation_changed(ListBase *lb, Panel **pa_animation, 
bool *no_animation)
 {
   LISTBASE_FOREACH (Panel *, panel, lb) {
@@ -530,13 +493,9 @@ static void reorder_instanced_panel_list(bContext *C, 
ARegion *region, Panel *dr
 static bool panel_set_expand_from_list_data_recursive(Panel *panel, short 
flag, short *flag_index)
 {
   bool open = (flag & (1 << *flag_index));
-  bool changed = (open == (bool)(panel->flag & PNL_CLOSEDY));
-  if (open) {
-    panel->flag &= ~PNL_CLOSEDY;
-  }
-  else {
-    panel->flag |= PNL_CLOSEDY;
-  }
+  bool changed = (open == (bool)(panel->flag & PNL_CLOSED));
+  SET_FLAG_FROM_TEST(panel->flag, !open, PNL_CLOSED);
+
   LISTBASE_FOREACH (Panel *, child, &panel->children) {
     *flag_index = *flag_index + 1;
     changed |= panel_set_expand_from_list_data_recursive(child, flag, 
flag_index);
@@ -572,13 +531,9 @@ void UI_panel_set_expand_from_list_data(const bContext *C, 
Panel *panel)
  */
 static void get_panel_expand_flag(Panel *panel, short *flag, short *flag_index)
 {
-  bool open = !(panel->flag & PNL_CLOSEDY);
-  if (open) {
-    *flag |= (1 << *flag_index);
-  }
-  else {
-    *flag &= ~(1 << *flag_index);
-  }
+  bool open = !(panel->flag & PNL_CLOSED);
+  SET_FLAG_FROM_TEST(*flag, open, (1 << *flag_index));
+
   LISTBASE_FOREACH (Panel *, child, &panel->children) {
     *flag_index = *flag_index + 1;
     get_panel_expand_flag(child, flag, flag_index);
@@ -635,14 +590,10 @@ static bool panel_set_flag_recursive(Panel *panel, int 
flag, bool value)
   return changed;
 }
 
-static void panels_collapse_all(const bContext *C,
-                                ScrArea *area,
-                                ARegion *region,
-                                const Panel *from_panel)
+static void panels_collapse_all(const bContext *C, ARegion *region, const 
Panel *from_panel)
 {
   const bool has_category_tabs = UI_panel_category_is_visible(region);
   const char *category = has_category_tabs ? 
UI_panel_category_active_get(region, false) : NULL;
-  const int flag = ((panel_aligned(area, region) == BUT_HORIZONTAL) ?

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to