Skip to content

Commit

Permalink
feat: Allow layouts to be deleted again
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed May 21, 2023
1 parent 6dbaac4 commit 1b88b37
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 7 additions & 1 deletion plugins/builtin/include/content/popups/popup_text_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ namespace hex::plugin::builtin {
ImGui::NewLine();

ImGui::PushItemWidth(-1);
ImGui::SetKeyboardFocusHere();

if (this->m_justOpened) {
ImGui::SetKeyboardFocusHere();
this->m_justOpened = false;
}

ImGui::InputTextIcon("##input", ICON_VS_SYMBOL_KEY, this->m_input);
ImGui::PopItemWidth();

Expand Down Expand Up @@ -57,6 +62,7 @@ namespace hex::plugin::builtin {

std::string m_message;
std::function<void(std::string)> m_function;
bool m_justOpened = true;
};

}
10 changes: 8 additions & 2 deletions plugins/builtin/source/content/main_menu_items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,15 @@ namespace hex::plugin::builtin {
LayoutManager::loadString(std::string(romfs::get("layouts/default.hexlyt").string()));
}

bool shift = ImGui::GetIO().KeyShift;
for (auto &[name, path] : LayoutManager::getLayouts()) {
if (ImGui::MenuItem(name.c_str(), "", false, ImHexApi::Provider::isValid())) {
LayoutManager::load(path);
if (ImGui::MenuItem(hex::format("{}{}", name, shift ? " [X]" : "").c_str(), "", false, ImHexApi::Provider::isValid())) {
if (shift) {
wolv::io::fs::remove(path);
LayoutManager::reload();
}
else
LayoutManager::load(path);
}
}
});
Expand Down

0 comments on commit 1b88b37

Please sign in to comment.