NOTE: Please use this article if you are using Altia Design 11.x and older. For Altia Design 12 and later, elide functionality is built-in natively to the tool, and is described in the newer KB article linked below:
https://altia.zendesk.com/hc/en-us/articles/115001351484-Eliding-text-in-Altia-Design-12
If you are using Altia Design 11.x or older, please continue reading...
Sometimes, when you have text strings that are too long in length to fit in the Text I/O's region of the screen, you may want to add "..." or any other delimiter like "[more...]" to your text strings. This process is called eliding, and while there is not currently an automatic way to elide your text, there are some simple functions you can write to do this from your own logic.
Below is some example code that you can use as a starting point. Some of the code uses C++ for the string functions, so you may need to use the C equivalent functions.
- First, get the maximum pixel width for the text IO textAnimationName.
success =altiaPollEvent(textAnimationName, &maxPixelWidth);
- Next, ask the Altia DeepScreen engine what the size of the new text string will be.
NOTE: For most altiaGL-based targets (not miniGL), you have built-in support for the pixel width by setting a TextI/O's _length_mode animation to 1, then watching/collecting the value of the Text I/O's _length animation every time its _text animation updates. Store this to stringWidth.
If you cannot use _length as above, then use something like:
stringWidth = altiaGetTextWidth(textAnimationName, const_cast<AltiaCharType *>(newTextString.c_str()));- If you're using animation IDs instead of names, you can use altiaGetTextWidthID().
- If the stringWidth is greater than the maxPixelWidth, then start removing characters and check the width again until it fits.
localString = localString.substr(0U, localString.size() - 1U);
stringWidth = altiaGetTextWidth(textAnimationName, const_cast<AltiaCharType *>(newTextString.c_str()));
- Once it fits, remove 3 characters and add in the ellipsis (or whatever delimiter you want to add).
static_cast<void>(localString.erase((localString.size() - 3U), 3U));
static_cast<void>(localString.append(ellipses));
Finally, send that updated string to the textIO as you would normally.
You can read about the 2 different altiaGetTextWidth functions in the DS_UsersGuide.pdf that is in your DeepScreen help directory in section "6.11.3 Obtaining Text Width in Pixels".