PureBasic Forum
http://forums.purebasic.com/english/

SweetyVD (Visual Designer)
http://forums.purebasic.com/english/viewtopic.php?f=12&t=68187
Page 4 of 11

Author:  ChrisR [ Tue May 02, 2017 9:46 am ]
Post subject:  Re: SweetyVD (Visual Designer)

Hi Little_man
Can you explain a little more, it is really worrying for the concept if it does not work for all.
Edit:
Little_man wrote:
Problem solved

Removed and reinstalled purebasic 5.60.
OK Thanks :)

I had prepared this for testing, a simple example to move a button and display a grid, based on same concept (canvas + Gadget in overlay).
Code:
Enumeration FormWindow
  #WinMain
EndEnumeration

Enumeration FormGadget
  #GridCanvas
  #Text
  #Canvas
  #Button
EndEnumeration

Declare OpenMainWindow(x = 0, y = 0, width = 340, height = 240)
Declare ShowGrid()
Declare MouseEvent()

Procedure ShowGrid()
  Protected X.i, Y.i
  Static GridDisplayed.b
 
  Select EventType()
    Case #PB_EventType_LeftButtonDown
      If StartDrawing(CanvasOutput(#GridCanvas))
        If GridDisplayed = #False
          Box(0, 0, OutputWidth(), OutputHeight(), $EBE6E1)
          For X = 0 To OutputWidth()
            For Y = 0 To OutputHeight()
              Line(0, Y, OutputWidth(), 1, $CCCCCC)
              Y+19
            Next
            Line(X, 0, 1, OutputHeight(), $CCCCCC)
            X+19
          Next
          GridDisplayed = #True
        Else
          Box(0, 0, OutputWidth(), OutputHeight(), $F0F0F0)
          GridDisplayed = #False
        EndIf
       StopDrawing()
      EndIf
       
  EndSelect
EndProcedure

Procedure MouseEvent()
  Static ButtonSelected.b, OffsetX, OffsetY
 
  Select EventType()
    Case #PB_EventType_LeftButtonDown
      ButtonSelected = #True
      OffsetX = GetGadgetAttribute(#Canvas, #PB_Canvas_MouseX)
      OffsetY = GetGadgetAttribute(#Canvas, #PB_Canvas_MouseY)
     
    Case #PB_EventType_LeftButtonUp
      ButtonSelected = #False
     
    Case #PB_EventType_MouseMove
      If ButtonSelected
        ResizeGadget(#Canvas, WindowMouseX(#WinMain)-OffsetX, WindowMouseY(#WinMain)-OffsetY ,#PB_Ignore, #PB_Ignore)
        ResizeGadget(#Button, WindowMouseX(#WinMain)-OffsetX, WindowMouseY(#WinMain)-OffsetY ,#PB_Ignore, #PB_Ignore)
      EndIf

   EndSelect
EndProcedure
       
Procedure OpenMainWindow(x = 0, y = 0, width = 340, height = 240)
  OpenWindow(#WinMain, x, y, width, height, "Click and Move Button + Grid", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
  CanvasGadget(#GridCanvas, x, y, width, height, #PB_Canvas_Container)
  If StartDrawing(CanvasOutput(#GridCanvas))
    Box(0, 0, OutputWidth(), OutputHeight(), $F0F0F0)
    StopDrawing()
  EndIf
  TextGadget(#Text, 100, 220, 140, 20, "Click to show/hide the grid", #PB_Text_Center)
  CanvasGadget(#Canvas, 100, 80, 140, 60)
  SetGadgetAttribute(#Canvas, #PB_Canvas_Cursor, #PB_Cursor_Arrows)
  ButtonGadget(#Button, 100, 80, 140, 60, "Click and Move")
  CompilerIf #PB_Compiler_OS = #PB_OS_MacOS : DisableGadget(#Button, #True) : EndIf
EndProcedure

OpenMainWindow()
BindGadgetEvent(#GridCanvas, @ShowGrid(), #PB_EventType_LeftButtonDown)
BindGadgetEvent(#Canvas, @MouseEvent(), #PB_EventType_LeftButtonDown)
BindGadgetEvent(#Canvas, @MouseEvent(), #PB_EventType_LeftButtonUp)
BindGadgetEvent(#Canvas, @MouseEvent(), #PB_EventType_MouseMove)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow


Edit: Disable button Gadget for OSX (see below)

Author:  Mindphazer [ Wed May 03, 2017 9:20 am ]
Post subject:  Re: SweetyVD (Visual Designer)

The click and move doesn't work on OS X...

Author:  ChrisR [ Wed May 03, 2017 11:05 am ]
Post subject:  Re: SweetyVD (Visual Designer)

Bonjour Mindphazer,
Sadly, I do not have a Mac to test.
I have seen some tuto to install an OSX eval in VMware, I have to look at.
Does anyone have a trick ?

I was able to test it quickly, a little while ago on the PC of an uncle at a family celebration.
And indeed, unlike Windows and Linux, the Gadgets remain active over the canvas and thus we can not directly select them.
However, in my quick test, it was possible to select and move the gadgets using the border. Is it still the case ?
For Mac, I enlarged the border from 1px to 3px for that but it's not the best.

A basic idea, can you do a quick test by adding in CreateGadgets Procedure
Code:
If DrawGadget = #False : DisableGadget(IdGadget, #True) : EndIf
Just before the comment
Code:
;Save gadget information in the gadget List
To see!

Author:  Mindphazer [ Wed May 03, 2017 1:11 pm ]
Post subject:  Re: SweetyVD (Visual Designer)

The click & move doesn't work on your example code above

In VD, it's still possible to select a gadget using its border.
I have tried to add the line in the procedure, but Drawgadget is not declared

Author:  ChrisR [ Wed May 03, 2017 1:50 pm ]
Post subject:  Re: SweetyVD (Visual Designer)

Ha, OK, in the above code example
For OSX, I think you should Disable the Button Gadget:
Code:
ButtonGadget(#Button, 100, 80, 140, 60, "Click and Move") : DisableGadget(#Button, #True)

For the line to add to sweetyvd.pb, I guess you did not put it at the right place,
Line 689 in latest github release, DrawGadget variable exists there
Code:
          If Model <> "TabBarGadget" And DrawGadget = #False : SetGadgetData(IdGadget, CountGadgets) : EndIf   ;Add Gadget Counter to Gadget Data
         
          ;Save gadget information in the gadget List
==>
Code:
          If Model <> "TabBarGadget" And DrawGadget = #False : SetGadgetData(IdGadget, CountGadgets) : EndIf   ;Add Gadget Counter to Gadget Data
          If DrawGadget = #False : DisableGadget(IdGadget, #True) : EndIf   ;<==
          ;Save gadget information in the gadget List


Congratulation for your next post the 100th :wink:

Author:  Mindphazer [ Wed May 03, 2017 2:25 pm ]
Post subject:  Re: SweetyVD (Visual Designer)

ChrisR wrote:
For OSX, I think you should Disable the Button Gadget:
Code:
ButtonGadget(#Button, 100, 80, 140, 60, "Click and Move") : DisableGadget(#Button, #True)

Works better !
ChrisR wrote:
For the line to add to sweetyvd.pb, I guess you did not put it at the right place,
Line 689 in latest github release, DrawGadget variable exists there
Code:
          If Model <> "TabBarGadget" And DrawGadget = #False : SetGadgetData(IdGadget, CountGadgets) : EndIf   ;Add Gadget Counter to Gadget Data
         
          ;Save gadget information in the gadget List
==>
Code:
          If Model <> "TabBarGadget" And DrawGadget = #False : SetGadgetData(IdGadget, CountGadgets) : EndIf   ;Add Gadget Counter to Gadget Data
          If DrawGadget = #False : DisableGadget(IdGadget, #True) : EndIf   ;<==
          ;Save gadget information in the gadget List

Oooops ! My bad, i didn't have the last version !
Now the gadget can be moved wherever it is clicked
Unfortunately, drag'n'drop still doesn't work on OSX, but it's not your fault !

ChrisR wrote:
Congratulation for your next post the 100th :wink:

Hé hé thank you ! :wink:

Author:  ChrisR [ Wed May 03, 2017 3:06 pm ]
Post subject:  Re: SweetyVD (Visual Designer)

Mindphazer wrote:
ChrisR wrote:
Now the gadget can be moved wherever it is clicked

Great, thanks Mindphazer for the test :)
I will modify accordingly for OS X.

Author:  Mindphazer [ Wed May 03, 2017 3:19 pm ]
Post subject:  Re: SweetyVD (Visual Designer)

ChrisR wrote:
Great, thanks Mindphazer for the test :)
I will modify accordingly for OS X.

You're welcome !!
I'd be glad to keep on testing further versions

Author:  Zebuddi123 [ Wed May 03, 2017 11:53 pm ]
Post subject:  Re: SweetyVD (Visual Designer)

Hi ChrisR Just downloaded 1.8.0 Again have`nt had much time :( to analyse your code but I have adapted CodeCreate() to my personel preferences ie. i,s,b,w..... prefixes and postfixes .i .s etc for variables type. Removed declare procedure() as not needed unless procedure replaced after procedure call and you code with that paradigm. I was also thinking about a adding StringGadget() and checkBoxGadget() for declaring variable prefix and postfix respectively.

Found a drawing glitch in dragging IPGadget() as below, also just checked v1.6.0 with the same effect.

Zebuddi. :)

Image
Image

Author:  ChrisR [ Thu May 04, 2017 5:54 pm ]
Post subject:  Re: SweetyVD (Visual Designer)

Hi Zebuddi,
With latest version 1.9.0, you can easily add prefixes by customizing the Gadgets models properties, in SweetyVD.json file.
It is created at first run and can be modified with notepad or other.

To do this, just change the name value as you wish. Ex here with TextGadget. Default Name = "Text" changed here to "sText" or "TextBox",...
For each Gadget, you can also change the default width and height
and possibly the default properties by keeping the current tags (#Text:, #Mini:, #Maxi,...). Ex here with "#Text:My Default Text"
And for Constants use the suffix (x) to choose the one activated by default.
Enlighten me, I do not really understand your use for Postfixes, they are GadgetID!
Code:
    "Model"            : "TextGadget",
    "Name"             : "sText",
    "Caption"          : "#Text:My Default Text",
    "DftWidth"         : 100,
    "DftHeight"        : 20,
    "Constants"        : "Text_Center|Text_Right(x)|Text_Border",

#
Do you reproduce the same with the latest version 1.9.0 ?
With the concept on true gadgets, there are some lags displays indeed, some already solved with for example containers and frame gadget drawn now.
I also added (not yet on Github) the resize (=WM_PAINT) of all the gadgets after a moving or resize, on KeyUp Event.
It should be a little better

Author:  Zebuddi123 [ Thu May 04, 2017 6:00 pm ]
Post subject:  Re: SweetyVD (Visual Designer)

Hi ChrisR That`s spooky Just this very minute I`m Implementing a ButtonGadget() for a pre/post fix design window after the #GridSpacing gadget lol. I`ll get the latest download and have a look. Hope your enjoying programming SweetyVD as much as I like using it!!! :)

Zebuddi. :)

Author:  Zebuddi123 [ Thu May 04, 2017 6:13 pm ]
Post subject:  Re: SweetyVD (Visual Designer)

Hi ChrisR We have a draw issue when after adding gadgets and the using the preview, no gadgets are displayed unless the mouse hovers over the gadget positions, which draws the gadgets but corrupts the gadgets also if you move the horizontal scroller the gadgets are redrawn correctly.

The Ipgadget() issue has been resolved :) Thanks.


In compiler option menu --> tab Constants --> Custom Constants: I have added "#BuildVersion" and set it to current version "1.0.9" and added the constant to the main windowTitle just so I know i`m running the current version. Not sure if you have seen this option. Something you might want to do. :)

Zebuddi. :)

Author:  ChrisR [ Thu May 04, 2017 6:32 pm ]
Post subject:  Re: SweetyVD (Visual Designer)

Thanks, I have seen also for the Preview/Designer switch, it's fixed now but not on github yet.
I keep taking pleasure to develop it but I miss a bit of time and more precisely several hours at a time to develop Some tricks

Author:  tester [ Thu May 04, 2017 7:05 pm ]
Post subject:  Re: SweetyVD (Visual Designer)

ChrisR wrote:
Don't be sorry, it is good to fix bugs I did not see :wink:

Got it, in Line 1008 change
Code:
For J=1 To ArraySize(ModelGadget())
==>
Code:
For J=0 To ArraySize(ModelGadget())
I did not see it first because in my JSON file, OpenWindow (Type=0) was at the beginning => ModelGadget() array element 0 ...


In Line 1537 change too:
Code:
Case 1 To 31   ;Popup menu for creating gadgets
==>
Code:
Case 0 To ArraySize(ModelGadget())   ;Popup menu for creating gadgets

ChrisR, Thank you so much for your long-awaited program.

Author:  ChrisR [ Fri May 05, 2017 3:54 pm ]
Post subject:  Re: SweetyVD (Visual Designer)

I added the custom Constants #BuildVersion Zebuddi. Thanks
@tester, thanks however it is is not really required here, for the Popup menu
Given your Nickname, I will wait for test results from you in next releases. You are welcome :wink:
I finished some additions, I am updating now...

Page 4 of 11 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/