Cosmetic improvement of Action manager and Log messages.

This commit is contained in:
brunoherbelin
2020-10-11 12:05:38 +02:00
parent 795c0ed30f
commit 8297c85220
6 changed files with 41 additions and 24 deletions

View File

@@ -399,8 +399,11 @@ void ImGuiVisitor::visit (Source& s)
// toggle enable/disable image processing // toggle enable/disable image processing
bool on = s.imageProcessingEnabled(); bool on = s.imageProcessingEnabled();
ImGui::SetCursorPos( ImVec2(preview_width + 15, pos.y -ImGui::GetFrameHeight() ) ); ImGui::SetCursorPos( ImVec2(preview_width + 15, pos.y -ImGui::GetFrameHeight() ) );
if ( ImGuiToolkit::ButtonToggle(ICON_FA_MAGIC, &on) ) if ( ImGuiToolkit::ButtonToggle(ICON_FA_MAGIC, &on) ){
Action::manager().store( on ? "Enable Filter" : "Disable Filter", s.id()); std::ostringstream oss;
oss << s.name() << ": " << ( on ? "Enable Filter" : "Disable Filter");
Action::manager().store(oss.str(), s.id());
}
s.setImageProcessingEnabled(on); s.setImageProcessingEnabled(on);
ImGui::SetCursorPos(pos); // ...come back ImGui::SetCursorPos(pos); // ...come back
@@ -445,8 +448,11 @@ void ImGuiVisitor::visit (SessionSource& s)
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
if (ImGui::SliderFloat("Fading", &f, 0.0, 1.0, f < 0.001 ? "None" : "%.2f") ) if (ImGui::SliderFloat("Fading", &f, 0.0, 1.0, f < 0.001 ? "None" : "%.2f") )
s.session()->setFading(f); s.session()->setFading(f);
if (ImGui::IsItemDeactivatedAfterEdit()) if (ImGui::IsItemDeactivatedAfterEdit()){
Action::manager().store("Fading", s.id()); std::ostringstream oss;
oss << s.name() << ": Fading " << std::setprecision(2) << f;
Action::manager().store(oss.str(), s.id());
}
if ( ImGui::Button( ICON_FA_FILE_UPLOAD " Make Current", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) if ( ImGui::Button( ICON_FA_FILE_UPLOAD " Make Current", ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
Mixer::manager().set( s.detach() ); Mixer::manager().set( s.detach() );
@@ -486,7 +492,9 @@ void ImGuiVisitor::visit (PatternSource& s)
for (int p = 0; p < Pattern::pattern_types.size(); ++p){ for (int 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());
Action::manager().store("Pattern "+Pattern::pattern_types[p], s.id()); std::ostringstream oss;
oss << s.name() << ": Pattern " << Pattern::pattern_types[p];
Action::manager().store(oss.str(), s.id());
} }
} }
ImGui::EndCombo(); ImGui::EndCombo();
@@ -506,7 +514,9 @@ 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);
Action::manager().store("Device "+namedev, s.id()); std::ostringstream oss;
oss << s.name() << " Device " << namedev;
Action::manager().store(oss.str(), s.id());
} }
} }
ImGui::EndCombo(); ImGui::EndCombo();

View File

@@ -105,7 +105,7 @@ void MediaSource::init()
// done init // done init
initialized_ = true; initialized_ = true;
Log::Info("Source '%s' linked to Media %s.", name().c_str(), mediaplayer()->uri().c_str()); Log::Info("Source '%s' linked to Media %s.", name().c_str(), std::to_string(mediaplayer_->id()).c_str());
// force update of activation mode // force update of activation mode
active_ = true; active_ = true;

View File

@@ -272,7 +272,8 @@ Source * Mixer::createSourceStream(const std::string &gstreamerpipeline)
s->setDescription(gstreamerpipeline); s->setDescription(gstreamerpipeline);
// propose a new name based on pattern name // propose a new name based on pattern name
renameSource(s, gstreamerpipeline.substr(0,10)); std::string name = gstreamerpipeline.substr(0, gstreamerpipeline.find(" "));
renameSource(s, name);
return s; return s;
} }
@@ -284,7 +285,9 @@ Source * Mixer::createSourcePattern(int pattern, glm::ivec2 res)
s->setPattern(pattern, res); s->setPattern(pattern, res);
// propose a new name based on pattern name // propose a new name based on pattern name
renameSource(s, Pattern::pattern_types[pattern]); std::string name = Pattern::pattern_types[pattern];
name = name.substr(0, name.find(" "));
renameSource(s, name);
return s; return s;
} }
@@ -295,7 +298,8 @@ Source * Mixer::createSourceDevice(const std::string &namedevice)
Source *s = Device::manager().createSource(namedevice); Source *s = Device::manager().createSource(namedevice);
// propose a new name based on pattern name // propose a new name based on pattern name
renameSource(s, namedevice); std::string name = namedevice.substr(0, namedevice.find(" "));
renameSource(s, name);
return s; return s;
} }
@@ -319,7 +323,7 @@ Source * Mixer::createSourceClone(const std::string &namesource)
// create a source // create a source
s = (*origin)->clone(); s = (*origin)->clone();
// get new name // propose new name (this automatically increments name)
renameSource(s, (*origin)->name()); renameSource(s, (*origin)->name());
} }

