diff options
Diffstat (limited to 'indra/newview/lljoystickbutton.h')
| -rw-r--r-- | indra/newview/lljoystickbutton.h | 142 |
1 files changed, 65 insertions, 77 deletions
diff --git a/indra/newview/lljoystickbutton.h b/indra/newview/lljoystickbutton.h index 2cd53b4146..93e2e7128b 100644 --- a/indra/newview/lljoystickbutton.h +++ b/indra/newview/lljoystickbutton.h @@ -2,30 +2,25 @@ * @file lljoystickbutton.h * @brief LLJoystick class definition * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2007, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlife.com/developers/opensource/gplv2 + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at http://secondlife.com/developers/opensource/flossexception + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -34,7 +29,7 @@ #include "llbutton.h" #include "llcoord.h" -#include "llviewerimage.h" +#include "llviewertexture.h" typedef enum e_joystick_quadrant { @@ -45,11 +40,27 @@ typedef enum e_joystick_quadrant JQ_RIGHT } EJoystickQuadrant; +struct QuadrantNames : public LLInitParam::TypeValuesHelper<EJoystickQuadrant, QuadrantNames> +{ + static void declareValues(); +}; + class LLJoystick : public LLButton { public: - LLJoystick(const LLString& name, LLRect rect, const LLString &default_image, const LLString &selected_image, EJoystickQuadrant initial); + struct Params + : public LLInitParam::Block<Params, LLButton::Params> + { + Optional<EJoystickQuadrant, QuadrantNames> quadrant; + + Params() + : quadrant("quadrant", JQ_ORIGIN) + { + label = ""; + } + }; + LLJoystick(const Params&); virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); @@ -59,12 +70,19 @@ public: virtual void onHeldDown() = 0; F32 getElapsedHeldDownTime(); - static void onHeldDown(void *userdata); // called by llbutton callback handler + static void onBtnHeldDown(void *userdata); // called by llbutton callback handler void setInitialQuadrant(EJoystickQuadrant initial) { mInitialQuadrant = initial; }; + + /** + * 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; - virtual LLXMLNodePtr getXML(bool save_children = true) const; - static LLString nameFromQuadrant(const EJoystickQuadrant quadrant); - static EJoystickQuadrant quadrantFromName(const LLString& name); + static std::string nameFromQuadrant(const EJoystickQuadrant quadrant); + static EJoystickQuadrant quadrantFromName(const std::string& name); static EJoystickQuadrant selectQuadrant(LLXMLNodePtr node); @@ -90,17 +108,9 @@ class LLJoystickAgentTurn : public LLJoystick { public: - LLJoystickAgentTurn(const LLString& name, LLRect rect, const LLString &default_image, const LLString &selected_image, EJoystickQuadrant initial) - : LLJoystick(name, rect, default_image, selected_image, initial) - { } - - virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_JOYSTICK_TURN; } - virtual LLString getWidgetTag() const { return LL_JOYSTICK_TURN; } - + struct Params : public LLJoystick::Params {}; + LLJoystickAgentTurn(const Params& p) : LLJoystick(p) {} virtual void onHeldDown(); - - static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); - }; @@ -109,18 +119,11 @@ class LLJoystickAgentSlide : public LLJoystick { public: - LLJoystickAgentSlide(const LLString& name, LLRect rect, const LLString &default_image, const LLString &selected_image, EJoystickQuadrant initial) - : LLJoystick(name, rect, default_image, selected_image, initial) - { } - - virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_JOYSTICK_SLIDE; } - virtual LLString getWidgetTag() const { return LL_JOYSTICK_SLIDE; } - + struct Params : public LLJoystick::Params {}; + LLJoystickAgentSlide(const Params& p) : LLJoystick(p) {} virtual void onHeldDown(); virtual void onMouseUp(); - - static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); }; @@ -129,7 +132,16 @@ class LLJoystickCameraRotate : public LLJoystick { public: - LLJoystickCameraRotate(const LLString& name, LLRect rect, const LLString &out_img, const LLString &in_img); + struct Params + : public LLInitParam::Block<Params, LLJoystick::Params> + { + Params() + { + held_down_delay.seconds(0.0); + } + }; + + LLJoystickCameraRotate(const LLJoystickCameraRotate::Params&); virtual void setToggleState( BOOL left, BOOL top, BOOL right, BOOL bottom ); @@ -140,7 +152,7 @@ public: protected: F32 getOrbitRate(); virtual void updateSlop(); - void drawRotatedImage( const LLImageGL* image, S32 rotations ); + void drawRotatedImage( LLPointer<LLUIImage> image, S32 rotations ); protected: BOOL mInLeft; @@ -155,38 +167,14 @@ class LLJoystickCameraTrack : public LLJoystickCameraRotate { public: - LLJoystickCameraTrack(const LLString& name, LLRect rect, const LLString &out_img, const LLString &in_img) - : LLJoystickCameraRotate(name, rect, out_img, in_img) - { } + struct Params + : public LLInitParam::Block<Params, LLJoystickCameraRotate::Params> + { + Params(); + }; + LLJoystickCameraTrack(const LLJoystickCameraTrack::Params&); virtual void onHeldDown(); }; - -// Zoom the camera in and out -class LLJoystickCameraZoom -: public LLJoystick -{ -public: - LLJoystickCameraZoom(const LLString& name, LLRect rect, const LLString &out_img, const LLString &plus_in_img, const LLString &minus_in_img); - - virtual void setToggleState( BOOL top, BOOL bottom ); - - virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); - virtual void onHeldDown(); - virtual void draw(); - -protected: - virtual void updateSlop(); - F32 getOrbitRate(); - -protected: - BOOL mInTop; - BOOL mInBottom; - LLPointer<LLViewerImage> mPlusInImage; - LLPointer<LLViewerImage> mMinusInImage; -}; - - - #endif // LL_LLJOYSTICKBUTTON_H |
