From 65fe37a93029e17f45e488619a5e589a2983757f Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Sat, 24 Jun 2023 01:49:27 +0300
Subject: [PATCH] SL-19604 Fix gallery view having huge ident at the bottom

---
 indra/llui/lllayoutstack.cpp                       |  9 +++++++++
 indra/llui/lllayoutstack.h                         |  1 +
 indra/newview/llpanelmaininventory.cpp             |  6 ++++++
 indra/newview/llpanelmaininventory.h               |  3 ++-
 .../skins/default/xui/en/panel_main_inventory.xml  | 14 +++++++-------
 5 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp
index 08ce31ffc5d..b1968e6a42b 100644
--- a/indra/llui/lllayoutstack.cpp
+++ b/indra/llui/lllayoutstack.cpp
@@ -523,6 +523,15 @@ void LLLayoutStack::updateLayout()
 	mNeedsLayout = continue_animating;
 } // end LLLayoutStack::updateLayout
 
+void LLLayoutStack::setPanelSpacing(S32 val)
+{
+    if (mPanelSpacing != val)
+    {
+        mPanelSpacing = val;
+        mNeedsLayout = true;
+    }
+}
+
 LLLayoutPanel* LLLayoutStack::findEmbeddedPanel(LLPanel* panelp) const
 {
 	if (!panelp) return NULL;
diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h
index 02685281ef7..000b919ae76 100644
--- a/indra/llui/lllayoutstack.h
+++ b/indra/llui/lllayoutstack.h
@@ -91,6 +91,7 @@ class LLLayoutStack : public LLView, public LLInstanceTracker<LLLayoutStack>
 	void updateLayout();
 
 	S32 getPanelSpacing() const { return mPanelSpacing; }
+    void setPanelSpacing(S32 val);
 	
 	static void updateClass();
 
diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp
index 5ae61f0c36a..27c8f10889c 100644
--- a/indra/newview/llpanelmaininventory.cpp
+++ b/indra/newview/llpanelmaininventory.cpp
@@ -256,6 +256,7 @@ BOOL LLPanelMainInventory::postBuild()
     mCombinationViewPanel = getChild<LLPanel>("combination_view_inventory");
     mCombinationGalleryLayoutPanel = getChild<LLLayoutPanel>("comb_gallery_layout");
     mCombinationListLayoutPanel = getChild<LLLayoutPanel>("comb_inventory_layout");
+    mCombinationLayoutStack = getChild<LLLayoutStack>("combination_view_stack");
 
     mCombinationInventoryPanel = getChild<LLInventorySingleFolderPanel>("comb_single_folder_inv");
     LLInventoryFilter& comb_inv_filter = mCombinationInventoryPanel->getFilter();
@@ -2371,6 +2372,7 @@ void LLPanelMainInventory::updatePanelVisibility()
             comb_gallery_filter.setFilterThumbnails(LLInventoryFilter::FILTER_INCLUDE_THUMBNAILS);
             comb_gallery_filter.markDefault();
 
+            mCombinationLayoutStack->setPanelSpacing(0);
             mCombinationGalleryLayoutPanel->setVisible(mSingleFolderMode && isGalleryViewMode());
             mCombinationGalleryPanel->setVisible(mSingleFolderMode && isGalleryViewMode()); // to prevent or process updates
             mCombinationListLayoutPanel->setVisible(mSingleFolderMode && isListViewMode());
@@ -2390,6 +2392,10 @@ void LLPanelMainInventory::updateCombinationVisibility()
     {
         bool is_gallery_empty = !mCombinationGalleryPanel->hasVisibleItems();
         bool show_inv_pane = mCombinationInventoryPanel->hasVisibleItems() || is_gallery_empty || mForceShowInvLayout;
+
+        const S32 DRAG_HANDLE_PADDING = 12; // for drag handle to not overlap gallery when both inventories are visible
+        mCombinationLayoutStack->setPanelSpacing(show_inv_pane ? DRAG_HANDLE_PADDING : 0);
+
         mCombinationGalleryLayoutPanel->setVisible(!is_gallery_empty);
         mCombinationListLayoutPanel->setVisible(show_inv_pane);
         mCombinationInventoryPanel->getRootFolder()->setForceArrange(!show_inv_pane);
diff --git a/indra/newview/llpanelmaininventory.h b/indra/newview/llpanelmaininventory.h
index bdc62fd8f72..79501e63bc1 100644
--- a/indra/newview/llpanelmaininventory.h
+++ b/indra/newview/llpanelmaininventory.h
@@ -210,7 +210,8 @@ class LLPanelMainInventory : public LLPanel, LLInventoryObserver
     LLInventorySingleFolderPanel* mCombinationInventoryPanel;
     LLInventoryGallery* mCombinationGalleryPanel;
     LLPanel* mCombinationGalleryLayoutPanel;
-    LLPanel* mCombinationListLayoutPanel;
+    LLLayoutPanel* mCombinationListLayoutPanel;
+    LLLayoutStack* mCombinationLayoutStack;
 
     boost::signals2::connection mListViewRootUpdatedConnection;
     boost::signals2::connection mGalleryRootUpdatedConnection;
diff --git a/indra/newview/skins/default/xui/en/panel_main_inventory.xml b/indra/newview/skins/default/xui/en/panel_main_inventory.xml
index b735dcf5289..f7a9c552cc4 100644
--- a/indra/newview/skins/default/xui/en/panel_main_inventory.xml
+++ b/indra/newview/skins/default/xui/en/panel_main_inventory.xml
@@ -271,7 +271,7 @@
     <panel
      follows="all"
      halign="center"
-     height="372"
+     height="375"
      layout="topleft"
      left="7"
      name="combination_view_inventory"
@@ -280,9 +280,9 @@
      <layout_stack
       follows="all"
       layout="topleft"
-      height="372"
+      height="375"
+      name="combination_view_stack"
       animate="false"
-      drag_handle_gap="13"
       drag_handle_thickness="6"
       drag_handle_first_indent="18"
       drag_handle_second_indent="18"
@@ -296,7 +296,7 @@
         bevel_style="in"
         user_resize="true"
         auto_resize="true"
-        height="246"
+        height="248"
         min_width="150"
         name="comb_gallery_layout">
         <panel
@@ -304,7 +304,7 @@
          filename="panel_inventory_gallery.xml"
          left="0"
          top="1"
-         height="246"
+         height="248"
          name="comb_gallery_view_inv"
          background_visible="true"
          follows="all"
@@ -316,7 +316,7 @@
         bevel_style="in"
         user_resize="true"
         auto_resize="true"
-        height="126"
+        height="127"
         min_height="100"
         name="comb_inventory_layout">
         <single_folder_inventory_panel
@@ -324,7 +324,7 @@
          follows="all"
          left="0"
          top="1"
-         height="126"
+         height="127"
          layout="topleft"
          show_item_link_overlays="true"
          bg_opaque_color="DkGray2"
-- 
GitLab