summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dyukov <adyukov@productengine.com>2009-11-16 18:09:33 +0200
committerAndrew Dyukov <adyukov@productengine.com>2009-11-16 18:09:33 +0200
commit32d8e9e396d497a83eb068888d794dd34216f6d7 (patch)
treeab49fdea2783d5b5c5ac3fa3be4a5d1933754071
parent1a7166dd40aaf0c96b0f3581dfdffc78f76f53b1 (diff)
Some coding style changes of EXT-1014 (Unable to move undocked camera controls bar)
fix (c63047a5bf60). --HG-- branch : product-engine
-rw-r--r--indra/newview/lljoystickbutton.cpp18
-rw-r--r--indra/newview/lljoystickbutton.h8
2 files changed, 17 insertions, 9 deletions
diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp
index d7eaad94f0..0acc67ff5a 100644
--- a/indra/newview/lljoystickbutton.cpp
+++ b/indra/newview/lljoystickbutton.cpp
@@ -134,15 +134,17 @@ void LLJoystick::updateSlop()
return;
}
-BOOL LLJoystick::pointInCircle(S32 x, S32 y) const
+bool LLJoystick::pointInCircle(S32 x, S32 y) const
{
- //cnt is x and y coordinates of center of joystick circle, and also its radius,
- //because area is not just rectangular, it's a square!
- //Make sure to change method if this changes.
- int cnt = this->getLocalRect().mTop/2;
- if((x-cnt)*(x-cnt)+(y-cnt)*(y-cnt)<=cnt*cnt)
+ if(this->getLocalRect().mTop!=this->getLocalRect().mRight)
+ {
+ llwarns << "Joystick shape is not square"<<llendl;
return TRUE;
- return FALSE;
+ }
+ //center is x and y coordinates of center of joystick circle, and also its radius
+ int center = this->getLocalRect().mTop/2;
+ bool in_circle = (x - center) * (x - center) + (y - center) * (y - center) <= center * center;
+ return in_circle;
}
BOOL LLJoystick::handleMouseDown(S32 x, S32 y, MASK mask)
@@ -150,7 +152,7 @@ BOOL LLJoystick::handleMouseDown(S32 x, S32 y, MASK mask)
//llinfos << "joystick mouse down " << x << ", " << y << llendl;
bool handles = false;
- if(handles = pointInCircle(x, y))
+ if(pointInCircle(x, y))
{
mLastMouse.set(x, y);
mFirstMouse.set(x, y);
diff --git a/indra/newview/lljoystickbutton.h b/indra/newview/lljoystickbutton.h
index 0465f78031..2b071a8999 100644
--- a/indra/newview/lljoystickbutton.h
+++ b/indra/newview/lljoystickbutton.h
@@ -79,7 +79,13 @@ public:
static void onBtnHeldDown(void *userdata); // called by llbutton callback handler
void setInitialQuadrant(EJoystickQuadrant initial) { mInitialQuadrant = initial; };
- BOOL pointInCircle(S32 x, S32 y) const;
+ /**
+ * Checks if click location is inside joystick circle.
+ *
+ * Image containing circle is square and this square has adherent points with joystick
+ * circle. Make sure to change method according to shape other than square.
+ */
+ bool pointInCircle(S32 x, S32 y) const;
static std::string nameFromQuadrant(const EJoystickQuadrant quadrant);
static EJoystickQuadrant quadrantFromName(const std::string& name);