From 8ef79a6dbde6cab5b8be4d77e1d9043930337461 Mon Sep 17 00:00:00 2001 From: brunoherbelin Date: Sat, 31 Oct 2020 19:21:05 +0100 Subject: [PATCH] Added frame buffer information display in session preview --- FrameBuffer.cpp | 20 +++++++++++++++++++- FrameBuffer.h | 1 + Mixer.cpp | 13 +++++++------ SessionCreator.cpp | 13 ++++++++++--- UserInterfaceManager.cpp | 6 +++--- 5 files changed, 40 insertions(+), 13 deletions(-) diff --git a/FrameBuffer.cpp b/FrameBuffer.cpp index 568fb07..d6ddc0f 100644 --- a/FrameBuffer.cpp +++ b/FrameBuffer.cpp @@ -9,7 +9,7 @@ const char* FrameBuffer::aspect_ratio_name[5] = { "4:3", "3:2", "16:10", "16:9", "21:9" }; glm::vec2 FrameBuffer::aspect_ratio_size[5] = { glm::vec2(4.f,3.f), glm::vec2(3.f,2.f), glm::vec2(16.f,10.f), glm::vec2(16.f,9.f) , glm::vec2(21.f,9.f) }; -const char* FrameBuffer::resolution_name[4] = { "720p", "1080p", "1440", "4K" }; +const char* FrameBuffer::resolution_name[4] = { "720", "1080", "1440", "4K" }; float FrameBuffer::resolution_height[4] = { 720.f, 1080.f, 1440.f, 2160.f }; @@ -114,6 +114,24 @@ float FrameBuffer::aspectRatio() const } +std::string FrameBuffer::info() const +{ + std::string s = ""; + + static int num_ar = ((int)(sizeof(FrameBuffer::aspect_ratio_size) / sizeof(*FrameBuffer::aspect_ratio_size))); + float myratio = aspectRatio(); + for(int i= 0; i < num_ar; i++) { + if ( myratio - (FrameBuffer::aspect_ratio_size[i].x / FrameBuffer::aspect_ratio_size[i].y ) < EPSILON) + { + s += std::string( FrameBuffer::aspect_ratio_name[i]) + ", "; + break; + } + } + + s += std::to_string(height()) + " px"; + return s; +} + glm::vec3 FrameBuffer::resolution() const { return glm::vec3(attrib_.viewport.x, attrib_.viewport.y, 0.f); diff --git a/FrameBuffer.h b/FrameBuffer.h index d6ea44e..c2b1106 100644 --- a/FrameBuffer.h +++ b/FrameBuffer.h @@ -40,6 +40,7 @@ public: inline uint height() const { return attrib_.viewport.y; } glm::vec3 resolution() const; float aspectRatio() const; + std::string info() const; // internal pixel format inline bool use_alpha() const { return use_alpha_; } diff --git a/Mixer.cpp b/Mixer.cpp index 81e7cbc..5e5b32d 100644 --- a/Mixer.cpp +++ b/Mixer.cpp @@ -46,12 +46,13 @@ static void saveSession(const std::string& filename, Session *session) // creation of XML doc XMLDocument xmlDoc; - XMLElement *version = xmlDoc.NewElement(APP_NAME); - version->SetAttribute("major", XML_VERSION_MAJOR); - version->SetAttribute("minor", XML_VERSION_MINOR); - version->SetAttribute("size", session->numSource()); - version->SetAttribute("date", SystemToolkit::date_time_string().c_str()); - xmlDoc.InsertEndChild(version); + XMLElement *rootnode = xmlDoc.NewElement(APP_NAME); + rootnode->SetAttribute("major", XML_VERSION_MAJOR); + rootnode->SetAttribute("minor", XML_VERSION_MINOR); + rootnode->SetAttribute("size", session->numSource()); + rootnode->SetAttribute("date", SystemToolkit::date_time_string().c_str()); + rootnode->SetAttribute("resolution", session->frame()->info().c_str()); + xmlDoc.InsertEndChild(rootnode); // 1. list of sources XMLElement *sessionNode = xmlDoc.NewElement("Session"); diff --git a/SessionCreator.cpp b/SessionCreator.cpp index 4f3610e..bde276c 100644 --- a/SessionCreator.cpp +++ b/SessionCreator.cpp @@ -37,9 +37,16 @@ std::string SessionCreator::info(const std::string& filename) if (header != nullptr && header->Attribute("date") != 0) { int s = header->IntAttribute("size"); ret = std::to_string( s ) + " source" + ( s > 1 ? "s\n" : "\n"); - std::string date( header->Attribute("date") ); - ret += date.substr(6,2) + "/" + date.substr(4,2) + "/" + date.substr(0,4) + " "; - ret += date.substr(8,2) + ":" + date.substr(10,2) + "\n"; + const char *att_string = header->Attribute("resolution"); + if (att_string) + ret += std::string( att_string ) + "\n"; + att_string = header->Attribute("date"); + if (att_string) { + std::string date( att_string ); + ret += date.substr(6,2) + "/" + date.substr(4,2) + "/" + date.substr(0,4) + " @ "; + ret += date.substr(8,2) + ":" + date.substr(10,2); + } + } return ret; diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index 93d0b13..58a0fb7 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -2362,18 +2362,18 @@ void Navigator::RenderMainPannel() ImGui::Text(APP_NAME); ImGui::PopFont(); - // TODO fixe fullscreen for OSX :( -#ifndef APPLE + // TODO fix fullscreen for OSX :( // Icon to switch fullscreen ImGui::SetCursorPos(ImVec2(pannel_width_ - 35.f, 15.f)); const char *tooltip[2] = {"Enter Fullscreen", "Exit Fullscreen"}; bool fs = Rendering::manager().mainWindow().isFullscreen(); if ( ImGuiToolkit::IconToggle(3,15,2,15, &fs, tooltip ) ) { Rendering::manager().mainWindow().toggleFullscreen(); +#ifndef APPLE ImGui::End(); +#endif return; } -#endif // Session menu ImGui::SetCursorPosY(width_); ImGui::Text("Session");