Exemplo n.º 1
0
FKeyAreaLayout::FKeyAreaLayout(FSequencerDisplayNode& InNode, int32 InSectionIndex)
{
	TotalHeight = 0.f;

	float LastPadding = 0.f;

	auto SetupKeyArea = [&](FSequencerDisplayNode& Node){

		if (Node.GetType() == ESequencerNode::KeyArea)
		{
			Elements.Add(FKeyAreaLayoutElement::FromKeyAreaNode(StaticCastSharedRef<FSectionKeyAreaNode>(Node.AsShared()), InSectionIndex, TotalHeight));
		}
		else if (!Node.IsExpanded())
		{
			Elements.Add(FKeyAreaLayoutElement::FromGroup(Node.UpdateKeyGrouping(InSectionIndex), TotalHeight, Node.GetNodeHeight()));
		}

	};


	// First, layout the parent
	{
		FSequencerDisplayNode* LayoutNode = &InNode;
		if (InNode.GetType() == ESequencerNode::Track)
		{
			TSharedPtr<FSequencerDisplayNode> KeyAreaNode = static_cast<FTrackNode&>(InNode).GetTopLevelKeyNode();
			if (KeyAreaNode.IsValid())
			{
				LayoutNode = KeyAreaNode.Get();
			}
		}

		SetupKeyArea(*LayoutNode);

		LastPadding = LayoutNode->GetNodePadding().Bottom;
		TotalHeight += LayoutNode->GetNodeHeight() + LastPadding;
	}

	// Then any children
	InNode.TraverseVisible_ParentFirst([&](FSequencerDisplayNode& Node){
		
		TotalHeight += Node.GetNodePadding().Top;

		SetupKeyArea(Node);

		LastPadding = Node.GetNodePadding().Bottom;
		TotalHeight += Node.GetNodeHeight() + LastPadding;
		return true;

	}, false);

	// Remove the padding from the bottom
	TotalHeight -= LastPadding;
}
FSectionLayout::FSectionLayout(FSequencerDisplayNode& InNode, int32 InSectionIndex)
{
	float VerticalOffset = 0.f;

	auto SetupKeyArea = [&](FSequencerDisplayNode& Node){

		if (Node.GetType() == ESequencerNode::KeyArea)
		{
			Elements.Add(FSectionLayoutElement::FromKeyAreaNode(
				StaticCastSharedRef<FSequencerSectionKeyAreaNode>(Node.AsShared()),
				InSectionIndex,
				VerticalOffset
			));
		}
		else if (Node.GetType() == ESequencerNode::Track && static_cast<FSequencerTrackNode&>(Node).GetTopLevelKeyNode().IsValid())
		{
			Elements.Add(FSectionLayoutElement::FromTrack(
				StaticCastSharedRef<FSequencerTrackNode>(Node.AsShared()),
				InSectionIndex,
				VerticalOffset
			));
		}
		else if (!Node.IsExpanded())
		{
			Elements.Add(FSectionLayoutElement::FromGroup(
				Node.AsShared(),
				Node.UpdateKeyGrouping(InSectionIndex),
				VerticalOffset
			));
		}
		else
		{
			// It's benign space
			Elements.Add(FSectionLayoutElement::EmptySpace(
				Node.AsShared(),
				VerticalOffset
			));
		}

	};

	// First, layout the parent
	{
		VerticalOffset += InNode.GetNodePadding().Top;

		SetupKeyArea(InNode);

		VerticalOffset += InNode.GetNodeHeight() + InNode.GetNodePadding().Bottom;
	}

	// Then any children
	InNode.TraverseVisible_ParentFirst([&](FSequencerDisplayNode& Node){
		
		VerticalOffset += Node.GetNodePadding().Top;

		SetupKeyArea(Node);

		VerticalOffset += Node.GetNodeHeight() + Node.GetNodePadding().Bottom;
		return true;

	}, false);
}