Improved message and log.

This commit is contained in:
brunoherbelin
2021-01-19 19:07:24 +01:00
parent 9449936df0
commit 4e6a402142
5 changed files with 26 additions and 14 deletions

25
Log.cpp
View File

@@ -195,10 +195,10 @@ void Log::Warning(const char* fmt, ...)
Log::Info("Warning - %s\n", buf.c_str());
}
void Log::Render(bool showNofitications, bool showWarnings)
void Log::Render(bool *showWarnings)
{
bool show_warnings = !warnings.empty() & showWarnings;
bool show_notification = !notifications.empty() & showNofitications;
bool show_warnings = !warnings.empty();
bool show_notification = !notifications.empty();
if (!show_notification && !show_warnings)
return;
@@ -238,6 +238,7 @@ void Log::Render(bool showNofitications, bool showWarnings)
notifications.clear();
}
if (show_warnings) {
ImGui::OpenPopup("Warning");
if (ImGui::BeginPopupModal("Warning", NULL, ImGuiWindowFlags_AlwaysAutoResize))
@@ -255,8 +256,21 @@ void Log::Render(bool showNofitications, bool showWarnings)
}
ImGui::PopTextWrapPos();
ImGui::Dummy(ImVec2(width * 0.8f, 0)); ImGui::SameLine(); // right align
if (ImGui::Button(" Ok ", ImVec2(width * 0.2f, 0))) {
bool close = false;
ImGui::Spacing();
if (ImGui::Button("Show logs", ImVec2(width * 0.2f, 0))) {
close = true;
if (showWarnings!= nullptr)
*showWarnings = true;
}
ImGui::SameLine();
ImGui::Dummy(ImVec2(width * 0.6f, 0)); // right align
ImGui::SameLine();
if (ImGui::Button(" Ok ", ImVec2(width * 0.2f, 0)))
close = true;
if (close) {
ImGui::CloseCurrentPopup();
// messages have been seen
warnings.clear();
@@ -267,7 +281,6 @@ void Log::Render(bool showNofitications, bool showWarnings)
}
}
}
void Log::Error(const char* fmt, ...)

2
Log.h
View File

@@ -12,7 +12,7 @@ namespace Log
// Draw logs
void ShowLogWindow(bool* p_open = nullptr);
void Render(bool showNofitications = true, bool showWarnings = true);
void Render(bool *showWarnings = nullptr);
}
#endif // __LOG_H_

View File

@@ -933,9 +933,9 @@ void MediaPlayer::setTimeline(Timeline tl)
// return media_.timeline.toggleGaps(from, to);
//}
std::string MediaPlayer::codec() const
MediaInfo MediaPlayer::media() const
{
return media_.codec_name;
return media_;
}
std::string MediaPlayer::uri() const

View File

@@ -101,7 +101,7 @@ public:
/**
* Get name of Codec of the media
* */
std::string codec() const;
MediaInfo media() const;
/**
* True if a media was oppenned
* */

View File

@@ -71,7 +71,6 @@ static TextEditor editor;
// utility functions
void ShowAboutGStreamer(bool* p_open);
void ShowAboutOpengl(bool* p_open);
void ShowConfig(bool* p_open);
void ShowSandbox(bool* p_open);
// static objects for multithreaded file dialog
@@ -765,7 +764,7 @@ void UserInterface::NewFrame()
void UserInterface::Render()
{
// warning modal dialog
Log::Render();
Log::Render(&Settings::application.widget.logs);
// clear view mode in Transition view
if ( !Settings::application.transition.hide_windows || Settings::application.current_view < View::TRANSITION) {
@@ -1535,8 +1534,8 @@ void MediaController::Render()
ImGui::SetCursorScreenPos(tooltip_pos);
ImGui::Text(" %s", mp_->filename().c_str());
ImGui::Text(" %s", mp_->codec().c_str());
if ( mp_->frameRate() > 0.f )
ImGui::Text(" %s", mp_->media().codec_name.c_str());
if ( mp_->frameRate() > 1.f )
ImGui::Text(" %d x %d px, %.2f / %.2f fps", mp_->width(), mp_->height(), mp_->updateFrameRate() , mp_->frameRate() );
else
ImGui::Text(" %d x %d px", mp_->width(), mp_->height());