Skip to content

Commit

Permalink
Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Feb 28, 2024
1 parent f2ca829 commit 49efb3e
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 74 deletions.
7 changes: 6 additions & 1 deletion mrv2/docs/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ v1.0.7
- 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.

- Fixed Media Information panel not refreshing properly when changing images.
- mrv2's tlRender library now reads the video and audio stream metadata.
- When there's no audio metadata there's no longer the titles of
Attribute/Value used at the end of the Metadata tab in the Media Info Panel.
- Metadata is now sorted and stripped of repeated data.
- Metadata folder now remembers to be opened.


v1.0.6
Expand Down
10 changes: 4 additions & 6 deletions mrv2/lib/mrvApp/mrvApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,26 +634,24 @@ namespace mrv
const char* kModule = "";
for (const auto& i : value)
{
const std::string& msg = i.message;
if (msg == lastMessage)
return;
lastMessage = msg;
switch (i.type)
{
case log::Type::Error:
{
const std::string& msg = i.message;
if (msg == lastMessage)
return;
lastMessage = msg;
LOG_ERROR(msg);
break;
}
case log::Type::Warning:
{
const std::string& msg = i.message;
LOG_WARNING(msg);
break;
}
case log::Type::Status:
{
const std::string& msg = i.message;
LOG_INFO(msg);
break;
}
Expand Down
9 changes: 9 additions & 0 deletions mrv2/lib/mrvCore/mrvString.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ namespace mrv
double toDouble() const;
};

struct CaseInsensitiveCompare
{
inline bool operator()(const std::string& a,
const std::string& b) const
{
return string::toLower(a) < string::toLower(b);
}
};

} // namespace string

} // namespace mrv
2 changes: 1 addition & 1 deletion mrv2/lib/mrvGL/mrvTimelineViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace mrv
float TimelineViewport::Private::helpTextFade;
bool TimelineViewport::Private::hudActive = true;
HudDisplay TimelineViewport::Private::hud = HudDisplay::kNone;
std::map<std::string, std::string, CaseInsensitiveCompare>
std::map<std::string, std::string, string::CaseInsensitiveCompare>
TimelineViewport::Private::tagData;

static void drawTimeoutText_cb(TimelineViewport* view)
Expand Down
11 changes: 3 additions & 8 deletions mrv2/lib/mrvGL/mrvTimelineViewportPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,20 @@
#include <tlTimeline/BackgroundOptions.h>
#include <tlTimeline/Player.h>

#include "mrvCore/mrvString.h"

#include "mrvDraw/Annotation.h"

class ViewerUI;
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;
string::CaseInsensitiveCompare> tagData;
static timeline::BackgroundOptions backgroundOptions;

timeline::OCIOOptions ocioOptions;
Expand Down
120 changes: 63 additions & 57 deletions mrv2/lib/mrvPanels/mrvImageInfoPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "mrvCore/mrvI8N.h"
#include "mrvCore/mrvUtil.h"
#include "mrvCore/mrvSequence.h"
#include "mrvCore/mrvString.h"
#include "mrvCore/mrvMath.h"

#include "mrvFl/mrvHotkey.h"
Expand Down Expand Up @@ -446,8 +447,7 @@ namespace mrv

std::string prefix = tab_prefix();
std::string key = prefix + "Main";
std_any value = settings->getValue<std::any>(key);
int open = std_any_empty(value) ? 1 : std_any_cast<int>(value);
int open = settings->getValue<int>(key);
if (!open)
m_image->close();

Expand All @@ -468,14 +468,12 @@ namespace mrv
m_video);

key = prefix + "Video";
value = settings->getValue<std::any>(key);
open = std_any_empty(value) ? 0 : std_any_cast<int>(value);
open = settings->getValue<int>(key);
if (!open)
m_video->close();

Y += m_video->h();
m_audio = new CollapsibleGroup(g->x(), Y, W, 400, _("Audio"));
m_audio->close();
m_audio->end();
b = m_audio->button();
b->callback(
Expand All @@ -491,14 +489,14 @@ namespace mrv
m_audio);

key = prefix + "Audio";
value = settings->getValue<std::any>(key);
open = std_any_empty(value) ? 0 : std_any_cast<int>(value);
open = settings->getValue<int>(key);
if (!open)
m_audio->close();

Y += m_audio->h();


m_subtitle = new CollapsibleGroup(g->x(), Y, W, 400, _("Subtitle"));
m_subtitle->close();
m_subtitle->end();
b = m_subtitle->button();
b->callback(
Expand All @@ -514,15 +512,13 @@ namespace mrv
m_subtitle);

