Skip to content

Commit

Permalink
Color picker
Browse files Browse the repository at this point in the history
  • Loading branch information
alxbilger authored and fredroy committed Feb 20, 2025
1 parent dff7182 commit 9736636
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions SofaImGui/src/SofaImGui/ImGuiDataWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,23 @@ void DataWidget<helper::BaseSelectableItem>::showWidget(
}
}

/***********************************************************************************************************************
* RGBAColor
**********************************************************************************************************************/

template<>
void DataWidget<type::RGBAColor>::showWidget(MyData& data)
{
const auto& colorData = data.getValue();
const auto& label = data.getName();
const auto id = data.getName() + data.getOwner()->getPathName();
ImVec4 color { colorData.r(), colorData.g(), colorData.b(), colorData.a()};
if (ImGui::ColorEdit4((label + "##" + id).c_str(), (float*)&color, ImGuiColorEditFlags_DisplayRGB))
{
data.setValue(type::RGBAColor(color.x, color.y, color.z, color.w));
}
}

/***********************************************************************************************************************
* Factory
**********************************************************************************************************************/
Expand Down Expand Up @@ -699,4 +716,5 @@ const bool dw_optionsGroup = DataWidgetFactory::Add<helper::OptionsGroup>();

const bool dw_selectable_items = DataWidgetFactory::Add<helper::BaseSelectableItem>();

const bool dw_rgbacolor = DataWidgetFactory::Add<type::RGBAColor>();
}

0 comments on commit 9736636

Please sign in to comment.