Lazarus

Programming => Widgetset => Cocoa => Topic started by: apeoperaio on October 10, 2018, 10:06:25 am

Title: TScrollBox: scrollbars issue
Post by: apeoperaio on October 10, 2018, 10:06:25 am
I have an issue with TScrollBox.
Look at the source below. A Tscrollbox aligned alClient with a Tempo a TListbox and a TButton.

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     ListBox1: TListBox;
  17.     Memo1: TMemo;
  18.     ScrollBox1: TScrollBox;
  19.     procedure FormCreate(Sender: TObject);
  20.   private
  21.  
  22.   public
  23.  
  24.   end;
  25.  
  26. var
  27.   Form1: TForm1;
  28.  
  29. implementation
  30.  
  31. {$R *.lfm}
  32.  
  33. { TForm1 }
  34.  
  35. procedure TForm1.FormCreate(Sender: TObject);
  36. begin
  37.   memo1.Align:= alTop;
  38.   memo1.Height:= 300;
  39.   ListBox1.Align:= alTop;
  40.   ListBox1.Height:= 300;
  41.   Button1.Align:= alClient;
  42. end;
  43.  
  44. end.
  45.  

When I run my app I can see the vertical scrollbar for few seconds, and I can use I to move on my TScrollBox, but after few seconds the scrollbar disappear and I cannot scroll anymore. In order to make the scrollbar appearing again I must resize the form.


Title: Re: TScrollBox: scrollbars issue
Post by: wp on October 10, 2018, 10:19:36 am
If I understand correctly there should not be a scrollbar at all because you client-align the button. Because of the top-aligned memo and listbox and the client-aligned button the scrollbox is completely filled. A scrollbar will appear only when the total extent of the controls within the scrollbox is larger than the clientrect of the scrollbox.

Make the button top-aligned and the scrollbar will be shown if the scrollbox height is less than the combined height of memo, listbox and button.

I don't understand why you see the scrollbar for a few seconds. Please post a complete compilable project.
Title: Re: TScrollBox: scrollbars issue
Post by: apeoperaio on October 10, 2018, 10:32:21 am
The horizontal scrollbar is not shown, properly, the vertical scrollbar should be shown since I cannot see all my components in the scrollbox. See images.
I attached a sample project. Let me know if I missed something.


Title: Re: TScrollBox: scrollbars issue
Post by: wp on October 10, 2018, 10:43:23 am
It's working correctly for me on Windows. But you seem to be on Mac... You should file a bug report then.
Title: Re: TScrollBox: scrollbars issue
Post by: apeoperaio on October 10, 2018, 10:51:15 am
It's working correctly for me on Windows. But you seem to be on Mac... You should file a bug report then.

It works on windows for me too. I am using Cocoa, so I wrote on Cocoa forum :)
Title: Re: TScrollBox: scrollbars issue
Post by: ChrisR on October 11, 2018, 03:17:09 am
What version of Lazarus are you using? I tested your project with SVN 59284. With this release, the vertical scroll bar looks fine, and it did not disappear on my MacOS 10.13 laptop. I do not that the horizontal scroll bar does seems a bit funny. It works with your stock application - appearing if you make the app very narrow so you need to scroll to see the TButton. However, if you set the Memo1.WordWrap := false and recompile, launch the program and type a long sting so a horizontal scroll bar would be required to pan to see the text. In this case I do not see the horizontal scrollbar.
Title: Re: TScrollBox: scrollbars issue
Post by: apeoperaio on October 11, 2018, 10:39:17 am
I am using Lazarus 2.1.0 r59284 FPC 3.0.4 x86_64-darwin-cocoa (alpha).
The vertical scrollbar works perfectly on panels, buttons, labels etc. but seems that on control including a scrollbar by themselves (or scrollable components, like memo, listbox etc) the TScrollBox scrollbar does not appear.
Title: Re: TScrollBox: scrollbars issue
Post by: MISV on October 21, 2018, 05:52:03 pm
Just for reference: I experience similar issues with TScrollBox
Title: Re: TScrollBox: scrollbars issue
Post by: cobata on March 16, 2019, 10:01:08 am
Actually, the main forms (the forms at all) MUST have scroll bars and not to use a scroll box instead... I am posted a bug with a promise by Dmitry that TForm will has Scrollbars, but the bug report is going to be 1 year old.

