Conditional -> GUIObject and make all gui objects children of GUIObject
Signed-off-by: Vojtech Bocek <vbocek@gmail.com>
Change-Id: Ic0a7d6354dabe5919b83942f2f1aa0715625e522
diff --git a/gui/Android.mk b/gui/Android.mk
index 29d99f7..40b67d8 100644
--- a/gui/Android.mk
+++ b/gui/Android.mk
@@ -15,7 +15,7 @@
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 9c785d1..951feb1 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -67,7 +67,7 @@
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 8c92278..771e1c1 100644
--- a/gui/animation.cpp
+++ b/gui/animation.cpp
@@ -26,7 +26,7 @@
#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 @@
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::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 b14e675..097bf71 100644
--- a/gui/button.cpp
+++ b/gui/button.cpp
@@ -43,7 +43,7 @@
#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 8739c9c..fe5f557 100644
--- a/gui/checkbox.cpp
+++ b/gui/checkbox.cpp
@@ -26,7 +26,7 @@
#include "objects.hpp"
GUICheckbox::GUICheckbox(xml_node<>* node)
- : Conditional(node)
+ : GUIObject(node)
{
xml_attribute<>* attr;
xml_node<>* child;
diff --git a/gui/console.cpp b/gui/console.cpp
index 517a7c2..5d0ed3e 100644
--- a/gui/console.cpp
+++ b/gui/console.cpp
@@ -103,7 +103,7 @@
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::Render(void)
{
+ if(!isConditionTrue())
+ return 0;
+
if (mSlideout && mSlideoutState == hidden)
return RenderSlideout();
@@ -250,6 +253,9 @@
int GUIConsole::Update(void)
{
+ if(!isConditionTrue())
+ return 0;
+
if (mSlideout && mSlideoutState != visible)
{
if (mSlideoutState == hidden)
@@ -326,6 +332,9 @@
// 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 1c2a8cc..484bcff 100644
--- a/gui/fileselector.cpp
+++ b/gui/fileselector.cpp
@@ -55,7 +55,7 @@
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 @@
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::Update(void)
{
+ if(!isConditionTrue())
+ return 0;
+
if (!mHeaderIsStatic) {
std::string newValue = gui_parse_text(mHeaderText);
if (mLastValue != newValue) {
@@ -659,6 +665,9 @@
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::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 ad1f4e0..1ddefaa 100644
--- a/gui/fill.cpp
+++ b/gui/fill.cpp
@@ -25,7 +25,7 @@
#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 @@
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 31d9418..2cf3b68 100644
--- a/gui/image.cpp
+++ b/gui/image.cpp
@@ -25,7 +25,7 @@
#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 4fd1d0e..e402074 100644
--- a/gui/input.cpp
+++ b/gui/input.cpp
@@ -47,7 +47,7 @@
#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 36106c7..f08d714 100644
--- a/gui/keyboard.cpp
+++ b/gui/keyboard.cpp
@@ -43,7 +43,7 @@
#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 626cbac..99e2ded 100644
--- a/gui/listbox.cpp
+++ b/gui/listbox.cpp
@@ -51,7 +51,7 @@
#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 @@
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::Update(void)
{
+ if(!isConditionTrue())
+ return 0;
+
if (!mHeaderIsStatic) {
std::string newValue = gui_parse_text(mHeaderText);
if (mLastValue != newValue) {
@@ -602,6 +608,9 @@
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::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/conditional.cpp b/gui/object.cpp
similarity index 92%
rename from gui/conditional.cpp
rename to gui/object.cpp
index 5ea8d17..b6010d7 100644
--- a/gui/conditional.cpp
+++ b/gui/object.cpp
@@ -27,7 +27,7 @@
#include "objects.hpp"
#include "../data.hpp"
-Conditional::Conditional(xml_node<>* node)
+GUIObject::GUIObject(xml_node<>* node)
{
// Break out early, it's too hard to check if valid every step
if (!node) return;
@@ -61,7 +61,11 @@
}
}
-bool Conditional::IsConditionVariable(std::string var)
+GUIObject::~GUIObject()
+{
+}
+
+bool GUIObject::IsConditionVariable(std::string var)
{
std::vector<Condition>::iterator iter;
for (iter = mConditions.begin(); iter != mConditions.end(); iter++)
@@ -72,7 +76,7 @@
return false;
}
-bool Conditional::isConditionTrue()
+bool GUIObject::isConditionTrue()
{
std::vector<Condition>::iterator iter;
for (iter = mConditions.begin(); iter != mConditions.end(); iter++)
@@ -83,7 +87,7 @@
return true;
}
-bool Conditional::isConditionTrue(Condition* condition)
+bool GUIObject::isConditionTrue(Condition* condition)
{
// This is used to hold the proper value of "true" based on the '!' NOT flag
bool bTrue = true;
@@ -150,12 +154,12 @@
return !bTrue;
}
-bool Conditional::isConditionValid()
+bool GUIObject::isConditionValid()
{
return !mConditions.empty();
}
-void Conditional::NotifyPageSet()
+void GUIObject::NotifyPageSet()
{
std::vector<Condition>::iterator iter;
for (iter = mConditions.begin(); iter != mConditions.end(); iter++)
@@ -175,7 +179,7 @@
}
}
-bool Conditional::isMounted(string vol)
+bool GUIObject::isMounted(string vol)
{
FILE *fp;
char tmpOutput[255];
diff --git a/gui/objects.hpp b/gui/objects.hpp
index e8110b0..42dfb1f 100644
--- a/gui/objects.hpp
+++ b/gui/objects.hpp
@@ -122,10 +122,11 @@
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 @@
// 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 @@
};
// 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 @@
};
// GUIFill - Used for fill colors
-class GUIFill : public RenderObject
+class GUIFill : public GUIObject, public RenderObject
{
public:
GUIFill(xml_node<>* node);
@@ -255,7 +256,7 @@
};
// 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
};
// GUIAnimation - Used for animations
-class GUIAnimation : public RenderObject
+class GUIAnimation : public GUIObject, public RenderObject
{
public:
GUIAnimation(xml_node<>* node);
@@ -720,7 +721,7 @@
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 @@
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 @@
#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 @@
};
// 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 @@
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 35bf702..cb9011f 100644
--- a/gui/partitionlist.cpp
+++ b/gui/partitionlist.cpp
@@ -52,7 +52,7 @@
#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 @@
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::Update(void)
{
+ if(!isConditionTrue())
+ return 0;
+
if (!mHeaderIsStatic) {
std::string newValue = gui_parse_text(mHeaderText);
if (mLastValue != newValue) {
@@ -619,6 +625,9 @@
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::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 d53fdc1..9c80eb4 100644
--- a/gui/progressbar.cpp
+++ b/gui/progressbar.cpp
@@ -25,7 +25,7 @@
#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 @@
int GUIProgressBar::Render(void)
{
+ if(!isConditionTrue())
+ return 0;
+
// This handles making sure timing updates occur
Update();
return RenderInternal();
@@ -102,6 +105,9 @@
int GUIProgressBar::Update(void)
{
+ if(!isConditionTrue())
+ return 0;
+
std::string str;
int min, max, cur, pos;
@@ -168,6 +174,9 @@
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 af0c542..6926765 100644
--- a/gui/slider.cpp
+++ b/gui/slider.cpp
@@ -27,7 +27,7 @@
#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 @@
int GUISlider::Render(void)
{
+ if(!isConditionTrue())
+ return 0;
+
if (!sSlider || !sSlider->GetResource())
return -1;
@@ -113,6 +116,9 @@
int GUISlider::Update(void)
{
+ if(!isConditionTrue())
+ return 0;
+
if (sUpdate)
return 2;
return 0;
@@ -120,6 +126,9 @@
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 d369ace..c83456b 100644
--- a/gui/slidervalue.cpp
+++ b/gui/slidervalue.cpp
@@ -25,7 +25,7 @@
#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 7eb6c18..715880b 100644
--- a/gui/text.cpp
+++ b/gui/text.cpp
@@ -26,7 +26,7 @@
#include "objects.hpp"
GUIText::GUIText(xml_node<>* node)
- : Conditional(node)
+ : GUIObject(node)
{
xml_attribute<>* attr;
xml_node<>* child;