Resize & Refresh - Some observations.

Post

Posted
Rating:
#1 (In Topic #311)
Avatar
Expert
Quincunxian is in the usergroup ‘Expert’
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.

Code (gambas)

  1. Public Sub Form_Resize
  2.   If Me.Width < 760 Then Me.Width = 760
  3.   If Me.Height < 660 Then Me.Height = 660
  4.   '...\{rest of code to resize controls}

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
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
sjsepan is in the usergroup ‘Regular’
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.
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
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.

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
sjsepan is in the usergroup ‘Regular’
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.

Code (gambas)

  1. Public Sub Form_Resize()
  2.  
  3.     ' If Me.Width < 800 Then
  4.     '     Me.Width = 800 '$objToolBarActionsDock.FormDesignerWidth
  5.     '     Wait
  6.     ' Endif
  7.     ' If Me.Height < 600 Then
  8.     '     Me.Height = 600 '$objToolBarActionsDock.FormDesignerHeight
  9.     '     Wait
  10.     ' Endif
  11.     If Me.Width < 800 Then
  12.         Me.Resize(800, Me.Height)
  13.     Endif
  14.     If Me.Height < 600 Then
  15.         Me.Resize(Me.Width, 600)
  16.     Endif
  17.  
  18.     $objToolBarActionsDock.Apply
  19.     $objStatusBarDock.Apply
  20.  
  21.     $objPanelTestAnchor.Apply
  22.     $objHBoxFormButtonsAnchor.Apply
  23.  

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.

Code (gambas)

  1. Public Sub Form_Resize()
  2.  
  3.     ' If Me.Width < 800 Then
  4.     '     Me.Width = 800 'TODO:$objToolBarActionsDock.FormDesignerWidth
  5.     '     Wait
  6.     ' Endif
  7.     ' If Me.Height < 600 Then
  8.     '     Me.Height = 600 'TODO:$objToolBarActionsDock.FormDesignerHeight
  9.     '     Wait
  10.     ' Endif
  11.     If Me.Width < 800 Then
  12.         Me.Resize(800, Me.Height)
  13.     Endif
  14.     If Me.Height < 600 Then
  15.         Me.Resize(Me.Width, 600)
  16.     Endif
  17.  
  18.     $objToolBarActionsDock.Apply
  19.     $objStatusBarDock.Apply
  20.  
  21.     $objPanelTestAnchor.Apply
  22.     $objHBoxFormButtonsAnchor.Apply
  23.  
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
Online now: No Back to the top
1 guest and 0 members have just viewed this.