Skip to content

Commit

Permalink
feature: automatically update on import variable window open #50
Browse files Browse the repository at this point in the history
  • Loading branch information
klonyyy committed May 4, 2024
1 parent 0f8fe8e commit 6800a70
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Gui/GuiImportVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ void Gui::drawImportVariablesWindow()
{
static std::unordered_map<std::string, uint32_t> selection;
static std::future<bool> refreshThread{};
static bool wasPreviouslyOpened = false;
static bool shouldUpdateOnOpen = false;

if (showImportVariablesWindow)
{
ImGui::OpenPopup("Import Variables");
if (!wasPreviouslyOpened)
shouldUpdateOnOpen = true;
}

ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
ImGui::SetNextWindowSize(ImVec2(500 * contentScale, 500 * contentScale), ImGuiCond_Once);
Expand All @@ -31,8 +37,11 @@ void Gui::drawImportVariablesWindow()
snprintf(buttonText, 30, "Refresh");
}

if (ImGui::Button(buttonText, ImVec2(-1, 25 * contentScale)))
if (ImGui::Button(buttonText, ImVec2(-1, 25 * contentScale)) || shouldUpdateOnOpen)
{
refreshThread = std::async(std::launch::async, &GdbParser::parse, parser, projectElfPath);
shouldUpdateOnOpen = false;
}

static std::string search{};
ImGui::Text("search ");
Expand Down Expand Up @@ -66,6 +75,8 @@ void Gui::drawImportVariablesWindow()

ImGui::EndPopup();
}

wasPreviouslyOpened = showImportVariablesWindow;
}

void Gui::drawImportVariablesTable(const std::map<std::string, GdbParser::VariableData>& importedVars, std::unordered_map<std::string, uint32_t>& selection, const std::string& substring)
Expand Down

0 comments on commit 6800a70

Please sign in to comment.