Page 19 of 45

Re: Form Designer for Mac/Windows/Linux -5.00b2

Posted: Sun Sep 02, 2012 12:29 pm
by freak
Polo wrote:
Andre wrote:I just thought, it will speed up things when using a lot of gadgets, and also the generated code is better readable.
That's true, though for gadget resizing inside a container there's the same issue then!
I always had in my mind that PB buffered that kind of data, we'll see what Fred or Timo say about that - if it's not buffered I'll make the change, if it is buffered I'd rather leave the functions directly :)
Those values are not buffered. Each call to WindowWidth() is an API call to measure the width. Whether the API does caching, I don't know.

Re: Form Designer for Mac/Windows/Linux -5.00b2

Posted: Sun Sep 02, 2012 12:52 pm
by Polo
freak wrote:Those values are not buffered. Each call to WindowWidth() is an API call to measure the width. Whether the API does caching, I don't know.
Thanks Timo!

Re: Form Designer for Mac/Windows/Linux -5.00b2

Posted: Sun Sep 02, 2012 12:54 pm
by Fangbeast
Really good work Polo. My eyes get worse every year but your layout seems easy to see for me.

Re: Form Designer for Mac/Windows/Linux -5.00b2

Posted: Sun Sep 02, 2012 1:07 pm
by Polo
Changed the calls to temp values.
Note that dynamic calls are kept for gadgets inside containers.

Code: Select all

Global Window_0

Global Button_0, Button_0_1, Tree_0, Panel_0, Scrollbar_0, Scrollbar_1

Declare ResizeGadgetsWindow_0()

