From b524aacb599b8c907e02eeb56b7441f42e9ddad2 Mon Sep 17 00:00:00 2001
From: "Nyx (Neal Orman)" <nyx@lindenlab.com>
Date: Tue, 25 May 2010 20:17:23 -0400
Subject: [PATCH] EXT-7213 WIP kill old appearance editor and all traces of
 code

First pass - eliminated all references to gFloaterCustomize except
those that call saveIfDirty. Haven't compiled, haven't reviewed.
Will clean up in further patches and get reviewed before pushing.
---
 indra/newview/llagentcamera.cpp         | 20 --------------------
 indra/newview/llinventorybridge.cpp     | 11 +++--------
 indra/newview/llpaneleditwearable.cpp   |  4 ++++
 indra/newview/llpaneleditwearable.h     |  2 ++
 indra/newview/llsidepanelappearance.cpp | 16 ++++++++++++++++
 indra/newview/llsidepanelappearance.h   |  2 ++
 indra/newview/llviewerinventory.cpp     |  5 +++--
 indra/newview/llviewerwindow.cpp        |  2 +-
 indra/newview/llwearable.cpp            | 16 ++++++++++------
 9 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 9638d0e94f8..d9eceec30da 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1538,26 +1538,6 @@ F32 LLAgentCamera::calcCustomizeAvatarUIOffset(const LLVector3d& camera_pos_glob
 {
 	F32 ui_offset = 0.f;
 
-	if (gFloaterCustomize)
-	{
-		const LLRect& rect = gFloaterCustomize->getRect();
-
-		// Move the camera so that the avatar isn't covered up by this floater.
-		F32 fraction_of_fov = 0.5f - (0.5f * (1.f - llmin(1.f, ((F32)rect.getWidth() / (F32)gViewerWindow->getWindowWidthScaled()))));
-		F32 apparent_angle = fraction_of_fov * LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect();  // radians
-		F32 offset = tan(apparent_angle);
-
-		if( rect.mLeft < (gViewerWindow->getWindowWidthScaled() - rect.mRight) )
-		{
-			// Move the avatar to the right (camera to the left)
-			ui_offset = offset;
-		}
-		else
-		{
-			// Move the avatar to the left (camera to the right)
-			ui_offset = -offset;
-		}
-	}
 	F32 range = (F32)dist_vec(camera_pos_global, getFocusGlobal());
 	mUIOffset = lerp(mUIOffset, ui_offset, LLCriticalDamp::getInterpolant(0.05f));
 	return mUIOffset * range;
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 0f532236e4d..7625a7ab830 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -62,6 +62,7 @@
 #include "llpreviewgesture.h"
 #include "llpreviewtexture.h"
 #include "llselectmgr.h"
+#include "llsidepanelappearance.h"
 #include "llsidetray.h"
 #include "lltrans.h"
 #include "llviewerassettype.h"
@@ -4884,15 +4885,9 @@ void LLWearableBridge::editOnAvatar()
 	const LLWearable* wearable = gAgentWearables.getWearableFromItemID(linked_id);
 	if( wearable )
 	{
-		// Set the tab to the right wearable.
-		if (gFloaterCustomize)
-			gFloaterCustomize->setCurrentWearableType( wearable->getType() );
+		LLPanel * panel = LLSideTray::getInstance()->getPanel("sidepanel_appearance");
 
-		if( CAMERA_MODE_CUSTOMIZE_AVATAR != gAgentCamera.getCameraMode() )
-		{
-			// Start Avatar Customization
-			gAgentCamera.changeCameraToCustomizeAvatar();
-		}
+		LLSidePanelAppearance::editWearable(wearable, panel);
 	}
 }
 
diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index 359b523dd61..2ba39fca9cd 100644
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -956,6 +956,10 @@ void LLPanelEditWearable::changeCamera(U8 subpart)
 	}
 }
 
+void LLPanelEditWearable::updateScrollingPanelList()
+{
+	updateScrollingPanelUI();
+}
 
 void LLPanelEditWearable::initializePanel()
 {
diff --git a/indra/newview/llpaneleditwearable.h b/indra/newview/llpaneleditwearable.h
index 5de2bcb1708..0af3758a4e2 100644
--- a/indra/newview/llpaneleditwearable.h
+++ b/indra/newview/llpaneleditwearable.h
@@ -66,6 +66,8 @@ class LLPanelEditWearable : public LLPanel
 	void				showDefaultSubpart();
 	void				onTabExpandedCollapsed(const LLSD& param, U8 index);
 
+	void 				updateScrollingPanelList();
+
 	static void			onRevertButtonClicked(void* userdata);
 	void				onCommitSexChange();
 
diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp
index 010d593b279..6f934a0b66c 100644
--- a/indra/newview/llsidepanelappearance.cpp
+++ b/indra/newview/llsidepanelappearance.cpp
@@ -465,3 +465,19 @@ void LLSidepanelAppearance::setWearablesLoading(bool val)
 	childSetVisible("wearables_loading_indicator", val);
 	childSetVisible("edit_outfit_btn", !val);
 }
