Browse Source

clean up and fwd/back buttons (colors on box components)

pull/2/head
Odilitime 5 years ago
parent
commit
81c141f2ca
  1. 74
      src/graphics/opengl/Window.cpp

74
src/graphics/opengl/Window.cpp

@ -43,29 +43,6 @@ bool Window::init() { @@ -43,29 +43,6 @@ bool Window::init() {
std::cout << "window::init - post initGL - not ok: " << glErr << std::endl;
}
//UI
// at 0x(640-64) size (1024w, 64h)
//boxComponents.push_back(std::make_unique<BoxComponent>(0.0f, 640.0f - 64.0f, windowWidth, 64.0f, windowWidth, windowHeight));
//boxComponents.push_back(std::make_unique<BoxComponent>(0.0f, -96, 125, 13, windowWidth, windowHeight));
// grows from center
//boxComponents.push_back(std::make_unique<AnimeComponent>(0.0f, -80, 16, 16, windowWidth, windowHeight));
//boxComponents.push_back(std::make_unique<InputComponent>(0.0f, -56.0f, 125.0f, 13.0f, windowWidth, windowHeight));
// draws 13 px up from the bottom of 0
//boxComponents.push_back(std::make_unique<InputComponent>(0.0f, 0.0f, 12.0f, 13.0f, windowWidth, windowHeight));
// this works fine, we can translate and resize
//boxComponents.back()->y = -56;
//boxComponents.back()->width = 125;
//boxComponents.back()->resize(windowWidth, windowHeight);
//boxComponents.push_back(std::make_unique<InputComponent>(0.0f, 20.0f, 123.0f, 13.0f, windowWidth, windowHeight));
// address bar
//boxComponents.push_back(std::make_unique<InputComponent>(192.0f, 640.0f - 48.0f, windowWidth - 384.0f, 24.0f, windowWidth, windowHeight));
//Mascot
//boxComponents.push_back(std::make_unique<AnimeComponent>(768.0f, 0.0f, 512.0f, 512.0f, windowWidth, windowHeight));
return true;
}
@ -172,7 +149,7 @@ bool Window::initGLFW() { @@ -172,7 +149,7 @@ bool Window::initGLFW() {
thiz->transformMatrix[13] += -yOffset * 0.1;
if (thiz->hoverComponent) {
if (thiz->hoverComponent->onWheel) {
thiz->hoverComponent->onWheel(xOffset * 10, yOffset * 10);
thiz->hoverComponent->onWheel(xOffset * 100, yOffset * 100);
}
}
@ -464,29 +441,11 @@ void Window::render() { @@ -464,29 +441,11 @@ void Window::render() {
return;
}
std::cout << "restarting drawing" << std::endl;
// just delete and recreate
//boxComponents.clear();
//UI
// at 0x(640-64) size (1024w, 64h)
//boxComponents.push_back(std::make_unique<BoxComponent>(0.0f, windowHeight - 64.0f, windowWidth, 64.0f, windowWidth, windowHeight));
// draws 13 px up from the bottom of 0
//boxComponents.push_back(std::make_unique<InputComponent>(0.0f, 0.0f, 123.0f, 13.0f, windowWidth, windowHeight));
//Mascot
//boxComponents.push_back(std::make_unique<AnimeComponent>(windowWidth * 0.75f, 0.0f, 512.0f, 512.0f, windowWidth, windowHeight));
/*
for (const std::unique_ptr<BoxComponent> &boxComponent : boxComponents) {
//boxComponent->windowWidth = windowWidth;
//boxComponent->windowHeight = windowHeight;
boxComponent->resize(windowWidth, windowHeight);
}
*/
//std::cout << "resizing" << std::endl;
const std::clock_t begin = clock();
//resizeComponentTree(rootComponent, windowWidth, windowHeight);
rootComponent->windowWidth = windowWidth;
rootComponent->windowHeight = windowHeight;
rootComponent->layout();
@ -526,12 +485,8 @@ void Window::render() { @@ -526,12 +485,8 @@ void Window::render() {
if(glErr != GL_NO_ERROR) {
std::cout << "window::render - glUseProgram - not ok: " << glErr << std::endl;
}
//renderBoxComponents(rootComponent);
/*
for (const std::unique_ptr<BoxComponent> &boxComponent : boxComponents) {
boxComponent->render();
}
*/
//GLint transformLocation = glGetUniformLocation(textureProgram, "transform");
//glUniformMatrix4fv(transformLocation, 1, GL_FALSE, transformMatrix);
renderBoxComponents(rootComponent);
// it's quick but done on scroll
glUseProgram(fontProgram);
@ -549,12 +504,6 @@ void Window::render() { @@ -549,12 +504,6 @@ void Window::render() {
// update 2nd buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgram(textureProgram);
//renderBoxComponents(rootComponent);
/*
for (const std::unique_ptr<BoxComponent> &boxComponent : boxComponents) {
boxComponent->render();
}
*/
renderBoxComponents(rootComponent);
// it's quick but done on scroll
glUseProgram(fontProgram);
@ -607,12 +556,23 @@ void Window::setDOM(const std::shared_ptr<Node> rootNode) { @@ -607,12 +556,23 @@ void Window::setDOM(const std::shared_ptr<Node> rootNode) {
//std::cout << "Window::setDOM window size: " << windowWidth << "x" << windowHeight << std::endl;
// Nav background
std::shared_ptr<BoxComponent> navBackground = std::make_unique<BoxComponent>(0.0f, windowHeight - 64.0f, windowWidth, 64.0f, windowWidth, windowHeight);
std::shared_ptr<BoxComponent> navBackground = std::make_unique<BoxComponent>(0.0f, windowHeight - 64.0f, windowWidth, 64.0f, 0x888888FF, windowWidth, windowHeight);
//navBackground->y = -64;
navBackground->isPickable = false;
// add it to our components
navBackground->parent = rootComponent;
rootComponent->children.push_back(navBackground);
std::shared_ptr<BoxComponent> navBackButton = std::make_unique<BoxComponent>(32.0f, windowHeight - 48.0f, 32.0f, 32.0f, 0x000000FF, windowWidth, windowHeight);
// add it to our components
navBackButton->parent = rootComponent;
rootComponent->children.push_back(navBackButton);
std::shared_ptr<BoxComponent> navForwardButton = std::make_unique<BoxComponent>(74.0f, windowHeight - 48.0f, 32.0f, 32.0f, 0x000000FF, windowWidth, windowHeight);
// add it to our components
navForwardButton->parent = rootComponent;
rootComponent->children.push_back(navForwardButton);
// Address Bar
std::shared_ptr<InputComponent> navAddressBar = std::make_unique<InputComponent>(192.0f, windowHeight - 48.0f, windowWidth - 384.0f, 24.0f, windowWidth, windowHeight);

Loading…
Cancel
Save