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

renderDocumentComponents(), if not boundToPage reset textProgram scroll position

parent 2af214c0
No related branches found
No related tags found
No related merge requests found
......@@ -180,9 +180,24 @@ void MultiComponent::resize(const int passedWindowWidth, const int passedWindowH
void MultiComponent::render() {
//std::cout << "MultiComponent::render" << std::endl;
glUseProgram(win->fontProgram);
renderDocumentComponents(rootComponent);
glUseProgram(win->textureProgram);
renderBoxComponents(rootComponent);
// if we flip, we can't put tab labels on top of the tab
glUseProgram(win->fontProgram);
if (!boundToPage) {
GLint transformLocation = glGetUniformLocation(win->fontProgram, "transform");
GLenum glErr=glGetError();
if(glErr != GL_NO_ERROR) {
std::cout << "InputComponent::render - glGetUniformLocation not ok: " << glErr << std::endl;
}
glUniformMatrix4fv(transformLocation, 1, GL_FALSE, win->transformMatrix);
glErr=glGetError();
if(glErr != GL_NO_ERROR) {
std::cout << "InputComponent::render - glUniformMatrix4fv not ok: " << glErr << std::endl;
}
}
renderComponents(rootComponent);
}
......@@ -192,10 +207,12 @@ void MultiComponent::renderComponents(std::shared_ptr<Component> component) {
std::cout << "DocumentComponent::renderComponents - got null passed" << std::endl;
return;
}
/*
DocumentComponent *docComponent = dynamic_cast<DocumentComponent*>(component.get());
if (docComponent) {
docComponent->render();
}
*/
TextComponent *textComponent = dynamic_cast<TextComponent*>(component.get());
if (textComponent) {
textComponent->render();
......@@ -209,6 +226,26 @@ void MultiComponent::renderComponents(std::shared_ptr<Component> component) {
}
}
void MultiComponent::renderDocumentComponents(std::shared_ptr<Component> component) {
if (!component) {
std::cout << "MultiComponent::renderBoxComponents - got null passed" << std::endl;
return;
}
//std::cout << "MultiComponent::renderBoxComponents - renderering: " << component->name << std::endl;
// render non-text components too
DocumentComponent *docComponent = dynamic_cast<DocumentComponent*>(component.get());
if (docComponent) {
docComponent->render();
}
// is this needed?
if (component->children.empty()) {
return;
}
for (std::shared_ptr<Component> &child : component->children) {
this->renderDocumentComponents(child);
}
}
void MultiComponent::renderBoxComponents(std::shared_ptr<Component> component) {
if (!component) {
std::cout << "MultiComponent::renderBoxComponents - got null passed" << std::endl;
......@@ -225,7 +262,7 @@ void MultiComponent::renderBoxComponents(std::shared_ptr<Component> component) {
return;
}
for (std::shared_ptr<Component> &child : component->children) {
renderBoxComponents(child);
this->renderBoxComponents(child);
}
}
......
......@@ -7,14 +7,18 @@
// we're a control with our own componentTree
// we can relay events down to these components
// can be used for documents, tabs and menus
//
// this component is not scrollable
class MultiComponent : public Component {
public:
MultiComponent(const float rawX, const float rawY, const float rawWidth, const float rawHeight, const int passedWindowWidth, const int passedWindowHeight);
void render();
void renderComponents(std::shared_ptr<Component> component);
void renderDocumentComponents(std::shared_ptr<Component> component);
void renderBoxComponents(std::shared_ptr<Component> component);
void resize(const int passedWindowWidth, const int passedWindowHeight);
std::shared_ptr<Component> searchComponentTree(const std::shared_ptr<Component> &component, const int passedX, const int passedY);
std::vector<std::shared_ptr<Component>> layers;
std::shared_ptr<Component> rootComponent = std::make_shared<Component>();
Window *win;
bool tabbed = false;
......
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