[Gambas-user] window resize help
Bruce Steers
bsteers4 at gmail.com
Tue Dec 20 21:27:19 CET 2022
On Tue, 20 Dec 2022 at 18:38, Benoit Minisini <
benoit.minisini at gambas-basic.org> wrote:
> Le 20/12/2022 à 19:06, Benoit Minisini a écrit :
> > Le 20/12/2022 à 18:00, Bruce Steers a écrit :
> >> Could you check this out Ben as it might be a gambas bug.
> >>
> >> the basic code for the left edge movement is thus...
> >>
> >> Dim hRect As New Rect(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
> >> hRect.Left = Mouse.ScreenX
> >> Me.Move(hRect.X, hRect.Y, hRect.W, hRect.H)
> >>
> >> Now apparently that should not move the right window edge but it does
> >> somewhat randomly jiggle it about.
> >> Is it a bug or is there something i need to account for?
> >>
> >> Many thanks
> >> BruceS
> >>
> >
> > Before looking at anything, I can tell you that resizing a window behind
> > the window manager
>
> --> I mean by following the mouse.
>
> --
> Benoît Minisini.
>
Do you mean only a window with a proper window manager titlebar/border
should be resized by mouse?
That's terrible.
The routines i made very nearly works perfectly.
I have come up with a fix now..
I make a note of the windows position in a $hORect object on MouseDown
event.
then after any left or top movement i set the movements Rect.Right or
Rect.Bottom to the $hORect initial value.
that seems to work, otherwise just using/setting the Rect.Left seems to be
faulty.
Odd that it has the glitch without the fix. or is that exactly what you
mean, it's not a reliable wm opperation so a fix is likely to be needed?
Respects
BruceS
Here's the fixed routine (only left/top movement needed attention)... And
the updated source that has it added as a property in Form.class at least
the window resizes gracefully now. For anyone looking for the same feature.
Public Sub OBS_MouseDown()
$hORect = New Rect(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
End
Public Sub OBS_MouseUp()
$hORect = Null
End
Public Sub OBS_MouseMove()
If Not $bBorderless Then Return
If Mouse.Left Then
Dim hRect, hStartRect As Rect
hRect = New Rect(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
hStartRect = hRect.Copy()
Select Me.Mouse
Case Mouse.SizeW
hRect.Left = Mouse.ScreenX
If hRect.Width <= Me.MinWidth Then hRect.Left -= Me.MinWidth -
hRect.Width
hRect.Right = $hORect.Right
Case Mouse.SizeNW
hRect.Left = Mouse.ScreenX
If hRect.Width <= Me.MinWidth Then hRect.Left -= Me.MinWidth -
hRect.Width
hRect.Top = Mouse.ScreenY
If hRect.Height <= Me.MinHeight Then hRect.Top -= Me.MinHeight -
hRect.Height
hRect.Right = $hORect.Right
hRect.Bottom = $hORect.Bottom
Case Mouse.SizeN
hRect.Top = Mouse.ScreenY
If hRect.Height <= Me.MinHeight Then hRect.Top -= Me.MinHeight -
hRect.Height
hRect.Bottom = $hORect.Bottom
Case Mouse.SizeNE
hRect.Top = Mouse.ScreenY
If hRect.Height <= Me.MinHeight Then hRect.Top -= Me.MinHeight -
hRect.Height
hRect.Width = Max(Me.MinWidth, Mouse.X)
hRect.Bottom = $hORect.Bottom
Case Mouse.SizeE
hRect.Width = Max(Me.MinWidth, Mouse.X)
Case Mouse.SizeSE
hRect.Width = Max(Me.MinWidth, Mouse.X)
hRect.Height = Max(Me.MinHeight, Mouse.Y)
Case Mouse.SizeS
hRect.Height = Max(Me.MinHeight, Mouse.Y)
Case Mouse.SizeSW
hRect.Left = Mouse.ScreenX
If hRect.Width <= Me.MinWidth Then hRect.Left -= Me.MinWidth -
hRect.Width
hRect.Height = Max(Me.MinHeight, Mouse.Y)
hRect.Right = $hORect.Right
Case Mouse.SizeAll
hRect.Move(Me.ScreenX + (Mouse.X - Mouse.StartX), Me.ScreenY +
(Mouse.Y - Mouse.StartY))
End Select
If hRect <> hStartRect Then
Me.Move(hRect.X, hRect.Y, hRect.W, hRect.H)
Wait
Endif
Return
Endif
If Mouse.X < $iHandleSize Then
If Mouse.Y < $iHandleSize Then
Me.Mouse = Mouse.SizeNW
Else If Mouse.Y >= Me.H - $iHandleSize Then
Me.Mouse = Mouse.SizeSW
Else
Me.Mouse = Mouse.SizeW
Endif
Else If Mouse.Y < $iHandleSize Then
If Mouse.X >= Me.W - $iHandleSize Then Me.Mouse = Mouse.SizeNE Else
Me.Mouse = Mouse.SizeN
Else If Mouse.X >= Me.W - $iHandleSize Then
If Mouse.Y >= Me.H - $iHandleSize Then Me.Mouse = Mouse.SizeSE Else
Me.Mouse = Mouse.SizeE
Else If Mouse.Y >= Me.H - $iHandleSize Then
Me.Mouse = Mouse.SizeS
Else
Me.Mouse = Mouse.SizeAll
Endif
End
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20221220/5a9000aa/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CustomWindow-1.0.3.tar.gz
Type: application/gzip
Size: 13668 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20221220/5a9000aa/attachment-0001.gz>
More information about the User
mailing list