139 views
in GUI Development by
Hi,

I am trying to create a marquee text using pointEffect! (moving horizontally) it is working but I am unable to set some properties correctly!

the text length is dynamic and maximum characters limit is 128.

The idea is to move the whole text till end. and not to move the text when it fits inside the screen (short text).

My problems are the following:

1) to my understanding I need to adjust the Value2  <-100,0>, based on the length of the string (to move along the whole text string). and I also understood that this -100 value actually corresponds to pixel. Is there anyway I can calculate the pixel length corresponding to the text string? or there is any other way I can set value2 which can help me?

2) I am confused how to fix the speed of the text. Apparently the value2 also affects the speed of the text, and also other properties like CycleDuration. How to manage such that the speed of the text is fixed and does not depend on the length of the text!

Please if you have any other suggestion, it will be highly appreciated!

Best Regards,  

Mariam Sohail

1 Answer

+1 vote
by
 
Best answer

Hello Mariam,

let me answer your questions:

Is there anyway I can calculate the pixel length corresponding to the text string? or there is any other way I can set value2 which can help me?

Please see the the chapters Arrange other views on the content of the Text view and Adjust text size to fill a given area (scale text). The chapters explain diverse technics to evaluate the Text view content and estimate the area occupied by the text. For example the method GetContentArea() returns coordinates of a rectangle enclosing the entire text. With it you can calculate the horizontal size of the text and then by subtracting the visible area of the Text view get the desired scrolling range:

var int32 width = TextView.GetContentArea().w - TextView.Bounds.w;

Effect.Value2 = point( -width, 0 )

Apparently the value2 also affects the speed of the text, and also other properties like CycleDuration. How to manage such that the speed of the text is fixed and does not depend on the length of the text!

No, Value2 does not affect the CycleDuration. What happens is, with CycleDuration you configure fixed time how long the entire animation should take. This means if Value1 = 0 and Value2 = 100, then the transition between 0 and 100 will take the time specified in CycleDuration.  If Value2 = 1000, the duration of the animation is still the same. This results in the faster movement of the Text content.

If you want the speed to be constant, you have to calculate CycleDuration from the scroll width of the text and the desired speed in pixel / second. Following could be the calculation:

// How many pixel have to be scrolled?
var int32 width = TextView.GetContentArea().w - TextView.Bounds.w;

// Desired scroll speed in pixel / second (e.g 100 px/sec)
var int32 speed = 100;

PointEffect.Value2        = point( -width, 0 );
PointEffect.CycleDuration = ( 1000 * width ) / speed;

I hope it helps you further.

Best regards

Paul Banach

by
It was really helpful as always! Thank you so much :)

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...