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