mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
(continue) Migrating clipboard manipulation to Session XML management
This commit is contained in:
@@ -15,25 +15,6 @@ ImageProcessingShader::ImageProcessingShader(): Shader()
|
|||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageProcessingShader::ImageProcessingShader(const ImageProcessingShader &S): Shader()
|
|
||||||
{
|
|
||||||
program_ = &imageProcessingShadingProgram;
|
|
||||||
reset();
|
|
||||||
brightness = S.brightness;
|
|
||||||
contrast = S.contrast;
|
|
||||||
saturation = S.saturation;
|
|
||||||
hueshift = S.hueshift;
|
|
||||||
threshold = S.threshold;
|
|
||||||
lumakey = S.lumakey;
|
|
||||||
nbColors = S.nbColors;
|
|
||||||
invert = S.invert;
|
|
||||||
filterid = S.filterid;
|
|
||||||
gamma = S.gamma;
|
|
||||||
levels = S.levels;
|
|
||||||
chromakey = S.chromakey;
|
|
||||||
chromadelta = S.chromadelta;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImageProcessingShader::use()
|
void ImageProcessingShader::use()
|
||||||
{
|
{
|
||||||
Shader::use();
|
Shader::use();
|
||||||
@@ -56,7 +37,6 @@ void ImageProcessingShader::use()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ImageProcessingShader::reset()
|
void ImageProcessingShader::reset()
|
||||||
{
|
{
|
||||||
Shader::reset();
|
Shader::reset();
|
||||||
@@ -78,7 +58,7 @@ void ImageProcessingShader::reset()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageProcessingShader::operator = (const ImageProcessingShader &S )
|
void ImageProcessingShader::copy(const ImageProcessingShader &S)
|
||||||
{
|
{
|
||||||
brightness = S.brightness;
|
brightness = S.brightness;
|
||||||
contrast = S.contrast;
|
contrast = S.contrast;
|
||||||
@@ -95,6 +75,11 @@ void ImageProcessingShader::operator = (const ImageProcessingShader &S )
|
|||||||
chromadelta = S.chromadelta;
|
chromadelta = S.chromadelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImageProcessingShader::operator = (const ImageProcessingShader &S )
|
||||||
|
{
|
||||||
|
copy(S);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ImageProcessingShader::accept(Visitor& v)
|
void ImageProcessingShader::accept(Visitor& v)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ class ImageProcessingShader : public Shader
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
ImageProcessingShader();
|
ImageProcessingShader();
|
||||||
ImageProcessingShader(const ImageProcessingShader &model);
|
|
||||||
|
|
||||||
void use() override;
|
void use() override;
|
||||||
void reset() override;
|
void reset() override;
|
||||||
void accept(Visitor& v) override;
|
void accept(Visitor& v) override;
|
||||||
|
|
||||||
void operator = (const ImageProcessingShader &S);
|
void operator = (const ImageProcessingShader &S);
|
||||||
|
void copy(const ImageProcessingShader &S);
|
||||||
|
|
||||||
// color effects
|
// color effects
|
||||||
float brightness; // [-1 1]
|
float brightness; // [-1 1]
|
||||||
|
|||||||
52
Mixer.cpp
52
Mixer.cpp
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include <tinyxml2.h>
|
#include <tinyxml2.h>
|
||||||
#include "tinyxml2Toolkit.h"
|
#include "tinyxml2Toolkit.h"
|
||||||
using namespace tinyxml2;
|
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
@@ -431,19 +430,13 @@ bool Mixer::recreateSource(Source *s)
|
|||||||
|
|
||||||
// get the xml description from this source, and exit if not wellformed
|
// get the xml description from this source, and exit if not wellformed
|
||||||
tinyxml2::XMLDocument xmlDoc;
|
tinyxml2::XMLDocument xmlDoc;
|
||||||
tinyxml2::XMLError eResult = xmlDoc.Parse(Source::xml(s).c_str());
|
tinyxml2::XMLElement* sourceNode = SessionLoader::firstSourceElement(SessionVisitor::getClipboard(s), xmlDoc);
|
||||||
if ( XMLResultError(eResult))
|
|
||||||
return false;
|
|
||||||
tinyxml2::XMLElement *root = xmlDoc.FirstChildElement(APP_NAME);
|
|
||||||
if ( root == nullptr )
|
|
||||||
return false;
|
|
||||||
XMLElement* sourceNode = root->FirstChildElement("Source");
|
|
||||||
if ( sourceNode == nullptr )
|
if ( sourceNode == nullptr )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// actually create the source with SessionLoader using xml description
|
// actually create the source with SessionLoader using xml description
|
||||||
SessionLoader loader( session_ );
|
SessionLoader loader( session_ );
|
||||||
Source *replacement = loader.createSource(sourceNode, false); // not clone
|
Source *replacement = loader.createSource(sourceNode, SessionLoader::DUPLICATE); // not clone
|
||||||
if (replacement == nullptr)
|
if (replacement == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -1228,40 +1221,23 @@ void Mixer::set(Session *s)
|
|||||||
sessionSwapRequested_ = true;
|
sessionSwapRequested_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mixer::isClipboard (const std::string& text)
|
|
||||||
{
|
|
||||||
if (text.size() > 6 && text.substr(0, 6) == "<vimix")
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mixer::paste(const std::string& clipboard)
|
void Mixer::paste(const std::string& clipboard)
|
||||||
{
|
{
|
||||||
if (clipboard.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
tinyxml2::XMLDocument xmlDoc;
|
tinyxml2::XMLDocument xmlDoc;
|
||||||
tinyxml2::XMLError eResult = xmlDoc.Parse(clipboard.c_str());
|
tinyxml2::XMLElement* sourceNode = SessionLoader::firstSourceElement(clipboard, xmlDoc);
|
||||||
if ( XMLResultError(eResult))
|
if (sourceNode) {
|
||||||
return;
|
|
||||||
|
|
||||||
tinyxml2::XMLElement *root = xmlDoc.FirstChildElement(APP_NAME);
|
SessionLoader loader( session_ );
|
||||||
if ( root == nullptr )
|
|
||||||
return;
|
|
||||||
|
|
||||||
SessionLoader loader( session_ );
|
for( ; sourceNode ; sourceNode = sourceNode->NextSiblingElement())
|
||||||
|
{
|
||||||
XMLElement* sourceNode = root->FirstChildElement("Source");
|
Source *s = loader.createSource(sourceNode);
|
||||||
for( ; sourceNode ; sourceNode = sourceNode->NextSiblingElement())
|
if (s) {
|
||||||
{
|
// Add source to Session
|
||||||
Source *s = loader.createSource(sourceNode);
|
session_->addSource(s);
|
||||||
if (s) {
|
// Add source to Mixer
|
||||||
// Add source to Session
|
addSource(s);
|
||||||
session_->addSource(s);
|
}
|
||||||
// Add source to Mixer
|
|
||||||
addSource(s);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
1
Mixer.h
1
Mixer.h
@@ -107,7 +107,6 @@ public:
|
|||||||
void open (const std::string& filename);
|
void open (const std::string& filename);
|
||||||
|
|
||||||
// create sources if clipboard contains well-formed xml text
|
// create sources if clipboard contains well-formed xml text
|
||||||
bool isClipboard (const std::string& text);
|
|
||||||
void paste (const std::string& clipboard);
|
void paste (const std::string& clipboard);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <tinyxml2.h>
|
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "SessionVisitor.h"
|
#include "SessionVisitor.h"
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
@@ -159,41 +157,9 @@ SourceList::iterator Selection::end()
|
|||||||
return selection_.end();
|
return selection_.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Selection::xml() const
|
std::string Selection::clipboard() const
|
||||||
{
|
{
|
||||||
std::string x = "";
|
return SessionVisitor::getClipboard(selection_);
|
||||||
|
|
||||||
if (!selection_.empty()) {
|
|
||||||
|
|
||||||
// create xml doc and root node
|
|
||||||
tinyxml2::XMLDocument xmlDoc;
|
|
||||||
tinyxml2::XMLElement *selectionNode = xmlDoc.NewElement(APP_NAME);
|
|
||||||
selectionNode->SetAttribute("size", (int) selection_.size());
|
|
||||||
xmlDoc.InsertEndChild(selectionNode);
|
|
||||||
|
|
||||||
// fill doc
|
|
||||||
SourceList selection_clones_;
|
|
||||||
SessionVisitor sv(&xmlDoc, selectionNode);
|
|
||||||
for (auto iter = selection_.begin(); iter != selection_.end(); iter++, sv.setRoot(selectionNode) ){
|
|
||||||
// start with clones
|
|
||||||
CloneSource *clone = dynamic_cast<CloneSource *>(*iter);
|
|
||||||
if (clone)
|
|
||||||
(*iter)->accept(sv);
|
|
||||||
else
|
|
||||||
selection_clones_.push_back(*iter);
|
|
||||||
}
|
|
||||||
// add others in front
|
|
||||||
for (auto iter = selection_clones_.begin(); iter != selection_clones_.end(); iter++, sv.setRoot(selectionNode) ){
|
|
||||||
(*iter)->accept(sv);
|
|
||||||
}
|
|
||||||
|
|
||||||
// get compact string
|
|
||||||
tinyxml2::XMLPrinter xmlPrint(0, true);
|
|
||||||
xmlDoc.Print( &xmlPrint );
|
|
||||||
x = xmlPrint.CStr();
|
|
||||||
}
|
|
||||||
|
|
||||||
return x;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceList Selection::getCopy() const
|
SourceList Selection::getCopy() const
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public:
|
|||||||
uint size () const;
|
uint size () const;
|
||||||
|
|
||||||
// extract
|
// extract
|
||||||
std::string xml() const;
|
std::string clipboard() const;
|
||||||
SourceList getCopy() const;
|
SourceList getCopy() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
22
Source.cpp
22
Source.cpp
@@ -715,28 +715,6 @@ void Source::setMask(FrameBufferImage *img)
|
|||||||
mask_need_update_ = false;
|
mask_need_update_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string Source::xml(Source *s)
|
|
||||||
{
|
|
||||||
std::string x = "";
|
|
||||||
|
|
||||||
tinyxml2::XMLDocument xmlDoc;
|
|
||||||
tinyxml2::XMLElement *selectionNode = xmlDoc.NewElement(APP_NAME);
|
|
||||||
selectionNode->SetAttribute("size", 1);
|
|
||||||
xmlDoc.InsertEndChild(selectionNode);
|
|
||||||
|
|
||||||
SessionVisitor sv(&xmlDoc, selectionNode);
|
|
||||||
s->accept(sv);
|
|
||||||
|
|
||||||
// get compact string
|
|
||||||
tinyxml2::XMLPrinter xmlPrint(0, true);
|
|
||||||
xmlDoc.Print( &xmlPrint );
|
|
||||||
x = xmlPrint.CStr();
|
|
||||||
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Source::hasNode::operator()(const Source* elem) const
|
bool Source::hasNode::operator()(const Source* elem) const
|
||||||
{
|
{
|
||||||
if (_n && elem)
|
if (_n && elem)
|
||||||
|
|||||||
15
Source.h
15
Source.h
@@ -198,9 +198,6 @@ public:
|
|||||||
// class-dependent icon
|
// class-dependent icon
|
||||||
virtual glm::ivec2 icon () const { return glm::ivec2(12, 11); }
|
virtual glm::ivec2 icon () const { return glm::ivec2(12, 11); }
|
||||||
|
|
||||||
// get the xml description text of a source
|
|
||||||
static std::string xml(Source *s);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// name
|
// name
|
||||||
std::string name_;
|
std::string name_;
|
||||||
@@ -274,6 +271,18 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class DummySource : public Source
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DummySource() : Source() {}
|
||||||
|
uint texture() const override { return 0; }
|
||||||
|
bool failed() const override { return true; }
|
||||||
|
void accept (Visitor& v) override { Source::accept(v); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void init() override {}
|
||||||
|
};
|
||||||
|
|
||||||
class CloneSource : public Source
|
class CloneSource : public Source
|
||||||
{
|
{
|
||||||
friend class Source;
|
friend class Source;
|
||||||
|
|||||||
Reference in New Issue
Block a user