lljoystickbutton.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLJOYSTICKBUTTON_H
00033 #define LL_LLJOYSTICKBUTTON_H
00034 
00035 #include "llbutton.h"
00036 #include "llcoord.h"
00037 #include "llviewerimage.h"
00038 
00039 typedef enum e_joystick_quadrant
00040 {
00041         JQ_ORIGIN,
00042         JQ_UP,
00043         JQ_DOWN,
00044         JQ_LEFT,
00045         JQ_RIGHT
00046 } EJoystickQuadrant;
00047 
00048 class LLJoystick
00049 :       public LLButton
00050 {
00051 public:
00052         LLJoystick(const LLString& name, LLRect rect,   const LLString &default_image,  const LLString &selected_image, EJoystickQuadrant initial);
00053 
00054         virtual BOOL    handleMouseDown(S32 x, S32 y, MASK mask);
00055         virtual BOOL    handleMouseUp(S32 x, S32 y, MASK mask);
00056         virtual BOOL    handleHover(S32 x, S32 y, MASK mask);
00057 
00058         virtual void    onMouseUp() {}
00059         virtual void    onHeldDown() = 0;
00060         F32                             getElapsedHeldDownTime();
00061 
00062         static void             onHeldDown(void *userdata);             // called by llbutton callback handler
00063         void            setInitialQuadrant(EJoystickQuadrant initial) { mInitialQuadrant = initial; };
00064         
00065         virtual LLXMLNodePtr getXML(bool save_children = true) const;
00066         static LLString nameFromQuadrant(const EJoystickQuadrant quadrant);
00067         static EJoystickQuadrant quadrantFromName(const LLString& name);
00068         static EJoystickQuadrant selectQuadrant(LLXMLNodePtr node);
00069 
00070 
00071 protected:
00072         virtual void    updateSlop();                                   // recompute slop margins
00073 
00074 protected:
00075         EJoystickQuadrant       mInitialQuadrant;                       // mousedown = click in this quadrant
00076         LLCoordGL                       mInitialOffset;                         // pretend mouse started here
00077         LLCoordGL                       mLastMouse;                                     // where was mouse on last hover event
00078         LLCoordGL                       mFirstMouse;                            // when mouse clicked, where was it
00079         S32                                     mVertSlopNear;                          // where the slop regions end
00080         S32                                     mVertSlopFar;                           // where the slop regions end
00081         S32                                     mHorizSlopNear;                         // where the slop regions end
00082         S32                                     mHorizSlopFar;                          // where the slop regions end
00083         BOOL                            mHeldDown;
00084         LLFrameTimer            mHeldDownTimer;
00085 };
00086 
00087 
00088 // Turn agent left and right, move forward and back
00089 class LLJoystickAgentTurn
00090 :       public LLJoystick
00091 {
00092 public:
00093         LLJoystickAgentTurn(const LLString& name, LLRect rect, const LLString &default_image, const LLString &selected_image, EJoystickQuadrant initial)
00094                 : LLJoystick(name, rect, default_image, selected_image, initial)
00095         { }
00096 
00097         virtual void    onHeldDown();
00098 
00099         static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00100 
00101 };
00102 
00103 
00104 // Slide left and right, move forward and back
00105 class LLJoystickAgentSlide
00106 :       public LLJoystick
00107 {
00108 public:
00109         LLJoystickAgentSlide(const LLString& name, LLRect rect, const LLString &default_image, const LLString &selected_image, EJoystickQuadrant initial)
00110                 : LLJoystick(name, rect, default_image, selected_image, initial)
00111         { }
00112         
00113         virtual void    onHeldDown();
00114         virtual void    onMouseUp();
00115 
00116         static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00117 };
00118 
00119 
00120 // Rotate camera around the focus point
00121 class LLJoystickCameraRotate
00122 :       public LLJoystick
00123 {
00124 public:
00125         LLJoystickCameraRotate(const LLString& name, LLRect rect, const LLString &out_img, const LLString &in_img);
00126 
00127         virtual void    setToggleState( BOOL left, BOOL top, BOOL right, BOOL bottom );
00128 
00129         virtual BOOL    handleMouseDown(S32 x, S32 y, MASK mask);
00130         virtual void    onHeldDown();
00131         virtual void    draw();
00132 
00133 protected:
00134         F32                             getOrbitRate();
00135         virtual void    updateSlop();
00136         void                    drawRotatedImage( const LLImageGL* image, S32 rotations );
00137 
00138 protected:
00139         BOOL                    mInLeft;
00140         BOOL                    mInTop;
00141         BOOL                    mInRight;
00142         BOOL                    mInBottom;
00143 };
00144 
00145 
00146 // Track the camera focus point forward/backward and side to side
00147 class LLJoystickCameraTrack
00148 :       public LLJoystickCameraRotate
00149 {
00150 public:
00151         LLJoystickCameraTrack(const LLString& name, LLRect rect, const LLString &out_img, const LLString &in_img)
00152                 : LLJoystickCameraRotate(name, rect, out_img, in_img)
00153         { }
00154 
00155         virtual void    onHeldDown();
00156 };
00157 
00158 
00159 // Zoom the camera in and out
00160 class LLJoystickCameraZoom
00161 :       public LLJoystick
00162 {
00163 public:
00164         LLJoystickCameraZoom(const LLString& name, LLRect rect, const LLString &out_img, const LLString &plus_in_img, const LLString &minus_in_img);
00165 
00166         virtual void    setToggleState( BOOL top, BOOL bottom );
00167 
00168         virtual BOOL    handleMouseDown(S32 x, S32 y, MASK mask);
00169         virtual void    onHeldDown();
00170         virtual void    draw();
00171 
00172 protected:
00173         virtual void updateSlop();
00174         F32                             getOrbitRate();
00175 
00176 protected:
00177         BOOL                    mInTop;
00178         BOOL                    mInBottom;
00179         LLUIImagePtr    mPlusInImage;
00180         LLUIImagePtr    mMinusInImage;
00181 };
00182 
00183 
00184 
00185 #endif  // LL_LLJOYSTICKBUTTON_H

Generated on Fri May 16 08:33:43 2008 for SecondLife by  doxygen 1.5.5