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