Glimmr Canvas Editor

version 1/100805 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Part - Window Setup

    Portrait orientation is a truth state that varies. Portrait orientation is false.

    The back-colour of the main-window is usually g-white.

    The editor-canvas is a g-canvas.
    Some g-canvases are defined by the Table of Canvases.

    Table of Canvases
    g-canvas  canvas-width  canvas-height  
    library-canvas  200  768  
    control-canvas  572  614  
    paging-canvas  200  24  
    layers-canvas  27  461  
    drawing-canvas  795  24  


    The editor-window is a graphlink g-window. The position is g-placeabove. The back-colour is usually g-placeNULLcol. The associated canvas is usually the editor-canvas. The measurement is 60.

    Some graphlink g-windows are defined by the Table of Windows.

    Table of Windows
    g-window  position  measurement  back-colour  associated canvas  
    library-window  g-placeright  20  g-mylightgray  library-canvas  
    control-window  g-placeleft  35  g-mylightgray  control-canvas  
    paging-window  g-placeabove  24  g-librarygray  paging-canvas  
    layers-window  g-placeleft  3  g-mylightgray  layers-canvas  
    drawing-window  g-placebelow  24  g-mylightgray  drawing-canvas  

    The scale method of the paging-window is g-fixed-size.
    The scale method of the drawing-window is g-fixed-size.

    The arbitrary scaling factor of the drawing-window is 1.0000.

    The help-window is a text-buffer g-window. The position is g-placebelow. The measurement is 50. The back-colour is g-pear.

    To use small type in subsequently opened windows:
        (- SetSmallType(); -)

    Include (-

    [ SetSmallType i ;
         for (i = 0: i < style_NUMSTYLES : i++)
    glk_stylehint_set(wintype_TextBuffer, i, stylehint_Size, -1);
    ];

    -)


    The main-window spawns the library-window. The library-window spawns the paging-window.
    The main-window spawns the editor-window. The editor-window spawns the layers-window.
    The editor-window spawns the drawing-window.
    The main-window spawns the control-window.
    The main-window spawns the help-window.

    The working window is a g-window that varies. The working window is usually the editor-window. The working canvas is a g-canvas that varies. The working canvas is usually the editor-canvas. [The working window identifies the window into which new sprite elements created from the library should be copied. Originally, it was planned to allow multiple windows/canvases to be worked on at the same time. However, this was decided to be unnecessary and probably confusing. Should anyone want to modify the extension to allow for this, however, the working window variable has been used where possible t/o the extension, easing the pain of a conversion.]

    The canvas-width of the editor-canvas is usually 795.
    The canvas-height of the editor-canvas is usually 460.

    A window-drawing rule for the library-window (this is the library-window drawing rule):
        if the library-window is g-present:
            [say "Drawing the library window...[line break]";]
            clear the library-window;
            page and scale the library-window sprites;
            draw library instances in the library-window;
            follow the library-paging rules;

    A window-drawing rule for the paging-window (this is the paging-window drawing rule):
        if the paging-window is g-present:
            clear the paging-window;
            resize the canvas of the paging-window to the window;
            let margin be the canvas-height of the paging-canvas divided by 4;
            let nav-size be (canvas-height of the paging-canvas minus margin) minus margin;
            change entry 1 of the origin of page-left_button to margin;
            change entry 2 of the origin of page-left_button to margin;
            change entry 2 of the origin of page-right_button to margin;
            change entry 1 of the origin of page-right_button to (canvas-width of paging-canvas minus margin) minus nav-size;
            let the header-coordinates be the center-point of the paging-canvas;
            let temp-coord-x be entry 1 of the header-coordinates minus (image-width of the Figure of Library Header / 2);
            let temp-coord-y be entry 2 of the header-coordinates minus (image-height of the Figure of Library Header / 2);
            display image (Figure of Library Header) in paging-window at (temp-coord-x) by (temp-coord-y);
            prune the link-table of paging-window links;
            repeat with current-element running through display-active paging-buttons:
                let temp-coord-x be entry 1 of the origin of current-element;
                let temp-coord-y be entry 2 of the origin of current-element;
                display image (image-ID of current-element) in paging-window at (temp-coord-x) by (temp-coord-y) with dimensions (nav-size) x (nav-size);
                if current-element is graphlinked:
                    set a graphlink in paging-window identified as current-element from (temp-coord-x) by (temp-coord-y) to (temp-coord-x + nav-size) by (temp-coord-y + nav-size) as the linked replacement-command of current-element;

    A window-drawing rule for the editor-window (this is the editor-window drawing rule):
        if the editor-window is g-present:
            carry out the scaling activity with the editor-window;
            carry out the offset calculation activity with the editor-window;
            carry out the window-framing adjustment activity with the editor-window;
            clear the editor-window;
            carry out the drawing the canvas background activity with the editor-window;
            if canvas-outlining is true:
                draw a box (color Canvas outline-color) in the editor-window from (x-offset of the editor-window) by (y-offset of the editor-window) to (the x-offset of the editor-window plus the scaled width of the editor-canvas) by (the y-offset of the editor-window plus the scaled height of the editor-canvas) with 1 pixel line-weight, inset;
            carry out the drawing the active elements activity with the editor-window;
            draw element-selection markers;
            if layer-revelation is true:
                append layer numbers;
            if drawing mode is true:
                unless first point is {-999, -999}:
                    draw a rectangle (color highlight-color) in (working window) from (current graphlink x - 1) by (current graphlink y - 1) to (current graphlink x + 1) by (current graphlink y + 1);

    For window-framing adjustment of the editor-window when we are zoomed in (this is the zoomed window centering rule):[This rule recenters the framing of the editor window when we are zoomed in.]
        if zoom-center is {-1, -1}:
            center the framing of the working window on its canvas;
        otherwise:
            center the framing of the working window on the zoom-center;
        continue the action.

    A window-drawing rule for the layers-window (this is the layers-window drawing rule):
        if the layers-window is g-present:
            clear the layers-window;
            unless portrait orientation is true:
                draw a rectangle (color g-librarygray) in the layers-window at (0) by (height of layers-window minus 1) with size (width of layers-window) by (1);
            [prune the link-table of layers-window links;]
            follow the layer indicator construction rules.

    A window-drawing rule for the control-window (this is the control-window drawing rule):
        if the control-window is g-present:
            if zoom is available:
                now the display status of the zoom_button is g-active;
                if we are zoomed out:
                    now the inactive-state of the zoom_button is Figure of Zoom Out Inactive;
                if we are zoomed in:
                    now the inactive-state of the zoom_button is Figure of Zoom In;
            otherwise:
                deactivate zoom_button;
            carry out the scaling activity with the control-window;
            carry out the offset calculation activity with the control-window;
            clear the control-window;
            carry out the drawing the canvas background activity with the control-window;
            carry out the drawing the active elements activity with the control-window;
            if portrait orientation is true:
                draw a rectangle (color g-librarygray) in the control-window at (width of control-window minus 1) by (0) with size (1) by (height of control-window).
                
    A window-drawing rule for the drawing-window (this is the drawing-window drawing rule):
        if the drawing-window is g-present:
            now the canvas-width of the drawing-canvas is the width of the drawing-window;
            carry out the scaling activity with the drawing-window;
            carry out the offset calculation activity with the drawing-window;
            clear the drawing-window;
            if canvas-width of the drawing-canvas > 501:
                activate close drawing window button;
                change entry 1 of origin of close drawing window button to canvas-width of drawing-canvas minus 17;
            otherwise:
                deactivate close drawing window button;
            change the tint of the foreground_color_indicator to the current element color;
            change the tint of the background_color_indicator to the current element background color;
            let v-offset be 24 - current line-weight;
            if v-offset < 3, let v-offset be 1;
            let v-offset be v-offset / 2;
            draw a rectangle (color current element color) in drawing-window at (455) by (v-offset) with dimensions (20) by (current line-weight);
            draw a box (color g-librarygray) in drawing-window from 0 by 0 to (width of the drawing-window) by (height of the drawing-window) with 1 pixel line-weight, inset;
            carry out the drawing the active elements activity with the drawing-window.
            
    Element display rule for the foreground_color_indicator when the current element color is g-placenullcol:
        let x be entry 1 of origin of foreground_color_indicator;
        let y be entry 2 of origin of foreground_color_indicator;
        display Figure of Null Color-Chip in drawing-window at x by y;
        
    Element display rule for the background_color_indicator when the current element background color is g-placenullcol:
        let x be entry 1 of origin of background_color_indicator;
        let y be entry 2 of origin of background_color_indicator;
        display Figure of Null Color-Chip in drawing-window at x by y.