diff --git a/mrv2/docs/HISTORY.md b/mrv2/docs/HISTORY.md index 627f5fa51..4152169b0 100644 --- a/mrv2/docs/HISTORY.md +++ b/mrv2/docs/HISTORY.md @@ -62,6 +62,8 @@ v1.0.7 image file, as taken from the playback tool bar. This value will take precedence over the Sequence Default speed as set in Preferences->Playback. - Made warnings also show up in the status bar, but with an orange background. +- Improved HUD Attributes. They are now listed alphabetically and they are not + repeated. Also, they refresh properly. diff --git a/mrv2/lib/mrvGL/mrvGLViewportDraw.cpp b/mrv2/lib/mrvGL/mrvGLViewportDraw.cpp index 519c69bfc..cf376798f 100644 --- a/mrv2/lib/mrvGL/mrvGLViewportDraw.cpp +++ b/mrv2/lib/mrvGL/mrvGLViewportDraw.cpp @@ -2,6 +2,7 @@ // mrv2 // Copyright Contributors to the mrv2 Project. All rights reserved. +#include #include #include @@ -868,7 +869,7 @@ namespace mrv { const auto& info = inPlayer->getIOInfo(); const auto& video = info.video[0]; - if (video.size.pixelAspectRatio != 1.0) + if (video.size.pixelAspectRatio != 1.F) { int width = video.size.w * video.size.pixelAspectRatio; snprintf( @@ -1049,38 +1050,14 @@ namespace mrv if (p.hud & HudDisplay::kAttributes) { - image::Tags tags; - if (!p.videoData.empty() && !p.videoData[0].layers.empty()) - { - if (p.videoData[0].layers[0].image) - { - tags = p.videoData[0].layers[0].image->getTags(); - for (const auto& tag : tags) - { - if (pos.y > viewportSize.h) - return; - snprintf( - buf, 512, "%s = %s", tag.first.c_str(), - tag.second.c_str()); - _drawText( - p.fontSystem->getGlyphs(buf, fontInfo), pos, - lineHeight, labelColor); - } - } - } - const auto& inPlayer = player->player(); - if (!inPlayer) - return; - const auto& info = inPlayer->getIOInfo(); - for (const auto& tag : info.tags) + for (const auto& tag : p.tagData) { if (pos.y > viewportSize.h) - return; - const std::string& key = tag.first; - const std::string rendererKey = "Renderer "; - if (key.compare(0, rendererKey.size(), rendererKey) == 0) - continue; - snprintf(buf, 512, "%s = %s", key.c_str(), tag.second.c_str()); + break; + + snprintf( + buf, 512, "%s = %s", tag.first.c_str(), tag.second.c_str()); + _drawText( p.fontSystem->getGlyphs(buf, fontInfo), pos, lineHeight, labelColor); diff --git a/mrv2/lib/mrvGL/mrvTimelineViewport.cpp b/mrv2/lib/mrvGL/mrvTimelineViewport.cpp index d3af23209..d181b799a 100644 --- a/mrv2/lib/mrvGL/mrvTimelineViewport.cpp +++ b/mrv2/lib/mrvGL/mrvTimelineViewport.cpp @@ -66,6 +66,8 @@ namespace mrv float TimelineViewport::Private::helpTextFade; bool TimelineViewport::Private::hudActive = true; HudDisplay TimelineViewport::Private::hud = HudDisplay::kNone; + std::map + TimelineViewport::Private::tagData; static void drawTimeoutText_cb(TimelineViewport* view) { @@ -665,7 +667,7 @@ namespace mrv } p.ui->uiColorChannel->redraw(); - + refreshWindows(); // needed - do not remove. } @@ -902,6 +904,7 @@ namespace mrv p.videoData[index] = value; if (index == 0) { + _getTags(); int layerId = sender->videoLayer(); p.missingFrame = false; if (p.missingFrameType != MissingFrameType::kBlackFrame && @@ -963,9 +966,15 @@ namespace mrv p.videoData[0].layers[0].image) { bool refresh = false; - if (sender->playback() == timeline::Playback::Stop) + + // If timeline is stopped or has a single frame, + // refresh the media info panel. + if (sender->playback() == timeline::Playback::Stop || + sender->timeRange().duration().value() == 1.0) refresh = true; + // If timeline has a Data Window (it is an OpenEXR) + // we also refresh the media info panel. const auto& tags = p.videoData[0].layers[0].image->getTags(); image::Tags::const_iterator i = tags.find("Data Window"); @@ -973,7 +982,9 @@ namespace mrv refresh = true; if (refresh) + { panel::imageInfoPanel->refresh(); + } } if (p.selection.max.x != -1) @@ -2751,4 +2762,40 @@ namespace mrv return speedValues[idx]; } + void TimelineViewport::_getTags() const noexcept + { + TLRENDER_P(); + + p.tagData.clear(); + + if (p.timelinePlayers.empty()) + return; + + auto sender = p.timelinePlayers[0]; + + char buf[1024]; + + const auto& player = sender->player(); + const auto& info = player->getIOInfo(); + for (const auto& tag : info.tags) + { + const std::string& key = tag.first; + const std::string rendererKey = "Renderer "; + if (key.compare(0, rendererKey.size(), + rendererKey) == 0) + continue; + p.tagData[key] = tag.second; + } + + if (!p.videoData.empty() && !p.videoData[0].layers.empty() && + p.videoData[0].layers[0].image) + { + const auto& tags = + p.videoData[0].layers[0].image->getTags(); + for (const auto& tag : tags) + { + p.tagData[tag.first] = tag.second; + } + } + } } // namespace mrv diff --git a/mrv2/lib/mrvGL/mrvTimelineViewport.h b/mrv2/lib/mrvGL/mrvTimelineViewport.h index 4c1148c1a..fe8061612 100644 --- a/mrv2/lib/mrvGL/mrvTimelineViewport.h +++ b/mrv2/lib/mrvGL/mrvTimelineViewport.h @@ -424,6 +424,8 @@ namespace mrv float _getZoomSpeedValue() const noexcept; + void _getTags() const noexcept; + TLRENDER_PRIVATE(); }; } // namespace mrv diff --git a/mrv2/lib/mrvGL/mrvTimelineViewportPrivate.h b/mrv2/lib/mrvGL/mrvTimelineViewportPrivate.h index b6dd59510..a6e6af756 100644 --- a/mrv2/lib/mrvGL/mrvTimelineViewportPrivate.h +++ b/mrv2/lib/mrvGL/mrvTimelineViewportPrivate.h @@ -16,10 +16,20 @@ class Fl_Menu_Button; namespace mrv { + struct CaseInsensitiveCompare + { + inline bool operator()(const std::string& a, const std::string& b) const + { + return tl::string::toLower(a) < tl::string::toLower(b); + } + }; struct TimelineViewport::Private { + static std::map tagData; static timeline::BackgroundOptions backgroundOptions; + timeline::OCIOOptions ocioOptions; timeline::LUTOptions lutOptions; std::vector imageOptions;