|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
#include "App.h" |
|
|
|
|
#include "../tools/Scheduler.h" |
|
|
|
|
#include "app.h" |
|
|
|
|
#include "../tools/scheduler.h" |
|
|
|
|
#include "../interfaces/components/TabbedComponent.h" |
|
|
|
|
#include "../parsers/markup/ntrml/NTRMLParser.h" |
|
|
|
|
#include "../parsers/markup/html/HTMLParser.h" |
|
|
|
@ -62,18 +62,18 @@ void doOnClick(std::string type, Component *component, Window *win) {
@@ -62,18 +62,18 @@ void doOnClick(std::string type, Component *component, Window *win) {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//std::cout << "Browser:zdoOnClick.navAddressBar->onClick - got " << value << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TabbedComponent *p_tabComponent = dynamic_cast<TabbedComponent*>(win->tabComponent.get()); |
|
|
|
|
if (p_tabComponent) { |
|
|
|
|
if (!p_tabComponent->tabs.size()) { |
|
|
|
|
p_tabComponent->addTab("Loading..."); |
|
|
|
|
p_tabComponent->selectTab(p_tabComponent->tabs.back()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
win->renderDirty = true; |
|
|
|
|
win->render(); // display loading tab before IO
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<DocumentComponent> docComponent = win->getActiveDocumentComponent(); |
|
|
|
|
if (docComponent) { |
|
|
|
|
//std::cout << "Browser:zdoOnClick.navAddressBar->onClick - Found an active document component" << std::endl;
|
|
|
|
@ -137,7 +137,7 @@ void App::rebuildTheme() {
@@ -137,7 +137,7 @@ void App::rebuildTheme() {
|
|
|
|
|
this->layers.clear(); // nuke any layers we have
|
|
|
|
|
this->createComponentTree(this->uiRootNode, rootComponent, win); |
|
|
|
|
//Component::printComponentTree(rootComponent, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// these probably should be fatal
|
|
|
|
|
if (!win->addressComponent) { |
|
|
|
|
std::cout << "ERROR: no addressComponent" << std::endl; |
|
|
|
@ -145,7 +145,7 @@ void App::rebuildTheme() {
@@ -145,7 +145,7 @@ void App::rebuildTheme() {
|
|
|
|
|
if (!win->tabComponent) { |
|
|
|
|
std::cout << "ERROR: no tabComponent" << std::endl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// we want each window to has it's own component tree, so each address bar can have different values
|
|
|
|
|
size_t layerCount = 0; |
|
|
|
|
for(auto layer: this->layers) { |
|
|
|
@ -162,11 +162,11 @@ void App::rebuildTheme() {
@@ -162,11 +162,11 @@ void App::rebuildTheme() {
|
|
|
|
|
layer.reset(); // deallocate our local layers
|
|
|
|
|
} |
|
|
|
|
rootComponent.reset(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//newWindow->rootComponent = rootComponent;
|
|
|
|
|
//newWindow->ui->rootComponent = rootComponent;
|
|
|
|
|
win->renderDirty = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -177,14 +177,14 @@ void App::transferTheme(std::string filename) {
@@ -177,14 +177,14 @@ void App::transferTheme(std::string filename) {
|
|
|
|
|
|
|
|
|
|
for(auto win: this->windows) { |
|
|
|
|
glfwMakeContextCurrent(win->window); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TabbedComponent *oldTabbedComponent = nullptr; |
|
|
|
|
if (win->tabComponent) { |
|
|
|
|
oldTabbedComponent = dynamic_cast<TabbedComponent *>(win->tabComponent.get()); |
|
|
|
|
} |
|
|
|
|
win->tabComponent = nullptr; // release to release
|
|
|
|
|
win->addressComponent = nullptr; // I think this is ok to release now
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// convert uiRootNode into a component list
|
|
|
|
|
std::shared_ptr<Component> rootComponent = std::make_shared<Component>(); |
|
|
|
|
rootComponent->name = "rootComponent of browser"; |
|
|
|
@ -192,7 +192,7 @@ void App::transferTheme(std::string filename) {
@@ -192,7 +192,7 @@ void App::transferTheme(std::string filename) {
|
|
|
|
|
// we build one global tree that each layer has a child node in
|
|
|
|
|
this->createComponentTree(this->uiRootNode, rootComponent, win); |
|
|
|
|
//Component::printComponentTree(rootComponent, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// these probably should be fatal
|
|
|
|
|
if (!win->addressComponent) { |
|
|
|
|
std::cout << "ERROR: no addressComponent" << std::endl; |
|
|
|
@ -200,7 +200,7 @@ void App::transferTheme(std::string filename) {
@@ -200,7 +200,7 @@ void App::transferTheme(std::string filename) {
|
|
|
|
|
if (!win->tabComponent) { |
|
|
|
|
std::cout << "ERROR: no tabComponent" << std::endl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ok now we need to transfer the tabs over
|
|
|
|
|
if (oldTabbedComponent) { |
|
|
|
|
// should have been set in createComponentTree
|
|
|
|
@ -214,7 +214,7 @@ void App::transferTheme(std::string filename) {
@@ -214,7 +214,7 @@ void App::transferTheme(std::string filename) {
|
|
|
|
|
if (oldDocComponent) { |
|
|
|
|
//std::cout << "Reading DOM" << std::endl;
|
|
|
|
|
//printNode(oldDocComponent->domRootNode, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<Tab> nTab = newTabbedComponent->addTab(tab->titleBox->text); |
|
|
|
|
newTabbedComponent->selectTab(nTab); |
|
|
|
|
// maybe faster if we can skip the component tree rebuild
|
|
|
|
@ -275,13 +275,13 @@ void App::transferTheme(std::string filename) {
@@ -275,13 +275,13 @@ void App::transferTheme(std::string filename) {
|
|
|
|
|
} else { |
|
|
|
|
std::cout << "old theme didnt have tab component" << std::endl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// now we're officially done with old layer, nuked them
|
|
|
|
|
for(auto layer: win->ui->layers) { |
|
|
|
|
layer.reset(); |
|
|
|
|
} |
|
|
|
|
win->ui->layers.clear(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// we want each window to has it's own component tree, so each address bar can have different values
|
|
|
|
|
size_t layerCount = 0; |
|
|
|
|
for(auto layer: this->layers) { |
|
|
|
@ -298,7 +298,7 @@ void App::transferTheme(std::string filename) {
@@ -298,7 +298,7 @@ void App::transferTheme(std::string filename) {
|
|
|
|
|
layer.reset(); // deallocate our local layers
|
|
|
|
|
} |
|
|
|
|
rootComponent.reset(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//newWindow->rootComponent = rootComponent;
|
|
|
|
|
//newWindow->ui->rootComponent = rootComponent;
|
|
|
|
|
win->renderDirty = true; |
|
|
|
@ -383,7 +383,7 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr<
@@ -383,7 +383,7 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr<
|
|
|
|
|
ss << std::hex << tagNode->properties["bgcolor"]; |
|
|
|
|
ss >> win->clearColor; |
|
|
|
|
//std::cout << "set clear color " << std::hex << win->clearColor << std::dec << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float r = (static_cast<float>((win->clearColor >> 24) & 0xFF)) / 255; |
|
|
|
|
float g = (static_cast<float>((win->clearColor >> 16) & 0xFF)) / 255; |
|
|
|
|
float b = (static_cast<float>((win->clearColor >> 8) & 0xFF)) / 255; |
|
|
|
@ -443,7 +443,7 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr<
@@ -443,7 +443,7 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr<
|
|
|
|
|
ss >> color; |
|
|
|
|
//std::cout << "read color " << tagNode->properties["color"] << " as " << std::hex << color << std::dec << std::endl;
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// winHeight minus because box coordinates? yes
|
|
|
|
|
//std::cout << "placing box at " << cX << "," << cY << " " << cW << "x" << cH << " color: " << std::hex << color << std::dec << std::endl;
|
|
|
|
|
//std::shared_ptr<BoxComponent> box = std::make_unique<BoxComponent>(cX, winHeight - cH - cY, cW, cH, color, winWidth, winHeight);
|
|
|
|
@ -515,18 +515,18 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr<
@@ -515,18 +515,18 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr<
|
|
|
|
|
|
|
|
|
|
navAddressBar->onEnter=[win](std::string value) { |
|
|
|
|
std::cout << "navAddressBar::onEnter got " << value << std::endl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TabbedComponent *p_tabComponent = dynamic_cast<TabbedComponent*>(win->tabComponent.get()); |
|
|
|
|
if (p_tabComponent) { |
|
|
|
|
if (!p_tabComponent->tabs.size()) { |
|
|
|
|
p_tabComponent->addTab("Loading..."); |
|
|
|
|
p_tabComponent->selectTab(p_tabComponent->tabs.back()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
win->renderDirty = true; |
|
|
|
|
win->render(); // display loading tab before IO
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<DocumentComponent> docComponent = win->getActiveDocumentComponent(); |
|
|
|
|
if (docComponent) { |
|
|
|
|
std::cout << "Found an active document component" << std::endl; |
|
|
|
@ -536,7 +536,7 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr<
@@ -536,7 +536,7 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr<
|
|
|
|
|
std::cout << "No active document component" << std::endl; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
navAddressBar->win = win; |
|
|
|
|
win->addressComponent = navAddressBar; |
|
|
|
|
component = navAddressBar; |
|
|
|
@ -585,12 +585,12 @@ void App::addJSDebuggerWindow() {
@@ -585,12 +585,12 @@ void App::addJSDebuggerWindow() {
|
|
|
|
|
newWindow->init(); // load our UI into it
|
|
|
|
|
std::shared_ptr<Component> p_rootComponent = std::make_shared<Component>(); |
|
|
|
|
p_rootComponent->name = "rootComponent of jsconsole"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<TextComponent> outputComp = std::make_shared<TextComponent>("NeTRunner JavaScript console", 0, 0, 12, false, 0x000000FF, newWindow->windowWidth, newWindow->windowHeight); |
|
|
|
|
outputComp->win = newWindow; |
|
|
|
|
newWindow->ui->layers.push_back(outputComp); |
|
|
|
|
outputComp.reset(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
std::shared_ptr<InputComponent> inputComp = std::make_shared<InputComponent>(0, 0, 1024, 12, newWindow->windowWidth, newWindow->windowHeight); |
|
|
|
|
inputComp->win = newWindow; |
|
|
|
@ -609,15 +609,15 @@ void App::addWindow() {
@@ -609,15 +609,15 @@ void App::addWindow() {
|
|
|
|
|
newWindow->windowWidth = 1024; |
|
|
|
|
newWindow->windowHeight = 640; |
|
|
|
|
newWindow->init(); // load our UI into it
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// convert uiRootNode into a component list
|
|
|
|
|
std::shared_ptr<Component> p_rootComponent = std::make_shared<Component>(); |
|
|
|
|
p_rootComponent->name = "rootComponent of browser"; |
|
|
|
|
// we build one global tree that each layer has a child node in
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this->createComponentTree(this->uiRootNode, p_rootComponent, newWindow); |
|
|
|
|
//Component::printComponentTree(p_rootComponent, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// these probably should be fatal
|
|
|
|
|
if (!newWindow->addressComponent) { |
|
|
|
|
std::cout << "ERROR: no addressComponent" << std::endl; |
|
|
|
@ -625,7 +625,7 @@ void App::addWindow() {
@@ -625,7 +625,7 @@ void App::addWindow() {
|
|
|
|
|
if (!newWindow->tabComponent) { |
|
|
|
|
std::cout << "ERROR: no tabComponent" << std::endl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// we want each window to has it's own component tree, so each address bar can have different values
|
|
|
|
|
size_t layerCount = 0; |
|
|
|
|
for(auto layer: this->layers) { |
|
|
|
@ -643,14 +643,14 @@ void App::addWindow() {
@@ -643,14 +643,14 @@ void App::addWindow() {
|
|
|
|
|
} |
|
|
|
|
this->layers.clear(); // nuke any layers we have
|
|
|
|
|
p_rootComponent.reset(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//newWindow->rootComponent = rootComponent;
|
|
|
|
|
//newWindow->ui->rootComponent = rootComponent;
|
|
|
|
|
newWindow->renderDirty = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this->windows.push_back(newWindow); |
|
|
|
|
newWindow.reset(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!activeWindow) { |
|
|
|
|
//std::cout << "Browser::addWindow - setting active window" << std::endl;
|
|
|
|
|
activeWindow = this->windows.back().get(); |
|
|
|
|