Conditional -> GUIObject and make all gui objects children of GUIObject

Signed-off-by: Vojtech Bocek <vbocek@gmail.com>

Change-Id: Ic0a7d6354dabe5919b83942f2f1aa0715625e522
This commit is contained in:
Vojtech Bocek
2014-02-07 23:58:09 +01:00
committed by Gerrit Code Review
parent f08ada8483
commit ede51c528e
19 changed files with 119 additions and 42 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ LOCAL_SRC_FILES := \
fileselector.cpp \
progressbar.cpp \
animation.cpp \
conditional.cpp \
object.cpp \
slider.cpp \
slidervalue.cpp \
listbox.cpp \
+1 -1
View File
@@ -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;
+7 -1
View File
@@ -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
+1 -1
View File
@@ -43,7 +43,7 @@ extern "C" {
#include "objects.hpp"
GUIButton::GUIButton(xml_node<>* node)
: Conditional(node)
: GUIObject(node)
{
xml_attribute<>* attr;
xml_node<>* child;
+1 -1
View File
@@ -26,7 +26,7 @@ extern "C" {
#include "objects.hpp"
GUICheckbox::GUICheckbox(xml_node<>* node)
: Conditional(node)
: GUIObject(node)
{
xml_attribute<>* attr;
xml_node<>* child;
+10 -1
View File
@@ -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)
+13 -1
View File
@@ -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, "");
+4 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -47,7 +47,7 @@ extern "C" {
#include "../data.hpp"
GUIInput::GUIInput(xml_node<>* node)
: Conditional(node)
: GUIObject(node)
{
xml_attribute<>* attr;
xml_node<>* child;
+1 -1
View File
@@ -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;
+13 -1
View File
@@ -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) {
+11 -7
View File
@@ -27,7 +27,7 @@ extern "C" {
#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 @@ Conditional::Conditional(xml_node<>* node)
}
}
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 @@ bool Conditional::IsConditionVariable(std::string var)
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 @@ bool Conditional::isConditionTrue()
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 @@ bool Conditional::isConditionTrue(Condition* condition)
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 @@ void Conditional::NotifyPageSet()
}
}
bool Conditional::isMounted(string vol)
bool GUIObject::isMounted(string vol)
{
FILE *fp;
char tmpOutput[255];
+19 -18
View File
@@ -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);
+13 -1
View File
@@ -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) {
+10 -1
View File
@@ -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())
+10 -1
View File
@@ -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)
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -26,7 +26,7 @@ extern "C" {
#include "objects.hpp"
GUIText::GUIText(xml_node<>* node)
: Conditional(node)
: GUIObject(node)
{
xml_attribute<>* attr;
xml_node<>* child;