Adding objects GUI initial. Changing TODO. Some fixes along side
This commit is contained in:
parent
f9d62c324d
commit
112fea2f04
18 changed files with 1345 additions and 56 deletions
|
|
@ -7,7 +7,7 @@ project(Objects)
|
|||
|
||||
### ---------------------- Static Library --------------------- ###
|
||||
file(GLOB SOURCES "./private/*.cpp" "./private/*/*.cpp")
|
||||
file(GLOB HEADERS "./public/*.hpp" "./public/*/*.hpp")
|
||||
file(GLOB HEADERS "./public/*.hpp" "./public/*/*.hpp" "./applications/*.hpp")
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
||||
|
||||
|
|
@ -17,9 +17,11 @@ target_link_libraries(${PROJECT_NAME} PUBLIC Strings Math Tokenizer CommandLine
|
|||
### -------------------------- Applications -------------------------- ###
|
||||
#add_executable(osc ./applications/Compiler.cpp)
|
||||
#add_executable(osi ./applications/Interpreter.cpp)
|
||||
add_executable(osg ./applications/GUI.cpp ./applications/GUIEntry.cpp)
|
||||
|
||||
#target_link_libraries(osc ${PROJECT_NAME})
|
||||
#target_link_libraries(osi ${PROJECT_NAME})
|
||||
target_link_libraries(osg ${PROJECT_NAME} Graphics Imgui)
|
||||
|
||||
### -------------------------- Tests -------------------------- ###
|
||||
enable_testing()
|
||||
|
|
|
|||
1109
Objects/applications/GUI.cpp
Normal file
1109
Objects/applications/GUI.cpp
Normal file
File diff suppressed because it is too large
Load diff
73
Objects/applications/GUI.h
Normal file
73
Objects/applications/GUI.h
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "primitives/primitives.h"
|
||||
#include "primitives//interpreterobject.h"
|
||||
|
||||
#include "compiler/function.h"
|
||||
|
||||
#include "strings.h"
|
||||
|
||||
namespace obj {
|
||||
|
||||
class ObjectsGUI {
|
||||
|
||||
enum { MAX_NAME_LENGHT = 102 };
|
||||
char mNameEdit [MAX_NAME_LENGHT];
|
||||
obj::Object* mLastNameEditObject = NULL;
|
||||
|
||||
struct ViewStackNode {
|
||||
obj::Object* obj;
|
||||
tp::String id;
|
||||
ViewStackNode() { obj = NULL; }
|
||||
ViewStackNode(obj::Object* obj, tp::String id) : obj(obj), id(id) {}
|
||||
operator bool() { return obj; }
|
||||
};
|
||||
|
||||
tp::List<ViewStackNode> mViewStack;
|
||||
obj::Object* mRoot = NULL;
|
||||
obj::Object* mActive = NULL;
|
||||
obj::Object* mClipboard = NULL;
|
||||
|
||||
void setClipboard(obj::Object*);
|
||||
obj::Object* getClipboard();
|
||||
|
||||
void* mImGuiCtx = NULL;
|
||||
|
||||
public:
|
||||
|
||||
bool mShowDebugInfo = true;
|
||||
bool mCaptureInput = false;
|
||||
|
||||
ObjectsGUI();
|
||||
~ObjectsGUI();
|
||||
|
||||
void cd(obj::Object* child, tp::String name);
|
||||
void cdup();
|
||||
|
||||
void clearEvents();
|
||||
|
||||
void draw();
|
||||
void explorer();
|
||||
void properties(const obj::ObjectType*, bool top_of_tree_vew = true);
|
||||
void drawFps();
|
||||
private:
|
||||
|
||||
void preview(obj::Object* obj);
|
||||
ViewStackNode enumView(obj::EnumObject* obj);
|
||||
ViewStackNode boolView(obj::BoolObject* obj);
|
||||
ViewStackNode floatView(obj::FloatObject* obj);
|
||||
ViewStackNode nullView(obj::NullObject* obj);
|
||||
ViewStackNode linkoView(obj::LinkObject* obj);
|
||||
ViewStackNode intoView(obj::IntObject* obj);
|
||||
ViewStackNode dictView(obj::DictObject* obj);
|
||||
ViewStackNode listView(obj::ListObject* obj);
|
||||
ViewStackNode stringView(obj::StringObject* in);
|
||||
ViewStackNode classView(obj::ClassObject* in);
|
||||
ViewStackNode methodView(obj::MethodObject* in);
|
||||
ViewStackNode colorView(obj::ColorObject* in);
|
||||
ViewStackNode interpreterView(obj::InterpreterObject* in);
|
||||
void dictViewEdit(obj::DictObject* dict, tp::String item_id, obj::Object* obj, bool& popup);
|
||||
void dictViewDrawCreate(obj::DictObject* dict);
|
||||
};
|
||||
};
|
||||
50
Objects/applications/GUIEntry.cpp
Normal file
50
Objects/applications/GUIEntry.cpp
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
#include "Window.hpp"
|
||||
|
||||
#include "GUI.h"
|
||||
|
||||
using namespace tp;
|
||||
using namespace obj;
|
||||
|
||||
class GUIWindow {
|
||||
Window* window;
|
||||
ObjectsGUI gui;
|
||||
|
||||
public:
|
||||
GUIWindow() {
|
||||
tp::HeapAllocGlobal::startIgnore();
|
||||
window = Window::createWindow(1500, 900, "Objects GUI");
|
||||
tp::HeapAllocGlobal::stopIgnore();
|
||||
|
||||
gui.cd(NDO->create("dict"), "root");
|
||||
}
|
||||
|
||||
void run() {
|
||||
while (!window->shouldClose()) {
|
||||
window->processEvents();
|
||||
gui.draw();
|
||||
window->draw();
|
||||
}
|
||||
}
|
||||
|
||||
~GUIWindow() {
|
||||
Window::destroyWindow(window);
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
|
||||
tp::ModuleManifest* deps[] = { &gModuleObjects, &gModuleGraphics, nullptr };
|
||||
tp::ModuleManifest module("ObjectsTests", nullptr, nullptr, deps);
|
||||
|
||||
if (module.initialize()) {
|
||||
{
|
||||
GUIWindow window;
|
||||
window.run();
|
||||
}
|
||||
module.deinitialize();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue