Cleaning up the pie menu code

Wed, 10 Dec 2014 11:00:31 +0100

author
Ansariel
date
Wed, 10 Dec 2014 11:00:31 +0100
changeset 43048
4533555eb15a
parent 43047
a56111a080f7
child 43049
9134c936410e

Cleaning up the pie menu code

indra/newview/piemenu.cpp file | annotate | diff | revisions
indra/newview/piemenu.h file | annotate | diff | revisions
indra/newview/pieseparator.cpp file | annotate | diff | revisions
indra/newview/pieseparator.h file | annotate | diff | revisions
indra/newview/pieslice.cpp file | annotate | diff | revisions
indra/newview/pieslice.h file | annotate | diff | revisions
     1.1 --- a/indra/newview/piemenu.cpp	Tue Dec 09 15:27:04 2014 +0100
     1.2 +++ b/indra/newview/piemenu.cpp	Wed Dec 10 11:00:31 2014 +0100
     1.3 @@ -26,20 +26,18 @@
     1.4   */
     1.5  
     1.6  #include "llviewerprecompiledheaders.h"
     1.7 -#include "linden_common.h"
     1.8  
     1.9  #include "piemenu.h"
    1.10  #include "pieslice.h"
    1.11  #include "pieseparator.h"
    1.12  #include "llviewercontrol.h"
    1.13  #include "llviewerwindow.h"
    1.14 -#include "v2math.h"
    1.15  
    1.16  // copied from LLMenuGL - Remove these lines over there when finished
    1.17 -const S32 PIE_INNER_SIZE=20;		// radius of the inner pie circle
    1.18 -const F32 PIE_POPUP_FACTOR=(F32)1.7f;		// pie menu size factor on popup
    1.19 -const F32 PIE_POPUP_TIME=(F32)0.25f;		// time to shrink from popup size to regular size
    1.20 -const S32 PIE_OUTER_SIZE=96;		// radius of the outer pie circle
    1.21 +const S32 PIE_INNER_SIZE = 20;		// radius of the inner pie circle
    1.22 +const F32 PIE_POPUP_FACTOR = 1.7f;		// pie menu size factor on popup
    1.23 +const F32 PIE_POPUP_TIME = 0.25f;		// time to shrink from popup size to regular size
    1.24 +const S32 PIE_OUTER_SIZE = 96;		// radius of the outer pie circle
    1.25  
    1.26  // register the pie menu globally as child widget
    1.27  static LLDefaultChildRegistry::Register<PieMenu> r1("pie_menu");
    1.28 @@ -53,61 +51,64 @@
    1.29  #define PIE_DRAW_BOUNDING_BOX 0		// debug
    1.30  
    1.31  // pie slice label text positioning
    1.32 -const S32 PIE_X[] = {64,45, 0,-45,-63,-45,  0, 45};
    1.33 -const S32 PIE_Y[] = { 0,44,73, 44,  0,-44,-73,-44};
    1.34 +const S32 PIE_X[] = {64, 45,  0, -45, -63, -45,   0,  45};
    1.35 +const S32 PIE_Y[] = { 0, 44, 73,  44,   0, -44, -73, -44};
    1.36  
    1.37  PieMenu::PieMenu(const LLContextMenu::Params& p) :
    1.38  	LLContextMenu(p)
    1.39  {
    1.40  	LL_DEBUGS() << "PieMenu::PieMenu()" << LL_ENDL;
    1.41  	// radius, so we need this *2
    1.42 -	reshape(PIE_OUTER_SIZE*2,PIE_OUTER_SIZE*2,FALSE);
    1.43 +	reshape(PIE_OUTER_SIZE * 2, PIE_OUTER_SIZE * 2, FALSE);
    1.44  	// set up the font for the menu
    1.45 -	mFont=LLFontGL::getFont(LLFontDescriptor("SansSerif","Pie",LLFontGL::NORMAL));
    1.46 -	if(!mFont)
    1.47 +	mFont = LLFontGL::getFont(LLFontDescriptor("SansSerif", "Pie", LLFontGL::NORMAL));
    1.48 +	if (!mFont)
    1.49  	{
    1.50  		LL_WARNS() << "Could not find font size for Pie menu, falling back to Small font." << LL_ENDL;
    1.51 -		mFont=LLFontGL::getFont(LLFontDescriptor("SansSerif","Small",LLFontGL::NORMAL));
    1.52 +		mFont = LLFontGL::getFont(LLFontDescriptor("SansSerif", "Small", LLFontGL::NORMAL));
    1.53  	}
    1.54  	// set slices pointer to our own slices
    1.55 -	mSlices=&mMySlices;
    1.56 +	mSlices = &mMySlices;
    1.57  	// this will be the first click on the menu
    1.58 -	mFirstClick=TRUE;
    1.59 +	mFirstClick = true;
    1.60  
    1.61  	// clean initialisation
    1.62 -	mSlice=0;
    1.63 +	mSlice = NULL;
    1.64  }
    1.65  
    1.66 -bool PieMenu::addChild(LLView* child,S32 tab_group)
    1.67 +bool PieMenu::addChild(LLView* child, S32 tab_group)
    1.68  {
    1.69  	// don't add invalid slices
    1.70 -	if(!child)
    1.71 +	if (!child)
    1.72 +	{
    1.73  		return FALSE;
    1.74 +	}
    1.75  
    1.76  	// add a new slice to the menu
    1.77  	mSlices->push_back(child);
    1.78  
    1.79  	// tell the view that our menu has changed and reshape it back to correct size
    1.80  	LLUICtrl::addChild(child);
    1.81 -	reshape(PIE_OUTER_SIZE*2,PIE_OUTER_SIZE*2,FALSE);
    1.82 +	reshape(PIE_OUTER_SIZE * 2, PIE_OUTER_SIZE * 2, FALSE);
    1.83 +
    1.84  	return TRUE;
    1.85  }
    1.86  
    1.87  void PieMenu::removeChild(LLView* child)
    1.88  {
    1.89  	// remove a slice from the menu
    1.90 -	slice_list_t::iterator found_it=std::find(mSlices->begin(),mSlices->end(),child);
    1.91 -	if(found_it!=mSlices->end())
    1.92 +	slice_list_t::iterator found_it = std::find(mSlices->begin(), mSlices->end(), child);
    1.93 +	if (found_it != mSlices->end())
    1.94  	{
    1.95  		mSlices->erase(found_it);
    1.96  	}
    1.97  
    1.98  	// tell the view that our menu has changed and reshape it back to correct size
    1.99  	LLUICtrl::removeChild(child);
   1.100 -	reshape(PIE_OUTER_SIZE*2,PIE_OUTER_SIZE*2,FALSE);
   1.101 +	reshape(PIE_OUTER_SIZE * 2, PIE_OUTER_SIZE * 2, FALSE);
   1.102  }
   1.103  
   1.104 -BOOL PieMenu::handleHover(S32 x,S32 y,MASK mask)
   1.105 +BOOL PieMenu::handleHover(S32 x, S32 y, MASK mask)
   1.106  {
   1.107  	// do nothing
   1.108  	return TRUE;
   1.109 @@ -116,8 +117,10 @@
   1.110  void PieMenu::show(S32 x, S32 y, LLView* spawning_view)
   1.111  {
   1.112  	// if the menu is already there, do nothing
   1.113 -	if(getVisible())
   1.114 +	if (getVisible())
   1.115 +	{
   1.116  		return;
   1.117 +	}
   1.118  
   1.119  	// play a sound
   1.120  	make_ui_sound("UISndPieMenuAppear");
   1.121 @@ -125,41 +128,49 @@
   1.122  	LL_DEBUGS() << "PieMenu::show(): " << x << " " << y << LL_ENDL;
   1.123  
   1.124  	// make sure the menu is always the correct size
   1.125 -	reshape(PIE_OUTER_SIZE*2,PIE_OUTER_SIZE*2,FALSE);
   1.126 +	reshape(PIE_OUTER_SIZE * 2, PIE_OUTER_SIZE * 2, FALSE);
   1.127  
   1.128  	// remember our center point
   1.129 -	mCenterX=x;
   1.130 -	mCenterY=y;
   1.131 +	mCenterX = x;
   1.132 +	mCenterY = y;
   1.133  
   1.134  	// get the 3D view rectangle
   1.135 -	LLRect screen=LLMenuGL::sMenuContainer->getMenuRect();
   1.136 +	LLRect screen = LLMenuGL::sMenuContainer->getMenuRect();
   1.137  
   1.138  	// check if the pie menu is out of bounds and move it accordingly
   1.139 -	if(x-PIE_OUTER_SIZE<0)
   1.140 -		x=PIE_OUTER_SIZE;
   1.141 -	else if(x+PIE_OUTER_SIZE>screen.getWidth())
   1.142 -		x=screen.getWidth()-PIE_OUTER_SIZE;
   1.143 +	if (x - PIE_OUTER_SIZE < 0)
   1.144 +	{
   1.145 +		x = PIE_OUTER_SIZE;
   1.146 +	}
   1.147 +	else if (x + PIE_OUTER_SIZE > screen.getWidth())
   1.148 +	{
   1.149 +		x = screen.getWidth() - PIE_OUTER_SIZE;
   1.150 +	}
   1.151  
   1.152 -	if(y-PIE_OUTER_SIZE<screen.mBottom)
   1.153 -		y=PIE_OUTER_SIZE+screen.mBottom;
   1.154 -	else if(y+PIE_OUTER_SIZE-screen.mBottom>screen.getHeight())
   1.155 -		y=screen.getHeight()-PIE_OUTER_SIZE+screen.mBottom;
   1.156 +	if (y - PIE_OUTER_SIZE < screen.mBottom)
   1.157 +	{
   1.158 +		y = PIE_OUTER_SIZE + screen.mBottom;
   1.159 +	}
   1.160 +	else if (y + PIE_OUTER_SIZE - screen.mBottom > screen.getHeight())
   1.161 +	{
   1.162 +		y = screen.getHeight() - PIE_OUTER_SIZE + screen.mBottom;
   1.163 +	}
   1.164  
   1.165  	// move the mouse pointer into the center of the menu
   1.166 -	LLUI::setMousePositionLocal(getParent(),x,y);
   1.167 +	LLUI::setMousePositionLocal(getParent(), x, y);
   1.168  	// set our drawing origin to the center of the menu, taking UI scale into account
   1.169 -	LLVector2 scale=gViewerWindow->getDisplayScale();
   1.170 -	setOrigin(x-PIE_OUTER_SIZE/scale.mV[VX],y-PIE_OUTER_SIZE/scale.mV[VY]);
   1.171 +	LLVector2 scale = gViewerWindow->getDisplayScale();
   1.172 +	setOrigin(x - PIE_OUTER_SIZE / scale.mV[VX], y - PIE_OUTER_SIZE / scale.mV[VY]);
   1.173  	// grab mouse control
   1.174  	gFocusMgr.setMouseCapture(this);
   1.175  
   1.176  	// this was the first click for the menu
   1.177 -	mFirstClick=TRUE;
   1.178 +	mFirstClick = true;
   1.179  	// set up the slices pointer to the menu's own slices
   1.180 -	mSlices=&mMySlices;
   1.181 +	mSlices = &mMySlices;
   1.182  
   1.183  	// reset enable update checks for slices
   1.184 -	for (slice_list_t::iterator it = mSlices->begin(); it != mSlices->end(); it++)
   1.185 +	for (slice_list_t::iterator it = mSlices->begin(); it != mSlices->end(); ++it)
   1.186  	{
   1.187  		PieSlice* resetSlice = dynamic_cast<PieSlice*>(*it);
   1.188  		if (resetSlice)
   1.189 @@ -169,8 +180,8 @@
   1.190  	}
   1.191  
   1.192  	// cleanup
   1.193 -	mSlice=0;
   1.194 -	mOldSlice=0;
   1.195 +	mSlice = NULL;
   1.196 +	mOldSlice = NULL;
   1.197  
   1.198  	// draw the menu on screen
   1.199  	setVisible(TRUE);
   1.200 @@ -180,15 +191,17 @@
   1.201  void PieMenu::hide()
   1.202  {
   1.203  	// if the menu is already hidden, do nothing
   1.204 -	if(!getVisible())
   1.205 +	if (!getVisible())
   1.206 +	{
   1.207  		return;
   1.208 +	}
   1.209  
   1.210  	// make a sound when hiding
   1.211  	make_ui_sound("UISndPieMenuHide");
   1.212  
   1.213  	LL_DEBUGS() << "Clearing selections" << LL_ENDL;
   1.214  
   1.215 -	mSlices=&mMySlices;
   1.216 +	mSlices = &mMySlices;
   1.217  #if PIE_POPUP_EFFECT
   1.218  	// safety in case the timer was still running
   1.219  	mPopupTimer.stop();
   1.220 @@ -199,7 +212,7 @@
   1.221  void PieMenu::setVisible(BOOL visible)
   1.222  {
   1.223  	// hide the menu if needed
   1.224 -	if(!visible)
   1.225 +	if (!visible)
   1.226  	{
   1.227  		hide();
   1.228  		// clear all menus and temporary selections
   1.229 @@ -207,37 +220,37 @@
   1.230  	}
   1.231  }
   1.232  
   1.233 -void PieMenu::draw( void )
   1.234 +void PieMenu::draw()
   1.235  {
   1.236  	// save the current OpenGL drawing matrix so we can freely modify it
   1.237  	gGL.pushMatrix();
   1.238  
   1.239  	// save the widget's rectangle for later use
   1.240 -	LLRect r=getRect();
   1.241 +	LLRect r = getRect();
   1.242  
   1.243  	// initialize pie scale factor for popup effect
   1.244 -	F32 factor=1.f;
   1.245 +	F32 factor = 1.f;
   1.246  
   1.247  #if PIE_POPUP_EFFECT
   1.248  	// set the popup size if this was the first click on the menu
   1.249 -	if(mFirstClick)
   1.250 +	if (mFirstClick)
   1.251  	{
   1.252 -		factor=PIE_POPUP_FACTOR;
   1.253 +		factor = PIE_POPUP_FACTOR;
   1.254  	}
   1.255  	// otherwise check if the popup timer is still running
   1.256 -	else if(mPopupTimer.getStarted())
   1.257 +	else if (mPopupTimer.getStarted())
   1.258  	{
   1.259  		// if the timer ran past the popup time, stop the timer and set the size to 1.0
   1.260 -		F32 elapsedTime=mPopupTimer.getElapsedTimeF32();
   1.261 -		if(elapsedTime>PIE_POPUP_TIME)
   1.262 +		F32 elapsedTime = mPopupTimer.getElapsedTimeF32();
   1.263 +		if (elapsedTime > PIE_POPUP_TIME)
   1.264  		{
   1.265 -			factor=1.f;
   1.266 +			factor = 1.f;
   1.267  			mPopupTimer.stop();
   1.268  		}
   1.269  		// otherwise calculate the size factor to make the menu shrink over time
   1.270  		else
   1.271  		{
   1.272 -			factor=PIE_POPUP_FACTOR-(PIE_POPUP_FACTOR-1.f)*elapsedTime/PIE_POPUP_TIME;
   1.273 +			factor = PIE_POPUP_FACTOR - (PIE_POPUP_FACTOR - 1.f) * elapsedTime / PIE_POPUP_TIME;
   1.274  		}
   1.275  //		setRect(r);  // obsolete?
   1.276  	}
   1.277 @@ -245,15 +258,15 @@
   1.278  
   1.279  #if PIE_DRAW_BOUNDING_BOX
   1.280  	// draw a bounding box around the menu for debugging purposes
   1.281 -	gl_rect_2d(0,r.getHeight(),r.getWidth(),0,LLColor4::white,FALSE);
   1.282 +	gl_rect_2d(0, r.getHeight(), r.getWidth(), 0, LLColor4::white, FALSE);
   1.283  #endif
   1.284  
   1.285  	// set up pie menu colors
   1.286 -	LLColor4 lineColor=LLUIColorTable::instance().getColor("PieMenuLineColor");
   1.287 -	LLColor4 selectedColor=LLUIColorTable::instance().getColor("PieMenuSelectedColor");
   1.288 -	LLColor4 textColor=LLUIColorTable::instance().getColor("PieMenuTextColor");
   1.289 -	LLColor4 bgColor=LLUIColorTable::instance().getColor("PieMenuBgColor");
   1.290 -	LLColor4 borderColor=bgColor % (F32)0.3f;
   1.291 +	LLColor4 lineColor = LLUIColorTable::instance().getColor("PieMenuLineColor");
   1.292 +	LLColor4 selectedColor = LLUIColorTable::instance().getColor("PieMenuSelectedColor");
   1.293 +	LLColor4 textColor = LLUIColorTable::instance().getColor("PieMenuTextColor");
   1.294 +	LLColor4 bgColor = LLUIColorTable::instance().getColor("PieMenuBgColor");
   1.295 +	LLColor4 borderColor = bgColor % 0.3f;
   1.296  
   1.297  	// if the user wants their own colors, apply them here
   1.298  	static LLCachedControl<bool> sOverridePieColors(gSavedSettings, "OverridePieColors", false);
   1.299 @@ -261,84 +274,88 @@
   1.300  	{
   1.301  		static LLCachedControl<F32> sPieMenuOpacity(gSavedSettings, "PieMenuOpacity");
   1.302  		static LLCachedControl<F32> sPieMenuFade(gSavedSettings, "PieMenuFade");
   1.303 -		bgColor=LLUIColorTable::instance().getColor("PieMenuBgColorOverride") % sPieMenuOpacity;
   1.304 -		borderColor=bgColor % (1.f - sPieMenuFade);
   1.305 -		selectedColor=LLUIColorTable::instance().getColor("PieMenuSelectedColorOverride");
   1.306 +		bgColor = LLUIColorTable::instance().getColor("PieMenuBgColorOverride") % sPieMenuOpacity;
   1.307 +		borderColor = bgColor % (1.f - sPieMenuFade);
   1.308 +		selectedColor = LLUIColorTable::instance().getColor("PieMenuSelectedColorOverride");
   1.309  	}
   1.310  
   1.311  	// on first click, make the menu fade out to indicate "borderless" operation
   1.312 -	if(mFirstClick)
   1.313 -		borderColor%=0.f;
   1.314 +	if (mFirstClick)
   1.315 +	{
   1.316 +		borderColor %= 0.f;
   1.317 +	}
   1.318  
   1.319  	// initially, the current segment is marked as invalid
   1.320 -	S32 currentSegment=-1;
   1.321 +	S32 currentSegment = -1;
   1.322  
   1.323  	// get the current mouse pointer position local to the pie
   1.324 -	S32 x,y;
   1.325 -	LLUI::getMousePositionLocal(this,&x,&y);
   1.326 +	S32 x, y;
   1.327 +	LLUI::getMousePositionLocal(this, &x, &y);
   1.328  	// remember to take the UI scaling into account
   1.329 -	LLVector2 scale=gViewerWindow->getDisplayScale();
   1.330 +	LLVector2 scale = gViewerWindow->getDisplayScale();
   1.331  	// move mouse coordinates to be relative to the pie center
   1.332 -	LLVector2 mouseVector(x-PIE_OUTER_SIZE/scale.mV[VX],y-PIE_OUTER_SIZE/scale.mV[VY]);
   1.333 +	LLVector2 mouseVector(x - PIE_OUTER_SIZE / scale.mV[VX], y - PIE_OUTER_SIZE / scale.mV[VY]);
   1.334  
   1.335  	// get the distance from the center point
   1.336 -	F32 distance=mouseVector.length();
   1.337 +	F32 distance = mouseVector.length();
   1.338  	// check if our mouse pointer is within the pie slice area
   1.339 -	if(distance>PIE_INNER_SIZE && (distance<(PIE_OUTER_SIZE*factor) || mFirstClick))
   1.340 +	if (distance > PIE_INNER_SIZE && (distance < (PIE_OUTER_SIZE * factor) || mFirstClick))
   1.341  	{
   1.342  		// get the angle of the mouse pointer from the center in radians
   1.343 -		F32 angle=acos(mouseVector.mV[VX]/distance);
   1.344 +		F32 angle = acos(mouseVector.mV[VX] / distance);
   1.345  		// if the mouse is below the middle of the pie, reverse the angle
   1.346 -		if(mouseVector.mV[VY]<0)
   1.347 -			angle=F_PI*2-angle;
   1.348 +		if (mouseVector.mV[VY] < 0)
   1.349 +		{
   1.350 +			angle = F_PI * 2 - angle;
   1.351 +		}
   1.352  		// rotate the angle slightly so the slices' centers are aligned correctly
   1.353 -		angle+=F_PI/8;
   1.354 +		angle += F_PI / 8;
   1.355  
   1.356  		// calculate slice number from the angle
   1.357 -		currentSegment=(S32) (8.f*angle/(F_PI*2.f)) % 8;
   1.358 +		currentSegment = (S32) (8.f * angle / (F_PI * 2.f)) % 8;
   1.359  	}
   1.360  
   1.361  	// move origin point to the center of our rectangle
   1.362  	gGL.translatef(r.getWidth() / 2, r.getHeight() / 2, 0);
   1.363  
   1.364  	// draw the general pie background
   1.365 -	gl_washer_2d(PIE_OUTER_SIZE*factor,PIE_INNER_SIZE,32,bgColor,borderColor);
   1.366 +	gl_washer_2d(PIE_OUTER_SIZE * factor, PIE_INNER_SIZE, 32, bgColor, borderColor);
   1.367  
   1.368  	// set up an item list iterator to point at the beginning of the item list
   1.369  	slice_list_t::iterator cur_item_iter;
   1.370 -	cur_item_iter=mSlices->begin();
   1.371 +	cur_item_iter = mSlices->begin();
   1.372  
   1.373  	// clear current slice pointer
   1.374 -	mSlice=0;
   1.375 +	mSlice = NULL;
   1.376  	// current slice number is 0
   1.377 -	S32 num=0;
   1.378 -	BOOL wasAutohide=FALSE;
   1.379 +	S32 num = 0;
   1.380 +	bool wasAutohide = false;
   1.381  	do
   1.382  	{
   1.383  		// standard item text color
   1.384 -		LLColor4 itemColor=textColor;
   1.385 +		LLColor4 itemColor = textColor;
   1.386  
   1.387  		// clear the label and set up the starting angle to draw in
   1.388  		std::string label("");
   1.389 -		F32 segmentStart = F_PI/4.f * (F32)num - F_PI / 8.f;
   1.390 +		F32 segmentStart = F_PI / 4.f * (F32)num - F_PI / 8.f;
   1.391  
   1.392  		// iterate through the list of slices
   1.393 -		if(cur_item_iter!=mSlices->end())
   1.394 +		if (cur_item_iter != mSlices->end())
   1.395  		{
   1.396  			// get current slice item
   1.397 -			LLView* item=(*cur_item_iter);
   1.398 +			LLView* item = (*cur_item_iter);
   1.399  
   1.400  			// check if this is a submenu or a normal click slice
   1.401 -			PieSlice* currentSlice=dynamic_cast<PieSlice*>(item);
   1.402 -			PieMenu* currentSubmenu=dynamic_cast<PieMenu*>(item);
   1.403 +			PieSlice* currentSlice = dynamic_cast<PieSlice*>(item);
   1.404 +			PieMenu* currentSubmenu = dynamic_cast<PieMenu*>(item);
   1.405  			// advance internally to the next slice item
   1.406  			cur_item_iter++;
   1.407  
   1.408  			// in case it is regular click slice
   1.409 -			if(currentSlice)
   1.410 +			if (currentSlice)
   1.411  			{
   1.412  				// get the slice label and tell the slice to check if it's supposed to be visible
   1.413 -				label=currentSlice->getLabel();
   1.414 +				label = currentSlice->getLabel();
   1.415  				currentSlice->updateVisible();
   1.416  				// disable it if it's not visible, pie slices never really disappear
   1.417  				BOOL slice_visible = currentSlice->getVisible();
   1.418 @@ -350,68 +367,81 @@
   1.419  				}
   1.420  
   1.421  				// if the current slice is the start of an autohide chain, clear out previous chains
   1.422 -				if(currentSlice->getStartAutohide())
   1.423 -					wasAutohide=FALSE;
   1.424 +				if (currentSlice->getStartAutohide())
   1.425 +				{
   1.426 +					wasAutohide = false;
   1.427 +				}
   1.428  
   1.429  				// check if the current slice is part of an autohide chain
   1.430 -				if(currentSlice->getAutohide())
   1.431 +				if (currentSlice->getAutohide())
   1.432  				{
   1.433  					// if the previous item already won the autohide, skip this item
   1.434 -					if(wasAutohide)
   1.435 +					if (wasAutohide)
   1.436 +					{
   1.437  						continue;
   1.438 +					}
   1.439 +
   1.440  					// look at the next item in the pie
   1.441 -					LLView* lookAhead=(*cur_item_iter);
   1.442 +					LLView* lookAhead = (*cur_item_iter);
   1.443  					// check if this is a normal click slice
   1.444 -					PieSlice* lookSlice=dynamic_cast<PieSlice*>(lookAhead);
   1.445 -					if(lookSlice)
   1.446 +					PieSlice* lookSlice = dynamic_cast<PieSlice*>(lookAhead);
   1.447 +					if (lookSlice)
   1.448  					{
   1.449  						// if the next item is part of the current autohide chain as well ...
   1.450 -						if(lookSlice->getAutohide() && !lookSlice->getStartAutohide())
   1.451 +						if (lookSlice->getAutohide() && !lookSlice->getStartAutohide())
   1.452  						{
   1.453  							// ... it's visible and it's enabled, skip the current one.
   1.454  							// the first visible and enabled item in autohide chains wins
   1.455  							// this is useful for Sit/Stand toggles
   1.456  							lookSlice->updateEnabled();
   1.457  							lookSlice->updateVisible();
   1.458 -							if(lookSlice->getVisible() && lookSlice->getEnabled())
   1.459 +							if (lookSlice->getVisible() && lookSlice->getEnabled())
   1.460 +							{
   1.461  								continue;
   1.462 +							}
   1.463 +
   1.464  							// this item won the autohide contest
   1.465 -							wasAutohide=TRUE;
   1.466 +							wasAutohide = true;
   1.467  						}
   1.468  					}
   1.469  				}
   1.470  				else
   1.471 +				{
   1.472  					// reset autohide chain
   1.473 -					wasAutohide=FALSE;
   1.474 +					wasAutohide = false;
   1.475 +				}
   1.476 +
   1.477  				// check if the slice is currently enabled
   1.478  				currentSlice->updateEnabled();
   1.479 -				if(!currentSlice->getEnabled())
   1.480 +				if (!currentSlice->getEnabled())
   1.481  				{
   1.482  					LL_DEBUGS() << label << " is disabled" << LL_ENDL;
   1.483  					// fade the item color alpha to mark the item as disabled
   1.484 -					itemColor%=(F32)0.3f;
   1.485 +					itemColor %= 0.3f;
   1.486  				}
   1.487  			}
   1.488  			// if it's a submenu just get the label
   1.489 -			else if(currentSubmenu)
   1.490 -				label=currentSubmenu->getLabel();
   1.491 +			else if (currentSubmenu)
   1.492 +			{
   1.493 +				label = currentSubmenu->getLabel();
   1.494 +			}
   1.495  
   1.496  			// if it's a slice or submenu, the mouse pointer is over the same segment as our counter and the item is enabled
   1.497 -			if((currentSlice || currentSubmenu) && (currentSegment==num) && item->getEnabled())
   1.498 +			if ((currentSlice || currentSubmenu) && (currentSegment==num) && item->getEnabled())
   1.499  			{
   1.500  				// memorize the currently highlighted slice for later
   1.501 -				mSlice=item;
   1.502 +				mSlice = item;
   1.503  				// if we highlighted a different slice than before, we must play a sound
   1.504 -				if(mOldSlice!=mSlice)
   1.505 +				if (mOldSlice != mSlice)
   1.506  				{
   1.507  					// get the appropriate UI sound and play it
   1.508 -					char soundNum='0'+num;
   1.509 -					std::string soundName="UISndPieMenuSliceHighlight";
   1.510 -					soundName+=soundNum;
   1.511 +					char soundNum = '0' + num;
   1.512 +					std::string soundName = "UISndPieMenuSliceHighlight";
   1.513 +					soundName += soundNum;
   1.514  
   1.515  					make_ui_sound(soundName.c_str());
   1.516  					// remember which slice we highlighted last, so we only play the sound once
   1.517 -					mOldSlice=mSlice;
   1.518 +					mOldSlice = mSlice;
   1.519  				}
   1.520  
   1.521  				// draw the currently highlighted pie slice
   1.522 @@ -434,12 +464,14 @@
   1.523  		// next slice
   1.524  		num++;
   1.525  	}
   1.526 -	while(num<8);	// do this until the menu is full
   1.527 +	while (num < 8);	// do this until the menu is full
   1.528  
   1.529  	// draw inner and outer circle, outer only if it was not the first click
   1.530 -	if(!mFirstClick)
   1.531 +	if (!mFirstClick)
   1.532 +	{
   1.533  		gl_washer_2d(PIE_OUTER_SIZE * factor, PIE_OUTER_SIZE * factor - 2.f, 32, lineColor, borderColor);
   1.534 -	gl_washer_2d(PIE_INNER_SIZE+1,PIE_INNER_SIZE-1,16,borderColor,lineColor);
   1.535 +	}
   1.536 +	gl_washer_2d(PIE_INNER_SIZE + 1, PIE_INNER_SIZE - 1, 16, borderColor, lineColor);
   1.537  
   1.538  	// restore OpenGL drawing matrix
   1.539  	gGL.popMatrix();
   1.540 @@ -451,8 +483,10 @@
   1.541  BOOL PieMenu::appendContextSubMenu(PieMenu* menu)
   1.542  {
   1.543  	LL_DEBUGS() << "PieMenu::appendContextSubMenu()" << LL_ENDL;
   1.544 -	if(!menu)
   1.545 +	if (!menu)
   1.546 +	{
   1.547  		return FALSE;
   1.548 +	}
   1.549  
   1.550  	LL_DEBUGS() << "PieMenu::appendContextSubMenu() appending " << menu->getLabel() << " to " << getLabel() << LL_ENDL;
   1.551  
   1.552 @@ -460,28 +494,29 @@
   1.553  	mSlices->push_back(menu);
   1.554  	// tell the view that our menu has changed
   1.555  	LLUICtrl::addChild(menu);
   1.556 +
   1.557  	return TRUE;
   1.558  }
   1.559  
   1.560 -BOOL PieMenu::handleMouseUp(S32 x,S32 y,MASK mask)
   1.561 +BOOL PieMenu::handleMouseUp(S32 x, S32 y, MASK mask)
   1.562  {
   1.563  	// left and right mouse buttons both do the same thing currently
   1.564 -	return handleMouseButtonUp(x,y,mask);
   1.565 +	return handleMouseButtonUp(x, y, mask);
   1.566  }
   1.567  
   1.568 -BOOL PieMenu::handleRightMouseUp(S32 x,S32 y,MASK mask)
   1.569 +BOOL PieMenu::handleRightMouseUp(S32 x, S32 y, MASK mask)
   1.570  {
   1.571  	// left and right mouse buttons both do the same thing currently
   1.572 -	return handleMouseButtonUp(x,y,mask);
   1.573 +	return handleMouseButtonUp(x, y, mask);
   1.574  }
   1.575  
   1.576  // left and right mouse buttons both do the same thing currently
   1.577 -BOOL PieMenu::handleMouseButtonUp(S32 x,S32 y,MASK mask)
   1.578 +BOOL PieMenu::handleMouseButtonUp(S32 x, S32 y, MASK mask)
   1.579  {
   1.580  	// if this was the first click and no slice is highlighted (no borderless click), start the popup timer
   1.581 -	if(mFirstClick && !mSlice)
   1.582 +	if (mFirstClick && !mSlice)
   1.583  	{
   1.584 -		mFirstClick=FALSE;
   1.585 +		mFirstClick = false;
   1.586  #if PIE_POPUP_EFFECT
   1.587  		mPopupTimer.start();
   1.588  #endif
   1.589 @@ -489,11 +524,11 @@
   1.590  	else
   1.591  	{
   1.592  		// default to invisible
   1.593 -		BOOL visible=FALSE;
   1.594 +		BOOL visible = FALSE;
   1.595  
   1.596  		// get the current selected slice and check if this is a regular click slice
   1.597 -		PieSlice* currentSlice=dynamic_cast<PieSlice*>(mSlice);
   1.598 -		if(currentSlice)
   1.599 +		PieSlice* currentSlice = dynamic_cast<PieSlice*>(mSlice);
   1.600 +		if (currentSlice)
   1.601  		{
   1.602  			// if so, click it and make a sound
   1.603  			make_ui_sound("UISndClickRelease");
   1.604 @@ -502,15 +537,15 @@
   1.605  		else
   1.606  		{
   1.607  			// check if this was a submenu
   1.608 -			PieMenu* currentSubmenu=dynamic_cast<PieMenu*>(mSlice);
   1.609 -			if(currentSubmenu)
   1.610 +			PieMenu* currentSubmenu = dynamic_cast<PieMenu*>(mSlice);
   1.611 +			if (currentSubmenu)
   1.612  			{
   1.613  				// if so, remember we clicked the menu already at least once
   1.614 -				mFirstClick=FALSE;
   1.615 +				mFirstClick = false;
   1.616  				// swap out the list of items for the ones in the submenu
   1.617 -				mSlices=&currentSubmenu->mMySlices;
   1.618 +				mSlices = &currentSubmenu->mMySlices;
   1.619  				// reset enable update checks for slices
   1.620 -				for (slice_list_t::iterator it = mSlices->begin(); it != mSlices->end(); it++)
   1.621 +				for (slice_list_t::iterator it = mSlices->begin(); it != mSlices->end(); ++it)
   1.622  				{
   1.623  					PieSlice* resetSlice = dynamic_cast<PieSlice*>(*it);
   1.624  					if (resetSlice)
   1.625 @@ -519,7 +554,7 @@
   1.626  					}
   1.627  				}
   1.628  				// the menu stays visible
   1.629 -				visible=TRUE;
   1.630 +				visible = TRUE;
   1.631  #if PIE_POPUP_EFFECT
   1.632  				// restart the popup timer
   1.633  				mPopupTimer.reset();
   1.634 @@ -533,9 +568,11 @@
   1.635  		setVisible(visible);
   1.636  	}
   1.637  	// release mouse capture after the first click if we still have it grabbed
   1.638 -	if(hasMouseCapture())
   1.639 +	if (hasMouseCapture())
   1.640 +	{
   1.641  		gFocusMgr.setMouseCapture(NULL);
   1.642 +	}
   1.643  
   1.644  	// give control back to the system
   1.645 -	return LLView::handleMouseUp(x,y,mask);
   1.646 +	return LLView::handleMouseUp(x, y, mask);
   1.647  }
     2.1 --- a/indra/newview/piemenu.h	Tue Dec 09 15:27:04 2014 +0100
     2.2 +++ b/indra/newview/piemenu.h	Wed Dec 10 11:00:31 2014 +0100
     2.3 @@ -45,7 +45,7 @@
     2.4  
     2.5  			Params()
     2.6  			{
     2.7 -				visible=false;
     2.8 +				visible = false;
     2.9  			}
    2.10  		};
    2.11  
    2.12 @@ -57,7 +57,7 @@
    2.13  		/*virtual*/ void setVisible(BOOL visible);
    2.14  
    2.15  		// adding and removing "child" slices to the pie
    2.16 -		/*virtual*/ bool addChild(LLView* child,S32 tab_group=0);
    2.17 +		/*virtual*/ bool addChild(LLView* child, S32 tab_group = 0);
    2.18  		/*virtual*/ void removeChild(LLView* child);
    2.19  
    2.20  		/*virtual*/ BOOL handleHover(S32 x,S32 y,MASK mask);
    2.21 @@ -90,7 +90,7 @@
    2.22  
    2.23  	protected:
    2.24  		// general mouse button handling
    2.25 -		BOOL handleMouseButtonUp(S32 x,S32 y,MASK mask);
    2.26 +		BOOL handleMouseButtonUp(S32 x, S32 y, MASK mask);
    2.27  		// font used for the menu
    2.28  		const LLFontGL* mFont;
    2.29  		// currently highlighted item, must be tested if it's a slice or submenu
    2.30 @@ -104,7 +104,7 @@
    2.31  		S32 mCenterX;
    2.32  		S32 mCenterY;
    2.33  		// this is TRUE when the first mouseclick came to display the menu, used for borderless menu
    2.34 -		BOOL mFirstClick;
    2.35 +		bool mFirstClick;
    2.36  };
    2.37  
    2.38  #endif // PIEMENU_H
     3.1 --- a/indra/newview/pieseparator.cpp	Tue Dec 09 15:27:04 2014 +0100
     3.2 +++ b/indra/newview/pieseparator.cpp	Wed Dec 10 11:00:31 2014 +0100
     3.3 @@ -26,7 +26,6 @@
     3.4   */
     3.5  
     3.6  #include "llviewerprecompiledheaders.h"
     3.7 -#include "linden_common.h"
     3.8  
     3.9  #include "pieseparator.h"
    3.10  
    3.11 @@ -40,5 +39,5 @@
    3.12  // pick up parameters from the XUI definition
    3.13  PieSeparator::Params::Params()
    3.14  {
    3.15 -	name="pie_separator";
    3.16 +	name = "pie_separator";
    3.17  }
     4.1 --- a/indra/newview/pieseparator.h	Tue Dec 09 15:27:04 2014 +0100
     4.2 +++ b/indra/newview/pieseparator.h	Wed Dec 10 11:00:31 2014 +0100
     4.3 @@ -28,7 +28,6 @@
     4.4  #ifndef PIESEPARATOR_H
     4.5  #define PIESEPARATOR_H
     4.6  
     4.7 -#include "llinitparam.h"
     4.8  #include "lluictrl.h"
     4.9  
    4.10  // a pie slice that does nothing and is not highlighting by mouse hover
     5.1 --- a/indra/newview/pieslice.cpp	Tue Dec 09 15:27:04 2014 +0100
     5.2 +++ b/indra/newview/pieslice.cpp	Wed Dec 10 11:00:31 2014 +0100
     5.3 @@ -47,9 +47,9 @@
     5.4  	on_click("on_click"),
     5.5  	on_visible("on_visible"),
     5.6  	on_enable("on_enable"),
     5.7 -	start_autohide("start_autohide",FALSE),
     5.8 -	autohide("autohide",FALSE),
     5.9 -	check_enable_once("check_enable_once",FALSE)
    5.10 +	start_autohide("start_autohide", FALSE),
    5.11 +	autohide("autohide", FALSE),
    5.12 +	check_enable_once("check_enable_once", FALSE)
    5.13  {
    5.14  }
    5.15  
    5.16 @@ -57,7 +57,7 @@
    5.17  void PieSlice::initFromParams(const Params& p)
    5.18  {
    5.19  	// add a callback if on_click is provided
    5.20 -	if(p.on_click.isProvided())
    5.21 +	if (p.on_click.isProvided())
    5.22  	{
    5.23  		setCommitCallback(initCommitCallback(p.on_click));
    5.24  	}
    5.25 @@ -87,12 +87,12 @@
    5.26  // call this to make the menu update its "enabled" status
    5.27  void PieSlice::updateEnabled()
    5.28  {
    5.29 -	if(mDoUpdateEnabled && mEnableSignal.num_slots()>0)
    5.30 +	if (mDoUpdateEnabled && mEnableSignal.num_slots() > 0)
    5.31  	{
    5.32 -		bool enabled=mEnableSignal(this,LLSD());
    5.33 -		if(mEnabledControlVariable)
    5.34 +		bool enabled = mEnableSignal(this, LLSD());
    5.35 +		if (mEnabledControlVariable)
    5.36  		{
    5.37 -			if(!enabled)
    5.38 +			if (!enabled)
    5.39  			{
    5.40  				// callback overrides control variable; this will call setEnabled()
    5.41  				mEnabledControlVariable->set(false);
    5.42 @@ -110,9 +110,9 @@
    5.43  // call this to make the menu update its "visible" status
    5.44  void PieSlice::updateVisible()
    5.45  {
    5.46 -	if(mVisibleSignal.num_slots()>0)
    5.47 +	if (mVisibleSignal.num_slots() > 0)
    5.48  	{
    5.49 -		bool visible=mVisibleSignal(this,LLSD());
    5.50 +		bool visible = mVisibleSignal(this, LLSD());
    5.51  		setVisible(visible);
    5.52  	}
    5.53  }
    5.54 @@ -138,7 +138,7 @@
    5.55  // accessor
    5.56  void PieSlice::setLabel(const std::string newLabel)
    5.57  {
    5.58 -	mLabel=newLabel;
    5.59 +	mLabel = newLabel;
    5.60  }
    5.61  
    5.62  // accessor
     6.1 --- a/indra/newview/pieslice.h	Tue Dec 09 15:27:04 2014 +0100
     6.2 +++ b/indra/newview/pieslice.h	Wed Dec 10 11:00:31 2014 +0100
     6.3 @@ -28,9 +28,6 @@
     6.4  #ifndef PIESLICE_H
     6.5  #define PIESLICE_H
     6.6  
     6.7 -#include <boost/signals2.hpp>
     6.8 -
     6.9 -#include "llinitparam.h"
    6.10  #include "lluictrl.h"
    6.11  
    6.12  // A slice in the pie. Does nothing by itself, just stores the function and

mercurial