From 85932344cd9a84d8586b4f9839855c730c8e8ebc Mon Sep 17 00:00:00 2001 From: Vojtech Bocek Date: Mon, 1 Apr 2013 22:11:33 +0200 Subject: Add new SliderValue GUI widget Signed-off-by: Vojtech Bocek Change-Id: Ic5d44314f501341140dd7059d1cb753341f5844c --- gui/objects.hpp | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'gui/objects.hpp') diff --git a/gui/objects.hpp b/gui/objects.hpp index 973c3cfe9..ff5429a9c 100644 --- a/gui/objects.hpp +++ b/gui/objects.hpp @@ -909,6 +909,72 @@ public: virtual int KeyRepeat(void); }; +class GUISliderValue: public RenderObject, public ActionObject, public Conditional +{ +public: + GUISliderValue(xml_node<>* node); + virtual ~GUISliderValue(); + +public: + // Render - Render the full object to the GL surface + // Return 0 on success, <0 on error + virtual int Render(void); + + // Update - Update any UI component animations (called <= 30 FPS) + // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error + virtual int Update(void); + + // SetPos - Update the position of the render object + // Return 0 on success, <0 on error + virtual int SetRenderPos(int x, int y, int w = 0, int h = 0); + + // NotifyTouch - Notify of a touch event + // Return 0 on success, >0 to ignore remainder of touch, and <0 on error + virtual int NotifyTouch(TOUCH_STATE state, int x, int y); + + // Notify of a variable change + virtual int NotifyVarChange(std::string varName, std::string value); + + // SetPageFocus - Notify when a page gains or loses focus + virtual void SetPageFocus(int inFocus); + +protected: + int measureText(const std::string& str); + int valueFromPct(float pct); + float pctFromValue(int value); + void loadValue(bool force = false); + + std::string mVariable; + int mMax; + int mMin; + int mValue; + char *mValueStr; + float mValuePct; + std::string mMaxStr; + std::string mMinStr; + Resource *mFont; + GUIText* mLabel; + int mLabelW; + COLOR mTextColor; + COLOR mLineColor; + COLOR mSliderColor; + bool mShowRange; + bool mShowCurr; + int mLineX; + int mLineY; + int mLineH; + int mLinePadding; + int mPadding; + int mSliderY; + int mSliderW; + int mSliderH; + bool mRendered; + int mFontHeight; + GUIAction *mAction; + bool mChangeOnDrag; + int lineW; +}; + // Helper APIs bool LoadPlacement(xml_node<>* node, int* x, int* y, int* w = NULL, int* h = NULL, RenderObject::Placement* placement = NULL); -- cgit v1.2.3