From ede51c528e5cebc7f1930d5c9da541e7d11c0138 Mon Sep 17 00:00:00 2001 From: Vojtech Bocek Date: Fri, 7 Feb 2014 23:58:09 +0100 Subject: Conditional -> GUIObject and make all gui objects children of GUIObject Signed-off-by: Vojtech Bocek Change-Id: Ic0a7d6354dabe5919b83942f2f1aa0715625e522 --- gui/Android.mk | 2 +- gui/action.cpp | 2 +- gui/animation.cpp | 8 +- gui/button.cpp | 2 +- gui/checkbox.cpp | 2 +- gui/conditional.cpp | 204 ------------------------------------------------- gui/console.cpp | 11 ++- gui/fileselector.cpp | 14 +++- gui/fill.cpp | 5 +- gui/image.cpp | 2 +- gui/input.cpp | 2 +- gui/keyboard.cpp | 2 +- gui/listbox.cpp | 14 +++- gui/object.cpp | 208 ++++++++++++++++++++++++++++++++++++++++++++++++++ gui/objects.hpp | 37 ++++----- gui/partitionlist.cpp | 14 +++- gui/progressbar.cpp | 11 ++- gui/slider.cpp | 11 ++- gui/slidervalue.cpp | 2 +- gui/text.cpp | 2 +- 20 files changed, 316 insertions(+), 239 deletions(-) delete mode 100644 gui/conditional.cpp create mode 100644 gui/object.cpp (limited to 'gui') diff --git a/gui/Android.mk b/gui/Android.mk index 29d99f7f8..40b67d80a 100644 --- a/gui/Android.mk +++ b/gui/Android.mk @@ -15,7 +15,7 @@ LOCAL_SRC_FILES := \ fileselector.cpp \ progressbar.cpp \ animation.cpp \ - conditional.cpp \ + object.cpp \ slider.cpp \ slidervalue.cpp \ listbox.cpp \ diff --git a/gui/action.cpp b/gui/action.cpp index 9c785d169..951feb114 100644 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -67,7 +67,7 @@ extern blanktimer blankTimer; void curtainClose(void); GUIAction::GUIAction(xml_node<>* node) - : Conditional(node) + : GUIObject(node) { xml_node<>* child; xml_node<>* actions; diff --git a/gui/animation.cpp b/gui/animation.cpp index 8c922786d..771e1c116 100644 --- a/gui/animation.cpp +++ b/gui/animation.cpp @@ -26,7 +26,7 @@ extern "C" { #include "objects.hpp" -GUIAnimation::GUIAnimation(xml_node<>* node) +GUIAnimation::GUIAnimation(xml_node<>* node) : GUIObject(node) { xml_node<>* child; xml_attribute<>* attr; @@ -101,6 +101,9 @@ GUIAnimation::GUIAnimation(xml_node<>* node) int GUIAnimation::Render(void) { + if(!isConditionTrue()) + return 0; + if (!mAnimation || !mAnimation->GetResource(mFrame)) return -1; gr_blit(mAnimation->GetResource(mFrame), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY); @@ -109,6 +112,9 @@ int GUIAnimation::Render(void) int GUIAnimation::Update(void) { + if(!isConditionTrue()) + return 0; + if (!mAnimation) return -1; // Handle the "end-of-animation" state diff --git a/gui/button.cpp b/gui/button.cpp index b14e6754c..097bf7189 100644 --- a/gui/button.cpp +++ b/gui/button.cpp @@ -43,7 +43,7 @@ extern "C" { #include "objects.hpp" GUIButton::GUIButton(xml_node<>* node) - : Conditional(node) + : GUIObject(node) { xml_attribute<>* attr; xml_node<>* child; diff --git a/gui/checkbox.cpp b/gui/checkbox.cpp index 8739c9c25..fe5f557bb 100644 --- a/gui/checkbox.cpp +++ b/gui/checkbox.cpp @@ -26,7 +26,7 @@ extern "C" { #include "objects.hpp" GUICheckbox::GUICheckbox(xml_node<>* node) - : Conditional(node) + : GUIObject(node) { xml_attribute<>* attr; xml_node<>* child; diff --git a/gui/conditional.cpp b/gui/conditional.cpp deleted file mode 100644 index 5ea8d176c..000000000 --- a/gui/conditional.cpp +++ /dev/null @@ -1,204 +0,0 @@ -// checkbox.cpp - GUICheckbox object - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -extern "C" { -#include "../twcommon.h" -#include "../minuitwrp/minui.h" -#include "../variables.h" -} - -#include "rapidxml.hpp" -#include "objects.hpp" -#include "../data.hpp" - -Conditional::Conditional(xml_node<>* node) -{ - // Break out early, it's too hard to check if valid every step - if (!node) return; - - // First, get the action - xml_node<>* condition = node->first_node("conditions"); - if (condition) condition = condition->first_node("condition"); - else condition = node->first_node("condition"); - - if (!condition) return; - - while (condition) - { - Condition cond; - - cond.mCompareOp = "="; - - xml_attribute<>* attr; - attr = condition->first_attribute("var1"); - if (attr) cond.mVar1 = attr->value(); - - attr = condition->first_attribute("op"); - if (attr) cond.mCompareOp = attr->value(); - - attr = condition->first_attribute("var2"); - if (attr) cond.mVar2 = attr->value(); - - mConditions.push_back(cond); - - condition = condition->next_sibling("condition"); - } -} - -bool Conditional::IsConditionVariable(std::string var) -{ - std::vector::iterator iter; - for (iter = mConditions.begin(); iter != mConditions.end(); iter++) - { - if (iter->mVar1 == var) - return true; - } - return false; -} - -bool Conditional::isConditionTrue() -{ - std::vector::iterator iter; - for (iter = mConditions.begin(); iter != mConditions.end(); iter++) - { - if (!isConditionTrue(&(*iter))) - return false; - } - return true; -} - -bool Conditional::isConditionTrue(Condition* condition) -{ - // This is used to hold the proper value of "true" based on the '!' NOT flag - bool bTrue = true; - - if (condition->mVar1.empty()) - return bTrue; - - if (!condition->mCompareOp.empty() && condition->mCompareOp[0] == '!') - bTrue = false; - - if (condition->mVar2.empty() && condition->mCompareOp != "modified") - { - if (!DataManager::GetStrValue(condition->mVar1).empty()) - return bTrue; - - return !bTrue; - } - - string var1, var2; - if (DataManager::GetValue(condition->mVar1, var1)) - var1 = condition->mVar1; - if (DataManager::GetValue(condition->mVar2, var2)) - var2 = condition->mVar2; - - // This is a special case, we stat the file and that determines our result - if (var1 == "fileexists") - { - struct stat st; - if (stat(var2.c_str(), &st) == 0) - var2 = var1; - else - var2 = "FAILED"; - } - if (var1 == "mounted") - { - if (isMounted(condition->mVar2)) - var2 = var1; - else - var2 = "FAILED"; - } - - if (condition->mCompareOp.find('=') != string::npos && var1 == var2) - return bTrue; - - if (condition->mCompareOp.find('>') != string::npos && (atof(var1.c_str()) > atof(var2.c_str()))) - return bTrue; - - if (condition->mCompareOp.find('<') != string::npos && (atof(var1.c_str()) < atof(var2.c_str()))) - return bTrue; - - if (condition->mCompareOp == "modified") - { - // This is a hack to allow areas to reset the default value - if (var1.empty()) - { - condition->mLastVal = var1; - return !bTrue; - } - - if (var1 != condition->mLastVal) - return bTrue; - } - - return !bTrue; -} - -bool Conditional::isConditionValid() -{ - return !mConditions.empty(); -} - -void Conditional::NotifyPageSet() -{ - std::vector::iterator iter; - for (iter = mConditions.begin(); iter != mConditions.end(); iter++) - { - if (iter->mCompareOp == "modified") - { - string val; - - // If this fails, val will not be set, which is perfect - if (DataManager::GetValue(iter->mVar1, val)) - { - DataManager::SetValue(iter->mVar1, ""); - DataManager::GetValue(iter->mVar1, val); - } - iter->mLastVal = val; - } - } -} - -bool Conditional::isMounted(string vol) -{ - FILE *fp; - char tmpOutput[255]; - - if (strcmp(vol.c_str(), "EXTERNAL") == 0) - DataManager::GetValue(TW_EXTERNAL_MOUNT, vol); - else if (strcmp(vol.c_str(), "INTERNAL") == 0) - DataManager::GetValue(TW_INTERNAL_MOUNT, vol); - fp = fopen("/proc/mounts", "rt"); - while (fgets(tmpOutput,255,fp) != NULL) - { - char* mnt = tmpOutput; - while (*mnt > 32) mnt++; - while (*mnt > 0 && *mnt <= 32) mnt++; - char* pos = mnt; - while (*pos > 32) pos++; - *pos = 0; - if (vol == mnt) - { - fclose(fp); - return true; - } - } - fclose(fp); - return false; -} diff --git a/gui/console.cpp b/gui/console.cpp index 517a7c293..5d0ed3ec3 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -103,7 +103,7 @@ extern "C" void gui_print_overwrite(const char *fmt, ...) return; } -GUIConsole::GUIConsole(xml_node<>* node) +GUIConsole::GUIConsole(xml_node<>* node) : GUIObject(node) { xml_attribute<>* attr; xml_node<>* child; @@ -242,6 +242,9 @@ int GUIConsole::RenderConsole(void) int GUIConsole::Render(void) { + if(!isConditionTrue()) + return 0; + if (mSlideout && mSlideoutState == hidden) return RenderSlideout(); @@ -250,6 +253,9 @@ int GUIConsole::Render(void) int GUIConsole::Update(void) { + if(!isConditionTrue()) + return 0; + if (mSlideout && mSlideoutState != visible) { if (mSlideoutState == hidden) @@ -326,6 +332,9 @@ int GUIConsole::IsInRegion(int x, int y) // Return 0 on success, >0 to ignore remainder of touch, and <0 on error int GUIConsole::NotifyTouch(TOUCH_STATE state, int x, int y) { + if(!isConditionTrue()) + return -1; + if (mSlideout && mSlideoutState == hidden) { if (state == TOUCH_START) diff --git a/gui/fileselector.cpp b/gui/fileselector.cpp index 1c2a8ccf0..484bcff11 100644 --- a/gui/fileselector.cpp +++ b/gui/fileselector.cpp @@ -55,7 +55,7 @@ extern "C" { int GUIFileSelector::mSortOrder = 0; -GUIFileSelector::GUIFileSelector(xml_node<>* node) +GUIFileSelector::GUIFileSelector(xml_node<>* node) : GUIObject(node) { xml_attribute<>* attr; xml_node<>* child; @@ -392,6 +392,9 @@ GUIFileSelector::~GUIFileSelector() int GUIFileSelector::Render(void) { + if(!isConditionTrue()) + return 0; + // First step, fill background gr_color(mBackgroundColor.red, mBackgroundColor.green, mBackgroundColor.blue, 255); gr_fill(mRenderX, mRenderY + mHeaderH, mRenderW, mRenderH - mHeaderH); @@ -577,6 +580,9 @@ int GUIFileSelector::Render(void) int GUIFileSelector::Update(void) { + if(!isConditionTrue()) + return 0; + if (!mHeaderIsStatic) { std::string newValue = gui_parse_text(mHeaderText); if (mLastValue != newValue) { @@ -659,6 +665,9 @@ int GUIFileSelector::GetSelection(int x, int y) int GUIFileSelector::NotifyTouch(TOUCH_STATE state, int x, int y) { + if(!isConditionTrue()) + return -1; + static int lastY = 0, last2Y = 0, fastScroll = 0; int selection = 0; @@ -858,6 +867,9 @@ int GUIFileSelector::NotifyTouch(TOUCH_STATE state, int x, int y) int GUIFileSelector::NotifyVarChange(std::string varName, std::string value) { + if(!isConditionTrue()) + return 0; + if (varName.empty()) { // Always clear the data variable so we know to use it DataManager::SetValue(mVariable, ""); diff --git a/gui/fill.cpp b/gui/fill.cpp index ad1f4e075..1ddefaa9b 100644 --- a/gui/fill.cpp +++ b/gui/fill.cpp @@ -25,7 +25,7 @@ extern "C" { #include "rapidxml.hpp" #include "objects.hpp" -GUIFill::GUIFill(xml_node<>* node) +GUIFill::GUIFill(xml_node<>* node) : GUIObject(node) { xml_attribute<>* attr; xml_node<>* child; @@ -50,6 +50,9 @@ GUIFill::GUIFill(xml_node<>* node) int GUIFill::Render(void) { + if(!isConditionTrue()) + return 0; + gr_color(mColor.red, mColor.green, mColor.blue, mColor.alpha); gr_fill(mRenderX, mRenderY, mRenderW, mRenderH); return 0; diff --git a/gui/image.cpp b/gui/image.cpp index 31d9418d3..2cf3b68af 100644 --- a/gui/image.cpp +++ b/gui/image.cpp @@ -25,7 +25,7 @@ extern "C" { #include "rapidxml.hpp" #include "objects.hpp" -GUIImage::GUIImage(xml_node<>* node) : Conditional(node) +GUIImage::GUIImage(xml_node<>* node) : GUIObject(node) { xml_attribute<>* attr; xml_node<>* child; diff --git a/gui/input.cpp b/gui/input.cpp index 4fd1d0ecf..e4020745c 100644 --- a/gui/input.cpp +++ b/gui/input.cpp @@ -47,7 +47,7 @@ extern "C" { #include "../data.hpp" GUIInput::GUIInput(xml_node<>* node) - : Conditional(node) + : GUIObject(node) { xml_attribute<>* attr; xml_node<>* child; diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp index 36106c7c1..f08d71488 100644 --- a/gui/keyboard.cpp +++ b/gui/keyboard.cpp @@ -43,7 +43,7 @@ extern "C" { #include "objects.hpp" GUIKeyboard::GUIKeyboard(xml_node<>* node) - : Conditional(node) + : GUIObject(node) { int layoutindex, rowindex, keyindex, Xindex, Yindex, keyHeight = 0, keyWidth = 0; rowY = colX = -1; diff --git a/gui/listbox.cpp b/gui/listbox.cpp index 626cbacf4..99e2dedf1 100644 --- a/gui/listbox.cpp +++ b/gui/listbox.cpp @@ -51,7 +51,7 @@ extern "C" { #define SCROLLING_FLOOR 10 #define SCROLLING_MULTIPLIER 6 -GUIListBox::GUIListBox(xml_node<>* node) +GUIListBox::GUIListBox(xml_node<>* node) : GUIObject(node) { xml_attribute<>* attr; xml_node<>* child; @@ -352,6 +352,9 @@ GUIListBox::~GUIListBox() int GUIListBox::Render(void) { + if(!isConditionTrue()) + return 0; + // First step, fill background gr_color(mBackgroundColor.red, mBackgroundColor.green, mBackgroundColor.blue, 255); gr_fill(mRenderX, mRenderY + mHeaderH, mRenderW, mRenderH - mHeaderH); @@ -522,6 +525,9 @@ int GUIListBox::Render(void) int GUIListBox::Update(void) { + if(!isConditionTrue()) + return 0; + if (!mHeaderIsStatic) { std::string newValue = gui_parse_text(mHeaderText); if (mLastValue != newValue) { @@ -602,6 +608,9 @@ int GUIListBox::GetSelection(int x, int y) int GUIListBox::NotifyTouch(TOUCH_STATE state, int x, int y) { + if(!isConditionTrue()) + return -1; + static int lastY = 0, last2Y = 0, fastScroll = 0; int selection = 0; @@ -753,6 +762,9 @@ int GUIListBox::NotifyTouch(TOUCH_STATE state, int x, int y) int GUIListBox::NotifyVarChange(std::string varName, std::string value) { + if(!isConditionTrue()) + return 0; + if (!mHeaderIsStatic) { std::string newValue = gui_parse_text(mHeaderText); if (mLastValue != newValue) { diff --git a/gui/object.cpp b/gui/object.cpp new file mode 100644 index 000000000..b6010d778 --- /dev/null +++ b/gui/object.cpp @@ -0,0 +1,208 @@ +// checkbox.cpp - GUICheckbox object + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +extern "C" { +#include "../twcommon.h" +#include "../minuitwrp/minui.h" +#include "../variables.h" +} + +#include "rapidxml.hpp" +#include "objects.hpp" +#include "../data.hpp" + +GUIObject::GUIObject(xml_node<>* node) +{ + // Break out early, it's too hard to check if valid every step + if (!node) return; + + // First, get the action + xml_node<>* condition = node->first_node("conditions"); + if (condition) condition = condition->first_node("condition"); + else condition = node->first_node("condition"); + + if (!condition) return; + + while (condition) + { + Condition cond; + + cond.mCompareOp = "="; + + xml_attribute<>* attr; + attr = condition->first_attribute("var1"); + if (attr) cond.mVar1 = attr->value(); + + attr = condition->first_attribute("op"); + if (attr) cond.mCompareOp = attr->value(); + + attr = condition->first_attribute("var2"); + if (attr) cond.mVar2 = attr->value(); + + mConditions.push_back(cond); + + condition = condition->next_sibling("condition"); + } +} + +GUIObject::~GUIObject() +{ +} + +bool GUIObject::IsConditionVariable(std::string var) +{ + std::vector::iterator iter; + for (iter = mConditions.begin(); iter != mConditions.end(); iter++) + { + if (iter->mVar1 == var) + return true; + } + return false; +} + +bool GUIObject::isConditionTrue() +{ + std::vector::iterator iter; + for (iter = mConditions.begin(); iter != mConditions.end(); iter++) + { + if (!isConditionTrue(&(*iter))) + return false; + } + return true; +} + +bool GUIObject::isConditionTrue(Condition* condition) +{ + // This is used to hold the proper value of "true" based on the '!' NOT flag + bool bTrue = true; + + if (condition->mVar1.empty()) + return bTrue; + + if (!condition->mCompareOp.empty() && condition->mCompareOp[0] == '!') + bTrue = false; + + if (condition->mVar2.empty() && condition->mCompareOp != "modified") + { + if (!DataManager::GetStrValue(condition->mVar1).empty()) + return bTrue; + + return !bTrue; + } + + string var1, var2; + if (DataManager::GetValue(condition->mVar1, var1)) + var1 = condition->mVar1; + if (DataManager::GetValue(condition->mVar2, var2)) + var2 = condition->mVar2; + + // This is a special case, we stat the file and that determines our result + if (var1 == "fileexists") + { + struct stat st; + if (stat(var2.c_str(), &st) == 0) + var2 = var1; + else + var2 = "FAILED"; + } + if (var1 == "mounted") + { + if (isMounted(condition->mVar2)) + var2 = var1; + else + var2 = "FAILED"; + } + + if (condition->mCompareOp.find('=') != string::npos && var1 == var2) + return bTrue; + + if (condition->mCompareOp.find('>') != string::npos && (atof(var1.c_str()) > atof(var2.c_str()))) + return bTrue; + + if (condition->mCompareOp.find('<') != string::npos && (atof(var1.c_str()) < atof(var2.c_str()))) + return bTrue; + + if (condition->mCompareOp == "modified") + { + // This is a hack to allow areas to reset the default value + if (var1.empty()) + { + condition->mLastVal = var1; + return !bTrue; + } + + if (var1 != condition->mLastVal) + return bTrue; + } + + return !bTrue; +} + +bool GUIObject::isConditionValid() +{ + return !mConditions.empty(); +} + +void GUIObject::NotifyPageSet() +{ + std::vector::iterator iter; + for (iter = mConditions.begin(); iter != mConditions.end(); iter++) + { + if (iter->mCompareOp == "modified") + { + string val; + + // If this fails, val will not be set, which is perfect + if (DataManager::GetValue(iter->mVar1, val)) + { + DataManager::SetValue(iter->mVar1, ""); + DataManager::GetValue(iter->mVar1, val); + } + iter->mLastVal = val; + } + } +} + +bool GUIObject::isMounted(string vol) +{ + FILE *fp; + char tmpOutput[255]; + + if (strcmp(vol.c_str(), "EXTERNAL") == 0) + DataManager::GetValue(TW_EXTERNAL_MOUNT, vol); + else if (strcmp(vol.c_str(), "INTERNAL") == 0) + DataManager::GetValue(TW_INTERNAL_MOUNT, vol); + fp = fopen("/proc/mounts", "rt"); + while (fgets(tmpOutput,255,fp) != NULL) + { + char* mnt = tmpOutput; + while (*mnt > 32) mnt++; + while (*mnt > 0 && *mnt <= 32) mnt++; + char* pos = mnt; + while (*pos > 32) pos++; + *pos = 0; + if (vol == mnt) + { + fclose(fp); + return true; + } + } + fclose(fp); + return false; +} diff --git a/gui/objects.hpp b/gui/objects.hpp index e8110b016..42dfb1f09 100644 --- a/gui/objects.hpp +++ b/gui/objects.hpp @@ -122,10 +122,11 @@ protected: int mActionX, mActionY, mActionW, mActionH; }; -class Conditional +class GUIObject { public: - Conditional(xml_node<>* node); + GUIObject(xml_node<>* node); + virtual ~GUIObject(); public: bool IsConditionVariable(std::string var); @@ -169,7 +170,7 @@ protected: // Derived Objects // GUIText - Used for static text -class GUIText : public RenderObject, public ActionObject, public Conditional +class GUIText : public GUIObject, public RenderObject, public ActionObject { public: // w and h may be ignored, in which case, no bounding box is applied @@ -217,7 +218,7 @@ protected: }; // GUIImage - Used for static image -class GUIImage : public RenderObject, public Conditional +class GUIImage : public GUIObject, public RenderObject { public: GUIImage(xml_node<>* node); @@ -240,7 +241,7 @@ protected: }; // GUIFill - Used for fill colors -class GUIFill : public RenderObject +class GUIFill : public GUIObject, public RenderObject { public: GUIFill(xml_node<>* node); @@ -255,7 +256,7 @@ protected: }; // GUIAction - Used for standard actions -class GUIAction : public ActionObject, public Conditional +class GUIAction : public GUIObject, public ActionObject { public: GUIAction(xml_node<>* node); @@ -289,7 +290,7 @@ protected: time_t Start; }; -class GUIConsole : public RenderObject, public ActionObject +class GUIConsole : public GUIObject, public RenderObject, public ActionObject { public: GUIConsole(xml_node<>* node); @@ -347,7 +348,7 @@ protected: virtual int RenderConsole(void); }; -class GUIButton : public RenderObject, public ActionObject, public Conditional +class GUIButton : public GUIObject, public RenderObject, public ActionObject { public: GUIButton(xml_node<>* node); @@ -386,7 +387,7 @@ protected: Placement TextPlacement; }; -class GUICheckbox: public RenderObject, public ActionObject, public Conditional +class GUICheckbox: public GUIObject, public RenderObject, public ActionObject { public: GUICheckbox(xml_node<>* node); @@ -420,7 +421,7 @@ protected: std::string mVarName; }; -class GUIFileSelector : public RenderObject, public ActionObject +class GUIFileSelector : public GUIObject, public RenderObject, public ActionObject { public: GUIFileSelector(xml_node<>* node); @@ -524,7 +525,7 @@ protected: bool updateFileList; }; -class GUIListBox : public RenderObject, public ActionObject +class GUIListBox : public GUIObject, public RenderObject, public ActionObject { public: GUIListBox(xml_node<>* node); @@ -612,7 +613,7 @@ protected: int touchDebounce; }; -class GUIPartitionList : public RenderObject, public ActionObject +class GUIPartitionList : public GUIObject, public RenderObject, public ActionObject { public: GUIPartitionList(xml_node<>* node); @@ -697,7 +698,7 @@ protected: }; // GUIAnimation - Used for animations -class GUIAnimation : public RenderObject +class GUIAnimation : public GUIObject, public RenderObject { public: GUIAnimation(xml_node<>* node); @@ -720,7 +721,7 @@ protected: int mUpdateCount; }; -class GUIProgressBar : public RenderObject, public ActionObject +class GUIProgressBar : public GUIObject, public RenderObject, public ActionObject { public: GUIProgressBar(xml_node<>* node); @@ -753,7 +754,7 @@ protected: virtual int RenderInternal(void); // Does the actual render }; -class GUISlider : public RenderObject, public ActionObject +class GUISlider : public GUIObject, public RenderObject, public ActionObject { public: GUISlider(xml_node<>* node); @@ -798,7 +799,7 @@ protected: #define KEYBOARD_SPECIAL_KEYS 245 #define KEYBOARD_BACKSPACE 8 -class GUIKeyboard : public RenderObject, public ActionObject, public Conditional +class GUIKeyboard : public GUIObject, public RenderObject, public ActionObject { public: GUIKeyboard(xml_node<>* node); @@ -836,7 +837,7 @@ protected: }; // GUIInput - Used for keyboard input -class GUIInput : public RenderObject, public ActionObject, public Conditional, public InputObject +class GUIInput : public GUIObject, public RenderObject, public ActionObject, public InputObject { public: // w and h may be ignored, in which case, no bounding box is applied @@ -912,7 +913,7 @@ public: virtual int KeyRepeat(void); }; -class GUISliderValue: public RenderObject, public ActionObject, public Conditional +class GUISliderValue: public GUIObject, public RenderObject, public ActionObject { public: GUISliderValue(xml_node<>* node); diff --git a/gui/partitionlist.cpp b/gui/partitionlist.cpp index 35bf702bb..cb9011f30 100644 --- a/gui/partitionlist.cpp +++ b/gui/partitionlist.cpp @@ -52,7 +52,7 @@ extern "C" { #define SCROLLING_FLOOR 10 #define SCROLLING_MULTIPLIER 6 -GUIPartitionList::GUIPartitionList(xml_node<>* node) +GUIPartitionList::GUIPartitionList(xml_node<>* node) : GUIObject(node) { xml_attribute<>* attr; xml_node<>* child; @@ -344,6 +344,9 @@ GUIPartitionList::~GUIPartitionList() int GUIPartitionList::Render(void) { + if(!isConditionTrue()) + return 0; + // First step, fill background gr_color(mBackgroundColor.red, mBackgroundColor.green, mBackgroundColor.blue, 255); gr_fill(mRenderX, mRenderY + mHeaderH, mRenderW, mRenderH - mHeaderH); @@ -525,6 +528,9 @@ int GUIPartitionList::Render(void) int GUIPartitionList::Update(void) { + if(!isConditionTrue()) + return 0; + if (!mHeaderIsStatic) { std::string newValue = gui_parse_text(mHeaderText); if (mLastValue != newValue) { @@ -619,6 +625,9 @@ int GUIPartitionList::GetSelection(int x, int y) int GUIPartitionList::NotifyTouch(TOUCH_STATE state, int x, int y) { + if(!isConditionTrue()) + return -1; + static int lastY = 0, last2Y = 0; int selection = 0; @@ -820,6 +829,9 @@ int GUIPartitionList::NotifyTouch(TOUCH_STATE state, int x, int y) int GUIPartitionList::NotifyVarChange(std::string varName, std::string value) { + if(!isConditionTrue()) + return 0; + if (!mHeaderIsStatic) { std::string newValue = gui_parse_text(mHeaderText); if (mLastValue != newValue) { diff --git a/gui/progressbar.cpp b/gui/progressbar.cpp index d53fdc19f..9c80eb40a 100644 --- a/gui/progressbar.cpp +++ b/gui/progressbar.cpp @@ -25,7 +25,7 @@ extern "C" { #include "rapidxml.hpp" #include "objects.hpp" -GUIProgressBar::GUIProgressBar(xml_node<>* node) +GUIProgressBar::GUIProgressBar(xml_node<>* node) : GUIObject(node) { xml_attribute<>* attr; xml_node<>* child; @@ -82,6 +82,9 @@ GUIProgressBar::GUIProgressBar(xml_node<>* node) int GUIProgressBar::Render(void) { + if(!isConditionTrue()) + return 0; + // This handles making sure timing updates occur Update(); return RenderInternal(); @@ -102,6 +105,9 @@ int GUIProgressBar::RenderInternal(void) int GUIProgressBar::Update(void) { + if(!isConditionTrue()) + return 0; + std::string str; int min, max, cur, pos; @@ -168,6 +174,9 @@ int GUIProgressBar::Update(void) int GUIProgressBar::NotifyVarChange(std::string varName, std::string value) { + if(!isConditionTrue()) + return 0; + static int nextPush = 0; if (varName.empty()) diff --git a/gui/slider.cpp b/gui/slider.cpp index af0c542de..692676561 100644 --- a/gui/slider.cpp +++ b/gui/slider.cpp @@ -27,7 +27,7 @@ extern "C" { #include "rapidxml.hpp" #include "objects.hpp" -GUISlider::GUISlider(xml_node<>* node) +GUISlider::GUISlider(xml_node<>* node) : GUIObject(node) { xml_attribute<>* attr; xml_node<>* child; @@ -93,6 +93,9 @@ GUISlider::~GUISlider() int GUISlider::Render(void) { + if(!isConditionTrue()) + return 0; + if (!sSlider || !sSlider->GetResource()) return -1; @@ -113,6 +116,9 @@ int GUISlider::Render(void) int GUISlider::Update(void) { + if(!isConditionTrue()) + return 0; + if (sUpdate) return 2; return 0; @@ -120,6 +126,9 @@ int GUISlider::Update(void) int GUISlider::NotifyTouch(TOUCH_STATE state, int x, int y) { + if(!isConditionTrue()) + return -1; + static bool dragging = false; switch (state) diff --git a/gui/slidervalue.cpp b/gui/slidervalue.cpp index d369aceb9..c83456b9e 100644 --- a/gui/slidervalue.cpp +++ b/gui/slidervalue.cpp @@ -25,7 +25,7 @@ extern "C" { #include "rapidxml.hpp" #include "objects.hpp" -GUISliderValue::GUISliderValue(xml_node<>* node) : Conditional(node) +GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node) { xml_attribute<>* attr; xml_node<>* child; diff --git a/gui/text.cpp b/gui/text.cpp index 7eb6c18b4..715880b62 100644 --- a/gui/text.cpp +++ b/gui/text.cpp @@ -26,7 +26,7 @@ extern "C" { #include "objects.hpp" GUIText::GUIText(xml_node<>* node) - : Conditional(node) + : GUIObject(node) { xml_attribute<>* attr; xml_node<>* child; -- cgit v1.2.3