Skip to content

Commit

Permalink
Fix UID not displayed as Hex and readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
Benualdo committed Sep 28, 2024
1 parent 2944115 commit dbcab8c
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/editor/ImGui/Window/ImGuiWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,14 @@ namespace vg::editor
}

#if VG_ENABLE_UNDO_REDO
if (EditingState::EndEdit == _editingState)
if (!_propContext.m_readOnly)
{
// Finalize Undo/Redo entry after editing
VG_ASSERT(undoRedoManager->HasCurrentlyEditedEntry());
undoRedoManager->AfterChange();
if (EditingState::EndEdit == _editingState)
{
// Finalize Undo/Redo entry after editing
VG_ASSERT(undoRedoManager->HasCurrentlyEditedEntry());
undoRedoManager->AfterChange();
}
}
#endif

Expand Down Expand Up @@ -401,11 +404,17 @@ namespace vg::editor
bool edited = false;

const auto dragSpeed = scalarTraits<S>::is_integer ? ImGuiWindow::getDragSpeedInt(_prop) : ImGuiWindow::getDragSpeedFloat(_prop);
const auto editFormat = scalarTraits<S>::is_integer ? (scalarTraits<S>::is_signed ? g_editIntFormat : g_editUIntFormat ) : g_editFloatFormat;
const auto flags = _prop->GetFlags();

auto editFormat = scalarTraits<S>::is_integer ? (scalarTraits<S>::is_signed ? g_editIntFormat : g_editUIntFormat) : g_editFloatFormat;
if (asBool(PropertyFlags::Hexadecimal & flags))
editFormat = "0x%0X";

VG_ASSERT(!asBool(PropertyFlags::Color & flags) || (count == 3 || count == 4));

if (_propContext.m_readOnly)
ImGui::BeginDisabled(true);

if (asBool(PropertyFlags::Color & flags) && (count == 3 || count == 4))
{
ImGuiColorEditFlags colorEditFlags = 0;
Expand All @@ -432,10 +441,16 @@ namespace vg::editor
edited = ImGui::DragScalarN(ImGuiWindow::getPropertyLabel(_label).c_str(), ImGuiDataTypeInfo<S>::type, &temp, count, dragSpeed, nullptr, nullptr, editFormat);
}

if (_propContext.m_readOnly)
edited = false;

EditingState editingState = undoRedoBeforeEdit<T>(edited, _propContext, _object, _prop, (S*)&temp[0], _ptr, InteractionType::Continuous);

ImGuiWindow::drawPropertyLabel(_propContext, _prop);

if (_propContext.m_readOnly)
ImGui::EndDisabled();

if (edited)
{
if (asBool(PropertyFlags::EulerAngle & flags))
Expand Down

0 comments on commit dbcab8c

Please sign in to comment.