Skip to content

Commit

Permalink
improvements to command palette
Browse files Browse the repository at this point in the history
  • Loading branch information
wkjarosz committed Dec 11, 2024
1 parent 12b43fa commit 76d60d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ endif()
CPMAddPackage(
NAME my_imgui_command_palette
GITHUB_REPOSITORY wkjarosz/imgui-command-palette
GIT_TAG 428085688d88adf046c051c158de2fc5a8ef82bf
GIT_TAG 3b356eb6b869a0f973d6a14888d188bb798167c9
DOWNLOAD_ONLY YES
)

Expand Down
25 changes: 12 additions & 13 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1799,7 +1799,7 @@ bool HDRViewApp::process_event(void *e)

void HDRViewApp::draw_command_palette()
{
// ImGui::OpenPopup("Command palette...");
ImGui::OpenPopup("Command palette...");

float2 display_size = ImGui::GetIO().DisplaySize;
#ifdef __EMSCRIPTEN__
Expand All @@ -1814,10 +1814,10 @@ void HDRViewApp::draw_command_palette()
0},
ImGuiCond_Always);

// if (ImGui::BeginPopupModal("Command palette...", &g_show_command_palette,
// ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDocking))
ImGui::Begin("Command palette...", &g_show_command_palette,
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDocking);
if (ImGui::BeginPopupModal("Command palette...", &g_show_command_palette,
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDocking))
// ImGui::Begin("Command palette...", &g_show_command_palette,
// ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDocking);
{

if (ImGui::IsWindowAppearing())
Expand Down Expand Up @@ -1863,10 +1863,8 @@ void HDRViewApp::draw_command_palette()
for (int i = 0; i < ImGuiTheme::ImGuiTheme_Count; ++i)
theme_names.push_back(ImGuiTheme::ImGuiTheme_Name((ImGuiTheme::ImGuiTheme_)(i)));

{
ImCmd::Prompt(theme_names);
ImCmd::SetNextCommandPaletteSearchBoxFocused();
}
ImCmd::Prompt(theme_names);
ImCmd::SetNextCommandPaletteSearchBoxFocused();
},
[](int selected_option)
{
Expand All @@ -1880,10 +1878,11 @@ void HDRViewApp::draw_command_palette()
ImCmd::SetNextCommandPaletteSearch("");
}

ImCmd::SetNextCommandPaletteSearchBoxFocused(); // always focus the search box
ImCmd::CommandPalette("Command palette", "Filter commands...");

if (ImCmd::IsAnyItemSelected() || ImGui::GlobalShortcut(ImGuiKey_Escape) ||
ImGui::GlobalShortcut(ImGuiMod_Ctrl | ImGuiKey_Period, ImGuiInputFlags_Repeat) ||
if (ImCmd::IsAnyItemSelected() || ImGui::GlobalShortcut(ImGuiKey_Escape, ImGuiInputFlags_RouteOverActive) ||
ImGui::GlobalShortcut(ImGuiMod_Ctrl | ImGuiKey_Period, ImGuiInputFlags_RouteOverActive) ||
!ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows))
// Close window when user selects an item, hits escape, or unfocuses the command palette window
// (clicking elsewhere)
Expand Down Expand Up @@ -1912,8 +1911,8 @@ void HDRViewApp::draw_command_palette()
ImGui::EndTable();
}

ImGui::End();
// ImGui::EndPopup();
// ImGui::End();
ImGui::EndPopup();
}
}

Expand Down

0 comments on commit 76d60d9

Please sign in to comment.