https://bugs.freepascal.org/view.php?id=33988
Title: Re: TScrollBox: scrollbars issue
Post by: VTwin on March 29, 2019, 01:42:46 am
I've posted Cocoa bug reports that are a few months old now, that have not yet been acknowledged. I realize folks are busy, and greatly appreciate the amazing progress made, I think largely by Dimitry. Maybe he has some other things going on, so no complaints from me. Just hoping these will be addressed.
 
To be clear, I think the current Cocoa widget set has surpassed the Carbon widget set.
Title: Re: TScrollBox: scrollbars issue
Post by: MISV on August 29, 2019, 01:34:27 pm
There is still a scrollbox problem it seems - I am running on a pretty recent trunk (not completely uptodate)

It is like it miscalculates when to show the vertical scrollbar

Imagine I have a window with various controls (toolbar at top, treeview at left, content at riight).
At e.g. right side I have a tscrollbox with a panel inside.

1) If I maximize / size-up the window I can see all controls in my panel.
2) But as I start sizing the window down I need to continue until e.g. 100 pixels hidden in my panel before the parent scrollbar starts to show its scrollbar.
3) If I maximize / size-up the window I can see all controls in my panel.

Has anyone reported such a problem? I will then either chime in on those or try create one
Title: Re: TScrollBox: scrollbars issue
Post by: MISV on August 29, 2019, 02:39:17 pm
Just tried 61470M - still same problem
Title: Re: TScrollBox: scrollbars issue
Post by: skalogryz on August 29, 2019, 03:54:52 pm
a sample project?
Title: Re: TScrollBox: scrollbars issue
Post by: MISV on August 30, 2019, 12:49:27 am
I will try as soon as possible ... At my real project at the right: I have nested panels/pagecontrol/tabs with a tscrollbox containing a tpanel in one of them.

It is possible it will be necessary to create a more complex demo. (At least if assuming I am the only one experiencing the problem)

If I am the only one experiencing the problem I will also try research this more myself and make some experiments. Maybe I can pinpoint the cause more easily then in the bug report.

Title: Re: TScrollBox: scrollbars issue
Post by: trev on August 30, 2019, 01:11:34 am
@MISV: I have a Tscrollbox which contains Tlabels and Tcomboboxes and the vertical scrollbar comes and goes as expected depending on the number of controls fitting or not. Maybe your issue is related to Tpanels?
Title: Re: TScrollBox: scrollbars issue
Post by: VTwin on August 31, 2019, 09:01:33 pm
Are you sure this is not just Mac functionality?

In Firefox, Messages, the Finder, or iTunes, for example, the scrollbar "thumbs" are not visible unless actively scrolling.

You can not see or grab the thumb until you scroll. If you stop, they disappear. I hate it, but it seems to be expected behavior.
Title: Re: TScrollBox: scrollbars issue
Post by: skalogryz on August 31, 2019, 09:21:38 pm
You can not see or grab the thumb until you scroll. If you stop, they disappear. I hate it, but it seems to be expected behavior.
The term "hate" suggests that you need to know - this behavior is configurable.

"System Preferences" -> "General" -> "Show Scroll Bars" -> "Always"
Title: Re: TScrollBox: scrollbars issue
Post by: VTwin on August 31, 2019, 10:00:54 pm
:D Thanks.
Title: Re: TScrollBox: scrollbars issue
Post by: MISV on September 09, 2019, 10:28:14 pm
Are you sure this is not just Mac functionality?

In Firefox, Messages, the Finder, or iTunes, for example, the scrollbar "thumbs" are not visible unless actively scrolling.

You can not see or grab the thumb until you scroll. If you stop, they disappear. I hate it, but it seems to be expected behavior.

Yes, because it is impossible for me to scroll the content into view. The scrollbar shows, I just can't scroll it far enough. I am sorry for my slow feedback on this. But it is not forgotten. I have some bug reports open and I intend to return to them with examples as soon as possible, so you can reproduce. I understand that is a required #1 step :)
Title: Re: TScrollBox: scrollbars issue
Post by: cobata on October 18, 2019, 12:34:58 pm
I just would like to note that Dmitry is already fixed the problem I reported in Mantis and I pointed here (time ago):
https://bugs.freepascal.org/view.php?id=33988
Title: Re: TScrollBox: scrollbars issue
Post by: MISV on October 18, 2019, 01:54:33 pm
I am playing with it today.

