Has it been confirmed one way or another if the gadgets can be used in a canvas (full screen)?
A "Graphics 640,480,32,60"-type fullscreen? It doesn't seem so. A "canvas covering the whole desktop"-type 'fullscreen'? Yes. Fairly quick-n-dirty code exploring this follows...
First off, it's not too hard to rescale gadgets to have a consistent look regardless of the window's size:
'Scaling Hello World
Strict
Local WindowWidth# = 300, DeltaW#
Local WindowHeight# = 140, DeltaH#
Local FontSize = 10
Local window:TGadget = CreateWindow("Scaling Hello World",40,40,WindowWidth ,WindowHeight ,Desktop(), WINDOW_TITLEBAR | WINDOW_RESIZABLE )
Local panel:TGadget = CreatePanel(0,0,ClientWidth(window),ClientHeight(window),window,PANEL_ACTIVE)
SetGadgetColor panel,200,100,100
SetGadgetLayout panel,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED
Local font:TGuiFont = LoadGuiFont( "Arial",FontSize)
Local textfield:TGadget = CreateTextField(14,14,150,20,panel)
SetGadgetFont textfield,font
SetGadgetLayout textfield,EDGE_RELATIVE,EDGE_RELATIVE,EDGE_RELATIVE,EDGE_RELATIVE
Local button:TGadget = CreateButton("OK",170,14,80,24,panel,BUTTON_OK)
SetGadgetFont button,font
SetGadgetLayout button,EDGE_RELATIVE,EDGE_RELATIVE,EDGE_RELATIVE,EDGE_RELATIVE
While WaitEvent()
Select EventID()
Case EVENT_GADGETACTION
Select EventSource()
Case textfield
Print "textfield updated"
Case button
SetGadgetText( textfield,"Hello, world!" )
End Select
Case EVENT_MOUSEDOWN
Select EventSource()
Case panel ' just making sure that a panel can be clicked - for later exploration
SetGadgetText( textfield,"Da panel! Da panel!" )
End Select
Case EVENT_WINDOWSIZE
'DebugLog
'DebugLog GadgetHeight( window )
DeltaW = GadgetWidth( window ) / WindowWidth
DeltaH = GadgetHeight( window ) / WindowHeight
If DeltaW < DeltaH Then
font = LoadGuiFont( "Arial",FontSize * DeltaW)
Else
font = LoadGuiFont( "Arial",FontSize * DeltaH)
EndIf
SetGadgetFont textfield,font
SetGadgetFont button,font
RedrawGadget panel 'redrawing panel & textfield helps reduce garbage when shrinking
RedrawGadget textfield
Case EVENT_WINDOWCLOSE
End
End Select
WendSo, you can make your windows/gadgets look pretty much the same regardless of the size that the user/player has his desktop set at (rescaling them all to take up the same percentage of screen space). It
might be possible to change the desktop size, then change it back when done, but I imagine that could be a bit messy if your game dies and leaves it at the wrong size (I'm not up on doing this, and I personally prefer avoiding platform-specific tricks).
The examples below don't do this dynamic scaling, but they could. They also aren't too happy on a Mac, but I'd guess(?) that's just a matter of a little fiddling around (I've been reading of some 1.12/MaxGUI Mac bugs).
Here's the sort of mix of graphical area and control area that I want for my games (the map is a fixed area at left, with a non-movable set of controls on the right):
Strict
Local ScreenW = GadgetWidth( Desktop() )
Local ScreenH = GadgetHeight( Desktop() )
'the main window masquerading as "desktop"
Local desk:TGadget = CreateWindow("Fake Desktop", 0 , 0, ScreenW ,ScreenH, Desktop(), Null) '
' a graphics area taking up the left 3/4 of screen
Local canvas:TGadget = CreateCanvas (0,0, ScreenW * 0.75, ScreenH, desk )
' a control area taking up the remaining 1/4
Local window:TGadget = CreateWindow("My Window",ScreenW*0.75, 0, ScreenW*0.25, ScreenH, desk, WINDOW_MENU )
Local button:TGadget[4]
button[0]=CreateButton("Draw Random Rect",10,10,140,24,window,BUTTON_PUSH)
button[1]=CreateButton("Use Oval instead of Rect",10,34,140,24,window,BUTTON_CHECKBOX)
button[2]=CreateButton("Blue",10,58,140,24,window,BUTTON_RADIO)
button[3]=CreateButton("Red",10,58+24,140,24,window,BUTTON_RADIO)
SetButtonState(button[2],True) ' start blue
'Set up a typical menu:
Const MENU_NEW=101
Const MENU_OPEN=102
Const MENU_SAVE=103
Const MENU_CLOSE=104
Const MENU_EXIT=105
Const MENU_CUT=106
Const MENU_COPY=107
Const MENU_PASTE=108
Const MENU_ABOUT=109
Local filemenu:TGadget = CreateMenu("&File",0,WindowMenu(window))
Local FileMenuItem[5]
FileMenuItem[0] = CreateMenu("&New",MENU_NEW,filemenu,KEY_N,MODIFIER_COMMAND)
FileMenuItem[1] = CreateMenu("&Open",MENU_OPEN,filemenu,KEY_O,MODIFIER_COMMAND)
FileMenuItem[2] = CreateMenu("&Close",MENU_CLOSE,filemenu,KEY_W,MODIFIER_COMMAND)
CreateMenu"",0,filemenu
FileMenuItem[3] = CreateMenu("&Save",MENU_SAVE,filemenu,KEY_S,MODIFIER_COMMAND)
CreateMenu"",0,filemenu
FileMenuItem[4] = CreateMenu("E&xit",MENU_EXIT,filemenu,KEY_F4,MODIFIER_COMMAND)
Local EditMenu:TGadget = CreateMenu("&Edit",0,WindowMenu(window))
CreateMenu "Cu&t",MENU_CUT,editmenu,KEY_X,MODIFIER_COMMAND
CreateMenu "&Copy",MENU_COPY,editmenu,KEY_C,MODIFIER_COMMAND
CreateMenu "&Paste",MENU_PASTE,editmenu,KEY_V,MODIFIER_COMMAND
Local HelpMenu:TGadget = CreateMenu("&Help",0,WindowMenu(window))
CreateMenu "&About",MENU_ABOUT,helpmenu
For Local i = 0 To 3
DisableMenu FileMenuItem[i]
Next
DisableMenu EditMenu
UpdateWindowMenu window
'Prepare canvas for drawing:
SetGraphics CanvasGraphics(canvas)
Local graphW = GraphicsWidth()
Local graphH = GraphicsHeight()
Cls
DrawText "graphics width:" + graphW, 0, 0
DrawText "graphics height:" + graphH, 0, 10
Flip
Local RectX, RectY, RectW, RectH
Local OvalNotRect = False
'Main loop
While True
WaitEvent
Select EventID()
Case EVENT_WINDOWCLOSE
End
Case EVENT_APPRESUME ' user alt-tabbed away, so need to refresh canvas graphics display
Flip
Case EVENT_WINDOWMOVE ' clean up after any window moving over canvas
Flip
Case EVENT_MENUACTION
Select EventData()
Case MENU_EXIT
End
Case MENU_ABOUT
Notify "A 'full screen' GUI"
Flip ' Notify messes up canvas if moved so clean up when done
End Select
Case EVENT_GADGETACTION
Select EventSource()
Case button[0]
RectW = 10 + Rand( 50 )
RectH = 10 + Rand( 50 )
RectX = Rand( GraphW - RectW )
RectY = Rand( GraphH - RectH )
If ButtonState(button[2]) Then SetColor 0,0,255 ' blue
If ButtonState(button[3]) Then SetColor 255,0,0 ' red
If ButtonState(button[1]) Then
DrawOval RectX, RectY, RectW, RectH
Else
DrawRect RectX, RectY, RectW, RectH
EndIf
Flip
End Select
End Select
WendIt seems possible to Alt-Tab away from and back to this app safely.
If you prefer a floating window moving over a full-desktop, that's possible too (I imagine that the "garbage trail" that appears could be reduced/eliminated, but I haven't investigated that since I plan to use the non-moving control area above):
Strict
Local ScreenW = GadgetWidth( Desktop() )
Local ScreenH = GadgetHeight( Desktop() )
'the main window masquerading as "desktop"
Local desk:TGadget = CreateWindow("Fake Desktop", 0 , 0, ScreenW ,ScreenH, Desktop(), Null)
' a graphics area taking up full screen
Local canvas:TGadget = CreateCanvas (0,0, ScreenW , ScreenH, desk )
' floating control area
Local window:TGadget = CreateWindow("My Window",40, 40, 300, 200, desk, WINDOW_TITLEBAR | WINDOW_MENU )
Local button:TGadget[4]
button[0]=CreateButton("Draw Random Rect",10,10,140,24,window,BUTTON_PUSH)
button[1]=CreateButton("Use Oval instead of Rect",10,34,140,24,window,BUTTON_CHECKBOX)
button[2]=CreateButton("Blue",10,58,140,24,window,BUTTON_RADIO)
button[3]=CreateButton("Red",10,58+24,140,24,window,BUTTON_RADIO)
SetButtonState(button[2],True) ' start blue
'Set up a typical menu:
Const MENU_NEW=101
Const MENU_OPEN=102
Const MENU_SAVE=103
Const MENU_CLOSE=104
Const MENU_EXIT=105
Const MENU_CUT=106
Const MENU_COPY=107
Const MENU_PASTE=108
Const MENU_ABOUT=109
Local filemenu:TGadget = CreateMenu("&File",0,WindowMenu(window))
Local FileMenuItem[5]
FileMenuItem[0] = CreateMenu("&New",MENU_NEW,filemenu,KEY_N,MODIFIER_COMMAND)
FileMenuItem[1] = CreateMenu("&Open",MENU_OPEN,filemenu,KEY_O,MODIFIER_COMMAND)
FileMenuItem[2] = CreateMenu("&Close",MENU_CLOSE,filemenu,KEY_W,MODIFIER_COMMAND)
CreateMenu"",0,filemenu
FileMenuItem[3] = CreateMenu("&Save",MENU_SAVE,filemenu,KEY_S,MODIFIER_COMMAND)
CreateMenu"",0,filemenu
FileMenuItem[4] = CreateMenu("E&xit",MENU_EXIT,filemenu,KEY_F4,MODIFIER_COMMAND)
Local EditMenu:TGadget = CreateMenu("&Edit",0,WindowMenu(window))
CreateMenu "Cu&t",MENU_CUT,editmenu,KEY_X,MODIFIER_COMMAND
CreateMenu "&Copy",MENU_COPY,editmenu,KEY_C,MODIFIER_COMMAND
CreateMenu "&Paste",MENU_PASTE,editmenu,KEY_V,MODIFIER_COMMAND
Local HelpMenu:TGadget = CreateMenu("&Help",0,WindowMenu(window))
CreateMenu "&About",MENU_ABOUT,helpmenu
For Local i = 0 To 3
DisableMenu FileMenuItem[i]
Next
DisableMenu EditMenu
UpdateWindowMenu window
'Prepare canvas for drawing:
SetGraphics CanvasGraphics(canvas)
Local graphW = GraphicsWidth()
Local graphH = GraphicsHeight()
Cls
DrawText "graphics width:" + graphW, 0, 0
DrawText "graphics height:" + graphH, 0, 10
Flip
Local RectX, RectY, RectW, RectH
Local OvalNotRect = False
'Main loop
While True
WaitEvent
Select EventID()
Case EVENT_WINDOWCLOSE
End
Case EVENT_APPRESUME ' user alt-tabbed away, so need to refresh canvas graphics display
Flip
Case EVENT_WINDOWMOVE ' clean up after any window moving over canvas
Flip
Case EVENT_MENUACTION
Select EventData()
Case MENU_EXIT
End
Case MENU_ABOUT
Notify "A 'full screen' GUI"
Flip ' Notify messes up canvas if moved so clean up when done
End Select
Case EVENT_GADGETACTION
Select EventSource()
Case button[0]
RectW = 10 + Rand( 50 )
RectH = 10 + Rand( 50 )
RectX = Rand( GraphW - RectW )
RectY = Rand( GraphH - RectH )
If ButtonState(button[2]) Then SetColor 0,0,255 ' blue
If ButtonState(button[3]) Then SetColor 255,0,0 ' red
If ButtonState(button[1]) Then
DrawOval RectX, RectY, RectW, RectH
Else
DrawRect RectX, RectY, RectW, RectH
EndIf
Flip
End Select
End Select
WendThis is all still rather rough, but seems a promising start for one day's exploration. :) All of this (plus the ability to use panels as "image buttons") has me feeling better about using MaxGUI for doing games as well as apps.