Integrating latest 47acbe8

This commit is contained in:
alexpete
2021-03-25 13:57:57 -07:00
parent 448c549698
commit 75dc720198
10312 changed files with 2711566 additions and 671451 deletions
@@ -17,6 +17,33 @@
namespace GraphCanvas
{
// Each layer will consist of a series of slots reserved for various elements
// These are the number of slots to reserve for each element, and is tracked roughly
//
// Group offsets will occur after selection offsets. Higher number means it will be on top of the previous section.
// i.e. [GroupOffset2 = 4, GroupOffset1 = 3, SelectionOffset2 = 2, SelectionOffset1 = 1] for Layer 1.
// i.e. [GroupOffset2 = 8, GroupOffset1 = 7, SelectionOffset2 = 6, SelectionOffset1 = 5] for Layer 2.
//
// This will ensure that each layer still holds priority, but internal to the layer we can still shift things around to make it feel more natural.
//
// Selection is doubled since I don't have a signal for when the selection is cleared to avoid that. So to keep the same general 'feel', I've just doubled the amount of offsets, and let the deselect downgrade it as well.
constexpr int s_selectionOffets = 20;
constexpr int s_groupOffsets = 10;
///////////////
// LayerUtils
///////////////
int LayerUtils::AlwaysOnTopZValue()
{
return std::numeric_limits<int>::max() - 1;
}
int LayerUtils::AlwaysOnBottomZValue()
{
return std::numeric_limits<int>::min() + 1;
}
/////////////////////////////
// LayerControllerComponent
/////////////////////////////
@@ -33,8 +60,9 @@ namespace GraphCanvas
}
}
LayerControllerComponent::LayerControllerComponent(AZStd::string_view layeringElement)
LayerControllerComponent::LayerControllerComponent(AZStd::string_view layeringElement, LayerOffset layerOffset)
: m_baseLayering(layeringElement)
, m_layerOffset(layerOffset)
, m_baseModifier("")
, m_externalLayerModifier("")
{
@@ -65,6 +93,16 @@ namespace GraphCanvas
SceneNotificationBus::Handler::BusDisconnect();
LayerControllerRequestBus::Handler::BusDisconnect();
RootGraphicsItemNotificationBus::Handler::BusDisconnect();
AZ::SystemTickBus::Handler::BusDisconnect();
GroupableSceneMemberNotificationBus::MultiHandler::BusDisconnect();
}
void LayerControllerComponent::OnSystemTick()
{
UpdateZValue();
LayerControllerNotificationBus::Event(GetEntityId(), &LayerControllerNotifications::OnOffsetsChanged, m_layerOffset, m_groupLayerOffset);
AZ::SystemTickBus::Handler::BusDisconnect();
}
void LayerControllerComponent::OnSceneSet(const AZ::EntityId& sceneId)
@@ -78,30 +116,62 @@ namespace GraphCanvas
{
SceneNotificationBus::Handler::BusConnect(sceneId);
SceneRequestBus::EventResult(m_editorId, sceneId, &SceneRequests::GetEditorId);
ComputeCurrentLayer();
}
LayerControllerRequestBus::Handler::BusConnect(GetEntityId());
RootGraphicsItemNotificationBus::Handler::BusConnect(GetEntityId());
auto entityId = GetEntityId();
LayerControllerRequestBus::Handler::BusConnect(entityId);
RootGraphicsItemNotificationBus::Handler::BusConnect(entityId);
m_uiRequests = SceneMemberUIRequestBus::FindFirstHandler(entityId);
m_groupableRequests = GroupableSceneMemberRequestBus::FindFirstHandler(entityId);
GroupableSceneMemberNotificationBus::MultiHandler::BusConnect(entityId);
ComputeCurrentLayer();
}
void LayerControllerComponent::OnStylesChanged()
{
int zValue = 0;
StyleManagerRequestBus::EventResult(zValue, m_editorId, &StyleManagerRequests::FindLayerZValue, m_currentStyle);
SceneMemberUIRequestBus::Event(GetEntityId(), &SceneMemberUIRequests::SetZValue, zValue);
StyleManagerRequestBus::EventResult(m_layer, m_editorId, &StyleManagerRequests::FindLayer, m_currentStyle);
AZ::SystemTickBus::Handler::BusConnect();
}
void LayerControllerComponent::OnSelectionChanged()
{
if (m_isInspected)
{
SetSelectionLayerOffset(s_selectionOffets - 1);
}
else if (m_selectionOffset > 0)
{
SetSelectionLayerOffset(m_selectionOffset - 1);
}
}
void LayerControllerComponent::OnDisplayStateChanged([[maybe_unused]] RootGraphicsItemDisplayState oldState, RootGraphicsItemDisplayState newState)
void LayerControllerComponent::OnDisplayStateChanged(RootGraphicsItemDisplayState /*oldState*/, RootGraphicsItemDisplayState newState)
{
// Handle selection information
if (newState == Inspection)
{
m_isInspected = true;
}
else
{
m_isInspected = false;
}
if (newState == Deletion
|| newState == InspectionTransparent
|| newState == Inspection)
{
m_baseModifier = "interactive";
}
else if (newState == RootGraphicsItemDisplayState::GroupHighlight)
{
m_baseModifier = "groupHighlight";
}
else
{
m_baseModifier = "";
@@ -110,7 +180,7 @@ namespace GraphCanvas
ComputeCurrentLayer();
}
void LayerControllerComponent::OnStateChanged([[maybe_unused]] const AZStd::string& state)
void LayerControllerComponent::OnStateChanged(const AZStd::string& /*state*/)
{
ComputeCurrentLayer();
}
@@ -120,27 +190,110 @@ namespace GraphCanvas
return &m_externalLayerModifier;
}
void LayerControllerComponent::OnGroupChanged()
{
GroupableSceneMemberNotificationBus::MultiHandler::BusDisconnect();
GroupableSceneMemberNotificationBus::MultiHandler::BusConnect(GetEntityId());
if (m_groupableRequests)
{
int groupLayerOffset = 0;
AZ::EntityId groupId = m_groupableRequests->GetGroupId();
while (groupId.IsValid())
{
groupLayerOffset += 1;
GroupableSceneMemberNotificationBus::MultiHandler::BusConnect(groupId);
AZ::EntityId newGroupId;
GroupableSceneMemberRequestBus::EventResult(newGroupId, groupId, &GroupableSceneMemberRequests::GetGroupId);
if (newGroupId == groupId)
{
break;
}
groupId = newGroupId;
}
SetGroupLayerOffset(groupLayerOffset);
}
}
int LayerControllerComponent::GetLayerOffset() const
{
// Triple indexed array logic
return m_layerOffset + (m_selectionOffset * OffsetCount) + (m_groupLayerOffset * s_selectionOffets * OffsetCount);
}
int LayerControllerComponent::GetSelectionOffset() const
{
return m_selectionOffset;
}
int LayerControllerComponent::GetGroupLayerOffset() const
{
return m_groupLayerOffset;
}
void LayerControllerComponent::SetBaseModifier(AZStd::string_view baseModifier)
{
m_baseModifier = baseModifier;
}
void LayerControllerComponent::SetGroupLayerOffset(int groupOffset)
{
m_groupLayerOffset = groupOffset;
if (m_groupLayerOffset > s_groupOffsets)
{
m_groupLayerOffset = s_groupOffsets;
}
AZ::SystemTickBus::Handler::BusConnect();
}
void LayerControllerComponent::SetSelectionLayerOffset(int selectionOffset)
{
m_selectionOffset = selectionOffset;
if (m_selectionOffset > s_selectionOffets)
{
m_selectionOffset = s_selectionOffets;
}
AZ::SystemTickBus::Handler::BusConnect();
}
int LayerControllerComponent::CalculateZValue(int layer)
{
// Z value is a triple indexed array more or less.
// OffsetCount handles the individual layers which are per election offset.
// Each seleciton offset is managed per group offset.
return layer * (OffsetCount + s_selectionOffets * OffsetCount + s_groupOffsets * s_selectionOffets * OffsetCount) + GetLayerOffset();
}
void LayerControllerComponent::UpdateZValue()
{
m_uiRequests->SetZValue(CalculateZValue(m_layer));
}
void LayerControllerComponent::ComputeCurrentLayer()
{
if (m_externalLayerModifier.GetState().empty()
&& m_baseModifier.empty())
{
m_currentStyle = m_baseLayering;
m_currentStyle = "default";
}
else if (!m_externalLayerModifier.GetState().empty())
else if (m_externalLayerModifier.HasState())
{
m_currentStyle = AZStd::string::format("%s_%s", m_baseLayering.c_str(), m_externalLayerModifier.GetState().c_str());
m_currentStyle = m_externalLayerModifier.GetState().c_str();
}
else
{
m_currentStyle = AZStd::string::format("%s_%s", m_baseLayering.c_str(), m_baseModifier.c_str());
m_currentStyle = m_baseModifier.c_str();
}
OnStylesChanged();
}
}
}