From 33e4a2c7b1ab3a06f1adb5edd9850523c897ea77 Mon Sep 17 00:00:00 2001
From: Leslie Linden <none@none>
Date: Wed, 25 May 2011 10:39:34 -0700
Subject: Updated Marketplace Inbox & Outbox panel to maintain size when one is
 expanded vs the other

---
 indra/llui/lllayoutstack.cpp                       |  18 +-
 indra/llui/lllayoutstack.h                         |   4 +
 indra/newview/llsidepanelinventory.cpp             |  49 +--
 .../skins/default/xui/en/sidepanel_inventory.xml   | 403 +++++++++++----------
 4 files changed, 248 insertions(+), 226 deletions(-)

diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp
index 9b6830a816..8a92796942 100644
--- a/indra/llui/lllayoutstack.cpp
+++ b/indra/llui/lllayoutstack.cpp
@@ -78,20 +78,20 @@ LLLayoutPanel::~LLLayoutPanel()
 	delete mResizeBar;
 	mResizeBar = NULL;
 }
-	
+
 F32 LLLayoutPanel::getCollapseFactor(LLLayoutStack::ELayoutOrientation orientation)
 {
 	if (orientation == LLLayoutStack::HORIZONTAL)
 	{
 		F32 collapse_amt = 
-		clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, (F32)mMinDim / (F32)llmax(1, getRect().getWidth()));
+			clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, (F32)mMinDim / (F32)llmax(1, getRect().getWidth()));
 		return mVisibleAmt * collapse_amt;
 	}
 	else
 	{
-			F32 collapse_amt = 
+		F32 collapse_amt = 
 			clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, llmin(1.f, (F32)mMinDim / (F32)llmax(1, getRect().getHeight())));
-			return mVisibleAmt * collapse_amt;
+		return mVisibleAmt * collapse_amt;
 	}
 }
 
@@ -182,14 +182,14 @@ BOOL LLLayoutStack::postBuild()
 }
 
 bool LLLayoutStack::addChild(LLView* child, S32 tab_group)
-		{
+{
 	LLLayoutPanel* panelp = dynamic_cast<LLLayoutPanel*>(child);
-			if (panelp)
-			{
+	if (panelp)
+	{
 		mPanels.push_back(panelp);
-			}
+	}
 	return LLView::addChild(child, tab_group);
-		}
+}
 
 
 S32 LLLayoutStack::getDefaultHeight(S32 cur_height)
diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h
index 4ac8ef0ee9..2fc2cf3eb4 100644
--- a/indra/llui/lllayoutstack.h
+++ b/indra/llui/lllayoutstack.h
@@ -177,6 +177,10 @@ public:
 	~LLLayoutPanel();
 
 	void initFromParams(const Params& p);
+
+	S32 getMinDim() const { return mMinDim; }
+	S32 getMaxDim() const { return mMaxDim; }
+
 	void setMinDim(S32 value) { mMinDim = value; }
 	void setMaxDim(S32 value) { mMaxDim = value; }
 
diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp
index 7f5a2e64bf..9247611257 100644
--- a/indra/newview/llsidepanelinventory.cpp
+++ b/indra/newview/llsidepanelinventory.cpp
@@ -134,38 +134,45 @@ BOOL LLSidepanelInventory::postBuild()
 }
 
 
-void LLSidepanelInventory::onToggleInboxBtn()
+void manageInboxOutboxPanels(LLLayoutStack * stack,
+							 LLButton * pressedButton, LLLayoutPanel * pressedPanel,
+							 LLButton * otherButton, LLLayoutPanel * otherPanel)
 {
-	LLLayoutStack* stack = getChild<LLLayoutStack>("inventory_layout_stack");
-	bool collapse = !getChild<LLButton>("inbox_btn")->getToggleState();
+	bool expand = pressedButton->getToggleState();
+	bool otherExpanded = otherButton->getToggleState();
 
-	if (stack)
-	{
-		stack->collapsePanel(getChild<LLLayoutPanel>("inbox_layout_panel"), collapse);
-	}
-	if (!collapse)
+	if (expand && otherExpanded)
 	{
-		stack->collapsePanel(getChild<LLLayoutPanel>("outbox_layout_panel"), true);
-		getChild<LLButton>("outbox_btn")->setToggleState(false);
+		// Reshape pressedPanel to the otherPanel's height so we preserve the marketplace panel size
+		pressedPanel->reshape(pressedPanel->getRect().getWidth(), otherPanel->getRect().getHeight());
+
+		stack->collapsePanel(otherPanel, true);
+		otherButton->setToggleState(false);
 	}
+
+	stack->collapsePanel(pressedPanel, !expand);
 }
 
