fix: RGBA8 hex editor data visualizer not working correctly
This commit is contained in:
parent
96db2074c6
commit
a6025e72fb
@ -235,15 +235,15 @@ namespace hex::plugin::builtin {
|
|||||||
bool drawEditing(u64 address, u8 *data, size_t size, bool upperCase, bool startedEditing) override {
|
bool drawEditing(u64 address, u8 *data, size_t size, bool upperCase, bool startedEditing) override {
|
||||||
hex::unused(address, data, size, upperCase);
|
hex::unused(address, data, size, upperCase);
|
||||||
|
|
||||||
|
m_currColor = { float(data[0]) / 0xFF, float(data[1]) / 0xFF, float(data[2]) / 0xFF, float(data[3]) / 0xFF };
|
||||||
if (startedEditing) {
|
if (startedEditing) {
|
||||||
m_currColor = { float(data[0]) / 0xFF, float(data[1]) / 0xFF, float(data[2]) / 0xFF, float(data[3]) / 0xFF };
|
|
||||||
ImGui::OpenPopup("##color_popup");
|
ImGui::OpenPopup("##color_popup");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::ColorButton("##color", ImColor(m_currColor[0], m_currColor[1], m_currColor[2], m_currColor[3]), ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoDragDrop, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
|
ImGui::ColorButton("##color", ImColor(m_currColor[0], m_currColor[1], m_currColor[2], m_currColor[3]), ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoDragDrop, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
|
||||||
|
|
||||||
if (ImGui::BeginPopup("##color_popup")) {
|
if (ImGui::BeginPopup("##color_popup")) {
|
||||||
if (ImGui::ColorPicker4("##picker", m_currColor.data(), ImGuiColorEditFlags_AlphaBar)) {
|
if (ImGui::ColorPicker4("##picker", m_currColor.data(), ImGuiColorEditFlags_AlphaBar | ImGuiColorEditFlags_InputRGB)) {
|
||||||
for (u8 i = 0; i < 4; i++)
|
for (u8 i = 0; i < 4; i++)
|
||||||
data[i] = m_currColor[i] * 0xFF;
|
data[i] = m_currColor[i] * 0xFF;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <hex/helpers/encoding_file.hpp>
|
#include <hex/helpers/encoding_file.hpp>
|
||||||
#include <hex/helpers/utils.hpp>
|
#include <hex/helpers/utils.hpp>
|
||||||
|
#include <wolv/utils/guards.hpp>
|
||||||
|
|
||||||
namespace hex::plugin::builtin::ui {
|
namespace hex::plugin::builtin::ui {
|
||||||
|
|
||||||
@ -197,8 +198,10 @@ namespace hex::plugin::builtin::ui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ImGui::SetKeyboardFocusHere();
|
if (m_enteredEditingMode) {
|
||||||
ImGui::SetNextFrameWantCaptureKeyboard(true);
|
ImGui::SetKeyboardFocusHere();
|
||||||
|
ImGui::SetNextFrameWantCaptureKeyboard(true);
|
||||||
|
}
|
||||||
|
|
||||||
bool shouldExitEditingMode = true;
|
bool shouldExitEditingMode = true;
|
||||||
if (cellType == m_editingCellType && cellType == CellType::Hex) {
|
if (cellType == m_editingCellType && cellType == CellType::Hex) {
|
||||||
@ -225,7 +228,7 @@ namespace hex::plugin::builtin::ui {
|
|||||||
size_t writtenBytes = 0;
|
size_t writtenBytes = 0;
|
||||||
for (size_t i = 0; i < m_editingBytes.size(); i += 1) {
|
for (size_t i = 0; i < m_editingBytes.size(); i += 1) {
|
||||||
if (m_editingBytes[i] != oldData[i]) {
|
if (m_editingBytes[i] != oldData[i]) {
|
||||||
m_provider->write(*m_editingAddress, &m_editingBytes[i], 1);
|
m_provider->write(*m_editingAddress + i, &m_editingBytes[i], 1);
|
||||||
writtenBytes += 1;
|
writtenBytes += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -250,7 +253,7 @@ namespace hex::plugin::builtin::ui {
|
|||||||
m_shouldUpdateEditingValue = true;
|
m_shouldUpdateEditingValue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left) && !hovered && !m_enteredEditingMode) {
|
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left) && !hovered && !m_enteredEditingMode && !ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopup)) {
|
||||||
m_editingAddress = std::nullopt;
|
m_editingAddress = std::nullopt;
|
||||||
m_shouldModifyValue = false;
|
m_shouldModifyValue = false;
|
||||||
}
|
}
|
||||||
@ -472,8 +475,12 @@ namespace hex::plugin::builtin::ui {
|
|||||||
this->handleSelection(byteAddress, bytesPerCell, &bytes[x * bytesPerCell], cellHovered);
|
this->handleSelection(byteAddress, bytesPerCell, &bytes[x * bytesPerCell], cellHovered);
|
||||||
|
|
||||||
// Get byte foreground color
|
// Get byte foreground color
|
||||||
if (foregroundColor.has_value())
|
|
||||||
|
auto popForeground = SCOPE_GUARD { ImGui::PopStyleColor(); };
|
||||||
|
if (foregroundColor.has_value() && !m_editingAddress.has_value())
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, *foregroundColor);
|
ImGui::PushStyleColor(ImGuiCol_Text, *foregroundColor);
|
||||||
|
else
|
||||||
|
popForeground.release();
|
||||||
|
|
||||||
// Draw cell content
|
// Draw cell content
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
|
||||||
@ -484,9 +491,6 @@ namespace hex::plugin::builtin::ui {
|
|||||||
ImGuiExt::TextFormatted("{}", std::string(maxCharsPerCell, '?'));
|
ImGuiExt::TextFormatted("{}", std::string(maxCharsPerCell, '?'));
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
if (foregroundColor.has_value())
|
|
||||||
ImGui::PopStyleColor();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
@ -925,4 +929,4 @@ namespace hex::plugin::builtin::ui {
|
|||||||
m_selectionChanged = false;
|
m_selectionChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user