fix: Patterns in pattern data view not being editable in providers that are not writable from the start
This commit is contained in:
parent
5948a74ad1
commit
22252d9044
@ -29,7 +29,7 @@ namespace hex::plugin::builtin {
|
|||||||
(*m_patternDrawer)->reset();
|
(*m_patternDrawer)->reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
EventPatternExecuted::subscribe(this, [this](auto){
|
EventPatternExecuted::subscribe(this, [this](const auto&){
|
||||||
(*m_patternDrawer)->reset();
|
(*m_patternDrawer)->reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -41,11 +41,11 @@ namespace hex::plugin::builtin {
|
|||||||
return { m_hoveredPatternRegion };
|
return { m_hoveredPatternRegion };
|
||||||
});
|
});
|
||||||
|
|
||||||
m_patternDrawer.setOnCreateCallback([this](const prv::Provider *provider, auto &drawer) {
|
m_patternDrawer.setOnCreateCallback([this](const prv::Provider *, auto &drawer) {
|
||||||
drawer = std::make_unique<ui::PatternDrawer>();
|
drawer = std::make_unique<ui::PatternDrawer>();
|
||||||
|
|
||||||
drawer->setSelectionCallback([](const pl::ptrn::Pattern *pattern) {
|
drawer->setSelectionCallback([](const pl::ptrn::Pattern *pattern) {
|
||||||
ImHexApi::HexEditor::setSelection(Region { pattern->getOffset(), pattern->getSize() });
|
ImHexApi::HexEditor::setSelection(Region(pattern->getOffset(), pattern->getSize()));
|
||||||
RequestPatternEditorSelectionChange::post(pattern->getLine(), 0);
|
RequestPatternEditorSelectionChange::post(pattern->getLine(), 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -53,12 +53,11 @@ namespace hex::plugin::builtin {
|
|||||||
if (pattern == nullptr)
|
if (pattern == nullptr)
|
||||||
m_hoveredPatternRegion = Region::Invalid();
|
m_hoveredPatternRegion = Region::Invalid();
|
||||||
else
|
else
|
||||||
m_hoveredPatternRegion = { pattern->getOffset(), pattern->getSize() };
|
m_hoveredPatternRegion = Region(pattern->getOffset(), pattern->getSize());
|
||||||
});
|
});
|
||||||
|
|
||||||
drawer->setTreeStyle(m_treeStyle);
|
drawer->setTreeStyle(m_treeStyle);
|
||||||
drawer->enableRowColoring(m_rowColoring);
|
drawer->enableRowColoring(m_rowColoring);
|
||||||
drawer->enablePatternEditing(provider->isWritable());
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,9 +72,10 @@ namespace hex::plugin::builtin {
|
|||||||
// Make sure the runtime has finished evaluating and produced valid patterns
|
// Make sure the runtime has finished evaluating and produced valid patterns
|
||||||
auto &runtime = ContentRegistry::PatternLanguage::getRuntime();
|
auto &runtime = ContentRegistry::PatternLanguage::getRuntime();
|
||||||
|
|
||||||
const auto height = std::max(ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeightWithSpacing() - ImGui::GetStyle().FramePadding.y * 2, ImGui::GetTextLineHeightWithSpacing() * 5);
|
const auto height = std::max(ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeightWithSpacing() - (ImGui::GetStyle().FramePadding.y * 2), ImGui::GetTextLineHeightWithSpacing() * 5);
|
||||||
|
|
||||||
if (*m_patternDrawer != nullptr) {
|
if (*m_patternDrawer != nullptr) {
|
||||||
|
(*m_patternDrawer)->enablePatternEditing(ImHexApi::Provider::get()->isWritable());
|
||||||
if (!runtime.arePatternsValid()) {
|
if (!runtime.arePatternsValid()) {
|
||||||
(*m_patternDrawer)->draw({ }, nullptr, height);
|
(*m_patternDrawer)->draw({ }, nullptr, height);
|
||||||
} else {
|
} else {
|
||||||
|
@ -454,7 +454,7 @@ namespace hex::ui {
|
|||||||
if (ImGui::Selectable("##PatternLine", false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap)) {
|
if (ImGui::Selectable("##PatternLine", false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap)) {
|
||||||
m_selectionCallback(&pattern);
|
m_selectionCallback(&pattern);
|
||||||
|
|
||||||
if (m_editingPattern != &pattern) {
|
if (m_editingPattern != nullptr && m_editingPattern != &pattern) {
|
||||||
this->resetEditing();
|
this->resetEditing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -565,7 +565,6 @@ namespace hex::ui {
|
|||||||
pattern.setValue(boolValue);
|
pattern.setValue(boolValue);
|
||||||
}
|
}
|
||||||
} else if (std::holds_alternative<i128>(value)) {
|
} else if (std::holds_alternative<i128>(value)) {
|
||||||
ImGui::SetKeyboardFocusHere();
|
|
||||||
if (ImGui::InputText("##Value", valueString, ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_EnterReturnsTrue)) {
|
if (ImGui::InputText("##Value", valueString, ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_EnterReturnsTrue)) {
|
||||||
wolv::math_eval::MathEvaluator<i128> mathEvaluator;
|
wolv::math_eval::MathEvaluator<i128> mathEvaluator;
|
||||||
|
|
||||||
@ -575,7 +574,6 @@ namespace hex::ui {
|
|||||||
this->resetEditing();
|
this->resetEditing();
|
||||||
}
|
}
|
||||||
} else if (std::holds_alternative<u128>(value)) {
|
} else if (std::holds_alternative<u128>(value)) {
|
||||||
ImGui::SetKeyboardFocusHere();
|
|
||||||
if (ImGui::InputText("##Value", valueString, ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_EnterReturnsTrue)) {
|
if (ImGui::InputText("##Value", valueString, ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_EnterReturnsTrue)) {
|
||||||
wolv::math_eval::MathEvaluator<u128> mathEvaluator;
|
wolv::math_eval::MathEvaluator<u128> mathEvaluator;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user