Scroll width not updating when horizontal scrollbar is hidden

333 views
Skip to first unread message

Gene Pavlovsky

unread,
Sep 25, 2017, 11:10:35 AM9/25/17
to scintilla-interest
Hi.

I'm contributing to FlashDevelop, which is based on Scintilla.
I'm working on a fix for a custom horizontal scrollbar not reflecting actual document width.

Custom scrollbars are rendered by FlashDevelop using particular UI themes, Scintilla's own scrollbars are hidden in this case.

The problem is, Scintilla doesn't update scroll width (with scroll width tracking enabled) if it's horizontal scrollbar is not visible. Therefore, there's no way for me to find the correct scroll width.

Related code is in Scintilla's Editor.cxx, at the end of Editor::Paint():
```
if (horizontalScrollBarVisible && trackLineWidth && (view.lineWidthMaxSeen > scrollWidth)) {
scrollWidth = view.lineWidthMaxSeen;
if (!FineTickerRunning(tickWiden)) {
FineTickerStart(tickWiden, 50, 5);
}
}
```

Can you please suggest a workaround? Is there any drawback to moving the `horizontalScrollBarVisible` condition to the inner `if`? The scrollWidth property would then be updated regardless of horizontal scrollbar visibility.

Appreciate your help.
--Gene

Neil Hodgson

unread,
Sep 27, 2017, 6:59:08 PM9/27/17
to scintilla...@googlegroups.com
Gene Pavlovsky:

> Can you please suggest a workaround? Is there any drawback to moving the `horizontalScrollBarVisible` condition to the inner `if`? The scrollWidth property would then be updated regardless of horizontal scrollbar visibility.

That may help but its likely incomplete. Shouldn't SetXYScroll also update your custom scrollbar?

Neil

Gene Pavlovsky

unread,
Oct 9, 2017, 11:42:49 AM10/9/17
to scintilla-interest
Hey Neil, appreciate you getting back to me.

I've looked at the code and in SetXYScroll there's also a check for `if (horizontalScrollBarVisible &&`
So since the stock scrollbar is hidden, scrollWidth is not being updated by SetXYScroll, either.

I would really appreciate if you can consider some improvement which would allow apps with custom scrollbars to be able to know the correct scrollWidth.

I understand that for performance reasons you don't want to call SetScrollBars() on scrollWidth update when the horizontal scroll bar is not visible.
But is there any performance hit to just keeping scrollWidth property updated? From what I see in the code, it's possible to update scrollWidth, and then only call SetScrollbars() (or set tickWiden) if the scrollbar is actually visible.

Looks like the simplest solution to me. But maybe you have a better idea. I just want to fix our custom horizontal scrollbar :)

Thanks Neil

Neil Hodgson

unread,
Oct 17, 2017, 1:31:26 AM10/17/17
to Scintilla mailing list
Gene Pavlovsky:

> I would really appreciate if you can consider some improvement which would allow apps with custom scrollbars to be able to know the correct scrollWidth.

FlashDevelop appears to be using the Win32 platform. What happens if you leave horizontalScrollBarVisible on and don’t turn on the WS_HSCROLL bit when the Scintilla window is created?

> I understand that for performance reasons you don't want to call SetScrollBars() on scrollWidth update when the horizontal scroll bar is not visible.

Its adding some new states and the full effects are unclear.

> Looks like the simplest solution to me. But maybe you have a better idea. I just want to fix our custom horizontal scrollbar :)

I can’t see how this is sufficient for custom scroll bars as there isn’t a mechanism to update the custom scroll bars. Possibly there is a timer or other indirect updater.

A more complete interface to custom scrollbars may be more motivating.

Neil

Reply all
Reply to author
Forward
0 new messages