Updated code, you can watch previews of movie files. For mp3/wav files you'll get a neat (but fake) spectrum graphic. Can't play the music yet, didn't put in the UI for it yet.
Version 0.2.4
REM *********************************
REM Version 0.2.4
REM TODO:
REM - preview window
REM - file content
REM *********************************
set display mode 800,600,32
#CONSTANT NODE_TYPE_FILE = 0
#CONSTANT NODE_TYPE_FOLDER = 1
#CONSTANT NODE_TYPE_DRIVE = 2
#CONSTANT FORMAT_SOUND = 1
#CONSTANT FORMAT_IMAGE = 2
#CONSTANT FORMAT_ANIMATION = 3
#CONSTANT THEME_DEFAULT = 1
#CONSTANT PREVIEW_ANIMATION_INDEX = 1
#CONSTANT PREVIEW_SOUND_INDEX = 100
#CONSTANT PREVIEW_IMAGE_INDEX = 50
#CONSTANT IMG_PLAY = 5
#CONSTANT IMG_PAUSE = 6
type _Node
name as string
date as string
fileType as integer
bper as float
endtype
type _FormatExtension
extension as string
formatType as integer
endtype
type _Window
x as integer
y as integer
width as integer
height as integer
mFlag as boolean
titleIsDragging as boolean
scrollIsDragging as boolean
isDividing as boolean
wheelFlag as integer
wheelStep as integer
wheelTimer as integer
toolTipFlag as boolean
ttCounter as integer
toolTipDelay as integer
divider as float
tx as integer
ty as integer
selectedIndex as integer
thumb as float
pixelOffset as integer
previewFormat as integer
aw as integer
ah as integer
endtype
type _WindowTheme
borderColor as dword : `color of border around window components
backgroundColor as dword : `background color of window body (and spacing between components)
foregroundColor as dword : `foreground color for list and preview windows
listBackgroundColor as dword : `background color of the list view component
hoverForegroundColor as dword : `foreground color of list item mouse is hovered over
hoverBackgroundColor as dword : `foreground color of list item mouse is hovered over
selectedForegroundColor as dword : `foreground color of selected file
selectedBackgroundColor as dword : `background color of highlighted row
titleFontColor as dword : `text color for title bar
titleGradient1 as dword : `title bar fades from this color
titleGradient2 as dword : `title bar fades into this color
toolTipForegroundColor as dword : `foreground color of tooltips
toolTipBackgroundColor as dword : `background color of tooltips
scrollBarTrackColor as dword : `scrollbar track color
scrollBarThumbColor as dword : `color of scrollbar thumb
dividerColor as dword : `color for divider
menuBackgroundColor as dword : `background color of the menu bar
menuForegroundColor as dword : `text color for menu bar items
windowBorderSize as integer : `size of border around the window
componentMargins as integer : `spacing between window components
componentBorderSize as integer : `size of border around each component
endtype
REM load supported format types
restore FORMAT_DATA
read formatCount
dim formats(formatCount) as _FormatExtension
index = 0
repeat
read formatType
read typeCount
for i = 1 to typeCount
read ext$
inc index
formats(index).extension = ext$
formats(index).formatType = formatType
dec formatCount
next i
until formatCount = 0
rem array to hold files of current directory
dim fileList(0) as _Node
rem 1-10 spectrum bar values, 0=timestamp for update
dim bars(10)
rem available themes
dim Themes(1) as _WindowTheme
Themes(THEME_DEFAULT).borderColor = rgb(66,75,82)
Themes(THEME_DEFAULT).backgroundColor = rgb(114,122,128)
Themes(THEME_DEFAULT).foregroundColor = 0
Themes(THEME_DEFAULT).listBackgroundColor = rgb(195,202,208)
Themes(THEME_DEFAULT).hoverForegroundColor = 0
Themes(THEME_DEFAULT).hoverBackgroundColor = rgb(155,163,168)
Themes(THEME_DEFAULT).selectedForegroundColor = rgb(255,255,255)
Themes(THEME_DEFAULT).selectedBackgroundColor = rgb(74,100,120)
Themes(THEME_DEFAULT).titleFontColor = rgb(22,69,110)
Themes(THEME_DEFAULT).titleGradient1 = rgb(115,132,145)
Themes(THEME_DEFAULT).titleGradient2 = rgb(74,100,120)
Themes(THEME_DEFAULT).toolTipForegroundColor = rgb(255,255,255)
Themes(THEME_DEFAULT).toolTipBackgroundColor = 0x804294CB
Themes(THEME_DEFAULT).scrollBarTrackColor = rgb(93,103,111)
Themes(THEME_DEFAULT).scrollBarThumbColor = rgb(66,75,82)
Themes(THEME_DEFAULT).dividerColor = rgb(93,103,111)
Themes(THEME_DEFAULT).menuBackgroundColor = rgb(93,103,111)
Themes(THEME_DEFAULT).menuForegroundColor = rgb(162,177,189)
Themes(THEME_DEFAULT).windowBorderSize = 2
Themes(THEME_DEFAULT).componentMargins = 1
Themes(THEME_DEFAULT).componentBorderSize = 1
currentTheme as _WindowTheme
currentTheme = Themes(THEME_DEFAULT)
dim Windows(1) as _Window
Windows(1).x = 100
Windows(1).y = 50
Windows(1).width = 500
Windows(1).height = 200
Windows(1).toolTipDelay = 1000
Windows(1).thumb = 0.0
Windows(1).divider = 0.5
load image "E:ProgrammingDBPro Sourcefolder.png", 1, 1
load image "E:ProgrammingDBPro Sourceplay.png", IMG_PLAY
load image "E:ProgrammingDBPro Sourcepause.png", IMG_PAUSE
`ax = animation width(1)
`ay = animation height(1)
resetSpectrum()
resumeSpectrum()
sync on
rem default directory
setDir("C:Documents and SettingsPhaelaxMy Documents",1)
set text font "Courier", 1
set text size 10
DO
cls
drawFileList(1, currentTheme)
sync
LOOP
REM **************************************************
REM Set the current directory
REM **************************************************
function setDir(path$, __winHnd)
rem clear current file list
undim fileList(array count(fileList()))
rem set current path and get files
set dir path$
perform checklist for files
size = checklist quantity()
dim fileList(size) as _Node
rem fill array with file names and dates
find first
for i = 1 to size
fileList(i).name = get file name$()
fileList(i).date = get file date$()
fileList(i).fileType = get file type()
find next
next i
Windows(__winHnd).selectedIndex = 0
sortFiles()
endfunction
function drawFileList(__winHnd, __theme as _WindowTheme)
_windowBorderSize = __theme.windowBorderSize
_componentMargins = __theme.componentMargins
_componentBorderSize = __theme.componentBorderSize
_titleX = Windows(__winHnd).x + _windowBorderSize : `x-position of title bar
_titleY = Windows(__winHnd).y + _windowBorderSize : `y-position of title bar
_titleWidth = Windows(__winHnd).width - _windowBorderSize*2 : `width of title bar
_titleHeight = 16 : `height of title bar
_menuX = Windows(__winHnd).x + _windowBorderSize + _componentMargins + _componentBorderSize : `x-position of menu bar
_menuY = _titleY + _titleHeight + _componentMargins + _componentBorderSize : `y-position of menu bar
_menuWidth = Windows(__winHnd).width - (_windowBorderSize+_componentBorderSize+_componentMargins)*2 : `width of menu bar (excludes the component's border size)
_menuHeight = text height("A") : `height of menu bar (excludes the component's border size)
_statusX = Windows(__winHnd).x + _windowBorderSize + _componentMargins + _componentBorderSize : `x-position of status bar
_statusHeight = 16 : `status bar height (excludes the component's border size)
_statusWidth = Windows(__winHnd).width - _windowBorderSize*2 - _componentBorderSize*2 - _componentMargins*2 : `width of status bar (excludes the component's border size)
_statusY = Windows(__winHnd).y + Windows(__winHnd).height - (_statusHeight+_windowBorderSize+_componentMargins+_componentBorderSize) : `y-position of status bar
_listX = Windows(__winHnd).x + _windowBorderSize + _componentMargins + _componentBorderSize : `x-position of file view list
_listY = _menuY + _menuHeight + _componentMargins + _componentBorderSize*2 : `y-position of file view list
_listTextOffset = 2 : `text within the list is offset from the left margin
_dividerWidth = 4 : `width of divider bar for controlling the split pane
windowWidth = Windows(__winHnd).width : `value needs assigned to variable to work around DBP bug of multiplying array elements
_dividerX = Windows(__winHnd).x + (windowWidth*Windows(__winHnd).divider) - _dividerWidth/2 : `x-position of divider bar
_dividerY = _menuY + _menuHeight : `y-position of divider bar
_dividerHeight = (_statusY - (_titleY+_titleHeight)) - _menuHeight : `height of the divider bar
_trackWidth = 12 : `width of scroll bar track
_trackX = _dividerX - _trackWidth - _componentBorderSize - _componentMargins : `x-position of scroll bar track
_trackY = _listY : `y-position of scroll bar track (should stay vertically aligned with list)
_trackHeight = (_statusY - _listY) - _componentMargins - _componentBorderSize*2 : `height of scroll bar track
_listWidth = (_trackX - _listX) - _componentMargins - _componentBorderSize*2 : `width of file view list
_listHeight = _trackHeight : `height of file view list
_thumbX = _trackX : `x-position of scrollbar thumb
_thumbWidth = _trackWidth : `width of scrollbar thumb (should be no larger than track width)
_thumbHeight = 12 : `height of scrollbar thumb
_thumbY = _trackY + (_listHeight-_thumbHeight)*Windows(__winHnd).thumb : `y-position of scrollbar thumb
_previewX = _dividerX+_dividerWidth + _componentMargins+_componentBorderSize
_previewY = _listY
_previewWidth = ((Windows(__winHnd).x+Windows(__winHnd).width) - _previewX) - (_componentMargins+_componentBorderSize+_windowBorderSize)
_previewHeight = _listHeight
_wheelDelay = 35 : `mouse wheel scroll speed (lower is faster)
_wheelStep = 12 : `how much to scroll with mouse wheel
_lineSpacing = 16 : `height of each displayed line in file list
_iconSize = 16 : `images are not resized to fit, this is the assume size of loaded file icons
_showCount = getMin(ceil((_listHeight+0.0) / _lineSpacing), array count(fileList())) : `number of visible files shown within the view list
_viewableContentHeight = getMax((array count(fileList())*_lineSpacing) - _listHeight, 0) : `how much viewable content is off-screen
_viewportPixelOffset = _viewableContentHeight*Windows(__winHnd).thumb : `Y-offset of viewable content pane (in pixels)
_startingIndex = _viewportPixelOffset / _lineSpacing + 1 : `file index to show first in the viewable file list
_endingIndex = getMin(_startingIndex + _showCount-1, array count(fileList())) : `last file index to be displayed in the viewable file list
Windows(__winHnd).pixelOffset = _viewportPixelOffset - (_startingIndex-1)*_lineSpacing : `line offset (in pixels) for file line, used for per-pixel scrolling
rem determine if another file should be displayed at bottom (only partially visible)
if _showCount*_lineSpacing-Windows(__winHnd).pixelOffset < _listHeight AND _endingIndex < array count(fileList()) then inc _endingIndex,1
hoveredIndex = 0 : `file index mouse is currently hovered over
doHover = 1 : `1 to show mouse hover effect over list items, 0 to turn off
rem draw background of entire window
ink __theme.backgroundColor,0
box Windows(__winHnd).x,Windows(__winHnd).y,Windows(__winHnd).x+Windows(__winHnd).width,Windows(__winHnd).y+Windows(__winHnd).height
rem draw border around window
drawOutline(Windows(__winHnd).x,Windows(__winHnd).y,Windows(__winHnd).x+Windows(__winHnd).width,Windows(__winHnd).y+Windows(__winHnd).height,_windowBorderSize,__theme.borderColor)
rem draw list background
ink __theme.listBackgroundColor,0
box _listX, _listY, _listX+_listWidth, _listY+_listHeight
rem display list of files names
ink __theme.foregroundColor,0
i = 0
for index = _startingIndex to _endingIndex
tx = _listX
ty = _listY + i*_lineSpacing - Windows(__winHnd).pixelOffset
if doHover = 1
rem if file is not currently selected
if index <> Windows(__winHnd).selectedIndex
rem special background hover effect
rem TODO: timer-based fade
if fileList(index).bper > 0
ink getTransitionalColor(__theme.listBackgroundColor,__theme.hoverBackgroundColor, fileList(index).bper),0
box tx, ty, tx+_listWidth, ty+_lineSpacing
fileList(index).bper = fileList(index).bper - 0.015
endif
endif
endif
rem if mouse is hovering over this file name
if mouseWithin(tx, ty, tx+_listWidth, ty+_lineSpacing) and Windows(__winHnd).mFlag = 0
if doHover = 1 then fileList(index).bper = 1.0
hoveredIndex = index
ink __theme.hoverForegroundColor,0
else
ink __theme.foregroundColor, 0
endif
rem if file is currently selected
if index = Windows(__winHnd).selectedIndex
ink __theme.selectedBackgroundColor,0
box tx, ty, tx+_listWidth, ty+_lineSpacing
ink __theme.selectedForegroundColor,0
endif
rem display file name
text tx+_listTextOffset*2+_iconSize, ty, capLength$(fileList(index).name, _listWidth-_listTextOffset*2-_iconSize)
if fileList(index).fileType = NODE_TYPE_FOLDER
if image exist(1)=1 then paste image 1, tx+_listTextOffset, ty,1
endif
inc i
next index
rem draw border around list view
drawOutline(_listX-_componentBorderSize, _listY-_componentBorderSize, _listX+_listWidth+_componentBorderSize, _listY+_listHeight+_componentBorderSize,_componentBorderSize,__theme.borderColor)
rem redraw background between components above and below the list view
rem this is to give the appearance that the text stays within the list view
rem (which is also why the title and status bars are drawn after the list)
ink __theme.backgroundColor,0
fillY = _menuY+_menuHeight+_componentBorderSize
box _listX, fillY, _listX+_listWidth, fillY+_componentMargins
fillY = _listY+_listHeight+_componentBorderSize
box _listX, fillY, _listX+_listWidth, fillY+_componentMargins
rem draw title bar
box _titleX, _titleY, _titleX+_titleWidth, _titleY+_titleHeight, __theme.titleGradient2,__theme.titleGradient1,__theme.titleGradient2,__theme.titleGradient1
ink __theme.titleFontColor,0
text _titleX+2, _titleY, capLength$(get dir$(), _titleWidth)
rem draw menu bar
ink __theme.menuBackgroundColor,0
box _menuX, _menuY, _menuX+_menuWidth, _menuY+_menuHeight
rem draw border around menu bar
drawOutline(_menuX-_componentBorderSize, _menuY-_componentBorderSize, _menuX+_menuWidth+_componentBorderSize, _menuY+_menuHeight+_componentBorderSize,_componentBorderSize,__theme.borderColor)
ink __theme.menuForegroundColor,0
text _menuX+6,_menuY, "File Edit View Tools Help"
rem draw scrollbar track
ink __theme.scrollBarTrackColor,0
box _trackX, _trackY, _trackX+_trackWidth, _trackY+_trackHeight
rem draw border around scrollbar track
drawOutline(_trackX-_componentBorderSize, _trackY-_componentBorderSize, _trackX+_trackWidth+_componentBorderSize, _trackY+_trackHeight+_componentBorderSize,_componentBorderSize,__theme.borderColor)
rem draw scrollbar thumb
ink __theme.scrollBarThumbColor,0
box _thumbX, _thumbY, _thumbX+_thumbWidth, _thumbY+_thumbHeight
rem draw divider
ink __theme.dividerColor,0
box _dividerX,_dividerY,_dividerX+_dividerWidth,_dividerY+_dividerHeight
rem draw border around divider
drawOutline(_dividerX,_dividerY,_dividerX+_dividerWidth,_dividerY+_dividerHeight,_componentBorderSize,__theme.borderColor)
rem draw status bar
ink __theme.listBackgroundColor,0
box _statusX, _statusY, _statusX+_statusWidth, _statusY+_statusHeight
rem draw border around status bar
drawOutline(_statusX-_componentBorderSize, _statusY-_componentBorderSize, _statusX+_statusWidth+_componentBorderSize, _statusY+_statusHeight+_componentBorderSize,_componentBorderSize,__theme.borderColor)
rem mouse events
if mouseclick() = 1
rem if clicked on title bar
if mouseWithin(_titleX, _titleY, _titleX+_titleWidth, _titleY+_titleHeight) and Windows(__winHnd).mFlag = 0
Windows(__winHnd).mFlag = 1
Windows(__winHnd).titleIsDragging = 1
Windows(__winHnd).tx = Windows(__winHnd).x - mousex()
Windows(__winHnd).ty = Windows(__winHnd).y - mousey()
endif
rem if clicked on scrollbar thumb
if mouseWithin(_thumbX, _thumbY, _thumbX+_thumbWidth, _thumbY+_thumbHeight) and Windows(__winHnd).mFlag = 0
Windows(__winHnd).mFlag = 1
Windows(__winHnd).ty = _thumbY - mousey()
Windows(__winHnd).scrollIsDragging = 1
endif
rem if clicked on a file in the list view
if mouseWithin(_listX,_listY,_listX+_listWidth,_listY+_listHeight) and Windows(__winHnd).mFlag = 0
Windows(__winHnd).selectedIndex = hoveredIndex
Windows(__winHnd).mFlag = 1
play sound 1
setPreview(__winHnd, hoveredIndex)
endif
rem if mouse clicked inside the divider for the split pane
if mouseWithin(_dividerX,_dividerY,_dividerX+_dividerWidth,_dividerY+_dividerHeight) and Windows(__winHnd).mFlag = 0
Windows(__winHnd).mFlag = 1
Windows(__winHnd).tx = _dividerX - mousex() + _dividerWidth/2
Windows(__winHnd).isDividing = 1
endif
rem if dragging scrollbar thumb
if Windows(__winHnd).scrollIsDragging = 1
_thumbY = (mousey() + Windows(__winHnd).ty) - _listY
Windows(__winHnd).thumb = ((mousey() + Windows(__winHnd).ty) - _listY) / (_listHeight-_thumbHeight+0.0)
if Windows(__winHnd).thumb < 0.0 then Windows(__winHnd).thumb = 0.0
if Windows(__winHnd).thumb > 1.0 then Windows(__winHnd).thumb = 1.0
endif
rem if dragging title bar
if Windows(__winHnd).titleIsDragging = 1
Windows(__winHnd).x = mousex() + Windows(__winHnd).tx
Windows(__winHnd).y = mousey() + Windows(__winHnd).ty
endif
rem if moving the scroll track bar (to resize the list view and preview window)
if Windows(__winHnd).isDividing = 1
dtx# = Windows(__winHnd).divider
Windows(__winHnd).divider = ((mousex() + Windows(__winHnd).tx) - Windows(__winHnd).x) / (Windows(__winHnd).width+0.0)
rem contraints
if Windows(__winHnd).divider < 0.1 then Windows(__winHnd).divider = 0.1
if Windows(__winHnd).divider > 0.9 then Windows(__winHnd).divider = 0.9
rem make sure preview window doesn't shrink smaller than width of spectrum bar
divX = Windows(__winHnd).x + (windowWidth*Windows(__winHnd).divider) - _dividerWidth/2
preX = ((Windows(__winHnd).x+Windows(__winHnd).width)) - (divX+_dividerWidth + _componentMargins+_componentBorderSize) - (_componentMargins+_componentBorderSize+_windowBorderSize)
if preX < 125 then Windows(__winHnd).divider = dtx#
endif
rem make sure mouseclick flag is set if not set above so user can't hold
rem mouse button down and drag around and accidently triggering a mouse event
`Windows(__winHnd).mFlag = 1
else
rem reset flag states
Windows(__winHnd).mFlag = 0
Windows(__winHnd).titleIsDragging = 0
Windows(__winHnd).scrollIsDragging = 0
Windows(__winHnd).isDividing = 0
endif
rem if displaying file preview information
if Windows(__winHnd).previewFormat > 0
if Windows(__winHnd).previewFormat = FORMAT_ANIMATION
aw = Windows(__winHnd).aw
ah = Windows(__winHnd).ah
if aw > 0 and ah > 0
tx# = aw*(_previewHeight-20) / ah
ty# = ah*_previewWidth / aw
if tx# > ty#
ah = _previewWidth*ah / aw
ax1 = _previewX
ax2 = _previewX+_previewWidth
ay1 = _previewY + ((_previewHeight-20) - ah)/2
ay2 = ay1 + ah
else
aw = (_previewHeight-20)*aw / ah
ay1 = _previewY
ay2 = _previewY + (_previewHeight-20)
ax1 = _previewX + (_previewWidth-aw)/2
ax2 = ax1 + aw
endif
endif
place animation PREVIEW_ANIMATION_INDEX,ax1+1,ay1+1,ax2-1,ay2-1
drawOutline(ax1,ay1,ax2,ay2,1,__theme.borderColor)
box ax1,ay2,ax2,ay2+18,rgb(92,116,135),rgb(195,202,208),rgb(92,116,135),rgb(195,202,208)
drawOutline(ax1,ay2,ax2,ay2+18,1,__theme.borderColor)
rem display animation controls
if animation paused(PREVIEW_ANIMATION_INDEX)
paste image IMG_PLAY, ax1+2, ay2+1, 1
else
if animation playing(PREVIEW_ANIMATION_INDEX)
paste image IMG_PAUSE, ax1+2, ay2+1, 1
else
paste image IMG_PLAY, ax1+2, ay2+1, 1
endif
endif
rem handle animation controls
if mouseclick() = 1 and mouseWithin(ax1+2, ay2+1,ax1+20, ay2+19) and Windows(__winHnd).mFlag = 0
Windows(__winHnd).mFlag = 1
if animation paused(PREVIEW_ANIMATION_INDEX)
resume animation PREVIEW_ANIMATION_INDEX
else
if animation playing(PREVIEW_ANIMATION_INDEX)
pause animation PREVIEW_ANIMATION_INDEX
else
play animation PREVIEW_ANIMATION_INDEX
endif
endif
endif
endif
if Windows(__winHnd).previewFormat = FORMAT_SOUND
sx = _previewX + _previewWidth/2
sy = _previewY + _previewHeight/2
_handleSpectrum(sx-62,sy-49)
endif
endif
rem detect is mouse wheel was used and determine which direction it was scrolled
scrollWheel = mousemovez()
if scrollWheel <> 0
thingy = scrollWheel
if scrollWheel > 0
if Windows(__winHnd).thumb = 0.0 : Windows(__winHnd).wheelFlag = 0 : else : Windows(__winHnd).wheelFlag = -1 : endif
else
if Windows(__winHnd).thumb = 1.0 : Windows(__winHnd).wheelFlag = 0 : else : Windows(__winHnd).wheelFlag = 1 : endif
endif
Windows(__winHnd).wheelStep = _wheelStep
endif
rem if mouse wheel was triggered, adjust smooth scroll
if Windows(__winHnd).wheelFlag <> 0
if Windows(__winHnd).wheelTimer + _wheelDelay <= timer()
Windows(__winHnd).wheelTimer = timer()
_viewportPixelOffset = _viewportPixelOffset + Windows(__winHnd).wheelStep*Windows(__winHnd).wheelFlag
Windows(__winHnd).thumb = _viewportPixelOffset / (_viewableContentHeight+0.0)
if Windows(__winHnd).thumb < 0.0 then Windows(__winHnd).thumb = 0.0 : Windows(__winHnd).wheelFlag = 0
if Windows(__winHnd).thumb > 1.0 then Windows(__winHnd).thumb = 1.0 : Windows(__winHnd).wheelFlag = 0
Windows(__winHnd).wheelStep = Windows(__winHnd).wheelStep - 1
if Windows(__winHnd).wheelStep = 0 then Windows(__winHnd).wheelFlag = 0
endif
endif
rem tool tip trigger
if mousemovex() <> 0 OR mousemovey() <> 0 OR mousemovez() <> 0 OR Windows(__winHnd).mFlag = 1
Windows(__winHnd).toolTipFlag = 0
Windows(__winHnd).ttCounter = timer()
else
rem only show tool tips for filenames longer than the list's viewable width
if mouseWithin(_listX, _listY, _listX+_listWidth, _listY+_listHeight) and hoveredIndex > -1
if text width(fileList(hoveredIndex).name) > _listWidth AND Windows(__winHnd).ttCounter + Windows(__winHnd).toolTipDelay <= timer() then Windows(__winHnd).toolTipFlag = 1
endif
endif
rem draw tool tip (drawn last to ensure it's displayed over everything else)
if Windows(__winHnd).toolTipFlag = 1 and hoveredIndex > -1
ttx = _listX
tty = _listY+(hoveredIndex-_startingIndex)*_lineSpacing - Windows(__winHnd).pixelOffset
box ttx, tty, ttx+text width(fileList(hoveredIndex).name)+_listTextOffset*2+_iconSize+2, tty+_lineSpacing,__theme.toolTipBackgroundColor,__theme.toolTipBackgroundColor,__theme.toolTipBackgroundColor,__theme.toolTipBackgroundColor
drawOutline(ttx, tty, ttx+text width(fileList(hoveredIndex).name)+_listTextOffset*2+2+_iconSize, tty+_lineSpacing,1,0x80000000)
ink __theme.toolTipForegroundColor,0
text ttx+_listTextOffset*2+_iconSize, tty,fileList(hoveredIndex).name
endif
if mouseclick() = 1 : Windows(__winHnd).mFlag = 1 : else : Windows(__winHnd).mFlag = 0 : endif
endfunction
REM **************************************************
REM Set up the preview window for a specified file
REM **************************************************
function setPreview(__winHnd, index)
if index = 0 then Windows(__winHnd).previewFormat = 0
format = getFileFormat(fileList(index).name)
Windows(__winHnd).previewFormat = format
if format = 0
if animation exist(PREVIEW_ANIMATION_INDEX) then delete animation PREVIEW_ANIMATION_INDEX
if sound exist(PREVIEW_SOUND_INDEX) then delete sound PREVIEW_SOUND_INDEX
exitfunction
endif
if format = FORMAT_ANIMATION
if animation exist(PREVIEW_ANIMATION_INDEX) then delete animation PREVIEW_ANIMATION_INDEX
load animation fileList(index).name, PREVIEW_ANIMATION_INDEX
Windows(__winHnd).aw = animation width(PREVIEW_ANIMATION_INDEX)
Windows(__winHnd).ah = animation height(PREVIEW_ANIMATION_INDEX)
play animation PREVIEW_ANIMATION_INDEX
endif
if format = FORMAT_SOUND
endif
if format = FORMAT_IMAGE
endif
endfunction
REM **************************************************
REM Returns a number based on the format of the file
REM -1 is returned if file is a directory or
REM an unknown file type.
REM See constants at top for available format types
REM **************************************************
function getFileFormat(filename as string)
ext$ = getExtension$(filename)
if ext$ = "" then exitfunction 0
for i = 1 to array count(formats())
ft = formats(i).formatType
if formats(i).extension = ext$ then exitfunction ft
next i
endfunction 0
REM **************************************************
REM Draws a spectrum meter from (X,Y) to (X+125,Y+40)
REM **************************************************
function _handleSpectrum(x,y)
box x,y,x+125,y+40,rgb(194,204,216),rgb(240,242,245),rgb(194,204,216),rgb(240,242,245)
for j = 0 to 9
drawMeter(x+3+(j*12),y+37,bars(j+1))
next j
if bars(0) + 100 <= timer()
for j = 1 to 10
bars(j) = rnd(17)
next j
bars(0) = timer()
endif
endfunction
REM **************************************************
REM Draws a spectrum bar from (X,Y) to (X+10,Y-40)
REM **************************************************
function drawMeter(x,y,value)
for k = 0 to 17
if k <= value : ink rgb(17,21,26),0 : else : ink rgb(152,164,178),0 : endif
box x,y-k*2,x+10,y-k*2+1
next k
endfunction
REM **************************************************
REM Resets all spectrum values
REM **************************************************
function resetSpectrum()
for j = 1 to 10
bars(j) = -1
next j
endfunction
REM **************************************************
REM Pauses the spectrum
REM **************************************************
function pauseSpectrum()
bars(0) = timer()+65535
endfunction
REM **************************************************
REM Resumes the spectrum
REM **************************************************
function resumeSpectrum()
bars(0) = 0
endfunction
REM **************************************************
REM Returns the string truncated to a specified width
REM in pixels.
REM **************************************************
function capLength$(string$, width)
if text width(string$) < width then exitfunction string$
L = len(string$)
min = width / text width("A")
for j = min to L
if text width(left$(string$,j)) > width then exitfunction left$(string$,j-1)
next j
endfunction string$
REM **************************************************
REM Checks to see if mouse is within the specified
REM coordinates
REM **************************************************
function mouseWithin(x1,y1,x2,y2)
if mousex() > x1 and mousex() < x2 and mousey() > y1 and mousey() < y2 then exitfunction 1
endfunction 0
REM **************************************************
REM Returns a linear interpolated color between base
REM color and target color. Percent ranges from 0 to 1
REM **************************************************
function getTransitionalColor(base, target, percent#)
br = rgbr(base)
bg = rgbg(base)
bb = rgbb(base)
tr = rgbr(target)
tg = rgbg(target)
tb = rgbb(target)
tr = br + (tr-br)*percent#
tg = bg + (tg-bg)*percent#
tb = bb + (tb-bb)*percent#
color = rgb(tr,tg,tb)
endfunction color
REM **************************************************
REM Get smallest of two values
REM **************************************************
function getMin(x,y)
if x > y then exitfunction y
endfunction x
REM **************************************************
REM Get smallest of two values
REM **************************************************
function getMax(x,y)
if x < y then exitfunction y
endfunction x
REM **************************************************
REM Returns a color with an alpha value
REM **************************************************
function argb(a,r,g,b)
c = (a*16777216)+(r*65536)+(g*256)+b
endfunction c
REM **************************************************
REM Draws an outline inside the given box dimensions
REM **************************************************
function drawOutline(x1,y1,x2,y2,thickness,color)
ink color,0
box x1,y1,x2,y1+thickness
box x1,y1,x1+thickness,y2
box x2-thickness,y1,x2,y2
box x1,y2-thickness,x2,y2
endfunction
REM **************************************************
REM sorts the files by type
REM **************************************************
function sortFiles()
temp as _Node
flag = 0
repeat
flag = 0
for i = 1 to array count(fileList())-1
if compareTo(i,i+1) = 1
flag = 1
temp = fileList(i)
fileList(i) = fileList(i+1)
fileList(i+1) = temp
endif
next i
until flag = 0
endfunction
REM **************************************************
REM Returns 1 if index1 is greater than index2
REM Returns 0 if both are equal
REM Returns -1 if index1 is less than index2
REM **************************************************
function compareTo(index1, index2)
if fileList(index1).fileType > fileList(index2).fileType then exitfunction -1
if fileList(index1).fileType < fileList(index2).fileType
exitfunction 1
else
rem if nodes are files, sort by extension
if fileList(index1).fileType = NODE_TYPE_FILE
ext1$ = getExtension$(lower$(fileList(index1).name))
ext2$ = getExtension$(lower$(fileList(index2).name))
if ext1$ > ext2$ then exitfunction 1
if ext1$ < ext2$ then exitfunction -1
endif
rem if nodes have matching file extensions or are not files at all
if lower$(fileList(index1).name) > lower$(fileList(index2).name) then exitfunction 1
if lower$(fileList(index1).name) < lower$(fileList(index2).name) then exitfunction -1
endif
endfunction 0
REM **************************************************
REM Returns true if string$ ends with suffix$
REM **************************************************
function endsWith(string$, suffix$)
if len(suffix$) > len(string$) then exitfunction 0
L = len(string$)
for k = len(suffix$) to 1 step -1
if mid$(suffix$,k) <> mid$(string$,L) then exitfunction 0
dec L
next k
endfunction 1
REM **************************************************
REM Returns the substring after the right-most period
REM An empty string is returned if no period is found
REM Result will always be returned in lower case
REM **************************************************
function getExtension$(string$)
L = len(string$)
for k = L to 1 step -1
if mid$(string$,k) = "." then exitfunction lower$(right$(string$, L-k))
next k
endfunction ""
FORMAT_DATA:
DATA 13
DATA 1,3,"wav","mp3","wma"
DATA 2,7,"jpg", "jpeg", "bmp", "png", "tga", "dds", "dib"
DATA 3,3,"mpeg", "avi", "gif"