Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
vs GUI Updates - the latest from b+
#31
OK done! and I found out I had to fix the drwPic code in the BM. Now I have Horizontal slider code and some practice using it.

Here is a brief graph of what variables L, B, D and w represent from the article vince took the equation from:
   

And here is my vs GUI with sliders reshaping the Egg
   

And the zip package of project:


Attached Files
.zip   vs GUI b+ mod vince Designer Egg.zip (Size: 557.93 KB / Downloads: 68)
b = b + ...
Reply
#32
wow, nice mod B+, very well composed. It is interesting how you can edit the number textboxes but the sliders overrule. First look at the code, it does look tricky to program, I will take a closer look and see
Reply
#33
Hi vince, 

Yeah about the text boxes, I started with the picture and one textbox to test changes in w, and a button to redraw with text box value. It soon became obvious that a slider would be way more fun so I dumped the redraw button and used the text boxes as labels to show where the sliders were at number wise. I should change the Text boxes to labels.

When I was doing this I came to realization that it is bad idea to lock all the library code up in a separate module. You can't possibly do GUI without knowing those routines like the back of your hand. I am constantly referring back to them to check on some detail. Eh, there has got to be a better way.

Even though I don't want to add a slider control to the list, we could add a Slider type to store slider data and have a common sub to handle the different sliders.
b = b + ...
Reply
#34
I just noticed there's another file, B+ vs GUI.txt, which is a nice write-up and should be helpful. I think the main issue with all these GUI toolkits, inform included, is that they don't really fit any kind of niche to be reused by the community at large. If I wanted GUI elements in my QB64 mods I'd probably prefer to roll my own in true BASIC spirit and it would likely end up being simpler than adapting a more fully-featured library. ie just hard-code a couple of buttons and sliders and be done with it. If I wanted something truly fully featured industry-standard GUI in the realm of GTK or windows API or similar then I'd look well away from QB64 as the base language.
Reply
#35
I don't know, it is very handy to do multiple inputs, multiple lists, multiple buttons is pretty easy but doing the mouse zone stuff for them could get boring. Here it's all setup in a GUI. I am not going to call it vs any more because it is not that simple to learn to use it, you might actually have to spend an hour or so learning and more hours of practice.

But again it is handy for multiple's specially List Boxes and Text Boxes. The BM code is still under 1K if you remove all the comments I add and lot's of handy stuff you'd want in any app, filled circles and triangles, Split and Join, Directory and File lists.

The Accounts Tracker is basically an Fields Editor for a Database app, with a tiny bit of calculation going on for one of the Fields.
b = b + ...
Reply
#36
Ha, now with that pep talk I can go back to Controls Editor and throw out the Get_Filename controls because it is working just fine as an independent program called in a Shell to get a pathed filename PLUS you can do other stuff with it like Kill some files you dont need anymore while you are browsing your system.

And rewrite the egg designer thing with Slider Type setup and common sub plus probably a Dim Shared Slider array, (text boxes converted to labels).
b = b + ...
Reply
#37
OK I have reworked the slider code. Since it comes in a picture box there is already a label we can use to keep it self contained all-in-one slider box.

and I reworked it again 2022-08-12, sorry just trying to get it right! The 3.4100000001 values in slider labels were making me crazy when they were supposed to be 3.41! So I added Steve's N2S$ for converting sci notation to normal layman and added my Round2$ function for rounding the display number to dp or 10^dp place in the decimal number eg, -2 = hundreths

Here is screen shot of the remake 2022-08-12:
   
I used 2 decimals with first slider, w, 3 for next, D, and 4 decimals for last two variables L, B.

And look how simple the code is! (2022-08-12 code just added 4 lines to code posted yesterday)

Code: (Select All)
Option _Explicit ' b+ 2022-08-11 & 12
'$include:'vs GUI.BI'

'   Set Globals from BI
Xmax = 1210: Ymax = 620: GuiTitle$ = "remake GUI b+ Mod of vince Designer Egg"
OpenWindow Xmax, Ymax, GuiTitle$, "arial.ttf" ' << arial works well for pixel sizes 6 to 128 .FontH
_ScreenMove 30, 40 ' <<< centers for a 1380 x 700 Screen area, you may prefer another center
' GUI Controls
'                     Dim and set Globals for GUI app
Dim Shared As Long picEgg, picw, picD, picL, picB
picEgg = NewControl(5, 10, 10, 800, 600, 20, 40, 393, "Designer Egg")
picw = NewControl(5, 820, 64, 380, 65, 18, 999, 555, "")
picD = NewControl(5, 820, 203, 380, 65, 18, 999, 555, "")
picL = NewControl(5, 820, 342, 380, 65, 18, 999, 555, "")
picB = NewControl(5, 820, 481, 380, 65, 18, 999, 555, "")
' End GUI Controls

Dim Shared S, B, L, w, D ' globals for Egg drawing
S = 80: L = 5.4: B = 4.1: w = .4: D = 3.2 '< These are Vince starting parameter values for good egg

