Browse Source

project reorg and cleanup

master
Odilitime 4 years ago
parent
commit
bfcdda5c04
  1. 10
      Makefile
  2. 165800
      anime.h
  3. 80
      src/app/App.cpp
  4. 6
      src/app/App.h
  5. 14
      src/app/browser/Browser.cpp
  6. 6
      src/app/browser/Browser.h
  7. 2
      src/environment/Environment.cpp
  8. 72
      src/interfaces/components/DocumentComponent.cpp
  9. 6
      src/interfaces/components/DocumentComponent.h
  10. 98
      src/interfaces/components/InputComponent.cpp
  11. 4
      src/interfaces/components/InputComponent.h
  12. 30
      src/interfaces/components/MultiComponent.cpp
  13. 10
      src/interfaces/components/TabbedComponent.h
  14. 2
      src/interfaces/elements/AElement.cpp
  15. 14
      src/interfaces/elements/BUTTONElement.cpp
  16. 14
      src/interfaces/elements/INPUTElement.cpp
  17. 6
      src/interfaces/elements/SCRIPTElement.cpp
  18. 4
      src/interfaces/elements/TEXTAREAElement.cpp
  19. 0
      src/interfaces/graphical/renderers/TextWindow.cpp
  20. 0
      src/interfaces/graphical/renderers/TextWindow.h
  21. 2
      src/interfaces/graphical/renderers/glfw/ShaderLoader.cpp
  22. 24
      src/interfaces/graphical/renderers/glfw/Window.cpp
  23. 18
      src/interfaces/graphical/renderers/glfw/Window.h
  24. 84
      src/interfaces/graphical/renderers/glfw/opengl.cpp
  25. 51
      src/main.cpp
  26. 2
      src/networking/HTTPRequest.h
  27. 2
      src/networking/HTTPSRequest.h
  28. 2
      src/parsers/images/netpbm/pnm.h
  29. 4
      src/parsers/images/tga/tga.h
  30. 18
      src/parsers/scripting/javascript/JSParser.cpp
  31. 0
      src/platform/Murmur3.cpp
  32. 0
      src/platform/Murmur3.h
  33. 0
      src/platform/netrunner.h
  34. 0
      src/platform/slre.c
  35. 0
      src/platform/slre.h
  36. 0
      src/platform/target.h
  37. 0
      src/platform/tlsf-winnt.h
  38. 0
      src/platform/tlsf.c
  39. 0
      src/platform/tlsf.h
  40. 0
      src/tools/BrowsingHistory.cpp
  41. 0
      src/tools/BrowsingHistory.h
  42. 4
      src/tools/CFGFileParser.cpp
  43. 4
      src/tools/CFGFileParser.h
  44. 0
      src/tools/CommandLineParams.cpp
  45. 0
      src/tools/CommandLineParams.h
  46. 0
      src/tools/FormData.cpp
  47. 2
      src/tools/FormData.h
  48. 0
      src/tools/LRUCache.h
  49. 0
      src/tools/Log.cpp
  50. 0
      src/tools/Log.h
  51. 2
      src/tools/Scheduler.cpp
  52. 0
      src/tools/Scheduler.h
  53. 0
      src/tools/StringUtils.cpp
  54. 0
      src/tools/StringUtils.h
  55. 0
      src/tools/TextBlock.cpp
  56. 0
      src/tools/TextBlock.h
  57. 0
      src/tools/URL.cpp
  58. 0
      src/tools/URL.h
  59. 24
      src/tools/WebResource.cpp
  60. 2
      src/tools/WebResource.h

10
Makefile

@ -48,7 +48,7 @@ RES = res/ @@ -48,7 +48,7 @@ RES = res/
all: $(SOURCES) netrunner
netrunner: $(OBJECTS) $(OBJDIR)/tlsf.o $(OBJDIR)/slre.o
netrunner: $(OBJECTS) $(OBJDIR)/platform/tlsf.o $(OBJDIR)/platform/slre.o
$(LINK) $(LDFLAGS) -o $@ $^ $(LIBS)
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
@ -57,10 +57,10 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp @@ -57,10 +57,10 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
$(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARNINGS) -c -o $@ $<
@mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@
$(OBJDIR)/tlsf.o: $(SRCDIR)/tlsf.c
$(OBJDIR)/platform/tlsf.o: $(SRCDIR)/platform/tlsf.c
$(CC) $(INCPATH) $(CWARN) -DTLSF_USE_LOCKS=0 -DUSE_MMAP=1 -DUSE_SBRK=1 -c -o $@ $<
$(OBJDIR)/slre.o: $(SRCDIR)/slre.c
$(OBJDIR)/platform/slre.o: $(SRCDIR)/platform/slre.c
$(CC) $(INCPATH) $(CWARN) -c -o $@ $<
$(DEPDIR)/%d: ;
@ -69,10 +69,10 @@ $(DEPDIR)/%d: ; @@ -69,10 +69,10 @@ $(DEPDIR)/%d: ;
test-url.o: tests/testPrograms/URLtest.cpp
$(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARINGS) -c -o $@ $<
ntr-run-tests: test-url.o $(OBJDIR)/URL.o $(OBJDIR)/StringUtils.o
ntr-run-tests: test-url.o $(OBJDIR)/tools/URL.o $(OBJDIR)/tools/StringUtils.o
$(LINK) $(LDFLAGS) -o $@ test-url.o $(OBJDIR)/URL.o $(OBJDIR)/StringUtils.o $(LIBS)
ntr-test-cfg: test-cfg.o $(OBJDIR)/CFGFileParser.o $(OBJDIR)/slre.o $(OBJDIR)/tlsf.o $(OBJDIR)/Murmur3.o
ntr-test-cfg: test-cfg.o $(OBJDIR)/tools/CFGFileParser.o $(OBJDIR)/platform/slre.o $(OBJDIR)/platform/tlsf.o $(OBJDIR)/platform/Murmur3.o
$(LINK) $(LDFLAGS) -o $@ $^ $(LIBS)
test-cfg.o: tests/TestCFG.cpp

