Browse Source

first update in a while

master
despair 2 years ago
parent
commit
448a61c1fe
6 changed files with 230 additions and 1081 deletions
  1. 4
    1
      NTMakefile
  2. 8
    0
      src/app.cpp
  3. 0
    1000
      src/graphics/opengl/TextWindow.cpp
  4. 0
    80
      src/graphics/opengl/TextWindow.h
  5. 169
    0
      src/win32-glob.c
  6. 49
    0
      src/win32-glob.h

+ 4
- 1
NTMakefile View File

@@ -83,7 +83,7 @@ netrunner.res.o: netrunner.rc
windres $^ -o $@
@rm favicon.ico
netrunner: $(OBJECTS) $(OBJDIR)/tlsf.o $(OBJDIR)/slre.o netrunner.res.o
netrunner: $(OBJECTS) $(OBJDIR)/tlsf.o $(OBJDIR)/slre.o $(OBJDIR)/win32-glob.o netrunner.res.o
$(LINK) $(LDFLAGS) -o $@ $^ $(LIBS)
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
@@ -95,6 +95,9 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
$(OBJDIR)/tlsf.o: $(SRCDIR)/tlsf.c
$(CC) $(INCPATH) $(CWARN) -DTLSF_USE_LOCKS=0 -DUSE_SBRK=1 -c -o $@ $<
$(OBJDIR)/win32-glob.o: $(SRCDIR)/win32-glob.c
$(CC) $(INCPATH) $(CWARN) -c -o $@ $<
$(OBJDIR)/slre.o: $(SRCDIR)/slre.c
$(CC) $(INCPATH) $(CWARN) -c -o $@ $<

+ 8
- 0
src/app.cpp View File

@@ -12,7 +12,11 @@
#include "interfaces/components/ButtonComponent.h"

#include <fstream>
#ifndef _WIN32
#include <glob.h>
#else
#include "win32-glob.h"
#endif

