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,6 +532,16 @@ bool ImGuiToolkit::TimelineSlider(const char* label, guint64 *time, guint64 star
if (tick_step_pixels > 5.f)
{
large_tick_step = 10 * 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 {
@@ -569,9 +579,9 @@ bool ImGuiToolkit::TimelineSlider(const char* label, guint64 *time, guint64 star
// label tick mark
if ( !(tick%label_tick_step) ) {
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",
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);
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 );

View File

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