Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
b+ Beginners Corner
#31
(06-24-2023, 09:12 PM)Dimster Wrote: Love the comment on killing animation.

I was just revealing personal preference. When I was younger, the animations were cool seen a few times but it does get boring especially when they cannot be disabled.

Now I'm not sure if animations were supported on Turbo Vision but otherwise I thought that GUI toolkit for Turbo Pascal and Turbo C++ looked cool, better than that for VB-DOS. You had to see the function calls that it required on Pascal because like BASIC, it didn't support an user's subprogram (procedure) with a variable number of parameters. The last parameter, then had to be a function pointer! LOL also wasn't eager for the oversized "OK" and "Cancel" buttons out of VB-DOS and having to use a SELECT CASE to handle the [TAB] order of controls of a dialog. Now I'm not sure about that programming. Probably it was event-driven since the very beginning of Visual Basic.

It was already said that the animation most supported on 16-bit single-core computers was the "pop up" which then became less desireable on Windows before Internet Explorer became more widely used and Google, sp____rs, anti-virus and other complications.

The "dropdown" isn't as difficult as you might think or as much as I might have explained poorly. Just do it one line at a time with a very brief delay as if you were adding menu items on the fly. Lie about how many menu items you actually have while drawing the menu, that's all it is. Harder might be to save the screen contents under the menu. Use an ordinary string variable or array to pick up SCREEN() function results in SCREEN 0, or an array for GET and PUT or maybe even an image handle for graphics screen.

I used to have a Tandy1000HX which originally came with 256KB RAM and bought the expansion board for it to lift it up to 640KB. It had a built-in 3-1/2-inch floppy disk drive and external 5-1/4-inch floppy disk, no hard disk. A neighbor gave me a green monochrome monitor which belonged to some typewriter system or something like that, because otherwise I had to use this large RF modulator to use a television screen as the monitor. Running QuickBASIC v4.5 on that computer was good except one sometimes had to deal with the slow redraws of its screen. The computer was so slow one was able to tell apart the two tones it did as "alert" sound, while on something with Intel i486 CPU the tones were sounded fairly fast one after another. On that Tandy computer I couldn't use [CTRL][BREAK] or any other such key combination to get out of programs. That's where I was forced to program [ESC] to leave programs. If not then... reboot was the only way to get away from an endless loop somewhere. The computer was also slow enough that after the used pressed [F5] to run the program, he/she was able to be able to catch "Binding..." at the status bar and sometimes doing it twice if the program was large enough.
Reply
#32
@Dimster or anyone who is interested in setting up a drop menu system, good goal but kinda advanced stuff.

I've been thinking ahead of what would be needed:
1. an ever present title bar that sits somewhere across the top line of the potential app it will be used.
2. when clicked it will drop it's drawers and offer choices from a designated string array 
3. the menu will close up if some other part of screen is clicked
4. the menu will close and run some particular code according to which drawer was clicked
So when title is clicked the menu running code will take over the clicks (not even going to worry about key presses yet let alone mouse over stuff).

But now we need some code, what I call a Main Router, that I used in my GUI mods to know when a menu title was clicked and transfer control to menu running code. This really seems to me to be a job for a GUI library. I might consider doing this as mod to my GUI but I'm afraid I've lost everyone on that project already?

What do you all think? (Not sure I want to do a monologue.)

I might be up for some changes to my GUI code like getting rid of Fonts except for labels so I can do Menus easier and also copy/paste into text boxes and working out an Editor Control from which a WP app can be easily built.

This is huge project and probably why Terry doesn't have Menu code in his tutorial.
b = b + ...
Reply
#33
Lately I've been using a menu input system along the lines of what I posted at:

https://qb64phoenix.com/forum/showthread.php?tid=657

It's not like an "always on", top line Windows system though, and has to be called when specific task choices are needed. It would require some reworking in order to satisfy those bullet points. It ignores clicking outside of the buttons and won't do fancy formatting options. It does, however, support horizontal or vertical orientations placed anywhere on the screen that one desires. I can see it doing a "drawer dropping" vertical sort of thing beneath an upper level horizontal menu.
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
Reply
#34
(06-25-2023, 05:49 PM)OldMoses Wrote: Lately I've been using a menu input system along the lines of what I posted at:

https://qb64phoenix.com/forum/showthread.php?tid=657

It's not like an "always on", top line Windows system though, and has to be called when specific task choices are needed. It would require some reworking in order to satisfy those bullet points. It ignores clicking outside of the buttons and won't do fancy formatting options. It does, however, support horizontal or vertical orientations placed anywhere on the screen that one desires. I can see it doing a "drawer dropping" vertical sort of thing beneath an upper level horizontal menu.

