ContainerGadget + ResizeGadget() ignores #PB_Ignore

Found an issue in SpiderBasic ? Please report it here !
blz
Posts: 7
Joined: Wed Apr 14, 2021 12:40 pm

ContainerGadget + ResizeGadget() ignores #PB_Ignore

Post by blz »

Please see below example.
Thanks,

Code: Select all

; ContainerGadget + ResizeGadget() ignores #PB_Ignore and keeps expanding both x&y directions

Enumeration
  #win0
EndEnumeration

Enumeration Gadgets
  #Container0
  #Button0
EndEnumeration

Procedure SizeWindowEvent()
  Select EventWindow()
    Case #win0
      ; #PB_Ignore is used here BUT #Container0 just keeps expanding x&y
      ResizeGadget(#Container0, #PB_Ignore, #PB_Ignore, #PB_Ignore, #PB_Ignore)
      
      ; Workaround: Container's w&h must be explicitly controlled
      ;   Comment above, uncomment below ResizeGadget() line
      ;ResizeGadget(#Container0, #PB_Ignore, #PB_Ignore, WindowWidth(#win0)-20, WindowHeight(#win0)-80)
      
      ; This is just to see that ButtonGadget is not affected by this issue. Not sure about other gadgets though.
      ResizeGadget(#Button0, #PB_Ignore, #PB_Ignore, #PB_Ignore, #PB_Ignore)  ; #PB_Ignore -> as expected, size is NOT affected
      
  EndSelect
EndProcedure

Procedure GadgetEvent()
  Select EventGadget()
    Case #Container0
      Debug "#Container0 resized..."  ; just to see if Event is being fired during resize
  EndSelect
  
EndProcedure

BindEvent(#PB_Event_SizeWindow, @SizeWindowEvent())
BindEvent(#PB_Event_Gadget, @GadgetEvent())

If OpenWindow(#win0, 100, 200, 300, 150, "Container WIDTH & HEIGHT should not be expanding", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
  ContainerGadget(#Container0, 10, 10, 280, WindowHeight(#win0)-80, #PB_Container_Raised)
  ButtonGadget(#Button0, 20, 20, 100, WindowHeight(#win0)-125, "Button 0")
  CloseGadgetList()
EndIf
User avatar
Peter
Posts: 888
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: ContainerGadget + ResizeGadget() ignores #PB_Ignore

Post by Peter »

Confirmed.

This is related to the Container-Border.

The Container without a border is not resized:

Code: Select all

[...]
If OpenWindow(#win0, 100, 200, 300, 150, "Container WIDTH & HEIGHT should not be expanding", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
  
  ContainerGadget(#Container0, 10, 10, 280, WindowHeight(#win0)-80)
    ButtonGadget(#Button0, 20, 20, 100, WindowHeight(#win0)-125, "Button 0")
  CloseGadgetList()
  
  SetGadgetColor(#Container0, #PB_Gadget_BackColor, #Red)
  
EndIf
[...]
blz
Posts: 7
Joined: Wed Apr 14, 2021 12:40 pm

Re: ContainerGadget + ResizeGadget() ignores #PB_Ignore

Post by blz »

Thanks for having a look, Peter.
I haven't tested it without the border, good to know it works without one.
Post Reply