-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
80 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
#include "eurekaui/context.h" | ||
|
||
namespace EurekaUI | ||
{ | ||
Context::Context() | ||
:mRoot(nullptr) | ||
{ | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "eurekaui/element.h" | ||
|
||
namespace EurekaUI | ||
{ | ||
Element::Element(Element *parent) | ||
:mParent(parent) | ||
{ | ||
} | ||
|
||
Element::~Element() | ||
{ | ||
// Free memory; | ||
for(auto child:mChildren) | ||
{ | ||
delete child; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#ifndef EUREKAUI_ELEMENT_H | ||
#define EUREKAUI_ELEMENT_H | ||
#include <unordered_map> | ||
#include <string> | ||
#include <list> | ||
|
||
namespace EurekaUI | ||
{ | ||
class Context; | ||
/** | ||
* | ||
*/ | ||
class Element | ||
{ | ||
friend class Context; | ||
public: | ||
template<class T> Element *createChild() | ||
{ | ||
Element *e = new T(*this); | ||
mChildren.push_back(e); | ||
return e; | ||
}; | ||
|
||
template<class T> Element *createChild(const std::string &&Id) | ||
{ | ||
Element *e = createChild<T>(); | ||
mChildrenById[Id] = e; | ||
return e; | ||
} | ||
|
||
Element *getParent(){return mParent;} | ||
private: | ||
explicit Element(Element *parent); | ||
~Element(); | ||
|
||
Element *mParent; | ||
std::list<Element*> mChildren; | ||
std::unordered_map<std::string,Element*> mChildrenById; | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
#include "context.h" | ||
#include "element.h" |