Minor improvements timeline display

This commit is contained in:
Bruno
2021-05-30 22:56:13 +02:00
parent 61164e627b
commit 552c09d377
2 changed files with 33 additions and 19 deletions

View File

@@ -532,7 +532,17 @@ bool ImGuiToolkit::TimelineSlider(const char* label, guint64 *time, guint64 star
if (tick_step_pixels > 5.f) if (tick_step_pixels > 5.f)
{ {
large_tick_step = 10 * step; large_tick_step = 10 * step;
label_tick_step = 30 * step;
if (step > 0) {
// try to put a label every second
if ( 1000000000 % step < 1000)
label_tick_step = (1000000000 / step) * step;
// not a round framerate: probalby best to use 10 frames interval
else
label_tick_step = 10 * step;
}
else
label_tick_step = 30 * step;
} }
else { else {
// while there is less than 5 pixels between two tick marks (or at last optimal tick mark) // while there is less than 5 pixels between two tick marks (or at last optimal tick mark)
@@ -569,9 +579,9 @@ bool ImGuiToolkit::TimelineSlider(const char* label, guint64 *time, guint64 star
// label tick mark // label tick mark
if ( !(tick%label_tick_step) ) { if ( !(tick%label_tick_step) ) {
tick_length = fontsize; tick_length = fontsize;
guint64 ticklabel = 100 * (guint64) round( (double)( tick ) / 100.0); // round value to avoid '0.99' and alike
ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%s", ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%s",
GstToolkit::time_to_string(tick, GstToolkit::TIME_STRING_MINIMAL).c_str()); GstToolkit::time_to_string(ticklabel, GstToolkit::TIME_STRING_MINIMAL).c_str());
overlay_size = ImGui::CalcTextSize(overlay_buf, NULL); overlay_size = ImGui::CalcTextSize(overlay_buf, NULL);
ImVec2 mini = ImVec2( pos.x - overlay_size.x / 2.f, pos.y + tick_length ); ImVec2 mini = ImVec2( pos.x - overlay_size.x / 2.f, pos.y + tick_length );
ImVec2 maxi = ImVec2( pos.x + overlay_size.x / 2.f, pos.y + tick_length + overlay_size.y ); ImVec2 maxi = ImVec2( pos.x + overlay_size.x / 2.f, pos.y + tick_length + overlay_size.y );

View File

@@ -2421,7 +2421,7 @@ void SourceController::RenderSingleSource(Source *s)
ImGui::Text("%s", info_.str().c_str()); ImGui::Text("%s", info_.str().c_str());
StreamSource *sts = dynamic_cast<StreamSource*>(s); StreamSource *sts = dynamic_cast<StreamSource*>(s);
if (sts) { if (sts && s->playing()) {
ImGui::SetCursorScreenPos(top + ImVec2( framesize.x - 1.5f * _buttons_height, 0.5f * tooltip_height)); ImGui::SetCursorScreenPos(top + ImVec2( framesize.x - 1.5f * _buttons_height, 0.5f * tooltip_height));
ImGui::Text("%.1f Hz", sts->stream()->updateFrameRate()); ImGui::Text("%.1f Hz", sts->stream()->updateFrameRate());
} }
@@ -2483,8 +2483,10 @@ void SourceController::RenderMediaPlayer(MediaPlayer *mp)
ImGui::SetCursorScreenPos(top + ImVec2(_h_space, _v_space)); ImGui::SetCursorScreenPos(top + ImVec2(_h_space, _v_space));
ImGui::Text("%s", info_.str().c_str()); ImGui::Text("%s", info_.str().c_str());
ImGui::SetCursorScreenPos(top + ImVec2( framesize.x - 1.5f * _buttons_height, 0.666f * tooltip_height)); if (mp->isPlaying()) {
ImGui::Text("%.1f Hz", mp->updateFrameRate()); ImGui::SetCursorScreenPos(top + ImVec2( framesize.x - 1.5f * _buttons_height, 0.666f * tooltip_height));
ImGui::Text("%.1f Hz", mp->updateFrameRate());
}
} }
/// ///
@@ -2627,21 +2629,23 @@ void SourceController::RenderMediaPlayer(MediaPlayer *mp)
size.x *= timeline_zoom; size.x *= timeline_zoom;
bool released = false; bool released = false;
if ( ImGuiToolkit::EditPlotHistoLines("##TimelineArray", Timeline *tl = mp->timeline();
mp->timeline()->gapsArray(), if (tl->is_valid())
mp->timeline()->fadingArray(), {
MAX_TIMELINE_ARRAY, 0.f, 1.f, if ( ImGuiToolkit::EditPlotHistoLines("##TimelineArray", tl->gapsArray(), tl->fadingArray(),
Settings::application.widget.timeline_editmode, &released, size) ) { MAX_TIMELINE_ARRAY, 0.f, 1.f,
mp->timeline()->update(); Settings::application.widget.timeline_editmode, &released, size) ) {
} tl->update();
else if (released) { }
Action::manager().store("Timeline change"); else if (released) {
} Action::manager().store("Timeline change");
}
// custom timeline slider // custom timeline slider
slider_pressed_ = ImGuiToolkit::TimelineSlider("##timeline", &seek_t, mp->timeline()->begin(), slider_pressed_ = ImGuiToolkit::TimelineSlider("##timeline", &seek_t, tl->begin(),
mp->timeline()->end(), mp->timeline()->step(), size.x); tl->end(), tl->step(), size.x);
}
} }
ImGui::EndChild(); ImGui::EndChild();