Add a delete button to themes in the preferences and fix a bug with imported themes.
This commit is contained in:
parent
18bc56e510
commit
2200119f1f
2 changed files with 19 additions and 4 deletions
21
main.cpp
21
main.cpp
|
@ -234,6 +234,8 @@ int main(int, char**)
|
|||
Theme dark(true);
|
||||
dark.Save(darkPath);
|
||||
}
|
||||
delete theme;
|
||||
theme = new Theme(darkPath);
|
||||
}
|
||||
}
|
||||
SDL_GL_SetSwapInterval(vsync ? 1 : 0);
|
||||
|
@ -378,11 +380,16 @@ int main(int, char**)
|
|||
ImGui::SetNextItemWidth(ImGui::GetWindowWidth() - ImGui::GetCursorPosX() - ImGui::GetStyle().WindowPadding.x);
|
||||
ImGui::InputText("##FilterInput", filter, 1024);
|
||||
ImGui::Text("Select a theme...");
|
||||
if (ImGui::BeginListBox("##Themes", ImVec2(ImGui::GetWindowWidth() - (ImGui::GetStyle().WindowPadding.x * 2.0f), -ImGui::GetTextLineHeightWithSpacing() - ImGui::GetStyle().WindowPadding.y))) {
|
||||
ImVec2 ListBoxSize = ImVec2(ImGui::GetWindowWidth() - (ImGui::GetStyle().WindowPadding.x * 2.0f), -ImGui::GetTextLineHeightWithSpacing() - ImGui::GetStyle().WindowPadding.y);
|
||||
if (ImGui::BeginTable("##Themes", 2, 0, ListBoxSize)) {
|
||||
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableSetupColumn("Remove", ImGuiTableColumnFlags_WidthFixed);
|
||||
for (auto themePath : Theme::availableThemes) {
|
||||
if (themePath.stem().string().starts_with(filter)) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
const bool is_selected = themePath == theme->file_path;
|
||||
if (ImGui::Selectable(themePath.stem().generic_string().c_str(), is_selected)) {
|
||||
if (ImGui::Selectable(themePath.stem().generic_string().c_str(), is_selected, 0)) {
|
||||
delete theme;
|
||||
theme = new Theme(themePath);
|
||||
theme->Apply(accent_color);
|
||||
|
@ -390,10 +397,18 @@ int main(int, char**)
|
|||
}
|
||||
if (is_selected) {
|
||||
ImGui::SetItemDefaultFocus();
|
||||
} else {
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
if (ImGui::SmallButton((string(ICON_FK_WINDOW_CLOSE "##") + themePath.stem().generic_string()).c_str())) {
|
||||
printf("%s\n", themePath.c_str());
|
||||
std::filesystem::remove(themePath);
|
||||
Theme::updateAvailableThemes();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndListBox();
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::SetNextItemWidth(ImGui::GetWindowWidth() - (ImGui::GetStyle().FramePadding.x * 4));
|
||||
if (ImGui::SliderFloat("##AccentColor", &accent_color, 0.0, 360.0, "UI hue: %.0f°", ImGuiSliderFlags_NoRoundToFormat)) {
|
||||
|
|
|
@ -186,7 +186,7 @@ bool Theme::ShowEditor(bool* open, Theme* &theme) {
|
|||
path selected_path = importDialog.GetSelected();
|
||||
path filename = selected_path.filename();
|
||||
copy_file(selected_path, theme->themeDir / filename);
|
||||
theme->availableThemes.insert(filename);
|
||||
Theme::updateAvailableThemes();
|
||||
importDialog.ClearSelected();
|
||||
}
|
||||
if (exportDialog.HasSelected()) {
|
||||
|
|
Loading…
Reference in a new issue