// why can't I const this?
std::unique_ptr<Scheduler> scheduler = std::make_unique<Scheduler>();
@@ -308,7 +312,11 @@ void App::transferTheme(std::string filename) {
void App::NextTheme() {
glob_t glob_result;
static unsigned int t = 0;
#ifndef _WIN32
glob("*.ntrml", GLOB_TILDE, nullptr, &glob_result);
#else
glob("*.ntrml", GLOB_NOCHECK, nullptr, &glob_result);
#endif
t++;
if (t == glob_result.gl_pathc) t = 0;
/*

+ 0
- 1000
src/graphics/opengl/TextWindow.cpp
File diff suppressed because it is too large
View File


+ 0
- 80
src/graphics/opengl/TextWindow.h View File

@@ -1,80 +0,0 @@
#ifndef TEXTWINDOW_H
#define TEXTWINDOW_H

#include "../components/ComponentBuilder.h"
#include "../components/Component.h"
#include "ShaderLoader.h"
#include "../../html/Node.h"
#include "Window.h"
#include <memory>
#include <vector>
#include <algorithm>
#include "../../networking/HTTPResponse.h"
#include "../../URL.h"

class TextWindow : public Window {
private:
public:
~TextWindow();
bool init();

void render();
void setDOM(const std::shared_ptr<Node> rootNode);
void createComponentTree(const std::shared_ptr<Node> rootNode, const std::shared_ptr<Component> &parentComponent);
void renderComponentType(std::string str, std::shared_ptr<Component> component);

void onResize(int passedWidth, int passedHeight);
void checkForResize();
void resize();
void resizeComponentTree(const std::shared_ptr<Component> &component, const int windowWidth, const int windowHeight);
std::shared_ptr<Component> searchComponentTree(const std::shared_ptr<Component> &component, const int x, const int y);
void navTo(std::string url);

// properties
int maxTextureSize = 0;
float transformMatrix[16] = {
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
};
bool transformMatrixDirty = true;
GLFWwindow *window;
int windowWidth;
int windowHeight;
//std::shared_ptr<Node> domRootNode = nullptr;
bool domDirty = false;
bool renderDirty = true;
ComponentBuilder componentBuilder;
std::shared_ptr<Component> rootComponent = std::make_shared<Component>();
// I hate doing this but we currently require this
std::shared_ptr<Component> tabComponent = nullptr;
std::shared_ptr<Component> addressComponent = nullptr;

// could break these out in some sort of cursor class
// to minimize dependencies
std::shared_ptr<Component> focusedComponent = nullptr;
std::shared_ptr<Component> hoverComponent = nullptr;
double cursorX = 0;
double cursorY = 0;
unsigned int delayResize = 0;
GLFWcursor* cursorHand;
GLFWcursor* cursorArrow;
GLFWcursor* cursorIbeam;
URL currentURL;
ShaderLoader shaderLoader;
// is there only one selection per window? (probably not)
int highlightStartX = 0;
int highlightStartY = 0;
std::vector<std::shared_ptr<Component>> selectionList;
};

bool setWindowContent(URL const& url);
void handleRequest(const HTTPResponse &response);

extern const std::unique_ptr<Window> window;

#endif

+ 169
- 0
src/win32-glob.c View File

@@ -0,0 +1,169 @@
/* libSoX minimal glob for MS-Windows: (c) 2009 SoX contributors
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "win32-glob.h"
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
typedef struct file_entry
{
char name[MAX_PATH];
struct file_entry *next;
} file_entry;
static int
insert(
const char* path,
const char* name,
file_entry** phead)
{
int len;
file_entry* cur = malloc(sizeof(file_entry));
if (!cur)
{
return ENOMEM;
}
len = _snprintf(cur->name, MAX_PATH, "%s%s", path, name);
cur->name[MAX_PATH - 1] = 0;
cur->next = *phead;
*phead = cur;
return len < 0 || len >= MAX_PATH ? ENAMETOOLONG : 0;
}
static int
entry_comparer(
const void* pv1,
const void* pv2)
{
const file_entry* const * pe1 = pv1;
const file_entry* const * pe2 = pv2;
return _stricmp((*pe1)->name, (*pe2)->name);
}
int
glob(
const char *pattern,
int flags,
void *unused,
glob_t *pglob)
{
char path[MAX_PATH];
file_entry *head = NULL;
int err = 0;
size_t len;
unsigned entries = 0;
WIN32_FIND_DATAA finddata;
HANDLE hfindfile = FindFirstFileA(pattern, &finddata);
if (!pattern || flags != (flags & GLOB_FLAGS) || unused || !pglob)
{
errno = EINVAL;
return EINVAL;
}
path[MAX_PATH - 1] = 0;
strncpy(path, pattern, MAX_PATH);
if (path[MAX_PATH - 1] != 0)
{
errno = ENAMETOOLONG;
return ENAMETOOLONG;
}
len = strlen(path);
while (len > 0 && path[len - 1] != '/' && path[len - 1] != '\\')
len--;
path[len] = 0;
if (hfindfile == INVALID_HANDLE_VALUE)
{
if (flags & GLOB_NOCHECK)
{
err = insert("", pattern, &head);
entries++;
}
}
else
{
do
{
err = insert(path, finddata.cFileName, &head);
entries++;
} while (!err && FindNextFileA(hfindfile, &finddata));
FindClose(hfindfile);
}
if (err == 0)
{
pglob->gl_pathv = malloc((entries + 1) * sizeof(char*));
if (pglob->gl_pathv)
{
pglob->gl_pathc = entries;
pglob->gl_pathv[entries] = NULL;
for (; head; head = head->next, entries--)
pglob->gl_pathv[entries - 1] = (char*)head;
qsort(pglob->gl_pathv, pglob->gl_pathc, sizeof(char*), entry_comparer);
}
else
{
pglob->gl_pathc = 0;
err = ENOMEM;
}
}
else if (pglob)
{
pglob->gl_pathc = 0;
pglob->gl_pathv = NULL;
}
if (err)
{
file_entry *cur;
while (head)
{
cur = head;
head = head->next;
free(cur);
}
errno = err;
}
return err;
}
void
globfree(
glob_t* pglob)
{
if (pglob)
{
char** cur;
for (cur = pglob->gl_pathv; *cur; cur++)
{
free(*cur);
}
pglob->gl_pathc = 0;
pglob->gl_pathv = NULL;
}
}

+ 49
- 0
src/win32-glob.h View File

@@ -0,0 +1,49 @@
/* libSoX minimal glob for MS-Windows: (c) 2009 SoX contributors
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef GLOB_H
#define GLOB_H 1
#define GLOB_NOCHECK (16)
#define GLOB_FLAGS (GLOB_NOCHECK)
typedef struct glob_t
{
unsigned gl_pathc;
char **gl_pathv;
} glob_t;
#ifdef __cplusplus
extern "C" {
#endif
int
glob(
const char *pattern,
int flags,
void *unused,
glob_t *pglob);
void
globfree(
glob_t* pglob);
#ifdef __cplusplus
}
#endif
#endif /* ifndef GLOB_H */

Loading…
Cancel
Save