summaryrefslogtreecommitdiffhomepage
path: root/main/app.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-13 12:13:56 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-13 12:13:56 +0200
commit67897701316d83495aed4baa94e96c9f84b818f8 (patch)
treec359b956e15b2cd9f9f36fe72b3c3cbe2297cac7 /main/app.cpp
parent713e473b65963ec6ca1b1eb185c297852fa336ea (diff)
a
Diffstat (limited to 'main/app.cpp')
-rw-r--r--main/app.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/main/app.cpp b/main/app.cpp
index cc5dbe78..ffebcc35 100644
--- a/main/app.cpp
+++ b/main/app.cpp
@@ -1,5 +1,9 @@
+#include <cstddef>
#include "app.hpp"
#include "compat/fpu.hpp"
+#include <Magnum/GL/DefaultFramebuffer.h>
+#include <Magnum/ImGuiIntegration/Context.h>
+#include <Magnum/ImGuiIntegration/Context.hpp>
namespace floormat {
@@ -18,8 +22,49 @@ app::app(const Arguments& arguments):
set_fp_mask();
reset_camera_offset();
update_window_scale(windowSize());
+ setMinimalLoopPeriod(5);
+ _imgui = ImGuiIntegration::Context(Vector2{windowSize()}/dpiScaling(), windowSize(), framebufferSize());
+ setup_menu();
timeline.start();
}
+void app::viewportEvent(Platform::Sdl2Application::ViewportEvent& event)
+{
+ update_window_scale(event.windowSize());
+ GL::defaultFramebuffer.setViewport({{}, event.windowSize()});
+ _imgui.relayout(Vector2{event.windowSize()}/event.dpiScaling(),
+ event.windowSize(), event.framebufferSize());
+}
+
+
+void app::mousePressEvent(Platform::Sdl2Application::MouseEvent& event)
+{
+ if (_imgui.handleMousePressEvent(event))
+ return event.setAccepted();
+}
+
+void app::mouseReleaseEvent(Platform::Sdl2Application::MouseEvent& event)
+{
+ if (_imgui.handleMouseReleaseEvent(event))
+ return event.setAccepted();
+}
+
+void app::mouseMoveEvent(Platform::Sdl2Application::MouseMoveEvent& event)
+{
+ if (_imgui.handleMouseMoveEvent(event))
+ return event.setAccepted();
+}
+
+void app::mouseScrollEvent(Platform::Sdl2Application::MouseScrollEvent& event)
+{
+ if (_imgui.handleMouseScrollEvent(event))
+ return event.setAccepted();
+}
+
+void app::textInputEvent(Platform::Sdl2Application::TextInputEvent& event)
+{
+ if (_imgui.handleTextInputEvent(event))
+ return event.setAccepted();
+}
void app::update(float dt)
{