165800
anime.h

File diff suppressed because it is too large Load Diff

80
src/app.cpp → src/app/App.cpp

@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
#include "app.h"
#include "scheduler.h"
#include "interfaces/components/TabbedComponent.h"
#include "parsers/markup/ntrml/NTRMLParser.h"
#include "parsers/markup/html/HTMLParser.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"
#include "interfaces/components/DocumentComponent.h"
#include "../interfaces/components/DocumentComponent.h"
//#include "interfaces/components/ComponentBuilder.h"
#include "interfaces/components/InputComponent.h"
#include "interfaces/components/ImageComponent.h"
#include "interfaces/components/TabbedComponent.h"
#include "interfaces/components/ButtonComponent.h"
#include "../interfaces/components/InputComponent.h"
#include "../interfaces/components/ImageComponent.h"
#include "../interfaces/components/TabbedComponent.h"
#include "../interfaces/components/ButtonComponent.h"
#include <fstream>
#include <glob.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();

6
src/app.h → src/app/App.h

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
#ifndef APP_H
#define APP_H
#include "interfaces/graphical/renderers/glfw/Window.h"
#include "interfaces/components/Component.h"
#include "parsers/markup/Node.h"
#include "../interfaces/graphical/renderers/glfw/Window.h"
#include "../interfaces/components/Component.h"
#include "../parsers/markup/Node.h"
//#include <GL/glew.h>
//#include <GLFW/glfw3.h>
//#include <memory>

14
src/browser.cpp → src/app/browser/Browser.cpp

