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 |
| 218 | class GUIImage : public RenderObject |
| 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 | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 383 | }; |
| 384 | |
| 385 | class GUICheckbox: public RenderObject, public ActionObject, public Conditional |
| 386 | { |
| 387 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 388 | GUICheckbox(xml_node<>* node); |
| 389 | virtual ~GUICheckbox(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 390 | |
| 391 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 392 | // Render - Render the full object to the GL surface |
| 393 | // Return 0 on success, <0 on error |
| 394 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 395 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 396 | // Update - Update any UI component animations (called <= 30 FPS) |
| 397 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 398 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 399 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 400 | // SetPos - Update the position of the render object |
| 401 | // Return 0 on success, <0 on error |
| 402 | 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] | 403 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 404 | // NotifyTouch - Notify of a touch event |
| 405 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 406 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 407 | |
| 408 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 409 | Resource* mChecked; |
| 410 | Resource* mUnchecked; |
| 411 | GUIText* mLabel; |
| 412 | int mTextX, mTextY; |
| 413 | int mCheckX, mCheckY, mCheckW, mCheckH; |
| 414 | int mLastState; |
| 415 | bool mRendered; |
| 416 | std::string mVarName; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 417 | }; |
| 418 | |
| 419 | class GUIFileSelector : public RenderObject, public ActionObject |
| 420 | { |
| 421 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 422 | GUIFileSelector(xml_node<>* node); |
| 423 | virtual ~GUIFileSelector(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 424 | |
| 425 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 426 | // Render - Render the full object to the GL surface |
| 427 | // Return 0 on success, <0 on error |
| 428 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 429 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 430 | // Update - Update any UI component animations (called <= 30 FPS) |
| 431 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 432 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 433 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 434 | // NotifyTouch - Notify of a touch event |
| 435 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 436 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 437 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 438 | // NotifyVarChange - Notify of a variable change |
| 439 | virtual int NotifyVarChange(std::string varName, std::string value); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 440 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 441 | // SetPos - Update the position of the render object |
| 442 | // Return 0 on success, <0 on error |
| 443 | 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] | 444 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 445 | // SetPageFocus - Notify when a page gains or loses focus |
| 446 | virtual void SetPageFocus(int inFocus); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 447 | |
| 448 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 449 | struct FileData { |
| 450 | std::string fileName; |
| 451 | unsigned char fileType; // Uses d_type format from struct dirent |
| 452 | mode_t protection; // Uses mode_t format from stat |
| 453 | uid_t userId; |
| 454 | gid_t groupId; |
| 455 | off_t fileSize; |
| 456 | time_t lastAccess; // Uses time_t format from stat |
| 457 | time_t lastModified; // Uses time_t format from stat |
| 458 | time_t lastStatChange; // Uses time_t format from stat |
| 459 | }; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 460 | |
| 461 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 462 | virtual int GetSelection(int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 463 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 464 | virtual int GetFileList(const std::string folder); |
| 465 | static bool fileSort(FileData d1, FileData d2); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 466 | |
| 467 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 468 | std::vector<FileData> mFolderList; |
| 469 | std::vector<FileData> mFileList; |
| 470 | std::string mPathVar; |
| 471 | std::string mExtn; |
| 472 | std::string mVariable; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 473 | std::string mSortVariable; |
| 474 | std::string mSelection; |
| 475 | std::string mHeaderText; |
| 476 | std::string mLastValue; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 477 | int actualLineHeight; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 478 | int mStart; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 479 | int mLineSpacing; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 480 | int mSeparatorH; |
| 481 | int mHeaderSeparatorH; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 482 | int mShowFolders, mShowFiles, mShowNavFolders; |
| 483 | int mUpdate; |
| 484 | int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 485 | int mHeaderH; |
Vojtech Bocek | 7cc278b | 2013-02-24 01:40:19 +0100 | [diff] [blame] | 486 | int mFastScrollW; |
| 487 | int mFastScrollLineW; |
| 488 | int mFastScrollRectW; |
| 489 | int mFastScrollRectH; |
| 490 | int mFastScrollRectX; |
| 491 | int mFastScrollRectY; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 492 | static int mSortOrder; |
| 493 | int startY; |
| 494 | int scrollingSpeed; |
| 495 | int scrollingY; |
| 496 | int mHeaderIsStatic; |
| 497 | int touchDebounce; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 498 | unsigned mFontHeight; |
| 499 | unsigned mLineHeight; |
| 500 | int mIconWidth, mIconHeight, mFolderIconHeight, mFileIconHeight, mFolderIconWidth, mFileIconWidth, mHeaderIconHeight, mHeaderIconWidth; |
| 501 | Resource* mHeaderIcon; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 502 | Resource* mFolderIcon; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 503 | Resource* mFileIcon; |
| 504 | Resource* mBackground; |
| 505 | Resource* mFont; |
| 506 | COLOR mBackgroundColor; |
| 507 | COLOR mFontColor; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 508 | COLOR mHeaderBackgroundColor; |
| 509 | COLOR mHeaderFontColor; |
| 510 | COLOR mSeparatorColor; |
| 511 | COLOR mHeaderSeparatorColor; |
Vojtech Bocek | 7cc278b | 2013-02-24 01:40:19 +0100 | [diff] [blame] | 512 | COLOR mFastScrollLineColor; |
| 513 | COLOR mFastScrollRectColor; |
Dees_Troy | e7585ca | 2013-02-15 11:42:29 -0600 | [diff] [blame] | 514 | bool hasHighlightColor; |
| 515 | bool hasFontHighlightColor; |
| 516 | bool isHighlighted; |
| 517 | COLOR mHighlightColor; |
| 518 | COLOR mFontHighlightColor; |
| 519 | int startSelection; |
Dees_Troy | c0583f5 | 2013-02-28 11:19:57 -0600 | [diff] [blame] | 520 | bool updateFileList; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 521 | }; |
| 522 | |
| 523 | class GUIListBox : public RenderObject, public ActionObject |
| 524 | { |
| 525 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 526 | GUIListBox(xml_node<>* node); |
| 527 | virtual ~GUIListBox(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 528 | |
| 529 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 530 | // Render - Render the full object to the GL surface |
| 531 | // Return 0 on success, <0 on error |
| 532 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 533 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 534 | // Update - Update any UI component animations (called <= 30 FPS) |
| 535 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 536 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 537 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 538 | // NotifyTouch - Notify of a touch event |
| 539 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 540 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 541 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 542 | // NotifyVarChange - Notify of a variable change |
| 543 | virtual int NotifyVarChange(std::string varName, std::string value); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 544 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 545 | // SetPos - Update the position of the render object |
| 546 | // Return 0 on success, <0 on error |
| 547 | 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] | 548 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 549 | // SetPageFocus - Notify when a page gains or loses focus |
| 550 | virtual void SetPageFocus(int inFocus); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 551 | |
| 552 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 553 | struct ListData { |
| 554 | std::string displayName; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 555 | std::string variableValue; |
| 556 | unsigned int selected; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 557 | }; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 558 | |
| 559 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 560 | virtual int GetSelection(int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 561 | |
| 562 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 563 | std::vector<ListData> mList; |
| 564 | std::string mVariable; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 565 | std::string mSelection; |
| 566 | std::string currentValue; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 567 | std::string mHeaderText; |
| 568 | std::string mLastValue; |
| 569 | int actualLineHeight; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 570 | int mStart; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 571 | int startY; |
| 572 | int mSeparatorH, mHeaderSeparatorH; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 573 | int mLineSpacing; |
| 574 | int mUpdate; |
| 575 | int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH, mHeaderH; |
Dees_Troy | 58f5cf0 | 2013-02-27 22:21:41 +0000 | [diff] [blame] | 576 | int mFastScrollW; |
| 577 | int mFastScrollLineW; |
| 578 | int mFastScrollRectW; |
| 579 | int mFastScrollRectH; |
| 580 | int mFastScrollRectX; |
| 581 | int mFastScrollRectY; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 582 | int mIconWidth, mIconHeight, mSelectedIconWidth, mSelectedIconHeight, mUnselectedIconWidth, mUnselectedIconHeight, mHeaderIconHeight, mHeaderIconWidth; |
| 583 | int scrollingSpeed; |
| 584 | int scrollingY; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 585 | static int mSortOrder; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 586 | unsigned mFontHeight; |
| 587 | unsigned mLineHeight; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 588 | Resource* mHeaderIcon; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 589 | Resource* mIconSelected; |
| 590 | Resource* mIconUnselected; |
| 591 | Resource* mBackground; |
| 592 | Resource* mFont; |
| 593 | COLOR mBackgroundColor; |
| 594 | COLOR mFontColor; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 595 | COLOR mHeaderBackgroundColor; |
| 596 | COLOR mHeaderFontColor; |
| 597 | COLOR mSeparatorColor; |
| 598 | COLOR mHeaderSeparatorColor; |
Dees_Troy | 58f5cf0 | 2013-02-27 22:21:41 +0000 | [diff] [blame] | 599 | COLOR mFastScrollLineColor; |
| 600 | COLOR mFastScrollRectColor; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 601 | bool hasHighlightColor; |
| 602 | bool hasFontHighlightColor; |
| 603 | bool isHighlighted; |
| 604 | COLOR mHighlightColor; |
| 605 | COLOR mFontHighlightColor; |
| 606 | int mHeaderIsStatic; |
| 607 | int startSelection; |
| 608 | int touchDebounce; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 609 | }; |
| 610 | |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 611 | class GUIPartitionList : public RenderObject, public ActionObject |
| 612 | { |
| 613 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 614 | GUIPartitionList(xml_node<>* node); |
| 615 | virtual ~GUIPartitionList(); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 616 | |
| 617 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 618 | // Render - Render the full object to the GL surface |
| 619 | // Return 0 on success, <0 on error |
| 620 | virtual int Render(void); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 621 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 622 | // Update - Update any UI component animations (called <= 30 FPS) |
| 623 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 624 | virtual int Update(void); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 625 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 626 | // NotifyTouch - Notify of a touch event |
| 627 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 628 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 629 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 630 | // NotifyVarChange - Notify of a variable change |
| 631 | virtual int NotifyVarChange(std::string varName, std::string value); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 632 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 633 | // SetPos - Update the position of the render object |
| 634 | // Return 0 on success, <0 on error |
| 635 | 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] | 636 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 637 | // SetPageFocus - Notify when a page gains or loses focus |
| 638 | virtual void SetPageFocus(int inFocus); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 639 | |
| 640 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 641 | virtual int GetSelection(int x, int y); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 642 | virtual void MatchList(void); |
| 643 | |
| 644 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 645 | std::vector<PartitionList> mList; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 646 | std::string ListType; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 647 | std::string mVariable; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 648 | std::string selectedList; |
| 649 | std::string currentValue; |
| 650 | std::string mHeaderText; |
| 651 | std::string mLastValue; |
| 652 | int actualLineHeight; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 653 | int mStart; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 654 | int startY; |
| 655 | int mSeparatorH, mHeaderSeparatorH; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 656 | int mLineSpacing; |
| 657 | int mUpdate; |
| 658 | int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH, mHeaderH; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 659 | int mFastScrollW; |
| 660 | int mFastScrollLineW; |
| 661 | int mFastScrollRectW; |
| 662 | int mFastScrollRectH; |
| 663 | int mFastScrollRectX; |
| 664 | int mFastScrollRectY; |
| 665 | int mIconWidth, mIconHeight, mSelectedIconWidth, mSelectedIconHeight, mUnselectedIconWidth, mUnselectedIconHeight, mHeaderIconHeight, mHeaderIconWidth; |
| 666 | int scrollingSpeed; |
| 667 | int scrollingY; |
| 668 | static int mSortOrder; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 669 | unsigned mFontHeight; |
| 670 | unsigned mLineHeight; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 671 | Resource* mHeaderIcon; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 672 | Resource* mIconSelected; |
| 673 | Resource* mIconUnselected; |
| 674 | Resource* mBackground; |
| 675 | Resource* mFont; |
| 676 | COLOR mBackgroundColor; |
| 677 | COLOR mFontColor; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 678 | COLOR mHeaderBackgroundColor; |
| 679 | COLOR mHeaderFontColor; |
| 680 | COLOR mSeparatorColor; |
| 681 | COLOR mHeaderSeparatorColor; |
| 682 | COLOR mFastScrollLineColor; |
| 683 | COLOR mFastScrollRectColor; |
| 684 | bool hasHighlightColor; |
| 685 | bool hasFontHighlightColor; |
| 686 | bool isHighlighted; |
| 687 | COLOR mHighlightColor; |
| 688 | COLOR mFontHighlightColor; |
| 689 | int mHeaderIsStatic; |
| 690 | int startSelection; |
| 691 | int touchDebounce; |
| 692 | bool updateList; |
| 693 | }; |
| 694 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 695 | // GUIAnimation - Used for animations |
| 696 | class GUIAnimation : public RenderObject |
| 697 | { |
| 698 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 699 | GUIAnimation(xml_node<>* node); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 700 | |
| 701 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 702 | // Render - Render the full object to the GL surface |
| 703 | // Return 0 on success, <0 on error |
| 704 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 705 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 706 | // Update - Update any UI component animations (called <= 30 FPS) |
| 707 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 708 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 709 | |
| 710 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 711 | AnimationResource* mAnimation; |
| 712 | int mFrame; |
| 713 | int mFPS; |
| 714 | int mLoop; |
| 715 | int mRender; |
| 716 | int mUpdateCount; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 717 | }; |
| 718 | |
| 719 | class GUIProgressBar : public RenderObject, public ActionObject |
| 720 | { |
| 721 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 722 | GUIProgressBar(xml_node<>* node); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 723 | |
| 724 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 725 | // Render - Render the full object to the GL surface |
| 726 | // Return 0 on success, <0 on error |
| 727 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 728 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 729 | // Update - Update any UI component animations (called <= 30 FPS) |
| 730 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 731 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 732 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 733 | // NotifyVarChange - Notify of a variable change |
| 734 | // Returns 0 on success, <0 on error |
| 735 | virtual int NotifyVarChange(std::string varName, std::string value); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 736 | |
| 737 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 738 | Resource* mEmptyBar; |
| 739 | Resource* mFullBar; |
| 740 | std::string mMinValVar; |
| 741 | std::string mMaxValVar; |
| 742 | std::string mCurValVar; |
| 743 | float mSlide; |
| 744 | float mSlideInc; |
| 745 | int mSlideFrames; |
| 746 | int mLastPos; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 747 | |
| 748 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 749 | virtual int RenderInternal(void); // Does the actual render |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 750 | }; |
| 751 | |
| 752 | class GUISlider : public RenderObject, public ActionObject |
| 753 | { |
| 754 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 755 | GUISlider(xml_node<>* node); |
| 756 | virtual ~GUISlider(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 757 | |
| 758 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 759 | // Render - Render the full object to the GL surface |
| 760 | // Return 0 on success, <0 on error |
| 761 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 762 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 763 | // Update - Update any UI component animations (called <= 30 FPS) |
| 764 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 765 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 766 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 767 | // NotifyTouch - Notify of a touch event |
| 768 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 769 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 770 | |
| 771 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 772 | GUIAction* sAction; |
| 773 | Resource* sSlider; |
| 774 | Resource* sSliderUsed; |
| 775 | Resource* sTouch; |
| 776 | int sTouchW, sTouchH; |
| 777 | int sCurTouchX; |
| 778 | int sUpdate; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 779 | }; |
| 780 | |
| 781 | #define MAX_KEYBOARD_LAYOUTS 5 |
| 782 | #define MAX_KEYBOARD_ROWS 9 |
| 783 | #define MAX_KEYBOARD_KEYS 20 |
| 784 | #define KEYBOARD_ACTION 253 |
| 785 | #define KEYBOARD_LAYOUT 254 |
| 786 | #define KEYBOARD_SWIPE_LEFT 252 |
| 787 | #define KEYBOARD_SWIPE_RIGHT 251 |
| 788 | #define KEYBOARD_ARROW_LEFT 250 |
| 789 | #define KEYBOARD_ARROW_RIGHT 249 |
| 790 | #define KEYBOARD_HOME 248 |
| 791 | #define KEYBOARD_END 247 |
| 792 | #define KEYBOARD_ARROW_UP 246 |
| 793 | #define KEYBOARD_ARROW_DOWN 245 |
| 794 | #define KEYBOARD_SPECIAL_KEYS 245 |
| 795 | #define KEYBOARD_BACKSPACE 8 |
| 796 | |
| 797 | class GUIKeyboard : public RenderObject, public ActionObject, public Conditional |
| 798 | { |
| 799 | public: |
| 800 | GUIKeyboard(xml_node<>* node); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 801 | virtual ~GUIKeyboard(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 802 | |
| 803 | public: |
| 804 | virtual int Render(void); |
| 805 | virtual int Update(void); |
| 806 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
| 807 | virtual int SetRenderPos(int x, int y, int w = 0, int h = 0); |
| 808 | |
| 809 | protected: |
| 810 | virtual int GetSelection(int x, int y); |
| 811 | |
| 812 | protected: |
| 813 | struct keyboard_key_class |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 814 | { |
| 815 | unsigned char key; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 816 | unsigned char longpresskey; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 817 | unsigned int end_x; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 818 | unsigned int layout; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 819 | }; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 820 | |
| 821 | Resource* keyboardImg[MAX_KEYBOARD_LAYOUTS]; |
| 822 | struct keyboard_key_class keyboard_keys[MAX_KEYBOARD_LAYOUTS][MAX_KEYBOARD_ROWS][MAX_KEYBOARD_KEYS]; |
| 823 | bool mRendered; |
| 824 | std::string mVariable; |
| 825 | unsigned int cursorLocation; |
| 826 | unsigned int currentLayout; |
| 827 | unsigned int row_heights[MAX_KEYBOARD_LAYOUTS][MAX_KEYBOARD_ROWS]; |
| 828 | unsigned int KeyboardWidth, KeyboardHeight; |
Dees_Troy | 30b962e | 2012-10-19 20:48:59 -0400 | [diff] [blame] | 829 | int rowY, colX, highlightRenderCount, hasHighlight; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 830 | GUIAction* mAction; |
Dees_Troy | 30b962e | 2012-10-19 20:48:59 -0400 | [diff] [blame] | 831 | COLOR mHighlightColor; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 832 | }; |
| 833 | |
| 834 | // GUIInput - Used for keyboard input |
| 835 | class GUIInput : public RenderObject, public ActionObject, public Conditional, public InputObject |
| 836 | { |
| 837 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 838 | // w and h may be ignored, in which case, no bounding box is applied |
| 839 | GUIInput(xml_node<>* node); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 840 | virtual ~GUIInput(); |
| 841 | |
| 842 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 843 | // Render - Render the full object to the GL surface |
| 844 | // Return 0 on success, <0 on error |
| 845 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 846 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 847 | // Update - Update any UI component animations (called <= 30 FPS) |
| 848 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 849 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 850 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 851 | // Notify of a variable change |
| 852 | virtual int NotifyVarChange(std::string varName, std::string value); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 853 | |
| 854 | // NotifyTouch - Notify of a touch event |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 855 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 856 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 857 | |
| 858 | virtual int NotifyKeyboard(int key); |
| 859 | |
| 860 | protected: |
| 861 | virtual int GetSelection(int x, int y); |
| 862 | |
| 863 | // Handles displaying the text properly when chars are added, deleted, or for scrolling |
| 864 | virtual int HandleTextLocation(int x); |
| 865 | |
| 866 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 867 | GUIText* mInputText; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 868 | GUIAction* mAction; |
| 869 | Resource* mBackground; |
| 870 | Resource* mCursor; |
| 871 | Resource* mFont; |
| 872 | std::string mText; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 873 | std::string mLastValue; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 874 | std::string mVariable; |
| 875 | std::string mMask; |
| 876 | std::string mMaskVariable; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 877 | COLOR mBackgroundColor; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 878 | COLOR mCursorColor; |
| 879 | int scrollingX; |
| 880 | int lastX; |
| 881 | int mCursorLocation; |
| 882 | int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH; |
| 883 | int mFontY; |
| 884 | unsigned skipChars; |
| 885 | unsigned mFontHeight; |
| 886 | unsigned CursorWidth; |
| 887 | bool mRendered; |
| 888 | bool HasMask; |
| 889 | bool DrawCursor; |
| 890 | bool isLocalChange; |
| 891 | bool HasAllowed; |
| 892 | bool HasDisabled; |
| 893 | std::string AllowedList; |
| 894 | std::string DisabledList; |
| 895 | unsigned MinLen; |
| 896 | unsigned MaxLen; |
| 897 | }; |
| 898 | |
| 899 | class HardwareKeyboard |
| 900 | { |
| 901 | public: |
| 902 | HardwareKeyboard(void); |
| 903 | virtual ~HardwareKeyboard(); |
| 904 | |
| 905 | public: |
| 906 | virtual int KeyDown(int key_code); |
| 907 | virtual int KeyUp(int key_code); |
| 908 | virtual int KeyRepeat(void); |
| 909 | }; |
| 910 | |
Vojtech Bocek | 8593234 | 2013-04-01 22:11:33 +0200 | [diff] [blame] | 911 | class GUISliderValue: public RenderObject, public ActionObject, public Conditional |
| 912 | { |
| 913 | public: |
| 914 | GUISliderValue(xml_node<>* node); |
| 915 | virtual ~GUISliderValue(); |
| 916 | |
| 917 | public: |
| 918 | // Render - Render the full object to the GL surface |
| 919 | // Return 0 on success, <0 on error |
| 920 | virtual int Render(void); |
| 921 | |
| 922 | // Update - Update any UI component animations (called <= 30 FPS) |
| 923 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 924 | virtual int Update(void); |
| 925 | |
| 926 | // SetPos - Update the position of the render object |
| 927 | // Return 0 on success, <0 on error |
| 928 | virtual int SetRenderPos(int x, int y, int w = 0, int h = 0); |
| 929 | |
| 930 | // NotifyTouch - Notify of a touch event |
| 931 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 932 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
| 933 | |
| 934 | // Notify of a variable change |
| 935 | virtual int NotifyVarChange(std::string varName, std::string value); |
| 936 | |
| 937 | // SetPageFocus - Notify when a page gains or loses focus |
| 938 | virtual void SetPageFocus(int inFocus); |
| 939 | |
| 940 | protected: |
| 941 | int measureText(const std::string& str); |
| 942 | int valueFromPct(float pct); |
| 943 | float pctFromValue(int value); |
| 944 | void loadValue(bool force = false); |
| 945 | |
| 946 | std::string mVariable; |
| 947 | int mMax; |
| 948 | int mMin; |
| 949 | int mValue; |
| 950 | char *mValueStr; |
| 951 | float mValuePct; |
| 952 | std::string mMaxStr; |
| 953 | std::string mMinStr; |
| 954 | Resource *mFont; |
| 955 | GUIText* mLabel; |
| 956 | int mLabelW; |
| 957 | COLOR mTextColor; |
| 958 | COLOR mLineColor; |
| 959 | COLOR mSliderColor; |
| 960 | bool mShowRange; |
| 961 | bool mShowCurr; |
| 962 | int mLineX; |
| 963 | int mLineY; |
| 964 | int mLineH; |
| 965 | int mLinePadding; |
| 966 | int mPadding; |
| 967 | int mSliderY; |
| 968 | int mSliderW; |
| 969 | int mSliderH; |
| 970 | bool mRendered; |
| 971 | int mFontHeight; |
| 972 | GUIAction *mAction; |
| 973 | bool mChangeOnDrag; |
| 974 | int lineW; |
| 975 | }; |
| 976 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 977 | // Helper APIs |
| 978 | bool LoadPlacement(xml_node<>* node, int* x, int* y, int* w = NULL, int* h = NULL, RenderObject::Placement* placement = NULL); |
| 979 | |
| 980 | #endif // _OBJECTS_HEADER |
| 981 | |