Recent

Author Topic: ScrollingText and text speed  (Read 539 times)

kkuba

  • New Member
  • *
  • Posts: 32
ScrollingText and text speed
« on: June 16, 2022, 09:49:05 am »
ScrollingText, unfortunately, does not have a property that allows you to adjust the speed of scrolling text. This property is very much lacking. I spoke to the author some time ago and he told me that there are currently no plans to develop this component, but he showed me how to fix the component. That's why I made a patch. I have a request to @wp to check and add it to the repository if it's ok.

wp

  • Hero Member
  • *****
  • Posts: 9907
Re: ScrollingText and text speed
« Reply #1 on: June 16, 2022, 12:02:01 pm »
Due to the many formatting changes it is hard to find out what the essential changes are. My impression is that you define a new property "ScrollSpeed", add a setter method for it ("SetScrollSpeed") which sets the timer interval and initialize the timer in Create by the scrollspeed default value rather than the hard-coded "30". Is this correct? Did I miss anything? There is no way for the user to change the scrollspeed at runtime while scrolling is active (that's what I am missing most)?

kkuba

  • New Member
  • *
  • Posts: 32
Re: ScrollingText and text speed
« Reply #2 on: June 16, 2022, 12:09:08 pm »
The formatting changes are due to the fact that the original code didn't have it done, I just instinctively did the JEDI Code Format. Sorry to unintentionally hindered your analysis. Such changes are exactly what you described.

Update: I read your post again. But You can change the speed at runtime while scrolling is active - I don't know what you meant?
« Last Edit: June 16, 2022, 12:20:17 pm by kkuba »

wp

  • Hero Member
  • *****
  • Posts: 9907
Re: ScrollingText and text speed
« Reply #3 on: June 16, 2022, 01:06:19 pm »
But You can change the speed at runtime while scrolling is active - I don't know what you meant?
How can the user change it? Click into the form or press some key to increase the speed stepwise? Or drag with the mouse?

BTW, a note about words: you call the new property "ScrollSpeed". When a speed has a high value, something changes quickly, and so I'd expect a fast scrolling effect. But your speed value is assigned to the timer's interval. When the timer.Interval is increased it actually is triggered less often, i.e. scrolling become slower in spite of the higher "speed" value. I think nobody wants to set the Timer.Interval with the precision of milliseconds. Therefore, I'd propose to keep the property name "ScrollSpeed", but introduce a conversion table from speed values to milliseconds, e.g.
Code: Pascal  [Select][+][-]
  1. type
  2.   TScrollSpeed = 1..7;;
  3. const
  4.   // ms for Timer.Interval
  5.   SCROLL_INTERVAL: Array[TScrollSpeed] of Integer = (
  6.     200, 100, 50, 30, 25, 20, 10
  7.   );
  8.  
  9. constructor TScrollingText.Create(AOwner: TComponent);
  10. begin
  11.   inherited Create(AOwner);
  12.   ...
  13.   FScrollSpeed := 4;
  14.   FTimer.Interval := SCROLL_INTERVAL[FScrollSpeed];
  15.   ...
  16. end;
  17.  
  18. procedure TScrollingText.SetScrollSpeed(Speed: TScrollSpeed);
  19. begin
  20.   FScrollSpeed := Speed;
  21.   FTimer.Interval := SCROLL_INTERVAL[FScrollSpeed];
  22. end;

kkuba

  • New Member
  • *
  • Posts: 32
Re: ScrollingText and text speed
« Reply #4 on: June 16, 2022, 01:34:26 pm »
And now I understand what you meant. What you write is actually not possible - but thanks to this amendment I change the value from e.g. a slider.
Of course what you propose is "prettier" code, so let's put it that way.
Overall thanks for improving the patch.  It seems that what we have done here is generally needed. Maybe you would submit @GetMem this fix to OPM

wp

  • Hero Member
  • *****
  • Posts: 9907
Re: ScrollingText and text speed
« Reply #5 on: June 16, 2022, 02:44:44 pm »
I have some more ideas:
- There is no reason why .res files should not work --> modified code
- There is an annoying "resource not found" exception at designtime. --> removed
- I also don't understand why the "TextFileName" and "ResourceName" have hard-coded names. Since there are already variables for them I think this feature just is not completed. --> changed.

Did not yet implement your speed patch. Are the entries in my conversion table well-spaced? My impression is that there are too many. I think that there should be only 3 (slow - normal - fast) or 5 (very slow - slow - normal - fast - very fast).

wp

  • Hero Member
  • *****
  • Posts: 9907
Re: ScrollingText and text speed
« Reply #6 on: June 16, 2022, 03:22:44 pm »
In r8311, I added the ScrollSpeed property. I decided to use 5 steps: TScrollSpeed = (ssVerySlow, ssSlow, ssNormal, ssFast, ssVeryFast). The ScrollInterval (array[TScrollSpeed] of integer) contains the associated milliseconds for the Timer.Interval; it is a variable and thus can be modified when the user wants different speeds.

kkuba

  • New Member
  • *
  • Posts: 32
Re: ScrollingText and text speed
« Reply #7 on: June 16, 2022, 03:54:32 pm »
Very good ideas. If no one notices any problems, the fix should be reported to OPM. These are minor changes, but very necessary.

wp

  • Hero Member
  • *****
  • Posts: 9907
Re: ScrollingText and text speed
« Reply #8 on: June 16, 2022, 04:32:59 pm »
Very good ideas. If no one notices any problems, the fix should be reported to OPM. These are minor changes, but very necessary.
Certainly. But let me wait a few days for more feedback.

kkuba

  • New Member
  • *
  • Posts: 32
Re: ScrollingText and text speed
« Reply #9 on: June 30, 2022, 09:06:38 pm »
@wp There seems to be no comment. Could I ask you for a final look and for submitting a new version to OPM?

wp

  • Hero Member
  • *****
  • Posts: 9907

 

TinyPortal © 2005-2018