diff options
Diffstat (limited to 'gui/objects.hpp')
-rw-r--r-- | gui/objects.hpp | 112 |
1 files changed, 51 insertions, 61 deletions
diff --git a/gui/objects.hpp b/gui/objects.hpp index d5c3b2738..a86747afb 100644 --- a/gui/objects.hpp +++ b/gui/objects.hpp @@ -366,67 +366,6 @@ protected: int simulate; }; -class GUIConsole : public GUIObject, public RenderObject, public ActionObject -{ -public: - GUIConsole(xml_node<>* node); - -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); - - // SetRenderPos - Update the position of the object - // Return 0 on success, <0 on error - virtual int SetRenderPos(int x, int y, int w = 0, int h = 0); - - // IsInRegion - Checks if the request is handled by this object - // Return 1 if this object handles the request, 0 if not - virtual int IsInRegion(int x, int y); - - // NotifyTouch - Notify of a touch event - // Return 0 on success, >0 to ignore remainder of touch, and <0 on error (Return error to allow other handlers) - virtual int NotifyTouch(TOUCH_STATE state, int x, int y); - -protected: - enum SlideoutState - { - hidden = 0, - visible, - request_hide, - request_show - }; - - FontResource* mFont; - ImageResource* mSlideoutImage; - COLOR mForegroundColor; - COLOR mBackgroundColor; - COLOR mScrollColor; - int mFontHeight; - int mCurrentLine; // index of last line to show; -1 to keep tracking last line - size_t mLastCount; // lines from gConsole that are already split and copied into rConsole - size_t RenderCount; // total number of lines after wrapping - int mMaxRows; // height of console in text rows - int mStartY; - int mSlideoutX, mSlideoutY, mSlideoutW, mSlideoutH; - int mSlideinX, mSlideinY, mSlideinW, mSlideinH; - int mConsoleX, mConsoleY, mConsoleW, mConsoleH; - int mLastTouchX, mLastTouchY; - int mSlideout; - SlideoutState mSlideoutState; - std::vector<std::string> rConsole; - std::vector<std::string> rConsoleColor; - bool mRender; - -protected: - virtual int RenderSlideout(void); - virtual int RenderConsole(void); -}; - class GUIButton : public GUIObject, public RenderObject, public ActionObject { public: @@ -606,6 +545,7 @@ protected: int firstDisplayedItem; // this item goes at the top of the display list - may only be partially visible int scrollingSpeed; // on a touch release, this is set based on the difference in the y-axis between the last 2 touches and indicates how fast the kinetic scrolling will go int y_offset; // this is how many pixels offset in the y axis for per pixel scrolling, is always <= 0 and should never be < -actualItemHeight + bool allowSelection; // true if touched item can be selected, false for pure read-only lists and the console size_t selectedItem; // selected item index after the initial touch, set to -1 if we are scrolling int touchDebounce; // debounce for touches, minimum of 6 pixels but may be larger calculated based actualItemHeight / 3 int lastY, last2Y; // last 2 touch locations, used for tracking kinetic scroll speed @@ -741,6 +681,56 @@ protected: bool updateList; }; +class GUIConsole : public GUIScrollList +{ +public: + GUIConsole(xml_node<>* node); + +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); + + // IsInRegion - Checks if the request is handled by this object + // Return 1 if this object handles the request, 0 if not + virtual int IsInRegion(int x, int y); + + // NotifyTouch - Notify of a touch event + // Return 0 on success, >0 to ignore remainder of touch, and <0 on error (Return error to allow other handlers) + virtual int NotifyTouch(TOUCH_STATE state, int x, int y); + + // ScrollList interface + virtual size_t GetItemCount(); + virtual void RenderItem(size_t itemindex, int yPos, bool selected); + virtual void NotifySelect(size_t item_selected); +protected: + enum SlideoutState + { + hidden = 0, + visible, + request_hide, + request_show + }; + + ImageResource* mSlideoutImage; + size_t mLastCount; // lines from gConsole that are already split and copied into rConsole + bool scrollToEnd; // true if we want to keep tracking the last line + int mSlideoutX, mSlideoutY, mSlideoutW, mSlideoutH; + int mSlideout; + SlideoutState mSlideoutState; + std::vector<std::string> rConsole; + std::vector<std::string> rConsoleColor; + +protected: + bool AddLines(); + int RenderSlideout(void); + int RenderConsole(void); +}; + // GUIAnimation - Used for animations class GUIAnimation : public GUIObject, public RenderObject { |