diff --git a/Sources/Overload/OvEditor/src/OvEditor/Panels/Inspector.cpp b/Sources/Overload/OvEditor/src/OvEditor/Panels/Inspector.cpp index 0dc8e38e1..3b88872c0 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Panels/Inspector.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Panels/Inspector.cpp @@ -125,7 +125,6 @@ OvEditor::Panels::Inspector::Inspector auto defineButtonsStates = [&addComponentButton](bool p_componentExists) { addComponentButton.disabled = p_componentExists; - addComponentButton.idleBackgroundColor = !p_componentExists ? OvUI::Types::Color{ 0.7f, 0.5f, 0.f } : OvUI::Types::Color{ 0.1f, 0.1f, 0.1f }; }; switch (p_value) @@ -174,7 +173,6 @@ OvEditor::Panels::Inspector::Inspector const bool isScriptValid = std::filesystem::exists(realScriptPath) && targetActor && !targetActor->GetBehaviour(p_script); addScriptButton.disabled = !isScriptValid; - addScriptButton.idleBackgroundColor = isScriptValid ? OvUI::Types::Color{ 0.7f, 0.5f, 0.f } : OvUI::Types::Color{ 0.1f, 0.1f, 0.1f }; }; m_scriptSelectorWidget->ContentChangedEvent += updateAddScriptButton; diff --git a/Sources/Overload/OvUI/src/OvUI/Widgets/Buttons/Button.cpp b/Sources/Overload/OvUI/src/OvUI/Widgets/Buttons/Button.cpp index 7bfd7f1fd..bc3d249a0 100644 --- a/Sources/Overload/OvUI/src/OvUI/Widgets/Buttons/Button.cpp +++ b/Sources/Overload/OvUI/src/OvUI/Widgets/Buttons/Button.cpp @@ -35,8 +35,24 @@ void OvUI::Widgets::Buttons::Button::_Draw_Impl() style.Colors[ImGuiCol_ButtonActive] = OvUI::Internal::Converter::ToImVec4(clickedBackgroundColor); style.Colors[ImGuiCol_Text] = OvUI::Internal::Converter::ToImVec4(textColor); - if (ImGui::ButtonEx((label + m_widgetID).c_str(), Internal::Converter::ToImVec2(size), disabled ? ImGuiItemFlags_Disabled : 0)) + // Instead of using disabled directly, as its value can change if some + // callback is bound to the ClickedEvent. + const bool isDisabled = disabled; + + if (isDisabled) + { + ImGui::BeginDisabled(); + } + + if (ImGui::Button((label + m_widgetID).c_str(), Internal::Converter::ToImVec2(size))) + { ClickedEvent.Invoke(); + } + + if (isDisabled) + { + ImGui::EndDisabled(); + } style.Colors[ImGuiCol_Button] = defaultIdleColor; style.Colors[ImGuiCol_ButtonHovered] = defaultHoveredColor; diff --git a/Sources/Overload/OvUI/src/OvUI/Widgets/Buttons/ButtonImage.cpp b/Sources/Overload/OvUI/src/OvUI/Widgets/Buttons/ButtonImage.cpp index 53eeb5490..ed1228fa1 100644 --- a/Sources/Overload/OvUI/src/OvUI/Widgets/Buttons/ButtonImage.cpp +++ b/Sources/Overload/OvUI/src/OvUI/Widgets/Buttons/ButtonImage.cpp @@ -20,6 +20,22 @@ void OvUI::Widgets::Buttons::ButtonImage::_Draw_Impl() ImVec4 bg = Internal::Converter::ToImVec4(background); ImVec4 tn = Internal::Converter::ToImVec4(tint); - if (ImGui::ImageButtonEx(ImGui::GetID(m_widgetID.c_str()), textureID.id, Internal::Converter::ToImVec2(size), ImVec2(0.f, 1.f), ImVec2(1.f, 0.f), bg, tn, disabled ? ImGuiItemFlags_Disabled : 0)) + // Instead of using disabled directly, as its value can change if some + // callback is bound to the ClickedEvent. + const bool isDisabled = disabled; + + if (isDisabled) + { + ImGui::BeginDisabled(); + } + + if (ImGui::ImageButtonEx(ImGui::GetID(m_widgetID.c_str()), textureID.id, Internal::Converter::ToImVec2(size), ImVec2(0.f, 1.f), ImVec2(1.f, 0.f), bg, tn)) + { ClickedEvent.Invoke(); + } + + if (isDisabled) + { + ImGui::EndDisabled(); + } }