Recent

Author Topic: Problem resizing Form with Splitter [BUG][WORKAROUND]  (Read 3385 times)

Vodnik

  • Full Member
  • ***
  • Posts: 210
Problem resizing Form with Splitter [BUG][WORKAROUND]
« on: January 16, 2019, 01:32:34 pm »
Attached is a very simple project: a Form with 2 Memos and a Splitter.
I followed this example: http://wiki.freepascal.org/TSplitter#Splitter_with_AnchorSides
Memo1 is anchored at top, left and bottom to a Form, at right - to Splitter.
Memo2 is anchored at top, right and bottom to a Form, at left - to Splitter.
Both Memos have Costraints.MinHeight and MinWidth, also do Form.
All align properties are set to alNone.

How to reproduce a problem:
Start application
Enlarge the form's width well enough
Using Splitter, minimize Memo1 to the possible minimum width
(up to now everything works fine)
Now drag right frame of a form to minimize the width.
Memo2 with Splitter starts to overlap Memo1.

I can't believe that this is a bug which nobody have noticed.
That's why I played few days with this issue to find out what I'm doing wrong.
Creating different projects with similar settings, I noticed that effect have random nature:
Sometimes Memo1 is overlapped by Splitter and Memo2,
Sometimes Splitter with Memo2 are dragged under Memo1 which looks transparent in that case.
Seems this depends upon the order of settings were done while designing the form and the controls, but I didn't find out the rule.
Lazarus 1.8.4
Windows 7
« Last Edit: January 17, 2019, 09:46:20 pm by Vodnik »

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: Problem resizing Form with Splitter
« Reply #1 on: January 16, 2019, 02:00:18 pm »
When starting to run your source code, I got SIGSEGV error. So I tried to run it directly from the binary, I got the error as the image below.

Please fix the error first. Or write another simple demo that showing your 'real' issue.

I wrote a simple desktop tool for my friend, it uses a TSplitter. So far, no any issue found. So I'm interested to know more about the problem you said.
« Last Edit: January 16, 2019, 02:11:13 pm by Handoko »

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: Problem resizing Form with Splitter
« Reply #2 on: January 16, 2019, 02:15:55 pm »
Same here

Data file is not in project, I commented out all the formshow event code.

To me its working fine.

Noy sure how you write the config file for the form data, but the form show that reads and set the values can be called many times. Try putting a breakpoint in the start of the event and see if that the problem.

The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: Problem resizing Form with Splitter
« Reply #3 on: January 16, 2019, 02:28:21 pm »
I tested OP's code again but with both OnFormShow and OnFormClose disabled. I cannot reproduce the issue OP said. Tested on Lazarus 1.8.4 Ubuntu 18.10 GTK 2.

Vodnik

  • Full Member
  • ***
  • Posts: 210
Re: Problem resizing Form with Splitter
« Reply #4 on: January 16, 2019, 03:28:17 pm »
I apologize for providing wrong example  :-[
I have replaced archive in original message for true one.
Probably this problem takes place only under Windows.
I have tested under Windows 7, Windows Server 2012 - effect was the same.

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: Problem resizing Form with Splitter
« Reply #5 on: January 16, 2019, 04:07:09 pm »
Yes, I can see what you meant now.

Please submit a bug report here:
https://bugs.freepascal.org/view_all_bug_page.php?project_id=1

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: Problem resizing Form with Splitter
« Reply #6 on: January 16, 2019, 05:35:47 pm »
Is it because you have used constraints on memo1 and set minimum width to 300, yet in design you have placed the splitter inside the that constaint, should the splitter be placed at left=308?

The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Vodnik

  • Full Member
  • ***
  • Posts: 210
Re: Problem resizing Form with Splitter
« Reply #7 on: January 16, 2019, 05:57:59 pm »
Josh, this didn't help. I played a bit with left, width, etc. - setting different values, indeed, may change the behaviour (who overlaps who), but do not fix the issue.
So, bug issue 0034883.

Vodnik

  • Full Member
  • ***
  • Posts: 210
Re: Problem resizing Form with Splitter
« Reply #8 on: January 16, 2019, 08:08:29 pm »
There is even more strange effect when TXMLPropStorage is added to the project to
store Form size and position and Splitter position.
If one repeat the described in original message steps to cause Memo1 overlapping by other controls, then with each application start Splitter will go more and more to to the left, until Memo1 will disappear completely. Example project is attached.

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: Problem resizing Form with Splitter [BUG]
« Reply #9 on: January 16, 2019, 08:24:11 pm »
Yep.

Vodnik

  • Full Member
  • ***
  • Posts: 210
Re: Problem resizing Form with Splitter [BUG]
« Reply #10 on: January 16, 2019, 08:59:47 pm »
Well, this problem is acknowledged in Bug Tracker since 2014 (0025558)...
What can be a workaround? Use of onResize event?

Vodnik

  • Full Member
  • ***
  • Posts: 210
Re: Problem resizing Form with Splitter [BUG]
« Reply #11 on: January 17, 2019, 08:28:49 pm »
Seems I have found a problem workaround for this example. I created a Form1.onResize handler that looks like:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormResize(Sender: TObject);
  2. begin
  3.   If Splitter1.Left<Memo1.Constraints.Minwidth+Memo1.BorderSpacing.Left+Memo1.BorderSpacing.Right
  4.     then Splitter1.SetSplitterPosition(Memo1.Constraints.Minwidth+Memo1.BorderSpacing.Left+Memo1.BorderSpacing.Right);
  5.   If Splitter1.Left>Form1.ClientWidth-(Memo2.Width+Memo2.BorderSpacing.Left+Memo2.BorderSpacing.Right+Splitter1.Width)
  6.     then Splitter1.SetSplitterPosition(Form1.ClientWidth-(Memo2.Width+Memo2.BorderSpacing.Left+Memo2.BorderSpacing.Right+Splitter1.Width));
  7. end;
  8.  
With it, issue have gone.
Example project attached.

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Re: Problem resizing Form with Splitter [BUG]
« Reply #12 on: January 17, 2019, 10:08:48 pm »
Seems I have found a problem workaround for this example. I created a Form1.onResize handler that looks like:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormResize(Sender: TObject);
  2. begin
  3.   If Splitter1.Left<Memo1.Constraints.Minwidth+Memo1.BorderSpacing.Left+Memo1.BorderSpacing.Right
  4.     then Splitter1.SetSplitterPosition(Memo1.Constraints.Minwidth+Memo1.BorderSpacing.Left+Memo1.BorderSpacing.Right);
  5.   If Splitter1.Left>Form1.ClientWidth-(Memo2.Width+Memo2.BorderSpacing.Left+Memo2.BorderSpacing.Right+Splitter1.Width)
  6.     then Splitter1.SetSplitterPosition(Form1.ClientWidth-(Memo2.Width+Memo2.BorderSpacing.Left+Memo2.BorderSpacing.Right+Splitter1.Width));
  7. end;
With it, issue have gone.
Example project attached.
Can your discovery help to solve these tickets?

0025558: Constraints.MinWidth ignored for client-aligned controls when parent changes size
https://bugs.freepascal.org/view.php?id=25558

0034883: Resizing Form with Splitter causes overlap of controls
https://bugs.freepascal.org/view.php?id=34883 [^]

Vodnik

  • Full Member
  • ***
  • Posts: 210
Re: Problem resizing Form with Splitter [BUG][WORKAROUND]
« Reply #13 on: January 18, 2019, 01:36:02 pm »
valdir.marcos, maybe. I saw you added this info to bug report, thanks.

 

TinyPortal © 2005-2018