mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 10:49:59 +01:00
Bugfix and cleanup Info on source in UI
This commit is contained in:
@@ -712,6 +712,7 @@ void ImGuiVisitor::visit (PatternSource& s)
|
|||||||
for (uint p = 0; p < Pattern::pattern_types.size(); ++p){
|
for (uint p = 0; p < Pattern::pattern_types.size(); ++p){
|
||||||
if (ImGui::Selectable( Pattern::pattern_types[p].c_str() )) {
|
if (ImGui::Selectable( Pattern::pattern_types[p].c_str() )) {
|
||||||
s.setPattern(p, s.pattern()->resolution());
|
s.setPattern(p, s.pattern()->resolution());
|
||||||
|
info.reset();
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << s.name() << ": Pattern " << Pattern::pattern_types[p];
|
oss << s.name() << ": Pattern " << Pattern::pattern_types[p];
|
||||||
Action::manager().store(oss.str());
|
Action::manager().store(oss.str());
|
||||||
@@ -751,6 +752,7 @@ void ImGuiVisitor::visit (DeviceSource& s)
|
|||||||
std::string namedev = Device::manager().name(d);
|
std::string namedev = Device::manager().name(d);
|
||||||
if (ImGui::Selectable( namedev.c_str() )) {
|
if (ImGui::Selectable( namedev.c_str() )) {
|
||||||
s.setDevice(namedev);
|
s.setDevice(namedev);
|
||||||
|
info.reset();
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << s.name() << " Device " << namedev;
|
oss << s.name() << " Device " << namedev;
|
||||||
Action::manager().store(oss.str());
|
Action::manager().store(oss.str());
|
||||||
@@ -789,8 +791,8 @@ void ImGuiVisitor::visit (NetworkSource& s)
|
|||||||
|
|
||||||
if ( ImGui::Button( ICON_FA_REPLY " Reconnect", ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
|
if ( ImGui::Button( ICON_FA_REPLY " Reconnect", ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
|
||||||
{
|
{
|
||||||
// TODO : reload ?
|
|
||||||
s.setConnection(s.connection());
|
s.setConnection(s.connection());
|
||||||
|
info.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -800,7 +802,7 @@ void ImGuiVisitor::visit (MultiFileSource& s)
|
|||||||
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
|
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
|
||||||
ImGui::SameLine(0, 10);
|
ImGui::SameLine(0, 10);
|
||||||
ImGui::Text("Images sequence");
|
ImGui::Text("Images sequence");
|
||||||
static int64_t id = s.id();
|
static int64_t id = 0;
|
||||||
|
|
||||||
// information text
|
// information text
|
||||||
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||||
@@ -857,4 +859,6 @@ void ImGuiVisitor::visit (MultiFileSource& s)
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Text("Folder");
|
ImGui::Text("Folder");
|
||||||
|
|
||||||
|
if (id != s.id())
|
||||||
|
id = s.id();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,12 +37,10 @@
|
|||||||
#include "SystemToolkit.h"
|
#include "SystemToolkit.h"
|
||||||
|
|
||||||
|
|
||||||
InfoVisitor::InfoVisitor(bool brief) : brief_(brief), current_id_(0)
|
InfoVisitor::InfoVisitor() : brief_(true), current_id_(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InfoVisitor::visit(Node &n)
|
void InfoVisitor::visit(Node &n)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -64,9 +62,13 @@ void InfoVisitor::visit(Primitive &n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void InfoVisitor::visit(MediaPlayer &mp)
|
void InfoVisitor::visit(MediaPlayer &mp)
|
||||||
{
|
{
|
||||||
|
if (current_id_ == mp.id())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Log::Info("Getting string info MediaPlayer %ld", current_id_);
|
||||||
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
if (brief_) {
|
if (brief_) {
|
||||||
oss << SystemToolkit::filename(mp.filename()) << std::endl;
|
oss << SystemToolkit::filename(mp.filename()) << std::endl;
|
||||||
@@ -82,7 +84,9 @@ void InfoVisitor::visit(MediaPlayer &mp)
|
|||||||
if (!mp.isImage())
|
if (!mp.isImage())
|
||||||
oss << ", " << std::fixed << std::setprecision(1) << mp.frameRate() << " fps";
|
oss << ", " << std::fixed << std::setprecision(1) << mp.frameRate() << " fps";
|
||||||
}
|
}
|
||||||
|
|
||||||
information_ = oss.str();
|
information_ = oss.str();
|
||||||
|
current_id_ = mp.id();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoVisitor::visit(Stream &n)
|
void InfoVisitor::visit(Stream &n)
|
||||||
@@ -180,8 +184,7 @@ void InfoVisitor::visit (PatternSource& s)
|
|||||||
oss << ", RGB";
|
oss << ", RGB";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::string desc = s.stream()->description();
|
oss << Pattern::pattern_types[s.pattern()->type()] << std::endl;
|
||||||
oss << desc.substr(0, desc.find_first_of('!')) << std::endl;
|
|
||||||
oss << s.pattern()->width() << " x " << s.pattern()->height();
|
oss << s.pattern()->width() << " x " << s.pattern()->height();
|
||||||
oss << ", RGB";
|
oss << ", RGB";
|
||||||
}
|
}
|
||||||
@@ -256,11 +259,11 @@ void InfoVisitor::visit (MultiFileSource& s)
|
|||||||
oss << s.sequence().min << " - " << s.sequence().max << "]";
|
oss << s.sequence().min << " - " << s.sequence().max << "]";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
oss << SystemToolkit::path_filename(s.sequence().location) ;
|
oss << s.sequence().location << " [";
|
||||||
oss << " " << s.sequence().max - s.sequence().min + 1 << " images [";
|
|
||||||
oss << s.sequence().min << " - " << s.sequence().max << "]" << std::endl;
|
oss << s.sequence().min << " - " << s.sequence().max << "]" << std::endl;
|
||||||
oss << s.sequence().width << " x " << s.sequence().height << ", ";
|
oss << s.sequence().width << " x " << s.sequence().height << ", ";
|
||||||
oss << s.sequence().codec;
|
oss << s.sequence().codec << " (";
|
||||||
|
oss << s.sequence().max - s.sequence().min + 1 << " images)";
|
||||||
}
|
}
|
||||||
|
|
||||||
information_ = oss.str();
|
information_ = oss.str();
|
||||||
|
|||||||
@@ -10,8 +10,11 @@ class InfoVisitor : public Visitor
|
|||||||
uint64_t current_id_;
|
uint64_t current_id_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InfoVisitor(bool brief = true);
|
InfoVisitor();
|
||||||
inline std::string str() const { return information_; }
|
inline void setBriefStringMode () { brief_ = true; current_id_ = 0; }
|
||||||
|
inline void setExtendedStringMode () { brief_ = false; current_id_ = 0; }
|
||||||
|
inline void reset () { current_id_ = 0; }
|
||||||
|
inline std::string str () const { return information_; }
|
||||||
|
|
||||||
// Elements of Scene
|
// Elements of Scene
|
||||||
void visit (Scene& n) override;
|
void visit (Scene& n) override;
|
||||||
|
|||||||
@@ -1242,16 +1242,16 @@ void MediaPlayer::TimeCounter::tic ()
|
|||||||
{
|
{
|
||||||
// how long since last time
|
// how long since last time
|
||||||
GstClockTime t = gst_util_get_timestamp ();
|
GstClockTime t = gst_util_get_timestamp ();
|
||||||
GstClockTime dt = t - last_time;
|
GstClockTime dt = t - last_time -1;
|
||||||
|
|
||||||
// one more frame since last time
|
// one more frame since last time
|
||||||
nbFrames++;
|
nbFrames++;
|
||||||
|
|
||||||
// calculate instantaneous framerate
|
// calculate instantaneous framerate
|
||||||
// Exponential moving averate with previous framerate to filter jitter (50/50)
|
// Exponential moving averate with previous framerate to filter jitter (70/30)
|
||||||
// The divition of frame/time is done on long integer GstClockTime, counting in microsecond
|
// The divition of frame/time is done on long integer GstClockTime, counting in microsecond
|
||||||
// NB: factor 100 to get 0.01 precision
|
// NB: factor 100 to get 0.01 precision
|
||||||
fps = 0.5 * fps + 0.005 * static_cast<double>( ( 100 * GST_SECOND * nbFrames ) / dt );
|
fps = 0.7 * fps + 0.003 * static_cast<double>( ( 100 * GST_SECOND * nbFrames ) / dt );
|
||||||
|
|
||||||
// reset counter every second
|
// reset counter every second
|
||||||
if ( dt >= GST_SECOND)
|
if ( dt >= GST_SECOND)
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ private:
|
|||||||
|
|
||||||
GstClockTime last_time;
|
GstClockTime last_time;
|
||||||
GstClockTime tic_time;
|
GstClockTime tic_time;
|
||||||
int nbFrames;
|
long nbFrames;
|
||||||
gdouble fps;
|
gdouble fps;
|
||||||
public:
|
public:
|
||||||
TimeCounter();
|
TimeCounter();
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ void Pattern::open( uint pattern, glm::ivec2 res )
|
|||||||
|
|
||||||
// all patterns before 'SMPTE test pattern' are single frames (not animated)
|
// all patterns before 'SMPTE test pattern' are single frames (not animated)
|
||||||
single_frame_ = type_ < 14;
|
single_frame_ = type_ < 14;
|
||||||
|
Log::Info("Stream %d SingleFrame", single_frame_);
|
||||||
|
|
||||||
// (private) open stream
|
// (private) open stream
|
||||||
Stream::open(gstreamer_pattern, res.x, res.y);
|
Stream::open(gstreamer_pattern, res.x, res.y);
|
||||||
|
|||||||
@@ -1963,15 +1963,17 @@ void ToolBox::Render()
|
|||||||
/// SOURCE CONTROLLER
|
/// SOURCE CONTROLLER
|
||||||
///
|
///
|
||||||
SourceController::SourceController() : _min_width(0.f), _h_space(0.f), _v_space(0.f), _buttons_height(0.f),
|
SourceController::SourceController() : _min_width(0.f), _h_space(0.f), _v_space(0.f), _buttons_height(0.f),
|
||||||
_timeline_height(0.f), _scrollbar(0.f), _mediaplayer_height(0.f),
|
_timeline_height(0.f), _scrollbar(0.f), _mediaplayer_height(0.f), _buttons_width(0.f),
|
||||||
active_label_(LABEL_AUTO_MEDIA_PLAYER), active_selection_(-1),
|
active_label_(LABEL_AUTO_MEDIA_PLAYER), active_selection_(-1),
|
||||||
media_playing_mode_(false), slider_pressed_(false)
|
media_playing_mode_(false), slider_pressed_(false)
|
||||||
{
|
{
|
||||||
|
info_.setExtendedStringMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SourceController::resetActiveSelection()
|
void SourceController::resetActiveSelection()
|
||||||
{
|
{
|
||||||
|
info_.reset();
|
||||||
active_selection_ = -1;
|
active_selection_ = -1;
|
||||||
active_label_ = LABEL_AUTO_MEDIA_PLAYER;
|
active_label_ = LABEL_AUTO_MEDIA_PLAYER;
|
||||||
}
|
}
|
||||||
@@ -2008,7 +2010,6 @@ void SourceController::Render()
|
|||||||
source_window_pos = ImGui::GetWindowPos();
|
source_window_pos = ImGui::GetWindowPos();
|
||||||
source_window_size = ImGui::GetWindowSize();
|
source_window_size = ImGui::GetWindowSize();
|
||||||
|
|
||||||
|
|
||||||
// menu (no title bar)
|
// menu (no title bar)
|
||||||
if (ImGui::BeginMenuBar())
|
if (ImGui::BeginMenuBar())
|
||||||
{
|
{
|
||||||
@@ -2037,6 +2038,7 @@ void SourceController::Render()
|
|||||||
{
|
{
|
||||||
active_selection_ = i;
|
active_selection_ = i;
|
||||||
active_label_ = label;
|
active_label_ = label;
|
||||||
|
info_.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2045,9 +2047,9 @@ void SourceController::Render()
|
|||||||
active_selection_ = Mixer::manager().session()->numPlayGroups();
|
active_selection_ = Mixer::manager().session()->numPlayGroups();
|
||||||
active_label_ = std::string("Selection #") + std::to_string(active_selection_);
|
active_label_ = std::string("Selection #") + std::to_string(active_selection_);
|
||||||
Mixer::manager().session()->addPlayGroup( ids(playable_only(Mixer::selection().getCopy())) );
|
Mixer::manager().session()->addPlayGroup( ids(playable_only(Mixer::selection().getCopy())) );
|
||||||
|
info_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2100,10 +2102,8 @@ void SourceController::RenderSelection(size_t i)
|
|||||||
{
|
{
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.f, _v_space));
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.f, _v_space));
|
||||||
|
|
||||||
|
|
||||||
for (auto source = selection_.begin(); source != selection_.end(); ++source) {
|
for (auto source = selection_.begin(); source != selection_.end(); ++source) {
|
||||||
|
|
||||||
|
|
||||||
ImVec2 framesize(1.5f * _timeline_height * (*source)->frame()->aspectRatio(), 1.5f * _timeline_height);
|
ImVec2 framesize(1.5f * _timeline_height * (*source)->frame()->aspectRatio(), 1.5f * _timeline_height);
|
||||||
|
|
||||||
ImVec2 image_top = ImGui::GetCursorPos();
|
ImVec2 image_top = ImGui::GetCursorPos();
|
||||||
@@ -2235,8 +2235,9 @@ bool SourceController::SourceButton(Source *s, ImVec2 framesize)
|
|||||||
|
|
||||||
ImGui::PushID(s->id());
|
ImGui::PushID(s->id());
|
||||||
ImGui::InvisibleButton("##sourcebutton", framesize);
|
ImGui::InvisibleButton("##sourcebutton", framesize);
|
||||||
if (ImGui::IsItemClicked())
|
if (ImGui::IsItemClicked()) {
|
||||||
ret = true;
|
ret = true;
|
||||||
|
}
|
||||||
if (ImGui::IsItemHovered()){
|
if (ImGui::IsItemHovered()){
|
||||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||||
draw_list->AddRect(frame_top, frame_top + framesize - ImVec2(1.f, 0.f), ImGui::GetColorU32(ImGuiCol_Text), 0, 0, 3.f);
|
draw_list->AddRect(frame_top, frame_top + framesize - ImVec2(1.f, 0.f), ImGui::GetColorU32(ImGuiCol_Text), 0, 0, 3.f);
|
||||||
@@ -2305,9 +2306,8 @@ void SourceController::RenderSelectedSources()
|
|||||||
framesize.x -= _h_space;
|
framesize.x -= _h_space;
|
||||||
|
|
||||||
ImVec2 image_top = ImGui::GetCursorPos();
|
ImVec2 image_top = ImGui::GetCursorPos();
|
||||||
if (SourceButton(*source, framesize)){
|
if (SourceButton(*source, framesize))
|
||||||
Mixer::selection().set(*source);
|
UserInterface::manager().showSourceEditor(*source);
|
||||||
}
|
|
||||||
|
|
||||||
// Play icon lower left corner
|
// Play icon lower left corner
|
||||||
ImGuiToolkit::PushFont(framesize.x > 350.f ? ImGuiToolkit::FONT_LARGE : ImGuiToolkit::FONT_MONO);
|
ImGuiToolkit::PushFont(framesize.x > 350.f ? ImGuiToolkit::FONT_LARGE : ImGuiToolkit::FONT_MONO);
|
||||||
@@ -2407,14 +2407,20 @@ void SourceController::RenderSingleSource(Source *s)
|
|||||||
ImGui::SetCursorScreenPos(top + ImVec2(framesize.x - ImGui::GetTextLineHeightWithSpacing(), _v_space));
|
ImGui::SetCursorScreenPos(top + ImVec2(framesize.x - ImGui::GetTextLineHeightWithSpacing(), _v_space));
|
||||||
ImGui::Text(ICON_FA_INFO_CIRCLE);
|
ImGui::Text(ICON_FA_INFO_CIRCLE);
|
||||||
if (ImGui::IsItemHovered()){
|
if (ImGui::IsItemHovered()){
|
||||||
static InfoVisitor info(false);
|
// fill info string
|
||||||
s->accept(info);
|
s->accept(info_);
|
||||||
|
|
||||||
float tooltip_height = 2.f * ImGui::GetTextLineHeightWithSpacing();
|
float tooltip_height = 2.f * ImGui::GetTextLineHeightWithSpacing();
|
||||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||||
draw_list->AddRectFilled(top, top + ImVec2(framesize.x, tooltip_height), IMGUI_COLOR_OVERLAY);
|
draw_list->AddRectFilled(top, top + ImVec2(framesize.x, tooltip_height), IMGUI_COLOR_OVERLAY);
|
||||||
ImGui::SetCursorScreenPos(top + ImVec2(_h_space, _v_space));
|
ImGui::SetCursorScreenPos(top + ImVec2(_h_space, _v_space));
|
||||||
ImGui::Text("%s", info.str().c_str());
|
ImGui::Text("%s", info_.str().c_str());
|
||||||
|
|
||||||
|
StreamSource *sts = dynamic_cast<StreamSource*>(s);
|
||||||
|
if (sts) {
|
||||||
|
ImGui::SetCursorScreenPos(top + ImVec2( framesize.x - 1.5f * _buttons_height, 0.5f * tooltip_height));
|
||||||
|
ImGui::Text("%.1f Hz", sts->stream()->updateFrameRate());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -2465,14 +2471,16 @@ void SourceController::RenderMediaPlayer(MediaPlayer *mp)
|
|||||||
ImGui::SetCursorScreenPos(top + ImVec2(framesize.x - ImGui::GetTextLineHeightWithSpacing(), _v_space));
|
ImGui::SetCursorScreenPos(top + ImVec2(framesize.x - ImGui::GetTextLineHeightWithSpacing(), _v_space));
|
||||||
ImGui::Text(ICON_FA_INFO_CIRCLE);
|
ImGui::Text(ICON_FA_INFO_CIRCLE);
|
||||||
if (ImGui::IsItemHovered()){
|
if (ImGui::IsItemHovered()){
|
||||||
static InfoVisitor info(false);
|
mp->accept(info_);
|
||||||
mp->accept(info);
|
|
||||||
|
|
||||||
float tooltip_height = 3.f * ImGui::GetTextLineHeightWithSpacing();
|
float tooltip_height = 3.f * ImGui::GetTextLineHeightWithSpacing();
|
||||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||||
draw_list->AddRectFilled(top, top + ImVec2(framesize.x, tooltip_height), IMGUI_COLOR_OVERLAY);
|
draw_list->AddRectFilled(top, top + ImVec2(framesize.x, tooltip_height), IMGUI_COLOR_OVERLAY);
|
||||||
ImGui::SetCursorScreenPos(top + ImVec2(_h_space, _v_space));
|
ImGui::SetCursorScreenPos(top + ImVec2(_h_space, _v_space));
|
||||||
ImGui::Text("%s", info.str().c_str());
|
ImGui::Text("%s", info_.str().c_str());
|
||||||
|
|
||||||
|
ImGui::SetCursorScreenPos(top + ImVec2( framesize.x - 1.5f * _buttons_height, 0.666f * tooltip_height));
|
||||||
|
ImGui::Text("%.1f Hz", mp->updateFrameRate());
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#define NAV_TRANS 67
|
#define NAV_TRANS 67
|
||||||
|
|
||||||
#include "SourceList.h"
|
#include "SourceList.h"
|
||||||
|
#include "InfoVisitor.h"
|
||||||
|
|
||||||
struct ImVec2;
|
struct ImVec2;
|
||||||
class MediaPlayer;
|
class MediaPlayer;
|
||||||
@@ -116,6 +117,7 @@ class SourceController
|
|||||||
|
|
||||||
std::string active_label_;
|
std::string active_label_;
|
||||||
int active_selection_;
|
int active_selection_;
|
||||||
|
InfoVisitor info_;
|
||||||
|
|
||||||
SourceList selection_;
|
SourceList selection_;
|
||||||
void DrawButtonBar(ImVec2 bottom, float width);
|
void DrawButtonBar(ImVec2 bottom, float width);
|
||||||
|
|||||||
Reference in New Issue
Block a user