本文整理汇总了C++中FGeometry类的典型用法代码示例。如果您正苦于以下问题:C++ FGeometry类的具体用法?C++ FGeometry怎么用?C++ FGeometry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FGeometry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnMouseButtonUp
/**
* See SWidget::OnMouseButtonUp.
*
* @param MyGeometry The Geometry of the widget receiving the event
* @param MouseEvent Information about the input event
*
* @return Whether the event was handled along with possible requests for the system to take action.
*/
FReply SCheckBox::OnMouseButtonUp( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent )
{
if ( MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton )
{
bIsPressed = false;
if( ClickMethod == EButtonClickMethod::MouseDown )
{
// NOTE: If we're configured to click on mouse-down, then we never capture the mouse thus
// may never receive an OnMouseButtonUp() call. We make sure that our bIsPressed
// state is reset by overriding OnMouseLeave().
}
else
{
const bool IsUnderMouse = MyGeometry.IsUnderLocation( MouseEvent.GetScreenSpacePosition() );
if ( IsUnderMouse )
{
// If we were asked to allow the button to be clicked on mouse up, regardless of whether the user
// pressed the button down first, then we'll allow the click to proceed without an active capture
if( ClickMethod == EButtonClickMethod::MouseUp || HasMouseCapture() )
{
ToggleCheckedState();
const TAttribute<ESlateCheckBoxState::Type>& State = IsCheckboxChecked.Get();
if(State == ESlateCheckBoxState::Checked)
{
PlayCheckedSound();
}
else if(State == ESlateCheckBoxState::Unchecked)
{
PlayUncheckedSound();
}
}
}
}
return FReply::Handled().ReleaseMouseCapture();
}
return FReply::Unhandled();
}
示例2: OnMouseButtonUp
FReply FVisualLoggerTimeSliderController::OnMouseButtonUp( TSharedRef<SWidget> WidgetOwner, const FGeometry& MyGeometry, const FPointerEvent& MouseEvent )
{
bool bHandleLeftMouseButton = MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton && WidgetOwner->HasMouseCapture();
bool bHandleRightMouseButton = MouseEvent.GetEffectingButton() == EKeys::RightMouseButton && WidgetOwner->HasMouseCapture() && TimeSliderArgs.AllowZoom ;
if ( bHandleRightMouseButton )
{
if (!bPanning)
{
// return unhandled in case our parent wants to use our right mouse button to open a context menu
return FReply::Unhandled().ReleaseMouseCapture();
}
bPanning = false;
FReply::Handled().CaptureMouse(WidgetOwner).UseHighPrecisionMouseMovement(WidgetOwner);
return FReply::Handled().ReleaseMouseCapture();
}
else if ( bHandleLeftMouseButton )
{
if( bDraggingScrubber )
{
TimeSliderArgs.OnEndScrubberMovement.ExecuteIfBound();
}
else
{
FScrubRangeToScreen RangeToScreen( TimeSliderArgs.ViewRange.Get(), MyGeometry.Size );
FVector2D CursorPos = MyGeometry.AbsoluteToLocal(MouseEvent.GetLastScreenSpacePosition());
float NewValue = RangeToScreen.LocalXToInput(CursorPos.X);
CommitScrubPosition( NewValue, /*bIsScrubbing=*/false );
}
bDraggingScrubber = false;
return FReply::Handled().ReleaseMouseCapture();
}
return FReply::Unhandled();
}
示例3: OnCursorQuery
/**
* The system asks each widget under the mouse to provide a cursor. This event is bubbled.
*
* @return FCursorReply::Unhandled() if the event is not handled; return FCursorReply::Cursor() otherwise.
*/
FCursorReply SSplitter::OnCursorQuery( const FGeometry& MyGeometry, const FPointerEvent& CursorEvent ) const
{
const FVector2D LocalMousePosition = MyGeometry.AbsoluteToLocal( CursorEvent.GetScreenSpacePosition() );
TArray<FLayoutGeometry> LayoutChildren = ArrangeChildrenForLayout(MyGeometry);
// Hit test which handle we are hovering over.
const int32 CurrentHoveredHandleIndex = (Orientation == Orient_Horizontal)
? GetHandleBeingResizedFromMousePosition<Orient_Horizontal>( PhysicalSplitterHandleSize, HitDetectionSplitterHandleSize, LocalMousePosition, LayoutChildren )
: GetHandleBeingResizedFromMousePosition<Orient_Vertical>( PhysicalSplitterHandleSize, HitDetectionSplitterHandleSize, LocalMousePosition, LayoutChildren );
if (CurrentHoveredHandleIndex != INDEX_NONE)
{
return ( Orientation == Orient_Horizontal )
? FCursorReply::Cursor( EMouseCursor::ResizeLeftRight )
: FCursorReply::Cursor( EMouseCursor::ResizeUpDown );
}
else
{
return FCursorReply::Unhandled();
}
}
示例4: GetNodeDragDropDataPos
float STrack::GetNodeDragDropDataPos( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
{
float DataPos = 0.f;
TSharedPtr<FTrackNodeDragDropOp> DragDropOp = StaticCastSharedPtr<FTrackNodeDragDropOp>(DragDropEvent.GetOperation());
if(DragDropOp.IsValid())
{
TSharedPtr<STrackNode> TrackNode = DragDropOp->OriginalTrackNode.Pin();
if(TrackNode.IsValid())
{
FVector2D CursorPos = MyGeometry.AbsoluteToLocal(TrackNode->GetDragDropScreenSpacePosition(MyGeometry, DragDropEvent));
DataPos = LocalToDataX(CursorPos.X, MyGeometry);
if(TrackNode->SnapToDragBars())
{
float OriginalX = DataPos;
DataPos = GetSnappedPosForLocalPos(MyGeometry, CursorPos.X);
TrackNode->OnSnapNodeDataPosition(OriginalX, DataPos);
}
}
}
return DataPos;
}
示例5: OnArrangeChildren
void SGraphPanel::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const
{
SNodePanel::OnArrangeChildren(AllottedGeometry, ArrangedChildren);
FArrangedChildren MyArrangedChildren(ArrangedChildren.GetFilter());
for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex)
{
FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex];
TSharedRef<SGraphNode> ChildNode = StaticCastSharedRef<SGraphNode>(CurWidget.Widget);
TArray<FOverlayWidgetInfo> OverlayWidgets = ChildNode->GetOverlayWidgets(false, CurWidget.Geometry.Size);
for (int32 WidgetIndex = 0; WidgetIndex < OverlayWidgets.Num(); ++WidgetIndex)
{
FOverlayWidgetInfo& OverlayInfo = OverlayWidgets[WidgetIndex];
MyArrangedChildren.AddWidget(AllottedGeometry.MakeChild( OverlayInfo.Widget.ToSharedRef(), CurWidget.Geometry.Position + OverlayInfo.OverlayOffset, OverlayInfo.Widget->GetDesiredSize(), GetZoomAmount() ));
}
}
ArrangedChildren.Append(MyArrangedChildren);
}
示例6: OnPaint
int32 FSlateImageRun::OnPaint( const FPaintArgs& Args, const FTextLayout::FLineView& Line, const TSharedRef< ILayoutBlock >& Block, const FTextBlockStyle& DefaultStyle, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const
{
// The block size and offset values are pre-scaled, so we need to account for that when converting the block offsets into paint geometry
const float InverseScale = Inverse(AllottedGeometry.Scale);
if ( Image->DrawAs != ESlateBrushDrawType::NoDrawType )
{
const FColor FinalColorAndOpacity( InWidgetStyle.GetColorAndOpacityTint() * Image->GetTint( InWidgetStyle ) );
const uint32 DrawEffects = bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect;
FSlateDrawElement::MakeBox(
OutDrawElements,
++LayerId,
AllottedGeometry.ToPaintGeometry(TransformVector(InverseScale, Block->GetSize()), FSlateLayoutTransform(TransformPoint(InverseScale, Block->GetLocationOffset()))),
Image,
MyClippingRect,
DrawEffects,
FinalColorAndOpacity
);
}
return LayerId;
}
示例7: FVector2D
void SSection::CheckForEdgeInteraction( const FPointerEvent& MouseEvent, const FGeometry& SectionGeometry )
{
bLeftEdgeHovered = false;
bRightEdgeHovered = false;
bLeftEdgePressed = false;
bRightEdgePressed = false;
if (!SectionInterface->SectionIsResizable())
{
return;
}
// Make areas to the left and right of the geometry. We will use these areas to determine if someone dragged the left or right edge of a section
FGeometry SectionRectLeft = SectionGeometry.MakeChild(
FVector2D::ZeroVector,
FVector2D( SequencerSectionConstants::SectionGripSize, SectionGeometry.Size.Y )
);
FGeometry SectionRectRight = SectionGeometry.MakeChild(
FVector2D( SectionGeometry.Size.X - SequencerSectionConstants::SectionGripSize, 0 ),
SectionGeometry.Size
);
if( SectionRectLeft.IsUnderLocation( MouseEvent.GetScreenSpacePosition() ) )
{
if( MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton )
{
bLeftEdgePressed = true;
}
else
{
bLeftEdgeHovered = true;
}
}
else if( SectionRectRight.IsUnderLocation( MouseEvent.GetScreenSpacePosition() ) )
{
if( MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton )
{
bRightEdgePressed = true;
}
else
{
bRightEdgeHovered = true;
}
}
}
示例8: Tick
virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override
{
if (!SlideCurve.IsPlaying())
{
StartSlideOffset = 0;
}
// Delete any widgets that are now offscreen
if (Children.Num() != 0)
{
const float Alpha = 1.f - SlideCurve.GetLerp();
float PositionSoFar = AllottedGeometry.GetLocalSize().Y + Alpha * StartSlideOffset;
for (int32 Index = 0; PositionSoFar > 0 && Index < NumSlots(); ++Index)
{
const SBoxPanel::FSlot& CurChild = Children[Index];
const EVisibility ChildVisibility = CurChild.GetWidget()->GetVisibility();
if (ChildVisibility != EVisibility::Collapsed)
{
const FVector2D ChildDesiredSize = CurChild.GetWidget()->GetDesiredSize();
PositionSoFar -= ChildDesiredSize.Y + CurChild.SlotPadding.Get().GetTotalSpaceAlong<Orient_Vertical>();
}
}
for (int32 Index = MaxNumVisible; Index < Children.Num(); )
{
if (StaticCastSharedRef<SWidgetStackItem>(Children[Index].GetWidget())->bIsFinished)
{
Children.RemoveAt(Index);
}
else
{
++Index;
}
}
}
}
示例9: OnMouseMove
FReply FScrollyZoomy::OnMouseMove( const TSharedRef<SWidget> MyWidget, IScrollableZoomable& ScrollableZoomable, const FGeometry& MyGeometry, const FPointerEvent& MouseEvent )
{
if (MouseEvent.IsMouseButtonDown(EKeys::RightMouseButton))
{
// If scrolling with the right mouse button, we need to remember how much we scrolled.
// If we did not scroll at all, we will bring up the context menu when the mouse is released.
AmountScrolledWhileRightMouseDown += FMath::Abs( MouseEvent.GetCursorDelta().X ) + FMath::Abs( MouseEvent.GetCursorDelta().Y );
// Has the mouse moved far enough with the right mouse button held down to start capturing
// the mouse and dragging the view?
if (IsRightClickScrolling())
{
this->HorizontalIntertia.AddScrollSample( MouseEvent.GetCursorDelta().X, FPlatformTime::Seconds() );
this->VerticalIntertia.AddScrollSample( MouseEvent.GetCursorDelta().Y, FPlatformTime::Seconds() );
const bool DidScroll = ScrollableZoomable.ScrollBy( MouseEvent.GetCursorDelta() );
FReply Reply = FReply::Handled();
// Capture the mouse if we need to
if (MyWidget->HasMouseCapture() == false)
{
Reply.CaptureMouse( MyWidget ).UseHighPrecisionMouseMovement( MyWidget );
SoftwareCursorPosition = MyGeometry.AbsoluteToLocal( MouseEvent.GetScreenSpacePosition() );
bShowSoftwareCursor = true;
}
// Check if the mouse has moved.
if (DidScroll)
{
SoftwareCursorPosition += MouseEvent.GetCursorDelta();
}
return Reply;
}
}
return FReply::Unhandled();
}
示例10: LayoutDebugPaint
int32 SGridPanel::LayoutDebugPaint(const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId ) const
{
float XOffset = 0;
for (int32 Column=0; Column<Columns.Num(); ++Column)
{
float YOffset = 0;
for (int32 Row=0; Row<Rows.Num(); ++Row)
{
FSlateDrawElement::MakeDebugQuad
(
OutDrawElements,
LayerId,
AllottedGeometry.ToPaintGeometry( FVector2D(XOffset, YOffset), FVector2D( Columns[Column], Rows[Row] ) ),
MyClippingRect
);
YOffset += Rows[Row];
}
XOffset += Columns[Column];
}
return LayerId;
}
示例11: OnPaint
int32 SBox::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const
{
// An SBox just draws its only child
FArrangedChildren ArrangedChildren(EVisibility::Visible);
{
#if SLATE_HD_STATS
SCOPE_CYCLE_COUNTER( STAT_SlateOnPaint_SBox );
#endif
this->ArrangeChildren(AllottedGeometry, ArrangedChildren);
}
// Maybe none of our children are visible
if( ArrangedChildren.Num() > 0 )
{
check( ArrangedChildren.Num() == 1 );
FArrangedWidget& TheChild = ArrangedChildren[0];
const FSlateRect ChildClippingRect = AllottedGeometry.GetClippingRect().InsetBy( ChildSlot.SlotPadding.Get() * AllottedGeometry.Scale ).IntersectionWith(MyClippingRect);
return TheChild.Widget->Paint( Args.WithNewParent(this), TheChild.Geometry, ChildClippingRect, OutDrawElements, LayerId, InWidgetStyle, ShouldBeEnabled( bParentEnabled ) );
}
return LayerId;
}
示例12: OnTouchEnded
FReply FSceneViewport::OnTouchEnded( const FGeometry& MyGeometry, const FPointerEvent& TouchEvent )
{
// Start a new reply state
CurrentReplyState = FReply::Handled();
UpdateCachedMousePos(MyGeometry, TouchEvent);
UpdateCachedGeometry(MyGeometry);
if( ViewportClient )
{
// Switch to the viewport clients world before processing input
FScopedConditionalWorldSwitcher WorldSwitcher( ViewportClient );
const FVector2D TouchPosition = MyGeometry.AbsoluteToLocal(TouchEvent.GetLastScreenSpacePosition());
if( !ViewportClient->InputTouch( this, TouchEvent.GetUserIndex(), TouchEvent.GetPointerIndex(), ETouchType::Ended, TouchPosition, FDateTime::Now(), TouchEvent.GetTouchpadIndex()) )
{
CurrentReplyState = FReply::Unhandled();
}
}
return CurrentReplyState;
}
示例13: OnMouseButtonDown
FReply FSequencerTimeSliderController::OnMouseButtonDown( SWidget& WidgetOwner, const FGeometry& MyGeometry, const FPointerEvent& MouseEvent )
{
bool bHandleLeftMouseButton = MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton;
bool bHandleRightMouseButton = MouseEvent.GetEffectingButton() == EKeys::RightMouseButton && TimeSliderArgs.AllowZoom;
DistanceDragged = 0;
FScrubRangeToScreen RangeToScreen( TimeSliderArgs.ViewRange.Get(), MyGeometry.Size );
MouseDownRange[0] = RangeToScreen.LocalXToInput(MyGeometry.AbsoluteToLocal(MouseEvent.GetLastScreenSpacePosition()).X);
MouseDownRange[1] = MouseDownRange[0];
if ( bHandleLeftMouseButton )
{
return FReply::Handled().CaptureMouse( WidgetOwner.AsShared() ).PreventThrottling();
}
else if ( bHandleRightMouseButton )
{
// Always capture mouse if we left or right click on the widget
return FReply::Handled().CaptureMouse( WidgetOwner.AsShared() );
}
return FReply::Unhandled();
}
示例14: OnMouseButtonDown
FReply SFlareKeyBind::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
if (bWaitingForKey)
{
SetKey(MouseEvent.GetEffectingButton());
return FReply::Handled();
}
else if (MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton)
{
// Get the center of the widget so we can lock our mouse there
FSlateRect Rect = MyGeometry.GetClippingRect();
WaitingMousePos.X = (Rect.Left + Rect.Right) * 0.5f;
WaitingMousePos.Y = (Rect.Top + Rect.Bottom) * 0.5f;
FSlateApplication::Get().GetPlatformApplication().Get()->Cursor->SetPosition(WaitingMousePos.X, WaitingMousePos.Y);
KeyText->SetText(LOCTEXT("SFlareKeyBindPressAnyKey", "Press a key..."));
bWaitingForKey = true;
FSlateApplication::Get().GetPlatformApplication().Get()->Cursor->Show(false);
return FReply::Handled();
}
return FReply::Unhandled();
}
示例15: ComputeEdgePanAmount
FVector2D SPaperEditorViewport::ComputeEdgePanAmount(const FGeometry& MyGeometry, const FVector2D& TargetPosition)
{
// How quickly to ramp up the pan speed as the user moves the mouse further past the edge of the graph panel.
static const float EdgePanSpeedCoefficient = 0.1f;
// Never pan slower than this, it's just unpleasant.
static const float MinPanSpeed = 5.0f;
// Start panning before we reach the edge of the graph panel.
static const float EdgePanForgivenessZone = 30.0f;
const FVector2D LocalCursorPos = MyGeometry.AbsoluteToLocal( TargetPosition );
// If the mouse is outside of the graph area, then we want to pan in that direction.
// The farther out the mouse is, the more we want to pan.
FVector2D EdgePanThisTick(0,0);
if ( LocalCursorPos.X <= EdgePanForgivenessZone )
{
EdgePanThisTick.X += FMath::Min( -MinPanSpeed, EdgePanSpeedCoefficient * (EdgePanForgivenessZone - LocalCursorPos.X) );
}
else if( LocalCursorPos.X >= MyGeometry.Size.X - EdgePanForgivenessZone )
{
EdgePanThisTick.X = FMath::Max( MinPanSpeed, EdgePanSpeedCoefficient * (MyGeometry.Size.X - EdgePanForgivenessZone - LocalCursorPos.X) );
}
if ( LocalCursorPos.Y <= EdgePanForgivenessZone )
{
EdgePanThisTick.Y += FMath::Min( -MinPanSpeed, EdgePanSpeedCoefficient * (EdgePanForgivenessZone - LocalCursorPos.Y) );
}
else if( LocalCursorPos.Y >= MyGeometry.Size.Y - EdgePanForgivenessZone )
{
EdgePanThisTick.Y = FMath::Max( MinPanSpeed, EdgePanSpeedCoefficient * (MyGeometry.Size.Y - EdgePanForgivenessZone - LocalCursorPos.Y) );
}
return EdgePanThisTick;
}