diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 14b39c6..8a66075 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,12 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR) add_executable(tomato main.cpp icon.rc + + screen.hpp + start_screen.hpp + start_screen.cpp + main_screen.hpp + main_screen.cpp ) target_compile_features(tomato PUBLIC cxx_std_17) diff --git a/src/main.cpp b/src/main.cpp index 5ec945f..d4472bd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,6 +7,8 @@ #include "./theme.hpp" +#include "./start_screen.hpp" + #include #include #include @@ -50,6 +52,8 @@ int main(int argc, char** argv) { ImGui_ImplSDLRenderer3_Init(renderer.get()); auto imgui_sdlrenderer_scope = std::async(std::launch::deferred, &ImGui_ImplSDLRenderer3_Shutdown); + std::unique_ptr screen = std::make_unique(); + bool quit = false; while (!quit) { SDL_Event event; @@ -68,7 +72,12 @@ int main(int argc, char** argv) { ImGui_ImplSDL3_NewFrame(); ImGui::NewFrame(); - ImGui::ShowDemoWindow(); + //ImGui::ShowDemoWindow(); + + Screen* ret_screen = screen->poll(quit); + if (ret_screen != nullptr) { + screen.reset(ret_screen); + } ImGui::Render(); ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData()); diff --git a/src/main_screen.cpp b/src/main_screen.cpp new file mode 100644 index 0000000..5b35205 --- /dev/null +++ b/src/main_screen.cpp @@ -0,0 +1,17 @@ +#include "./main_screen.hpp" + +#include + +#include + +MainScreen::MainScreen(std::string save_path) { +} + +Screen* MainScreen::poll(bool& quit) { + bool open = !quit; + ImGui::ShowDemoWindow(&open); + quit = !open; + + return nullptr; +} + diff --git a/src/main_screen.hpp b/src/main_screen.hpp new file mode 100644 index 0000000..e4f5448 --- /dev/null +++ b/src/main_screen.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include "./screen.hpp" + +#include + +struct MainScreen final : public Screen { + MainScreen(std::string save_path); + ~MainScreen(void) = default; + + // return nullptr if not next + // sets bool quit to true if exit + Screen* poll(bool&) override; +}; + diff --git a/src/screen.hpp b/src/screen.hpp new file mode 100644 index 0000000..c48d9d1 --- /dev/null +++ b/src/screen.hpp @@ -0,0 +1,10 @@ +#pragma once + +struct Screen { + virtual ~Screen(void) = default; + + // return nullptr if not next + // sets bool quit to true if exit + virtual Screen* poll(bool& quit) = 0; +}; + diff --git a/src/start_screen.cpp b/src/start_screen.cpp new file mode 100644 index 0000000..35efbd5 --- /dev/null +++ b/src/start_screen.cpp @@ -0,0 +1,23 @@ +#include "./start_screen.hpp" + +#include "./main_screen.hpp" + +#include + +StartScreen::StartScreen(void) { +} + +Screen* StartScreen::poll(bool&) { + + // TODO: imgui tox profile selector? + // +------------------------ + // | +------+ +-------- + // | | ICON | | fileselector/dropdown? + // | | | | password input + // | +------+ +-------- + // +------------------------ + + auto new_screen = std::make_unique("tomato.tox"); + return new_screen.release(); +} + diff --git a/src/start_screen.hpp b/src/start_screen.hpp new file mode 100644 index 0000000..632feac --- /dev/null +++ b/src/start_screen.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "./screen.hpp" + +struct StartScreen final : public Screen { + StartScreen(void); + ~StartScreen(void) = default; + + // return nullptr if not next + // sets bool quit to true if exit + Screen* poll(bool&) override; +}; +