Skip to content

Commit

Permalink
Set size to amount of space required
Browse files Browse the repository at this point in the history
Fix sequencer expands to fill the space its in and pushing other
elements off below it.

The sequencer doesn't need to fill the space and it's likely that you
want to draw additional information about the selection below it.
Instead of filling available space, fill horizontal space and calculate
how much space we need.
  • Loading branch information
idbrii committed Oct 26, 2022
1 parent ae8925a commit 0bebdaf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ImSequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,20 @@ namespace ImSequencer
ImDrawList* draw_list = ImGui::GetWindowDrawList();
ImVec2 canvas_pos = ImGui::GetCursorScreenPos(); // ImDrawList API uses screen coordinates!
ImVec2 canvas_size = ImGui::GetContentRegionAvail(); // Resize canvas to what's available
ImVec2 headerSize(canvas_size.x, (float)ItemHeight);
ImVec2 scrollBarSize(canvas_size.x, 14.f);
int firstFrameUsed = firstFrame ? *firstFrame : 0;


const float spacer = 8.0f;
int controlHeight = sequenceCount * ItemHeight;
for (int i = 0; i < sequenceCount; i++)
controlHeight += int(sequence->GetCustomHeight(i));
int frameCount = ImMax(sequence->GetFrameMax() - sequence->GetFrameMin(), 1);

// Don't hide elements below. Limit our height to the space we use.
canvas_size.y = spacer + 10.0f + static_cast<float>(controlHeight) + headerSize.y + scrollBarSize.y;

static bool MovingScrollBar = false;
static bool MovingCurrentFrame = false;
struct CustomDraw
Expand Down Expand Up @@ -155,12 +161,10 @@ namespace ImSequencer
}
*/
// test scroll area
ImVec2 headerSize(canvas_size.x, (float)ItemHeight);
ImVec2 scrollBarSize(canvas_size.x, 14.f);
ImGui::InvisibleButton("topBar", headerSize);
draw_list->AddRectFilled(canvas_pos, canvas_pos + headerSize, 0xFFFF0000, 0);
ImVec2 childFramePos = ImGui::GetCursorScreenPos();
ImVec2 childFrameSize(canvas_size.x, canvas_size.y - 8.f - headerSize.y - (hasScrollBar ? scrollBarSize.y : 0));
ImVec2 childFrameSize(canvas_size.x, canvas_size.y - spacer - headerSize.y - (hasScrollBar ? scrollBarSize.y : 0));
ImGui::PushStyleColor(ImGuiCol_FrameBg, 0);
ImGui::BeginChildFrame(889, childFrameSize);
sequence->focused = ImGui::IsWindowFocused();
Expand Down

0 comments on commit 0bebdaf

Please sign in to comment.