B4J Question Resize form with rounded corners

Gandalf

Member
Licensed User
Longtime User
Hello all
I have to make an app with rounded form corners. There is Erel's example showing how to make form corners rounded and how to move such form. Also there is solution by moore_it which describes how to resize undecorated form. Now it is possible to resize the form by dragging its bottom-right corner. But in my case it is not enough. I need to have this form resizeable as any regular form - in all directions, dragging by edges and corners. I managed to do it, but my solution has two problems:
1. It requires disabling Windows scaling for the app.
2. There is noticeable wobbling effect when form resizes in top and/or left directions.
Sample project is attached. Can anyone help me solve these two problems, please?
 

Attachments

  • RoundedFormCornersExperiment.zip
    2.9 KB · Views: 54
Last edited:

Gandalf

Member
Licensed User
Longtime User
Problem #1 solved. Disabling Windows scaling is not required anymore. Sample attached.
 

Attachments

  • RoundedFormCornersExperiment_v2.zip
    2.9 KB · Views: 57
Upvote 0

zed

Active Member
Licensed User
Hi,

When you analyze the logs, you find that the dimensions are correct.
But once you activate the panels, the result is not what we expect.
It doesn't work properly. Maybe something is missing.
If anyone can do better.
 

Attachments

  • FormResize.zip
    50.5 KB · Views: 48
Upvote 0

PaulMeuris

Active Member
Licensed User
When the form is resized the contents of the form is redrawn for every mouse drag. This causes the wobbling effect.
In other programming languages the forms behave in the same way.
The strange thing about this is that it only happens when dragging to the left or to the top. I have no explanation for this.
You can eliminate the wobbling effect if you remove all the child views from the form pane, wait a second, load the layout again and adjust the views accordingly.
Side effect here is that if the dragging takes longer than a second there is a flikkering of the redraws.
This is the code i used to test this:
B4X:
Sub AppStart (Form1 As Form, Args() As String)
    Cursors.InitializeStatic("javafx.scene.Cursor")
    MainForm = Form1
'    MainForm.SetFormStyle("TRANSPARENT")
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    MainForm.BackColor = fx.Colors.ARGB(0, 255, 0, 0)
    CSSUtils.SetBackgroundColor(MainForm.RootPane, fx.Colors.Transparent)
End Sub

Private Sub MainForm_Resize (Width As Double, Height As Double)
    MainForm.RootPane.RemoveAllNodes
    Sleep(1000)
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.RootPane.SetLayoutAnimated(0,0,0,MainForm.RootPane.Width,MainForm.RootPane.Height)
    UnderPane.PrefWidth = MainForm.RootPane.Width
    UnderPane.PrefHeight = MainForm.RootPane.Height
    MainPane.PrefWidth = MainForm.RootPane.Width-20
    MainPane.PrefHeight = MainForm.RootPane.Height-20
End Sub

Private Sub FormCloseBtn_Click
    MainForm.Close
End Sub
I am using a standard form style for this test.
 
Upvote 0

Gandalf

Member
Licensed User
Longtime User
I have added ResizeStep variable. It helps a bit. Also added MinXsize and MinYsize for the form and some views to see how they behave. Making views invisible when resizing may possibly confuse users, so I don't consider it for now.
 

Attachments

  • RoundedFormCornersExperiment_v3.zip
    3.3 KB · Views: 43
Upvote 0

zed

Active Member
Licensed User
We always use LEFT/TOP as the starting anchor. It could be the cause.
If now we could also do RIGHT/BOTTOM maybe the FORM would react differently. A JAVA problem?
The IDE B4X we use reacts the same way. @Erel didn't solve this problem, I doubt we'll get there.šŸ¤£
 
Upvote 0

Gandalf

Member
Licensed User
Longtime User
We always use LEFT/TOP as the starting anchor. It could be the cause.
If now we could also do RIGHT/BOTTOM maybe the FORM would react differently. A JAVA problem?
The IDE B4X we use reacts the same way. @Erel didn't solve this problem, I doubt we'll get there.šŸ¤£
Dragging right bottom corner does not cause wobbling. I suppose it is because it does not change form location (top/left coordinates), it changes height/width only. When top and/or left coordinate is changed, form wobbles.
And yes, B4J IDE window behaves exactly the same way. I agree, it is unlikely that we can solve it.
 
Upvote 0
Top