-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the behavior when dragging the divider of split container #1618
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve a couple of questions/comments:
- I don’t understand why the numbers of the new test are as they are.
Why is a move of 10 a change in the offset of 0.3? - I’d prefer a test which checks the rendered output of the whole container not only some property of the divider.
- I cannot reproduce the behaviour shown on your GIFs. On my Mac only the divider of the outer container misbehaves while the dividers of the inner container work like expected. Also, I did not understand why the current code misbehaves. Do you have an explanation?
Let me check on 3. first,
Would you reproduce it with a code like the following? func main() {
a := app.New()
w := a.NewWindow("Test")
windowSize := fyne.NewSize(500, 500)
rectMinSize := fyne.NewSize(150, 150) // windowSize * 0.3
r1 := canvas.NewRectangle(color.RGBA{128, 0, 0, 0})
r2 := canvas.NewRectangle(color.RGBA{0, 128, 0, 0})
r3 := canvas.NewRectangle(color.RGBA{0, 0, 128, 0})
r1.SetMinSize(rectMinSize)
r2.SetMinSize(rectMinSize)
r3.SetMinSize(rectMinSize)
s1 := widget.NewVSplitContainer(r1, r2)
s2 := widget.NewHSplitContainer(r3, s1)
// set 0.0 - 0.3 if check the leading
// set 0.7 - 1.0 if check the trailing
s1.SetOffset(0.1)
s2.SetOffset(0.1)
w.SetContent(s2)
w.Resize(windowSize)
w.ShowAndRun()
} |
In the above example, if move the divider to the |
Ah, so the problem is not the computation in IMO, this should be fixed in the container instead.
|
P.S.: I’m not dogmatic about |
@toaster perhaps compare it to |
On the face of it I think this change makes sense, and does fix an issue I have encountered before as well. |
Thanks for the confirmation.
Does this refer to the following comments?
How should this test be done?
Like |
@lusingander I was referring to the 3 bullets message that was raised regarding offset, but yes the PR comments would need addressed as well.
It's my understanding that's what the Offset field should currently do. The change added here stops it from setting invalid values, so the outcome of this landing is that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, thanks @lusingander!
Regarding (un)exported Regarding the fix: It is definitely needed but I still think that the place is wrong and that the tests should be more “integrative” (testing the render output). |
No, it doesn’t because |
Seems like this would resolve the concerns, If you can address it @lusingander we would like to get this merged into 1.4.2 which I hope to call for vote at the end of the week. |
As However the original intention was that However the real bug here is that func (r *splitContainerRenderer) MinSize() fyne.Size {
s := fyne.NewSize(0, 0)
for _, o := range r.objects {
min := o.MinSize()
if r.split.Horizontal {
s.Width += min.Width
s.Height = fyne.Max(s.Height, min.Height)
} else {
s.Width = fyne.Max(s.Width, min.Width)
s.Height += min.Height
}
}
return s
} Instead it should calculate the minsize of The downside to this, and the reason I didn't implement it, is because it resulted in odd behaviour where the user dragged the divider, and the splitter's minsize changed to accommodate the children so the window kept expanding. |
I think it's better without having the offset be included in the MinSize. |
@toaster where are we on your thoughts for this? |
@lusingander can you please rebase on latest develop? |
9d830a1
1182447
to
9d830a1
Compare
I've rebased it to the latest version. And I see the windows test is failing... |
The passes check (was a temporary failure) and I'm happy that this is a useful fix. |
# Conflicts: # widget/splitcontainer.go
@lusingander @andydotxyz I cannot see what the latest changes were. Force pushes are a very bad idea on a work-in-progress PR. However, looking at the complete diff, I cannot see were my objections were addressed:
|
Reviewing tickets for 1.4.3 which is being put together now and saw this ticket. Thinking about the request for image tests I'm not sure how it can prove correctness without the mouse cursor visible, so maybe the tests present are sufficient. |
I didn’t ask for image tests but for markup tests. Also, the mouse pointer does not need to be visible for an image based test to work. |
If we want to cherry-pick this to 1.4.x we can't use the markup tests, as they are not available in 1.4 code... As for code location I worry that we are setting a precident here that bug fixes must come with code refactoring if the code it's fixing is out of date / not well structured... Is that what we want? |
Normally, absolutely. However in this case the fix is in applying the correct behaviour based on mouse location. |
That’s the scenario I had in mind with https://gophers.slack.com/archives/CK5U4BU87/p1606297439264800. I don’t like the idea to have to do things in a certain way on dev because of some release branch.
That is what I want at least. |
Because we “move” the mouse to position |
Just for clarity, what I was hoping for was to land this so it could be in the 1.4.3 release, which we were hoping to prepare iminently ("Late December" was the due date). It is relatively clear that, despite this being a simple and useful fix, the objections listed about making that change on develop seem to indicate it will not be possible to land this for 1.4. |
I do not consider this a lower quality patch - I think it matches the quality of the code in that area well. |
As discussed in Slack, I’ll refactor the |
Thanks very much @toaster I appreciate your help on this. We can get it into 1.4.3 and work on the refactor later :). |
Description:
In
SplitContainer
, when the default offset value is less thanMinSize
ratio, dragging the divider does not seem to work as expected.For example, in the following image, the offset of the main window is set to 0 and the offset of each of the
SplitTab
is set to 1.I think that the following behavior would be expected:
Checklist: