diff --git a/rsc/images/icons.dds b/rsc/images/icons.dds index e14e335..92c9236 100644 Binary files a/rsc/images/icons.dds and b/rsc/images/icons.dds differ diff --git a/src/ImageFilter.cpp b/src/ImageFilter.cpp index 3dec906..21a758c 100644 --- a/src/ImageFilter.cpp +++ b/src/ImageFilter.cpp @@ -272,7 +272,7 @@ void ImageFilteringShader::setCode(const std::string &code, std::promiseset_value("No change."); + ret->set_value("No change"); } } diff --git a/src/Mixer.cpp b/src/Mixer.cpp index 3e09dbe..7c9097a 100644 --- a/src/Mixer.cpp +++ b/src/Mixer.cpp @@ -465,10 +465,10 @@ Source * Mixer::createSourceGroup() return s; } -Source * Mixer::createSourceClone(const std::string &namesource, bool copy_attributes) +CloneSource * Mixer::createSourceClone(const std::string &namesource, bool copy_attributes) { // ready to create a source - Source *s = nullptr; + CloneSource *s = nullptr; // origin to clone is either the given name or the current SourceList::iterator origin = session_->end(); diff --git a/src/Mixer.h b/src/Mixer.h index c34f447..178d8aa 100644 --- a/src/Mixer.h +++ b/src/Mixer.h @@ -50,7 +50,7 @@ public: // creation of sources Source * createSourceFile (const std::string &path, bool disable_hw_decoding = false); Source * createSourceMultifile(const std::list &list_files, uint fps); - Source * createSourceClone (const std::string &namesource = "", bool copy_attributes = true); + class CloneSource *createSourceClone(const std::string &namesource = "", bool copy_attributes = true); Source * createSourceRender (); Source * createSourceStream (const std::string &gstreamerpipeline); Source * createSourcePattern(uint pattern, glm::ivec2 res); diff --git a/src/ShaderEditWindow.cpp b/src/ShaderEditWindow.cpp index 7f945bc..11b3961 100644 --- a/src/ShaderEditWindow.cpp +++ b/src/ShaderEditWindow.cpp @@ -18,6 +18,7 @@ TextEditor _editor; #include "SystemToolkit.h" #include "CloneSource.h" #include "DialogToolkit.h" +#include "UserInterfaceManager.h" #include "ShaderEditWindow.h" @@ -141,6 +142,8 @@ void ShaderEditWindow::Render() return; } + Source *cs = Mixer::manager().currentSource(); + // menu (no title bar) if (ImGui::BeginMenuBar()) { @@ -149,6 +152,16 @@ void ShaderEditWindow::Render() Settings::application.widget.shader_editor = false; if (ImGui::BeginMenu(IMGUI_TITLE_SHADEREDITOR)) { + // Menu entry to allow creating a custom filter + if (ImGui::MenuItem(ICON_FA_SHARE_SQUARE " Clone source & add filter", + nullptr, nullptr, cs != nullptr)) { + CloneSource *filteredclone = Mixer::manager().createSourceClone(); + filteredclone->setFilter(FrameBufferFilter::FILTER_IMAGE); + Mixer::manager().addSource ( filteredclone ); + UserInterface::manager().showPannel( Mixer::manager().numSource() ); + } + ImGui::Separator(); + // reload code from GPU if (ImGui::MenuItem( ICON_FA_REDO_ALT " Reload", nullptr, nullptr, current_ != nullptr)) { // force reload @@ -189,13 +202,6 @@ void ShaderEditWindow::Render() if (ImGui::MenuItem( ICON_FA_EXTERNAL_LINK_ALT " Browse shadertoy.com")) SystemToolkit::open("https://www.shadertoy.com/"); - // Enable/Disable editor options - ImGui::Separator(); - ImGui::MenuItem( ICON_FA_UNDERLINE " Show Shader Inputs", nullptr, &show_shader_inputs_); - bool ws = _editor.IsShowingWhitespaces(); - if (ImGui::MenuItem( ICON_FA_ELLIPSIS_H " Show whitespace", nullptr, &ws)) - _editor.SetShowWhitespaces(ws); - // output manager menu ImGui::Separator(); bool pinned = Settings::application.widget.shader_editor_view == Settings::application.current_view; @@ -231,6 +237,13 @@ void ShaderEditWindow::Render() if (ImGui::MenuItem( MENU_SELECTALL, SHORTCUT_SELECTALL, nullptr, _editor.GetText().size() > 1 )) _editor.SetSelection(TextEditor::Coordinates(), TextEditor::Coordinates(_editor.GetTotalLines(), 0)); + // Enable/Disable editor options + ImGui::Separator(); + ImGui::MenuItem( ICON_FA_UNDERLINE " Show Shader Inputs", nullptr, &show_shader_inputs_); + bool ws = _editor.IsShowingWhitespaces(); + if (ImGui::MenuItem( ICON_FA_ELLIPSIS_H " Show whitespace", nullptr, &ws)) + _editor.SetShowWhitespaces(ws); + ImGui::EndMenu(); } @@ -301,11 +314,9 @@ void ShaderEditWindow::Render() else { ImageFilter *i = nullptr; - // get current clone source - Source *s = Mixer::manager().currentSource(); // if there is a current source - if (s != nullptr) { - CloneSource *c = dynamic_cast(s); + if (cs != nullptr) { + CloneSource *c = dynamic_cast(cs); // if the current source is a clone if ( c != nullptr ) { FrameBufferFilter *f = c->filter(); @@ -325,6 +336,7 @@ void ShaderEditWindow::Render() if (i == nullptr) { status_ = "-"; _editor.SetText(""); + _editor.SetReadOnly(true); current_ = nullptr; } } @@ -347,10 +359,13 @@ void ShaderEditWindow::Render() _editor.SetText( filters_[i].code().first ); _editor.SetReadOnly(false); _editor.SetColorizerEnable(true); - status_ = "Ready."; + status_ = "Ready"; } // cancel edit clone else { + // possibility that source was removed + g_printerr("cancel edit clone %ld\n", current_); + // disable editor _editor.SetReadOnly(true); _editor.SetColorizerEnable(false); diff --git a/src/UserInterfaceManager.cpp b/src/UserInterfaceManager.cpp index 1882c0d..2fb505f 100644 --- a/src/UserInterfaceManager.cpp +++ b/src/UserInterfaceManager.cpp @@ -1122,6 +1122,9 @@ void UserInterface::showMenuWindows() if ( ImGui::MenuItem( MENU_INPUTS, SHORTCUT_INPUTS, &Settings::application.widget.inputs) ) UserInterface::manager().inputscontrol.setVisible(Settings::application.widget.inputs); + if ( ImGui::MenuItem( MENU_SHADEREDITOR, SHORTCUT_SHADEREDITOR, &Settings::application.widget.shader_editor) ) + UserInterface::manager().shadercontrol.setVisible(Settings::application.widget.shader_editor); + // Show Help ImGui::MenuItem( MENU_HELP, SHORTCUT_HELP, &Settings::application.widget.help ); // Show Logs @@ -3558,8 +3561,10 @@ void Navigator::RenderSourcePannel(Source *s, const ImVec2 &iconsize) if ( s->failed() ) { ImGuiToolkit::ButtonDisabled( ICON_FA_SHARE_SQUARE " Clone & Filter", ImVec2(ImGui::GetContentRegionAvail().x, 0)); } - else if ( ImGui::Button( ICON_FA_SHARE_SQUARE " Clone & Filter", ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) - Mixer::manager().addSource ( Mixer::manager().createSourceClone() ); + else if ( ImGui::Button( ICON_FA_SHARE_SQUARE " Clone & Filter", ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) { + Mixer::manager().addSource ( (Source *) Mixer::manager().createSourceClone() ); + UserInterface::manager().showPannel( Mixer::manager().numSource() ); + } // replace button if ( ImGui::Button( ICON_FA_PLUS_SQUARE " Replace", ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) { diff --git a/src/defines.h b/src/defines.h index c67cf6b..ac03bbc 100644 --- a/src/defines.h +++ b/src/defines.h @@ -232,9 +232,10 @@ #define MENU_TIMER ICON_FA_CLOCK " Timer " #define TOOLTIP_TIMER "Timer " #define SHORTCUT_TIMER CTRL_MOD "T" -#define MENU_INPUTS ICON_FA_HAND_PAPER " Inputs mapping " +#define MENU_INPUTS ICON_FA_HAND_PAPER " Input mapping " #define TOOLTIP_INPUTS "Inputs mapping " #define SHORTCUT_INPUTS CTRL_MOD "I" +#define MENU_SHADEREDITOR ICON_FA_CODE " Shader Editor " #define TOOLTIP_SHADEREDITOR "Shader Editor " #define SHORTCUT_SHADEREDITOR CTRL_MOD "E" #define TOOLTIP_FULLSCREEN "Fullscreen "