diff --git a/CMakeLists.txt b/CMakeLists.txt index 13a3cc2..255c47b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,6 +121,8 @@ add_executable(${GUI_TARGET_NAME} ${SVA_GUI_FILES} ) +source_group(TREE ${PROJECT_SOURCE_DIR}/src/ PREFIX "Source" FILES ${SVA_GUI_FILES}) + # --------------- # RAYLIB # --------------- @@ -209,4 +211,5 @@ if(${SVA_CREATE_INCLUDES_TARGET}) SOURCES ${INCLUDE_FILES} ) + source_group(TREE ${PROJECT_SOURCE_DIR}/include/ PREFIX "Source" FILES ${INCLUDE_FILES}) endif() diff --git a/include/Profiling/Timer.hpp b/include/Profiling/Timer.hpp index 30094e9..ac5c36f 100644 --- a/include/Profiling/Timer.hpp +++ b/include/Profiling/Timer.hpp @@ -3,6 +3,7 @@ #include #include #include +#include struct timer_result { @@ -17,12 +18,12 @@ struct Timer { paused = 1 }; State state = paused; - + std::clock_t begin; std::clock_t elapsed = 0; std::optional out; std::optional result; - + Timer() : begin(std::clock()) {} Timer(std::ostream& o) : begin(std::clock()), out(&o) {} Timer(timer_result& r) : begin(std::clock()), result(&r) {} @@ -43,7 +44,7 @@ struct Timer { if (state == paused) begin = 0; } - + Timer(std::ostream& o, timer_result& r, State initial_state) : state(initial_state), begin(std::clock()), out(&o), result(&r) { if (state == paused) @@ -99,7 +100,7 @@ struct Timer { *out.value() << "Total time = " << static_cast(total_time) / CLOCKS_PER_SEC << std::endl; } } - + ~Timer() { lap(); } diff --git a/src/Components/BigSortComponent.cpp b/src/Components/BigSortComponent.cpp new file mode 100644 index 0000000..eda8339 --- /dev/null +++ b/src/Components/BigSortComponent.cpp @@ -0,0 +1,129 @@ +#include "BigSortComponent.hpp" +#include +#include "raylibs/raygui.h" + +BigSortComponent::BigSortComponent() : m_Sorter(2000) +{ + +} + + +int BigSortComponent::draw() +{ + // raygui: controls drawing + //---------------------------------------------------------------------------------- + if (m_FunctionDropdown_EditMode) + GuiLock(); + + GuiGroupBox({ anchor01.x + 0, anchor01.y + 8, 456, 304 }, "Run Sorting"); + { + if (GuiTextBox({ anchor02.x + 8, anchor02.y + 8, 216, 24 }, m_FunctionTextBox_Text, 128, m_FunctionTextBox_EditMode)) m_FunctionTextBox_EditMode = !m_FunctionTextBox_EditMode; + + + GuiGroupBox({ anchor02.x + 0, anchor02.y + 0, 232, 72 }, "Add & Check Function"); + { + if (GuiButton({ anchor02.x + 72, anchor02.y + 40, 72, 24 }, "Check")) + { + // FATAL: asserts + sol::optional func = m_LuaState[m_FunctionTextBox_Text]; + if (!func) + { + m_ErrorWindow.error("Function does not exits", "A function was selected, that does not exist."); + // TODO: formating works differently + spdlog::error("BigSortComponent: Function does not exist %s", m_FunctionTextBox_Text); + repack_function_list(); + } + } + + if (GuiButton({ anchor02.x + 152, anchor02.y + 40, 72, 24 }, "Add")) + { + // TODO: Check for validity + add_function(m_FunctionTextBox_Text); + } + } + + if (GuiButton({ anchor01.x + 8, anchor01.y + 48, 56, 24 }, "Run")) + { + // TODO: Run Test + } + + GuiLine({ anchor01.x + 8, anchor01.y + 96, 440, 12 }, nullptr); + + // TODO: format infos into strings; + GuiLabel({ anchor01.x + 8, anchor01.y + 176, 144, 24 }, "Is Sorted: "); + GuiLabel({ anchor01.x + 8, anchor01.y + 200, 144, 24 }, "Time elapsed: : "); + GuiGroupBox({ anchor03.x + 0, anchor03.y + 0, 288, 104 }, "Calls"); + GuiLabel({ anchor03.x + 8, anchor03.y + 8, 120, 24 }, "Swap: "); + GuiLabel({ anchor03.x + 8, anchor03.y + 32, 120, 24 }, "Size: "); + GuiLabel({ anchor03.x + 136, anchor03.y + 8, 120, 24 }, "Greater: "); + GuiLabel({ anchor03.x + 136, anchor03.y + 32, 120, 24 }, "Lesser: "); + GuiLabel({ anchor03.x + 136, anchor03.y + 56, 120, 24 }, "Equal: "); + GuiLabel({ anchor01.x + 8, anchor01.y + 152, 144, 24 }, "Array size: "); + GuiLabel({ anchor01.x + 8, anchor01.y + 112, 144, 24 }, "Tests ran: "); + GuiLabel({ anchor01.x + 152, anchor01.y + 112, 144, 24 }, "Test number: "); + + if (GuiButton({ anchor01.x + 112, anchor01.y + 264, 88, 24 }, "Next")) + { + // TODO: implement Test result stack movement + } + if (GuiButton({ anchor01.x + 8, anchor01.y + 264, 88, 24 }, "Previous")) + { + // TODO: Display previous result + } + + if (GuiButton({ anchor01.x + 320, anchor01.y + 264, 120, 24 }, "Clear All Test")) + { + m_SortResults.clear(); + } + + if (GuiDropdownBox({ anchor01.x + 8, anchor01.y + 16, 184, 24 }, m_FunctionList.c_str(), &m_FunctionDropdown_Active, m_FunctionDropdown_EditMode)) m_FunctionDropdown_EditMode = !m_FunctionDropdown_EditMode; + } + GuiUnlock(); + //---------------------------------------------------------------------------------- + + return m_ErrorWindow.draw(); +} + +int BigSortComponent::input() +{ + return m_ErrorWindow.input(); +} + +void BigSortComponent::onAttach() +{ + sva::Sorter::setup(m_LuaState); + m_LuaState["list"] = m_Sorter; +} + +void BigSortComponent::run_test() +{ + std::string function_name = m_FunctionNames[m_FunctionDropdown_Active]; + spdlog::debug("%s: Running sorting function: %s", function_name.c_str(), function_name.c_str()); + m_SortResults.push_back(m_Sorter.run(m_LuaState[function_name])); + + if (!m_SortResults.back().is_sorted) + { + spdlog::debug("%s: Could not sort the array", function_name.c_str()); + } +} + +void BigSortComponent::add_function(const std::string& function_name) +{ + m_FunctionNames.push_back(function_name); + if (m_FunctionList.empty()) + { + m_FunctionList = function_name; + return; + } + m_FunctionList += ';' + function_name; +} + +void BigSortComponent::repack_function_list() +{ + m_FunctionList.clear(); + for (const auto& fn : m_FunctionNames) + { + m_FunctionList += fn + ';'; + } + m_FunctionList.pop_back(); +} \ No newline at end of file diff --git a/src/Components/BigSortComponent.hpp b/src/Components/BigSortComponent.hpp new file mode 100644 index 0000000..efef0b9 --- /dev/null +++ b/src/Components/BigSortComponent.hpp @@ -0,0 +1,48 @@ +#pragma once + +#include "../gui/GuiComponent.hpp" +#include "../Sorter.hpp" +#include +#include +#include "../gui/CoreComponents.hpp" + +class BigSortComponent : public sva::GuiComponent +{ + Vector2 m_ComponentOffset = { 0,0 }; + + // BigSortComponent: controls initialization + //---------------------------------------------------------------------------------- + Vector2 anchor01 = { 8, 8 }; + Vector2 anchor02 = { 224, 24 }; + Vector2 anchor03 = { 160, 152 }; + + bool m_FunctionDropdown_EditMode = false; + int m_FunctionDropdown_Active = 0; + + bool m_FunctionTextBox_EditMode = false; + char m_FunctionTextBox_Text[256] = "Name own Function"; + + sva::ErrorWindow m_ErrorWindow; + + //---------------------------------------------------------------------------------- +public: + BigSortComponent(); + + int draw() override; + int input() override; + void onAttach() override; + +private: + sol::state m_LuaState; + + std::vector m_FunctionNames; + std::string m_FunctionList; + + sva::Sorter m_Sorter; + std::vector m_SortResults; + sva::Sorter::SortResult* m_ActiveSortResult = nullptr; + + void run_test(); + void add_function(const std::string&); + void repack_function_list(); +}; \ No newline at end of file diff --git a/src/Components/SaveClosePopup.cpp b/src/Components/SaveClosePopup.cpp new file mode 100644 index 0000000..026684d --- /dev/null +++ b/src/Components/SaveClosePopup.cpp @@ -0,0 +1,83 @@ +#include "./SaveClosePopup.hpp" + +SafeClosePopup::~SafeClosePopup() +{ + CloseWindow(); +} + +void SafeClosePopup::onAttach() +{ + m_WindowOpen = false; +} + +int SafeClosePopup::draw() +{ + if (WindowShouldClose()) + { + if (m_WindowOpen) { + CloseWindow(); + } + else { + OpenWindow(); + } + onResize(); + } + + if (m_WindowOpen) + { + GuiUnlock(); + anchor03 = { .x = m_WndRect.x + 168, .y = m_WndRect.y + 88 }; + + m_WindowOpen = !GuiWindowBox(m_WndRect, "#191# Are you sure you want to close this program?"); + { // Drawing in different colours + int border_color = GuiGetStyle(DEFAULT, BORDER_COLOR_NORMAL); + int base_color = GuiGetStyle(DEFAULT, BASE_COLOR_NORMAL); + + GuiSetStyle(DEFAULT, BORDER_COLOR_NORMAL, 0x7192C2FF); + GuiSetStyle(DEFAULT, BASE_COLOR_NORMAL, 0xBBCDD3FF); + + m_CQB_YesButton = GuiButton({ anchor03.x + -152, anchor03.y + 32, 120, 24 }, "#112#Yes"); + + GuiSetStyle(DEFAULT, BORDER_COLOR_NORMAL, border_color); + GuiSetStyle(DEFAULT, BASE_COLOR_NORMAL, base_color); + } + m_CQB_NoButton = GuiButton({ anchor03.x + 24, anchor03.y + 32, 120, 24 }, "#113#No"); + GuiLabel({ anchor03.x + -104, anchor03.y + -40, 208, 24 }, "Are you sure you want to close this?"); + GuiLabel({ anchor03.x + -56, anchor03.y + -8, 120, 24 }, "Press \"Yes\" to close"); + if (m_CQB_YesButton) + { + *m_WndRunning = false; + return 1; + } + if (m_CQB_NoButton) CloseWindow(); + } + return 0; +} + +int SafeClosePopup::rinput(Vector2& mouse_position) +{ + if (IsKeyReleased(KEY_ENTER)) { + *m_WndRunning = false; + return 1; + } + GuiLock(); + return 0; +} + +void SafeClosePopup::onResize() +{ + anchor03 = { static_cast(m_WndWidth) / 2 , static_cast(m_WndHeight) / 2 }; + m_WndRect = { anchor03.x + -168, anchor03.y + -88, 328, 160 }; +} + +void SafeClosePopup::OpenWindow() +{ + GuiLock(); + m_WindowOpen = true; +} + +void SafeClosePopup::CloseWindow() +{ + m_WindowOpen = false; + GuiUnlock(); +} \ No newline at end of file diff --git a/src/Components/SaveClosePopup.hpp b/src/Components/SaveClosePopup.hpp new file mode 100644 index 0000000..e6cb99d --- /dev/null +++ b/src/Components/SaveClosePopup.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include "../gui/CoreComponents.hpp" + + + +/**************************************************** + * A "Are you sure you want to exit?" Window. + * + * Yes is default +****************************************************/ +class SafeClosePopup final : public sva::GuiMovableWindow +{ + Vector2 anchor03 = { 0,0 }; + + bool m_CQB_YesButton = false; + bool m_CQB_NoButton = false; + +public: + + ~SafeClosePopup() override; + + void onAttach() override; + + int draw() override; + + int rinput(Vector2& mouse_position) override; + + + void onResize() override; + +public: + void OpenWindow(); + + void CloseWindow(); +}; + diff --git a/src/Profiler/Profiler.cpp b/src/Profiler/Profiler.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/Profiler/Profiler.hpp b/src/Profiler/Profiler.hpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/Sorter.cpp b/src/Sorter.cpp new file mode 100644 index 0000000..1e8cd4b --- /dev/null +++ b/src/Sorter.cpp @@ -0,0 +1,118 @@ +#include "Sorter.hpp" + +#include "Profiling/Timer.hpp" + +#define BOOL_FMT "%s" +#define BOOL_ARG(exp) (exp) ? "true" : "false" + +namespace sva { + Sorter::Sorter(size_t size) : m_SortArray(size) + { + populate(size); + spdlog::debug("Sorter: created -- size: %lld, is-sorted: " BOOL_FMT, size, BOOL_ARG(is_sorted())); + } + + Sorter::SortResult Sorter::run(const sol::protected_function& sort_func) + { + SortResult res; + timer_result tres; + + if (m_ActiveSortResult) spdlog::error("Sorter: A Sort already running..."); + m_ActiveSortResult = &res; + + Timer timer(tres, timer.paused); + spdlog::debug("Sorter: running function"); + + timer.set_state(timer.running); + + sol::function_result result = sort_func(); + + timer.set_state(timer.paused); + + if (!result.valid()) + { + spdlog::critical("Sol.Lua: Function result is invalid"); + } + + if (m_ActiveSortResult) spdlog::error("Sorter: Something went wrong while running the test. There is no active result"); + m_ActiveSortResult = nullptr; + return res; + } + + void Sorter::setup(sol::state& state) + { + state.open_libraries(sol::lib::coroutine, sol::lib::table); + state.new_usertype("Sorter", + "size", &Sorter::list_size, + "swap", &Sorter::list_swap, + "greater", &Sorter::list_greater, + "less", &Sorter::list_less, + "equal", &Sorter::list_equal + ); + } + + + bool Sorter::list_greater(size_t a, size_t b) const + { + if (m_ActiveSortResult) + m_ActiveSortResult->calls.nGreater++; + return m_SortArray[a] > m_SortArray[b]; + } + + bool Sorter::list_less(size_t a, size_t b) const + { + if (m_ActiveSortResult) + m_ActiveSortResult->calls.nLesser++; + return m_SortArray[a] < m_SortArray[b]; + } + + bool Sorter::list_equal(size_t a, size_t b) const + { + if (m_ActiveSortResult) + m_ActiveSortResult->calls.nEqual++; + return m_SortArray[a] == m_SortArray[b]; + } + + void Sorter::list_swap(size_t a, size_t b) + { + if (m_ActiveSortResult) + m_ActiveSortResult->calls.nSwap++; + // list[index1] ^= list[index2]; + // list[index2] ^= list[index1]; + // list[index1] ^= list[index2]; + auto tmp = m_SortArray[a]; + m_SortArray[a] = m_SortArray[b]; + m_SortArray[b] = tmp; + } + + size_t Sorter::list_size() const + { + if (m_ActiveSortResult) + m_ActiveSortResult->calls.nSize++; + return m_SortArray.size(); + } + + bool Sorter::is_sorted() const + { + if (m_SortArray.size() <= 1) + return true; + for (size_t i = 1; i < m_SortArray.size(); i++) + { + if (m_SortArray[i - 1] > m_SortArray[i]) + return false; + } + return true; + } + + void Sorter::populate(size_t size) + { + std::random_device dev; + std::mt19937_64 rng(dev()); + std::uniform_int_distribution dist(0, SIZE_MAX); + + for (size_t i = 0; i < size; i++) + { + m_SortArray.at(i) = dist(rng); + } + } +} diff --git a/src/Sorter.hpp b/src/Sorter.hpp new file mode 100644 index 0000000..1870b9b --- /dev/null +++ b/src/Sorter.hpp @@ -0,0 +1,47 @@ +#pragma once +#include + +#include +#include + +namespace sva { + class Sorter + { + public: + struct SortResult + { + bool is_sorted; + double elapsed_time; + struct + { + size_t nSwap; + size_t nSize; + size_t nGreater; + size_t nLesser; + size_t nEqual; + } calls; + }; + + private: + std::vector m_SortArray; + + SortResult* m_ActiveSortResult; + public: + Sorter(size_t size); + + SortResult run(const sol::protected_function& sort_func); + + static void setup(sol::state& state); + + protected: + void list_swap(size_t, size_t); + bool list_greater(size_t, size_t) const; + bool list_less(size_t, size_t) const; + bool list_equal(size_t, size_t) const; + size_t list_size() const; + + bool is_sorted() const; + + void populate(size_t); + }; +} diff --git a/src/gui/CoreComponents.cpp b/src/gui/CoreComponents.cpp new file mode 100644 index 0000000..c4a21f7 --- /dev/null +++ b/src/gui/CoreComponents.cpp @@ -0,0 +1,85 @@ +#include "./CoreComponents.hpp" + +namespace sva { + GuiMovableWindow::GuiMovableWindow() + { + m_Title = "Example movable Window"; + } + + int GuiMovableWindow::input() + { + if (!m_WindowOpen) return 0; + Vector2 mouse_pos = GetMousePosition(); + + if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && !m_DragWindow) + { + if (CheckCollisionPointRec(mouse_pos, { m_WndRect.x, m_WndRect.y, m_WndRect.width - 24, 20 })) + { + m_DragWindow = true; + m_PanOffset = { mouse_pos.x - m_WndRect.x, mouse_pos.y - m_WndRect.y }; + } + } + + if (m_DragWindow) + { + m_WndRect.x = (mouse_pos.x - m_PanOffset.x); + m_WndRect.y = (mouse_pos.y - m_PanOffset.y); + if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) m_DragWindow = false; + } + return rinput(mouse_pos); + } + + int GuiMovableWindow::rinput(Vector2& mouse_position) + { + return 0; + } + + int GuiMovableWindow::rdraw() + { + return 0; + } + + int GuiMovableWindow::draw() + { + if (!m_WindowOpen) return 0; + + m_WindowOpen = !GuiWindowBox(m_WndRect, m_Title.c_str()); + + return rdraw(); + } + + + void ErrorWindow::onAttach() + { + m_WindowOpen = false; + } + + int ErrorWindow::rdraw() + { + GuiLabel({ m_WndRect.x + m_TextAnchor.x, m_WndRect.y + m_TextAnchor.y, m_WndRect.width, m_WndRect.height }, m_Msg.c_str()); + + return 0; + } + + void ErrorWindow::onResize() + { + m_WndRect.x = (static_cast(m_WndWidth) - m_WndRect.width) / 2; + m_WndRect.y = (static_cast(m_WndHeight) - m_WndRect.height) / 2; + } + + void ErrorWindow::error(std::string title, std::string msg) + { + m_Msg = std::move(msg); + float text_padding = 20; + m_WndRect.width = static_cast(MeasureText(m_Msg.c_str(), GuiGetStyle(DEFAULT, TEXT_SIZE))) + text_padding; + m_WndRect.height = (m_WndRect.width * 2) / 3; + + m_TextAnchor = { + .x = text_padding / 2, + .y = m_WndRect.height / 2 - static_cast(GuiGetStyle(DEFAULT, TEXT_SIZE)) + }; + + m_WindowOpen = true; + m_Title = std::move(title); + } +} diff --git a/src/gui/CoreComponents.hpp b/src/gui/CoreComponents.hpp index 9e2bdba..e4e0431 100644 --- a/src/gui/CoreComponents.hpp +++ b/src/gui/CoreComponents.hpp @@ -3,163 +3,38 @@ #include #include - -class GuiMovableWindow : public sva::GuiComponent -{ -private: - bool m_DragWindow = false; - Vector2 m_PanOffset = { 0,0 }; -protected: - Rectangle m_WndRect = { 20,20, 200, 100 }; - bool m_WindowOpen = true; -public: - - virtual int input() override +namespace sva { + class GuiMovableWindow : public sva::GuiComponent { - if (!m_WindowOpen) return 0; - Vector2 mouse_pos = GetMousePosition(); + private: + bool m_DragWindow = false; + Vector2 m_PanOffset = { 0,0 }; + protected: + Rectangle m_WndRect = { 20,20, 200, 100 }; + bool m_WindowOpen = true; + std::string m_Title; + public: + GuiMovableWindow(); - if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && !m_DragWindow) - { - if (CheckCollisionPointRec(mouse_pos, { m_WndRect.x, m_WndRect.y, m_WndRect.width - 24, 20 })) - { - m_DragWindow = true; - m_PanOffset = { mouse_pos.x - m_WndRect.x, mouse_pos.y - m_WndRect.y }; - } - } + virtual int input() override; - if (m_DragWindow) - { - m_WndRect.x = (mouse_pos.x - m_PanOffset.x); - m_WndRect.y = (mouse_pos.y - m_PanOffset.y); - if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) m_DragWindow = false; - } - return rinput(mouse_pos); - } + virtual int rinput(Vector2& mouse_position); + virtual int rdraw(); - virtual int rinput(Vector2& mouse_position) { return 0; }; + virtual int draw() override; + }; - virtual int draw() override + class ErrorWindow : public GuiMovableWindow { - if (!m_WindowOpen) return 0; + std::string m_Msg; + Vector2 m_TextAnchor = { 0,0 }; + public: + void onAttach() override; - m_WindowOpen = !GuiWindowBox(m_WndRect, "Example Movable Window"); + int rdraw() override; - return 0; - } -}; - - -/**************************************************** - * A "Are you sure you want to exit?" Window. - * - * Yes is default - * TODO: Make the Yes-Button standout as the default -****************************************************/ -class SafeClosePopup final : public GuiMovableWindow -{ - Vector2 anchor03 = { 0,0 }; - - bool m_CQB_YesButton = false; - bool m_CQB_NoButton = false; - -public: - - ~SafeClosePopup() { - CloseWindow(); - } - - void onAttach() override - { - m_WindowOpen = false; - } - - int draw() override - { - if (WindowShouldClose()) - { - if (m_WindowOpen) { - CloseWindow(); - } - else { - OpenWindow(); - } - onResize(); - } - - if (m_WindowOpen) - { - GuiUnlock(); - anchor03 = { m_WndRect.x + 168, m_WndRect.y + 88 }; - - m_WindowOpen = !GuiWindowBox(m_WndRect, "#191# Are you sure you want to close this program?"); - int border_color = GuiGetStyle(DEFAULT, BORDER_COLOR_NORMAL); - int base_color = GuiGetStyle(DEFAULT, BASE_COLOR_NORMAL); - GuiSetStyle(DEFAULT, BORDER_COLOR_NORMAL, 0x7192C2FF); - GuiSetStyle(DEFAULT, BASE_COLOR_NORMAL, 0xBBCDD3FF); - m_CQB_YesButton = GuiButton({ anchor03.x + -152, anchor03.y + 32, 120, 24 }, "#112#Yes"); - GuiSetStyle(DEFAULT, BORDER_COLOR_NORMAL, border_color); - GuiSetStyle(DEFAULT, BASE_COLOR_NORMAL, base_color); - m_CQB_NoButton = GuiButton({ anchor03.x + 24, anchor03.y + 32, 120, 24 }, "#113#No"); - GuiLabel({ anchor03.x + -104, anchor03.y + -40, 208, 24 }, "Are you sure you want to close this?"); - GuiLabel({ anchor03.x + -56, anchor03.y + -8, 120, 24 }, "Press \"Yes\" to close"); - if (m_CQB_YesButton) - { - *m_WndRunning = false; - return 1; - } - if (m_CQB_NoButton) CloseWindow(); - } - return 0; - } - - int rinput(Vector2& mouse_position) override - { - if (IsKeyReleased(KEY_ENTER)) { - *m_WndRunning = false; - return 1; - } - GuiLock(); - return 0; - } - - - void onResize() override - { - anchor03 = { static_cast(m_WndWidth) / 2 , static_cast(m_WndHeight) / 2 }; - m_WndRect = { anchor03.x + -168, anchor03.y + -88, 328, 160 }; - } - -public: - void OpenWindow() { - GuiLock(); - m_WindowOpen = true; - } - - void CloseWindow() { - m_WindowOpen = false; - GuiUnlock(); - } -}; - - -class SettingsComponent final : public sva::GuiComponent { -public: - struct { - bool borderlessFullscreen; - uint32_t state; - } values; - - void onAttach() override { - values.borderlessFullscreen = false; - values.state = 0; - } - - int draw() override { - if (GuiButton({ 100, 100, 300, 30 }, "This should not work when the safe window is open!")) { - std::cout << "got pressed\n"; - } - return 0; - } -}; + void onResize() override; + void error(std::string title, std::string msg); + }; +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index ff92ca7..2664baf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,7 +21,10 @@ #include #include "gui/ComponentStack.hpp" -#include "gui/CoreComponents.hpp" + +// gui components +#include "Components/SaveClosePopup.hpp" +#include "Components/BigSortComponent.hpp" #include @@ -74,7 +77,7 @@ int main(int argc, char** argv) int run_result = 0; - ComponentStack::push(); + ComponentStack::push(); // always on top... SafeClosePopup safe_close_popup;