Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Sources/Overload/OvEditor/src/OvEditor/Panels/Inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 17 additions & 1 deletion Sources/Overload/OvUI/src/OvUI/Widgets/Buttons/Button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 17 additions & 1 deletion Sources/Overload/OvUI/src/OvUI/Widgets/Buttons/ButtonImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}