Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
2647c85323 | |||
93140231c6 | |||
e76e56e025 |
21
src/main.cpp
21
src/main.cpp
@ -55,8 +55,29 @@ int main(int argc, char** argv) {
|
|||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
|
|
||||||
|
if (SDL_GetSystemTheme() == SDL_SYSTEM_THEME_LIGHT) {
|
||||||
|
ImGui::StyleColorsLight();
|
||||||
|
} else {
|
||||||
//ImGui::StyleColorsDark();
|
//ImGui::StyleColorsDark();
|
||||||
setThemeGreen();
|
setThemeGreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ImGui::GetIO().Fonts->ClearFonts();
|
||||||
|
ImFontConfig fontcfg;
|
||||||
|
|
||||||
|
// upsampling to int looks almost ok
|
||||||
|
const float font_size_scale = 1.3f;
|
||||||
|
const float font_oversample = 4.f;
|
||||||
|
|
||||||
|
// default font is pixel perfect at 13
|
||||||
|
fontcfg.SizePixels = 13.f * font_size_scale;
|
||||||
|
fontcfg.RasterizerDensity = font_oversample/font_size_scale;
|
||||||
|
// normally density would be set to dpi scale of the display
|
||||||
|
|
||||||
|
ImGui::GetIO().Fonts->AddFontDefault(&fontcfg);
|
||||||
|
ImGui::GetIO().Fonts->Build();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui_ImplSDL3_InitForSDLRenderer(window.get(), renderer.get());
|
ImGui_ImplSDL3_InitForSDLRenderer(window.get(), renderer.get());
|
||||||
auto imgui_sdl_scope = std::async(std::launch::deferred, &ImGui_ImplSDL3_Shutdown);
|
auto imgui_sdl_scope = std::async(std::launch::deferred, &ImGui_ImplSDL3_Shutdown);
|
||||||
|
@ -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();
|
||||||
|
@ -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};
|
||||||
|
@ -7,7 +7,7 @@ SDLRendererTextureUploader::SDLRendererTextureUploader(SDL_Renderer* renderer_)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t SDLRendererTextureUploader::uploadRGBA(const uint8_t* data, uint32_t width, uint32_t height) {
|
uint64_t SDLRendererTextureUploader::uploadRGBA(const uint8_t* data, uint32_t width, uint32_t height, Filter filter) {
|
||||||
// TODO: test if pitch is 4 or 4*width
|
// TODO: test if pitch is 4 or 4*width
|
||||||
SDL_Surface* surf = SDL_CreateSurfaceFrom(
|
SDL_Surface* surf = SDL_CreateSurfaceFrom(
|
||||||
(void*)data,
|
(void*)data,
|
||||||
@ -20,6 +20,12 @@ uint64_t SDLRendererTextureUploader::uploadRGBA(const uint8_t* data, uint32_t wi
|
|||||||
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);
|
||||||
|
@ -10,7 +10,7 @@ struct SDLRendererTextureUploader : public TextureUploaderI {
|
|||||||
SDLRendererTextureUploader(SDL_Renderer* renderer_);
|
SDLRendererTextureUploader(SDL_Renderer* renderer_);
|
||||||
~SDLRendererTextureUploader(void) = default;
|
~SDLRendererTextureUploader(void) = default;
|
||||||
|
|
||||||
uint64_t uploadRGBA(const uint8_t* data, uint32_t width, uint32_t height) override;
|
uint64_t uploadRGBA(const uint8_t* data, uint32_t width, uint32_t height, Filter filter) override;
|
||||||
void destroy(uint64_t tex_id) override;
|
void destroy(uint64_t tex_id) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -116,7 +116,6 @@ void SettingsWindow::render(void) {
|
|||||||
}
|
}
|
||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,14 @@
|
|||||||
struct TextureUploaderI {
|
struct TextureUploaderI {
|
||||||
static constexpr const char* version {"1"};
|
static constexpr const char* version {"1"};
|
||||||
|
|
||||||
|
enum Filter {
|
||||||
|
NEAREST,
|
||||||
|
LINEAR,
|
||||||
|
};
|
||||||
|
|
||||||
virtual ~TextureUploaderI(void) {}
|
virtual ~TextureUploaderI(void) {}
|
||||||
|
|
||||||
//virtual uint64_t uploadRGBA(const uint8_t* data, uint64_t data_size) = 0;
|
virtual uint64_t uploadRGBA(const uint8_t* data, uint32_t width, uint32_t height, Filter filter = LINEAR) = 0;
|
||||||
virtual uint64_t uploadRGBA(const uint8_t* data, uint32_t width, uint32_t height) = 0;
|
|
||||||
|
|
||||||
virtual void destroy(uint64_t tex_id) = 0;
|
virtual void destroy(uint64_t tex_id) = 0;
|
||||||
};
|
};
|
||||||
|
@ -203,7 +203,7 @@ std::optional<TextureEntry> ToxAvatarLoader::load(TextureUploaderI& tu, Contact3
|
|||||||
new_entry.timestamp_last_rendered = Message::getTimeMS();
|
new_entry.timestamp_last_rendered = Message::getTimeMS();
|
||||||
new_entry.current_texture = 0;
|
new_entry.current_texture = 0;
|
||||||
|
|
||||||
const auto n_t = tu.uploadRGBA(pixels.data(), 5, 5);
|
const auto n_t = tu.uploadRGBA(pixels.data(), 5, 5, TextureUploaderI::NEAREST);
|
||||||
new_entry.textures.push_back(n_t);
|
new_entry.textures.push_back(n_t);
|
||||||
new_entry.frame_duration.push_back(250);
|
new_entry.frame_duration.push_back(250);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user