Provisional implemenation and testing of central state tracker to track viewport editing modes. (#4112)
* Provisional impl and testing of central state tracker. Signed-off-by: John <jonawals@amazon.com> * Add missing namespace comment. Signed-off-by: John <jonawals@amazon.com> * ViewportEditorModeState -> ViewportEditorModes Signed-off-by: John <jonawals@amazon.com> * ViewportEditorModesTracker -> ViewportEditorModeTracker Signed-off-by: John <jonawals@amazon.com> * GetEditorModeState ->GetViewportEditorModes Signed-off-by: John <jonawals@amazon.com> * GetNumTrackedViewports -> GetTrackedViewportCount Signed-off-by: John <jonawals@amazon.com> * IsViewportStateBeingTracked -> IsViewportModeTracked Signed-off-by: John <jonawals@amazon.com> * Fix API comments. Signed-off-by: John <jonawals@amazon.com> * Delete hangover file. Signed-off-by: John <jonawals@amazon.com> * Delete more hangover files. Signed-off-by: John <jonawals@amazon.com> * Minor member name refactor. Signed-off-by: John <jonawals@amazon.com> * Refactor nonclemanture. Signed-off-by: John <jonawals@amazon.com> * Rename Enter/ExitMode to Register/UnregisterMode. Signed-off-by: John <jonawals@amazon.com> * Error and warning msgs now return AZ::Outcomes. Signed-off-by: John <jonawals@amazon.com> * Change all nomenclature to Activate/Deactivate for consistency. Signed-off-by: John <jonawals@amazon.com> * Change tense of notification bus methods. Signed-off-by: John <jonawals@amazon.com> * Fix malformed string format. Signed-off-by: John <jonawals@amazon.com> * Fix malformed string format (again). Signed-off-by: John <jonawals@amazon.com> * Fix Linux warning. Signed-off-by: John <jonawals@amazon.com>
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/Outcome/Outcome.h>
|
||||
#include <AzToolsFramework/API/ViewportEditorModeTrackerNotificationBus.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
//! The AZ::Interface of the central editor mode tracker for all viewports.
|
||||
class ViewportEditorModeTrackerInterface
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ViewportEditorModeTrackerInterface, "{7D72A4F7-2147-4ED9-A315-E456A3BE3CF6}");
|
||||
|
||||
virtual ~ViewportEditorModeTrackerInterface() = default;
|
||||
|
||||
//! Activates the specified editor mode for the specified viewport.
|
||||
virtual AZ::Outcome<void, AZStd::string> ActivateMode(
|
||||
const ViewportEditorModeInfo& viewportEditorModeInfo, ViewportEditorMode mode) = 0;
|
||||
|
||||
//! Deactivates the specified editor mode for the specified viewport.
|
||||
virtual AZ::Outcome<void, AZStd::string> DeactivateMode(
|
||||
const ViewportEditorModeInfo& viewportEditorModeInfo, ViewportEditorMode mode) = 0;
|
||||
|
||||
//! Attempts to retrieve the editor mode state for the specified viewport, otherwise returns nullptr.
|
||||
virtual const ViewportEditorModesInterface* GetViewportEditorModes(const ViewportEditorModeInfo& viewportEditorModeInfo) const = 0;
|
||||
|
||||
//! Returns the number of viewports currently being tracked.
|
||||
virtual size_t GetTrackedViewportCount() const = 0;
|
||||
|
||||
//! Returns true if the specified viewport is being tracked, otherwise false.
|
||||
virtual bool IsViewportModeTracked(const ViewportEditorModeInfo& viewportEditorModeInfo) const = 0;
|
||||
};
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#include <AzCore/EBus/Event.h>
|
||||
#include <AzFramework/Viewport/ViewportId.h>
|
||||
#include <AzToolsFramework/ViewportUi/ViewportUiRequestBus.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
//! Enumeration of each viewport editor mode.
|
||||
enum class ViewportEditorMode : AZ::u8
|
||||
{
|
||||
Default,
|
||||
Component,
|
||||
Focus,
|
||||
Pick
|
||||
};
|
||||
|
||||
//! Viewport identifier and other relevant viewport data.
|
||||
struct ViewportEditorModeInfo
|
||||
{
|
||||
using IdType = AzFramework::ViewportId;
|
||||
IdType m_id = ViewportUi::DefaultViewportId; //!< The unique identifier for a given viewport.
|
||||
};
|
||||
|
||||
//! Interface for the editor modes of a given viewport.
|
||||
class ViewportEditorModesInterface
|
||||
{
|
||||
public:
|
||||
virtual ~ViewportEditorModesInterface() = default;
|
||||
|
||||
//! Returns true if the specified editor mode is active, otherwise false.
|
||||
virtual bool IsModeActive(ViewportEditorMode mode) const = 0;
|
||||
};
|
||||
|
||||
//! Provides a bus to notify when the different editor modes are entered/exit.
|
||||
class ViewportEditorModeNotifications
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// EBusTraits overrides
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
using BusIdType = ViewportEditorModeInfo::IdType;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! Notifies subscribers of the a given viewport to the activation of the specified editor mode.
|
||||
virtual void OnEditorModeActivated([[maybe_unused]] const ViewportEditorModesInterface& editorModeState, [[maybe_unused]] ViewportEditorMode mode)
|
||||
{
|
||||
}
|
||||
|
||||
//! Notifies subscribers of the a given viewport to the deactivation of the specified editor mode.
|
||||
virtual void OnEditorModeDeactivated([[maybe_unused]] const ViewportEditorModesInterface& editorModeState, [[maybe_unused]] ViewportEditorMode mode)
|
||||
{
|
||||
}
|
||||
};
|
||||
using ViewportEditorModeNotificationsBus = AZ::EBus<ViewportEditorModeNotifications>;
|
||||
} // namespace AzToolsFramework
|
||||
Reference in New Issue
Block a user