1
0
mirror of synced 2024-11-28 17:40:51 +01:00

impr: Disable endianess switch in hex editor when visualizer only uses one byte

This commit is contained in:
WerWolv 2023-07-18 14:23:02 +02:00
parent 90267ec356
commit 2d4f971d10

View File

@ -824,11 +824,22 @@ namespace hex::plugin::builtin::ui {
ImGui::SameLine(0, 0);
int sliderPos = this->m_dataVisualizerEndianness == std::endian::little ? 0 : 1;
ImGui::PushItemWidth(60_scaled);
ImGui::SliderInt("##visualizer_endianness", &sliderPos, 0, 1, sliderPos == 0 ? "hex.builtin.common.little"_lang : "hex.builtin.common.big"_lang);
ImGui::PopItemWidth();
this->m_dataVisualizerEndianness = sliderPos == 0 ? std::endian::little : std::endian::big;
{
bool hasEndianess = this->m_currDataVisualizer->getBytesPerCell() > 1;
if (!hasEndianess)
this->m_dataVisualizerEndianness = std::endian::native;
ImGui::BeginDisabled(!hasEndianess);
{
int sliderPos = this->m_dataVisualizerEndianness == std::endian::little ? 0 : 1;
ImGui::PushItemWidth(60_scaled);
ImGui::SliderInt("##visualizer_endianness", &sliderPos, 0, 1, sliderPos == 0 ? "hex.builtin.common.little"_lang : "hex.builtin.common.big"_lang);
ImGui::PopItemWidth();
this->m_dataVisualizerEndianness = sliderPos == 0 ? std::endian::little : std::endian::big;
}
ImGui::EndDisabled();
}
ImGui::SameLine(0, 2_scaled);
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - 60_scaled);