Added frame buffer information display in session preview

This commit is contained in:
brunoherbelin
2020-10-31 19:21:05 +01:00
parent 940dd0f2a5
commit 8ef79a6dbd
5 changed files with 40 additions and 13 deletions

View File

@@ -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);

View File

@@ -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_; }

View File

@@ -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");

View File

@@ -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;

View File

@@ -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");