Page MenuHomeWildfire Games

Return correct width from GenerateText
ClosedPublic

Authored by s0600204 on Aug 26 2017, 5:40 PM.

Details

Summary

Currently, the GenerateText function in CGUI.cpp returns the wrong width if any part of the text "generated" is wrapped.

The function wraps text by measuring each word within the text provided and adding the resultant width to an x variable until the sum exceeds the permitted width (at which point it starts a new line with the word it got to).

The returned object from the function has (amongst other things) an m_Size attribute that can be used by the host gui element - but for some reason the code that sets the value of m_Size.cx (aka width) includes the exceeded-width measurement.

Currently, the only gui element to be affected by this is the Tooltip, and that deals with the problem with a workaround marked by a todo comment from philip.

Test Plan

Check that my changes are sane.

Compile pyrogenesis, and look at various tooltips with wrapped text.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

s0600204 created this revision.Aug 26 2017, 5:40 PM
Owners added a subscriber: Restricted Owners Package.Aug 26 2017, 5:40 PM
Vulcan added a subscriber: Vulcan.Aug 27 2017, 2:41 PM
Executing section Default...
Executing section Source...
Executing section JS...
Executing section XML GUI...
Executing section Python...
Executing section Perl...

http://jw:8080/job/phabricator_lint/440/ for more details.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jw:8080/job/phabricator/1920/ for more details.

bb accepted this revision.Feb 6 2018, 10:27 PM
bb added a subscriber: bb.

Either both of us are stupid or neither

great improvement on f.e. the late observer option in the optionsmenu

This revision is now accepted and ready to land.Feb 6 2018, 10:27 PM
This revision was automatically updated to reflect the committed changes.

Thank you for the review (and acceptance).

In D836#52437, @bb wrote:

Either both of us are stupid or neither

I'm hoping neither 😉