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
08-11-2022, 01:27 AM (This post was last modified: 08-11-2022, 01:33 AM by bplus.)
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.
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.
08-11-2022, 04:00 PM (This post was last modified: 08-11-2022, 04:18 PM by bplus.)
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.
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).
08-12-2022, 03:31 AM (This post was last modified: 08-12-2022, 06:11 PM by bplus.)
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)
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.
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.
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:
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.