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