View File

@@ -62,8 +62,8 @@ const char* pattern_internal_[24] = { "videotestsrc pattern=black",
"videotestsrc pattern=black ! clockoverlay halignment=center valignment=center font-desc=\"Sans, 72\" " "videotestsrc pattern=black ! clockoverlay halignment=center valignment=center font-desc=\"Sans, 72\" "
}; };
std::vector<std::string> Pattern::pattern_types = { "100% Black", std::vector<std::string> Pattern::pattern_types = { "Black",
"100% White", "White",
"Gradient", "Gradient",
"Checkers 1x1 px", "Checkers 1x1 px",
"Checkers 8x8 px", "Checkers 8x8 px",
@@ -71,18 +71,18 @@ std::vector<std::string> Pattern::pattern_types = { "100% Black",
"Lissajous", "Lissajous",
"Pinwheel", "Pinwheel",
"Spokes", "Spokes",
"100% Red", "Red",
"100% Green", "Green",
"100% Blue", "Blue",
"Color bars", "Color bars",
"Color grid", "RGB grid",
"SMPTE test pattern", "SMPTE test pattern",
"Television snow", "Television snow",
"Blink", "Blink",
"Fresnel zone plate", "Fresnel zone plate",
"Chroma zone plate", "Chroma zone plate",
"Moving bar", "Bar moving",
"Moving ball", "Ball bouncing",
"Blob", "Blob",
"Timer", "Timer",
"Clock" "Clock"
@@ -107,7 +107,7 @@ void Pattern::open( uint pattern, glm::ivec2 res )
// there is always a special case... // there is always a special case...
switch(type_) switch(type_)
{ {
case 16: case 18:
case 17: case 17:
{ {
std::ostringstream oss; std::ostringstream oss;

View File

@@ -88,7 +88,7 @@ void StreamSource::init()
// done init // done init
initialized_ = true; initialized_ = true;
Log::Info("Source '%s' linked to Stream %d.", name().c_str(), stream_->id()); Log::Info("Source '%s' linked to Stream %s", name().c_str(), std::to_string(stream_->id()).c_str());
// force update of activation mode // force update of activation mode
active_ = true; active_ = true;

View File

@@ -12,6 +12,7 @@
// memmove // memmove
#include <string.h> #include <string.h>
#include <sstream> #include <sstream>
#include <regex>
#include <iomanip> #include <iomanip>
#include "View.h" #include "View.h"
@@ -123,6 +124,8 @@ void View::initiate()
void View::terminate() void View::terminate()
{ {
std::regex r("\\n");
current_action_ = std::regex_replace(current_action_, r, " ");
Action::manager().store(current_action_, current_id_); Action::manager().store(current_action_, current_id_);
current_action_ = ""; current_action_ = "";
current_id_ = 0; current_id_ = 0;
@@ -502,7 +505,7 @@ View::Cursor MixingView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pai
info << "Inactive"; info << "Inactive";
// store action in history // store action in history
current_action_ = s->name() + " " + info.str(); current_action_ = s->name() + ": " + info.str();
current_id_ = s->id(); current_id_ = s->id();
return Cursor(Cursor_ResizeAll, info.str() ); return Cursor(Cursor_ResizeAll, info.str() );
@@ -1174,7 +1177,7 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
s->touch(); s->touch();
// store action in history // store action in history
current_action_ = s->name() + " " + info.str(); current_action_ = s->name() + ": " + info.str();
current_id_ = s->id(); current_id_ = s->id();
// update cursor // update cursor
@@ -1355,7 +1358,7 @@ View::Cursor LayerView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair
info << "Depth " << std::fixed << std::setprecision(2) << d; info << "Depth " << std::fixed << std::setprecision(2) << d;
// store action in history // store action in history
current_action_ = s->name() + " " + info.str(); current_action_ = s->name() + ": " + info.str();
current_id_ = s->id(); current_id_ = s->id();
return Cursor(Cursor_ResizeNESW, info.str() ); return Cursor(Cursor_ResizeNESW, info.str() );