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