(continue) Migrating clipboard manipulation to Session XML management

This commit is contained in:
brunoherbelin
2021-04-05 13:06:31 +02:00
parent d3a130d9ba
commit c22df2eb2a
2 changed files with 48 additions and 15 deletions

View File

@@ -9,6 +9,9 @@
#include <glm/gtc/type_ptr.hpp> #include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/constants.hpp> #include <glm/gtc/constants.hpp>
#include <tinyxml2.h>
#include "tinyxml2Toolkit.h"
#include "defines.h" #include "defines.h"
#include "Log.h" #include "Log.h"
#include "Scene.h" #include "Scene.h"
@@ -21,6 +24,8 @@
#include "PatternSource.h" #include "PatternSource.h"
#include "DeviceSource.h" #include "DeviceSource.h"
#include "NetworkSource.h" #include "NetworkSource.h"
#include "SessionCreator.h"
#include "SessionVisitor.h"
#include "Settings.h" #include "Settings.h"
#include "Mixer.h" #include "Mixer.h"
#include "ActionManager.h" #include "ActionManager.h"
@@ -237,11 +242,7 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
{ {
ImGui::PushID(std::to_string(n.id()).c_str()); ImGui::PushID(std::to_string(n.id()).c_str());
if (ImGuiToolkit::ButtonIcon(6, 2)) { ImGuiToolkit::Icon(6, 2);
ImageProcessingShader defaultvalues;
n = defaultvalues;
Action::manager().store("Reset Filters");
}
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::Text("Filters"); ImGui::Text("Filters");
@@ -463,13 +464,45 @@ void ImGuiVisitor::visit (Source& s)
} }
s.setImageProcessingEnabled(on); s.setImageProcessingEnabled(on);
ImGui::SetCursorPosY(pos.y + preview_height); // ...come back
// image processing pannel // image processing pannel
if (s.imageProcessingEnabled()) if (s.imageProcessingEnabled()) {
s.processingShader()->accept(*this);
// geometry direct control // menu icon for image processing
ImGui::SetCursorPos( ImVec2( preview_width - ImGui::GetTextLineHeight(), pos.y + 4.5f * ImGui::GetFrameHeightWithSpacing())); // ...come back
if (ImGuiToolkit::IconButton(5, 8))
ImGui::OpenPopup( "MenuImageProcessing" );
if (ImGui::BeginPopup( "MenuImageProcessing" ))
{
if (ImGui::MenuItem("Reset" )){
ImageProcessingShader defaultvalues;
s.processingShader()->copy(defaultvalues);
std::ostringstream oss;
oss << s.name() << ": " << "Reset Filter";
Action::manager().store(oss.str());
}
if (ImGui::MenuItem("Copy" )){
std::string clipboard = SessionVisitor::getClipboard(s.processingShader());
if (!clipboard.empty())
ImGui::SetClipboardText(clipboard.c_str());
}
const char *clipboard = ImGui::GetClipboardText();
const bool can_paste = (clipboard != nullptr && SessionLoader::isClipboard(clipboard));
if (ImGui::MenuItem("Paste", NULL, false, can_paste)) {
SessionLoader::applyImageProcessing(s, clipboard);
std::ostringstream oss;
oss << s.name() << ": " << "Change Filter";
Action::manager().store(oss.str());
}
ImGui::EndPopup();
}
// full panel for image processing
ImGui::SetCursorPos( ImVec2( pos.x, pos.y + preview_height)); // ...come back
s.processingShader()->accept(*this);
}
// geometry direct control for DEBUG
// s.groupNode(View::GEOMETRY)->accept(*this); // s.groupNode(View::GEOMETRY)->accept(*this);
// s.groupNode((View::Mode) Settings::application.current_view)->accept(*this); // s.groupNode((View::Mode) Settings::application.current_view)->accept(*this);

View File

@@ -258,12 +258,12 @@ void UserInterface::handleKeyboard()
Action::manager().undo(); Action::manager().undo();
} }
else if (ImGui::IsKeyPressed( GLFW_KEY_C )) { else if (ImGui::IsKeyPressed( GLFW_KEY_C )) {
std::string clipboard = Mixer::selection().xml(); std::string clipboard = Mixer::selection().clipboard();
if (!clipboard.empty()) if (!clipboard.empty())
ImGui::SetClipboardText(clipboard.c_str()); ImGui::SetClipboardText(clipboard.c_str());
} }
else if (ImGui::IsKeyPressed( GLFW_KEY_X )) { else if (ImGui::IsKeyPressed( GLFW_KEY_X )) {
std::string clipboard = Mixer::selection().xml(); std::string clipboard = Mixer::selection().clipboard();
if (!clipboard.empty()) { if (!clipboard.empty()) {
ImGui::SetClipboardText(clipboard.c_str()); ImGui::SetClipboardText(clipboard.c_str());
Mixer::manager().deleteSelection(); Mixer::manager().deleteSelection();
@@ -787,10 +787,10 @@ void UserInterface::showMenuEdit()
{ {
bool has_selection = !Mixer::selection().empty(); bool has_selection = !Mixer::selection().empty();
const char *clipboard = ImGui::GetClipboardText(); const char *clipboard = ImGui::GetClipboardText();
bool has_clipboard = (clipboard != nullptr && strlen(clipboard) > 0 && Mixer::manager().isClipboard(clipboard)); bool has_clipboard = (clipboard != nullptr && strlen(clipboard) > 0 && SessionLoader::isClipboard(clipboard));
if (ImGui::MenuItem( ICON_FA_CUT " Cut", CTRL_MOD "X", false, has_selection)) { if (ImGui::MenuItem( ICON_FA_CUT " Cut", CTRL_MOD "X", false, has_selection)) {
std::string copied_text = Mixer::selection().xml(); std::string copied_text = Mixer::selection().clipboard();
if (!copied_text.empty()) { if (!copied_text.empty()) {
ImGui::SetClipboardText(copied_text.c_str()); ImGui::SetClipboardText(copied_text.c_str());
Mixer::manager().deleteSelection(); Mixer::manager().deleteSelection();
@@ -798,7 +798,7 @@ void UserInterface::showMenuEdit()
navigator.hidePannel(); navigator.hidePannel();
} }
if (ImGui::MenuItem( ICON_FA_COPY " Copy", CTRL_MOD "C", false, has_selection)) { if (ImGui::MenuItem( ICON_FA_COPY " Copy", CTRL_MOD "C", false, has_selection)) {
std::string copied_text = Mixer::selection().xml(); std::string copied_text = Mixer::selection().clipboard();
if (!copied_text.empty()) if (!copied_text.empty())
ImGui::SetClipboardText(copied_text.c_str()); ImGui::SetClipboardText(copied_text.c_str());
navigator.hidePannel(); navigator.hidePannel();