-void LLSidepanelInventory::onToggleOutboxBtn()
+void LLSidepanelInventory::onToggleInboxBtn()
 {
 	LLLayoutStack* stack = getChild<LLLayoutStack>("inventory_layout_stack");
-	bool collapse = !getChild<LLButton>("outbox_btn")->getToggleState();
+	LLButton* pressedButton = getChild<LLButton>("inbox_btn");
+	LLLayoutPanel* pressedPanel = getChild<LLLayoutPanel>("inbox_layout_panel");
+	LLButton* otherButton = getChild<LLButton>("outbox_btn");
+	LLLayoutPanel* otherPanel = getChild<LLLayoutPanel>("outbox_layout_panel");
 
-	if (stack)
-	{
-		stack->collapsePanel(getChild<LLLayoutPanel>("outbox_layout_panel"), collapse);
-	}
+	manageInboxOutboxPanels(stack, pressedButton, pressedPanel, otherButton, otherPanel);
+}
 
-	if (!collapse)
-	{
-		stack->collapsePanel(getChild<LLLayoutPanel>("inbox_layout_panel"), true);
-		getChild<LLButton>("inbox_btn")->setToggleState(false);
-	}
+void LLSidepanelInventory::onToggleOutboxBtn()
+{
+	LLLayoutStack* stack = getChild<LLLayoutStack>("inventory_layout_stack");
+	LLButton* pressedButton = getChild<LLButton>("outbox_btn");
+	LLLayoutPanel* pressedPanel = getChild<LLLayoutPanel>("outbox_layout_panel");
+	LLButton* otherButton = getChild<LLButton>("inbox_btn");
+	LLLayoutPanel* otherPanel = getChild<LLLayoutPanel>("inbox_layout_panel");
 
+	manageInboxOutboxPanels(stack, pressedButton, pressedPanel, otherButton, otherPanel);
 }
 
 
diff --git a/indra/newview/skins/default/xui/en/sidepanel_inventory.xml b/indra/newview/skins/default/xui/en/sidepanel_inventory.xml
index a0caf80256..ce5cf4c622 100644
--- a/indra/newview/skins/default/xui/en/sidepanel_inventory.xml
+++ b/indra/newview/skins/default/xui/en/sidepanel_inventory.xml
@@ -9,170 +9,181 @@
 	  min_width="240"
 	  name="objects panel"
 	  width="333">