Procedure InitWindow_0()
  Protected WindowWidth, WindowHeight
  Window_0 = OpenWindow(#PB_Any, 0, 0, 600, 400, "", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget)
  WindowWidth = WindowWidth(Window_0)
  WindowHeight = WindowHeight(Window_0)
  Button_0 = ButtonGadget(#PB_Any, WindowWidth - 100, WindowHeight - 30, 90, 25, "Save")
  Button_0_1 = ButtonGadget(#PB_Any, WindowWidth - 200, WindowHeight - 30, 90, 25, "Cancel")
  Tree_0 = TreeGadget(#PB_Any, 10, 10, 210, WindowHeight - 50)
  Panel_0 = PanelGadget(#PB_Any, 230, 10, WindowWidth - 240, WindowHeight - 50)
  AddGadgetItem(Panel_0, -1, "Tab 1")
  Scrollbar_0 = ScrollBarGadget(#PB_Any, 10, GetGadgetAttribute(Panel_0,#PB_Panel_ItemHeight) - 23, GetGadgetAttribute(Panel_0,#PB_Panel_ItemWidth) - 20, 20, 0, 0, 0)
  Scrollbar_1 = ScrollBarGadget(#PB_Any, GetGadgetAttribute(Panel_0,#PB_Panel_ItemWidth) - 20, 0, 20, GetGadgetAttribute(Panel_0,#PB_Panel_ItemHeight) - 30, 0, 0, 0, #PB_ScrollBar_Vertical)
  CloseGadgetList()
EndProcedure

Procedure ResizeGadgetsWindow_0()
  Protected WindowWidth, WindowHeight
  WindowWidth = WindowWidth(Window_0)
  WindowHeight = WindowHeight(Window_0)
  ResizeGadget(Button_0, WindowWidth - 100, WindowHeight - 30, 90, 25)
  ResizeGadget(Button_0_1, WindowWidth - 200, WindowHeight - 30, 90, 25)
  ResizeGadget(Tree_0, 10, 10, 210, WindowHeight - 50)
  ResizeGadget(Panel_0, 230, 10, WindowWidth - 240, WindowHeight - 50)
  ResizeGadget(Scrollbar_0, 10, GetGadgetAttribute(Panel_0,#PB_Panel_ItemHeight) - 23, GetGadgetAttribute(Panel_0,#PB_Panel_ItemWidth) - 20, 20)
  ResizeGadget(Scrollbar_1, GetGadgetAttribute(Panel_0,#PB_Panel_ItemWidth) - 20, 0, 20, GetGadgetAttribute(Panel_0,#PB_Panel_ItemHeight) - 30)
EndProcedure

Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
  EndSelect
EndProcedure

InitWindow_0()

Repeat
  event = WaitWindowEvent()
  
  If event = #PB_Event_SizeWindow
    ResizeGadgetsWindow_0()
  EndIf
  
Until event = #PB_Event_CloseWindow

Re: Form Designer for Mac/Windows/Linux -5.00b2

Posted: Sun Sep 02, 2012 1:47 pm
by luciano
Good news:
Form Designer will make Purebasic even easier and more productive to use, for me it is the best improvement of PB 5.00

Bad news:
a glitch,
to recreate the bug you should start FD and create a simple form and save this, e.g.:

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 Image_0

Global Img_0

UsePNGImageDecoder()

Img_0 = LoadImage(#PB_Any,"C:\aqua-ball-green.png")

Procedure InitWindow_0()
  Window_0 = OpenWindow(#PB_Any, 0, 0, 600, 400, "", #PB_Window_SystemMenu)
  Image_0 = ImageGadget(#PB_Any, 80, 40, 128, 128, ImageID(Img_0))
EndProcedure


Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
  EndSelect
EndProcedure


now close FD and open it again, then open the previously saved file.
Add a new gadget as the one which existed, FD will use again the default gadget number: you will end with two gadgets with the same number.
I realized when I saw two gadgets responding to the same event :-)

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 Image_0, Image_0

Global Img_0, Img_1

UsePNGImageDecoder()

Img_0 = LoadImage(#PB_Any,"C:\aqua-ball-green.png")
Img_1 = LoadImage(#PB_Any,"C:\Golf ball.png")

Procedure InitWindow_0()
  Window_0 = OpenWindow(#PB_Any, 0, 0, 600, 400, "", #PB_Window_SystemMenu)
  Image_0 = ImageGadget(#PB_Any, 80, 40, 128, 128, ImageID(Img_0))
  Image_0 = ImageGadget(#PB_Any, 230, 110, 64, 64, ImageID(Img_1))
EndProcedure


Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
  EndSelect
EndProcedure


Re: Form Designer for Mac/Windows/Linux -5.00b2

Posted: Sun Sep 02, 2012 1:54 pm
by Polo
Thanks Luciano!
I know about the gadget variable numbering - however I don't know of any easy way to handle this properly.
At the moment I just store a count per gadget (and it's not even window based) and the counts don't get updated when loading a file (that'd be quite messy)

Re: Form Designer for Mac/Windows/Linux -5.00b2

Posted: Sun Sep 02, 2012 2:18 pm
by luciano
I'm afraid my solution is not an easy one.
Since the problem should arise only with default names, I suggest to parse the code for default names (e.g. image_xx) and when one is found and if your counter is lower then increase the variable counter to image_xx+1

these names were progressively named instead:

Code: Select all

Img_0 = LoadImage(#PB_Any,"C:\aqua-ball-green.png")
Img_1 = LoadImage(#PB_Any,"C:\Golf ball.png")

Re: Form Designer for Mac/Windows/Linux -5.00b2

Posted: Sun Sep 02, 2012 2:19 pm
by Polo
Yes the images use dynamic names so the problem can't happen on this!
I'm gonna add the count on a per window basic first, then add it to the parser, that's important to have something that works well :)

Re: Form Designer for Mac/Windows/Linux -5.00b2

Posted: Sun Sep 02, 2012 2:33 pm
by luciano
Your image management is super fantastic,
I tested hard to break it using repated images in the form, but I could never fool it and FD generates a real optimized code, avoiding useless repeated image loading!

Re: Form Designer for Mac/Windows/Linux -5.00b2

Posted: Sun Sep 02, 2012 2:44 pm
by Polo
luciano wrote:avoiding useless repeated image loading!
This was reaaaally annoying to do :mrgreen:
Though it has to be done, considering how much memory images can use.

I added the fix for variable numbering when opening files. Variable numering is on a per window basis now which is much better.
Thanks for reporting this, otherwise i would have been too lazy to do it! ;)

Re: Form Designer for Mac/Windows/Linux -5.00b2

Posted: Sun Sep 02, 2012 3:21 pm
by Polo
I won't do intermediate releases now it's part of the official PB package, though as this still is an early beta and considering I've changed quite a few things, here's a new beta for you to test. Language files are not included.

This is for OSX, Windows and Linux.

http://www.gdpcomputing.co.uk/formdesigner.html

Please test! :)
(Andre, let me know if this version works for you, I've still not been able to install OSX Leopard).

Re: Form Designer for Mac/Windows/Linux -5.00b2 (update!)

Posted: Sun Sep 02, 2012 3:45 pm
by ts-soft
I think, it is time to add more settings in preferences, for example:
Position and size of FormDesigner,
Default Value for: x, y, width and height of new Window
Default Value for flags (Window)
Default Value for Create Events or not.

Thats not all, but i think the most missing :wink:

Greetings - Thomas

Re: Form Designer for Mac/Windows/Linux -5.00b2 (update!)

Posted: Sun Sep 02, 2012 3:47 pm
by Polo
Added to todo list :)

By the way, the preferences window in next version will be a .pbf file :P

Re: Form Designer for Mac/Windows/Linux -5.00b2 (update!)

Posted: Sun Sep 02, 2012 4:32 pm
by luciano
Gaetan, I have been fully immersed in your latest release.
WWWWOOOOOWWWW
It is a resized wow :-)

Re: Form Designer for Mac/Windows/Linux -5.00b2 (update!)

Posted: Sun Sep 02, 2012 4:36 pm
by ts-soft
Polo wrote:By the way, the preferences window in next version will be a .pbf file :P
Okay, a Template-File, good idea! :D