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