From 44925ad19051d4ffe239b3ba99ea27e7275409dc Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Wed, 22 Jul 2015 12:33:59 -0500 Subject: GUI TextBox Allows the GUI to create a scrollable text box for long text that may not all fit on the screen. Also includes code to allow the console to wrap on spaces and other such characters instead of wrapping in the middle of a word. To see an example of how to add a text box to the XML, see: https://gerrit.omnirom.org/#/c/14183/ Change-Id: Ifd139172ede290046b58ea3fe526e2e06da1d4ef --- gui/objects.hpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'gui/objects.hpp') diff --git a/gui/objects.hpp b/gui/objects.hpp index 73d8717d5..3d217c45f 100644 --- a/gui/objects.hpp +++ b/gui/objects.hpp @@ -545,6 +545,7 @@ protected: int lastY, last2Y; // last 2 touch locations, used for tracking kinetic scroll speed int fastScroll; // indicates that the inital touch was inside the fastscroll region - makes for easier fast scrolling as the touches don't have to stay within the fast scroll region and you drag your finger int mUpdate; // indicates that a change took place and we need to re-render + bool AddLines(std::vector* origText, std::vector* origColor, size_t* lastCount, std::vector* rText, std::vector* rColor); }; class GUIFileSelector : public GUIScrollList @@ -680,6 +681,33 @@ protected: bool updateList; }; +class GUITextBox : public GUIScrollList +{ +public: + GUITextBox(xml_node<>* node); + +public: + // 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); + + // NotifyVarChange - Notify of a variable change + virtual int NotifyVarChange(const std::string& varName, const std::string& value); + + // ScrollList interface + virtual size_t GetItemCount(); + virtual void RenderItem(size_t itemindex, int yPos, bool selected); + virtual void NotifySelect(size_t item_selected); +protected: + + size_t mLastCount; + bool mIsStatic; + std::vector mLastValue; // Parsed text - parsed for variables but not word wrapped + std::vector mText; // Original text - not parsed for variables and not word wrapped + std::vector rText; // Rendered text - what we actually see + +}; + class GUIConsole : public GUIScrollList { public: @@ -725,7 +753,6 @@ protected: std::vector rConsoleColor; protected: - bool AddLines(); int RenderSlideout(void); int RenderConsole(void); }; -- cgit v1.2.3