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; |
| 353 | bool mRender; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 354 | |
| 355 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 356 | virtual int RenderSlideout(void); |
| 357 | virtual int RenderConsole(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 358 | }; |
| 359 | |
Vojtech Bocek | ede51c5 | 2014-02-07 23:58:09 +0100 | [diff] [blame] | 360 | class GUIButton : public GUIObject, public RenderObject, public ActionObject |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 361 | { |
| 362 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 363 | GUIButton(xml_node<>* node); |
| 364 | virtual ~GUIButton(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 365 | |
| 366 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 367 | // Render - Render the full object to the GL surface |
| 368 | // Return 0 on success, <0 on error |
| 369 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 370 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 371 | // Update - Update any UI component animations (called <= 30 FPS) |
| 372 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 373 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 374 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 375 | // SetPos - Update the position of the render object |
| 376 | // Return 0 on success, <0 on error |
| 377 | 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] | 378 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 379 | // NotifyTouch - Notify of a touch event |
| 380 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 381 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 382 | |
| 383 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 384 | GUIImage* mButtonImg; |
| 385 | Resource* mButtonIcon; |
| 386 | GUIText* mButtonLabel; |
| 387 | GUIAction* mAction; |
| 388 | int mTextX, mTextY, mTextW, mTextH; |
| 389 | int mIconX, mIconY, mIconW, mIconH; |
| 390 | bool mRendered; |
Dees_Troy | 1a7a667 | 2013-02-15 09:39:07 -0600 | [diff] [blame] | 391 | bool hasHighlightColor; |
| 392 | bool renderHighlight; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 393 | bool hasFill; |
| 394 | COLOR mFillColor; |
Dees_Troy | 1a7a667 | 2013-02-15 09:39:07 -0600 | [diff] [blame] | 395 | COLOR mHighlightColor; |
Dees Troy | b21cc64 | 2013-09-10 17:36:41 +0000 | [diff] [blame] | 396 | Placement TextPlacement; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 397 | }; |
| 398 | |
Vojtech Bocek | ede51c5 | 2014-02-07 23:58:09 +0100 | [diff] [blame] | 399 | class GUICheckbox: public GUIObject, public RenderObject, public ActionObject |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 400 | { |
| 401 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 402 | GUICheckbox(xml_node<>* node); |
| 403 | virtual ~GUICheckbox(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 404 | |
| 405 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 406 | // Render - Render the full object to the GL surface |
| 407 | // Return 0 on success, <0 on error |
| 408 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 409 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 410 | // Update - Update any UI component animations (called <= 30 FPS) |
| 411 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 412 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 413 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 414 | // SetPos - Update the position of the render object |
| 415 | // Return 0 on success, <0 on error |
| 416 | 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] | 417 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 418 | // NotifyTouch - Notify of a touch event |
| 419 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 420 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 421 | |
| 422 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 423 | Resource* mChecked; |
| 424 | Resource* mUnchecked; |
| 425 | GUIText* mLabel; |
| 426 | int mTextX, mTextY; |
| 427 | int mCheckX, mCheckY, mCheckW, mCheckH; |
| 428 | int mLastState; |
| 429 | bool mRendered; |
| 430 | std::string mVarName; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 431 | }; |
| 432 | |
Vojtech Bocek | ede51c5 | 2014-02-07 23:58:09 +0100 | [diff] [blame] | 433 | class GUIFileSelector : public GUIObject, public RenderObject, public ActionObject |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 434 | { |
| 435 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 436 | GUIFileSelector(xml_node<>* node); |
| 437 | virtual ~GUIFileSelector(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 438 | |
| 439 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 440 | // Render - Render the full object to the GL surface |
| 441 | // Return 0 on success, <0 on error |
| 442 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 443 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 444 | // Update - Update any UI component animations (called <= 30 FPS) |
| 445 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 446 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 447 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 448 | // NotifyTouch - Notify of a touch event |
| 449 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 450 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 451 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 452 | // NotifyVarChange - Notify of a variable change |
Vojtech Bocek | 0722056 | 2014-02-08 02:05:33 +0100 | [diff] [blame] | 453 | virtual int NotifyVarChange(const std::string& varName, const std::string& value); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 454 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 455 | // SetPos - Update the position of the render object |
| 456 | // Return 0 on success, <0 on error |
| 457 | 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] | 458 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 459 | // SetPageFocus - Notify when a page gains or loses focus |
| 460 | virtual void SetPageFocus(int inFocus); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 461 | |
| 462 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 463 | struct FileData { |
| 464 | std::string fileName; |
| 465 | unsigned char fileType; // Uses d_type format from struct dirent |
| 466 | mode_t protection; // Uses mode_t format from stat |
| 467 | uid_t userId; |
| 468 | gid_t groupId; |
| 469 | off_t fileSize; |
| 470 | time_t lastAccess; // Uses time_t format from stat |
| 471 | time_t lastModified; // Uses time_t format from stat |
| 472 | time_t lastStatChange; // Uses time_t format from stat |
| 473 | }; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 474 | |
| 475 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 476 | virtual int GetSelection(int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 477 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 478 | virtual int GetFileList(const std::string folder); |
| 479 | static bool fileSort(FileData d1, FileData d2); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 480 | |
| 481 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 482 | std::vector<FileData> mFolderList; |
| 483 | std::vector<FileData> mFileList; |
| 484 | std::string mPathVar; |
| 485 | std::string mExtn; |
| 486 | std::string mVariable; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 487 | std::string mSortVariable; |
| 488 | std::string mSelection; |
| 489 | std::string mHeaderText; |
| 490 | std::string mLastValue; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 491 | int actualLineHeight; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 492 | int mStart; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 493 | int mLineSpacing; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 494 | int mSeparatorH; |
| 495 | int mHeaderSeparatorH; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 496 | int mShowFolders, mShowFiles, mShowNavFolders; |
| 497 | int mUpdate; |
| 498 | int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 499 | int mHeaderH; |
Vojtech Bocek | 7cc278b | 2013-02-24 01:40:19 +0100 | [diff] [blame] | 500 | int mFastScrollW; |
| 501 | int mFastScrollLineW; |
| 502 | int mFastScrollRectW; |
| 503 | int mFastScrollRectH; |
| 504 | int mFastScrollRectX; |
| 505 | int mFastScrollRectY; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 506 | static int mSortOrder; |
| 507 | int startY; |
| 508 | int scrollingSpeed; |
| 509 | int scrollingY; |
| 510 | int mHeaderIsStatic; |
| 511 | int touchDebounce; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 512 | unsigned mFontHeight; |
| 513 | unsigned mLineHeight; |
| 514 | int mIconWidth, mIconHeight, mFolderIconHeight, mFileIconHeight, mFolderIconWidth, mFileIconWidth, mHeaderIconHeight, mHeaderIconWidth; |
| 515 | Resource* mHeaderIcon; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 516 | Resource* mFolderIcon; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 517 | Resource* mFileIcon; |
| 518 | Resource* mBackground; |
| 519 | Resource* mFont; |
| 520 | COLOR mBackgroundColor; |
| 521 | COLOR mFontColor; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 522 | COLOR mHeaderBackgroundColor; |
| 523 | COLOR mHeaderFontColor; |
| 524 | COLOR mSeparatorColor; |
| 525 | COLOR mHeaderSeparatorColor; |
Vojtech Bocek | 7cc278b | 2013-02-24 01:40:19 +0100 | [diff] [blame] | 526 | COLOR mFastScrollLineColor; |
| 527 | COLOR mFastScrollRectColor; |
Dees_Troy | e7585ca | 2013-02-15 11:42:29 -0600 | [diff] [blame] | 528 | bool hasHighlightColor; |
| 529 | bool hasFontHighlightColor; |
| 530 | bool isHighlighted; |
| 531 | COLOR mHighlightColor; |
| 532 | COLOR mFontHighlightColor; |
| 533 | int startSelection; |
Dees_Troy | c0583f5 | 2013-02-28 11:19:57 -0600 | [diff] [blame] | 534 | bool updateFileList; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 535 | }; |
| 536 | |
Vojtech Bocek | ede51c5 | 2014-02-07 23:58:09 +0100 | [diff] [blame] | 537 | class GUIListBox : public GUIObject, public RenderObject, public ActionObject |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 538 | { |
| 539 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 540 | GUIListBox(xml_node<>* node); |
| 541 | virtual ~GUIListBox(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 542 | |
| 543 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 544 | // Render - Render the full object to the GL surface |
| 545 | // Return 0 on success, <0 on error |
| 546 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 547 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 548 | // Update - Update any UI component animations (called <= 30 FPS) |
| 549 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 550 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 551 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 552 | // NotifyTouch - Notify of a touch event |
| 553 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 554 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 555 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 556 | // NotifyVarChange - Notify of a variable change |
Vojtech Bocek | 0722056 | 2014-02-08 02:05:33 +0100 | [diff] [blame] | 557 | virtual int NotifyVarChange(const std::string& varName, const std::string& value); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 558 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 559 | // SetPos - Update the position of the render object |
| 560 | // Return 0 on success, <0 on error |
| 561 | 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] | 562 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 563 | // SetPageFocus - Notify when a page gains or loses focus |
| 564 | virtual void SetPageFocus(int inFocus); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 565 | |
| 566 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 567 | struct ListData { |
| 568 | std::string displayName; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 569 | std::string variableValue; |
| 570 | unsigned int selected; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 571 | }; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 572 | |
| 573 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 574 | virtual int GetSelection(int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 575 | |
| 576 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 577 | std::vector<ListData> mList; |
| 578 | std::string mVariable; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 579 | std::string mSelection; |
| 580 | std::string currentValue; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 581 | std::string mHeaderText; |
| 582 | std::string mLastValue; |
| 583 | int actualLineHeight; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 584 | int mStart; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 585 | int startY; |
| 586 | int mSeparatorH, mHeaderSeparatorH; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 587 | int mLineSpacing; |
| 588 | int mUpdate; |
| 589 | int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH, mHeaderH; |
Dees_Troy | 58f5cf0 | 2013-02-27 22:21:41 +0000 | [diff] [blame] | 590 | int mFastScrollW; |
| 591 | int mFastScrollLineW; |
| 592 | int mFastScrollRectW; |
| 593 | int mFastScrollRectH; |
| 594 | int mFastScrollRectX; |
| 595 | int mFastScrollRectY; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 596 | int mIconWidth, mIconHeight, mSelectedIconWidth, mSelectedIconHeight, mUnselectedIconWidth, mUnselectedIconHeight, mHeaderIconHeight, mHeaderIconWidth; |
| 597 | int scrollingSpeed; |
| 598 | int scrollingY; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 599 | static int mSortOrder; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 600 | unsigned mFontHeight; |
| 601 | unsigned mLineHeight; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 602 | Resource* mHeaderIcon; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 603 | Resource* mIconSelected; |
| 604 | Resource* mIconUnselected; |
| 605 | Resource* mBackground; |
| 606 | Resource* mFont; |
| 607 | COLOR mBackgroundColor; |
| 608 | COLOR mFontColor; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 609 | COLOR mHeaderBackgroundColor; |
| 610 | COLOR mHeaderFontColor; |
| 611 | COLOR mSeparatorColor; |
| 612 | COLOR mHeaderSeparatorColor; |
Dees_Troy | 58f5cf0 | 2013-02-27 22:21:41 +0000 | [diff] [blame] | 613 | COLOR mFastScrollLineColor; |
| 614 | COLOR mFastScrollRectColor; |
Dees_Troy | eead985 | 2013-02-15 14:31:06 -0600 | [diff] [blame] | 615 | bool hasHighlightColor; |
| 616 | bool hasFontHighlightColor; |
| 617 | bool isHighlighted; |
| 618 | COLOR mHighlightColor; |
| 619 | COLOR mFontHighlightColor; |
| 620 | int mHeaderIsStatic; |
| 621 | int startSelection; |
| 622 | int touchDebounce; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 623 | }; |
| 624 | |
Vojtech Bocek | ede51c5 | 2014-02-07 23:58:09 +0100 | [diff] [blame] | 625 | class GUIPartitionList : public GUIObject, public RenderObject, public ActionObject |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 626 | { |
| 627 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 628 | GUIPartitionList(xml_node<>* node); |
| 629 | virtual ~GUIPartitionList(); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 630 | |
| 631 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 632 | // Render - Render the full object to the GL surface |
| 633 | // Return 0 on success, <0 on error |
| 634 | virtual int Render(void); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 635 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 636 | // Update - Update any UI component animations (called <= 30 FPS) |
| 637 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 638 | virtual int Update(void); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 639 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 640 | // NotifyTouch - Notify of a touch event |
| 641 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 642 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 643 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 644 | // NotifyVarChange - Notify of a variable change |
Vojtech Bocek | 0722056 | 2014-02-08 02:05:33 +0100 | [diff] [blame] | 645 | virtual int NotifyVarChange(const std::string& varName, const std::string& value); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 646 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 647 | // SetPos - Update the position of the render object |
| 648 | // Return 0 on success, <0 on error |
| 649 | 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] | 650 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 651 | // SetPageFocus - Notify when a page gains or loses focus |
| 652 | virtual void SetPageFocus(int inFocus); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 653 | |
| 654 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 655 | virtual int GetSelection(int x, int y); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 656 | virtual void MatchList(void); |
| 657 | |
| 658 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 659 | std::vector<PartitionList> mList; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 660 | std::string ListType; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 661 | std::string mVariable; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 662 | std::string selectedList; |
| 663 | std::string currentValue; |
| 664 | std::string mHeaderText; |
| 665 | std::string mLastValue; |
| 666 | int actualLineHeight; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 667 | int mStart; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 668 | int startY; |
| 669 | int mSeparatorH, mHeaderSeparatorH; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 670 | int mLineSpacing; |
| 671 | int mUpdate; |
| 672 | int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH, mHeaderH; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 673 | int mFastScrollW; |
| 674 | int mFastScrollLineW; |
| 675 | int mFastScrollRectW; |
| 676 | int mFastScrollRectH; |
| 677 | int mFastScrollRectX; |
| 678 | int mFastScrollRectY; |
| 679 | int mIconWidth, mIconHeight, mSelectedIconWidth, mSelectedIconHeight, mUnselectedIconWidth, mUnselectedIconHeight, mHeaderIconHeight, mHeaderIconWidth; |
| 680 | int scrollingSpeed; |
| 681 | int scrollingY; |
| 682 | static int mSortOrder; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 683 | unsigned mFontHeight; |
| 684 | unsigned mLineHeight; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 685 | Resource* mHeaderIcon; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 686 | Resource* mIconSelected; |
| 687 | Resource* mIconUnselected; |
| 688 | Resource* mBackground; |
| 689 | Resource* mFont; |
| 690 | COLOR mBackgroundColor; |
| 691 | COLOR mFontColor; |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 692 | COLOR mHeaderBackgroundColor; |
| 693 | COLOR mHeaderFontColor; |
| 694 | COLOR mSeparatorColor; |
| 695 | COLOR mHeaderSeparatorColor; |
| 696 | COLOR mFastScrollLineColor; |
| 697 | COLOR mFastScrollRectColor; |
| 698 | bool hasHighlightColor; |
| 699 | bool hasFontHighlightColor; |
| 700 | bool isHighlighted; |
| 701 | COLOR mHighlightColor; |
| 702 | COLOR mFontHighlightColor; |
| 703 | int mHeaderIsStatic; |
| 704 | int startSelection; |
| 705 | int touchDebounce; |
| 706 | bool updateList; |
| 707 | }; |
| 708 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 709 | // GUIAnimation - Used for animations |
Vojtech Bocek | ede51c5 | 2014-02-07 23:58:09 +0100 | [diff] [blame] | 710 | class GUIAnimation : public GUIObject, public RenderObject |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 711 | { |
| 712 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 713 | GUIAnimation(xml_node<>* node); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 714 | |
| 715 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 716 | // Render - Render the full object to the GL surface |
| 717 | // Return 0 on success, <0 on error |
| 718 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 719 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 720 | // Update - Update any UI component animations (called <= 30 FPS) |
| 721 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 722 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 723 | |
| 724 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 725 | AnimationResource* mAnimation; |
| 726 | int mFrame; |
| 727 | int mFPS; |
| 728 | int mLoop; |
| 729 | int mRender; |
| 730 | int mUpdateCount; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 731 | }; |
| 732 | |
Vojtech Bocek | ede51c5 | 2014-02-07 23:58:09 +0100 | [diff] [blame] | 733 | class GUIProgressBar : public GUIObject, public RenderObject, public ActionObject |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 734 | { |
| 735 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 736 | GUIProgressBar(xml_node<>* node); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 737 | |
| 738 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 739 | // Render - Render the full object to the GL surface |
| 740 | // Return 0 on success, <0 on error |
| 741 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 742 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 743 | // Update - Update any UI component animations (called <= 30 FPS) |
| 744 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 745 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 746 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 747 | // NotifyVarChange - Notify of a variable change |
| 748 | // Returns 0 on success, <0 on error |
Vojtech Bocek | 0722056 | 2014-02-08 02:05:33 +0100 | [diff] [blame] | 749 | virtual int NotifyVarChange(const std::string& varName, const std::string& value); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 750 | |
| 751 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 752 | Resource* mEmptyBar; |
| 753 | Resource* mFullBar; |
| 754 | std::string mMinValVar; |
| 755 | std::string mMaxValVar; |
| 756 | std::string mCurValVar; |
| 757 | float mSlide; |
| 758 | float mSlideInc; |
| 759 | int mSlideFrames; |
| 760 | int mLastPos; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 761 | |
| 762 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 763 | virtual int RenderInternal(void); // Does the actual render |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 764 | }; |
| 765 | |
Vojtech Bocek | ede51c5 | 2014-02-07 23:58:09 +0100 | [diff] [blame] | 766 | class GUISlider : public GUIObject, public RenderObject, public ActionObject |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 767 | { |
| 768 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 769 | GUISlider(xml_node<>* node); |
| 770 | virtual ~GUISlider(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 771 | |
| 772 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 773 | // Render - Render the full object to the GL surface |
| 774 | // Return 0 on success, <0 on error |
| 775 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 776 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 777 | // Update - Update any UI component animations (called <= 30 FPS) |
| 778 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 779 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 780 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 781 | // NotifyTouch - Notify of a touch event |
| 782 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 783 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 784 | |
| 785 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 786 | GUIAction* sAction; |
| 787 | Resource* sSlider; |
| 788 | Resource* sSliderUsed; |
| 789 | Resource* sTouch; |
| 790 | int sTouchW, sTouchH; |
| 791 | int sCurTouchX; |
| 792 | int sUpdate; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 793 | }; |
| 794 | |
| 795 | #define MAX_KEYBOARD_LAYOUTS 5 |
| 796 | #define MAX_KEYBOARD_ROWS 9 |
| 797 | #define MAX_KEYBOARD_KEYS 20 |
| 798 | #define KEYBOARD_ACTION 253 |
| 799 | #define KEYBOARD_LAYOUT 254 |
| 800 | #define KEYBOARD_SWIPE_LEFT 252 |
| 801 | #define KEYBOARD_SWIPE_RIGHT 251 |
| 802 | #define KEYBOARD_ARROW_LEFT 250 |
| 803 | #define KEYBOARD_ARROW_RIGHT 249 |
| 804 | #define KEYBOARD_HOME 248 |
| 805 | #define KEYBOARD_END 247 |
| 806 | #define KEYBOARD_ARROW_UP 246 |
| 807 | #define KEYBOARD_ARROW_DOWN 245 |
| 808 | #define KEYBOARD_SPECIAL_KEYS 245 |
| 809 | #define KEYBOARD_BACKSPACE 8 |
| 810 | |
Vojtech Bocek | ede51c5 | 2014-02-07 23:58:09 +0100 | [diff] [blame] | 811 | class GUIKeyboard : public GUIObject, public RenderObject, public ActionObject |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 812 | { |
| 813 | public: |
| 814 | GUIKeyboard(xml_node<>* node); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 815 | virtual ~GUIKeyboard(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 816 | |
| 817 | public: |
| 818 | virtual int Render(void); |
| 819 | virtual int Update(void); |
| 820 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
| 821 | virtual int SetRenderPos(int x, int y, int w = 0, int h = 0); |
| 822 | |
| 823 | protected: |
| 824 | virtual int GetSelection(int x, int y); |
| 825 | |
| 826 | protected: |
| 827 | struct keyboard_key_class |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 828 | { |
| 829 | unsigned char key; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 830 | unsigned char longpresskey; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 831 | unsigned int end_x; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 832 | unsigned int layout; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 833 | }; |
Ethan Yonker | c3120d4 | 2014-02-17 07:55:00 -0600 | [diff] [blame] | 834 | struct capslock_tracking_struct |
| 835 | { |
| 836 | int capslock; |
| 837 | int set_capslock; |
| 838 | int revert_layout; |
| 839 | }; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 840 | |
| 841 | Resource* keyboardImg[MAX_KEYBOARD_LAYOUTS]; |
| 842 | 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] | 843 | struct capslock_tracking_struct caps_tracking[MAX_KEYBOARD_LAYOUTS]; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 844 | bool mRendered; |
| 845 | std::string mVariable; |
| 846 | unsigned int cursorLocation; |
| 847 | unsigned int currentLayout; |
| 848 | unsigned int row_heights[MAX_KEYBOARD_LAYOUTS][MAX_KEYBOARD_ROWS]; |
| 849 | unsigned int KeyboardWidth, KeyboardHeight; |
Ethan Yonker | c3120d4 | 2014-02-17 07:55:00 -0600 | [diff] [blame] | 850 | int rowY, colX, highlightRenderCount, hasHighlight, hasCapsHighlight; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 851 | GUIAction* mAction; |
Dees_Troy | 30b962e | 2012-10-19 20:48:59 -0400 | [diff] [blame] | 852 | COLOR mHighlightColor; |
Ethan Yonker | c3120d4 | 2014-02-17 07:55:00 -0600 | [diff] [blame] | 853 | COLOR mCapsHighlightColor; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 854 | }; |
| 855 | |
| 856 | // GUIInput - Used for keyboard input |
Vojtech Bocek | ede51c5 | 2014-02-07 23:58:09 +0100 | [diff] [blame] | 857 | class GUIInput : public GUIObject, public RenderObject, public ActionObject, public InputObject |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 858 | { |
| 859 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 860 | // w and h may be ignored, in which case, no bounding box is applied |
| 861 | GUIInput(xml_node<>* node); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 862 | virtual ~GUIInput(); |
| 863 | |
| 864 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 865 | // Render - Render the full object to the GL surface |
| 866 | // Return 0 on success, <0 on error |
| 867 | virtual int Render(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 868 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 869 | // Update - Update any UI component animations (called <= 30 FPS) |
| 870 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 871 | virtual int Update(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 872 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 873 | // Notify of a variable change |
Vojtech Bocek | 0722056 | 2014-02-08 02:05:33 +0100 | [diff] [blame] | 874 | virtual int NotifyVarChange(const std::string& varName, const std::string& value); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 875 | |
| 876 | // NotifyTouch - Notify of a touch event |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 877 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 878 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 879 | |
| 880 | virtual int NotifyKeyboard(int key); |
| 881 | |
| 882 | protected: |
| 883 | virtual int GetSelection(int x, int y); |
| 884 | |
| 885 | // Handles displaying the text properly when chars are added, deleted, or for scrolling |
| 886 | virtual int HandleTextLocation(int x); |
| 887 | |
| 888 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 889 | GUIText* mInputText; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 890 | GUIAction* mAction; |
| 891 | Resource* mBackground; |
| 892 | Resource* mCursor; |
| 893 | Resource* mFont; |
| 894 | std::string mText; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 895 | std::string mLastValue; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 896 | std::string mVariable; |
| 897 | std::string mMask; |
| 898 | std::string mMaskVariable; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 899 | COLOR mBackgroundColor; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 900 | COLOR mCursorColor; |
| 901 | int scrollingX; |
| 902 | int lastX; |
| 903 | int mCursorLocation; |
| 904 | int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH; |
| 905 | int mFontY; |
| 906 | unsigned skipChars; |
| 907 | unsigned mFontHeight; |
| 908 | unsigned CursorWidth; |
| 909 | bool mRendered; |
| 910 | bool HasMask; |
| 911 | bool DrawCursor; |
| 912 | bool isLocalChange; |
| 913 | bool HasAllowed; |
| 914 | bool HasDisabled; |
| 915 | std::string AllowedList; |
| 916 | std::string DisabledList; |
| 917 | unsigned MinLen; |
| 918 | unsigned MaxLen; |
| 919 | }; |
| 920 | |
| 921 | class HardwareKeyboard |
| 922 | { |
| 923 | public: |
| 924 | HardwareKeyboard(void); |
| 925 | virtual ~HardwareKeyboard(); |
| 926 | |
| 927 | public: |
| 928 | virtual int KeyDown(int key_code); |
| 929 | virtual int KeyUp(int key_code); |
| 930 | virtual int KeyRepeat(void); |
Vojtech Bocek | 0b7fe50 | 2014-03-13 17:36:52 +0100 | [diff] [blame] | 931 | |
| 932 | void ConsumeKeyRelease(int key); |
| 933 | |
| 934 | private: |
| 935 | std::set<int> mPressedKeys; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 936 | }; |
| 937 | |
Vojtech Bocek | ede51c5 | 2014-02-07 23:58:09 +0100 | [diff] [blame] | 938 | class GUISliderValue: public GUIObject, public RenderObject, public ActionObject |
Vojtech Bocek | 8593234 | 2013-04-01 22:11:33 +0200 | [diff] [blame] | 939 | { |
| 940 | public: |
| 941 | GUISliderValue(xml_node<>* node); |
| 942 | virtual ~GUISliderValue(); |
| 943 | |
| 944 | public: |
| 945 | // Render - Render the full object to the GL surface |
| 946 | // Return 0 on success, <0 on error |
| 947 | virtual int Render(void); |
| 948 | |
| 949 | // Update - Update any UI component animations (called <= 30 FPS) |
| 950 | // Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error |
| 951 | virtual int Update(void); |
| 952 | |
| 953 | // SetPos - Update the position of the render object |
| 954 | // Return 0 on success, <0 on error |
| 955 | virtual int SetRenderPos(int x, int y, int w = 0, int h = 0); |
| 956 | |
| 957 | // NotifyTouch - Notify of a touch event |
| 958 | // Return 0 on success, >0 to ignore remainder of touch, and <0 on error |
| 959 | virtual int NotifyTouch(TOUCH_STATE state, int x, int y); |
| 960 | |
| 961 | // Notify of a variable change |
Vojtech Bocek | 0722056 | 2014-02-08 02:05:33 +0100 | [diff] [blame] | 962 | virtual int NotifyVarChange(const std::string& varName, const std::string& value); |
Vojtech Bocek | 8593234 | 2013-04-01 22:11:33 +0200 | [diff] [blame] | 963 | |
| 964 | // SetPageFocus - Notify when a page gains or loses focus |
| 965 | virtual void SetPageFocus(int inFocus); |
| 966 | |
| 967 | protected: |
| 968 | int measureText(const std::string& str); |
| 969 | int valueFromPct(float pct); |
| 970 | float pctFromValue(int value); |
| 971 | void loadValue(bool force = false); |
| 972 | |
| 973 | std::string mVariable; |
| 974 | int mMax; |
| 975 | int mMin; |
| 976 | int mValue; |
| 977 | char *mValueStr; |
| 978 | float mValuePct; |
| 979 | std::string mMaxStr; |
| 980 | std::string mMinStr; |
| 981 | Resource *mFont; |
| 982 | GUIText* mLabel; |
| 983 | int mLabelW; |
| 984 | COLOR mTextColor; |
| 985 | COLOR mLineColor; |
| 986 | COLOR mSliderColor; |
| 987 | bool mShowRange; |
| 988 | bool mShowCurr; |
| 989 | int mLineX; |
| 990 | int mLineY; |
| 991 | int mLineH; |
| 992 | int mLinePadding; |
| 993 | int mPadding; |
| 994 | int mSliderY; |
| 995 | int mSliderW; |
| 996 | int mSliderH; |
| 997 | bool mRendered; |
| 998 | int mFontHeight; |
| 999 | GUIAction *mAction; |
| 1000 | bool mChangeOnDrag; |
| 1001 | int lineW; |
| 1002 | }; |
| 1003 | |
Vojtech Bocek | 1fc30fc | 2014-01-29 18:37:19 +0100 | [diff] [blame] | 1004 | class MouseCursor : public RenderObject |
| 1005 | { |
| 1006 | public: |
| 1007 | MouseCursor(int posX, int posY); |
| 1008 | virtual ~MouseCursor(); |
| 1009 | |
| 1010 | virtual int Render(void); |
| 1011 | virtual int Update(void); |
| 1012 | virtual int SetRenderPos(int x, int y, int w = 0, int h = 0); |
| 1013 | |
| 1014 | void Move(int deltaX, int deltaY); |
| 1015 | void GetPos(int& x, int& y); |
| 1016 | void LoadData(xml_node<>* node); |
| 1017 | void ResetData(int resX, int resY); |
| 1018 | |
| 1019 | private: |
| 1020 | int m_resX; |
| 1021 | int m_resY; |
| 1022 | bool m_moved; |
| 1023 | float m_speedMultiplier; |
| 1024 | COLOR m_color; |
| 1025 | Resource *m_image; |
| 1026 | bool m_present; |
| 1027 | }; |
| 1028 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1029 | // Helper APIs |
| 1030 | bool LoadPlacement(xml_node<>* node, int* x, int* y, int* w = NULL, int* h = NULL, RenderObject::Placement* placement = NULL); |
| 1031 | |
| 1032 | #endif // _OBJECTS_HEADER |
| 1033 | |