| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #pragma once
- #if !defined(Q_MOC_RUN)
- #include <AzQtComponents/Components/Widgets/TabWidget.h>
- #include <QMetaType>
- #include <AzCore/Component/EntityId.h>
- #include <AzCore/Asset/AssetCommon.h>
- #include <ScriptCanvas/Core/Core.h>
- #include <ScriptCanvas/Bus/RequestBus.h>
- #endif
- class QGraphicsView;
- class QVBoxLayout;
- namespace ScriptCanvasEditor
- {
- using SourceHandle = SourceHandle;
- namespace Widget
- {
- class CanvasWidget;
- struct GraphTabMetadata
- {
- SourceHandle m_assetId;
- QWidget* m_hostWidget = nullptr;
- CanvasWidget* m_canvasWidget = nullptr;
- Tracker::ScriptCanvasFileState m_fileState = Tracker::ScriptCanvasFileState::INVALID;
- };
- class GraphTabBar
- : public AzQtComponents::TabBar
- {
- Q_OBJECT
- public:
- GraphTabBar(QWidget* parent = nullptr);
- ~GraphTabBar() override = default;
- AZStd::optional<GraphTabMetadata> GetTabData(int index) const;
- AZStd::optional<GraphTabMetadata> GetTabData(SourceHandle assetId) const;
- void SetTabData(const GraphTabMetadata& data, int index);
- void SetTabData(const GraphTabMetadata& data, SourceHandle assetId);
- void AddGraphTab(SourceHandle assetId, Tracker::ScriptCanvasFileState fileState);
- void CloseTab(int index);
- void CloseAllTabs();
- int InsertGraphTab(int tabIndex, SourceHandle assetId, Tracker::ScriptCanvasFileState fileState);
- bool SelectTab(SourceHandle assetId);
- int FindTab(SourceHandle assetId) const;
- int FindTab(ScriptCanvasEditor::GraphPtrConst graph) const;
- int FindSaveOverMatch(SourceHandle assetId) const;
- SourceHandle FindTabByPath(AZStd::string_view path) const;
- SourceHandle FindAssetId(int tabIndex);
- ScriptCanvas::ScriptCanvasId FindScriptCanvasIdFromGraphCanvasId(const GraphCanvas::GraphId& graphCanvasGraphId) const;
- void ClearTabView(int tabIndex);
- CanvasWidget* ModOrCreateTabView(int tabIndex);
- CanvasWidget* ModTabView(int tabIndex);
- void OnContextMenu(const QPoint& point);
- void mouseReleaseEvent(QMouseEvent* event) override;
- // Updates the tab at the supplied index with the GraphTabMetadata
- // The host widget field of the tabMetadata is not used and will not overwrite the tab data
- void SetTabText(int tabIndex, const QString& path, Tracker::ScriptCanvasFileState fileState = Tracker::ScriptCanvasFileState::INVALID);
- void UpdateFileState(const SourceHandle& assetId, Tracker::ScriptCanvasFileState fileState);
- Q_SIGNALS:
- void TabInserted(int index);
- void TabRemoved(int index);
- // Emits a signal to close the tab which is distinct from pressing the close button the actual tab bar.
- // This allows handling of the close tab button being pressed different than the actual closing of the tab.
- // Pressing the close tab button will prompt the user to save file in tab if it is modified
- void TabCloseNoButton(int index);
- void SaveTab(int index);
- void CloseAllTabsSignal();
- void CloseAllTabsButSignal(int index);
- void CopyPathToClipboard(int index);
- void OnActiveFileStateChanged();
- protected:
- void tabInserted(int index) override;
- void tabRemoved(int index) override;
- private:
- // Called when the selected tab changes
- void currentChangedTab(int index);
-
- int m_signalSaveOnChangeTo = -1;
- };
- }
- }
- Q_DECLARE_METATYPE(ScriptCanvasEditor::Widget::GraphTabMetadata);
|