Screen 0 Hardware PopUp
#1
Code: (Select All)
SCR = _NewImage(80, 25, 0)
Screen SCR
_Delay .2
_ScreenMove _Middle

Do
    xMod = Int(Rnd * 100): ymod = Int(Rnd * 40)

    temp = _NewImage(80 + xMod, 25 + ymod, 0)
    Screen temp: _FreeImage SCR: SCR = temp
    _Delay .25: _ScreenMove _Middle

    Cls , 1
    x = HW_PopUp
Loop Until _KeyDown(27)


Function HW_PopUp
    $Color:32
    Static OptionScreen As Long, OptionDisplay As Long
    Dim As Long DisplayHeight, DisplayWidth, TotalHeight, TotalWidth
    Dim As _Float StepScaleY
    OSW = _Width * _FontWidth: OSH = _Height * _FontHeight
    DisplayWidth = OSW * .8: DisplayHeight = OSH * .8
    DisplayX = OSW * .1: DisplayY = OSH * .1

    If OptionScreen = 0 Then OptionScreen = _NewImage(600, 2000, 32)
    OptionDisplay = _NewImage(DisplayWidth, DisplayHeight, 32)

    _Dest OptionScreen 'draw to option screen

    x1 = DisplayWidth - _FontWidth: x2 = DisplayWidth
    y1 = 0: y2 = DisplayHeight

    NumOfLines = DisplayHeight / _FontHeight
    TotalLines = (2000) / _FontHeight(16)

    StepScaleY = DisplayHeight / TotalLines 'How much of the screen we can see at once

    Do
        Cls , SkyBlue
        Color Black, 0

        k = _KeyHit
        Select Case k
            Case 18432: Ypos = Ypos - 1: If Ypos < 0 Then Ypos = 0
            Case 20480: Ypos = Ypos + 1: If Ypos > TotalLines - NumOfLines Then Ypos = TotalLines - NumOfLines
            Case 1 To 255: _Dest 0: _FreeImage OptionDisplay: Exit Function
        End Select


        _Dest OptionDisplay 'draw the scrollbar on the visible display for the user
        ScrollPositionY = Ypos * StepScaleY
        'If ScrollPosition >= ProgramLength Then ScrollPosition = ProgramLength
        Line (x1, 0)-(x2, _Height(OptionDisplay)), LightGray, BF
        Line (x1, ScrollPositionY)-(x2, ScrollPositionY + NumOfLines * StepScaleY), Red, BF

        _Dest OptionScreen
        For i = 1 To TotalLines
            Locate i, 1: Print i, NumOfLines, TotalLines; StepScaleY;
        Next
        Locate 1, 1

        _PutImage (0, 0)-(x1, y2), OptionScreen, OptionDisplay, (0, Ypos * _FontHeight)-(600, (Ypos + NumOfLines) * _FontHeight)


        HWdisplay = _CopyImage(OptionDisplay, 33)
        _PutImage (DisplayX, DisplayY), HWdisplay
        _FreeImage HWdisplay

        _Display
        _Limit 30
    Loop

End Function


This is one @Pete will probably like.  Smile

What we're doing here is making a 600x2000 graphic screen...  then we're taking a portion of that screen and scaling it so we can display it as a pop-up centered over 80% of our SCREEN 0 screen.

We have arrow keys!  We have scalable sliders!

And... umm.... we resize?  umm...  

We don't really do anything right now, as this is just a work-in-progress, but what we CAN do now, is draw graphics, text, input boxes, or other things inside that popup box, and have them center and display all nice and pretty on our screen 0 text screen.   Just place what you'd like to see on the screen where you currently see the code for:

Code: (Select All)
      _Dest OptionScreen

        For i = 1 To TotalLines
            Locate i, 1: Print i, NumOfLines, TotalLines; StepScaleY;
        Next
        Locate 1, 1
Reply
#2
This is nice. I like it. But there's a small problem. It looks like my computer running Linux (Manjaro MATE) doesn't like "SkyBlue", indicates error #5 with your usage of "CLS" and "COLOR" in a loop. I tested a simple program with the special color names, 32-bit color and using those other two color keywords and a print statement revealing red, green, blue registers of "SkyBlue". It ran perfectly which made me scratch my head. In your program I noticed a few "33" instead of "32" for third parameter to "_NEWIMAGE()" but I don't dare speculate what is the source of the problem.

I have to comment out the "CLS" and "COLOR" so it works correctly but with black background for the "list box". Combining the two into one "COLOR" statement didn't do any good neither.

Update: I verified in the first time "COLOR" is called, the fake list box gets its background set to "SkyBlue", but then when it's called again it errors. (scratch head)
Reply
#3
(11-28-2022, 09:58 PM)mnrvovrfc Wrote: This is nice. I like it. But there's a small problem. It looks like my computer running Linux (Manjaro MATE) doesn't like "SkyBlue", indicates error #5 with your usage of "CLS" and "COLOR" in a loop. I tested a simple program with the special color names, 32-bit color and using those other two color keywords and a print statement revealing red, green, blue registers of "SkyBlue". It ran perfectly which made me scratch my head. In your program I noticed a few "33" instead of "32" for third parameter to "_NEWIMAGE()" but I don't dare speculate what is the source of the problem.

I have to comment out the "CLS" and "COLOR" so it works correctly but with black background for the "list box". Combining the two into one "COLOR" statement didn't do any good neither.

Edited to fix that issue.  Problem was a stray _DEST going back to SCREEN 0 before exiting the function.  My apologies.  Wink
Reply




Users browsing this thread: 3 Guest(s)