Well my work is done! Smile

The only criticism I have is that for beginners the variables are hard to follow but to your credit you did have each parameter described. Oh and not exactly drop down either... 

I might give this a go myself but luv your vertical and horizontal flexibility and luv those buttons. Hmm... I wonder where Ken got the idea for them, they look so familiar LOL
b = b + ...
Reply
#35
(06-25-2023, 06:40 PM)bplus Wrote: I might give this a go myself but luv your vertical and horizontal flexibility and luv those buttons. Hmm... I wonder where Ken got the idea for them, they look so familiar LOL

We could call it the degrees of separation of code. I try not to dig too much and call 'em where I see 'em.

I suspect the branchless stuff would be even more confusing for beginners. I'm kind of a high functioning beginner... folks say, "Were you high when you began to write that function?"
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
Reply
#36
OK @Dimster and @OldMoses I think I have it roughed out:
Code: (Select All)
Option _Explicit
_Title "Drop Menu function test" 'b+ 2023-06-25
' Instigated by Dimster here:
' https://qb64phoenix.com/forum/showthread.php?tid=1693&pid=17117#pid17117

Const ButtonW = 200, ButtonH = 20, Spacer = 2
Type BoxType ' to be used for mouse click checking
    As String Label
    As Long LeftX, TopY, BoxW, BoxH ' left most = x, top most = y, box width = w, box height = h
End Type
Dim Shared As Integer NBoxes
NBoxes = 72
Dim Shared Boxes(1 To NBoxes) As BoxType
Dim As Integer i, x, y, mz, mx, my, nItems, choice
ReDim menu$(1 To 1)
Dim s$
Screen _NewImage(806, 600, 32)
_ScreenMove 250, 50
_PrintMode _KeepBackground
Cls ' so
' set up boxes
x = 0: y = 0
For i = 1 To NBoxes
    Boxes(i).Label = "Box" + Str$(i)
    Boxes(i).LeftX = x: Boxes(i).TopY = y
    Boxes(i).BoxW = ButtonW
    Boxes(i).BoxH = ButtonH
    If (x + 2 * ButtonW + Spacer) > _Width Then
        x = 0: y = y + ButtonH + Spacer
    Else
        x = x + ButtonW + Spacer
    End If
    DrawTitleBox i
Next
Do
    mz = MouseZone%(mx, my)
    'If mz Then _MessageBox "Mouse Click Detected", "Box" + Str$(mz) + " @" + Str$(mx) + Str$(my), "info"
    If mz Then
        ' quick make up a menu of items for box mz
        nItems = Int(Rnd * 10) + 1
        ' nItems = 10 ' for testing
        ReDim menu$(1 To nItems)
        For i = 1 To nItems
            menu$(i) = "Box" + Str$(mz) + " Menu Item:" + Str$(i)
        Next
        choice = getButtonNumberChoice%(Boxes(mz).LeftX, Boxes(mz).TopY, menu$())
        If choice = 0 Then s$ = "You quit menu." Else s$ = menu$(choice)
        _MessageBox "Drop Menu Test", "Your Menu Choice was: " + s$, "info"
    End If
    _Limit 30
Loop Until _KeyDown(27)
Sub DrawTitleBox (i)
    Line (Boxes(i).LeftX, Boxes(i).TopY)-Step(ButtonW, ButtonH), &HFFFF0000, BF
    Color &HFFFFFFFF
    _PrintString (Boxes(i).LeftX + (ButtonW - _PrintWidth(Boxes(i).Label)) / 2, Boxes(i).TopY + ButtonH / 2 - 8), Boxes(i).Label
End Sub
Sub DrawChoiceBox (leftX, topY, S$)
    Line (leftX, topY)-Step(ButtonW, ButtonH), &HFFAABBFF, BF
    Line (leftX, topY)-Step(ButtonW, ButtonH), &HFF000000, B
    Color &HFF000088
    _PrintString (leftX + (ButtonW - _PrintWidth(S$)) / 2, topY + ButtonH / 2 - 8), S$
