Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2013 bigbiff/Dees_Troy TeamWin |
| 3 | This file is part of TWRP/TeamWin Recovery Project. |
| 4 | |
| 5 | TWRP is free software: you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation, either version 3 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | TWRP is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with TWRP. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 18 | // objects.h - Base classes for object manager of GUI |
| 19 | |
| 20 | #ifndef _OBJECTS_HEADER |
| 21 | #define _OBJECTS_HEADER |
| 22 | |
| 23 | #include "rapidxml.hpp" |
| 24 | #include <vector> |
| 25 | #include <string> |
| 26 | #include <map> |
| 27 | |
| 28 | extern "C" { |
Dees Troy | b7ae098 | 2013-09-10 20:47:35 +0000 | [diff] [blame] | 29 | #ifdef HAVE_SELINUX |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 30 | #include "../minzip/Zip.h" |
Dees Troy | b7ae098 | 2013-09-10 20:47:35 +0000 | [diff] [blame] | 31 | #else |
| 32 | #include "../minzipold/Zip.h" |
| 33 | #endif |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | using namespace rapidxml; |
| 37 | |
| 38 | #include "../data.hpp" |
| 39 | #include "resources.hpp" |
| 40 | #include "pages.hpp" |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 41 | #include "../partitions.hpp" |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 42 | |
| 43 | class RenderObject |
| 44 | { |
| 45 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 46 | enum Placement { |
| 47 | TOP_LEFT = 0, |
| 48 | TOP_RIGHT = 1, |
| 49 | BOTTOM_LEFT = 2, |
| 50 | BOTTOM_RIGHT = 3, |
| 51 | CENTER = 4, |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 52 | CENTER_X_ONLY = 5, |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 53 | }; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 54 | |
| 55 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 56 | RenderObject() { mRenderX = 0; mRenderY = 0; mRenderW = 0; mRenderH = 0; mPlacement = TOP_LEFT; } |
| 57 | virtual ~RenderObject() {} |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 58 | |
| 59 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 60 | // Render - Render the full object to the GL surface |
| 61 | // Return 0 on success, <0 on error |
| 62 | virtual int Render(void) = 0; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 63 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 64 | // Update - Update any UI component animations (called <= 30 FPS) |
| 65 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 66 | virtual int Update(void) { return 0; } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 67 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 68 | // GetRenderPos - Returns the current position of the object |
| 69 | virtual int GetRenderPos(int& x, int& y, int& w, int& h) { x = mRenderX; y = mRenderY; w = mRenderW; h = mRenderH; return 0; } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 70 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 71 | // SetRenderPos - Update the position of the object |
| 72 | // Return 0 on success, <0 on error |
| 73 | virtual int SetRenderPos(int x, int y, int w = 0, int h = 0) { mRenderX = x; mRenderY = y; if (w || h) { mRenderW = w; mRenderH = h; } return 0; } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 74 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 75 | // GetPlacement - Returns the current placement |
| 76 | virtual int GetPlacement(Placement& placement) { placement = mPlacement; return 0; } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 77 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 78 | // SetPlacement - Update the current placement |
| 79 | virtual int SetPlacement(Placement placement) { mPlacement = placement; return 0; } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 80 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 81 | // SetPageFocus - Notify when a page gains or loses focus |
| 82 | virtual void SetPageFocus(int inFocus) { return; } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 83 | |
| 84 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 85 | int mRenderX, mRenderY, mRenderW, mRenderH; |
| 86 | Placement mPlacement; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | class ActionObject |
| 90 | { |
| 91 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 92 | ActionObject() { mActionX = 0; mActionY = 0; mActionW = 0; mActionH = 0; } |
| 93 | virtual ~ActionObject() {} |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 94 | |
| 95 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 96 | // NotifyTouch - Notify of a touch event |
| 97 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 98 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y) { return 0; } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 99 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 100 | // NotifyKey - Notify of a key press |
| 101 | // Return 0 on success (and consume key), >0 to pass key to next handler, and <0 on error |
| 102 | virtual int NotifyKey(int key) { return 1; } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 103 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 104 | // GetRenderPos - Returns the current position of the object |
| 105 | virtual int GetActionPos(int& x, int& y, int& w, int& h) { x = mActionX; y = mActionY; w = mActionW; h = mActionH; return 0; } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 106 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 107 | // SetRenderPos - Update the position of the object |
| 108 | // Return 0 on success, <0 on error |
| 109 | virtual int SetActionPos(int x, int y, int w = 0, int h = 0); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 110 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 111 | // IsInRegion - Checks if the request is handled by this object |
| 112 | // Return 0 if this object handles the request, 1 if not |
| 113 | virtual int IsInRegion(int x, int y) { return ((x < mActionX || x > mActionX + mActionW || y < mActionY || y > mActionY + mActionH) ? 0 : 1); } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 114 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 115 | // NotifyVarChange - Notify of a variable change |
| 116 | // Returns 0 on success, <0 on error |
| 117 | virtual int NotifyVarChange(std::string varName, std::string value) { return 0; } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 118 | |
| 119 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 120 | int mActionX, mActionY, mActionW, mActionH; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | class Conditional |
| 124 | { |
| 125 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 126 | Conditional(xml_node<>* node); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 127 | |
| 128 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 129 | bool IsConditionVariable(std::string var); |
| 130 | bool isConditionTrue(); |
| 131 | bool isConditionValid(); |
| 132 | void NotifyPageSet(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 133 | |
| 134 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 135 | class Condition |
| 136 | { |
| 137 | public: |
| 138 | std::string mVar1; |
| 139 | std::string mVar2; |
| 140 | std::string mCompareOp; |
| 141 | std::string mLastVal; |
| 142 | }; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 143 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 144 | std::vector<Condition> mConditions; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 145 | |
| 146 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 147 | bool isMounted(std::string vol); |
| 148 | bool isConditionTrue(Condition* condition); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 149 | }; |
| 150 | |
| 151 | class InputObject |
| 152 | { |
| 153 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 154 | InputObject() { HasInputFocus = 0; } |
| 155 | virtual ~InputObject() {} |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 156 | |
| 157 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 158 | // NotifyKeyboard - Notify of keyboard input |
| 159 | // Return 0 on success (and consume key), >0 to pass key to next handler, and <0 on error |
| 160 | virtual int NotifyKeyboard(int key) { return 1; } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 161 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 162 | virtual int SetInputFocus(int focus) { HasInputFocus = focus; return 1; } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 163 | |
| 164 | protected: |
| 165 | int HasInputFocus; |
| 166 | }; |
| 167 | |
| 168 | // Derived Objects |
| 169 | // GUIText - Used for static text |
| 170 | class GUIText : public RenderObject, public ActionObject, public Conditional |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 171 | { |
| 172 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 173 | // w and h may be ignored, in which case, no bounding box is applied |
| 174 | GUIText(xml_node<>* node); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 175 | |
| 176 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 177 | // Render - Render the full object to the GL surface |
| 178 | // Return 0 on success, <0 on error |
| 179 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 180 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 181 | // Update - Update any UI component animations (called <= 30 FPS) |
| 182 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 183 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 184 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 185 | // Retrieve the size of the current string (dynamic strings may change per call) |
| 186 | virtual int GetCurrentBounds(int& w, int& h); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 187 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 188 | // Notify of a variable change |
| 189 | virtual int NotifyVarChange(std::string varName, std::string value); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 190 | |
| 191 | // Set maximum width in pixels |
| 192 | virtual int SetMaxWidth(unsigned width); |
| 193 | |
| 194 | // Set number of characters to skip (for scrolling) |
| 195 | virtual int SkipCharCount(unsigned skip); |
| 196 | |
Dees_Troy | 4d12f96 | 2012-10-19 13:13:15 -0400 | [diff] [blame] | 197 | public: |
| 198 | bool isHighlighted; |
| 199 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 200 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 201 | std::string mText; |
| 202 | std::string mLastValue; |
| 203 | COLOR mColor; |
Dees_Troy | 4d12f96 | 2012-10-19 13:13:15 -0400 | [diff] [blame] | 204 | COLOR mHighlightColor; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 205 | Resource* mFont; |
| 206 | int mIsStatic; |
| 207 | int mVarChanged; |
| 208 | int mFontHeight; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 209 | unsigned maxWidth; |
| 210 | unsigned charSkip; |
Dees_Troy | 4d12f96 | 2012-10-19 13:13:15 -0400 | [diff] [blame] | 211 | bool hasHighlightColor; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 212 | |
| 213 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 214 | std::string parseText(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 215 | }; |
| 216 | |
| 217 | // GUIImage - Used for static image |
Vojtech Bocek | 6041a78 | 2013-10-11 14:40:01 +0200 | [diff] [blame] | 218 | class GUIImage : public RenderObject, public Conditional |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 219 | { |
| 220 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 221 | GUIImage(xml_node<>* node); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 222 | |
| 223 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 224 | // Render - Render the full object to the GL surface |
| 225 | // Return 0 on success, <0 on error |
| 226 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 227 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 228 | // SetRenderPos - Update the position of the object |
| 229 | // Return 0 on success, <0 on error |
| 230 | virtual int SetRenderPos(int x, int y, int w = 0, int h = 0); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 231 | |
Dees_Troy | 4d12f96 | 2012-10-19 13:13:15 -0400 | [diff] [blame] | 232 | public: |
| 233 | bool isHighlighted; |
| 234 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 235 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 236 | Resource* mImage; |
Dees_Troy | 4d12f96 | 2012-10-19 13:13:15 -0400 | [diff] [blame] | 237 | Resource* mHighlightImage; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 238 | }; |
| 239 | |
| 240 | // GUIFill - Used for fill colors |
| 241 | class GUIFill : public RenderObject |
| 242 | { |
| 243 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 244 | GUIFill(xml_node<>* node); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 245 | |
| 246 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 247 | // Render - Render the full object to the GL surface |
| 248 | // Return 0 on success, <0 on error |
| 249 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 250 | |
| 251 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 252 | COLOR mColor; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 253 | }; |
| 254 | |
| 255 | // GUIAction - Used for standard actions |
| 256 | class GUIAction : public ActionObject, public Conditional |
| 257 | { |
| 258 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 259 | GUIAction(xml_node<>* node); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 260 | |
| 261 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 262 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
| 263 | virtual int NotifyKey(int key); |
| 264 | virtual int NotifyVarChange(std::string varName, std::string value); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 265 | virtual int doActions(); |
| 266 | |
| 267 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 268 | class Action |
| 269 | { |
| 270 | public: |
| 271 | std::string mFunction; |
| 272 | std::string mArg; |
| 273 | }; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 274 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 275 | std::vector<Action> mActions; |
| 276 | int mKey; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 277 | |
| 278 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 279 | int getKeyByName(std::string key); |
| 280 | virtual int doAction(Action action, int isThreaded = 0); |
| 281 | static void* thread_start(void *cookie); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 282 | void simulate_progress_bar(void); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 283 | int flash_zip(std::string filename, std::string pageName, const int simulate, int* wipe_cache); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 284 | void operation_start(const string operation_name); |
| 285 | void operation_end(const int operation_status, const int simulate); |
| 286 | static void* command_thread(void *cookie); |
| 287 | }; |
| 288 | |
| 289 | class GUIConsole : public RenderObject, public ActionObject |
| 290 | { |
| 291 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 292 | GUIConsole(xml_node<>* node); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 293 | |
| 294 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 295 | // Render - Render the full object to the GL surface |
| 296 | // Return 0 on success, <0 on error |
| 297 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 298 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 299 | // Update - Update any UI component animations (called <= 30 FPS) |
| 300 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 301 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 302 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 303 | // SetRenderPos - Update the position of the object |
| 304 | // Return 0 on success, <0 on error |
| 305 | virtual int SetRenderPos(int x, int y, int w = 0, int h = 0); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 306 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 307 | // IsInRegion - Checks if the request is handled by this object |
| 308 | // Return 0 if this object handles the request, 1 if not |
| 309 | virtual int IsInRegion(int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 310 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 311 | // NotifyTouch - Notify of a touch event |
| 312 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error (Return error to allow other handlers) |
| 313 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 314 | |
| 315 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 316 | enum SlideoutState |
| 317 | { |
| 318 | hidden = 0, |
| 319 | visible, |
| 320 | request_hide, |
| 321 | request_show |
| 322 | }; |
| 323 | |
| 324 | Resource* mFont; |
| 325 | Resource* mSlideoutImage; |
| 326 | COLOR mForegroundColor; |
| 327 | COLOR mBackgroundColor; |
| 328 | COLOR mScrollColor; |
| 329 | unsigned int mFontHeight; |
| 330 | int mCurrentLine; |
| 331 | unsigned int mLastCount; |
| 332 | unsigned int mMaxRows; |
| 333 | int mStartY; |
| 334 | int mSlideoutX, mSlideoutY, mSlideoutW, mSlideoutH; |
| 335 | int mSlideinX, mSlideinY, mSlideinW, mSlideinH; |
| 336 | int mConsoleX, mConsoleY, mConsoleW, mConsoleH; |
| 337 | int mLastTouchX, mLastTouchY; |
| 338 | int mSlideMultiplier; |
| 339 | int mSlideout; |
| 340 | SlideoutState mSlideoutState; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 341 | |
| 342 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 343 | virtual int RenderSlideout(void); |
| 344 | virtual int RenderConsole(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 345 | }; |
| 346 | |
| 347 | class GUIButton : public RenderObject, public ActionObject, public Conditional |
| 348 | { |
| 349 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 350 | GUIButton(xml_node<>* node); |
| 351 | virtual ~GUIButton(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 352 | |
| 353 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 354 | // Render - Render the full object to the GL surface |
| 355 | // Return 0 on success, <0 on error |
| 356 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 357 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 358 | // Update - Update any UI component animations (called <= 30 FPS) |
| 359 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 360 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 361 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 362 | // SetPos - Update the position of the render object |
| 363 | // Return 0 on success, <0 on error |
| 364 | virtual int SetRenderPos(int x, int y, int w = 0, int h = 0); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 365 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 366 | // NotifyTouch - Notify of a touch event |
| 367 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 368 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 369 | |
| 370 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 371 | GUIImage* mButtonImg; |
| 372 | Resource* mButtonIcon; |
| 373 | GUIText* mButtonLabel; |
| 374 | GUIAction* mAction; |
| 375 | int mTextX, mTextY, mTextW, mTextH; |
| 376 | int mIconX, mIconY, mIconW, mIconH; |
| 377 | bool mRendered; |
Dees_Troy | 1a7a667 | 2013-02-15 09:39:07 -0600 | [diff] [blame] | 378 | bool hasHighlightColor; |
| 379 | bool renderHighlight; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 380 | bool hasFill; |
| 381 | COLOR mFillColor; |
Dees_Troy | 1a7a667 | 2013-02-15 09:39:07 -0600 | [diff] [blame] | 382 | COLOR mHighlightColor; |
Dees Troy | b21cc64 | 2013-09-10 17:36:41 +0000 | [diff] [blame] | 383 | Placement TextPlacement; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 384 | }; |
| 385 | |
| 386 | class GUICheckbox: public RenderObject, public ActionObject, public Conditional |
| 387 | { |
| 388 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 389 | GUICheckbox(xml_node<>* node); |
| 390 | virtual ~GUICheckbox(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 391 | |
| 392 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 393 | // Render - Render the full object to the GL surface |
| 394 | // Return 0 on success, <0 on error |
| 395 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 396 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 397 | // Update - Update any UI component animations (called <= 30 FPS) |
| 398 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 399 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 400 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 401 | // SetPos - Update the position of the render object |
| 402 | // Return 0 on success, <0 on error |
| 403 | virtual int SetRenderPos(int x, int y, int w = 0, int h = 0); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 404 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 405 | // NotifyTouch - Notify of a touch event |
| 406 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 407 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 408 | |
| 409 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 410 | Resource* mChecked; |
| 411 | Resource* mUnchecked; |
| 412 | GUIText* mLabel; |
| 413 | int mTextX, mTextY; |
| 414 | int mCheckX, mCheckY, mCheckW, mCheckH; |
| 415 | int mLastState; |
| 416 | bool mRendered; |
| 417 | std::string mVarName; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 418 | }; |
| 419 | |
| 420 | class GUIFileSelector : public RenderObject, public ActionObject |
| 421 | { |
| 422 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 423 | GUIFileSelector(xml_node<>* node); |
| 424 | virtual ~GUIFileSelector(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 425 | |
| 426 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 427 | // Render - Render the full object to the GL surface |
| 428 | // Return 0 on success, <0 on error |
| 429 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 430 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 431 | // Update - Update any UI component animations (called <= 30 FPS) |
| 432 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 433 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 434 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 435 | // NotifyTouch - Notify of a touch event |
| 436 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 437 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 438 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 439 | // NotifyVarChange - Notify of a variable change |
| 440 | virtual int NotifyVarChange(std::string varName, std::string value); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 441 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 442 | // SetPos - Update the position of the render object |
| 443 | // Return 0 on success, <0 on error |
| 444 | virtual int SetRenderPos(int x, int y, int w = 0, int h = 0); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 445 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 446 | // SetPageFocus - Notify when a page gains or loses focus |
| 447 | virtual void SetPageFocus(int inFocus); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 448 | |
| 449 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 450 | struct FileData { |
| 451 | std::string fileName; |
| 452 | unsigned char fileType; // Uses d_type format from struct dirent |
| 453 | mode_t protection; // Uses mode_t format from stat |
| 454 | uid_t userId; |
| 455 | gid_t groupId; |
| 456 | off_t fileSize; |
| 457 | time_t lastAccess; // Uses time_t format from stat |
| 458 | time_t lastModified; // Uses time_t format from stat |
| 459 | time_t lastStatChange; // Uses time_t format from stat |
| 460 | }; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 461 | |
| 462 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 463 | virtual int GetSelection(int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 464 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 465 | virtual int GetFileList(const std::string folder); |
| 466 | static bool fileSort(FileData d1, FileData d2); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 467 | |
| 468 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 469 | std::vector<FileData> mFolderList; |
| 470 | std::vector<FileData> mFileList; |
| 471 | std::string mPathVar; |
| 472 | std::string mExtn; |
| 473 | std::string mVariable; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 474 | std::string mSortVariable; |
| 475 | std::string mSelection; |
| 476 | std::string mHeaderText; |
| 477 | std::string mLastValue; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 478 | int actualLineHeight; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 479 | int mStart; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 480 | int mLineSpacing; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 481 | int mSeparatorH; |
| 482 | int mHeaderSeparatorH; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 483 | int mShowFolders, mShowFiles, mShowNavFolders; |
| 484 | int mUpdate; |
| 485 | int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 486 | int mHeaderH; |
Vojtech Bocek | 7cc278b | 2013-02-24 01:40:19 +0100 | [diff] [blame] | 487 | int mFastScrollW; |
| 488 | int mFastScrollLineW; |
| 489 | int mFastScrollRectW; |
| 490 | int mFastScrollRectH; |
| 491 | int mFastScrollRectX; |
| 492 | int mFastScrollRectY; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 493 | static int mSortOrder; |
| 494 | int startY; |
| 495 | int scrollingSpeed; |
| 496 | int scrollingY; |
| 497 | int mHeaderIsStatic; |
| 498 | int touchDebounce; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 499 | unsigned mFontHeight; |
| 500 | unsigned mLineHeight; |
| 501 | int mIconWidth, mIconHeight, mFolderIconHeight, mFileIconHeight, mFolderIconWidth, mFileIconWidth, mHeaderIconHeight, mHeaderIconWidth; |
| 502 | Resource* mHeaderIcon; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 503 | Resource* mFolderIcon; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 504 | Resource* mFileIcon; |
| 505 | Resource* mBackground; |
| 506 | Resource* mFont; |
| 507 | COLOR mBackgroundColor; |
| 508 | COLOR mFontColor; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 509 | COLOR mHeaderBackgroundColor; |
| 510 | COLOR mHeaderFontColor; |
| 511 | COLOR mSeparatorColor; |
| 512 | COLOR mHeaderSeparatorColor; |
Vojtech Bocek | 7cc278b | 2013-02-24 01:40:19 +0100 | [diff] [blame] | 513 | COLOR mFastScrollLineColor; |
| 514 | COLOR mFastScrollRectColor; |
Dees_Troy | e7585ca | 2013-02-15 11:42:29 -0600 | [diff] [blame] | 515 | bool hasHighlightColor; |
| 516 | bool hasFontHighlightColor; |
| 517 | bool isHighlighted; |
| 518 | COLOR mHighlightColor; |
| 519 | COLOR mFontHighlightColor; |
| 520 | int startSelection; |
Dees_Troy | c0583f5 | 2013-02-28 11:19:57 -0600 | [diff] [blame] | 521 | bool updateFileList; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 522 | }; |
| 523 | |
| 524 | class GUIListBox : public RenderObject, public ActionObject |
| 525 | { |
| 526 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 527 | GUIListBox(xml_node<>* node); |
| 528 | virtual ~GUIListBox(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 529 | |
| 530 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 531 | // Render - Render the full object to the GL surface |
| 532 | // Return 0 on success, <0 on error |
| 533 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 534 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 535 | // Update - Update any UI component animations (called <= 30 FPS) |
| 536 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 537 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 538 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 539 | // NotifyTouch - Notify of a touch event |
| 540 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 541 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 542 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 543 | // NotifyVarChange - Notify of a variable change |
| 544 | virtual int NotifyVarChange(std::string varName, std::string value); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 545 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 546 | // SetPos - Update the position of the render object |
| 547 | // Return 0 on success, <0 on error |
| 548 | virtual int SetRenderPos(int x, int y, int w = 0, int h = 0); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 549 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 550 | // SetPageFocus - Notify when a page gains or loses focus |
| 551 | virtual void SetPageFocus(int inFocus); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 552 | |
| 553 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 554 | struct ListData { |
| 555 | std::string displayName; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 556 | std::string variableValue; |
| 557 | unsigned int selected; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 558 | }; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 559 | |
| 560 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 561 | virtual int GetSelection(int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 562 | |
| 563 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 564 | std::vector<ListData> mList; |
| 565 | std::string mVariable; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 566 | std::string mSelection; |
| 567 | std::string currentValue; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 568 | std::string mHeaderText; |
| 569 | std::string mLastValue; |
| 570 | int actualLineHeight; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 571 | int mStart; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 572 | int startY; |
| 573 | int mSeparatorH, mHeaderSeparatorH; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 574 | int mLineSpacing; |
| 575 | int mUpdate; |
| 576 | int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH, mHeaderH; |
Dees_Troy | 58f5cf0 | 2013-02-27 22:21:41 +0000 | [diff] [blame] | 577 | int mFastScrollW; |
| 578 | int mFastScrollLineW; |
| 579 | int mFastScrollRectW; |
| 580 | int mFastScrollRectH; |
| 581 | int mFastScrollRectX; |
| 582 | int mFastScrollRectY; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 583 | int mIconWidth, mIconHeight, mSelectedIconWidth, mSelectedIconHeight, mUnselectedIconWidth, mUnselectedIconHeight, mHeaderIconHeight, mHeaderIconWidth; |
| 584 | int scrollingSpeed; |
| 585 | int scrollingY; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 586 | static int mSortOrder; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 587 | unsigned mFontHeight; |
| 588 | unsigned mLineHeight; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 589 | Resource* mHeaderIcon; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 590 | Resource* mIconSelected; |
| 591 | Resource* mIconUnselected; |
| 592 | Resource* mBackground; |
| 593 | Resource* mFont; |
| 594 | COLOR mBackgroundColor; |
| 595 | COLOR mFontColor; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 596 | COLOR mHeaderBackgroundColor; |
| 597 | COLOR mHeaderFontColor; |
| 598 | COLOR mSeparatorColor; |
| 599 | COLOR mHeaderSeparatorColor; |
Dees_Troy | 58f5cf0 | 2013-02-27 22:21:41 +0000 | [diff] [blame] | 600 | COLOR mFastScrollLineColor; |
| 601 | COLOR mFastScrollRectColor; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 602 | bool hasHighlightColor; |
| 603 | bool hasFontHighlightColor; |
| 604 | bool isHighlighted; |
| 605 | COLOR mHighlightColor; |
| 606 | COLOR mFontHighlightColor; |
| 607 | int mHeaderIsStatic; |
| 608 | int startSelection; |
| 609 | int touchDebounce; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 610 | }; |
| 611 | |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 612 | class GUIPartitionList : public RenderObject, public ActionObject |
| 613 | { |
| 614 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 615 | GUIPartitionList(xml_node<>* node); |
| 616 | virtual ~GUIPartitionList(); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 617 | |
| 618 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 619 | // Render - Render the full object to the GL surface |
| 620 | // Return 0 on success, <0 on error |
| 621 | virtual int Render(void); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 622 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 623 | // Update - Update any UI component animations (called <= 30 FPS) |
| 624 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 625 | virtual int Update(void); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 626 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 627 | // NotifyTouch - Notify of a touch event |
| 628 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 629 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 630 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 631 | // NotifyVarChange - Notify of a variable change |
| 632 | virtual int NotifyVarChange(std::string varName, std::string value); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 633 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 634 | // SetPos - Update the position of the render object |
| 635 | // Return 0 on success, <0 on error |
| 636 | virtual int SetRenderPos(int x, int y, int w = 0, int h = 0); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 637 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 638 | // SetPageFocus - Notify when a page gains or loses focus |
| 639 | virtual void SetPageFocus(int inFocus); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 640 | |
| 641 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 642 | virtual int GetSelection(int x, int y); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 643 | virtual void MatchList(void); |
| 644 | |
| 645 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 646 | std::vector<PartitionList> mList; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 647 | std::string ListType; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 648 | std::string mVariable; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 649 | std::string selectedList; |
| 650 | std::string currentValue; |
| 651 | std::string mHeaderText; |
| 652 | std::string mLastValue; |
| 653 | int actualLineHeight; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 654 | int mStart; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 655 | int startY; |
| 656 | int mSeparatorH, mHeaderSeparatorH; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 657 | int mLineSpacing; |
| 658 | int mUpdate; |
| 659 | int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH, mHeaderH; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 660 | int mFastScrollW; |
| 661 | int mFastScrollLineW; |
| 662 | int mFastScrollRectW; |
| 663 | int mFastScrollRectH; |
| 664 | int mFastScrollRectX; |
| 665 | int mFastScrollRectY; |
| 666 | int mIconWidth, mIconHeight, mSelectedIconWidth, mSelectedIconHeight, mUnselectedIconWidth, mUnselectedIconHeight, mHeaderIconHeight, mHeaderIconWidth; |
| 667 | int scrollingSpeed; |
| 668 | int scrollingY; |
| 669 | static int mSortOrder; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 670 | unsigned mFontHeight; |
| 671 | unsigned mLineHeight; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 672 | Resource* mHeaderIcon; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 673 | Resource* mIconSelected; |
| 674 | Resource* mIconUnselected; |
| 675 | Resource* mBackground; |
| 676 | Resource* mFont; |
| 677 | COLOR mBackgroundColor; |
| 678 | COLOR mFontColor; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 679 | COLOR mHeaderBackgroundColor; |
| 680 | COLOR mHeaderFontColor; |
| 681 | COLOR mSeparatorColor; |
| 682 | COLOR mHeaderSeparatorColor; |
| 683 | COLOR mFastScrollLineColor; |
| 684 | COLOR mFastScrollRectColor; |
| 685 | bool hasHighlightColor; |
| 686 | bool hasFontHighlightColor; |
| 687 | bool isHighlighted; |
| 688 | COLOR mHighlightColor; |
| 689 | COLOR mFontHighlightColor; |
| 690 | int mHeaderIsStatic; |
| 691 | int startSelection; |
| 692 | int touchDebounce; |
| 693 | bool updateList; |
| 694 | }; |
| 695 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 696 | // GUIAnimation - Used for animations |
| 697 | class GUIAnimation : public RenderObject |
| 698 | { |
| 699 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 700 | GUIAnimation(xml_node<>* node); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 701 | |
| 702 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 703 | // Render - Render the full object to the GL surface |
| 704 | // Return 0 on success, <0 on error |
| 705 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 706 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 707 | // Update - Update any UI component animations (called <= 30 FPS) |
| 708 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 709 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 710 | |
| 711 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 712 | AnimationResource* mAnimation; |
| 713 | int mFrame; |
| 714 | int mFPS; |
| 715 | int mLoop; |
| 716 | int mRender; |
| 717 | int mUpdateCount; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 718 | }; |
| 719 | |
| 720 | class GUIProgressBar : public RenderObject, public ActionObject |
| 721 | { |
| 722 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 723 | GUIProgressBar(xml_node<>* node); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 724 | |
| 725 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 726 | // Render - Render the full object to the GL surface |
| 727 | // Return 0 on success, <0 on error |
| 728 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 729 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 730 | // Update - Update any UI component animations (called <= 30 FPS) |
| 731 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 732 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 733 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 734 | // NotifyVarChange - Notify of a variable change |
| 735 | // Returns 0 on success, <0 on error |
| 736 | virtual int NotifyVarChange(std::string varName, std::string value); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 737 | |
| 738 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 739 | Resource* mEmptyBar; |
| 740 | Resource* mFullBar; |
| 741 | std::string mMinValVar; |
| 742 | std::string mMaxValVar; |
| 743 | std::string mCurValVar; |
| 744 | float mSlide; |
| 745 | float mSlideInc; |
| 746 | int mSlideFrames; |
| 747 | int mLastPos; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 748 | |
| 749 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 750 | virtual int RenderInternal(void); // Does the actual render |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 751 | }; |
| 752 | |
| 753 | class GUISlider : public RenderObject, public ActionObject |
| 754 | { |
| 755 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 756 | GUISlider(xml_node<>* node); |
| 757 | virtual ~GUISlider(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 758 | |
| 759 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 760 | // Render - Render the full object to the GL surface |
| 761 | // Return 0 on success, <0 on error |
| 762 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 763 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 764 | // Update - Update any UI component animations (called <= 30 FPS) |
| 765 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 766 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 767 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 768 | // NotifyTouch - Notify of a touch event |
| 769 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 770 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 771 | |
| 772 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 773 | GUIAction* sAction; |
| 774 | Resource* sSlider; |
| 775 | Resource* sSliderUsed; |
| 776 | Resource* sTouch; |
| 777 | int sTouchW, sTouchH; |
| 778 | int sCurTouchX; |
| 779 | int sUpdate; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 780 | }; |
| 781 | |
| 782 | #define MAX_KEYBOARD_LAYOUTS 5 |
| 783 | #define MAX_KEYBOARD_ROWS 9 |
| 784 | #define MAX_KEYBOARD_KEYS 20 |
| 785 | #define KEYBOARD_ACTION 253 |
| 786 | #define KEYBOARD_LAYOUT 254 |
| 787 | #define KEYBOARD_SWIPE_LEFT 252 |
| 788 | #define KEYBOARD_SWIPE_RIGHT 251 |
| 789 | #define KEYBOARD_ARROW_LEFT 250 |
| 790 | #define KEYBOARD_ARROW_RIGHT 249 |
| 791 | #define KEYBOARD_HOME 248 |
| 792 | #define KEYBOARD_END 247 |
| 793 | #define KEYBOARD_ARROW_UP 246 |
| 794 | #define KEYBOARD_ARROW_DOWN 245 |
| 795 | #define KEYBOARD_SPECIAL_KEYS 245 |
| 796 | #define KEYBOARD_BACKSPACE 8 |
| 797 | |
| 798 | class GUIKeyboard : public RenderObject, public ActionObject, public Conditional |
| 799 | { |
| 800 | public: |
| 801 | GUIKeyboard(xml_node<>* node); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 802 | virtual ~GUIKeyboard(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 803 | |
| 804 | public: |
| 805 | virtual int Render(void); |
| 806 | virtual int Update(void); |
| 807 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
| 808 | virtual int SetRenderPos(int x, int y, int w = 0, int h = 0); |
| 809 | |
| 810 | protected: |
| 811 | virtual int GetSelection(int x, int y); |
| 812 | |
| 813 | protected: |
| 814 | struct keyboard_key_class |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 815 | { |
| 816 | unsigned char key; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 817 | unsigned char longpresskey; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 818 | unsigned int end_x; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 819 | unsigned int layout; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 820 | }; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 821 | |
| 822 | Resource* keyboardImg[MAX_KEYBOARD_LAYOUTS]; |
| 823 | struct keyboard_key_class keyboard_keys[MAX_KEYBOARD_LAYOUTS][MAX_KEYBOARD_ROWS][MAX_KEYBOARD_KEYS]; |
| 824 | bool mRendered; |
| 825 | std::string mVariable; |
| 826 | unsigned int cursorLocation; |
| 827 | unsigned int currentLayout; |
| 828 | unsigned int row_heights[MAX_KEYBOARD_LAYOUTS][MAX_KEYBOARD_ROWS]; |
| 829 | unsigned int KeyboardWidth, KeyboardHeight; |
Dees_Troy | 30b962e | 2012-10-19 20:48:59 -0400 | [diff] [blame] | 830 | int rowY, colX, highlightRenderCount, hasHighlight; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 831 | GUIAction* mAction; |
Dees_Troy | 30b962e | 2012-10-19 20:48:59 -0400 | [diff] [blame] | 832 | COLOR mHighlightColor; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 833 | }; |
| 834 | |
| 835 | // GUIInput - Used for keyboard input |
| 836 | class GUIInput : public RenderObject, public ActionObject, public Conditional, public InputObject |
| 837 | { |
| 838 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 839 | // w and h may be ignored, in which case, no bounding box is applied |
| 840 | GUIInput(xml_node<>* node); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 841 | virtual ~GUIInput(); |
| 842 | |
| 843 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 844 | // Render - Render the full object to the GL surface |
| 845 | // Return 0 on success, <0 on error |
| 846 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 847 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 848 | // Update - Update any UI component animations (called <= 30 FPS) |
| 849 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 850 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 851 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 852 | // Notify of a variable change |
| 853 | virtual int NotifyVarChange(std::string varName, std::string value); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 854 | |
| 855 | // NotifyTouch - Notify of a touch event |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 856 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 857 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 858 | |
| 859 | virtual int NotifyKeyboard(int key); |
| 860 | |
| 861 | protected: |
| 862 | virtual int GetSelection(int x, int y); |
| 863 | |
| 864 | // Handles displaying the text properly when chars are added, deleted, or for scrolling |
| 865 | virtual int HandleTextLocation(int x); |
| 866 | |
| 867 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 868 | GUIText* mInputText; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 869 | GUIAction* mAction; |
| 870 | Resource* mBackground; |
| 871 | Resource* mCursor; |
| 872 | Resource* mFont; |
| 873 | std::string mText; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 874 | std::string mLastValue; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 875 | std::string mVariable; |
| 876 | std::string mMask; |
| 877 | std::string mMaskVariable; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 878 | COLOR mBackgroundColor; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 879 | COLOR mCursorColor; |
| 880 | int scrollingX; |
| 881 | int lastX; |
| 882 | int mCursorLocation; |
| 883 | int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH; |
| 884 | int mFontY; |
| 885 | unsigned skipChars; |
| 886 | unsigned mFontHeight; |
| 887 | unsigned CursorWidth; |
| 888 | bool mRendered; |
| 889 | bool HasMask; |
| 890 | bool DrawCursor; |
| 891 | bool isLocalChange; |
| 892 | bool HasAllowed; |
| 893 | bool HasDisabled; |
| 894 | std::string AllowedList; |
| 895 | std::string DisabledList; |
| 896 | unsigned MinLen; |
| 897 | unsigned MaxLen; |
| 898 | }; |
| 899 | |
| 900 | class HardwareKeyboard |
| 901 | { |
| 902 | public: |
| 903 | HardwareKeyboard(void); |
| 904 | virtual ~HardwareKeyboard(); |
| 905 | |
| 906 | public: |
| 907 | virtual int KeyDown(int key_code); |
| 908 | virtual int KeyUp(int key_code); |
| 909 | virtual int KeyRepeat(void); |
| 910 | }; |
| 911 | |
Vojtech Bocek | 8593234 | 2013-04-01 22:11:33 +0200 | [diff] [blame] | 912 | class GUISliderValue: public RenderObject, public ActionObject, public Conditional |
| 913 | { |
| 914 | public: |
| 915 | GUISliderValue(xml_node<>* node); |
| 916 | virtual ~GUISliderValue(); |
| 917 | |
| 918 | public: |
| 919 | // Render - Render the full object to the GL surface |
| 920 | // Return 0 on success, <0 on error |
| 921 | virtual int Render(void); |
| 922 | |
| 923 | // Update - Update any UI component animations (called <= 30 FPS) |
| 924 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 925 | virtual int Update(void); |
| 926 | |
| 927 | // SetPos - Update the position of the render object |
| 928 | // Return 0 on success, <0 on error |
| 929 | virtual int SetRenderPos(int x, int y, int w = 0, int h = 0); |
| 930 | |
| 931 | // NotifyTouch - Notify of a touch event |
| 932 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 933 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
| 934 | |
| 935 | // Notify of a variable change |
| 936 | virtual int NotifyVarChange(std::string varName, std::string value); |
| 937 | |
| 938 | // SetPageFocus - Notify when a page gains or loses focus |
| 939 | virtual void SetPageFocus(int inFocus); |
| 940 | |
| 941 | protected: |
| 942 | int measureText(const std::string& str); |
| 943 | int valueFromPct(float pct); |
| 944 | float pctFromValue(int value); |
| 945 | void loadValue(bool force = false); |
| 946 | |
| 947 | std::string mVariable; |
| 948 | int mMax; |
| 949 | int mMin; |
| 950 | int mValue; |
| 951 | char *mValueStr; |
| 952 | float mValuePct; |
| 953 | std::string mMaxStr; |
| 954 | std::string mMinStr; |
| 955 | Resource *mFont; |
| 956 | GUIText* mLabel; |
| 957 | int mLabelW; |
| 958 | COLOR mTextColor; |
| 959 | COLOR mLineColor; |
| 960 | COLOR mSliderColor; |
| 961 | bool mShowRange; |
| 962 | bool mShowCurr; |
| 963 | int mLineX; |
| 964 | int mLineY; |
| 965 | int mLineH; |
| 966 | int mLinePadding; |
| 967 | int mPadding; |
| 968 | int mSliderY; |
| 969 | int mSliderW; |
| 970 | int mSliderH; |
| 971 | bool mRendered; |
| 972 | int mFontHeight; |
| 973 | GUIAction *mAction; |
| 974 | bool mChangeOnDrag; |
| 975 | int lineW; |
| 976 | }; |
| 977 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 978 | // Helper APIs |
| 979 | bool LoadPlacement(xml_node<>* node, int* x, int* y, int* w = NULL, int* h = NULL, RenderObject::Placement* placement = NULL); |
| 980 | |
| 981 | #endif // _OBJECTS_HEADER |
| 982 | |