basic form test

This commit is contained in:
zetaPRIME 2017-02-28 08:51:48 -05:00
parent 6ade2e8081
commit 10ac977cb1
4 changed files with 24 additions and 5 deletions

View File

@ -94,7 +94,7 @@ void Application::_mainLoop() {
forms.sort(Form::OrderedCompare); forms.sort(Form::OrderedCompare);
// reconstruct ui container heirarchy // reconstruct ui container heirarchy
bool otouch, otop; bool otouch = false, otop = false;
formTouchScreen->RemoveAll(); formTouchScreen->RemoveAll();
formTopScreen->RemoveAll(); formTopScreen->RemoveAll();

View File

@ -30,6 +30,8 @@ using starlight::ui::Form;
// STATIC MEMBERS // // STATIC MEMBERS //
//////////////////// ////////////////////
unsigned int Form::nextShowCounter = 0;
bool Form::OrderedCompare(std::shared_ptr<Form>& f1, std::shared_ptr<Form>& f2) { // acts as < operator bool Form::OrderedCompare(std::shared_ptr<Form>& f1, std::shared_ptr<Form>& f2) { // acts as < operator
if (!f1->IsVisible()) return true; if (!f1->IsVisible()) return true;
if (f1->priority < f2->priority) return true; if (f1->priority < f2->priority) return true;
@ -41,6 +43,13 @@ bool Form::OrderedCompare(std::shared_ptr<Form>& f1, std::shared_ptr<Form>& f2)
// INSTANCE MEMBERS // // INSTANCE MEMBERS //
////////////////////// //////////////////////
Form::Form(bool useDefaults) {
if (useDefaults) {
touchScreen = std::make_shared<UIContainer>(VRect(0, 0, 320, 240));
topScreen = std::make_shared<UIContainer>(VRect(0, 0, 400, 240));
}
}
void Form::Open() { void Form::Open() {
auto app = Application::Current(); auto app = Application::Current();
if (app == nullptr) return; if (app == nullptr) return;

View File

@ -24,7 +24,7 @@ namespace starlight {
open = 1 << 30 open = 1 << 30
}; };
typedef std::underlying_type<FormFlags>::type FormFlags_t; //typedef std::underlying_type<FormFlags>::type FormFlags_t;
class Form; class Form;
template<class F> template<class F>
@ -52,19 +52,20 @@ namespace starlight {
// INSTANCE MEMBERS // // INSTANCE MEMBERS //
////////////////////// //////////////////////
private: private:
unsigned int showCounter; unsigned int showCounter = 0;
protected: protected:
// //
public: public:
int priority; int priority = 0;
unsigned int flags; unsigned int flags = 0;
std::shared_ptr<UIContainer> touchScreen = nullptr; std::shared_ptr<UIContainer> touchScreen = nullptr;
std::shared_ptr<UIContainer> topScreen = nullptr; std::shared_ptr<UIContainer> topScreen = nullptr;
Form() { } Form() { }
Form(bool useDefaults);
virtual ~Form() { } virtual ~Form() { }
void Open(); void Open();

View File

@ -57,6 +57,15 @@ void Core::Init() {
label->SetFont("default.12"); label->SetFont("default.12");
btn.SetText("Clicked again!\nBunch of lines!\nNow testing scrollarea fling with some extra size!\n\n\nPotato.\nCalamari sandwich on rye with a side of octagonal pimento; a jar of butter?"); btn.SetText("Clicked again!\nBunch of lines!\nNow testing scrollarea fling with some extra size!\n\n\nPotato.\nCalamari sandwich on rye with a side of octagonal pimento; a jar of butter?");
btn.rect.size.y = 573; btn.rect.size.y = 573;
auto form = std::make_shared<sl::ui::Form>(true);
auto label = std::make_shared<sl::ui::Label>(VRect(0,0,320,0));
label->autoSizeV = true;
label->SetText("This is a form, coming in and nuking the non-form UI elements. Whoops.");
form->topScreen->Add(label);
form->Open();
form->Show();
if (!form->GetFlag(sl::ui::FormFlags::open)) btn.SetText("fuck.");
}; };
}; };
}; };