mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 15:57:03 -05:00
Compare commits
1 Commits
feature/co
...
feature/we
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
810955b1be |
@@ -316,28 +316,40 @@ namespace hex {
|
||||
pressedShortcut += s_macOSMode ? CTRLCMD : SUPER;
|
||||
if (focused)
|
||||
pressedShortcut += CurrentView;
|
||||
if (!ImHexApi::Provider::isValid()) {
|
||||
pressedShortcut += CurrentView;
|
||||
pressedShortcut += ShowOnWelcomeScreen;
|
||||
}
|
||||
|
||||
pressedShortcut += scanCodeToKey(keyCode);
|
||||
|
||||
return pressedShortcut;
|
||||
}
|
||||
|
||||
static bool processShortcut(Shortcut shortcut, const std::map<Shortcut, ShortcutManager::ShortcutEntry> &shortcuts) {
|
||||
static auto findShortcut(const Shortcut &shortcut, const std::map<Shortcut, ShortcutManager::ShortcutEntry> &shortcuts, bool condition, auto ... extraOption) {
|
||||
auto modifiedShortcut = shortcut;
|
||||
((modifiedShortcut += extraOption), ...);
|
||||
if (condition) {
|
||||
return shortcuts.find(modifiedShortcut);
|
||||
} else {
|
||||
auto it = shortcuts.find(shortcut);
|
||||
if (it == shortcuts.end())
|
||||
return shortcuts.find(modifiedShortcut);
|
||||
}
|
||||
|
||||
return shortcuts.end();
|
||||
}
|
||||
|
||||
static bool processShortcut(const Shortcut &shortcut, const std::map<Shortcut, ShortcutManager::ShortcutEntry> &shortcuts) {
|
||||
if (s_paused)
|
||||
return true;
|
||||
|
||||
if (ImGui::IsPopupOpen(ImGuiID(0), ImGuiPopupFlags_AnyPopupId))
|
||||
return true;
|
||||
|
||||
auto it = shortcuts.end();
|
||||
if (ImGui::GetIO().WantTextInput) {
|
||||
it = shortcuts.find(shortcut + AllowWhileTyping);
|
||||
} else {
|
||||
it = shortcuts.find(shortcut);
|
||||
if (it == shortcuts.end())
|
||||
it = shortcuts.find(shortcut + AllowWhileTyping);
|
||||
}
|
||||
|
||||
auto it = findShortcut(shortcut, shortcuts, ImGui::GetIO().WantTextInput, AllowWhileTyping);
|
||||
if (it == shortcuts.end())
|
||||
it = findShortcut(shortcut, shortcuts, ImGui::GetIO().WantTextInput, AllowWhileTyping, ShowOnWelcomeScreen);
|
||||
if (it != shortcuts.end()) {
|
||||
const auto &[foundShortcut, entry] = *it;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
bool View::shouldProcess() const {
|
||||
return this->shouldDraw() && this->getWindowOpenState();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool View::hasViewMenuItemEntry() const {
|
||||
|
||||
@@ -728,13 +728,13 @@ namespace hex {
|
||||
view->trackViewState();
|
||||
|
||||
// Skip views that shouldn't be processed currently
|
||||
if (!view->shouldProcess())
|
||||
if (!view->shouldProcess() || !view->getWindowOpenState())
|
||||
continue;
|
||||
|
||||
const auto openViewCount = std::ranges::count_if(ContentRegistry::Views::impl::getEntries(), [](const auto &entry) {
|
||||
const auto &[unlocalizedName, openView] = entry;
|
||||
|
||||
return openView->hasViewMenuItemEntry() && openView->shouldProcess();
|
||||
return openView->hasViewMenuItemEntry() && openView->shouldDraw();
|
||||
});
|
||||
|
||||
ImGuiWindowClass windowClass = {};
|
||||
@@ -758,6 +758,19 @@ namespace hex {
|
||||
// Draw view
|
||||
view->draw();
|
||||
|
||||
// Handle view shortcuts
|
||||
for (const auto &key : m_pressedKeys) {
|
||||
ShortcutManager::process(
|
||||
view.get(),
|
||||
io.ConfigMacOSXBehaviors ? io.KeySuper : io.KeyCtrl,
|
||||
io.KeyAlt,
|
||||
io.KeyShift,
|
||||
io.ConfigMacOSXBehaviors ? io.KeyCtrl : io.KeySuper,
|
||||
view.get() == View::getLastFocusedView(),
|
||||
key
|
||||
);
|
||||
}
|
||||
|
||||
// If the window was just opened, it wasn't found above, so try to find it again
|
||||
if (window == nullptr)
|
||||
window = ImGui::FindWindowByName(view->getName().c_str());
|
||||
@@ -793,10 +806,6 @@ namespace hex {
|
||||
|
||||
// Pass on currently pressed keys to the shortcut handler
|
||||
if (!windowIsPopup) {
|
||||
for (const auto &key : m_pressedKeys) {
|
||||
ShortcutManager::process(view.get(), io.ConfigMacOSXBehaviors ? io.KeySuper : io.KeyCtrl, io.KeyAlt, io.KeyShift, io.ConfigMacOSXBehaviors ? io.KeyCtrl : io.KeySuper, focused, key);
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
} else if (view->didWindowJustClose()) {
|
||||
@@ -808,7 +817,13 @@ namespace hex {
|
||||
|
||||
// Handle global shortcuts
|
||||
for (const auto &key : m_pressedKeys) {
|
||||
ShortcutManager::processGlobals(io.ConfigMacOSXBehaviors ? io.KeySuper : io.KeyCtrl, io.KeyAlt, io.KeyShift, io.ConfigMacOSXBehaviors ? io.KeyCtrl : io.KeySuper, key);
|
||||
ShortcutManager::processGlobals(
|
||||
io.ConfigMacOSXBehaviors ? io.KeySuper : io.KeyCtrl,
|
||||
io.KeyAlt,
|
||||
io.KeyShift,
|
||||
io.ConfigMacOSXBehaviors ? io.KeyCtrl : io.KeySuper,
|
||||
key
|
||||
);
|
||||
}
|
||||
|
||||
m_pressedKeys.clear();
|
||||
|
||||
@@ -373,7 +373,7 @@ for (const auto &path : m_paths) {
|
||||
if (const auto &shortcut = ShortcutManager::getPreviousShortcut(); shortcut.has_value()) {
|
||||
auto keys = m_shortcut.getKeys();
|
||||
std::erase_if(keys, [](Key key) {
|
||||
return key != AllowWhileTyping && key != CurrentView;
|
||||
return key != AllowWhileTyping && key != CurrentView && key != ShowOnWelcomeScreen;
|
||||
});
|
||||
|
||||
for (const auto &key : shortcut->getKeys()) {
|
||||
|
||||
Reference in New Issue
Block a user