diff options
| author | Leslie Linden <leslie@lindenlab.com> | 2011-10-11 17:36:23 -0700 | 
|---|---|---|
| committer | Leslie Linden <leslie@lindenlab.com> | 2011-10-11 17:36:23 -0700 | 
| commit | f9e900f5ac9002f5ef3b44b02ac300971288e89b (patch) | |
| tree | 091238cd0560d87e1213433966debf0e60c0775b /indra/llui | |
| parent | a90a4b7b99b383490e594e2cdf1181d13e0c0f06 (diff) | |
* New floater positioning code.  Better than what's checked in but not great.
* Floater updates for positioning and to revert some earlier string changes.
Diffstat (limited to 'indra/llui')
| -rw-r--r-- | indra/llui/llfloater.cpp | 76 | ||||
| -rw-r--r-- | indra/llui/llfloater.h | 42 | ||||
| -rw-r--r-- | indra/llui/llfloaterreg.cpp | 35 | 
3 files changed, 110 insertions, 43 deletions
| diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 90c41e99dc..0398c0d7eb 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -62,6 +62,17 @@  // use this to control "jumping" behavior when Ctrl-Tabbing  const S32 TABBED_FLOATER_OFFSET = 0; +namespace LLInitParam +{ +	void TypeValues<LLFloaterEnums::EOpenPositioning>::declareValues() +	{ +		declare("none",       LLFloaterEnums::OPEN_POSITIONING_NONE); +		declare("cascading",  LLFloaterEnums::OPEN_POSITIONING_CASCADING); +		declare("centered",   LLFloaterEnums::OPEN_POSITIONING_CENTERED); +		declare("specified",  LLFloaterEnums::OPEN_POSITIONING_SPECIFIED); +	} +} +  std::string	LLFloater::sButtonNames[BUTTON_COUNT] =   {  	"llfloater_close_btn",		//BUTTON_CLOSE @@ -154,7 +165,6 @@ LLFloater::Params::Params()  :	title("title"),  	short_title("short_title"),  	single_instance("single_instance", false), -	auto_tile("auto_tile", false),  	can_resize("can_resize", false),  	can_minimize("can_minimize", true),  	can_close("can_close", true), @@ -164,7 +174,7 @@ LLFloater::Params::Params()  	save_rect("save_rect", false),  	save_visibility("save_visibility", false),  	can_dock("can_dock", false), -	open_centered("open_centered", false), +	open_positioning("open_positioning", LLFloaterEnums::OPEN_POSITIONING_NONE),  	header_height("header_height", 0),  	legacy_header_height("legacy_header_height", 0),  	close_image("close_image"), @@ -227,7 +237,6 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p)  	mShortTitle(p.short_title),  	mSingleInstance(p.single_instance),  	mKey(key), -	mAutoTile(p.auto_tile),  	mCanTearOff(p.can_tear_off),  	mCanMinimize(p.can_minimize),  	mCanClose(p.can_close), @@ -831,7 +840,7 @@ LLMultiFloater* LLFloater::getHost()  	return (LLMultiFloater*)mHostHandle.get();   } -void    LLFloater::applySavedVariables() +void LLFloater::applySavedVariables()  {  	applyRectControl();  	applyDockState(); @@ -839,13 +848,7 @@ void    LLFloater::applySavedVariables()  void LLFloater::applyRectControl()  { -	// first, center on screen if requested	 -	if (mOpenCentered) -	{ -		center(); -	} - -	// override center if we have saved rect control +	// If we have a saved rect, use it  	if (mRectControl.size() > 1)  	{  		const LLRect& rect = getControlGroup()->getRect(mRectControl); @@ -867,7 +870,50 @@ void LLFloater::applyDockState()  		bool dockState = getControlGroup()->getBOOL(mDocStateControl);  		setDocked(dockState);  	} +} + +void LLFloater::applyPositioning() +{ +	// Otherwise position according to the positioning code +	switch (mOpenPositioning) +	{ +	case LLFloaterEnums::OPEN_POSITIONING_CENTERED: +		center(); +		break; + +	case LLFloaterEnums::OPEN_POSITIONING_SPECIFIED: +		{ +			// Translate relative to snap rect +			LLRect r = getRect(); +			r.mBottom = getSnapRect().getHeight() - r.getHeight() - r.mBottom; +			setOrigin(r.mLeft, r.mBottom); +			translateIntoRect(getSnapRect(), FALSE); +		} +		break; +	case LLFloaterEnums::OPEN_POSITIONING_CASCADING: +		{ +			static const U32 CASCADING_FLOATER_HOFFSET = 25; +			static const U32 CASCADING_FLOATER_VOFFSET = 25; +			static const S32 CASCADING_FLOATER_LIMIT = 15; +			static S32 cascading_floater_count = 1;  +			const S32 top = CASCADING_FLOATER_VOFFSET * cascading_floater_count; +			const S32 left = CASCADING_FLOATER_HOFFSET * cascading_floater_count; +			setOrigin(left, top); +			translateIntoRect(getSnapRect(), FALSE); + +			if (++cascading_floater_count > CASCADING_FLOATER_LIMIT) +			{ +				cascading_floater_count = 1; +			} +		} +		break; + +	case LLFloaterEnums::OPEN_POSITIONING_NONE: +	default: +		// Do nothing +		break; +	}  }  void LLFloater::applyTitle() @@ -2784,7 +2830,6 @@ void LLFloater::setInstanceName(const std::string& name)  		{  			mDocStateControl = LLFloaterReg::declareDockStateControl(ctrl_name);  		} -  	}  } @@ -2846,9 +2891,9 @@ void LLFloater::initFromParams(const LLFloater::Params& p)  	mHeaderHeight = p.header_height;  	mLegacyHeaderHeight = p.legacy_header_height;  	mSingleInstance = p.single_instance; -	mAutoTile = p.auto_tile; -	mOpenCentered = p.open_centered; +	mOpenPositioning = p.open_positioning; +	/*  	if (p.save_rect && mRectControl.empty())  	{  		mRectControl = "t"; // flag to build mRectControl name once mInstanceName is set @@ -2856,7 +2901,7 @@ void LLFloater::initFromParams(const LLFloater::Params& p)  	if (p.save_visibility)  	{  		mVisibilityControl = "t"; // flag to build mVisibilityControl name once mInstanceName is set -	} +	}*/  	if(p.save_dock_state)  	{ @@ -3008,6 +3053,7 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str  		llerrs << "Failed to construct floater " << getName() << llendl;  	} +	applyPositioning();  	applyRectControl(); // If we have a saved rect control, apply it  	gFloaterView->adjustToFitScreen(this, FALSE); // Floaters loaded from XML should all fit on screen	 diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index af9665e599..b404306e94 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -59,11 +59,35 @@ const BOOL CLOSE_NO = FALSE;  const BOOL ADJUST_VERTICAL_YES = TRUE;  const BOOL ADJUST_VERTICAL_NO = FALSE; +namespace LLFloaterEnums +{ +	enum EOpenPositioning +	{ +		OPEN_POSITIONING_NONE, +		OPEN_POSITIONING_CASCADING, +		OPEN_POSITIONING_CENTERED, +		OPEN_POSITIONING_SPECIFIED, + +		OPEN_POSITIONING_COUNT +	}; +} + +namespace LLInitParam +{ +	template<> +	struct TypeValues<LLFloaterEnums::EOpenPositioning> : public TypeValuesHelper<LLFloaterEnums::EOpenPositioning> +	{ +		static void declareValues(); +	}; +} + +  class LLFloater : public LLPanel  { -friend class LLFloaterView; -friend class LLFloaterReg; -friend class LLMultiFloater; +	friend class LLFloaterView; +	friend class LLFloaterReg; +	friend class LLMultiFloater; +  public:  	struct KeyCompare  	{ @@ -95,7 +119,6 @@ public:  								short_title;  		Optional<bool>			single_instance, -								auto_tile,  								can_resize,  								can_minimize,  								can_close, @@ -104,8 +127,10 @@ public:  								save_rect,  								save_visibility,  								save_dock_state, -								can_dock, -								open_centered; +								can_dock; +		 +		Optional<LLFloaterEnums::EOpenPositioning>	open_positioning; +		  		Optional<S32>			header_height,  								legacy_header_height; // HACK see initFromXML() @@ -297,6 +322,7 @@ protected:  	virtual void	applyRectControl();  	void			applyDockState(); +	void			applyPositioning();  	void			storeRectControl();  	void			storeVisibilityControl();  	void			storeDockStateControl(); @@ -378,14 +404,14 @@ private:  	BOOL			mSingleInstance;	// TRUE if there is only ever one instance of the floater  	std::string		mInstanceName;		// Store the instance name so we can remove ourselves from the list -	BOOL			mAutoTile;			// TRUE if placement of new instances tiles  	BOOL			mCanTearOff;  	BOOL			mCanMinimize;  	BOOL			mCanClose;  	BOOL			mDragOnLeft;  	BOOL			mResizable; -	bool			mOpenCentered; + +	LLFloaterEnums::EOpenPositioning	mOpenPositioning;  	S32				mMinWidth;  	S32				mMinHeight; diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index ae06eb74ac..058223abbd 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -107,7 +107,6 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key)  			if (!groupname.empty())  			{  				instance_list_t& list = sInstanceMap[groupname]; -				int index = list.size();  				res = build_func(key);  				if (!res) @@ -121,27 +120,18 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key)  					llwarns << "Failed to build floater type: '" << name << "'." << llendl;  					return NULL;  				} -					 +  				// Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe  				if (res->mKey.isUndefined())   				{ -						res->mKey = key; +					res->mKey = key;  				}  				res->setInstanceName(name);  				res->applySavedVariables(); // Can't apply rect and dock state until setting instance name -				if (res->mAutoTile && !res->getHost() && index > 0) -				{ -					LLFloater* last_floater = getLastFloaterInGroup(groupname); -					if (last_floater) -					{ -						res->stackWith(*last_floater); -						gFloaterView->adjustToFitScreen(res, true); -					} -				} -				else -				{ -					gFloaterView->adjustToFitScreen(res, false); -				} + +				// apply list.size() and possibly stackWith(getLastFloaterInGroup(groupname)) +				gFloaterView->adjustToFitScreen(res, false); +  				list.push_back(res);  			}  		} @@ -477,16 +467,21 @@ void LLFloaterReg::toggleToolbarFloaterInstance(const LLSD& sdname)  	std::string name = sdname.asString();  	parse_name_key(name, key); -	LLFloater* instance = findInstance(name, key);  +	LLFloater* instance = getInstance(name, key);  -	if (LLFloater::isMinimized(instance)) +	if (!instance) +	{ +		lldebugs << "Unable to get instance of floater '" << name << "'" << llendl; +	} +	else if (instance->isMinimized())  	{  		instance->setMinimized(FALSE);  		instance->setFocus(TRUE);  	} -	else if (!LLFloater::isShown(instance)) +	else if (!instance->isShown())  	{ -		showInstance(name, key, TRUE); +		instance->openFloater(key); +		instance->setFocus(TRUE);  	}  	else if (!instance->hasFocus() && !instance->getIsChrome())  	{ | 
