fix: Diffing option popup flickering when opening
This commit is contained in:
parent
e786cb8180
commit
28ba34f1bf
@ -18,6 +18,7 @@ namespace hex::plugin::diffing {
|
||||
~ViewDiff() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawAlwaysVisibleContent() override;
|
||||
ImGuiWindowFlags getWindowFlags() const override { return ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse; }
|
||||
|
||||
public:
|
||||
|
@ -192,14 +192,12 @@ namespace hex::plugin::diffing {
|
||||
ImGui::TableSetupColumn("hex.diffing.view.diff.provider_b"_lang);
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
ImVec2 buttonPos;
|
||||
ImGui::BeginDisabled(m_diffTask.isRunning());
|
||||
{
|
||||
// Draw settings button
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGuiExt::DimmedIconButton(ICON_VS_SETTINGS_GEAR, ImGui::GetStyleColorVec4(ImGuiCol_Text)))
|
||||
ImGui::OpenPopup("DiffingAlgorithmSettings");
|
||||
buttonPos = ImGui::GetCursorScreenPos();
|
||||
RequestOpenPopup::post("##DiffingAlgorithmSettings");
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
@ -212,41 +210,6 @@ namespace hex::plugin::diffing {
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::SetNextWindowPos(buttonPos);
|
||||
if (ImGui::BeginPopup("DiffingAlgorithmSettings")) {
|
||||
ImGuiExt::Header("hex.diffing.view.diff.algorithm"_lang, true);
|
||||
ImGui::PushItemWidth(300_scaled);
|
||||
if (ImGui::BeginCombo("##Algorithm", m_algorithm == nullptr ? "" : Lang(m_algorithm->getUnlocalizedName()))) {
|
||||
for (const auto &algorithm : ContentRegistry::Diffing::impl::getAlgorithms()) {
|
||||
ImGui::PushID(algorithm.get());
|
||||
if (ImGui::Selectable(Lang(algorithm->getUnlocalizedName()))) {
|
||||
m_algorithm = algorithm.get();
|
||||
m_analyzed = false;
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
if (m_algorithm != nullptr) {
|
||||
ImGuiExt::TextFormattedWrapped("{}", Lang(m_algorithm->getUnlocalizedDescription()));
|
||||
}
|
||||
|
||||
ImGuiExt::Header("hex.diffing.view.diff.settings"_lang);
|
||||
if (m_algorithm != nullptr) {
|
||||
auto drawList = ImGui::GetWindowDrawList();
|
||||
auto prevIdx = drawList->_VtxCurrentIdx;
|
||||
m_algorithm->drawSettings();
|
||||
auto currIdx = drawList->_VtxCurrentIdx;
|
||||
|
||||
if (prevIdx == currIdx)
|
||||
ImGuiExt::TextFormatted("hex.diffing.view.diff.settings.no_settings"_lang);
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::TableNextRow();
|
||||
|
||||
// Draw first hex editor column
|
||||
@ -337,4 +300,42 @@ namespace hex::plugin::diffing {
|
||||
}
|
||||
}
|
||||
|
||||
void ViewDiff::drawAlwaysVisibleContent() {
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(400_scaled, 600_scaled));
|
||||
if (ImGui::BeginPopup("##DiffingAlgorithmSettings")) {
|
||||
ImGuiExt::Header("hex.diffing.view.diff.algorithm"_lang, true);
|
||||
ImGui::PushItemWidth(300_scaled);
|
||||
if (ImGui::BeginCombo("##Algorithm", m_algorithm == nullptr ? "" : Lang(m_algorithm->getUnlocalizedName()))) {
|
||||
for (const auto &algorithm : ContentRegistry::Diffing::impl::getAlgorithms()) {
|
||||
ImGui::PushID(algorithm.get());
|
||||
if (ImGui::Selectable(Lang(algorithm->getUnlocalizedName()))) {
|
||||
m_algorithm = algorithm.get();
|
||||
m_analyzed = false;
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
if (m_algorithm != nullptr) {
|
||||
ImGuiExt::TextFormattedWrapped("{}", Lang(m_algorithm->getUnlocalizedDescription()));
|
||||
}
|
||||
|
||||
ImGuiExt::Header("hex.diffing.view.diff.settings"_lang);
|
||||
if (m_algorithm != nullptr) {
|
||||
auto drawList = ImGui::GetWindowDrawList();
|
||||
auto prevIdx = drawList->_VtxCurrentIdx;
|
||||
m_algorithm->drawSettings();
|
||||
auto currIdx = drawList->_VtxCurrentIdx;
|
||||
|
||||
if (prevIdx == currIdx)
|
||||
ImGuiExt::TextFormatted("hex.diffing.view.diff.settings.no_settings"_lang);
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user