Resize & Refresh - Some observations.

Post your Gambas programming questions here.
Post Reply
User avatar
Quincunxian
Posts: 171
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Resize & Refresh - Some observations.

Post by Quincunxian »

Resizing
I posted a project in Project Showcase that converts some media formats.
Cogier noticed that I did not put in a Resize function even though the form was set to be resizeable.
So I added the resize functions and needed to set a minimum width & height as less than that, the form was not really usable so at the top of the Form_Resize routine I added.
Public Sub Form_Resize
  If Me.Width < 760 Then Me.Width = 760
  If Me.Height < 660 Then Me.Height = 660
  '...{rest of code to resize controls}
End
It did not work and on testing, it allowed me to resize the form less than the limits I had set !
I knew that this 'should' work as I've used the same format in other projects successfully.

Checking against another project that does work, I found that using the gb.gui component ignores the setting of the minimums and changing it to gb.qt4 component made it work correctly.

Note# Your Resize event should always be declared Public as if you declare it Private, it does not trigger.

Refreshing
When you are updating visual displays with new data in a loop or other fast acting update structure, you sometimes need to call a control.refresh method followed by a Wait function without any delay parameters which processes all pending events and returns immediately according to the Gambas wiki.
This forces a Redraw of the control to ensure that the visual display is updated with any new data.

I noticed that this was not working in one specific area as a Label control was not updating with new text as required. I added a small delay (0.1 second ) to the Wait function, the data was refreshed.

Be interested in any other observations that fellow Gambas users have.
Cheers - Quin.
I code therefore I am
User avatar
sjsepan
Posts: 68
Joined: Saturday 12th October 2019 10:11pm
Location: Leeper, PA, USA
Contact:

Re: Resize & Refresh - Some observations.

Post by sjsepan »

I am playing around with form resizing right now, and I'm seeing all you have described.

BTW, when a menubar is present, it seems to take up about 21 or 22 pixels(?) of space, and the other controls then measure X=0 from the bottom of the menubar. Note that the form Height still reflects the full amount, including the menubar.
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Resize & Refresh - Some observations.

Post by cogier »

Can you post your form so I can have a look. I respect Quin's wish to manipulate the resizing in code but Gambas does have a powerful system to automatically handle the sizing of Forms.

Resize the attached, no code required.
Sizeing.tar.gz
(13.67 KiB) Downloaded 359 times
User avatar
sjsepan
Posts: 68
Joined: Saturday 12th October 2019 10:11pm
Location: Leeper, PA, USA
Contact:

Re: Resize & Refresh - Some observations.

Post by sjsepan »

Not really having trouble with resizing, as I am using Qt4/5; just noting that I too see the behaviour in the component he mentioned. I am not using that one anyway. :-)
Steve

UPDATE: I did create a project of type 'Graphical application' which is using gb.gui and it behaves as he says. The height/width are ignored, even if I do a Wait.
Public Sub Form_Resize()

    ' If Me.Width < 800 Then
    '     Me.Width = 800 '$objToolBarActionsDock.FormDesignerWidth
    '     Wait
    ' Endif
    ' If Me.Height < 600 Then
    '     Me.Height = 600 '$objToolBarActionsDock.FormDesignerHeight
    '     Wait
    ' Endif
    If Me.Width < 800 Then
        Me.Resize(800, Me.Height)
    Endif
    If Me.Height < 600 Then
        Me.Resize(Me.Width, 600)
    Endif

    $objToolBarActionsDock.Apply
    $objStatusBarDock.Apply

    $objPanelTestAnchor.Apply
    $objHBoxFormButtonsAnchor.Apply

End
Interestingly, the other projects I am playing with using the Gtk3 and Qt5 components seem to be enforcing the minimum without code. I must play around and see if it is one of the form properties doing that...

UPDATE2: if, instead, I try to resize another way, it still does not work. However, I noticed that my other code seems to be seeing those form properties being set, and acting accordingly, even though the viewport or window frame is smaller.
Public Sub Form_Resize()

    ' If Me.Width < 800 Then
    '     Me.Width = 800 'TODO:$objToolBarActionsDock.FormDesignerWidth
    '     Wait
    ' Endif
    ' If Me.Height < 600 Then
    '     Me.Height = 600 'TODO:$objToolBarActionsDock.FormDesignerHeight
    '     Wait
    ' Endif
    If Me.Width < 800 Then
        Me.Resize(800, Me.Height)
    Endif
    If Me.Height < 600 Then
        Me.Resize(Me.Width, 600)
    Endif

    $objToolBarActionsDock.Apply
    $objStatusBarDock.Apply

    $objPanelTestAnchor.Apply
    $objHBoxFormButtonsAnchor.Apply

End
Console output of Debug print...
Dock.Apply.72: f:w=800,h=600
Dock.Apply.72: f:w=800,h=600
Dock.Apply.72: f:w=800,h=600
Dock.Apply.72: f:w=800,h=600
Gambas 3.14
Post Reply