int32 SSplitter::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const { FArrangedChildren ArrangedChildren( EVisibility::Visible ); ArrangeChildren( AllottedGeometry, ArrangedChildren ); int32 MaxLayerId = PaintArrangedChildren( Args, ArrangedChildren, MyClippingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled ); const FSlateBrush* NormalHandleBrush = &Style->HandleNormalBrush; // Draw the splitter above any children MaxLayerId += 1; for( int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex ) { const FGeometry& GeometryAfterSplitter = ArrangedChildren[ FMath::Clamp(ChildIndex + 1, 0, ArrangedChildren.Num()-1) ].Geometry; const float HalfHitDetectionSplitterHandleSize = ( HitDetectionSplitterHandleSize / 2 ); const float HalfPhysicalSplitterHandleSize = ( PhysicalSplitterHandleSize / 2 ); FVector2D HandleSize; FVector2D HandlePosition; if ( Orientation == Orient_Horizontal ) { HandleSize.Set( PhysicalSplitterHandleSize, GeometryAfterSplitter.Size.Y ); HandlePosition.Set( -(HalfHitDetectionSplitterHandleSize + HalfPhysicalSplitterHandleSize), 0 ); } else { HandleSize.Set( GeometryAfterSplitter.Size.X, PhysicalSplitterHandleSize ); HandlePosition.Set( 0, -(HalfHitDetectionSplitterHandleSize + HalfPhysicalSplitterHandleSize) ); } if (HoveredHandleIndex != ChildIndex) { FSlateDrawElement::MakeBox( OutDrawElements, MaxLayerId, GeometryAfterSplitter.ToPaintGeometry( HandlePosition, HandleSize, 1.0f ), NormalHandleBrush, MyClippingRect, ShouldBeEnabled( bParentEnabled ), InWidgetStyle.GetColorAndOpacityTint() * NormalHandleBrush->TintColor.GetSpecifiedColor() ); } else { FSlateDrawElement::MakeBox( OutDrawElements, MaxLayerId, GeometryAfterSplitter.ToPaintGeometry( HandlePosition, HandleSize, 1.0f ), &Style->HandleHighlightBrush, MyClippingRect, ShouldBeEnabled( bParentEnabled ), InWidgetStyle.GetColorAndOpacityTint() * Style->HandleHighlightBrush.TintColor.GetSpecifiedColor() ); } } return MaxLayerId; }
/** SWidget Interface */ int32 SSequencerSectionAreaView::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const { FArrangedChildren ArrangedChildren(EVisibility::Visible); ArrangeChildren(AllottedGeometry, ArrangedChildren); if( SectionAreaNode.IsValid() ) { // Draw a region around the entire section area FSlateDrawElement::MakeBox( OutDrawElements, LayerId, AllottedGeometry.ToPaintGeometry(), BackgroundBrush, MyClippingRect, ESlateDrawEffect::None, SequencerSectionAreaConstants::BackgroundColor ); } for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex) { FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex]; FSlateRect ChildClipRect = MyClippingRect.IntersectionWith( CurWidget.Geometry.GetClippingRect() ); const int32 CurWidgetsMaxLayerId = CurWidget.Widget->Paint( Args.WithNewParent(this), CurWidget.Geometry, ChildClipRect, OutDrawElements, LayerId+1, InWidgetStyle, ShouldBeEnabled( bParentEnabled ) ); } return LayerId+1; }
void MFCChannelView::RemoveOutputRepresentation(Output *d) { MFCOutputView *dv = (MFCOutputView *)OutputRepresentationFor(d); RemoveOutR(dv); dv->DestroyWindow(); ArrangeChildren(); }
void MixerView::AddChannel(Channel *c) { if (Window()) Window()->Lock(); channelSelector->AddChannel(c); ArrangeChildren(); if (Window()) Window()->Unlock(); }
int32 SClippingHorizontalBox::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const { // Get the clipped children info FArrangedChildren ClippedArrangedChildren(EVisibility::Visible); ArrangeChildren(AllottedGeometry, ClippedArrangedChildren); // Get the non-clipped children info // @todo umg: One should not call the virtual OnArrangeChildren, one should only call ArrangeChildren. FArrangedChildren ArrangedChildren(EVisibility::Visible); SBoxPanel::OnArrangeChildren(AllottedGeometry, ArrangedChildren); if ((ClippedArrangedChildren.Num() != 0) && (ArrangedChildren.Num() != 0)) { int32 IndexClippedAt = ClippedArrangedChildren.Num() - 1; const FArrangedWidget& LastCippedChild = ClippedArrangedChildren[IndexClippedAt]; const FArrangedWidget& FirstChild = ArrangedChildren[0]; const FArrangedWidget& LastChild = ArrangedChildren[ArrangedChildren.Num() - 1]; float BorderLocalWidth = AllottedGeometry.Size.X; // If only the last child/block, which is the wrap button, is being clipped if (IndexClippedAt == ArrangedChildren.Num() - 2) { // Only recalculate the alloted geometry size if said size is fitted to the toolbar/menubar if (FMath::TruncToInt(AllottedGeometry.AbsolutePosition.X + AllottedGeometry.Size.X * AllottedGeometry.Scale) <= FMath::TruncToInt(LastChild.Geometry.AbsolutePosition.X + LastChild.Geometry.Size.X * LastChild.Geometry.Scale)) { // Calculate the size of the custom border BorderLocalWidth = (LastCippedChild.Geometry.AbsolutePosition.X + LastCippedChild.Geometry.Size.X * LastCippedChild.Geometry.Scale - FirstChild.Geometry.AbsolutePosition.X) / AllottedGeometry.Scale; } } else { // Children/blocks are being clipped, calculate the size of the custom border const FArrangedWidget& NextChild = (IndexClippedAt + 1 < ClippedArrangedChildren.Num())? ClippedArrangedChildren[IndexClippedAt + 1]: LastCippedChild; BorderLocalWidth = (NextChild.Geometry.AbsolutePosition.X + NextChild.Geometry.Size.X * NextChild.Geometry.Scale - FirstChild.Geometry.AbsolutePosition.X) / AllottedGeometry.Scale; } bool bEnabled = ShouldBeEnabled( bParentEnabled ); ESlateDrawEffect::Type DrawEffects = !bEnabled ? ESlateDrawEffect::DisabledEffect : ESlateDrawEffect::None; FSlateColor BorderBackgroundColor = FLinearColor::White; // Draw the custom border FSlateDrawElement::MakeBox( OutDrawElements, LayerId, AllottedGeometry.ToPaintGeometry(FVector2D(BorderLocalWidth, AllottedGeometry.Size.Y), FSlateLayoutTransform()), BackgroundBrush, MyClippingRect, DrawEffects, BackgroundBrush->GetTint( InWidgetStyle ) * InWidgetStyle.GetColorAndOpacityTint() * BorderBackgroundColor.GetColor(InWidgetStyle) ); } return SHorizontalBox::OnPaint(Args, AllottedGeometry, MyClippingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled); }
void MFCChannelView::AddOutputRepresentation(Output *d) { MFCOutputView *dv = new MFCOutputView; dv->Create(_T("STATIC"), "Output", WS_CHILD | WS_VISIBLE, CRect(0, 0, INI_DESTINATION_WIDTH, INI_DESTINATION_HEIGHT), this, 1234, NULL); dv->SetOutput(d); AddOutR(dv); ArrangeChildren(); }
void MixerView::DeleteSchedulablePanel(Panel *P) { if (Window()) Window()->Lock(); BRect bnd = P->Frame(); float toGo = P->myHeight + 1; fprintf(stderr, "delete sc %g\n", toGo); if (back->RemoveChild(P)) { ArrangeChildren(); } if (Window()) Window()->Unlock(); }
int32 SMenuAnchor::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const { FArrangedChildren ArrangedChildren( EVisibility::Visible ); ArrangeChildren( AllottedGeometry, ArrangedChildren ); // There may be zero elements in this array if our child collapsed/hidden if ( ArrangedChildren.Num() > 0 ) { const FArrangedWidget& FirstChild = ArrangedChildren[0]; // In the case where the user doesn't provide content to the menu anchor, the null widget // wont appear in the visible set of arranged children, so only immediately paint the first child, // if it's visible and matches the first slot content. const bool bHasArrangedAnchorContent = FirstChild.Widget == Children[0].GetWidget(); if ( bHasArrangedAnchorContent ) { const FSlateRect ChildClippingRect = AllottedGeometry.GetClippingRect().IntersectionWith(MyClippingRect); LayerId = FirstChild.Widget->Paint(Args.WithNewParent(this), FirstChild.Geometry, ChildClippingRect, OutDrawElements, LayerId + 1, InWidgetStyle, ShouldBeEnabled(bParentEnabled)); } const bool bIsOpen = IsOpen(); if ( bIsOpen ) { // In the case where the anchor content is present and visible, it's the 1 index child, in the case // where the anchor content is invisible, it's the 0 index child. FArrangedWidget* PopupChild = nullptr; if ( bHasArrangedAnchorContent && ArrangedChildren.Num() > 1 ) { PopupChild = &ArrangedChildren[1]; } else if ( !bHasArrangedAnchorContent && ArrangedChildren.Num() == 1 ) { PopupChild = &ArrangedChildren[0]; } if ( PopupChild != nullptr ) { OutDrawElements.QueueDeferredPainting( FSlateWindowElementList::FDeferredPaint(PopupChild->Widget, Args, PopupChild->Geometry, MyClippingRect, InWidgetStyle, bParentEnabled)); } } } return LayerId; }
BOOL CEntityOutputWnd::OnInitDialog() { CDialogEx::OnInitDialog(); CRect rect; GetClientRect(rect); m_lastSizeX = rect.Width(); m_lastSizeY = rect.Height(); m_list.InitStyle(); ArrangeChildren(); m_cbTarget.FillData(); ClearInputMask(); EnableInputMask(FALSE); m_bAdd.EnableWindow(FALSE); m_bPaste.EnableWindow(FALSE); m_list.EnableWindow(FALSE); return TRUE; // return TRUE unless you set the focus to a control }
int32 SSequencerTrackArea::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const { FArrangedChildren ArrangedChildren(EVisibility::Visible); ArrangeChildren(AllottedGeometry, ArrangedChildren); for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex) { FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex]; FSlateRect ChildClipRect = MyClippingRect.IntersectionWith( CurWidget.Geometry.GetClippingRect() ); const int32 ThisWidgetLayerId = CurWidget.Widget->Paint( Args.WithNewParent(this), CurWidget.Geometry, ChildClipRect, OutDrawElements, LayerId + 1, InWidgetStyle, ShouldBeEnabled( bParentEnabled ) ); LayerId = FMath::Max(LayerId, ThisWidgetLayerId); } auto SequencerPin = SequencerWidget.Pin(); if (SequencerPin.IsValid()) { return SequencerPin->GetEditTool().OnPaint(AllottedGeometry, MyClippingRect, OutDrawElements, LayerId + 1); } return LayerId; }
void MixerView::AddSchedulablePanel(Panel *p) { if (Window()) Window()->Lock(); BRect wrect = Bounds(); int len = wrect.bottom - wrect.top; int wid = wrect.right - wrect.left; wrect = p->Bounds(); // fprintf(stderr, "%g %g %g %g\n", // wrect.left, wrect.top, wrect.right, wrect.bottom); p->MoveTo(0, len); back->AddChild(p); ArrangeChildren(); // len += (wrect.bottom - wrect.top)+1; // wid = Max(wid, wrect.right - wrect.left + 2*MARGIN); // ResizeTo(wid,len); if (Window()) Window()->Unlock(); }
void SWidget::TickWidgetsRecursively( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime ) { INC_DWORD_STAT(STAT_SlateNumTickedWidgets); // Execute any pending active timers for this widget, followed by the passive tick ExecuteActiveTimers( InCurrentTime, InDeltaTime ); { SLATE_CYCLE_COUNTER_SCOPE_CUSTOM_DETAILED(SLATE_STATS_DETAIL_LEVEL_MED, GSlateWidgetTick, GetType()); Tick(AllottedGeometry, InCurrentTime, InDeltaTime); } // Gather all children, whether they're visible or not. We need to allow invisible widgets to // consider whether they should still be invisible in their tick functions, as well as maintain // other state when hidden, FArrangedChildren ArrangedChildren(TickInvisibleWidgets.GetValueOnGameThread() ? EVisibility::All : EVisibility::Visible); ArrangeChildren(AllottedGeometry, ArrangedChildren); // Recur! for(int32 ChildIndex=0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex) { FArrangedWidget& SomeChild = ArrangedChildren[ChildIndex]; SomeChild.Widget->TickWidgetsRecursively( SomeChild.Geometry, InCurrentTime, InDeltaTime ); } }
void HKWidgetListbox::Update() { if(!bDragging) { if(velocity != 0.f) { // apply scroll velocity velocity *= 1.f - MFSystem_GetTimeDelta()*10.f; if(velocity < 0.01f) velocity = 0.f; scrollOffset += velocity * MFSystem_GetTimeDelta(); } if(scrollOffset > 0.f) { scrollOffset = MFMax(scrollOffset - MFMax(scrollOffset * 10.f * MFSystem_GetTimeDelta(), 1.f), 0.f); } else { float listSize = orientation == Horizontal ? size.x - (padding.x + padding.z) : size.y - (padding.y + padding.w); float overflow = MFMin(listSize - (contentSize + scrollOffset), -scrollOffset); if(overflow > 0.f) { scrollOffset = MFMin(scrollOffset + MFMax(overflow * 10.f * MFSystem_GetTimeDelta(), 1.f), scrollOffset + overflow); } } } scrollOffset = MFFloor(scrollOffset); if(scrollOffset != prevScrollOffset) { prevScrollOffset = scrollOffset; ArrangeChildren(); } }
void CEntityOutputWnd::OnSize(UINT nType, int cx, int cy) { CDialogEx::OnSize(nType, cx, cy); ArrangeChildren(); }
/** SWidget interface */ virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const override { // First paint the background { LayerId = PaintBackground(AllottedGeometry, MyClippingRect, OutDrawElements, LayerId); LayerId++; } FArrangedChildren ArrangedChildren(EVisibility::Visible); ArrangeChildren(AllottedGeometry, ArrangedChildren); // Draw the child nodes // When drawing a marquee, need a preview of what the selection will be. const auto* SelectionToVisualize = &(SelectionManager.SelectedNodes); FGraphPanelSelectionSet SelectionPreview; if (Marquee.IsValid()) { ApplyMarqueeSelection(Marquee, SelectionManager.SelectedNodes, SelectionPreview); SelectionToVisualize = &SelectionPreview; } int32 NodesLayerId = LayerId; for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex) { FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex]; TSharedRef<SWorldTileItem> ChildNode = StaticCastSharedRef<SWorldTileItem>(CurWidget.Widget); ChildNode->bAffectedByMarquee = SelectionToVisualize->Contains(ChildNode->GetObjectBeingDisplayed()); LayerId = CurWidget.Widget->Paint(Args.WithNewParent(this), CurWidget.Geometry, MyClippingRect, OutDrawElements, NodesLayerId, InWidgetStyle, ShouldBeEnabled(bParentEnabled)); ChildNode->bAffectedByMarquee = false; } // Draw editable world bounds if (!WorldModel->IsSimulating()) { float ScreenSpaceSize = FLevelCollectionModel::EditableAxisLength()*GetZoomAmount()*2.f; FVector2D PaintSize = FVector2D(ScreenSpaceSize, ScreenSpaceSize); FVector2D PaintPosition = GraphCoordToPanelCoord(FVector2D::ZeroVector) - (PaintSize*0.5f); float Scale = 0.2f; // Scale down drawing border FSlateLayoutTransform LayoutTransform(Scale, AllottedGeometry.GetAccumulatedLayoutTransform().GetTranslation() + PaintPosition); FSlateRenderTransform RenderTransform(Scale, AllottedGeometry.GetAccumulatedRenderTransform().GetTranslation() + PaintPosition); FPaintGeometry EditableArea(LayoutTransform, RenderTransform, PaintSize/Scale); FLinearColor PaintColor = FLinearColor::Yellow; PaintColor.A = 0.4f; FSlateDrawElement::MakeBox( OutDrawElements, ++LayerId, EditableArea, FEditorStyle::GetBrush(TEXT("Graph.CompactNode.ShadowSelected")), MyClippingRect, ESlateDrawEffect::None, PaintColor ); } // Draw the marquee selection rectangle PaintMarquee(AllottedGeometry, MyClippingRect, OutDrawElements, ++LayerId); // Draw the software cursor PaintSoftwareCursor(AllottedGeometry, MyClippingRect, OutDrawElements, ++LayerId); if(WorldModel->IsSimulating()) { // Draw a surrounding indicator when PIE is active, to make it clear that the graph is read-only, etc... FSlateDrawElement::MakeBox( OutDrawElements, LayerId, AllottedGeometry.ToPaintGeometry(), FEditorStyle::GetBrush(TEXT("Graph.PlayInEditor")), MyClippingRect ); } // Draw observer location { FVector ObserverPosition; FRotator ObserverRotation; if (WorldModel->GetObserverView(ObserverPosition, ObserverRotation)) { FVector2D ObserverPositionScreen = GraphCoordToPanelCoord(FVector2D(ObserverPosition.X, ObserverPosition.Y)); const FSlateBrush* CameraImage = FEditorStyle::GetBrush(TEXT("WorldBrowser.SimulationViewPositon")); FPaintGeometry PaintGeometry = AllottedGeometry.ToPaintGeometry( ObserverPositionScreen - CameraImage->ImageSize*0.5f, CameraImage->ImageSize ); FSlateDrawElement::MakeRotatedBox( OutDrawElements, ++LayerId, PaintGeometry, CameraImage, MyClippingRect, ESlateDrawEffect::None, FMath::DegreesToRadians(ObserverRotation.Yaw), CameraImage->ImageSize*0.5f, FSlateDrawElement::RelativeToElement ); } FVector PlayerPosition; FRotator PlayerRotation; if (WorldModel->GetPlayerView(PlayerPosition, PlayerRotation)) { FVector2D PlayerPositionScreen = GraphCoordToPanelCoord(FVector2D(PlayerPosition.X, PlayerPosition.Y)); const FSlateBrush* CameraImage = FEditorStyle::GetBrush(TEXT("WorldBrowser.SimulationViewPositon")); FPaintGeometry PaintGeometry = AllottedGeometry.ToPaintGeometry( PlayerPositionScreen - CameraImage->ImageSize*0.5f, CameraImage->ImageSize ); FSlateDrawElement::MakeRotatedBox( OutDrawElements, ++LayerId, PaintGeometry, CameraImage, MyClippingRect, ESlateDrawEffect::None, FMath::DegreesToRadians(PlayerRotation.Yaw), CameraImage->ImageSize*0.5f, FSlateDrawElement::RelativeToElement, FLinearColor(FColorList::Orange) ); } } LayerId = PaintScaleRuler(AllottedGeometry, MyClippingRect, OutDrawElements, LayerId); return LayerId; }