Skip to content

Commit

Permalink
timeline: Only draw InvisibleButton if size greater than zero (#87)
Browse files Browse the repository at this point in the history
Only draw Items, Effects and Transitions if their durations are greater
than zero.

Signed-off-by: Thomas Wilshaw <thomaswilshaw@gmail.com>
  • Loading branch information
ThomasWilshaw authored Dec 5, 2024
1 parent 2039019 commit 36a8d08
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ void DrawItem(
float height,
std::map<otio::Composable*, otio::TimeRange>& range_map) {
auto duration = item->duration();

// If duration is 0, don't draw Item.
if (duration.to_seconds() <= 0) {
return;
}
auto trimmed_range = item->trimmed_range();
float width = duration.to_seconds() * scale;
if (width < 1)
Expand Down Expand Up @@ -254,6 +259,11 @@ void DrawTransition(
float height,
std::map<otio::Composable*, otio::TimeRange>& range_map) {
auto duration = transition->duration();

// If duration is 0, don't draw Transition.
if (duration.to_seconds() <= 0) {
return;
}
float width = duration.to_seconds() * scale;

auto range_it = range_map.find(transition);
Expand Down Expand Up @@ -348,6 +358,12 @@ void DrawEffects(
if (effects.size() == 0)
return;

auto item_duration = item->duration();
// If duration is 0, don't draw Effect.
if (item_duration.to_seconds() <= 0) {
return;
}

std::string label_str;
for (const auto& effect : effects) {
if (label_str != "")
Expand All @@ -358,7 +374,6 @@ void DrawEffects(
const auto text_size = ImGui::CalcTextSize(label_str.c_str());
ImVec2 text_offset(5.0f, 5.0f);

auto item_duration = item->duration();
float item_width = item_duration.to_seconds() * scale;
float width = fminf(item_width, text_size.x + text_offset.x * 2);
float height = fminf(row_height - 2, text_size.y + text_offset.y * 2);
Expand Down

0 comments on commit 36a8d08

Please sign in to comment.