diff --git a/CMakeLists.txt b/CMakeLists.txt index 4830139..e78f504 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ # and include sub-projects here. # cmake_minimum_required (VERSION 3.8) +set(CMAKE_CXX_STANDARD 17) project ("ComplexPlotting") diff --git a/ComplexPlotting/CMakeLists.txt b/ComplexPlotting/CMakeLists.txt index bf7fa2e..cf07efe 100644 --- a/ComplexPlotting/CMakeLists.txt +++ b/ComplexPlotting/CMakeLists.txt @@ -14,7 +14,7 @@ endif() # Add source to this project's executable. add_executable (ComplexPlotting "main.cpp" -) + "PlotWindow.hpp" "PlotWindow.cpp" "PlotWindowFactory.hpp" "PlotWindowManager.hpp") target_include_directories(ComplexPlotting PRIVATE ${SDL2_INCLUDES} diff --git a/ComplexPlotting/PlotWindow.cpp b/ComplexPlotting/PlotWindow.cpp new file mode 100644 index 0000000..381042d --- /dev/null +++ b/ComplexPlotting/PlotWindow.cpp @@ -0,0 +1,33 @@ +#include "PlotWindow.hpp" + +PlotWindow::PlotWindow(std::string title) : + IWindow::IWindow( + UnitVector2u * 400, + UnitVector2i * SDL_WINDOWPOS_UNDEFINED, + title, + NULL) +{ +} + +void PlotWindow::OnEvent(const SDL_Event& e) +{ + if (e.window.windowID != m_uWindowID) + return; + + switch (e.window.type) + { + case SDL_WINDOWEVENT_CLOSE: + m_isWindowOpen = false; + break; + } +} + +bool PlotWindow::OnUpdate(double frametime) +{ + return false; +} + +void PlotWindow::OnRender(SDL_Renderer* renderer) +{ + return; +} diff --git a/ComplexPlotting/PlotWindow.hpp b/ComplexPlotting/PlotWindow.hpp new file mode 100644 index 0000000..ca1872c --- /dev/null +++ b/ComplexPlotting/PlotWindow.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include + +#include "Window.hpp" + +using namespace sf; + +class PlotWindow : + public IWindow +{ +public: + PlotWindow(std::string title); + + void OnEvent(const SDL_Event& e) override; + bool OnUpdate(double frametime) override; + void OnRender(SDL_Renderer* renderer) override; + +private: +}; \ No newline at end of file diff --git a/ComplexPlotting/PlotWindowManager.hpp b/ComplexPlotting/PlotWindowManager.hpp new file mode 100644 index 0000000..44f4326 --- /dev/null +++ b/ComplexPlotting/PlotWindowManager.hpp @@ -0,0 +1,26 @@ +#include "PlotWindow.hpp" + +#include + +class PlotWindowManager +{ +public: + PlotWindowManager() = delete; + PlotWindowManager& operator=(const PlotWindowManager& other) = delete; + + static void MakeNew() + { + PlotWindows.emplace_back("Plot " + std::to_string(PlotWindowCount)); + PlotWindowCount++; + } + + static void HandleEvents() + { + for(auto plot : PlotWIndows) + + } + +private: + static inline Uint32 PlotWindowCount; + static std::vector PlotWindows; +}; \ No newline at end of file diff --git a/ComplexPlotting/main.cpp b/ComplexPlotting/main.cpp index 42f17a6..aab2ab1 100644 --- a/ComplexPlotting/main.cpp +++ b/ComplexPlotting/main.cpp @@ -1,5 +1,8 @@ #include +#include + #include +#include "PlotWindow.hpp" #undef main @@ -7,5 +10,28 @@ int main(int argc, char** argv) { printf("Running on SDL %i.%i.%i\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL); + SDL_Init(SDL_INIT_VIDEO); + + // Create and open some windows + PlotWindow window("Plot"); + + // Wait for window processes to end + SDL_Event e; + bool quit = false; + while (!quit) + { + while (SDL_PollEvent(&e)) + { + if (e.type == SDL_QUIT) + quit = true; + + window.OnEvent(e); + } + + window.OnUpdate(0); + + window.OnRender(nullptr); + } + return 0; } \ No newline at end of file