@ -1,11 +1,11 @@ @@ -1,11 +1,11 @@
#include "browser.h"
#include "interfaces/components/TabbedComponent.h"
#include "parsers/markup/html/HTMLParser.h"
#include "Browser.h"
#include "../../interfaces/components/TabbedComponent.h"
#include "../../parsers/markup/html/HTMLParser.h"
#include "interfaces/components/InputComponent.h"
#include "interfaces/components/ImageComponent.h"
#include "interfaces/components/TabbedComponent.h"
#include "interfaces/components/ButtonComponent.h"
#include "../../interfaces/components/InputComponent.h"
#include "../../interfaces/components/ImageComponent.h"
#include "../../interfaces/components/TabbedComponent.h"
#include "../../interfaces/components/ButtonComponent.h"
Browser::Browser() {
/*

6
src/browser.h → src/app/browser/Browser.h

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
#ifndef BROWSER_H
#define BROWSER_H
#include "app.h"
#include "../App.h"
//#include "interfaces/graphical/renderers/glfw/Window.h"
//#include "interfaces/components/Component.h"
#include "interfaces/components/DocumentComponent.h"
#include "../../interfaces/components/DocumentComponent.h"
//#include "interfaces/components/ComponentBuilder.h"
//#include "parsers/markup/Node.h"
//#include <GL/glew.h>
@ -23,7 +23,7 @@ public: @@ -23,7 +23,7 @@ public:
Browser();
void addWindow();
std::shared_ptr<DocumentComponent> getActiveDocumentComponent();
std::shared_ptr<Component> tabComponent = nullptr;
std::shared_ptr<Component> addressComponent = nullptr;

2
src/environment/Environment.cpp

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
#include <vector>
#include "Path.h"
#include "../Log.h"
#include "../tools/Log.h"
std::string Environment::resourceDir = "";

72
src/interfaces/components/DocumentComponent.cpp

@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
#include "DocumentComponent.h"
#include <cmath>
#include <iostream>
#include "../../Log.h"
#include "InputComponent.h"
#include "ButtonComponent.h"
#include "TabbedComponent.h"
#include <ctime>
#include "../graphical/renderers/glfw/Shader.h"
#include "../../WebResource.h"
#include "../../browser.h"
#include "../../tools/Log.h"
#include "../../tools/WebResource.h"
#include "../../app/browser/Browser.h"
#include "../../parsers/markup/html/HTMLParser.h"
void deleteComponent(std::shared_ptr<Component> &component);
@ -59,20 +59,20 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f @@ -59,20 +59,20 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f
windowWidth = passedWindowWidth;
windowHeight = passedWindowHeight;
//std::cout << "DocumentComponent::DocumentComponent - window size: " << windowWidth << "x" << windowHeight << std::endl;
std::shared_ptr<Component> rootComponent = std::make_shared<Component>();
this->layers.push_back(rootComponent);
x = rawX;
y = rawY;
width = rawWidth;
height = rawHeight;
if (height < 0) {
std::cout << "DocumentComponent::DocumentComponent - height was less than zero" << std::endl;
height = 0;
}
//std::cout << "DocumentComponent::DocumentComponent - our size" << static_cast<int>(width) << "x" << static_cast<int>(height) << std::endl;
onMousemove=[this](int passedX, int passedY) {
// set hover component
@ -320,19 +320,19 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f @@ -320,19 +320,19 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f
if (key == GLFW_KEY_PAGE_UP && (action == GLFW_PRESS || action == GLFW_REPEAT)) {
std::cout << "PgUp is/was pressed. Scrolling down." << std::endl;
this->scrollY(-yOffsetScroll*0.1);
}
if (key == GLFW_KEY_PAGE_DOWN && (action == GLFW_PRESS || action == GLFW_REPEAT)) {
std::cout << "PgDn is/was pressed. Scrolling up." << std::endl;
this->scrollY(yOffsetScroll*0.1);
}
// FIXME Scrolling with this can scroll past boundary whereas the same doesn't happen with
// scrolling wheel
if (key == GLFW_KEY_J && (action == GLFW_PRESS || action == GLFW_REPEAT)) {
std::cout << "J is/was pressed. Scrolling down." << std::endl;
this->scrollY(-yOffsetScroll*0.1);
}
// FIXME Scrolling with this can scroll past boundary whereas the same doesn't happen with
// scrolling wheel
@ -404,17 +404,17 @@ void DocumentComponent::setDOM(const std::shared_ptr<Node> rootNode) { @@ -404,17 +404,17 @@ void DocumentComponent::setDOM(const std::shared_ptr<Node> rootNode) {
// reset JS engine
//mainScript.clear();
mainScript = std::make_shared<JavaScript>();
// reset scroll position
//transformMatrix[13] = 2;
//transformMatrixDirty = true;
this->scrollY(0);
// new root component
rootComponent = std::make_shared<Component>();
rootComponent->name = "rootComponent of " + name;
rootComponent->y = y;
domRootNode = rootNode;
//std::cout << "DocumentComponent::setDOM - printing nodes" << endl; printNode(domRootNode, 0);
domDirty = true;
@ -429,17 +429,17 @@ void DocumentComponent::render() { @@ -429,17 +429,17 @@ void DocumentComponent::render() {
const std::clock_t end = clock();
// root component here doesn't have any children...
std::cout << "built & laid out document components in: " << std::fixed << ((static_cast<double>(end - begin)) / CLOCKS_PER_SEC) << std::scientific << " seconds" << std::endl;
//Component::printComponentTree(rootComponent, 0);
domDirty = false;
/*
std::cout << "DocumentComponent::render - JS var state" << std::endl;
for(auto it : this->mainScript->rootScope.variables) {
std::cout << "[" << it.first << "=" << it.second << "]" << std::endl;
}
*/
//std::cout << "root Height: " << static_cast<int>(rootComponent->height) << " window Height: " << windowHeight << " y " << static_cast<int>(this->y) << std::endl;
//scrollHeight = std::max(0, static_cast<int>(rootComponent->height - (windowHeight + (this->y * 2))));
@ -449,22 +449,22 @@ void DocumentComponent::render() { @@ -449,22 +449,22 @@ void DocumentComponent::render() {
transformMatrix[13]=std::max((rootComponent->height)/(windowHeight)*2.0f, 2.0f);
transformMatrixDirty = true;
}
// after we load in the document, allow scroll to work
this->updateMouse();
}
// we have to do this each time because window resets it
//if (transformMatrixDirty) {
//const std::clock_t begin = clock();
Shader *fontShader = this->win->shaderLoader.getShader(VertexShader("FontShader.vert"),
FragmentShader("FontShader.frag"));
GLint transformLocation = fontShader->uniform("transform");
glUniformMatrix4fv(transformLocation, 1, GL_FALSE, transformMatrix);
//const std::clock_t end = clock();
//std::cout << "Updated font matrix in: " << std::fixed << ((static_cast<double>(end - begin)) / CLOCKS_PER_SEC) << std::scientific << " seconds" << std::endl;
Shader *textureShader = this->win->shaderLoader.getShader(VertexShader("TextureShader.vert"),
FragmentShader("TextureShader.frag"));
@ -474,7 +474,7 @@ void DocumentComponent::render() { @@ -474,7 +474,7 @@ void DocumentComponent::render() {
textureShader->bind();
GLint transformLocation2 = textureShader->uniform("transform");
glUniformMatrix4fv(transformLocation2, 1, GL_FALSE, textureTransformMatrix);
//std::cout << "DocumentComponent::render - start Box components" << std::endl;
//renderBoxComponents(rootComponent);
this->renderComponentType("input", rootComponent);
@ -560,18 +560,18 @@ std::shared_ptr<Component> DocumentComponent::searchComponentTree(const std::sha @@ -560,18 +560,18 @@ std::shared_ptr<Component> DocumentComponent::searchComponentTree(const std::sha
// preparation for multiple HTML documents
void DocumentComponent::navTo(const std::string url) {
logDebug() << "DocumentComponent::navTo(" << url << ")" << std::endl;
this->currentURL = currentURL.merge(URL(url));
logDebug() << "DocumentComponent::navTo - go to: " << currentURL << std::endl;
//setWindowContent(currentURL);
logDebug() << "main::setWindowContent - " << url << std::endl;
// integrity check
TabbedComponent *tabComponent = dynamic_cast<TabbedComponent*>(this->win->tabComponent.get());
if (!tabComponent->tabs.size()) {
std::cout << "DocumentComponent::navTo - There's a document when there's not tabs" << std::endl;
}
// download URL
WebResource res = getWebResource(this->currentURL);
this->handleResource(res, currentURL.toString());
@ -587,23 +587,23 @@ void DocumentComponent::handleResource(WebResource &res, std::string url) { @@ -587,23 +587,23 @@ void DocumentComponent::handleResource(WebResource &res, std::string url) {
// bind tag to root
tagNode->parent = rootNode;
rootNode->children.push_back(tagNode);
std::shared_ptr<TextNode> textNode = std::make_shared<TextNode>();
textNode->text = "Invalid Resource Type, HTTP Result Status: " + res.raw;
// bind text to tag
textNode->parent = tagNode;
tagNode->children.push_back(textNode);
// send NodeTree to window
//this->win->setDOM(rootNode);
this->setDOM(rootNode);
}
//std::cout << "body: " << res.raw << std::endl;
//std::cout << "type: " << res.resourceType << std::endl;
// parse HTML
if (res.resourceType == ResourceType::HTML) {
HTMLParser parser;
@ -611,11 +611,11 @@ void DocumentComponent::handleResource(WebResource &res, std::string url) { @@ -611,11 +611,11 @@ void DocumentComponent::handleResource(WebResource &res, std::string url) {
std::shared_ptr<Node> rootNode = parser.parse(res.raw);
const std::clock_t end = clock();
logDebug() << "DocumentComponent::handleResource - Parsed document in: " << std::fixed << ((static_cast<double>(end - begin)) / CLOCKS_PER_SEC) << std::scientific << " seconds" << std::endl;
// send NodeTree to window
//this->win->setDOM(rootNode);
//printNode(rootNode, 0);
// we need a way to communicate with our tabComponent
// maybe an event is best
if (this->onBeforeLoad) {
@ -630,15 +630,15 @@ void DocumentComponent::handleResource(WebResource &res, std::string url) { @@ -630,15 +630,15 @@ void DocumentComponent::handleResource(WebResource &res, std::string url) {
// bind tag to root
tagNode->parent = rootNode;
rootNode->children.push_back(tagNode);
std::shared_ptr<TextNode> textNode = std::make_shared<TextNode>();
textNode->text = res.raw;
// bind text to tag
textNode->parent = tagNode;
tagNode->children.push_back(textNode);
// send NodeTree to window
//this->win->setDOM(rootNode);
this->setDOM(rootNode);

6
src/interfaces/components/DocumentComponent.h

@ -7,9 +7,9 @@ @@ -7,9 +7,9 @@
#include "ComponentBuilder.h"
#include "../../parsers/markup/Node.h"
#include "../../parsers/scripting/javascript/JSParser.h"
#include "../../URL.h"
#include "../../networking/HTTPResponse.h"
#include "../../WebResource.h"
#include "../../tools/URL.h"
#include "../../tools/WebResource.h"
std::pair<size_t, size_t> getLine(std::string text, int findLine);
size_t getNumberOfLines(std::string text);
@ -32,7 +32,7 @@ public: @@ -32,7 +32,7 @@ public:
//
//int scrollY = 0;
//int scrollHeight = 0;
// FIXME: I don't think we need two matrixes (they scroll in the same direction)
float textureTransformMatrix[16] = {
1, 0, 0, 0,

98
src/interfaces/components/InputComponent.cpp

@ -2,8 +2,6 @@ @@ -2,8 +2,6 @@
#include "DocumentComponent.h"
#include <iostream>
#include "../graphical/font/TextRasterizerCache.h"
#include "../../scheduler.h"
#include "../graphical/renderers/glfw/Shader.h"
extern TextRasterizerCache *rasterizerCache;
@ -14,10 +12,10 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r @@ -14,10 +12,10 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r
//std::cout << "InputComponent::InputComponent - create, boundToPage" << boundToPage << std::endl;
//std::cout << "InputComponent::InputComponent - window: " << windowWidth << "x" << windowHeight << " passed " << passedWindowWidth << "x" << passedWindowHeight << std::endl;
//boundToPage = true;
useBoxShader = true;
// set up state
windowWidth = passedWindowWidth;
windowHeight = passedWindowHeight;
@ -29,7 +27,7 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r @@ -29,7 +27,7 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r
x = rawX;
y = rawY;
lastRenderedWindowHeight = windowHeight;
// const float rawX, const float rawY, const float rawWidth, const float rawHeight, const unsigned int hexColor, const int passedWindowWidth, const int passedWindowHeight
// we only want it one line high (esp for text area)
this->cursorBox = new BoxComponent(x, y, 2, 13, 0x000000FF, windowWidth, windowHeight);
@ -42,7 +40,7 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r @@ -42,7 +40,7 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r
}
this->cursorBox->resize(this->windowWidth, this->windowHeight);
this->updateText();
onFocus=[this]() {
this->focused = true;
//std::cout << "focus input" << std::endl;
@ -67,7 +65,7 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r @@ -67,7 +65,7 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r
};
//std::cout << "InputComponent::InputComponent - placing box at " << (int)x << "," << (int)y << " size: " << (int)width << "x" << (int)height << std::endl;
// copy initial state
initialX = x;
initialY = y;
@ -75,26 +73,26 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r @@ -75,26 +73,26 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r
initialHeight = height;
initialWindowWidth = windowWidth;
initialWindowHeight = windowHeight;
data[0][0][0] = 0xf0; // set R color
data[0][0][1] = 0xf0; // set G color
data[0][0][2] = 0xf0; // set B color
data[0][0][3] = 0xff; // set alpha
float vx = rawX;
float vy = rawY;
//std::cout << "placing box at " << (int)vx << "x" << (int)vy << " size: " << (int)rawWidth << "x" << (int)rawHeight << std::endl;
float vWidth = rawWidth;
float vHeight = rawHeight;
pointToViewport(vx, vy);
// converts 512 to 1 and 1 to 2
//std::cout << "vWidth before: " << (int)vWidth << std::endl;
distanceToViewport(vWidth, vHeight);
//std::cout << "vWidth after: " << (int)vWidth << std::endl;
//std::cout << "InputComponent::InputComponent - placing box at GL " << vx << "," << vy << " to " << vx+vWidth << "," << vy+vHeight << " size: " << vWidth << "x" << vHeight << std::endl;
vertices[(0 * 5) + 0] = vx;
vertices[(0 * 5) + 1] = vy + vHeight;
vertices[(1 * 5) + 0] = vx + vWidth;
@ -103,31 +101,31 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r @@ -103,31 +101,31 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r
vertices[(2 * 5) + 1] = vy;
vertices[(3 * 5) + 0] = vx;
vertices[(3 * 5) + 1] = vy;
glGenVertexArrays(1, &vertexArrayObject);
glGenBuffers(1, &vertexBufferObject);
glGenBuffers(1, &elementBufferObject);
glBindVertexArray(vertexArrayObject);
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObject);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBufferObject);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), nullptr);
glEnableVertexAttribArray(0);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), reinterpret_cast<void*>(3 * sizeof(float)));
glEnableVertexAttribArray(1);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
glBindVertexArray(0); // protect what we created against any further modification
}
@ -152,7 +150,7 @@ void InputComponent::render() { @@ -152,7 +150,7 @@ void InputComponent::render() {
}
verticesDirty = false;
}
glBindVertexArray(vertexArrayObject);
glErr=glGetError();
if(glErr != GL_NO_ERROR) {
@ -196,7 +194,7 @@ void InputComponent::render() { @@ -196,7 +194,7 @@ void InputComponent::render() {
}
if (focused) {
//std::cout << "Rendering cursor" << std::endl;
// render it if we need to
if (showCursor) {
cursorBox->render();
@ -207,14 +205,14 @@ void InputComponent::render() { @@ -207,14 +205,14 @@ void InputComponent::render() {
void InputComponent::resize(const int passedWindowWidth, const int passedWindowHeight) {
//std::cout << "InputComponent::resize" << std::endl;
//std::cout << "InputComponent::resize - rasterizing at " << (int)x << "x" << (int)y << " size: " << (int)width << "x" << (int)height << std::endl;
// maybe already done at component::resize
// set up state
windowWidth = passedWindowWidth;
windowHeight = passedWindowHeight;
//std::cout << "InputComponent::resize - boxShader: " << useBoxShader << " boundToPage: " << boundToPage << std::endl;
/*
if (!boundToPage) {
// ok because box shader is anchored to the bottom of the screen
@ -225,20 +223,20 @@ void InputComponent::resize(const int passedWindowWidth, const int passedWindowH @@ -225,20 +223,20 @@ void InputComponent::resize(const int passedWindowWidth, const int passedWindowH
lastRenderedWindowHeight = windowHeight;
}
*/
// turning this off breaks coordinates
//boundToPage = true;
/*
useBoxShader = true;
for (int i = 0; i < 3; i++) {
data[0][0][i] = 0xf0; // set RGB color
}
data[0][0][3] = 0xff; // set alpha
*/
//std::cout << "InputComponent::resize - placing box at " << (int)x << "," << (int)y << " size: " << (int)width << "x" << (int)height << std::endl;
float vx = x;
float vy = y;
if (this->boundToPage) {
@ -246,37 +244,37 @@ void InputComponent::resize(const int passedWindowWidth, const int passedWindowH @@ -246,37 +244,37 @@ void InputComponent::resize(const int passedWindowWidth, const int passedWindowH
//std::cout << "InputComponent::resize - Adjust y to " << vy << " from " << y << " h: " << (int)height << std::endl;
}
pointToViewport(vx, vy);
float vWidth = width;
float vHeight = height;
distanceToViewport(vWidth, vHeight);
float vx1 = vx + vWidth;
float vy1 = vy + vHeight;
//std::cout << "InputComponent::resize - placing box at GL " << vx << "," << vy << " to " << vx1 << "," << vy1 << " size: " << vWidth << "x" << vHeight << std::endl;
vertices[(0 * 5) + 0] = vx;
vertices[(0 * 5) + 1] = vy1;
vertices[(1 * 5) + 0] = vx1;
vertices[(1 * 5) + 1] = vy1;
vertices[(2 * 5) + 0] = vx1;
vertices[(2 * 5) + 1] = vy;
vertices[(3 * 5) + 0] = vx;
vertices[(3 * 5) + 1] = vy;
glBindVertexArray(vertexArrayObject);
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObject);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glBindVertexArray(0); // protect what we created against any further modification
//updateText();
if (userInputText) {
// do we need updateText here?
userInputText->resize(passedWindowWidth, passedWindowHeight);
}
}
@ -418,7 +416,7 @@ void InputComponent::updateCursor(int mX, int mY) { @@ -418,7 +416,7 @@ void InputComponent::updateCursor(int mX, int mY) {
//if (pos < this->text.getValue().size()) {
//std::cout << "InputComponent::updateCursor - Cursor at " << this->cursorCharX << "," << this->cursorCharY << " " << this->value.at(pos) << std::endl;
//}
const std::shared_ptr<TextRasterizer> textRasterizer = rasterizerCache->loadFont(12, false); // fontSize, bold
rasterizationRequest request;
//request.text = text.getValue().substr(0, pos);
@ -437,7 +435,7 @@ void InputComponent::updateCursor(int mX, int mY) { @@ -437,7 +435,7 @@ void InputComponent::updateCursor(int mX, int mY) {
//std::cout << "InputComponent::updateCursor - response at [" << textInfo->endingX << "," << textInfo->endingY << "]" << std::endl;
int textEndingX = textInfo->endingX;
int textEndingY = textInfo->endingY;
// adjust text crop
//std::cout << "c.endingY: " << textInfo->endingY << " c.y:" << endingY << "" << std::endl;
this->textCropX = std::max(textInfo->endingX, static_cast<int>(this->width));
@ -445,7 +443,7 @@ void InputComponent::updateCursor(int mX, int mY) { @@ -445,7 +443,7 @@ void InputComponent::updateCursor(int mX, int mY) {
this->textScrollY = 0; // reset scroll
//this->cursorStartAtX = textInfo->endingX;
//this->cursorStartAtY = textInfo->endingY;
// adjust our scroll
//std::cout << "cursor height" << (int)textInfo->height << " > " << (int)this->height << " (" << this->textScrollY << ")" << std::endl;
if (textInfo->height > this->height) {
@ -463,7 +461,7 @@ void InputComponent::updateCursor(int mX, int mY) { @@ -463,7 +461,7 @@ void InputComponent::updateCursor(int mX, int mY) {
}
//std::cout << "placing cursor at " << (int)cursorBox->x << "," << (int)cursorBox->y << std::endl;
cursorBox->resize(this->windowWidth, this->windowHeight);
// ok placement of the cursor may trigger the text to scroll and need to be re-rasterized
if (moved) {
/*
@ -482,7 +480,7 @@ void InputComponent::updateCursor(int mX, int mY) { @@ -482,7 +480,7 @@ void InputComponent::updateCursor(int mX, int mY) {
this->cursorLastX = this->cursorCharX;
this->cursorLastY = this->cursorCharY;
}
// if we move the cursor, redraw immediately
this->showCursor = true;
if (this->win) {
@ -492,7 +490,7 @@ void InputComponent::updateCursor(int mX, int mY) { @@ -492,7 +490,7 @@ void InputComponent::updateCursor(int mX, int mY) {
void InputComponent::updateText() {
//std::cout << "InputComponent::updateText - input value is now: " << this->text.getValue() << std::endl;
if (this->node) {
std::map<std::string, std::string>::iterator it = this->node->properties.find("value");
if (it == this->node->properties.end()) {
@ -501,7 +499,7 @@ void InputComponent::updateText() { @@ -501,7 +499,7 @@ void InputComponent::updateText() {
it->second = this->text.getValue();
}
}
//std::cout << "placed userInputText at " << static_cast<int>(x) << "," << static_cast<int>(y - windowHeight) << std::endl;
// 125 pixels width
// but first we need to know how wide the text is
@ -528,7 +526,7 @@ void InputComponent::updateText() { @@ -528,7 +526,7 @@ void InputComponent::updateText() {
//int estHeight = textInfo->height;
//this->cursorStartAtX = textInfo->endingX;
//this->cursorStartAtY = textInfo->endingY;
// if textHeight is bigger than window, adjust cursor too
/*
if (estHeight > this->height) {
@ -537,7 +535,7 @@ void InputComponent::updateText() { @@ -537,7 +535,7 @@ void InputComponent::updateText() {
}
*/
//this->updateCursor(0, 0);
// why does changing the width mess shit up?
//std::cout << "InputComponent::updateText - our width: " << static_cast<int>(width) << " windowWidth: " << windowWidth << std::endl;
if (this->win) {
@ -559,7 +557,7 @@ void InputComponent::updateText() { @@ -559,7 +557,7 @@ void InputComponent::updateText() {
userInputText->y = this->y - this->windowHeight + 16;
}
userInputText->boundToPage = this->boundToPage;
userInputText->rasterStartX = this->textScrollX;
userInputText->rasterStartY = this->textScrollY;
userInputText->rasterCropX = this->textCropX;
@ -594,8 +592,8 @@ void InputComponent::updateText() { @@ -594,8 +592,8 @@ void InputComponent::updateText() {
//std::cout << "InputComponent::updateText - textHeight: " << estHeight << " inputHeight: " << static_cast<int>(height) << " eY: " << textInfo->endingY << " y0max:" << textInfo->y0max << " rasterStartY: " << userInputText->rasterStartY << " lines: " << textInfo->lines << std::endl;
// don't wrap if multiLine, otherwise wrap
userInputText->noWrap = !this->multiLine;
userInputText->resize(this->windowWidth, this->windowHeight, this->width); // need to make sure there's a texture
this->win->renderDirty = true;
} // else it was called from cstr, and window isn't set up yet but no worrites, render will be dirty
}
}

4
src/interfaces/components/InputComponent.h

@ -5,8 +5,8 @@ @@ -5,8 +5,8 @@
#include <string>
#include "BoxComponent.h"
#include "TextComponent.h"
#include "../../scheduler.h"
#include "../../TextBlock.h"
#include "../../tools/TextBlock.h"
#include "../../tools/Scheduler.h"
class Window;

30
src/interfaces/components/MultiComponent.cpp

@ -8,27 +8,27 @@ @@ -8,27 +8,27 @@
#include "ImageComponent.h"
#include "../graphical/renderers/glfw/Shader.h"
#include "../../browser.h"
#include "../../app/browser/Browser.h"
#include <ctime>
extern std::unique_ptr<Browser> browser;
MultiComponent::MultiComponent(const float rawX, const float rawY, const float rawWidth, const float rawHeight, const int passedWindowWidth, const int passedWindowHeight) {
// take our space (for parent picking)
x = rawX;
y = rawY;
width = rawWidth;
height = rawHeight;
// not really needed but nothing else sets this
this->windowWidth = passedWindowWidth;
this->windowHeight = passedWindowHeight;
this->onResize=[this](int w, int h) {
this->resize(w, h);
};
// we need a mouseout to mouseout our hovercomponent
this->onMouseout=[this]() {
if (this->hoverComponent && this->hoverComponent->onMouseout) {
@ -37,7 +37,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r @@ -37,7 +37,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r
// select nothing
this->hoverComponent = nullptr;
};
this->onMousemove=[this](int passedX, int passedY) {
//std::cout << "MultiComponent::MultiComponent:onMousemove - at " << passedX << "," << passedY << std::endl;
if (this->cursorX == passedX && this->cursorY == passedY) {
@ -86,7 +86,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r @@ -86,7 +86,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r
this->hoverComponent->onFocus();
}
}
this->focusedComponent = this->hoverComponent;
if (this->focusedComponent && this->focusedComponent->onMouseup) {
//std::cout << "click event" << std::endl;
@ -111,7 +111,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r @@ -111,7 +111,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r
};
this->onWheel=[this](int passedX, int passedY) {
//std::cout << "MultiComponent::MultiComponent:onWheel " << passedX << "," << passedY << std::endl;
// if we're hovering over somethign
if (this->hoverComponent) {
// and it receives these messages
@ -146,7 +146,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r @@ -146,7 +146,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r
return;
}
*/
// allow address bar to hijack from relayKeyboardComponent
InputComponent *inputComponent = dynamic_cast<InputComponent*>(this->focusedComponent.get());
if (inputComponent) {
@ -184,7 +184,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r @@ -184,7 +184,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r
if (key == GLFW_KEY_BACKSLASH) key='|';
if (key == GLFW_KEY_RIGHT_BRACKET) key='}';
if (key == GLFW_KEY_GRAVE_ACCENT) key='~';
} else {
// no shift or caplocks
// basically: when SHIFT isn't pressed but key is in A-Z range, add ascii offset to make it lower case
@ -230,7 +230,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r @@ -230,7 +230,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r
}
if (key == GLFW_KEY_T && action == GLFW_RELEASE) {
browser->NextTheme();
}
}
if (relayKeyboardComponent->onKeyUp) {
relayKeyboardComponent->onKeyUp(key, scancode, action, mods);
return;
@ -281,7 +281,7 @@ void MultiComponent::updateMouse() { @@ -281,7 +281,7 @@ void MultiComponent::updateMouse() {
}
} else {
glfwSetCursor(this->win->window, this->win->cursorArrow);
}
}
}
void MultiComponent::resize(const int passedWindowWidth, const int passedWindowHeight) {
@ -312,7 +312,7 @@ void MultiComponent::resize(const int passedWindowWidth, const int passedWindowH @@ -312,7 +312,7 @@ void MultiComponent::resize(const int passedWindowWidth, const int passedWindowH
}
const std::clock_t end = clock();
std::cout << "MultiComponent::resize - resized layers in: " << std::fixed << ((static_cast<double>(end - begin)) / CLOCKS_PER_SEC) << std::scientific << " seconds" << std::endl;
//renderDirty = true;
// should we mark win->renderDirty = true?
if (this->win) {
@ -359,10 +359,10 @@ void MultiComponent::render() { @@ -359,10 +359,10 @@ void MultiComponent::render() {
this->renderComponentType("tab", layer);
textureShader->bind();
//std::cout << "MultiComponent::render - end Box components" << std::endl;
//textureShader->release(); // select no shader
// if we move text earlier, we can't put tab labels on top of the tab
// but we have layers now
fontShader->bind();

10
src/interfaces/components/TabbedComponent.h

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
#include "MultiComponent.h"
#include "TextComponent.h"
#include "../../BrowsingHistory.h"
#include "../../tools/BrowsingHistory.h"
struct Tab {
//std::string title;
@ -52,20 +52,20 @@ public: @@ -52,20 +52,20 @@ public:
std::shared_ptr<Tab> mpSelectedTab = nullptr; // we just want a pointer to where we want to go
// this sucks tbh, just phase it out
std::vector<std::shared_ptr<Tab>>::iterator selectedTab;
// was DocumentComponent but generalized to be more general (and compatible with Tab)
std::shared_ptr<Component> documentComponent = nullptr;
unsigned int tabAddColor = 0xF0F0F0FF;
unsigned int tabAddHoverColor = 0x008800FF;
unsigned int tabInactiveColor = 0x808080FF;
unsigned int tabHoverColor = 0x8888BBFF;
unsigned int tabActiveColor = 0xE0E0E0FF;
unsigned int tabTextColor = 0x000000FF;
unsigned int tabTextHoverColor = 0x008888FF;
unsigned int tabCloseColor = 0x222222FF;
unsigned int tabCloseHoverColor = 0x880000FF;
};

2
src/interfaces/elements/AElement.cpp

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#include "AElement.h"
#include "../../parsers/markup/TagNode.h"
#include <iostream>
#include "../../browser.h"
#include "../../app/browser/Browser.h"
extern const std::unique_ptr<Browser> browser;

14
src/interfaces/elements/BUTTONElement.cpp

@ -3,9 +3,9 @@ @@ -3,9 +3,9 @@
#include "../components/InputComponent.h"
#include "../components/ButtonComponent.h"
#include "../components/DocumentComponent.h"
#include "../../WebResource.h"
#include "../../Log.h"
#include "../../FormData.h"
#include "../../tools/WebResource.h"
#include "../../tools/Log.h"
#include "../../tools/FormData.h"
BUTTONElement::BUTTONElement() {
isInline = true;
@ -54,7 +54,7 @@ std::unique_ptr<Component> BUTTONElement::renderer(const ElementRenderRequest &r @@ -54,7 +54,7 @@ std::unique_ptr<Component> BUTTONElement::renderer(const ElementRenderRequest &r
method=formNodeMethodIter->second;
}
std::cout << "Form method is " << method << std::endl;
if (method=="POST" || method=="post") {
// need documentComponent
URL uAction = request.docComponent->currentURL.merge(URL(formNodeActionIter->second));
@ -64,7 +64,7 @@ std::unique_ptr<Component> BUTTONElement::renderer(const ElementRenderRequest &r @@ -64,7 +64,7 @@ std::unique_ptr<Component> BUTTONElement::renderer(const ElementRenderRequest &r
request.docComponent->handleResource(res, uAction.toString());
} else {
// need documentComponent
std::string queryString = "";
if (formData) {
// iterator over formData
@ -74,14 +74,14 @@ std::unique_ptr<Component> BUTTONElement::renderer(const ElementRenderRequest &r @@ -74,14 +74,14 @@ std::unique_ptr<Component> BUTTONElement::renderer(const ElementRenderRequest &r
// strip last & off
queryString = queryString.substr(0, queryString.size() - 1);
std::cout << "queryString is " << queryString << std::endl;
// The moral of the story is, if you have binary (non-alphanumeric) data (or a significantly sized payload) to transmit, use multipart/form-data
auto search = queryString.find(" ");
if (search != std::string::npos) {
queryString.replace(search, 1, "+");
}
}
URL uAction = request.docComponent->currentURL.merge(URL(formNodeActionIter->second+"?"+queryString));
std::cout << "Action URL is " << uAction.toString() << std::endl;
// download URL

14
src/interfaces/elements/INPUTElement.cpp

@ -2,9 +2,9 @@ @@ -2,9 +2,9 @@
#include "../components/InputComponent.h"
#include "../components/ButtonComponent.h"
#include "../components/DocumentComponent.h"
#include "../../Log.h"
#include "../../parsers/markup/html/HTMLParser.h"
#include "../../FormData.h"
#include "../../tools/Log.h"
#include "../../tools/FormData.h"
#include <ctime>
INPUTElement::INPUTElement() {
@ -55,28 +55,28 @@ std::unique_ptr<Component> INPUTElement::renderer(const ElementRenderRequest &re @@ -55,28 +55,28 @@ std::unique_ptr<Component> INPUTElement::renderer(const ElementRenderRequest &re
std::cout << "INPUTElement::renderer:butComponent->onClick - Can't find documentComponent for submit" << std::endl;
return;
}
TagNode *formTagNode = dynamic_cast<TagNode*>(formNode.get());
auto formNodeActionIter = formTagNode->properties.find("action");
if (formNodeActionIter == formTagNode->properties.end()) {
std::cout << "Form has no action" << std::endl;
return;
}
auto formNodeMethodIter = formTagNode->properties.find("method");
std::string method="GET";
if (formNodeMethodIter != formTagNode->properties.end()) {
method=formNodeMethodIter->second;
}
std::cout << "Form method is " << method << std::endl;
auto formData = buildFormData(formNode, nullptr);
// add our name/value (because we skip all submit buttons, there can only be one)
auto submitButtonNameValue = tagNode->getTagNodeNameValue();
if (submitButtonNameValue) {
formData->insert(*submitButtonNameValue);
}
if (method=="POST" || method=="post") {
// need documentComponent
URL uAction = request.docComponent->currentURL.merge(URL(formNodeActionIter->second));
@ -103,7 +103,7 @@ std::unique_ptr<Component> INPUTElement::renderer(const ElementRenderRequest &re @@ -103,7 +103,7 @@ std::unique_ptr<Component> INPUTElement::renderer(const ElementRenderRequest &re
queryString.replace(search, 1, "+");
}
}
URL uAction = request.docComponent->currentURL.merge(URL(formNodeActionIter->second+"?"+queryString));
std::cout << "Action URL is " << uAction.toString() << std::endl;
// download URL

6
src/interfaces/elements/SCRIPTElement.cpp