I have this construct many places

TPageControl (this may be nested under other controls, align alClient) > TTabSheet

In this I have
- TScrollBox(align alClient)

In scrollbox I then have
- TPanel (align AlTop)

That is the most simple construct. I am wondering if my problems (if you do not experience them) are related to TPageControl/TTabSheet and many nested controls. Still hard to understand how the scrollbox miscalculates its own area

... A really corny "fix" seems to be iterate all controls and then:

Code: Pascal  [Select][+][-]
  1.    
  2.    if
  3.       (AControl is TPanel)
  4.     and
  5.       ( (AControl.Top = 0) and (AControl.Align = alTop) )
  6.     and
  7.       (AControl.Parent is TScrollBox)
  8.     and
  9.       ( (AControl.Parent.Parent is TTabSheet) or (AControl.Parent.Parent is TPanel) )
  10.     then
  11.       begin
  12.         AControl.Height := AControl.Height + 65;
  13.       end
  14.     ;
  15.  
Title: Re: TScrollBox: scrollbars issue
Post by: MISV on February 18, 2020, 12:22:07 am
I am playing with this again since the "solution" I posted is not a 100% solution and not very satisfying at that either.

I have one bit of news. I tried to load the project into Windows/Lazarus. Scrollbars seem to behave as expected there.

I will return to work inside Lazarus/Mac/Cocoa, but I just wanted to test on Windows/Lazasus/LCL to see if maybe my problem was not really Cocoa related.
Title: Re: TScrollBox: scrollbars issue
Post by: MISV on February 19, 2020, 03:15:49 am
--- I am looking at at workarounds until someday I figure out why ---

What is the best way to force a tscrollbox to recalculate if it should show scrollbars?

Info:
If I resize the form just a few pixels it is enough to trigger recalculation so it shows the scrollbars correctly
(like it should also have done all the time since a lot of the TPanel in TScrollBox is hidden)
Title: Re: TScrollBox: scrollbars issue
Post by: trev on February 19, 2020, 06:22:54 am
Can you provide a minimal project which demos the problem?
Title: Re: TScrollBox: scrollbars issue
Post by: MISV on February 19, 2020, 09:54:01 am
I will attempt, but the problem I am experiencing on is on a project with massive amount of nested controls.

So meanwhile, if I can find a combination of workarounds even if not ideal, it is *much* better than no solution. 

(And such workarounds may also help others. It is my impression LCL-Cocoa is improving every day due to the massive work by skalogryz and possibly others as well, so the problems I am experiencing now may be gone in a couple of years. Crossing fingers)

Title: Re: TScrollBox: scrollbars issue
Post by: MISV on February 21, 2020, 05:55:41 pm
I am playing with it today.

I have this construct many places

TPageControl (this may be nested under other controls, align alClient) > TTabSheet

In this I have
- TScrollBox(align alClient)

In scrollbox I then have
- TPanel (align AlTop)

That is the most simple construct. I am wondering if my problems (if you do not experience them) are related to TPageControl/TTabSheet and many nested controls. Still hard to understand how the scrollbox miscalculates its own area

... A really corny "fix" seems to be iterate all controls and then:

Code: Pascal  [Select][+][-]
  1.    
  2.    if
  3.       (AControl is TPanel)
  4.     and
  5.       ( (AControl.Top = 0) and (AControl.Align = alTop) )
  6.     and
  7.       (AControl.Parent is TScrollBox)
  8.     and
  9.       ( (AControl.Parent.Parent is TTabSheet) or (AControl.Parent.Parent is TPanel) )
  10.     then
  11.       begin
  12.         AControl.Height := AControl.Height + 65;
  13.       end
  14.     ;
  15.  

One more workaround:
When changing tab, resize the panel contained in a scrollbox plus one pixel in height and then minus one pixel in height


This seems to help solve the problem as well

TinyPortal © 2005-2018