COMMON: Improved performance. Updated FORM, IMAGE, INKEY, TIMER commands #21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Android:
Desktop: new SDL2 port is completed
General:
Improved graphics and runtime performance.
Source code view displays line numbers
Line drawing now uses antialiasing to produce smoother looking lines. You can turn this feature off by placing the following statement at the start of your program:
Option Predef Antialias OFF
Improved syntax error messages
Updated the PAUSE statement to allow waiting until a system event has occurred. This allows you to pause execution until there is a touch or mouse event, without any CPU usage overhead. To use this feature, pass TRUE as the PAUSE argument, i.e. PAUSE TRUE.
Improved INPUT widget including clipboard handling.
Update INKEY to return ALT, CTRL, ALT+CTRL key information
Added timer func support. When called as a function, the TIMER keyword accepts two arguments: a timeout value (in milliseconds) and the name of a call back FUNC. Note the timeout value only provides approximate millisecond precision.
Sub timer_func
print "Timer called: ", Timer
End
Timer(5000, timer_func)
Print "Starting..."
While 1
Pause 1
Print "paused..."
Wend
REM create a form widget
input1.x = n
input1.y = n
input1.width = n
input1.height = n
input1.value
input1.label
input1.type - [label|link|listbox|choice|text|button|image
input1.name - file name for image button type
input1.backgroundColor
input1.color
input1.visible
input1.selectedIndex
input1.length
input1.noFocus
input1.onclick = func
REM creates a form object
f.input << input1
var f = form(f)
REM
f.value = "text"
f.focusColor = "green"
REM push messages through the system event queue
f.doEvents()
REM close the form
f.close()
Please refer to examples: memoryTest.bas, calc.bas, sokoban.bas
There are two supported image formats PNG and XPM. PNG images can to be
loaded using the OPEN command, or by passing the filename string as an argument
to the Image creator function. XPM images can also optionally be passed as a string
argument to the Image creator function.
REM Use the OPEN statement to open the image file
Open "1234.png" as #1
REM create an IMAGE object
i = Image(#1)
REM Display the image - passing optional x, y, zindex, opacity attributes
i.Show([x, y [, zindex [, opacity]]])
REM change the image attributes
i.x = 100
i.y = 10
i.offsetTop = 1
i.offsetLeft = 1
i.width = 100
i.height = 100
i.zindex = 0
i.opacity = 0
REM display the image with current attributes
i.Show()
REM hide the image
i.Hide()
... print the image details
PRINT i
REM create an XPM image
ar << "30 30 770 2"
ar << " c None"
ar << ". c #5B3015"
...
ar << ". + @ # $ @ % & * = - ; > , ' ) ! ~ { ] ^ / ( _ : < [ } | 1 "
...
i2 = image(ar)
i2.x=15
i2.y=15
i2.zindex=1
i2.show()
REM create a window object
w = Window()
REM Create a status message
w.status("Hello")
REM draw into an inset screen
w = window()
w.insetTextScreen(5,10,90,90)
for i = 0 to 200
? "This is in the text screen"
next i
REM display in the text based screen
w.textScreen()
print "This is the text mode screen"
REM switch between graphics screens
w = window()
print "on screen1... pausing"
pause
w.graphicsScreen2()
print "on screen 2.... pausing..."
pause
w.graphicsScreen1()
print "back to 1"
REM display an alert
local wnd = window()
local msg = "You must restart SmallBASIC for this change to take effect"
wnd.alert(msg, "Restart required")
REM Display a menu
local w = window()
w.menu("one", "two", "three")
REM Display the keypad
local w = window()
w.showKeypad()