Open rjwignar opened 7 months ago
The typical ImGui pattern for dealing with setter/getters is something like this:
auto enabled = item->enabled();
if (ImGui::Checkbox("Enabled", &enabled)) {
item->set_enabled(enabled);
}
Is that what you tried already?
I believe the problem is that there might be more than one item named "Enabled" in the interface. ImGui requires all the gui elements to be uniquely identified and generally relies on a widgets label for that. So I bet, if you modify your code like the below, it will work.
ImGui::PushId(&item->_enabled);
bool x = ImGui::Checkbox("Enabled", &item->_enabled);
ImGui::PopId();
This is a Work-In-Progress Pull Request meant to solve #19
Summary of Changes (WIP)
inspector.cpp
ImGui::Checkbox()
:timeline.cpp
DrawItem()
, added conditional graying out on disabled itemsfill_color
(obtained by callingUIColorFromName("")
to getIM_COL32(0x88, 0x88, 0x88, 0xff)
).Request for help - Use Checkbox while keeping
Item::_enabled
privateThe
ImGui::Checkbox()
only works as presented ifItem::_enabled
data member is exposed (made a non-private data member). I couldn't get the checkbox to work otherwise. I tried using the public getter/setter methods (Item::enabled()
andItem::set_enabled()
) to make the checkbox functional but the checkbox would quickly un-tick itself once enabled.I'd appreciate any advice on how to add a functional checkbox while keeping
Item::_enabled
private.