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


Messages In This Thread
Screen 0 Hardware PopUp - by SMcNeill - 11-28-2022, 09:38 PM
RE: Screen 0 Hardware PopUp - by mnrvovrfc - 11-28-2022, 09:58 PM
RE: Screen 0 Hardware PopUp - by SMcNeill - 11-28-2022, 10:04 PM



Users browsing this thread: 4 Guest(s)