Skip to content
Snippets Groups Projects
Commit d533740b authored by Odilitime's avatar Odilitime
Browse files

typeOfComponent() detect new tab type, auto bind component built to the page

parent 459c3e6a
No related branches found
No related tags found
No related merge requests found
......@@ -89,10 +89,15 @@ std::shared_ptr<Component> ComponentBuilder::build(const std::shared_ptr<Node> n
// set our type
component->isInline = isInline;
// need to bind it to the page
component->boundToPage = true;
// place us in tree
component->setParent(parentComponent);
if (parentComponent) {
parentComponent->children.push_back(component);
} else {
std::cout << "componentBuilder::build - no parentComponent for " << typeOfComponent(component) << std::endl;
}
// figure out our position, size, texture
......@@ -108,9 +113,13 @@ std::shared_ptr<Component> ComponentBuilder::build(const std::shared_ptr<Node> n
return component;
}
// these aren't used in any elements yet
#include "DocumentComponent.h"
#include "TabbedComponent.h"
std::string typeOfComponent(const std::shared_ptr<Component> &component) {
TabbedComponent *tabComponent = dynamic_cast<TabbedComponent*>(component.get());
if (tabComponent) return "tab";
DocumentComponent *docComponent = dynamic_cast<DocumentComponent*>(component.get());
if (docComponent) return "doc";
TextComponent *textComponent = dynamic_cast<TextComponent*>(component.get());
......
......@@ -30,6 +30,7 @@ public:
std::shared_ptr<Component> build(const std::shared_ptr<Node> node, const std::shared_ptr<Component> &parentComponent, int windowWidth, int windowHeight);
};
// getComponentType
std::string typeOfComponent(const std::shared_ptr<Component> &component);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment