raven icon indicating copy to clipboard operation
raven copied to clipboard

Enable/Disable Clips

Open rjwignar opened this issue 1 year ago • 3 comments

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

Summary of Changes (WIP)

inspector.cpp

  • added 'Enabled' checkbox for non-Gap items (Tracks and Clips) using ImGui::Checkbox(): image

timeline.cpp

  • In DrawItem(), added conditional graying out on disabled items
    • Disabled non-Gap items have a gray fill_color (obtained by calling UIColorFromName("") to get IM_COL32(0x88, 0x88, 0x88, 0xff)).
  • Disabled tracks look like this: image
  • The color change seems to apply only to disabled clips and not disabled tracks
  • The current color for disabled items is just a placeholder until I can find a better color to use.

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.

rjwignar avatar Nov 28 '23 01:11 rjwignar

CLA Not Signed

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?

jminor avatar Jan 05 '24 18:01 jminor

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

meshula avatar Jan 17 '24 22:01 meshula

Closing in favour of #74

rjwignar avatar Sep 28 '24 20:09 rjwignar

Thank you @jminor and @meshula for your suggestions. With your help I was able to redo this work in #74.

rjwignar avatar Sep 28 '24 20:09 rjwignar