From 4675be7e2a56b9f9383a3f77bb37a9ae8ec292e0 Mon Sep 17 00:00:00 2001 From: Bruno Herbelin Date: Sun, 5 Dec 2021 18:32:23 +0100 Subject: [PATCH] Unified notification of source creation with Source info New virtual function source::info used for notification after adding source --- DeviceSource.cpp | 6 +++++- DeviceSource.h | 1 + MediaSource.cpp | 6 +++++- MediaSource.h | 1 + Mixer.cpp | 13 ++++++++----- MultiFileSource.cpp | 11 +++++++++++ MultiFileSource.h | 3 ++- NetworkSource.cpp | 9 ++++++++- NetworkSource.h | 3 ++- PatternSource.cpp | 10 +++++++++- PatternSource.h | 3 ++- SessionSource.cpp | 35 ++++++++++++++++++++++++++++++++++- SessionSource.h | 10 +++++++--- Source.cpp | 12 +++++++++++- Source.h | 6 +++++- 15 files changed, 111 insertions(+), 18 deletions(-) diff --git a/DeviceSource.cpp b/DeviceSource.cpp index adf6e06..31f5715 100644 --- a/DeviceSource.cpp +++ b/DeviceSource.cpp @@ -363,7 +363,6 @@ DeviceSource::~DeviceSource() void DeviceSource::setDevice(const std::string &devicename) { device_ = devicename; - Log::Notify("Creating Source with device '%s'", device_.c_str()); int index = Device::manager().index(device_); if (index > -1) { @@ -589,6 +588,11 @@ glm::ivec2 DeviceSource::icon() const return glm::ivec2(2, 14); } +std::string DeviceSource::info() const +{ + return std::string("device '") + device_ + "'"; +} + diff --git a/DeviceSource.h b/DeviceSource.h index 7c55b9e..f1d4b9d 100644 --- a/DeviceSource.h +++ b/DeviceSource.h @@ -25,6 +25,7 @@ public: inline std::string device() const { return device_; } glm::ivec2 icon() const override; + std::string info() const override; private: std::string device_; diff --git a/MediaSource.cpp b/MediaSource.cpp index edf2c76..217f71a 100644 --- a/MediaSource.cpp +++ b/MediaSource.cpp @@ -46,7 +46,6 @@ MediaSource::~MediaSource() void MediaSource::setPath(const std::string &p) { path_ = p; - Log::Notify("Creating Source with media '%s'", path_.c_str()); // open gstreamer mediaplayer_->open(path_); @@ -74,6 +73,11 @@ glm::ivec2 MediaSource::icon() const return glm::ivec2(18, 13); } +std::string MediaSource::info() const +{ + return std::string("media '") + path_ + "'"; +} + bool MediaSource::failed() const { return mediaplayer_->failed(); diff --git a/MediaSource.h b/MediaSource.h index 4a31229..a7bc64a 100644 --- a/MediaSource.h +++ b/MediaSource.h @@ -30,6 +30,7 @@ public: MediaPlayer *mediaplayer() const; glm::ivec2 icon() const override; + std::string info() const override; protected: diff --git a/Mixer.cpp b/Mixer.cpp index b4e2307..660cd35 100644 --- a/Mixer.cpp +++ b/Mixer.cpp @@ -258,10 +258,6 @@ Source * Mixer::createSourceFile(const std::string &path) ms->setPath(path); s = ms; } - - // remember in recent media - Settings::application.recentImport.push(path); - // propose a new name based on uri s->setName(SystemToolkit::base_filename(path)); @@ -427,6 +423,12 @@ void Mixer::insertSource(Source *s, View::Mode m) // new state in history manager Action::manager().store(s->name() + std::string(": source inserted")); + // notify creation of source + Log::Notify("Added source '%s' with %s", s->name().c_str(), s->info().c_str()); + MediaSource *ms = dynamic_cast(s); + if (ms) + Settings::application.recentImport.push(ms->path()); + // if requested to show the source in a given view // (known to work for View::MIXING et TRANSITION: other views untested) if (m != View::INVALID) { @@ -703,9 +705,10 @@ void Mixer::groupSelection() info << sessiongroup->name() << " inserted: " << sessiongroup->session()->numSource() << " sources flatten."; Action::manager().store(info.str()); + Log::Notify("Added source '%s' with %s", sessiongroup->name().c_str(), sessiongroup->info().c_str()); + // give the hand to the user Mixer::manager().setCurrentSource(sessiongroup); - Log::Notify(info.str().c_str()); } void Mixer::renameSource(Source *s, const std::string &newname) diff --git a/MultiFileSource.cpp b/MultiFileSource.cpp index 78e6581..a37f200 100644 --- a/MultiFileSource.cpp +++ b/MultiFileSource.cpp @@ -259,3 +259,14 @@ MultiFile *MultiFileSource::multifile () const } +glm::ivec2 MultiFileSource::icon () const +{ + return glm::ivec2(3, 9); +} + +std::string MultiFileSource::info() const +{ + return std::string("sequence '") + sequence_.location + "'"; +} + + diff --git a/MultiFileSource.h b/MultiFileSource.h index 98249c8..c8266ee 100644 --- a/MultiFileSource.h +++ b/MultiFileSource.h @@ -51,7 +51,8 @@ public: // StreamSource interface Stream *stream () const override { return stream_; } - glm::ivec2 icon () const override { return glm::ivec2(3, 9); } + glm::ivec2 icon() const override; + std::string info() const override; // specific interface void setFiles (const std::list &list_files, uint framerate); diff --git a/NetworkSource.cpp b/NetworkSource.cpp index a2ed2f4..49a1fe7 100644 --- a/NetworkSource.cpp +++ b/NetworkSource.cpp @@ -310,7 +310,6 @@ NetworkStream *NetworkSource::networkStream() const void NetworkSource::setConnection(const std::string &nameconnection) { connection_name_ = nameconnection; - Log::Notify("Network Source connecting to '%s'", connection_name_.c_str()); // open network stream networkStream()->connect( connection_name_ ); @@ -333,5 +332,13 @@ void NetworkSource::accept(Visitor& v) v.visit(*this); } +glm::ivec2 NetworkSource::icon() const +{ + return glm::ivec2(18, 11); +} +std::string NetworkSource::info() const +{ + return std::string("connected to '") + connection_name_ + "'"; +} diff --git a/NetworkSource.h b/NetworkSource.h index b5214a2..be00872 100644 --- a/NetworkSource.h +++ b/NetworkSource.h @@ -74,7 +74,8 @@ public: void setConnection(const std::string &nameconnection); std::string connection() const; - glm::ivec2 icon() const override { return glm::ivec2(18, 11); } + glm::ivec2 icon() const override; + std::string info() const override; }; diff --git a/PatternSource.cpp b/PatternSource.cpp index 1370375..8bb40f6 100644 --- a/PatternSource.cpp +++ b/PatternSource.cpp @@ -147,7 +147,6 @@ void PatternSource::setPattern(uint type, glm::ivec2 resolution) // open gstreamer with pattern if ( Pattern::get(type).available) { pattern()->open( (uint) type, resolution ); - Log::Notify("Creating Source with pattern '%s'", Pattern::get(type).label.c_str()); } // revert to pattern Black if not available else { @@ -175,3 +174,12 @@ Pattern *PatternSource::pattern() const } +glm::ivec2 PatternSource::icon() const +{ + return glm::ivec2(11, 5); +} + +std::string PatternSource::info() const +{ + return std::string("pattern '") + Pattern::get(pattern()->type()).label + "'"; +} diff --git a/PatternSource.h b/PatternSource.h index 9c5f61c..11a49f5 100644 --- a/PatternSource.h +++ b/PatternSource.h @@ -47,7 +47,8 @@ public: Pattern *pattern() const; void setPattern(uint type, glm::ivec2 resolution); - glm::ivec2 icon() const override { return glm::ivec2(11, 5); } + glm::ivec2 icon() const override; + std::string info() const override; }; diff --git a/SessionSource.cpp b/SessionSource.cpp index d9867ae..51dee64 100644 --- a/SessionSource.cpp +++ b/SessionSource.cpp @@ -279,6 +279,16 @@ void SessionFileSource::accept(Visitor& v) v.visit(*this); } +glm::ivec2 SessionFileSource::icon() const +{ + return glm::ivec2(19, 6); +} + +std::string SessionFileSource::info() const +{ + return std::string("session vimix '") + path_ + "'"; +} + SessionGroupSource::SessionGroupSource(uint64_t id) : SessionSource(id), resolution_(glm::vec3(0.f)) { @@ -335,7 +345,7 @@ void SessionGroupSource::init() ++View::need_deep_update_; // done init - Log::Info("Source Group (%d x %d).", int(renderbuffer->resolution().x), int(renderbuffer->resolution().y) ); + Log::Info("Source Group created (%d x %d).", int(renderbuffer->resolution().x), int(renderbuffer->resolution().y) ); } } @@ -360,6 +370,19 @@ void SessionGroupSource::accept(Visitor& v) v.visit(*this); } +glm::ivec2 SessionGroupSource::icon() const +{ + return glm::ivec2(10, 6); +} + +std::string SessionGroupSource::info() const +{ + if (session_) + return std::string("group of ") + std::to_string(session_->numSource()) + " sources"; + else + return std::string("undefined group."); +} + RenderSource::RenderSource(uint64_t id) : Source(id), session_(nullptr) { // set symbol @@ -423,3 +446,13 @@ void RenderSource::accept(Visitor& v) // if (!failed()) v.visit(*this); } + +glm::ivec2 RenderSource::icon() const +{ + return glm::ivec2(0, 2); +} + +std::string RenderSource::info() const +{ + return std::string("Render loopback"); +} diff --git a/SessionSource.h b/SessionSource.h index c37728d..f6dd63f 100644 --- a/SessionSource.h +++ b/SessionSource.h @@ -46,7 +46,9 @@ public: void load(const std::string &p = "", uint recursion = 0); inline std::string path() const { return path_; } - glm::ivec2 icon() const override { return glm::ivec2(19, 6); } + + glm::ivec2 icon() const override; + std::string info() const override; protected: @@ -72,7 +74,8 @@ public: // import a source bool import(Source *source); - glm::ivec2 icon() const override { return glm::ivec2(10, 6); } + glm::ivec2 icon() const override; + std::string info() const override; protected: @@ -99,7 +102,8 @@ public: glm::vec3 resolution() const; - glm::ivec2 icon() const override { return glm::ivec2(0, 2); } + glm::ivec2 icon() const override; + std::string info() const override; protected: diff --git a/Source.cpp b/Source.cpp index 0948286..644a5dd 100644 --- a/Source.cpp +++ b/Source.cpp @@ -733,7 +733,7 @@ FrameBuffer *Source::frame() const return renderbuffer_; } else { - static FrameBuffer *black = new FrameBuffer(640,480); + static FrameBuffer *black = new FrameBuffer(320,180); return black; } } @@ -916,3 +916,13 @@ void CloneSource::accept(Visitor& v) v.visit(*this); } +glm::ivec2 CloneSource::icon() const +{ + return glm::ivec2(9, 2); +} + +std::string CloneSource::info() const +{ + return std::string("clone of '") + origin_->name() + "'"; +} + diff --git a/Source.h b/Source.h index db0bfd5..1fb1a03 100644 --- a/Source.h +++ b/Source.h @@ -230,6 +230,9 @@ public: // class-dependent icon virtual glm::ivec2 icon () const { return glm::ivec2(12, 11); } + // class-dependent notification + virtual std::string info () const { return "Undefined"; } + SourceLink processingshader_link_; protected: @@ -322,7 +325,8 @@ public: inline void detach() { origin_ = nullptr; } inline Source *origin() const { return origin_; } - glm::ivec2 icon() const override { return glm::ivec2(9, 2); } + glm::ivec2 icon() const override; + std::string info() const override; protected: // only Source class can create new CloneSource via clone();