Hello jay.lin,
since Attributed Text view includes diverse configuration attributes affecting the layout of the text, there is no method to query a width. It works other way around -> you specify the expected width and the Attributed Text view layouts the text, the paragraphs, the columns, etc. to fit within this width.
Depending on your application case, following approaches are possible:
1. Use the regular Text view instead of Attributed Text view. It permits you to query the area occupied by the text. See also the section Arrange other views on the content of the Text view. In particular the method GetContentArea() would provide the desired information.
2. Use the methods of the Resources::Font class to calculate the area needed to display some text (e.g. "Unknown (Title)"). Use the font object associated to the Attributed Text view when calculating the area. To calculate the text width, the appropriate method could GetTextExtent().
Once you know the width of the text you can configure a Move Point Effect to perform the scrolling animation. For example:
// The estimated width of the text.
var int32 width = ...
// Configure a point effect to run forth and back in the specified range
// animating the 'ScrollOffset' property of the Text view. One cycle takes
// 1 sec.
PointEffect.Value1 = <0,0>;
PointEffect.Value2 = point( Text.Bounds.w - width, 0 );
PointEffect.Outlet = ^Text.ScrollOffset;
PointEffect.Symmetric = true;
PointEffect.NoOfCycles = 0;
PointEffect.CycleDuration = 1000;
PointEffect.Enabled = true;
Assuming you have a PointEffect object added to the component, the above code can be implemented within a method which should start the effect (for example, when the text content changes). Alternative, most of the configuration parameters can also be specified more conveniently in the Inspector window:
... then when the content of the Text vie changes, just update the value range for the animations effect:
// The estimated width of the text.
var int32 width = ...
PointEffect.Value2 = point( Text.Bounds.w - width, 0 );
I hope it helps you further.
Best regards
Paul Banach