CedricGuillemet / ImGuizmo

Immediate mode 3D gizmo for scene editing and other controls based on Dear Imgui
MIT License
3.22k stars 907 forks source link

ImSequencer: Fix clip when scrolling out of view #271

Closed idbrii closed 2 years ago

idbrii commented 2 years ago

Fix failure to clip within our parent when using BeginChild.

This is a reimplementation of #57 which no longer merges cleanly. It pulls simpler changes out of #195 to get them merged. See https://github.com/CedricGuillemet/ImGuizmo/pull/195#issuecomment-895619149.

It's just passing true for intersect_with_current_clip_rect in PushClipRect and removing an outdated comment. I've been using this (via #195 for a year and it's worked well).

Test case

Build sample app but with this sequencer section:

if (ImGui::CollapsingHeader("Sequencer"))
{
   // let's create the sequencer
   static int selectedEntry = -1;
   static int firstFrame = 0;
   static bool expanded = true;
   static int currentFrame = 100;
   static bool was_expanded = false;
   ImVec2 sequencer_size = ImGui::GetContentRegionAvail();
   sequencer_size.y -= 20;
   if (was_expanded) {
      sequencer_size.y -= 25 * 2;
   }

   ImGui::BeginChild("Sequencer", sequencer_size);
   {
      Sequencer(&mySequence, &currentFrame, &expanded, &selectedEntry, &firstFrame, ImSequencer::SEQUENCER_EDIT_ALL);
   }
   ImGui::EndChild();

   was_expanded = ImGui::CollapsingHeader("Colors");
   if (was_expanded) {
      static float color[4] = { 0, 0, 0, 0, };
      for (int i = 0; i < 10; ++i) {
         ImGui::ColorEdit4("Color", color);
      }
   }
}

Before

image

After

image