Dim Shared Sliders(3) As Slider
Sliders(0).Label = "w = "
Sliders(0).Low = 0
Sliders(0).High = 1
Sliders(0).Value = .4
Sliders(0).DecPt = -2

Sliders(1).Label = "D = "
Sliders(1).Low = 2.8
Sliders(1).High = 3.6
Sliders(1).Value = 3.2
Sliders(1).DecPt = -3

Sliders(2).Label = "L = "
Sliders(2).Low = 4.4
Sliders(2).High = 6.4
Sliders(2).Value = 5.4
Sliders(2).DecPt = -4

Sliders(3).Label = "B = "
Sliders(3).Low = 3.6
Sliders(3).High = 4.6
Sliders(3).Value = 4.1
Sliders(3).DecPt = -4

drwEgg ' up date picEgg
drwHSlider picw, 0, -1
drwHSlider picD, 1, -1
drwHSlider picL, 2, -1
drwHSlider picB, 3, -1
MainRouter ' after all controls setup

Sub BtnClickEvent (i As Long)
    i = i
End Sub

Sub LstSelectEvent (control As Long)
    control = control
End Sub

Sub PicClickEvent (i As Long, Pmx As Long, Pmy As Long)
    Pmy = Pmy
    Select Case i
        Case picw
            drwHSlider picw, 0, Pmx
            w = Sliders(0).Value
            drwEgg
        Case picD
            drwHSlider picD, 1, Pmx
            D = Sliders(1).Value
            drwEgg
        Case picL
            drwHSlider picL, 2, Pmx
            L = Sliders(2).Value
            drwEgg
        Case picB
            drwHSlider picB, 3, Pmx
            B = Sliders(3).Value
            drwEgg
    End Select
End Sub

Sub PicFrameUpdate (i As Long)
    i = i
End Sub

Sub drwEgg ' makes an image the size of the picBox and give it the picEgg N1 handle
    Dim xx, x, a, y, aa, sh, sw
    Dim As Long sd
    sh = Con(picEgg).H: sw = Con(picEgg).W
    sd = _Dest
    _Dest Con(picEgg).N1
    Line (0, 0)-(Con(picEgg).W, Con(picEgg).H), &HFF000000, BF ' cls

    For xx = -0.5 * L * S To 0.5 * L * S
        x = xx / S
        a = (L * L - 4 * x * x) / (L * L + 8 * w * x + 4 * w * w)
        y = 0.5 * B * Sqr(a)
        'you can stop here for p(x) = x

        a = Sqr(5.5 * L * L + 11 * L * w + 4 * w * w)
        a = a * (Sqr(3) * B * L - 2 * D * Sqr(L * L + 2 * w * L + 4 * w * w))
        a = a / (Sqr(3) * B * L * (Sqr(5.5 * L * L + 11 * L * w + 4 * w * w) - 2 *_
         Sqr(L * L + 2 * w * L + 4 * w * w)))

        aa = L * (L * L + 8 * w * x + 4 * w * w)
        aa = aa / (2 * (L - 2 * w) * x * x + (L * L + 8 * L * w - 4 * w * w) * x +_
         2 * L * w * w + L * L * w + L * L * L)
        aa = 1 - aa

        y = y * (1 - a * aa)

        Line (sw / 2 + xx, sh / 2 - S * y)-(sw / 2 + xx, sh / 2 + S * y), &HFFFFFFFF
    Next
    'ok now that N1 has been updated
    _Dest sd
    drwPic picEgg, 0
End Sub

'$include:'vs GUI.BM'
 
Perfect little demo for horz. sliders

Zip has the revised BI/BM code to do the new sliders.

EDIT 2022-08-12 everything completely changed out for label fix in Sliders, you can now spec the decimal precision to display.


Attached Files
.zip   2022-08-12 GUI b+ mod vince Designer Egg.zip (Size: 561.01 KB / Downloads: 54)
b = b + ...
Reply
#38
Note: 2022-08-12 Previous post has been completely changed out and updated since yesterday 8-11 (no one had downloaded yesterday's anyway). Fixed precision display in slider labels. The old trick Int(x * 100) / 100 does not always work and sometimes get 3.4100000001 when all I wanted was 3.41.
b = b + ...
Reply
#39
I was running through all the GUI apps testing with the new BI/BM and found a bug in the Accounts Tracker app. I have been using it for over a week and never noticed the Insert button doesn't get the amount, so the balance isn't changed. It gets a new line inserted but misses the amount, a single line missing in code.

So here is the fix for that with the latest BI/BM and docs:


Attached Files
.zip   Acct Tracker 2022-08-12 Fixed Insert.zip (Size: 1.77 MB / Downloads: 59)
b = b + ...
Reply
#40
OK tried Kens Artillery with Sliders, had to move stuff around, very handy to have adjustable start and stop values so can put the angles between 40 and 80 degrees and power 50 to 100% otherwise half the slider would be wasted starting at 0's.
   


Attached Files
.zip   make over #3 GUI Kens Artillery with Sliders.zip (Size: 1.78 MB / Downloads: 62)
b = b + ...
Reply




Users browsing this thread: 5 Guest(s)