Last active
July 8, 2017 15:52
-
-
Save dockimbel/a6ad059854e8059147d23e5033b490d6 to your computer and use it in GitHub Desktop.
Dynamic View usage example: drawing a board of buttons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [ | |
Title: "Dynamic View usage example" | |
Author: "Nenad Rakocevic" | |
Date: 08/07/2017 | |
] | |
generate: function [board [pair!] sz [pair!] return: [block!]][ | |
pane: make block! sz/x * sz/y | |
pos: 1x1 | |
count: 1 | |
loop board/y [ | |
loop board/x [ | |
append pane make face! [type: 'button size: sz offset: pos text: form count] | |
pos/x: pos/x + sz/x | |
count: count + 1 | |
] | |
pos: as-pair 0 pos/y + sz/y | |
] | |
pane | |
] | |
board: 4x5 ;-- board's columns x rows | |
but-sz: 50x50 ;-- size of each piece | |
view center-face make face! [ | |
type: 'window | |
size: as-pair board/x * but-sz/x board/y * but-sz/y | |
pane: generate board but-sz | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment