Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » ScrollBarSize() - Is it (possibly) a bug?
ScrollBarSize() - Is it (possibly) a bug? [message #58936] Tue, 27 September 2022 01:35 Go to next message
Lance is currently offline  Lance
Messages: 534
Registered: March 2007
Contributor
I was looking for some member function in ScrollBar to retieve the scrollbar size, or expose the const Style *style
which can in turn access the barsize value, but to no avail. Until I find this function
inline int ScrollBarSize()                  { return ScrollBar::StyleDefault().barsize; }//!!


A search in the Upp src indicates many libraries make use of this function, including in HeaderCtrl
void HeaderCtrl::FrameLayout(Rect& r)
{
	LayoutFrameTop(r, this, invisible ? 0 : GetHeight());
	LayoutFrameBottom(r, &sb, sb.IsShown() ? ScrollBarSize() : 0);
}

void HeaderCtrl::FrameAddSize(Size& sz)
{
	if(!invisible)
		sz.cy += GetHeight();
	if(sb.IsVisible())
		sz.cy += ScrollBarSize();
}


Does this imply that a customized ScrollBar Style shall not disagree on barsize with the default ScrollBar Style? Is this restriction necessary? or shall we expose int ScrollBar::ScrollBarSize()const(elevate it to a public member function from a private one as it is now)?
Re: ScrollBarSize() - Is it (possibly) a bug? [message #59335 is a reply to message #58936] Sat, 17 December 2022 14:15 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
Lance wrote on Tue, 27 September 2022 01:35
I was looking for some member function in ScrollBar to retieve the scrollbar size, or expose the const Style *style
which can in turn access the barsize value, but to no avail. Until I find this function
inline int ScrollBarSize()                  { return ScrollBar::StyleDefault().barsize; }//!!


A search in the Upp src indicates many libraries make use of this function, including in HeaderCtrl
void HeaderCtrl::FrameLayout(Rect& r)
{
	LayoutFrameTop(r, this, invisible ? 0 : GetHeight());
	LayoutFrameBottom(r, &sb, sb.IsShown() ? ScrollBarSize() : 0);
}

void HeaderCtrl::FrameAddSize(Size& sz)
{
	if(!invisible)
		sz.cy += GetHeight();
	if(sb.IsVisible())
		sz.cy += ScrollBarSize();
}


Does this imply that a customized ScrollBar Style shall not disagree on barsize with the default ScrollBar Style? Is this restriction necessary? or shall we expose int ScrollBar::ScrollBarSize()const(elevate it to a public member function from a private one as it is now)?


What a nice grey corner have you sumpled upon...

Well, I would say, for now it means that if you use ScrollBar::SetStyle, you cannot expect your styled ScollBar be well integrated is some other widgets unless scrollbarsize is the same...

In practice, in over 15 years I do not remember single instance of custom Scrollbar style, so while this should be fixed, it is really low priority.
Re: ScrollBarSize() - Is it (possibly) a bug? [message #59342 is a reply to message #59335] Sun, 18 December 2022 04:32 Go to previous message
Lance is currently offline  Lance
Messages: 534
Registered: March 2007
Contributor
Thank you, Mirek!

It so happened that a widget I wrote used both vertical ScrollBar and horizontal ScrollBar with both scrollbars set to autohide. An edge case arose that if I set the page width, page height, total width, total height programmatically and I set the page width=total width = width of the view, and when the total height is (maybe slightly) greater than view height, an oscillation kind of events happened: a change in the visibility of one scrollbar causes the change in the visibility of the other scrollbar, the GUI keeps flickering and no user input can be processed.

I have lost my old code, am not sure if I remember what happened exactly, and am not sure if I can still reproduce the event, but I swear it happened to me.

To remedy that, I decided to disable native ScrollBar autohide behaviour and write the autohide logic myself. For that purpose, I need to query the ScrollBarSize(), ideally not in a hackish way. Currently I use the exposed global function but are feeling unsure/uncomfortable Smile

[Updated on: Sun, 18 December 2022 04:41]

Report message to a moderator

Previous Topic: bug in the routine involving the time of the zip file
Next Topic: why there's still empty space below a ColumnList ctrl after I set RoundSize?
Goto Forum:
  


Current Time: Sun Jun 16 21:34:16 CEST 2024

Total time taken to generate the page: 0.01514 seconds