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);
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();
00073
00074 protected:
00075 EJoystickQuadrant mInitialQuadrant;
00076 LLCoordGL mInitialOffset;
00077 LLCoordGL mLastMouse;
00078 LLCoordGL mFirstMouse;
00079 S32 mVertSlopNear;
00080 S32 mVertSlopFar;
00081 S32 mHorizSlopNear;
00082 S32 mHorizSlopFar;
00083 BOOL mHeldDown;
00084 LLFrameTimer mHeldDownTimer;
00085 };
00086
00087
00088
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 EWidgetType getWidgetType() const { return WIDGET_TYPE_JOYSTICK_TURN; }
00098 virtual LLString getWidgetTag() const { return LL_JOYSTICK_TURN; }
00099
00100 virtual void onHeldDown();
00101
00102 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00103
00104 };
00105
00106
00107
00108 class LLJoystickAgentSlide
00109 : public LLJoystick
00110 {
00111 public:
00112 LLJoystickAgentSlide(const LLString& name, LLRect rect, const LLString &default_image, const LLString &selected_image, EJoystickQuadrant initial)
00113 : LLJoystick(name, rect, default_image, selected_image, initial)
00114 { }
00115
00116 virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_JOYSTICK_SLIDE; }
00117 virtual LLString getWidgetTag() const { return LL_JOYSTICK_SLIDE; }
00118
00119
00120 virtual void onHeldDown();
00121 virtual void onMouseUp();
00122
00123 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00124 };
00125
00126
00127
00128 class LLJoystickCameraRotate
00129 : public LLJoystick
00130 {
00131 public:
00132 LLJoystickCameraRotate(const LLString& name, LLRect rect, const LLString &out_img, const LLString &in_img);
00133
00134 virtual void setToggleState( BOOL left, BOOL top, BOOL right, BOOL bottom );
00135
00136 virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
00137 virtual void onHeldDown();
00138 virtual void draw();
00139
00140 protected:
00141 F32 getOrbitRate();
00142 virtual void updateSlop();
00143 void drawRotatedImage( LLImageGL* image, S32 rotations );
00144
00145 protected:
00146 BOOL mInLeft;
00147 BOOL mInTop;
00148 BOOL mInRight;
00149 BOOL mInBottom;
00150 };
00151
00152
00153
00154 class LLJoystickCameraTrack
00155 : public LLJoystickCameraRotate
00156 {
00157 public:
00158 LLJoystickCameraTrack(const LLString& name, LLRect rect, const LLString &out_img, const LLString &in_img)
00159 : LLJoystickCameraRotate(name, rect, out_img, in_img)
00160 { }
00161
00162 virtual void onHeldDown();
00163 };
00164
00165
00166
00167 class LLJoystickCameraZoom
00168 : public LLJoystick
00169 {
00170 public:
00171 LLJoystickCameraZoom(const LLString& name, LLRect rect, const LLString &out_img, const LLString &plus_in_img, const LLString &minus_in_img);
00172
00173 virtual void setToggleState( BOOL top, BOOL bottom );
00174
00175 virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
00176 virtual void onHeldDown();
00177 virtual void draw();
00178
00179 protected:
00180 virtual void updateSlop();
00181 F32 getOrbitRate();
00182
00183 protected:
00184 BOOL mInTop;
00185 BOOL mInBottom;
00186 LLPointer<LLViewerImage> mPlusInImage;
00187 LLPointer<LLViewerImage> mMinusInImage;
00188 };
00189
00190
00191
00192 #endif // LL_LLJOYSTICKBUTTON_H