Skip to content

GUI Note Min Window

Christopher Ross-Gill edited this page Aug 1, 2016 · 1 revision

Use this approach to isolate bugs in the graphics system, below the R3 GUI.

Purpose

The GUI system rests on top of the graphics and windowing systems.

Sometimes, if you think you found a bug, you will need to determine if the bug is in the GUI itself, or the graphics system. By using the code below, you can access the lower level graphics system directly without using any of the higher level GUI/view system.

Minimal Raw Window with Graphics

To help you test for bugs in the lower level system, such as in GOBs or the DRAW dialect, you need to be able to test the code at a level below the GUI. In fact, you may want to entirely bypass the GUI.

It's pretty easy to do. Take a look at this code:

Rebol [Title: "Base level (minimum) window code"]

win: make gob! [text: "test" offset: 100x100 size: 300x300]
append win make gob! [
    draw: [
        fill-pen red
        box 5x5 90x90 3
    ]
]
append system/view/screen-gob win
show system/view/screen-gob

ask "ok?"

This draws a red rounded box in a small window. None of the GUI system is used here so you can work at debugging the problem in your DRAW code.

Note that ASK will stop the process from terminating, and there is no GUI event handler running. So the window will not refresh properly. If you need it to refresh, use WAIT, and add a little event handler, as shown below.

Minimal Event Handler

If you need a minimal event handler to refresh the windows, you can remove the ASK in the code above, and add these lines.

system/view/event-port: make port! [scheme: 'event]

system/view/event-port/awake: func [event] [
    print ["EVENT:" event/type event/offset event/flags]
    if event/type = 'close [quit]
    tail? system/view/screen-gob
]

wait system/view/event-port

This code will show events, but will only act on one event, a CLOSE.

Again, the code shown here is only necessary for low level debugging, bypassing the GUI system. Most scripts do not need to use this code.

Clone this wiki locally