-	 <panel
-		 follows="all"
-		 layout="topleft"
-		 left="0"
-		 name="sidepanel__inventory_panel"
-		 top="0"
-		 label=""
-		 height="570"
-		 visible="true"
-		 width="330">
-         <layout_stack
-              follows="left|right|top|bottom"
-              layout="topleft"
-              left="0"
-              top="0"
-              orientation="vertical"
-              name="inventory_layout_stack"
-              height="540"
-              width="330">
-             <layout_panel
-                 width="330"
-                  follows="bottom|left|right"
-                 height="480">
-                 <panel
-                      class="panel_main_inventory"
-                      filename="panel_main_inventory.xml"
-                      follows="all"
-                      layout="topleft"
-                      left="0"
-                      name="panel_main_inventory"
-                      top="0"
-                      label=""
-                      height="480"
-                      width="330" />
-             </layout_panel>
-             <layout_panel
-                 width="330"
-                 auto_resize="true"
-                  follows="bottom|left|right"
-                 min_dim="35"
-                 name="inbox_layout_panel"
-                 max_dim="125"
-                 height="35">
-                 <panel
-                      follows="top|left|right"
-                      layout="topleft"
-                      left="0"
-                      name="marketplace_inbox"
-                      class="panel_marketplace_inbox"
-                      top="0"
-                      label=""
-                      height="125"
-                      width="330">
-                     <button
-                         label="MARKETPLACE INBOX"
-                         name="inbox_btn"
-                         height="35"
-                         width="308"
-                         image_unselected="MarketplaceBtn_Off"
-                            image_selected="MarketplaceBtn_Selected"
-                         halign="left"
-                         follows="top|left|right"
-                         is_toggle="true"
-                         tab_stop="false"
-                         pad_left="35"
-                         top="0"
-                         left="10"
-                         ></button>
-                         <panel
-                             follows="all"
-                             left="0"
-                             height="90"
-                             width="250"
-                             top="30"
-                           >
-                             <text
-                                 left ="40"
-                                 top="15"
-                                 align="left"
-                                 height="14"
-                                 width="100"
-                                 >Just a panel</text>    
-                         </panel>
-                     
-                 </panel>
-             </layout_panel>
-             <layout_panel
-  width="330"
-  auto_resize="true"
-   follows="bottom|left|right"
-  name="outbox_layout_panel"
-                 min_dim="35"
-                 max_dim="125"
-  height="35">
-                 <panel
-                      follows="top|left|right"
-                      layout="topleft"
-                      left="10"
-                      name="marketplace_outbox"
-                      class="panel_marketplace_outbox"
-                      top="0"
-                      label=""
-                      height="125"
-                      width="310">
-                     <button
-                         label="MARKETPLACE OUTBOX"
-                         is_toggle="true"
-                         name="outbox_btn"
-                      follows="top|left|right"
-                         image_unselected="MarketplaceBtn_Off"
-                            image_selected="MarketplaceBtn_Selected"
-                         height="35"
-                         tab_stop="false"
-                         width="308"
-                         halign="left"
-                         pad_left="35"
-                         top="0"
-                         left="0"
-                         ></button>
-                     <panel
-                         follows="all"
-                         left="0"
-                         height="90"
-                         width="250"
-                         top="30"
+    <panel
+        follows="all"
+        layout="topleft"
+        left="0"
+        name="sidepanel__inventory_panel"
+        top="0"
+        label=""
+        height="570"
+        visible="true"
+        width="330">
+        <layout_stack
+             follows="left|right|top|bottom"
+             layout="topleft"
+             left="0"
+             top="0"
+             orientation="vertical"
+             name="inventory_layout_stack"
+             height="535"
+             width="330">
+            <layout_panel
+                width="330"
+                follows="bottom|left|right"
+                height="480">
+                <panel
+                     class="panel_main_inventory"
+                     filename="panel_main_inventory.xml"
+                     follows="all"
+                     layout="topleft"
+                     left="0"
+                     name="panel_main_inventory"
+                     top="0"
+                     label=""
+                     height="480"
+                     width="330" />
+            </layout_panel>
+            <layout_panel
+                width="330"
+                auto_resize="true"
+                user_resize="false"
+                follows="bottom|left|right"
+                min_dim="35"
+                name="inbox_layout_panel"
+                max_dim="125"
+                height="35">
+                <panel
+                     follows="top|left|right"
+                     layout="topleft"
+                     left="0"
+                     name="marketplace_inbox"
+                     class="panel_marketplace_inbox"
+                     top="0"
+                     label=""
+                     height="125"
+                     width="330">
+                    <button
+                        label="MARKETPLACE INBOX"
+                        name="inbox_btn"
+                        height="35"
+                        width="308"
+                        image_unselected="MarketplaceBtn_Off"
+                        image_selected="MarketplaceBtn_Selected"
+                        halign="left"
+                        follows="top|left|right"
+                        is_toggle="true"
+                        tab_stop="false"
+                        pad_left="35"
+                        top="0"
+                        left="10" />
+                    <panel
+                        follows="all"
+                        left="0"
+                        height="90"
+                        width="250"
+                        top="30"
+                            >
+                        <text
+                            left ="40"
+                            top="15"
+                            align="left"
+                            height="14"
+                            width="100"
+                                 >Just a panel</text>
+                    </panel>
+                </panel>
+            </layout_panel>
+            <layout_panel
+                width="330"
+                auto_resize="true"
+                user_resize="false"
+                follows="bottom|left|right"
+                name="outbox_layout_panel"
+                min_dim="35"
+                max_dim="125"
+                height="35">
+                <panel
+                     follows="top|left|right"
+                     layout="topleft"
+                     left="10"
+                     name="marketplace_outbox"
+                     class="panel_marketplace_outbox"
+                     top="0"
+                     label=""
+                     height="125"
+                     width="310">
+                    <button
+                        label="MARKETPLACE OUTBOX"
+                        is_toggle="true"
+                        name="outbox_btn"
+                        follows="top|left|right"
+                        image_unselected="MarketplaceBtn_Off"
+                        image_selected="MarketplaceBtn_Selected"
+                        height="35"
+                        tab_stop="false"
+                        width="308"
+                        halign="left"
+                        pad_left="35"
+                        top="0"
+                        left="0" />
+                    <button
+                        label="SYNC"
+                        is_toggle="false"
+                        name="outbox_sync_btn"
+                        follows="top|right"
+                        height="25"
+                        tab_stop="false"
+                        width="45"
+                        halign="center"
+                        top="5"
+                        left="-50"
+                        enabled="false" />
+                    <panel
+                        follows="all"
+                        left="0"
+                        height="90"
+                        width="250"
+                        top="30"
                            >
