Skip to content

Commit

Permalink
refactor: move downsampling settings to own method
Browse files Browse the repository at this point in the history
  • Loading branch information
vtx22 committed Mar 4, 2025
1 parent c450a89 commit 0015a96
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/SettingsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,25 @@ SettingsWindow::SettingsWindow(DataHandler *data_handler) : Window(ICON_FA_GEAR

void SettingsWindow::update_content()
{
bool settings_changed = false;
show_downsampling_settings();

if (_settings_changed)
{
_config_handler.write_config();
_settings_changed = false;
}
}

void SettingsWindow::show_downsampling_settings()
{
if (ImGui::CollapsingHeader("Downsampling"))
{
bool downsampling_enabled;
std::istringstream(_config_handler.ini["downsampling"]["enabled"]) >> std::boolalpha >> downsampling_enabled;
if (ImGui::Checkbox("Enabled", &downsampling_enabled))
{
_config_handler.ini["downsampling"]["enabled"] = downsampling_enabled ? "true" : "false";
settings_changed = true;
_settings_changed = true;
}

ImGui::Text("Max Samples:");
Expand All @@ -34,7 +43,7 @@ void SettingsWindow::update_content()
}

_config_handler.ini["downsampling"]["max_samples"] = std::to_string(max_samples);
settings_changed = true;
_settings_changed = true;
}

ImGui::SameLine();
Expand Down Expand Up @@ -65,12 +74,7 @@ void SettingsWindow::update_content()
if (max_samples_type != prev_max_samples_type)
{
_config_handler.ini["downsampling"]["max_samples_type"] = std::to_string(max_samples_type);
settings_changed = true;
_settings_changed = true;
}
}

if (settings_changed)
{
_config_handler.write_config();
}
}
5 changes: 5 additions & 0 deletions src/SettingsWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ class SettingsWindow : public Window
SettingsWindow(DataHandler *data_handler);

void update_content() override;

void show_downsampling_settings();

private:
bool _settings_changed = false;
};

0 comments on commit 0015a96

Please sign in to comment.