Browse Source

animeComponent => image, clearColor, don't build UI

Odilitime 5 years ago
parent
commit
fb891e2c6d
  1. 36
      src/graphics/opengl/Window.cpp
  2. 1
      src/graphics/opengl/Window.h

36
src/graphics/opengl/Window.cpp

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
#include "../../URL.h"
#include "../../Log.h"
#include "../components/BoxComponent.h"
#include "../components/AnimeComponent.h"
#include "../components/ImageComponent.h"
#include "../components/DocumentComponent.h"
#include "../components/TabbedComponent.h"
#include "../components/TextComponent.h"
@ -63,6 +63,7 @@ bool Window::init() { @@ -63,6 +63,7 @@ bool Window::init() {
// 4 -> input
//Mascot
/*
std::shared_ptr<AnimeComponent> mascot = std::make_unique<AnimeComponent>(windowWidth * 0.75f, 0.0f, 512.0f, 512.0f, windowWidth, windowHeight);
mascot->uiControl.x = { 75, 0 }; // 75% width
mascot->uiControl.y = { 0, 0 }; // 0px
@ -195,7 +196,8 @@ bool Window::init() { @@ -195,7 +196,8 @@ bool Window::init() {
//std::cout << "navRefreshButton->onMouseout" << std::endl;
navRefreshButton->changeColor(0x000000FF);
this->renderDirty = true;
}; // add it to our components
};
// add it to our components
navRefreshButton->setParent(rootComponent);
rootComponent->children.push_back(navRefreshButton);
@ -247,7 +249,8 @@ bool Window::init() { @@ -247,7 +249,8 @@ bool Window::init() {
//std::cout << "placing inputComponent at " << static_cast<int>(navAddressBar->x) << "," << static_cast<int>(navAddressBar->y) << std::endl;
navAddressBar->setParent(rootComponent);
rootComponent->children.push_back(navAddressBar);
*/
/*
// textTest
// TextComponent(const std::string &rawText, const int rawX, const int rawY, const unsigned int size, const bool bolded, const unsigned int hexColor, const int passedWindowWidth, const int passedWindowHeight);
@ -265,7 +268,7 @@ bool Window::init() { @@ -265,7 +268,7 @@ bool Window::init() {
*/
// set tab component
this->tabComponent = tabbedComponent;
//this->tabComponent = tabbedComponent;
return true;
}
@ -665,7 +668,13 @@ bool Window::initGL() { @@ -665,7 +668,13 @@ bool Window::initGL() {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0.8f, 0.8f, 0.8f, 0.8f);
float r = (static_cast<float>((this->clearColor >> 24) & 0xFF)) / 255;
float g = (static_cast<float>((this->clearColor >> 16) & 0xFF)) / 255;
float b = (static_cast<float>((this->clearColor >> 8) & 0xFF)) / 255;
float a = (static_cast<float>((this->clearColor >> 0) & 0xFF)) / 255;
glClearColor(r, g, b, a);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@ -787,7 +796,7 @@ void Window::render() { @@ -787,7 +796,7 @@ void Window::render() {
// draw anime 1st, tabbed components 2nd
// then box shit
// text last
renderComponentType("anime", rootComponent);
renderComponentType("image", rootComponent);
renderComponentType("tab", rootComponent);
textureShader->bind();
@ -840,7 +849,7 @@ void Window::render() { @@ -840,7 +849,7 @@ void Window::render() {
// update 2nd buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
textureShader->bind();
renderComponentType("anime", rootComponent);
renderComponentType("image", rootComponent);
renderComponentType("tab", rootComponent);
textureShader->bind();
// reset it our textureTransformationMatrix
@ -937,9 +946,9 @@ void Window::renderComponentType(std::string str, std::shared_ptr<Component> com @@ -937,9 +946,9 @@ void Window::renderComponentType(std::string str, std::shared_ptr<Component> com
} else if (str =="input") {
InputComponent *inputComponent = dynamic_cast<InputComponent*>(component.get());
inputComponent->render();
} else if (str =="anime") {
AnimeComponent *animeComponent = dynamic_cast<AnimeComponent*>(component.get());
animeComponent->render();
} else if (str =="image") {
ImageComponent *imageComponent = dynamic_cast<ImageComponent*>(component.get());
imageComponent->render();
} else if (str =="box") {
//AnimeComponent *animeComponent = dynamic_cast<AnimeComponent*>(component.get());
//if (!animeComponent) {
@ -966,14 +975,15 @@ void Window::renderComponentType(std::string str, std::shared_ptr<Component> com @@ -966,14 +975,15 @@ void Window::renderComponentType(std::string str, std::shared_ptr<Component> com
std::shared_ptr<Component> Window::searchComponentTree(const std::shared_ptr<Component> &component, const int x, const int y) {
if (component->children.empty()) {
// x,y: 0,0 is the upper left
//std::cout << "cursor at: " << x << "," << y << " component at " << static_cast<int>(component->x) << "," << static_cast<int>(component->y) << " size " << static_cast<int>(component->width) << "," << static_cast<int>(component->height) << std::endl;
//std::cout << "cursor at: " << x << "," << y << " component at " << static_cast<int>(component->x) << "," << static_cast<int>(component->y) << " size " << static_cast<int>(component->width) << "," << static_cast<int>(component->height) << " type: " << typeOfComponent(component) << std::endl;
int ty = component->y;
int ty1 = component->height + component->y;
// FIXME: hack for tabbed component
if (ty < 0) {
ty = 0;
ty1 += 64; // FIXME: hack (for what?)
ty1 += 64;
}
//std::cout << "Window::searchComponentTree - y search: " << ty1 << ">" << static_cast<int>(this->windowHeight + y) << ">" << static_cast<int>(ty) << std::endl;
//std::cout << "Window::searchComponentTree - y search: " << ty1 << ">" << static_cast<int>(this->windowHeight + y) << ">" << static_cast<int>(ty) << " type: " << typeOfComponent(component) << std::endl;
if (ty1 > this->windowHeight + y && this->windowHeight + y > ty) {
//std::cout << "y match" << std::endl;
if (component->x < x && component->x + component->width > x) {

1
src/graphics/opengl/Window.h

@ -86,6 +86,7 @@ public: @@ -86,6 +86,7 @@ public:
std::vector<std::shared_ptr<Component>> selectionList;
// multiwindow support
size_t id; // key for shader caches
unsigned int clearColor = 0xCCCCCCCC;
};
bool setWindowContent(URL const& url);

Loading…
Cancel
Save