From 32d8e9e396d497a83eb068888d794dd34216f6d7 Mon Sep 17 00:00:00 2001 From: Andrew Dyukov Date: Mon, 16 Nov 2009 18:09:33 +0200 Subject: Some coding style changes of EXT-1014 (Unable to move undocked camera controls bar) fix (c63047a5bf60). --HG-- branch : product-engine --- indra/newview/lljoystickbutton.cpp | 18 ++++++++++-------- indra/newview/lljoystickbutton.h | 8 +++++++- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'indra') 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"<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); -- cgit v1.2.3