Cuperino / QPrompt-Teleprompter

Teleprompter software for all video creators. Built with ease of use, productivity, control accuracy, and smooth performance in mind.
https://qprompt.app
GNU General Public License v3.0
378 stars 26 forks source link

Reduce delay of font resizing in large documents #131

Open Cuperino opened 1 year ago

Cuperino commented 1 year ago

Original discussion: https://forum.cuperino.com/t/changing-font-size/58

Quote from @videosmith at the forum:

On a long script (~11k words in this case) is it normal to have a delay in response when attempting to adjust the font size slider?

My reply, quoted from the forum:

That is the case for now, yes. QPrompt can handle a little over 36 hours of text without crashing, but the font size handle become slow long before because all glyph dimensions need to be recomputed for all text to be placed correctly.

If this is too much of an issue, there are a couple of ways in which the editor/prompter’s implementation could be improved for that not to happen. It’s one of those features that require a lot of work for small gains that go underappreciated, and the solution still wouldn’t fully eliminate the delay.

The solution that I have in mind is to re-implement Qt’s TextEditor component such that previous glyph sizes are cached instead of deleted when the text is re-sized. This wouldn’t prevent the initial delay, but it would prevent the delay from happening if you move the slider back to a previous position, reducing the total amount of delay when trying to make a precise font size adjustment, as each size would only have to be processed once.

An ideal solution would be to resize only the elements on screen first, and compute the rest after the user lets go of the slider. Unfortunately I have no idea of how to implement that at the time. I would likely have to develop the character engine from scratch.

videosmith commented 1 year ago

I realize this is a clumsy alternative, however can you, upon dragging the Font Size slider, swap QPrompt's contents for your default script and when the slider is released, swap the contents back and resize?

Cuperino commented 1 year ago

Huh... That's a fairly good idea! This could be an "offline editing" feature.

I could try copy the text that surrounds what's currently on screen and swap the editor with the copy when any of the sliders that control text properties are grabbed. This would create the illusion that the text being resized is that from the editor while in fact it is only the portion that was copied.

Some experimentation is needed to figure out whether the copying would be fast enough. Nevertheless, if that doesn't work out, it could always be swapped with a Lorem Ipsum that reflects the font properties behind the text cursor.

videosmith commented 1 year ago

Perhaps a numerical entry in the field next to the slider would be an alternative to dragging?

Cuperino commented 1 year ago

I could try adding something like that... By double clicking on the label one would trigger an edit mode to edit the value. The change would take effect when the user exits that edit mode, by either clicking outside of pressing enter.