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