REBOL [
Title: "Iconic Image Browser"
File: %icon-browse.r
Date: 4-Jun-2000
Version: 1.1.0
Author: "Carl Sassenrath"
Purpose: {
Browse a directory of images using a scrolling list of icons.
Displays a progress bar while icons are being created.
}
Category: [view VID 3]
]
files: []
icons: []
num: 0
selection: none
carlwaves: if exists? %carlwaves.jpg [load %carlwaves.jpg]
;-- Progress box:
view/new layout [
backtile carlwaves effect [tile gradcol 1x1 0.0.160 200.0.0]
text "Iconifying Images..." bold
filn: text 120x20
prog: progress 200x14
]
;-- Read directory, find image files:
files: read %.
while [not tail? files] [
either find [%.bmp %.jpg %.gif] find/last first files "." [
files: next files][remove files]
]
files: head files
;-- Create icons from images:
icons: []
incr: 200 / max 1 length? files
total: 0
foreach f files [
filn/text: f show filn
prog/data: to-integer total: total + incr show prog
append icons to-image make face [
size: 40x40
color: 40.40.80
image: load-image f
effect: [aspect]
]
]
unview/all
;-- Main display:
view layout [
backtile carlwaves effect [tile gradcol 1x1 0.0.160 200.0.0]
title reform ["REBOL" system/script/header/title
system/script/header/version] font [size: 16]
across space 0
vx: list 84x600 200.200.200 [
size 80x74 space 0
at 20x4 i: image 40x40 [
img/image: load selection: i/data show vx show img]
at 1x44 text 78x32 center font [
size: 10 color: black shadow: none]
] supply [
face/show?: true
count: count + num
if count > length? files [face/show?: false exit]
either index = 2 [face/text: files/:count][
face/effect: if selection = files/:count [[invert]]
face/image: icons/:count
face/data: files/:count
]
]
vv: slider vx/size * 0x1 + 16x0 length? files [
num: vv/data - 1 show vx]
pad 20
img: frame 600x600 40.40.80 effect none
at 638x20
tgl: toggle 50x24 #"s" "Fit" [
img/effect: either tgl/state ['aspect][none] show img
]
button "Quit" 50x24 #"^(ESC)" [quit]
]