x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Is it possible to center justifiy FSlateDrawElement::MakeText?

Hey Team,

Is it possible for me to center justify drawn text with FSlateDrawElement::MakeText OR to get the rendered text size to manually offset the text?

I am building a custom graph widget and am using FSlateDrawElement::MakeText to draw the graph's axis and grid labels as seen below. The labels are generated on load depending on the data's range and scale. This means I can't manually set the graph grids and labels in the widget's blueprint as the number of labels and grids and their positions change dynamically.

alt text

If MakeText is not the recommended technique for manually drawing text, how should I go about drawing my labels in my custom widget?

Cheers, Mugen

Product Version: UE 4.8
Tags:
graph.jpg (32.6 kB)
more ▼

asked Aug 24 '15 at 04:15 AM in C++ Programming

avatar image

MugenCity
182 12 18 104

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

To draw centered text, you need to first calculate the size that the text will be when it is actually drawn. You can get find this information by getting the font measure service in slate via

 const TSharedRef< FSlateFontMeasure > FontMeasureService = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();

and then calling the appropriate procedures on it. You can look in the source code for Slate's editable text view ( SEditableText.cpp ) for an example of this. (Other widgets use it too, of course).

more ▼

answered Aug 24 '15 at 04:50 AM

avatar image

cancel
2.4k 101 72 124

avatar image MugenCity Aug 26 '15 at 09:55 PM

Awesome, the font measure service works perfectly. Thank you Cancel!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question