Skip to main content
Chandan Bhatia1
Associate III
November 28, 2020
Question

Marquee text character from left to write

  • November 28, 2020
  • 13 replies
  • 4088 views

I have big text which I need to scroll left to right in loop with touch gfx. When I read more on it and found about scrollableContainer but kinda unsure how to combine it with my text object widget.

I added below code

  scrollableTripAdviceParameterText_II.setPosition(509, 353, 282, 57);

  scrollableTripAdviceParameterText_II.enableHorizontalScroll(true);

  scrollableTripAdviceParameterText_II.setScrollbarsColor(touchgfx::Color::getColorFrom24BitRGB(240, 235, 235));

// below code is added by me

 scrollableTripAdviceParameterText_II.add(tripAdviceParameterText_II);

scrollableTripAdviceParameterText_II is Scrollable Container widget and tripAdviceParameterText_II is text widget

Is there any other way to add Scrollable Container for my application? I read few blogs on it but unable to figure it out.

Thanks

This topic has been closed for replies.

13 replies

Michael K
Senior III
November 29, 2020

Not sure I'd use a scrollable container for this. Try activating the MoveAnimator mixin on your textbox. Then you can have an animation that linearly moves the text from outside the screen on the left to outside the screen on the right. Add an animationComplete callback that calls a function that would move the text back to the left side and restart the animation.

Sidenote - for English text it's best to scroll it from the right side of the screen to the left.

MarqueeExampleView.hpp

#ifndef MARQUEEEXAMPLEVIEW_HPP
#define MARQUEEEXAMPLEVIEW_HPP
 
#include <gui_generated/marqueeexample_screen/MarqueeExampleViewBase.hpp>
#include <gui/marqueeexample_screen/MarqueeExamplePresenter.hpp>
 
class MarqueeExampleView : public MarqueeExampleViewBase
{
public:
 MarqueeExampleView();
 virtual ~MarqueeExampleView() {}
 virtual void setupScreen();
 virtual void tearDownScreen();
 void startAnimation();
 void animationCompleteHandler(const MoveAnimator<TextArea>& t);
protected:
 
 Callback<MarqueeExampleView, const MoveAnimator<TextArea>&> animationCompleteCallback;
};
 
#endif // MARQUEEEXAMPLEVIEW_HPP

MarqueeExampleView.cpp

MarqueeExampleView::MarqueeExampleView() : animationCompleteCallback(this, &MarqueeExampleView::animationCompleteHandler)
{
}
 
void MarqueeExampleView::setupScreen()
{
 MarqueeExampleViewBase::setupScreen();
 textArea1.setMoveAnimationEndedAction(animationCompleteCallback);
 textArea1.resizeToCurrentText();
 startAnimation();
}
 
void MarqueeExampleView::tearDownScreen()
{
 MarqueeExampleViewBase::tearDownScreen();
}
 
void MarqueeExampleView::startAnimation() {
 textArea1.setXY(800, textArea1.getY()); // replace 800 with your device screen width
 textArea1.startMoveAnimation(-textArea1.getWidth(), textArea1.getY(), 450, touchgfx::EasingEquations::linearEaseNone);
}
 
void MarqueeExampleView::animationCompleteHandler(const MoveAnimator<TextArea>& t) {
 startAnimation();
}

Embedded UI/UX Consulting: cadenza.design
Chandan Bhatia1
Associate III
November 29, 2020

@Michael K​  Thanks for reply. It didn't work for me.

First thing in toughgfx IDE I am not able to find any option to attach my text widget in Scrollable Container widget. I am doing it manually in code. Is this correct way or I am doing something wrong.

Also In MoveAnimator there is no option of resetAnimation(), I am doing start animation in callback.

Thanks.

Michael K
Senior III
November 29, 2020

Hi, I've edited my post with an example. I intended "resetAnimation()" to be code you implement yourself. Try the example and let me know how it goes!

As for your other question, to add text to a scrollable container, in the touchgfx designer just drag object listing for the textbox (in the left sidebar) on top of the scrollable container object listing.

Embedded UI/UX Consulting: cadenza.design