add imgui stylign window + change how texture filters are applied

This commit is contained in:
Green Sky 2024-01-21 20:20:32 +01:00
parent 93140231c6
commit 2647c85323
No known key found for this signature in database
4 changed files with 20 additions and 8 deletions

View File

@ -191,6 +191,12 @@ Screen* MainScreen::render(float time_delta, bool&) {
ImGui::EndMenu(); ImGui::EndMenu();
} }
if (ImGui::BeginMenu("Settings")) {
if (ImGui::MenuItem("ImGui Style Editor")) {
_show_tool_style_editor = true;
}
ImGui::EndMenu();
}
ImGui::EndMenuBar(); ImGui::EndMenuBar();
} }
@ -198,6 +204,12 @@ Screen* MainScreen::render(float time_delta, bool&) {
ImGui::End(); 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) { if constexpr (false) {
ImGui::ShowDemoWindow(); ImGui::ShowDemoWindow();

View File

@ -64,6 +64,8 @@ struct MainScreen final : public Screen {
ToxUIUtils tuiu; ToxUIUtils tuiu;
ToxDHTCapHisto tdch; ToxDHTCapHisto tdch;
bool _show_tool_style_editor {false};
bool _window_hidden {false}; bool _window_hidden {false};
bool _window_hidden_ts {0}; bool _window_hidden_ts {0};
float _time_since_event {0.f}; float _time_since_event {0.f};

View File

@ -17,16 +17,15 @@ uint64_t SDLRendererTextureUploader::uploadRGBA(const uint8_t* data, uint32_t wi
); );
assert(surf); // TODO: add error reporting 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); SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, surf);
assert(tex); // TODO: add error reporting 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); SDL_DestroySurface(surf);
return reinterpret_cast<uint64_t>(tex); return reinterpret_cast<uint64_t>(tex);

View File

@ -116,7 +116,6 @@ void SettingsWindow::render(void) {
} }
ImGui::EndMenuBar(); ImGui::EndMenuBar();
} }
} }
ImGui::End(); ImGui::End();
} }