TCoverFlow
Fonte: source/classes/tcvrflow.prg
Inherits from: TControl
TCoverFlow is a cover-flow image browser control inspired by the iTunes / Apple Cover Flow user interface. It displays a horizontal row of images with the center item enlarged and the side items angled outward. Users can navigate left and right via mouse clicks, keyboard arrows, or programmatic calls.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
aCovers | Array | Array of cover definitions (bitmap, text, color) |
nAt | Numeric | Index of the currently selected cover |
nAngle | Numeric | Angle (in degrees) applied to side covers |
nSeparation | Numeric | Pixel separation between covers |
nCoverWidth | Numeric | Width of each cover image |
bAction | Block | Code block evaluated when a cover is selected |
Methods
| Method | Description |
|---|---|
New( nTop, nLeft, nBottom, nRight, oWnd ) | Create a new TCoverFlow control |
AddCover( cBmp, cText, nClrText ) | Add a cover with bitmap, caption, and text color |
GoLeft() | Navigate one cover to the left |
GoRight() | Navigate one cover to the right |
GoTo( n ) | Jump directly to the cover at index n |
AtCover( nRow, nCol ) | Return the cover index at the given pixel coordinates |
Example: Album Browser
#include "FiveWin.ch"
function Main()
local oWnd, oCover, aCovers := { "cover1.jpg", "cover2.jpg", "cover3.jpg" }
DEFINE WINDOW oWnd TITLE "Album Browser" SIZE 800, 400
@ 20, 20 COVERFLOW oCover ;
SIZE 760, 320 OF oWnd ;
ACTION ( MsgInfo( "Selected cover #" + Str( oCover:nAt ) ) )
oCover:AddCover( "cover1.jpg", "Album One", CLR_WHITE )
oCover:AddCover( "cover2.jpg", "Album Two", CLR_WHITE )
oCover:AddCover( "cover3.jpg", "Album Three", CLR_WHITE )
oCover:nAngle := 20
oCover:nSeparation := 60
oCover:nCoverWidth := 200
oCover:GoTo( 1 )
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- The
AddCover()method expects a bitmap file path or a resource name forcBmp. Images are internally scaled tonCoverWidthwhile preserving aspect ratio. - Navigation can be performed with mouse clicks on the left/right covers or by using left/right arrow keys when the control has focus.
- The
bActioncode block (or theACTIONclause in theCOVERFLOWcommand) fires when the user double-clicks or presses Enter on the center cover. - The
AtCover()method is useful for hit-testing during custom mouse handling. - Adjust
nAngleandnSeparationto control the perspective and spacing of side covers.