Browse Source

gcc fix, theme font fix/disablement for now, AddWindow cleans up layers afer use now, addJSDebuggerWindow()

master
Odilitime 5 years ago
parent
commit
313d7d9008
  1. 46
      src/app.cpp
  2. 1
      src/app.h

46
src/app.cpp

@ -308,7 +308,7 @@ void App::transferTheme(std::string filename) { @@ -308,7 +308,7 @@ void App::transferTheme(std::string filename) {
void App::NextTheme() {
glob_t glob_result;
static unsigned int t = 0;
glob("*.ntrml", GLOB_TILDE, NULL, &glob_result);
glob("*.ntrml", GLOB_TILDE, nullptr, &glob_result);
t++;
if (t == glob_result.gl_pathc) t = 0;
/*
@ -351,6 +351,8 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr< @@ -351,6 +351,8 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr<
tag = tagNode->tag;
}
} else if (node->nodeType == NodeType::TEXT) {
// just ignore text blocks
return;
tagNode = dynamic_cast<TagNode*>(node->parent.get());
if (tagNode) {
tag = tagNode->tag;
@ -412,12 +414,20 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr< @@ -412,12 +414,20 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr<
//std::cout << "Added img component to ui" << std::endl;
} else if (tag == "font") {
// 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);
std::shared_ptr<TextComponent> text = std::make_unique<TextComponent>("NeTRunner", 0, 0, 12, false, 0x000000FF, winWidth, winHeight);
std::string label = "NeTRunner";
if (node->children.size()) {
TextNode *textNode = dynamic_cast<TextNode*>(node->children.front().get());
if (textNode) {
label = textNode->text;
}
}
std::shared_ptr<TextComponent> text = std::make_unique<TextComponent>(label, 0, 0, 12, false, 0x000000FF, winWidth, winHeight);
text->boundToPage = false; // have to set this before setUpUI
text->win = win;
// this may not work for the text shader...
// this may not work for the text shader... yea doesn't seem to
text->setUpUI(tagNode->properties, win.get());
text->isPickable = false;
//text->resize(win->windowWidth, win->windowHeight); // force a re-raster
// set up interactivity
if (tagNode->properties.find("onClick") != tagNode->properties.end()) {
text->isPickable = true;
@ -566,6 +576,32 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr< @@ -566,6 +576,32 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr<
component.reset();
}
void App::addJSDebuggerWindow() {
windowCounter++;
std::shared_ptr<Window> newWindow = std::make_shared<Window>();
newWindow->id = windowCounter;
newWindow->windowWidth = 1024;
newWindow->windowHeight = 640;
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;
newWindow->ui->layers.push_back(inputComp);
inputComp.reset();
*/
this->windows.push_back(newWindow);
newWindow.reset();
}
void App::addWindow() {
windowCounter++;
std::shared_ptr<Window> newWindow = std::make_shared<Window>();
@ -578,7 +614,7 @@ void App::addWindow() { @@ -578,7 +614,7 @@ void App::addWindow() {
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->layers.clear(); // nuke any layers we have
this->createComponentTree(this->uiRootNode, p_rootComponent, newWindow);
//Component::printComponentTree(p_rootComponent, 0);
@ -605,6 +641,7 @@ void App::addWindow() { @@ -605,6 +641,7 @@ void App::addWindow() {
layerCount++;
layer.reset(); // deallocate our local layers
}
this->layers.clear(); // nuke any layers we have
p_rootComponent.reset();
//newWindow->rootComponent = rootComponent;
@ -661,6 +698,7 @@ void App::loop() { @@ -661,6 +698,7 @@ void App::loop() {
// FIXME: one close shouldn't close the app
for(std::vector<std::shared_ptr<Window>>::iterator it = this->windows.begin(); it != this->windows.end(); ++it) {
if (glfwWindowShouldClose(it->get()->window)) {
// FIXME: just remove window from stack
shouldQuit = true;
break;
}

1
src/app.h

@ -23,6 +23,7 @@ public: @@ -23,6 +23,7 @@ public:
void transferTheme(std::string filename);
void NextTheme();
void createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr<Component> &parentComponent, std::shared_ptr<Window> win);
void addJSDebuggerWindow();
void addWindow();
void render();
void loop();

Loading…
Cancel
Save