[SOLVED] Contents within PanelGadget appear slowly and untidily before panel is drawn around them

Windows specific forum
PBJim
Enthusiast
Enthusiast
Posts: 296
Joined: Fri Jan 19, 2024 11:56 pm

[SOLVED] Contents within PanelGadget appear slowly and untidily before panel is drawn around them

Post by PBJim »

I'm not sure if my sequence of defining the gadgets is the cause here. As the application commences, the text gadgets within the panel (tab 1) towards the centre-right of the window, are drawn first, then eventually the panel is drawn after all other gadgets are completed. It is not until all other screen gadgets are finished, that the panel then finally appears and tidies up the results. During that delay, the text looks untidy because of its missing background. This effect can be seen in the below example, captured during the drawing process. The calc fields have a white block around them, in anticipation of the white panel still waiting to be drawn.

In the genuine application, from which this test code has been extracted, there are a greater number of screen gadgets and graphics and consequently the delay is so significant that it will make users think there is something wrong with it. Is there a way to improve or resolve this?

Image

Code: Select all

window1 = OpenWindow(#PB_Any, #PB_Ignore, #PB_Ignore, 1266, 780, "", #PB_Window_MinimizeGadget | #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   
; **
; **  Define text labels
; **
TextGadget(#PB_Any, 30, 75, 160, 25,  "Input")
TextGadget(#PB_Any, 30, 106, 160, 25, "Input")
TextGadget(#PB_Any, 30, 137, 160, 25, "Input")

TextGadget(#PB_Any, 30, 168, 160, 25, "Input")
TextGadget(#PB_Any, 30, 199, 30, 25,  "Input")

TextGadget(#PB_Any, 330, 421, 110, 25, "Calc")

TextGadget(#PB_Any, 30, 465, 60, 25, "X 1")
TextGadget(#PB_Any, 30, 496, 60, 25, "X 2")
TextGadget(#PB_Any, 30, 527, 60, 25, "X 3")
TextGadget(#PB_Any, 30, 558, 60, 25, "X 4")
TextGadget(#PB_Any, 30, 589, 60, 25, "X 5")
TextGadget(#PB_Any, 30, 620, 60, 25, "X 6")

TextGadget(#PB_Any, 330, 465, 120, 25,  "Calc")
TextGadget(#PB_Any, 330, 496, 120, 25,  "Calc")
TextGadget(#PB_Any, 330, 527, 120, 25,  "Calc")
TextGadget(#PB_Any, 330, 558, 120, 25,  "Calc")
TextGadget(#PB_Any, 330, 589, 120, 25,  "Calc")
TextGadget(#PB_Any, 330, 620, 120, 25,  "Calc")

; **
; **  Define input fields
; **
StringGadget(#PB_Any, 220, 70, 140, 25, "")
StringGadget(#PB_Any, 220, 101, 120, 25, "")
StringGadget(#PB_Any, 220, 132, 180, 25, "")
ComboBoxGadget(#PB_Any, 220, 163, 130, 25)
ComboBoxGadget(#PB_Any, 220, 194, 180, 25)

StringGadget(#PB_Any, 490, 460, 110, 25, "")
StringGadget(#PB_Any, 490, 491, 110, 25, "")
StringGadget(#PB_Any, 490, 522, 110, 25, "")
StringGadget(#PB_Any, 490, 553, 110, 25, "")
StringGadget(#PB_Any, 490, 584, 110, 25, "")
ComboBoxGadget(#PB_Any, 560, 615, 40, 25)

StringGadget(#PB_Any, 30, 250, 440, 25, "")
StringGadget(#PB_Any, 30, 281, 440, 25, "")
StringGadget(#PB_Any, 30, 312, 440, 25, "")
StringGadget(#PB_Any, 30, 343, 440, 25, "")
StringGadget(#PB_Any, 30, 374, 440, 25, "")

StringGadget(#PB_Any, 490, 416, 110, 25, "")
StringGadget(#PB_Any, 100, 460, 60, 25, "")
StringGadget(#PB_Any, 100, 491, 60, 25, "")
StringGadget(#PB_Any, 100, 522, 60, 25, "")
StringGadget(#PB_Any, 100, 553, 60, 25, "")
StringGadget(#PB_Any, 100, 584, 60, 25, "")
StringGadget(#PB_Any, 100, 615, 60, 25, "")


; **
; **  Set up right-side panel area
; **
Pg = PanelGadget(#PB_Any, 660, 70, 515, 630)
AddGadgetItem(Pg, -1, "Tab 1")

; **
; **  Define text labels
; **
TextGadget(#PB_Any, 30, 40, 100, 25,  "Calc")
TextGadget(#PB_Any, 30, 71, 100, 25,  "Calc")
TextGadget(#PB_Any, 30, 102, 100, 25, "Calc")
TextGadget(#PB_Any, 30, 133, 100, 25, "Calc")
TextGadget(#PB_Any, 30, 195, 100, 25, "Calc")
TextGadget(#PB_Any, 30, 226, 100, 25, "Calc")
TextGadget(#PB_Any, 30, 257, 100, 25, "Calc")
TextGadget(#PB_Any, 30, 288, 100, 25, "Calc")
TextGadget(#PB_Any, 30, 319, 100, 25, "Calc")
TextGadget(#PB_Any, 30, 350, 100, 25, "Calc")
TextGadget(#PB_Any, 30, 412, 100, 25, "Calc")
TextGadget(#PB_Any, 30, 443, 100, 25, "Calc")
TextGadget(#PB_Any, 30, 474, 100, 25, "Calc")
TextGadget(#PB_Any, 30, 505, 100, 25, "Calc")

; **
; **  Define input fields
; **
StringGadget(#PB_Any, 245, 35, 100, 25,  "")
StringGadget(#PB_Any, 175, 97, 30, 25,   "")
StringGadget(#PB_Any, 175, 314, 30, 25,  "")
StringGadget(#PB_Any, 245, 407, 100, 25, "")
StringGadget(#PB_Any, 175, 438, 30, 25,  "")
StringGadget(#PB_Any, 245, 66, 100, 25,  "")
StringGadget(#PB_Any, 245, 97, 100, 25,  "")
StringGadget(#PB_Any, 245, 128, 100, 25, "")
StringGadget(#PB_Any, 245, 190, 100, 25, "")
StringGadget(#PB_Any, 245, 221, 100, 25, "")
StringGadget(#PB_Any, 245, 252, 100, 25, "")
StringGadget(#PB_Any, 245, 283, 100, 25, "")
StringGadget(#PB_Any, 245, 314, 100, 25, "")
StringGadget(#PB_Any, 245, 345, 100, 25, "")
StringGadget(#PB_Any, 245, 438, 100, 25, "")
StringGadget(#PB_Any, 245, 469, 100, 25, "")
StringGadget(#PB_Any, 245, 500, 100, 25, "")

; **
; **  Tab 2
; **
AddGadgetItem(Pg, -1, "Tab 2")

; **
; **  Define text labels
; **
TextGadget(#PB_Any, 30, 40, 145, 25,  "Input")

; **
; **  Define input fields
; **
EditorGadget(#PB_Any, 30, 65, 445, 200, #PB_Editor_WordWrap)
CheckBoxGadget(#PB_Any, 30, 286, 250, 25, "Display")
CheckBoxGadget(#PB_Any, 30, 317, 250, 25, "Display")
CheckBoxGadget(#PB_Any, 30, 348, 250, 25, "Display")
CheckBoxGadget(#PB_Any, 30, 379, 250, 25, "Display")
CheckBoxGadget(#PB_Any, 30, 410, 250, 25, "Display")

; **
; **  Tab 3
; **
AddGadgetItem(Pg, -1, "Tab 3")

; **
; **  Define text labels
; **
TextGadget(#PB_Any, 30, 40, 160, 25,  "Input 1")
TextGadget(#PB_Any, 30, 71, 160, 25,  "Input 2")
TextGadget(#PB_Any, 30, 101, 160, 25, "Input 3")
TextGadget(#PB_Any, 30, 132, 160, 25, "Input 4")
TextGadget(#PB_Any, 30, 163, 160, 25, "Input 4")

; **
; **  Define input fields
; **
ComboBoxGadget(#PB_Any, 175, 35, 300, 25)
StringGadget(#PB_Any, 175, 66, 300, 25, "")
StringGadget(#PB_Any, 175, 97, 300, 25, "")
StringGadget(#PB_Any, 175, 128, 60, 25, "")
StringGadget(#PB_Any, 175, 159, 60, 25, "")

CloseGadgetList()

; **
; **  Main programme
; **
Repeat
  event = WaitWindowEvent()

  Select event
    Case #PB_Event_CloseWindow
      Break

  EndSelect
ForEver
End
Last edited by PBJim on Mon Nov 18, 2024 3:23 pm, edited 1 time in total.
User avatar
Kiffi
Addict
Addict
Posts: 1497
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Contents within PanelGadget appear slowly and untidily before panel is drawn around them

Post by Kiffi »

Possible workaround: Open the window with #PB_Window_Invisible and show it again with HideWindow() after creating the gadget .

Code: Select all

window1 = OpenWindow(#PB_Any, #PB_Ignore, #PB_Ignore, 1266, 780, "", #PB_Window_MinimizeGadget | #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_Invisible)
[...]
HideWindow(window1, #False)

; **  Main programme
[...]
Hygge
PBJim
Enthusiast
Enthusiast
Posts: 296
Joined: Fri Jan 19, 2024 11:56 pm

Re: Contents within PanelGadget appear slowly and untidily before panel is drawn around them

Post by PBJim »

Kiffi wrote: Mon Nov 18, 2024 11:36 am Possible workaround: Open the window with #PB_Window_Invisible and show it again with HideWindow() after creating the gadget .

Code: Select all

window1 = OpenWindow(#PB_Any, #PB_Ignore, #PB_Ignore, 1266, 780, "", [...] | #PB_Window_Invisible)
[...]
HideWindow(window1, #False)
That is fantastic Kiffi, it's works perfectly. It's interesting — the effect can be varied by the placement of the HideWindow(... #False). Just as an experiment, I put it after the panels are drawn. In that case the main screen draws first, but the panels then appear containing their gadgets, rather than the gadgets appearing before the panel.

Thanks a lot, appreciated.
Fred
Administrator
Administrator
Posts: 18199
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Contents within PanelGadget appear slowly and untidily before panel is drawn around them

Post by Fred »

When creating a lot of gadget, it's better to do it on an hidden window as they are displayed on the fly, so a lot of refresh happens.
PBJim
Enthusiast
Enthusiast
Posts: 296
Joined: Fri Jan 19, 2024 11:56 pm

Re: Contents within PanelGadget appear slowly and untidily before panel is drawn around them

Post by PBJim »

Fred wrote: Mon Nov 18, 2024 3:23 pm When creating a lot of gadget, it's better to do it on an hidden window as they are displayed on the fly, so a lot of refresh happens.
Thank you Fred, the gadgets are hugely interesting to work with, when coming from a non-GUI developer background. I noted, with the event loop, it draws only one single string or combobox gadget with each iteration of the loop, but for all text gadgets, they are drawn at once.

An interesting effect can be seen with this :

Code: Select all

; **
; **  Main programme
; **
Repeat
  event = WaitWindowEvent()
Delay(100)
  Select event
    Case #PB_Event_CloseWindow
      Break

  EndSelect
ForEver
User avatar
mk-soft
Always Here
Always Here
Posts: 6242
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: [SOLVED] Contents within PanelGadget appear slowly and untidily before panel is drawn around them

Post by mk-soft »

A TextGadget emit no events
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply