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