This commit is contained in:
Ilusha 2024-03-19 20:17:47 +03:00
parent 29280949a8
commit 752243c7e9
7 changed files with 40 additions and 40 deletions

View file

@ -1,6 +1,5 @@
#include "GraphicApplication.hpp" #include "GraphicApplication.hpp"
#include "imgui.h" #include "imgui.h"
using namespace tp; using namespace tp;
@ -22,6 +21,18 @@ public:
}; };
int main() { int main() {
ExampleApplication app;
app.run(); ModuleManifest* deps[] = { &gModuleGraphics, nullptr };
ModuleManifest module("Eample", nullptr, nullptr, deps);
if (!module.initialize()) {
return 1;
}
{
ExampleApplication app;
app.run();
}
module.deinitialize();
} }

View file

@ -3,11 +3,7 @@
using namespace tp; using namespace tp;
Application::Application() : Application::Application() {
mApplicationModule("Application", nullptr, nullptr, mModuleDeps) {
mInitialized = mApplicationModule.initialize();
if (!mInitialized) return;
mWindow = Window::createWindow(); mWindow = Window::createWindow();
mDrawTimer.setDuration(1000.f / mDrawPerSecond); mDrawTimer.setDuration(1000.f / mDrawPerSecond);
@ -83,7 +79,5 @@ void Application::drawFrame(Canvas* canvas) {
} }
Application::~Application() { Application::~Application() {
if (!mInitialized) return;
Window::destroyWindow(mWindow); Window::destroyWindow(mWindow);
mApplicationModule.deinitialize();
} }

View file

@ -18,9 +18,6 @@ namespace tp {
virtual ~Application(); virtual ~Application();
protected: protected:
ModuleManifest* mModuleDeps[2] = { &gModuleGraphics, nullptr };
ModuleManifest mApplicationModule;
Window* mWindow = nullptr; Window* mWindow = nullptr;
bool mInitialized = false; bool mInitialized = false;

View file

@ -6,7 +6,7 @@ file(GLOB HEADERS "./public/*.hpp")
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
target_include_directories(${PROJECT_NAME} PUBLIC ./public/) target_include_directories(${PROJECT_NAME} PUBLIC ./public/)
target_link_libraries(${PROJECT_NAME} PUBLIC Math Strings) target_link_libraries(${PROJECT_NAME} PUBLIC Math Graphics Strings)
### -------------------------- Tests -------------------------- ### ### -------------------------- Tests -------------------------- ###
enable_testing() enable_testing()

View file

@ -1,32 +1,29 @@
#include "ExampleGUI.hpp" #include "ExampleGUI.hpp"
#include "Graphics.hpp" #include "GraphicApplication.hpp"
using namespace tp; using namespace tp;
void runApp() { class ExampleGUI : public Application {
auto window = tp::Window::createWindow({ 800, 600 }, "Window 1"); public:
ExampleGUI() {
tp::ComplexWidget<tp::EventHandler, tp::Canvas> gui; gGlobalGUIConfig = &mConfig;
if (window) {
while (!window->shouldClose()) {
window->processEvents();
auto area = window->getCanvas().getAvaliableArea();
gui.proc(window->getEvents(), {}, { area.x, area.y, area.z, area.w });
gui.draw(window->getCanvas());
tp::sleep(20);
window->draw();
}
} }
tp::Window::destroyWindow(window); void processFrame(EventHandler* eventHandler) override {
} auto rec = RectF( { 0, 0 }, mWindow->getSize() );
mGui.proc(*eventHandler, rec, rec);
}
void drawFrame(Canvas* canvas) override {
mGui.draw(*canvas);
}
private:
GlobalGUIConfig mConfig;
ComplexWidget<EventHandler, Canvas> mGui;
};
int main() { int main() {
@ -38,9 +35,8 @@ int main() {
} }
{ {
tp::GlobalGUIConfig config; ExampleGUI gui;
tp::gGlobalGUIConfig = &config; gui.run();
runApp();
} }
binModule.deinitialize(); binModule.deinitialize();

View file

@ -23,9 +23,9 @@ namespace tp {
return; return;
} }
mIsHover = getHandle().isInside(events.getPos()); mIsHover = getHandle().isInside(events.getPointer());
if (events.isPressed() && mIsHover) { if (events.isPressed(InputID::MOUSE1) && mIsHover) {
mResizeInProcess = true; mResizeInProcess = true;
} else if (!events.isDown()) { } else if (!events.isDown()) {
mResizeInProcess = false; mResizeInProcess = false;

View file

@ -5,6 +5,8 @@
#include "Rect.hpp" #include "Rect.hpp"
#include "Strings.hpp" #include "Strings.hpp"
#include "InputCodes.hpp"
namespace tp { namespace tp {
extern ModuleManifest gModuleWidgets; extern ModuleManifest gModuleWidgets;