-                         <text
-                             left ="40"
-                             top="15"
-                             align="left"
-                             height="14"
-                             width="100"
+                        <text
+                            left ="40"
+                            top="15"
+                            align="left"
+                            height="14"
+                            width="100"
                                  >Just a panel</text>
-                     </panel>
+                    </panel>
 
-                 </panel>
-             </layout_panel>
-         </layout_stack>
-		<panel
-		     follows="bottom|left|right"
-			 height="30"
-			 layout="topleft"
-			 name="button_panel"
-			 left="9"
-			 top_pad="2"
-			 width="308">
-			<layout_stack
-     	         follows="bottom|left|right"
-		         height="23"
-		         layout="topleft"
-		         mouse_opaque="false"
-		         name="button_panel_ls"
-		         left="0"
-		         orientation="horizontal"
-		         top="0"
-		         width="308">	
-			    <layout_panel
-			         follows="bottom|left|right"
-			         height="23"
+                </panel>
+            </layout_panel>
+        </layout_stack>
+        <panel
+             follows="bottom|left|right"
+             height="30"
+             layout="topleft"
+             name="button_panel"
+             left="9"
+             top_pad="7"
+             width="308">
+            <layout_stack
+                 follows="bottom|left|right"
+                 height="23"
+                 layout="topleft"
+                 mouse_opaque="false"
+                 name="button_panel_ls"
+                 left="0"
+                 orientation="horizontal"
+                 top="0"
+                 width="308">
+                <layout_panel
+                     follows="bottom|left|right"
+                     height="23"
                      layout="bottomleft"
-                     left="0"			
+                     left="0"
                      mouse_opaque="false"
                      name="info_btn_lp"
-                     user_resize="false" 
+                     user_resize="false"
                      auto_resize="true"
                      width="101">
                     <button
@@ -186,15 +197,15 @@
                          tool_tip="Show object profile"
                          top="0"
                          width="100" />
-			    </layout_panel>
-			    <layout_panel
+                </layout_panel>
+                <layout_panel
                      follows="bottom|left|right"
                      height="23"
                      layout="bottomleft"
-                     left_pad="1"			
+                     left_pad="1"
                      mouse_opaque="false"
                      name="share_btn_lp"
-                     user_resize="false" 
+                     user_resize="false"
                      auto_resize="true"
                      width="100">
                     <button
@@ -208,15 +219,15 @@
                          tool_tip="Share an inventory item"
                          top="0"
                          width="99" />
-			    </layout_panel>
-			    <layout_panel
+                </layout_panel>
+                <layout_panel
                      follows="bottom|left|right"
                      height="23"
                      layout="bottomleft"
-                     left_pad="1"			
+                     left_pad="1"
                      mouse_opaque="false"
                      name="shop_btn_lp"
-                     user_resize="false" 
+                     user_resize="false"
                      auto_resize="true"
                      width="100">
                     <button
@@ -262,36 +273,36 @@
                          tool_tip="Teleport to the selected area"
                          top="0"
                          width="99" />
-			    </layout_panel>
-			</layout_stack>
-		</panel>
-	</panel>
+                </layout_panel>
+            </layout_stack>
+        </panel>
+    </panel>
 
-<panel
-		 follows="all"
-		 layout="topleft"
-		 left="0"
-		 class="sidepanel_item_info"
-		 filename="sidepanel_item_info.xml"
-		 name="sidepanel__item_panel"
-		 top="0"
-		 label=""
-		 height="570"
-		 visible="false"
-		 width="330">
-	</panel>
+    <panel
+             follows="all"
+             layout="topleft"
+             left="0"
+             class="sidepanel_item_info"
+             filename="sidepanel_item_info.xml"
+             name="sidepanel__item_panel"
+             top="0"
+             label=""
+             height="570"
+             visible="false"
+             width="330">
+    </panel>
 
-<panel
-		 follows="all"
-		 layout="topleft"
-		 left="0"
-		 class="sidepanel_task_info"
-		 filename="sidepanel_task_info.xml"
-		 name="sidepanel__task_panel"
-		 top="0"
-		 label=""
-		 height="570"
-		 visible="false"
-		 width="330">
-	</panel>
+    <panel
+             follows="all"
+             layout="topleft"
+             left="0"
+             class="sidepanel_task_info"
+             filename="sidepanel_task_info.xml"
+             name="sidepanel__task_panel"
+             top="0"
+             label=""
+             height="570"
+             visible="false"
+             width="330">
+    </panel>
 </panel>
-- 
cgit v1.2.3