+
+void LLSidepanelAppearance::showDefaultSubpart()
+{
+	if (mEditWearable->getVisible())
+	{
+		mEditWearable->showDefaultSubpart();
+	}
+}
+
+void LLSidepanelAppearance::updateScrollingPanelList()
+{
+	if (mEditWearable->getVisible())
+	{
+		mEditWearable->updateScrollingPanelList();
+	}
+}
diff --git a/indra/newview/llsidepanelappearance.h b/indra/newview/llsidepanelappearance.h
index 12303b6e96c..5bde962c8d2 100644
--- a/indra/newview/llsidepanelappearance.h
+++ b/indra/newview/llsidepanelappearance.h
@@ -67,6 +67,8 @@ class LLSidepanelAppearance : public LLPanel
 	void showOutfitEditPanel();
 	void showWearableEditPanel(LLWearable *wearable = NULL);
 	void setWearablesLoading(bool val);
+	void showDefaultSubpart();
+	void updateScrollingPanelList();
 
 private:
 	void onFilterEdit(const std::string& search_string);
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index f0532d5a31a..838f57073ee 100644
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -883,9 +883,10 @@ void ModifiedCOFCallback::fire(const LLUUID& inv_item)
 	if( CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode() )
 	{
 		// If we're in appearance editing mode, the current tab may need to be refreshed
-		if (gFloaterCustomize)
+		LLSidepanelAppearance *panel = dynamic_cast<LLSidePanelAppearance*>(LLSideTray::getInstance()->getPanel("sidepanel_appearance"));
+		if (panel)
 		{
-			gFloaterCustomize->switchToDefaultSubpart();
+			panel->showDefaultSubpart();
 		}
 	}
 }
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index e0463e3c4a8..f72f122f8a8 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -4545,7 +4545,7 @@ void LLViewerWindow::restoreGL(const std::string& progress_message)
 		
 		gResizeScreenTexture = TRUE;
 
-		if (gFloaterCustomize && gFloaterCustomize->getVisible())
+		if (gAgentCamera.cameraCustomizeAvatar())
 		{
 			LLVisualParamHint::requestHintUpdates();
 		}
diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp
index 10b9a18fa8e..358defbb31a 100644
--- a/indra/newview/llwearable.cpp
+++ b/indra/newview/llwearable.cpp
@@ -705,9 +705,9 @@ void LLWearable::removeFromAvatar( LLWearableType::EType type, BOOL upload_bake
 		}
 	}
 
-	if( gFloaterCustomize )
+	if( gAgentCamera.cameraCustomizeAvatar() )
 	{
-		gFloaterCustomize->setWearable(type, NULL, PERM_ALL, TRUE);
+		LLSideTray::getInstance()->showPanel("sidepanel_appearance", LLSD().with("type", "edit_outfit"));
 	}
 
 	gAgentAvatarp->updateVisualParams();
@@ -976,9 +976,11 @@ void LLWearable::revertValues()
 
 	syncImages(mSavedTEMap, mTEMap);
 
-	if( gFloaterCustomize )
+
+	LLSidepanelAppearance *panel = dynamic_cast<LLSidepanelAppearance*>(LLSideTray::getInstance()->getPanel("sidepanel_appearance"));
+	if( panel )
 	{
-		gFloaterCustomize->updateScrollingPanelList(TRUE);
+		panel->updateScrollingPanelList();
 	}
 }
 
@@ -1015,9 +1017,11 @@ void LLWearable::saveValues()
 	// Deep copy of mTEMap (copies only those tes that are current, filling in defaults where needed)
 	syncImages(mTEMap, mSavedTEMap);
 
-	if( gFloaterCustomize )
+
+	LLSidepanelAppearance *panel = dynamic_cast<LLSidepanelAppearance*>(LLSideTray::getInstance()->getPanel("sidepanel_appearance"));
+	if( panel )
 	{
-		gFloaterCustomize->updateScrollingPanelList(TRUE);
+		panel->updateScrollingPanelList();
 	}
 }
 
-- 
GitLab