key = prefix + "Subtitle";
value = settings->getValue<std::any>(key);
open = std_any_empty(value) ? 0 : std_any_cast<int>(value);
open = settings->getValue<int>(key);
if (!open)
m_subtitle->close();

Y += m_subtitle->h();
m_attributes =
new CollapsibleGroup(g->x(), Y, W, 400, _("Metadata"));
m_attributes->close();
m_attributes->end();
b = m_attributes->button();
b->callback(
Expand Down Expand Up @@ -704,7 +700,7 @@ namespace mrv
m_subtitle->hide();
m_attributes->hide();

DBG3;

}

void ImageInfoPanel::set_tabs() const
Expand Down Expand Up @@ -754,17 +750,17 @@ namespace mrv

fill_data();

m_image->end();
m_attributes->end();
m_video->end();
m_audio->end();
m_subtitle->end();
m_audio->end();
m_video->end();
m_image->end();


if (player)
g->end();

DBG3;

}

Table*
Expand Down Expand Up @@ -1932,13 +1928,13 @@ namespace mrv
_("OCIO Input Color Space"),
img->ocio_input_color_space().c_str() );

DBG3;

++group;
#endif

#if 0

DBG3;

if ( !img->has_video() )
{
add_text( _("Line Order"), _("Line order in file"),
Expand All @@ -1951,7 +1947,7 @@ namespace mrv
{
++group;

DBG3;


add_text( _("Compression"), _("Clip Compression"), img->compression() );

Expand All @@ -1965,15 +1961,15 @@ namespace mrv
#if 0


DBG3;

const char* space_type = nullptr;
double memory_space = double( to_memory( (long double)img->memory(),
space_type ) );
snprintf( buf, 256, "%.3f %s", memory_space, space_type );
add_text( _("Memory"), _("Memory without Compression"), buf );


DBG3;

if ( img->disk_space() >= 0 )
{

Expand All @@ -1984,7 +1980,7 @@ namespace mrv
(long double) img->memory() ) );


DBG3;

snprintf( buf, 256, _("%.3f %s (%.2f %% of memory size)"),
disk_space, space_type, pct );

Expand All @@ -2003,50 +1999,22 @@ namespace mrv
}


DBG3;


++group;
add_text( _("Creation Date"), _("Creation Date"), img->creation_date() );


DBG3;



DBG3;

#endif

DBG3;


g->tooltip(nullptr);

image::Tags tags;
if (!videoData.empty() && !videoData[0].layers.empty() &&
videoData[0].layers[0].image)
{
{
m_curr = add_browser(m_attributes);
tags = videoData[0].layers[0].image->getTags();
for (const auto& tag : tags)
{
add_text(_(tag.first.c_str()), "", tag.second);
}

m_attributes->show();
}
}

m_curr = add_browser(m_attributes);

for (const auto& tag : info.tags)
{
auto it = tags.find(tag.first);
if (it != tags.end())
continue;
add_text(_(tag.first.c_str()), "", tag.second);
}

m_attributes->show();

if (num_audio_streams > 0)
{
for (int i = 0; i < num_audio_streams; ++i)
Expand Down Expand Up @@ -2108,9 +2076,6 @@ namespace mrv

++group;

add_text(_("Language"), _("Language if known"), audio.name);
++group;

#if 0
add_text( _("Disposition"), _("Disposition of Track"),
s.disposition);
Expand Down Expand Up @@ -2172,6 +2137,47 @@ namespace mrv
}
#endif

std::map<std::string, std::string,
string::CaseInsensitiveCompare> tagData;
image::Tags tags;

// First, add global tags
for (const auto& tag : info.tags)
{
tagData[tag.first] = tag.second;
}

// Then add image tags
if (!videoData.empty() && !videoData[0].layers.empty() &&
videoData[0].layers[0].image)
{
m_curr = add_browser(m_attributes);
tags = videoData[0].layers[0].image->getTags();
for (const auto& tag : tags)
{
tagData[tag.first] = tag.second;
}
}

for (const auto& item : tagData)
{
bool skip = false;
if (item.first.substr(0, 5) == "Video" ||
item.first.substr(0, 5) == "Audio")
{
if (item.first.substr(0, 12) != "Video Stream" &&
item.first.substr(0, 12) != "Audio Stream")
skip = true;
}
if (skip)
{
continue;
}
add_text( _(item.first.c_str()), "", _(item.second.c_str()));
}

m_attributes->show();

// Call g->end() so we refresh the pack/scroll sizes
// g->end();
}
Expand Down
2 changes: 1 addition & 1 deletion tlRender

0 comments on commit 49efb3e

Please sign in to comment.