From 2647c85323c5d9262492cd403b8fe201ef96eed3 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Sun, 21 Jan 2024 20:20:32 +0100 Subject: [PATCH] add imgui stylign window + change how texture filters are applied --- src/main_screen.cpp | 12 ++++++++++++ src/main_screen.hpp | 2 ++ src/sdlrenderer_texture_uploader.cpp | 13 ++++++------- src/settings_window.cpp | 1 - 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/main_screen.cpp b/src/main_screen.cpp index 1058e59f..f5eb477d 100644 --- a/src/main_screen.cpp +++ b/src/main_screen.cpp @@ -191,6 +191,12 @@ Screen* MainScreen::render(float time_delta, bool&) { ImGui::EndMenu(); } + if (ImGui::BeginMenu("Settings")) { + if (ImGui::MenuItem("ImGui Style Editor")) { + _show_tool_style_editor = true; + } + ImGui::EndMenu(); + } ImGui::EndMenuBar(); } @@ -198,6 +204,12 @@ Screen* MainScreen::render(float time_delta, bool&) { ImGui::End(); } + if (_show_tool_style_editor) { + if (ImGui::Begin("Dear ImGui Style Editor", &_show_tool_style_editor)) { + ImGui::ShowStyleEditor(); + } + ImGui::End(); + } if constexpr (false) { ImGui::ShowDemoWindow(); diff --git a/src/main_screen.hpp b/src/main_screen.hpp index d261f300..84facd66 100644 --- a/src/main_screen.hpp +++ b/src/main_screen.hpp @@ -64,6 +64,8 @@ struct MainScreen final : public Screen { ToxUIUtils tuiu; ToxDHTCapHisto tdch; + bool _show_tool_style_editor {false}; + bool _window_hidden {false}; bool _window_hidden_ts {0}; float _time_since_event {0.f}; diff --git a/src/sdlrenderer_texture_uploader.cpp b/src/sdlrenderer_texture_uploader.cpp index 24346d79..da058321 100644 --- a/src/sdlrenderer_texture_uploader.cpp +++ b/src/sdlrenderer_texture_uploader.cpp @@ -17,16 +17,15 @@ uint64_t SDLRendererTextureUploader::uploadRGBA(const uint8_t* data, uint32_t wi ); assert(surf); // TODO: add error reporting - // TODO: this touches global state, reset? - if (filter == NEAREST) { - SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest"); - } else if (filter == LINEAR) { - SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); - } - SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, surf); assert(tex); // TODO: add error reporting + if (filter == NEAREST) { + SDL_SetTextureScaleMode(tex, SDL_SCALEMODE_NEAREST); + } else if (filter == LINEAR) { + SDL_SetTextureScaleMode(tex, SDL_SCALEMODE_LINEAR); + } + SDL_DestroySurface(surf); return reinterpret_cast(tex); diff --git a/src/settings_window.cpp b/src/settings_window.cpp index e67e2615..2c987a78 100644 --- a/src/settings_window.cpp +++ b/src/settings_window.cpp @@ -116,7 +116,6 @@ void SettingsWindow::render(void) { } ImGui::EndMenuBar(); } - } ImGui::End(); }