OpenTimelineIO / raven

Raven - OpenTimelineIO Viewer Application
Apache License 2.0
74 stars 15 forks source link

Enable/Disable Clips #27

Open rjwignar opened 7 months ago

rjwignar commented 7 months ago

This is a Work-In-Progress Pull Request meant to solve #19

Summary of Changes (WIP)

inspector.cpp

timeline.cpp

Request for help - Use Checkbox while keeping Item::_enabled private

The ImGui::Checkbox() only works as presented if Item::_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() and Item::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.

linux-foundation-easycla[bot] commented 7 months ago

CLA Not Signed

jminor commented 6 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?

meshula commented 6 months ago

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();