Browse Source

renderer() now uses ElementRenderRequest

master
Odilitime 5 years ago
parent
commit
d185193614
  1. 3
      src/graphics/elements/Element.cpp
  2. 26
      src/graphics/elements/Element.h

3
src/graphics/elements/Element.cpp

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
Element::~Element() {
}
std::unique_ptr<Component> Element::renderer(const std::shared_ptr<Node> node, const int x, const int y, const int windowWidth, const int windowHeight) {
std::unique_ptr<Component> Element::renderer(const ElementRenderRequest &request) {
return nullptr;
}

26
src/graphics/elements/Element.h

@ -4,18 +4,32 @@ @@ -4,18 +4,32 @@
#include <functional>
#include <memory>
#include "../components/Component.h"
#include "../opengl/Window.h"
#include "../../html/Node.h"
class ElementRenderRequest {
public:
// we read the attributes from node (color, size, positioning, font info)
// and pass them to a newly made component
// and then we set up behaviors for that new component
std::shared_ptr<Node> node;
// has really no purpose except to pass win
// it was supposed to be for positions, but ComponentBuilder handles all that now
// as an element we shouldn't really care too much about position
// if we set up the component right, it'll handle all that
std::shared_ptr<Component> parentComponent;
// can get this from parentComponent
//std::shared_ptr<Window> win;
};
// we define tokens in a language
// and convert them into a component (UI element)
class Element {
public:
bool isInline = false;
virtual ~Element();
// TODO: remove position
// add parent (node or component? well component because that's how the create component is going to calculate position
// well right now ComponentBuilder calls renderer and it has parent/window size
// component constructors don't really need parent/window size
// so we could remove window size too
virtual std::unique_ptr<Component> renderer(const std::shared_ptr<Node> node, const int x, const int y, const int windowWidth, const int windowHeight);
virtual std::unique_ptr<Component> renderer(const ElementRenderRequest &request);
};
#endif

Loading…
Cancel
Save