mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-09-18 19:03:42 +08:00
cabana: show placeholder for unresolved timestamps (#38870)
This commit is contained in:
@@ -147,8 +147,13 @@ void VideoWidget::drawPlaybackController() {
|
||||
const char *play_icon = can->isPaused() ? icon::PLAY : icon::PAUSE;
|
||||
const char *play_tooltip = can->isPaused() ? "Play" : "Pause";
|
||||
const char *loop_icon = getReplay() && getReplay()->loop() ? icon::REPEAT : icon::REPEAT_1;
|
||||
const std::string time_text = slider_ ? formatTime(can->currentSec(), true) + " / " + formatTime(slider_->maximum() / slider_->factor)
|
||||
: formatTime(can->currentSec(), true);
|
||||
const bool timestamps_resolved = can->liveStreaming()
|
||||
? msgs_received_
|
||||
: can->beginDateTime() != std::chrono::system_clock::time_point{};
|
||||
const std::string time_text = timestamps_resolved
|
||||
? (slider_ ? formatTime(can->currentSec(), true) + " / " + formatTime(slider_->maximum() / slider_->factor)
|
||||
: formatTime(can->currentSec(), true))
|
||||
: "--:--.-- / --:--.--";
|
||||
const char *time_tooltip = settings.absolute_time ? "Elapsed time" : "Absolute time";
|
||||
|
||||
std::vector<ToolbarItem> items;
|
||||
@@ -161,14 +166,14 @@ void VideoWidget::drawPlaybackController() {
|
||||
} else {
|
||||
items.push_back(toolbarAction("fast-forward", icon::FAST_FORWARD, "Seek forward", []() { can->seekTo(can->currentSec() + 1); }));
|
||||
}
|
||||
if (slider_ || msgs_received_) {
|
||||
if (slider_ || timestamps_resolved) {
|
||||
// a mono font: with proportional digits the time changed width as it ticked and the items after it moved
|
||||
pushMonoFont(ImGui::GetFontSize());
|
||||
pushMonoFont(ImGui::GetStyle().FontSizeBase);
|
||||
const float time_width = ImGui::CalcTextSize(time_text.c_str()).x;
|
||||
popMonoFont();
|
||||
items.push_back({time_width,
|
||||
[&]() {
|
||||
pushMonoFont(ImGui::GetFontSize());
|
||||
pushMonoFont(ImGui::GetStyle().FontSizeBase);
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::TextUnformatted(time_text.c_str());
|
||||
popMonoFont();
|
||||
|
||||
@@ -112,7 +112,7 @@ private:
|
||||
std::string speed_text_;
|
||||
int speed_index_ = -1; // checked entry of the speed menu
|
||||
bool skip_to_end_enabled_ = true;
|
||||
bool msgs_received_ = false; // the time is blank until the live stream delivers its first messages
|
||||
bool msgs_received_ = false; // live-stream timestamps resolve when the first messages arrive
|
||||
double thumbnail_display_time_ = -1;
|
||||
std::unique_ptr<Slider> slider_;
|
||||
std::unique_ptr<TabBar> camera_tab_;
|
||||
|
||||
Reference in New Issue
Block a user