End Sub
Function MouseZone% (mx%, my%) ' returns the boxes index clicked or 0 and
    ' Set the following up in your Main code of app
    'Type BoxType ' to be used for mouse click checking
    '   As Long LeftX, TopY, BoxW, BoxH ' left most = x, top most = y, box width = w, box height = h
    'End Type
    'Dim Shared As Integer NBoxes
    'Dim Shared Boxes(1 To NBoxes) As BoxType
    ' If function detects a mouse click inside a box mx and my will be adjusted to top left
    'corner of box and box index returned by function name
    Dim As Integer i, mb
    mx% = -1: my% = -1 ' not valid zone signal
    While _MouseInput: Wend ' poll mouse
    mb = _MouseButton(1)
    If mb Then
        _Delay .25
        mx% = _MouseX: my% = _MouseY
        For i = 1 To NBoxes
            If mx% > Boxes(i).LeftX And mx% < Boxes(i).LeftX + Boxes(i).BoxW Then
                If my% > Boxes(i).TopY And my% < Boxes(i).TopY + Boxes(i).BoxH Then
                    mx% = mx% - Boxes(i).LeftX: my% = my% - Boxes(i).TopY
                    MouseZone% = i: Exit Function
                End If
            End If
        Next
    End If
End Function
Function getButtonNumberChoice% (BoxX As Integer, BoxY As Integer, choice$())
    Dim As Integer ub, lb, b, mx, my, mb
    Dim As Long SaveSection
    'this sub uses drwBtn
    ub = UBound(choice$)
    lb = LBound(choice$)
    SaveSection = _NewImage(ButtonW, ButtonH * (ub - lb + 1), 32)
    _PutImage , 0, SaveSection, (BoxX, BoxY + ButtonH)-Step(ButtonW, ButtonH * (ub - lb + 1))
    For b = lb To ub '   drawing a column of buttons at _width - 210 starting at y = 10
        DrawChoiceBox BoxX, BoxY + b * ButtonH, choice$(b)
    Next
    Do
        While _MouseInput: Wend
        mx = _MouseX: my = _MouseY: mb = _MouseButton(1)
        If mb Then
            If mx > BoxX And mx <= BoxX + ButtonW Then
                For b = lb To ub
                    If my >= BoxY + b * ButtonH And my <= BoxY + b * ButtonH + ButtonH Then
                        ' put image back
                        _PutImage (BoxX, BoxY + ButtonH)-Step(ButtonW, ButtonH * (ub - lb + 1)), SaveSection, 0
                        ' delay before exit to give user time to release mouse button
                        _FreeImage SaveSection
                        getButtonNumberChoice% = b: _Delay .25: Exit Function
                    End If
                Next
                Beep
            Else
                Beep
            End If
        End If
        _Limit 60
    Loop
End Function

   

Oops! Forgot if click outside menu while down that is cancel or a quit menu not a beep.

I'll add that and clean up code next.
b = b + ...
Reply
#37
LOL at "instigated". Looks pretty good, although red is not my favorite color. I would have never thought of something like this, looks complicated! This is an alternative to a panel option that comes with a file manager on Linux, to select a folder to open that file manager. But it is clunky to some people having to make a choice in one menu, only to get another menu, then another choice for another menu, and so on for a long path name. I think this panel option is available on MATE and XFCE. But I repeat it's clunkier than the "large box of drawers" displayed by this demonstration.



The animation could go down something like this. This is the top of the "getButtonNumberChoice%()" function (the last one listed):

Code: (Select All)
Dim As Integer ub, lb, b, bb, mx, my, mb
    Dim As Long SaveSection
    'this sub uses drwBtn
    ub = UBound(choice$)
    lb = LBound(choice$)
    SaveSection = _NewImage(ButtonW, ButtonH * (ub - lb + 1), 32)
    _PutImage , 0, SaveSection, (BoxX, BoxY + ButtonH)-Step(ButtonW, ButtonH * (ub - lb + 1))
    For bb = lb + 1 to ub
        For b = lb To bb '   drawing a column of buttons at _width - 210 starting at y = 10
            DrawChoiceBox BoxX, BoxY + b * ButtonH, choice$(b)
        Next
        _Delay 0.25
    Next
Reply
#38
Can we get an example of hovering the mouse over a box and displaying a tooltip? And then having the tooltip stick to the mouse for that box's boundary all the way until it changes to another box?
Schuwatch!
Yes, it's me. Now shut up.
Reply
#39
(06-26-2023, 11:29 AM)Ultraman Wrote: Can we get an example of hovering the mouse over a box and displaying a tooltip? And then having the tooltip stick to the mouse for that box's boundary all the way until it changes to another box?

LOL if you want it from me, don't hold your breath. But maybe...
b = b + ...
Reply
#40
(06-26-2023, 12:17 PM)bplus Wrote: LOL if you want it from me, don't hold your breath. But maybe...
I will pretend I'm a billionaire making my way to wreckage of an old cruise ship
Schuwatch!
Yes, it's me. Now shut up.
Reply




Users browsing this thread: 2 Guest(s)