Look what I've just added...
automatic resizing
Each gadgets can now be assigned two new flags: width / height relative to parent.
If these flags are assigned, the generated code will compute the width / height according to the parent (either the window or a container).
You just have to check the flag, you can still input the width/height or resize the gadgets as you wish, the FD computes the differences all by itself!
You'll end up with a generated code like this:
Code: Select all
Procedure InitWindow_0()
Window_0 = OpenWindow(#PB_Any, 0, 0, 600, 400, "", #PB_Window_SystemMenu)
Panel_0 = PanelGadget(#PB_Any, 10, 10, 300, WindowHeight(Window_0) - 20)
AddGadgetItem(Panel_0, -1, "Tab 1")
ScrollArea_0 = ScrollAreaGadget(#PB_Any, 0, 0, GetGadgetAttribute(Panel_0,#PB_Panel_ItemWidth) - 10, GetGadgetAttribute(Panel_0,#PB_Panel_ItemHeight) - 10, 380, 560,1)
CloseGadgetList()
CloseGadgetList()
EndProcedure
(which was tricky to parse back

)
I also added a ResizeGadgets procedure that you can use if you want, it looks like this:
Code: Select all
Procedure ResizeGadgetsWindow_0()
ResizeGadget(Panel_0, 10, 10, 300, WindowHeight(Window_0) - 20)
ResizeGadget(ScrollArea_0, 0, 0, GetGadgetAttribute(Panel_0,#PB_Panel_ItemWidth) - 10, GetGadgetAttribute(Panel_0,#PB_Panel_ItemHeight) - 10)
EndProcedure
Just add a call to ResizeGadgetsWindow_0() in your window event procedure and all the gadgets are resized automatically!
I used to spend hours typing all ResizeGadget so that they correctly resize everything, it's just amazing not having to do it anymore.
Huge work implementing this though...!
You can test the generated code here (I just added an event loop for testing):
Code: Select all
; Form Designer for Purebasic - 5.0
; Warning: this file uses a strict syntax, if you edit it, make sure to respect the Form Designer limitation or it won't be opened again.
Global Window_0
Global Panel_0, ScrollArea_0
Declare ResizeGadgetsWindow_0()
Procedure InitWindow_0()
Window_0 = OpenWindow(#PB_Any, 0, 0, 600, 400, "", #PB_Window_SystemMenu | #PB_Window_SizeGadget)
Panel_0 = PanelGadget(#PB_Any, 10, 10, 300, WindowHeight(Window_0) - 20)
AddGadgetItem(Panel_0, -1, "Tab 1")
ScrollArea_0 = ScrollAreaGadget(#PB_Any, 0, 0, GetGadgetAttribute(Panel_0,#PB_Panel_ItemWidth) - 10, GetGadgetAttribute(Panel_0,#PB_Panel_ItemHeight) - 10, 380, 560,1)
CloseGadgetList()
CloseGadgetList()
EndProcedure
Procedure ResizeGadgetsWindow_0()
ResizeGadget(Panel_0, 10, 10, 300, WindowHeight(Window_0) - 20)
ResizeGadget(ScrollArea_0, 0, 0, GetGadgetAttribute(Panel_0,#PB_Panel_ItemWidth) - 10, GetGadgetAttribute(Panel_0,#PB_Panel_ItemHeight) - 10)
EndProcedure
Procedure Window_0_Events(event)
Select event
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
EndSelect
EndProcedure
; --- end of generated code ---
InitWindow_0()
Repeat
event = WaitWindowEvent()
If event = #PB_Event_SizeWindow
ResizeGadgetsWindow_0()
EndIf
Until event = #PB_Event_CloseWindow