From 69c7033b18db49f2c5e1ab46e1af0bdbacb70fca Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sat, 5 Aug 2017 16:21:36 +0200 Subject: [PATCH] GUI: headers: add support for "video projection" track headers Implements part of #2064. --- NEWS.md | 2 ++ src/mkvtoolnix-gui/header_editor/tab.cpp | 28 ++++++++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/NEWS.md b/NEWS.md index e8cd683ee..2cdfd7e3e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -26,6 +26,8 @@ attributes. Part of the implementation of #2064. * mkvpropedit: added support for the "video projection" track header attributes. Part of the implementation of #2064. +* MKVToolNix GUI: header editor: added support for the "video projection" + track header attributes. Part of the implementation of #2064. ## Bug fixes diff --git a/src/mkvtoolnix-gui/header_editor/tab.cpp b/src/mkvtoolnix-gui/header_editor/tab.cpp index 11b2c9735..53096b016 100644 --- a/src/mkvtoolnix-gui/header_editor/tab.cpp +++ b/src/mkvtoolnix-gui/header_editor/tab.cpp @@ -355,29 +355,22 @@ Tab::pruneEmptyMastersForTrack(TrackTypePage &page) { if (!mtx::included_in(trackType, track_video, track_audio)) return; - auto handler = [](EbmlMaster *parent, EbmlMaster *child) { - if (!parent || !child || (0 < child->ListSize())) - return; - - auto itr = std::find(parent->begin(), parent->end(), child); - if (itr != parent->end()) - parent->Remove(itr); - - delete child; - }; + std::unordered_map handled; if (trackType == track_video) { auto trackVideo = &GetChild(page.m_master); auto videoColour = &GetChild(trackVideo); auto videoColourMasterMeta = &GetChild(videoColour); + auto videoProjection = &GetChild(trackVideo); - handler(videoColour, videoColourMasterMeta); - handler(trackVideo, videoColour); - handler(&page.m_master, trackVideo); + remove_master_from_parent_if_empty_or_only_defaults(videoColour, videoColourMasterMeta, handled); + remove_master_from_parent_if_empty_or_only_defaults(trackVideo, videoColour, handled); + remove_master_from_parent_if_empty_or_only_defaults(trackVideo, videoProjection, handled); + remove_master_from_parent_if_empty_or_only_defaults(&page.m_master, trackVideo, handled); } else // trackType is track_audio - handler(&page.m_master, &GetChild(page.m_master)); + remove_master_from_parent_if_empty_or_only_defaults(&page.m_master, &GetChild(page.m_master), handled); } void @@ -487,13 +480,20 @@ Tab::handleTracks(kax_analyzer_data_c const &data) { colourMasterMetaPage->setParentPage(*page); colourMasterMetaPage->init(); + auto projectionPage = new TopLevelPage{*this, YT("Video projection information")}; + projectionPage->setInternalIdentifier(Q("videoProjection %1").arg(trackIdxMkvmerge - 1)); + projectionPage->setParentPage(*page); + projectionPage->init(); + parentMastersByCallback[&KaxTrackVideo::ClassInfos] = &GetChild(kTrackEntry); parentMastersByCallback[&KaxVideoColour::ClassInfos] = &GetChild(parentMastersByCallback[&KaxTrackVideo::ClassInfos]); parentMastersByCallback[&KaxVideoColourMasterMeta::ClassInfos] = &GetChild(parentMastersByCallback[&KaxVideoColour::ClassInfos]); + parentMastersByCallback[&KaxVideoProjection::ClassInfos] = &GetChild(parentMastersByCallback[&KaxTrackVideo::ClassInfos]); parentPagesByCallback[&KaxTrackVideo::ClassInfos] = page; parentPagesByCallback[&KaxVideoColour::ClassInfos] = colourPage; parentPagesByCallback[&KaxVideoColourMasterMeta::ClassInfos] = colourMasterMetaPage; + parentPagesByCallback[&KaxVideoProjection::ClassInfos] = projectionPage; } else if (track_audio == trackType) { parentMastersByCallback[&KaxTrackAudio::ClassInfos] = &GetChild(kTrackEntry);