Announcement

Collapse
No announcement yet.

Troubles with drawing an image in a custom widget

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Troubles with drawing an image in a custom widget

    Hey Team,

    I have created a new Graph UMG widget with an underlying CompoundWidget slate graph rending below it.

    Click image for larger version

Name:	graph.JPG
Views:	1
Size:	34.7 KB
ID:	1160888

    I'm running into issues as I am attempting to draw a small icon (bmp texture) on my graph to indicate the max point on the data line.
    FSlateDrawElement::MakeBox maximizes the brush to the size of my graph, rather than allowing me to provide a size and position and call it on my slate's OnPaint().

    Is there any way I can limit it to the position and size I wish?

    Cheers,
    Mugen

    #2
    Part of the data passed to MakeBox is the paint geometry of the box, including the size and position. If you're just using the paint geometry of the chart that's why.

    Comment


      #3
      That did the trick, cheers Nick.

      I had attempted to create the geometry previously but had not tried .MakeChild(). For clarification to solve the problem, this is what I ended up with to produce the desired result:

      Code:
      int32 SGraph::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
      {
          FGeometry geometry = AllottedGeometry.MakeChild(IconSize, IconTransform);
          FSlateDrawElement::MakeBox(OutDrawElements, LayerId + 1, geometry.ToPaintGeometry(), Brush.Get(), MyClippingRect);
          return LayerId; 
      }
      Hope this can help others.
      Cheers
      Mugen

      Comment

      Working...
      X