Post Reply 
 
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fullscreen programs
04-05-2017, 05:44 AM (This post was last modified: 04-05-2017 07:10 PM by clasqm.)
Post: #1
Fullscreen programs
This will appear as an appendix in the next version of Programming with yab.

Yab does not have a built-in facility to write apps that run in a formal fullscreen mode. But we can fake it! Writing such a program is not very difficult. It boils down to the following steps:

1, Find out the dimensions of the screen using the PEEK command
2. Create a window from 0, 0 to those dimensions, in other words, cover the entire screen with a window.
3. Remove all the window decor with WINDOW SET
4. Continue writing the rest of the program.

That's all there is to it, really! The following little demo shows how to do this.

Code:
#!yab
doc Fullscreen demo
OpenWindow()

// Main Message Loop
dim msg$(1)
while(not leavingLoop)
//This is a dummy loop just to stop the demo from closing
wend
end
// Setup the main window here
sub OpenWindow()
local xw, yh
xw = peek("desktopwidth")
yh = peek ("desktopheight")
    window open 0,0 to xw,yh, "MainWindow", "Main Window"
    window set "MainWindow", "look", "no-border"
end sub

In an actual program, though, I would do one thing differently. Those values for xw and yh - I am going to need them all over the place once I start placing widgets on this window. So just this once, I would consider making them global rather than local variables. Global variables are not intrinsically evil: if you know what you are doing, a good mixture of global and local variables is perfectly acceptable.

This is of course just a regular application that happens to take up the entire screen. Other apps can hide behind it or come up in front of it. A true full-screen mode is provided by the operating system and prevents that from happening.

There is a way to specify that a yab app should always remain on top (see the documentation for WINDOW SET), but that is normally a bad idea when you are working full-screen. You would prevent your user from getting to Tracker or the Deskbar, for one thing. If you are going to do that, make sure to provide an obvious way to minimize or close your app. Yes, you will need to do it - you can't just leave it to the window tab, because we removed it!

But what if you want your program to toggle between a window and full screen? WINDOW SET can help you there too: it has a range of options for moving and resizing your window.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

Free Web Hosting