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