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