Skip to content

Commit

Permalink
Improved HUD attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Feb 28, 2024
1 parent 0cc5168 commit f2ca829
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 33 deletions.
2 changes: 2 additions & 0 deletions mrv2/docs/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.



Expand Down
39 changes: 8 additions & 31 deletions mrv2/lib/mrvGL/mrvGLViewportDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// mrv2
// Copyright Contributors to the mrv2 Project. All rights reserved.

#include <tlCore/String.h>
#include <tlCore/Mesh.h>
#include <tlGL/Util.h>

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down
51 changes: 49 additions & 2 deletions mrv2/lib/mrvGL/mrvTimelineViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ namespace mrv
float TimelineViewport::Private::helpTextFade;
bool TimelineViewport::Private::hudActive = true;
HudDisplay TimelineViewport::Private::hud = HudDisplay::kNone;
std::map<std::string, std::string, CaseInsensitiveCompare>
TimelineViewport::Private::tagData;

static void drawTimeoutText_cb(TimelineViewport* view)
{
Expand Down Expand Up @@ -665,7 +667,7 @@ namespace mrv
}

p.ui->uiColorChannel->redraw();

refreshWindows(); // needed - do not remove.
}

Expand Down Expand Up @@ -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 &&
Expand Down Expand Up @@ -963,17 +966,25 @@ 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");
if (i != tags.end())
refresh = true;

if (refresh)
{
panel::imageInfoPanel->refresh();
}
}

if (p.selection.max.x != -1)
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions mrv2/lib/mrvGL/mrvTimelineViewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ namespace mrv

float _getZoomSpeedValue() const noexcept;

void _getTags() const noexcept;

TLRENDER_PRIVATE();
};
} // namespace mrv
10 changes: 10 additions & 0 deletions mrv2/lib/mrvGL/mrvTimelineViewportPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, std::string,
CaseInsensitiveCompare> tagData;
static timeline::BackgroundOptions backgroundOptions;

timeline::OCIOOptions ocioOptions;
timeline::LUTOptions lutOptions;
std::vector<tl::timeline::ImageOptions> imageOptions;
Expand Down

0 comments on commit f2ca829

Please sign in to comment.