Flexible Windows

Flexible Windows seems to be the only currently-supported way to display multiple windows, but the only example it has involving graphics just has a pile of I6 code, mostly relating to image scaling. What’s the easiest way to display a static image?

I’m displaying an image with a caption underneath. For anyone who cares, my window code is:

[code]The graphics-window is a graphics g-window. The main-window spawns the graphics-window. The position of the graphics-window is g-placeright. The scale method of the graphics-window is g-fixed-size. The measurement of the graphics-window is 600.

The byline-window is a text-grid g-window. The graphics-window spawns the byline-window. The position of the byline-window is g-placebelow. The scale method of the byline-window is g-proportional. The measurement of the byline-window is 25.[/code]

Glimmr Simple Graphics Window–which really just defines a Flexible Windows graphics window–includes an example that shows how to code a display rule in I7. Otherwise, your non-I6 options are to use one of the prefab display rules from Emily’s Simple Graphics Window (one window only), or to use Glimmr Canvas-Based Drawing. The latter is intended for more complicated displays than yours, though, so I’d head there only if you don’t like the other options.

–Erik

OK, but that example is essentially identical to the other one except that the scaling calculations are done in I7 instead of I6. I don’t know I6; I don’t know how to modify this so that it just displays the image at its native resolution without scaling it, and consequently so the DrawImageScaled function only takes the figure name and the window as variables:

[code] Include (-

[DrawImageScaled ID win x y image_x image_y ;
    if (win.ref_number) {
        glk_image_draw_scaled(win.ref_number, ResourceIDsOfFigures-->ID, x, y, image_x, image_y);
    }
];

-).[/code]

The example exposes all the functions that are used at the I7 level. There is no need to write any I6. If you want to display the image w/o scaling, just give the original dimensions of the image in the “display image” phrase.

–Erik

No, “display Figure Test in the graphics-window at 1 by 1 with dimensions 300 by 300” is unrecognized. (A simple “display Figure Test” just puts in in the main window, obviously.)

Are you starting with the code from the example in Glimmr Simple Graphics Window? As I said, that code exposes all of the functions you are likely to need to write a graphics drawing rule purely in I7. Here are the main functions and wrappers defined there:

[code]To display (ID - a figure name) in (win - a g-window) at (x1 - a number) by/x (y1 - a number) with size/dimensions (width - a number) by/x (height - a number):
(- DrawImageScaled({ID}, {win}, {x1}, {y1}, {width}, {height}); -)

Include (-

[DrawImageScaled ID win x y image_x image_y ;
    if (win.ref_number) {
        glk_image_draw_scaled(win.ref_number, ResourceIDsOfFigures-->ID, x, y, image_x, image_y);
    }
]; 

-).

To decide which number is the greater/max of/-- (X - a number) or (Y - a number):
    if Y > X, decide on Y;
    decide on X.

To decide what number is the image-width of (img - a figure name):
    (- FindImageWidth({img}) -)

To decide what number is the image-height of (img - a figure name):
    (- FindImageHeight({img}) -)


Include (-

[ FindImageWidth img result img_width;
    result = glk_image_get_info(ResourceIDsOfFigures-->img, gg_arguments, gg_arguments+WORDSIZE);
 img_width = gg_arguments-->0;
    return img_width;
];

[ FindImageHeight img result img_height;
    result = glk_image_get_info(ResourceIDsOfFigures-->img, gg_arguments, gg_arguments+WORDSIZE);
 img_height = gg_arguments-->1;
    return img_height;
];

-)

[/code]

–Erik