From 99d1d5694c860d7c39ddf15ef5a4700216a55468 Mon Sep 17 00:00:00 2001 From: apistol78 Date: Wed, 29 May 2024 16:34:20 +0200 Subject: [PATCH] Traktor: Moved target logs to target pane and handled by the Runtime.Editor module. --- code/Editor/App/EditorForm.cpp | 53 +--- code/Editor/App/EditorForm.h | 4 - code/Editor/App/ObjectEditor.cpp | 5 - code/Editor/App/ObjectEditor.h | 2 - code/Editor/IEditor.h | 3 - code/Editor/{App => }/LogView.cpp | 2 +- code/Editor/{App => }/LogView.h | 10 +- code/Runtime/Editor/EditorPlugin.cpp | 34 ++- code/Runtime/Editor/EditorPlugin.h | 5 + code/Runtime/Editor/TargetManager.cpp | 5 +- code/Runtime/Editor/TargetManager.h | 6 +- resources/build/TraktorWin64.xms | 345 +++++++++++++------------- 12 files changed, 236 insertions(+), 238 deletions(-) rename code/Editor/{App => }/LogView.cpp (99%) rename code/Editor/{App => }/LogView.h (89%) diff --git a/code/Editor/App/EditorForm.cpp b/code/Editor/App/EditorForm.cpp index 6e509074c7..0e6c098034 100644 --- a/code/Editor/App/EditorForm.cpp +++ b/code/Editor/App/EditorForm.cpp @@ -48,6 +48,7 @@ #include "Editor/IObjectEditor.h" #include "Editor/IObjectEditorFactory.h" #include "Editor/IPipeline.h" +#include "Editor/LogView.h" #include "Editor/PipelineDependency.h" #include "Editor/PipelineDependencySet.h" #include "Editor/TypeBrowseFilter.h" @@ -60,7 +61,6 @@ #include "Editor/App/EditorForm.h" #include "Editor/App/EditorPageSite.h" #include "Editor/App/EditorPluginSite.h" -#include "Editor/App/LogView.h" #include "Editor/App/MRU.h" #include "Editor/App/NewInstanceDialog.h" #include "Editor/App/NewWorkspaceDialog.h" @@ -594,18 +594,9 @@ bool EditorForm::create(const CommandLine& cmdLine) m_paneSouth->dock(m_dataBaseView); // Create output panel. - m_tabOutput = new ui::Tab(); - m_tabOutput->create(m_dock, ui::Tab::WsLine | ui::Tab::WsBottom); - m_tabOutput->setText(i18n::Text(L"TITLE_OUTPUT")); - if (!m_mergedSettings->getProperty< bool >(L"Editor.LogVisible")) - m_tabOutput->hide(); - - Ref< ui::TabPage > tabPageLog = new ui::TabPage(); - tabPageLog->create(m_tabOutput, i18n::Text(L"TITLE_LOG"), new ui::FloodLayout()); - m_logView = new LogView(this); - m_logView->create(tabPageLog); - m_logView->setText(i18n::Text(L"TITLE_LOG")); + m_logView->create(m_dock); + m_logView->setText(i18n::Text(L"TITLE_OUTPUT")); // Replay logs into log view. infoLog->replay(m_logView->getLogTarget()); @@ -616,10 +607,7 @@ bool EditorForm::create(const CommandLine& cmdLine) log::warning.setGlobalTarget(new LogRedirectTarget(defaultWarningLog, m_logView->getLogTarget())); log::error.setGlobalTarget(new LogRedirectTarget(defaultErrorLog, m_logView->getLogTarget())); - m_tabOutput->addPage(tabPageLog); - m_tabOutput->setActivePage(tabPageLog); - - m_paneSouth->dock(m_tabOutput); + m_paneSouth->dock(m_logView); // Create tab groups; only add one by default, user needs to add more groups manually. m_tabGroupContainer = new ui::MultiSplitter(); @@ -913,33 +901,6 @@ void EditorForm::revertWorkspaceSettings() { } -Ref< ILogTarget > EditorForm::createLogTarget(const std::wstring& title) -{ - if (m_logTargets[title] == nullptr) - { - Ref< ui::TabPage > tabPageLog = new ui::TabPage(); - if (!tabPageLog->create(m_tabOutput, title, new ui::FloodLayout())) - return nullptr; - - Ref< LogView > logView = new LogView(this); - logView->create(tabPageLog); - logView->setText(title); - - Ref< ui::TabPage > activePage = m_tabOutput->getActivePage(); - m_tabOutput->addPage(tabPageLog); - - if (m_globalSettings->getProperty< bool >(L"Editor.ShowNewLogTargets")) - m_tabOutput->setActivePage(tabPageLog); - else - m_tabOutput->setActivePage(activePage); - - m_tabOutput->update(); - - m_logTargets[title] = logView->getLogTarget(); - } - return m_logTargets[title]; -} - Ref< db::Database > EditorForm::getSourceDatabase() const { return m_sourceDatabase; @@ -2739,7 +2700,7 @@ bool EditorForm::handleCommand(const ui::Command& command) } else if (command == L"Editor.ViewLog") { - m_dock->showWidget(m_tabOutput); + m_dock->showWidget(m_logView); } else if (command == L"Editor.ViewOther") { @@ -2964,8 +2925,8 @@ void EditorForm::eventClose(ui::CloseEvent* event) m_globalSettings->setProperty< PropertyInteger >(L"Editor.PaneEastWidth", unit(m_paneEast->getPaneRect().getWidth()).get()); // Save panes visible. - m_globalSettings->setProperty< PropertyBoolean >(L"Editor.DatabaseVisible", m_dataBaseView->isVisible(false)); - m_globalSettings->setProperty< PropertyBoolean >(L"Editor.LogVisible", m_tabOutput->isVisible(false)); + m_globalSettings->setProperty< PropertyBoolean >(L"Editor.DatabaseVisible", m_dock->isWidgetVisible(m_dataBaseView)); + m_globalSettings->setProperty< PropertyBoolean >(L"Editor.LogVisible", m_dock->isWidgetVisible(m_logView)); // Save form placement. const ui::Rect rc = getNormalRect(); diff --git a/code/Editor/App/EditorForm.h b/code/Editor/App/EditorForm.h index 4516c43c7d..91cfab7097 100644 --- a/code/Editor/App/EditorForm.h +++ b/code/Editor/App/EditorForm.h @@ -112,8 +112,6 @@ class EditorForm virtual void revertWorkspaceSettings() override final; - virtual Ref< ILogTarget > createLogTarget(const std::wstring& title) override final; - virtual Ref< db::Database > getSourceDatabase() const override final; virtual Ref< db::Database > getOutputDatabase() const override final; @@ -205,8 +203,6 @@ class EditorForm Ref< ui::Menu > m_menuTab; Ref< ui::ToolBarMenu > m_menuTools; Ref< DatabaseView > m_dataBaseView; - Ref< ui::Tab > m_tabOutput; - std::map< std::wstring, Ref< ILogTarget > > m_logTargets; Ref< LogView > m_logView; Ref< db::Database > m_sourceDatabase; Ref< db::Database > m_outputDatabase; diff --git a/code/Editor/App/ObjectEditor.cpp b/code/Editor/App/ObjectEditor.cpp index e2f2bc9cee..0927fb7632 100644 --- a/code/Editor/App/ObjectEditor.cpp +++ b/code/Editor/App/ObjectEditor.cpp @@ -55,11 +55,6 @@ void ObjectEditor::revertWorkspaceSettings() m_editor->revertWorkspaceSettings(); } -Ref< ILogTarget > ObjectEditor::createLogTarget(const std::wstring& title) -{ - return m_editor->createLogTarget(title); -} - Ref< db::Database > ObjectEditor::getSourceDatabase() const { return m_editor->getSourceDatabase(); diff --git a/code/Editor/App/ObjectEditor.h b/code/Editor/App/ObjectEditor.h index 95b7ea75f2..a063de96bd 100644 --- a/code/Editor/App/ObjectEditor.h +++ b/code/Editor/App/ObjectEditor.h @@ -44,8 +44,6 @@ class ObjectEditor virtual void revertWorkspaceSettings() override final; - virtual Ref< ILogTarget > createLogTarget(const std::wstring& title) override final; - virtual Ref< db::Database > getSourceDatabase() const override final; virtual Ref< db::Database > getOutputDatabase() const override final; diff --git a/code/Editor/IEditor.h b/code/Editor/IEditor.h index 6ca0f5b09f..3d34abb2b5 100644 --- a/code/Editor/IEditor.h +++ b/code/Editor/IEditor.h @@ -81,9 +81,6 @@ class T_NOVTABLE IEditor /*! \} */ - /*! Create log targets. */ - virtual Ref< ILogTarget > createLogTarget(const std::wstring& title) = 0; - /*! Get source asset database. */ virtual Ref< db::Database > getSourceDatabase() const = 0; diff --git a/code/Editor/App/LogView.cpp b/code/Editor/LogView.cpp similarity index 99% rename from code/Editor/App/LogView.cpp rename to code/Editor/LogView.cpp index 29138a76ec..604bc867d5 100644 --- a/code/Editor/App/LogView.cpp +++ b/code/Editor/LogView.cpp @@ -20,7 +20,7 @@ #include "Database/Instance.h" #include "Database/Traverse.h" #include "Editor/IEditor.h" -#include "Editor/App/LogView.h" +#include "Editor/LogView.h" #include "I18N/Text.h" #include "Ui/Edit.h" #include "Ui/Menu.h" diff --git a/code/Editor/App/LogView.h b/code/Editor/LogView.h similarity index 89% rename from code/Editor/App/LogView.h rename to code/Editor/LogView.h index 0831cb2141..92a8d067e5 100644 --- a/code/Editor/App/LogView.h +++ b/code/Editor/LogView.h @@ -11,6 +11,14 @@ #include "Ui/Container.h" #include "Ui/LogList/LogList.h" +// import/export mechanism. +#undef T_DLLCLASS +#if defined(T_EDITOR_EXPORT) +# define T_DLLCLASS T_DLLEXPORT +#else +# define T_DLLCLASS T_DLLIMPORT +#endif + namespace traktor { @@ -35,7 +43,7 @@ namespace traktor::editor class IEditor; -class LogView +class T_DLLCLASS LogView : public ui::Container , public ui::LogList::ISymbolLookup { diff --git a/code/Runtime/Editor/EditorPlugin.cpp b/code/Runtime/Editor/EditorPlugin.cpp index e140f5f116..2e66c450fa 100644 --- a/code/Runtime/Editor/EditorPlugin.cpp +++ b/code/Runtime/Editor/EditorPlugin.cpp @@ -29,6 +29,7 @@ #include "Drawing/PixelFormat.h" #include "Editor/IEditorPage.h" #include "Editor/IEditorPageSite.h" +#include "Editor/LogView.h" #include "I18N/Text.h" #include "Net/BidirectionalObjectTransport.h" #include "Net/Network.h" @@ -62,8 +63,11 @@ #include "Ui/Clipboard.h" #include "Ui/Command.h" #include "Ui/Container.h" +#include "Ui/FloodLayout.h" #include "Ui/MenuItem.h" #include "Ui/Splitter.h" +#include "Ui/Tab.h" +#include "Ui/TabPage.h" #include "Ui/TableLayout.h" #include "Ui/ToolBar/ToolBar.h" #include "Ui/ToolBar/ToolBarButtonClickEvent.h" @@ -199,8 +203,8 @@ bool EditorPlugin::create(editor::IEditor* editor, ui::Widget* parent, editor::I // Performance panel { - Ref< ui::Container > container = new ui::Container(); - container->create(m_splitter, ui::WsNone, new ui::TableLayout(L"100%", L"100%", 0_ut, 0_ut)); + m_tabOutput = new ui::Tab(); + m_tabOutput->create(m_splitter, ui::Tab::WsLine | ui::Tab::WsBottom); } m_site->createAdditionalPanel(m_splitter, 200_ut, false); @@ -352,7 +356,9 @@ void EditorPlugin::handleWorkspaceOpened() updateTargetLists(); // Create target manager. - m_targetManager = new TargetManager(m_editor); + m_targetManager = new TargetManager(m_editor, [=, this](const std::wstring& name) -> Ref< ILogTarget > { + return createLogTarget(name); + }); if (!m_targetManager->create()) { log::error << L"Unable to create target manager; target manager disabled" << Endl; @@ -488,6 +494,28 @@ void EditorPlugin::updateTargetManagers() } } +Ref< ILogTarget > EditorPlugin::createLogTarget(const std::wstring& name) +{ + if (m_logTargets[name] == nullptr) + { + Ref< ui::TabPage > tabPageLog = new ui::TabPage(); + if (!tabPageLog->create(m_tabOutput, name, new ui::FloodLayout())) + return nullptr; + + Ref< editor::LogView > logView = new editor::LogView(m_editor); + logView->create(tabPageLog); + logView->setText(name); + + Ref< ui::TabPage > activePage = m_tabOutput->getActivePage(); + m_tabOutput->addPage(tabPageLog); + m_tabOutput->setActivePage(tabPageLog); + m_tabOutput->update(); + + m_logTargets[name] = logView->getLogTarget(); + } + return m_logTargets[name]; +} + Ref< PropertyGroup > EditorPlugin::getTweakSettings() const { Ref< PropertyGroup > tweakSettings = new PropertyGroup(); diff --git a/code/Runtime/Editor/EditorPlugin.h b/code/Runtime/Editor/EditorPlugin.h index b92a07dc9a..dbd21a77d7 100644 --- a/code/Runtime/Editor/EditorPlugin.h +++ b/code/Runtime/Editor/EditorPlugin.h @@ -32,6 +32,7 @@ namespace traktor::ui class Container; class Splitter; +class Tab; class TimerEvent; class ToolBar; class ToolBarButtonClickEvent; @@ -115,6 +116,8 @@ class EditorPlugin : public editor::IEditorPlugin Ref< ui::ToolBarDropMenu > m_toolTweaks; Ref< ui::ToolBarDropDown > m_toolLanguage; Ref< TargetListControl > m_targetList; + Ref< ui::Tab > m_tabOutput; + std::map< std::wstring, Ref< ILogTarget > > m_logTargets; // \} // \name Tool @@ -146,6 +149,8 @@ class EditorPlugin : public editor::IEditorPlugin void updateTargetManagers(); + Ref< ILogTarget > createLogTarget(const std::wstring& name); + Ref< PropertyGroup > getTweakSettings() const; void launch(TargetInstance* targetInstance); diff --git a/code/Runtime/Editor/TargetManager.cpp b/code/Runtime/Editor/TargetManager.cpp index c24ff1cbea..6e1cd42b37 100644 --- a/code/Runtime/Editor/TargetManager.cpp +++ b/code/Runtime/Editor/TargetManager.cpp @@ -26,8 +26,9 @@ namespace traktor::runtime T_IMPLEMENT_RTTI_CLASS(L"traktor.runtime.TargetManager", TargetManager, Object) -TargetManager::TargetManager(editor::IEditor *editor) +TargetManager::TargetManager(editor::IEditor* editor, const fn_new_log_target_t& newLogTargetFn) : m_editor(editor) +, m_newLogTargetFn(newLogTargetFn) , m_port(0) { } @@ -143,7 +144,7 @@ bool TargetManager::update() if (running > 0) logName += L" (" + toString(running) + L")"; - Ref< ILogTarget > targetLog = m_editor->createLogTarget(logName); + Ref< ILogTarget > targetLog = m_newLogTargetFn(logName); // Create connection object and add to instance. Ref< script::IScriptDebuggerSessions > debuggerSessions = m_editor->getObjectStore()->get< script::IScriptDebuggerSessions >(); diff --git a/code/Runtime/Editor/TargetManager.h b/code/Runtime/Editor/TargetManager.h index fe010b0ae2..3e82360bbe 100644 --- a/code/Runtime/Editor/TargetManager.h +++ b/code/Runtime/Editor/TargetManager.h @@ -8,6 +8,7 @@ */ #pragma once +#include #include "Core/RefArray.h" #include "Net/TcpSocket.h" @@ -38,7 +39,9 @@ class TargetManager : public Object T_RTTI_CLASS; public: - explicit TargetManager(editor::IEditor *editor); + typedef std::function< Ref< ILogTarget >(const std::wstring& name) > fn_new_log_target_t; + + explicit TargetManager(editor::IEditor* editor, const fn_new_log_target_t& newLogTargetFn); bool create(); @@ -56,6 +59,7 @@ class TargetManager : public Object private: editor::IEditor* m_editor; + fn_new_log_target_t m_newLogTargetFn; Ref< net::TcpSocket > m_listenSocket; RefArray< TargetInstance > m_instances; uint16_t m_port; diff --git a/resources/build/TraktorWin64.xms b/resources/build/TraktorWin64.xms index 5d967ee72b..3c67f71bbc 100644 --- a/resources/build/TraktorWin64.xms +++ b/resources/build/TraktorWin64.xms @@ -5045,6 +5045,159 @@ LnkYes + + true + LnkYes + + true + Traktor.I18N + $(TRAKTOR_HOME)/code/I18N + + + DebugShared + TfSharedLibrary + TpDebug + + + + T_I18N_EXPORT + + + + WlCompilerDefault + + + + + + + + + Traktor.I18N.pdb + debugshared + + + Traktor.I18N.lib + debugshared + + + Traktor.I18N.dll + debugshared + + + debugshared + + + ReleaseShared + TfSharedLibrary + TpRelease + + + + T_I18N_EXPORT + + + + WlCompilerDefault + + + + + + + + + Traktor.I18N.pdb + releaseshared + + + Traktor.I18N.lib + releaseshared + + + Traktor.I18N.dll + releaseshared + + + releaseshared + + + DebugStatic + TfStaticLibrary + TpDebug + + + + T_STATIC + + + + WlCompilerDefault + + + + + + + + + Traktor.I18N.pdb + debugstatic + + + Traktor.I18N.lib + debugstatic + + + debugstatic + + + ReleaseStatic + TfStaticLibrary + TpRelease + + + + T_STATIC + + + + WlCompilerDefault + + + + + + + + + Traktor.I18N.pdb + releasestatic + + + Traktor.I18N.lib + releasestatic + + + releasestatic + + + + + *.* + + + + + + + true + LnkYes + + + + + @@ -5652,155 +5805,7 @@ true LnkYes - - true - Traktor.I18N - $(TRAKTOR_HOME)/code/I18N - - - DebugShared - TfSharedLibrary - TpDebug - - - - T_I18N_EXPORT - - - - WlCompilerDefault - - - - - - - - - Traktor.I18N.pdb - debugshared - - - Traktor.I18N.lib - debugshared - - - Traktor.I18N.dll - debugshared - - - debugshared - - - ReleaseShared - TfSharedLibrary - TpRelease - - - - T_I18N_EXPORT - - - - WlCompilerDefault - - - - - - - - - Traktor.I18N.pdb - releaseshared - - - Traktor.I18N.lib - releaseshared - - - Traktor.I18N.dll - releaseshared - - - releaseshared - - - DebugStatic - TfStaticLibrary - TpDebug - - - - T_STATIC - - - - WlCompilerDefault - - - - - - - - - Traktor.I18N.pdb - debugstatic - - - Traktor.I18N.lib - debugstatic - - - debugstatic - - - ReleaseStatic - TfStaticLibrary - TpRelease - - - - T_STATIC - - - - WlCompilerDefault - - - - - - - - - Traktor.I18N.pdb - releasestatic - - - Traktor.I18N.lib - releasestatic - - - releasestatic - - - - - *.* - - - - - - - true - LnkYes - - - - + true @@ -5980,7 +5985,7 @@ true LnkYes - + true @@ -6304,7 +6309,7 @@ true LnkYes - + true @@ -7150,7 +7155,7 @@ true LnkYes - + true @@ -7799,7 +7804,7 @@ true LnkYes - + true @@ -8032,7 +8037,7 @@ true LnkYes - + true @@ -8227,7 +8232,7 @@ true LnkYes - + true @@ -8479,7 +8484,7 @@ true LnkYes - + true @@ -9323,7 +9328,7 @@ true LnkYes - + true @@ -9548,7 +9553,7 @@ true LnkYes - + true @@ -9609,7 +9614,7 @@ - + true Traktor.I18N.Editor @@ -9765,7 +9770,7 @@ true LnkYes - + true @@ -11116,7 +11121,7 @@ true LnkYes - + true @@ -12172,7 +12177,7 @@ true LnkYes - + true @@ -12565,7 +12570,7 @@ true LnkYes - + true @@ -12912,7 +12917,7 @@ true LnkYes - + true @@ -13816,7 +13821,7 @@ true LnkYes - + true @@ -14066,7 +14071,7 @@ true LnkYes - + true @@ -15389,7 +15394,7 @@ true LnkYes - + true @@ -15568,7 +15573,7 @@ true LnkYes - + true @@ -16817,7 +16822,7 @@ true LnkYes - + true @@ -20187,7 +20192,7 @@ true LnkYes - +