@@ -9,9 +9,7 @@ uses |
| 9 |
LMessages, HugeDatatypes, ClipboardUtils, gdeque, gstack, utils, effecteditor, |
9 |
LMessages, HugeDatatypes, ClipboardUtils, gdeque, gstack, utils, effecteditor, |
| 10 |
Keymap; |
10 |
Keymap; |
| 11 |
|
11 |
|
| 12 |
// TODO: Maybe read these from a config file |
|
|
| 13 |
const |
12 |
const |
| 14 |
NUM_ROWS = 64; |
|
|
| 15 |
UNDO_STACK_SIZE = 100; |
13 |
UNDO_STACK_SIZE = 100; |
| 16 |
|
14 |
|
| 17 |
type |
15 |
type |
@@ -120,7 +118,7 @@ type |
| 120 |
public |
118 |
public |
| 121 |
Cursor, Other: TSelectionPos; |
119 |
Cursor, Other: TSelectionPos; |
| 122 |
ColumnWidth, RowHeight: Integer; |
120 |
ColumnWidth, RowHeight: Integer; |
| 123 |
NumColumns: Integer; |
121 |
NumColumns, NumRows: Integer; |
| 124 |
|
122 |
|
| 125 |
SelectedInstrument, SelectedOctave, Step: Integer; |
123 |
SelectedInstrument, SelectedOctave, Step: Integer; |
| 126 |
|
124 |
|
@@ -156,7 +154,8 @@ type |
| 156 |
AOwner: TComponent; |
154 |
AOwner: TComponent; |
| 157 |
Parent: TWinControl; |
155 |
Parent: TWinControl; |
| 158 |
PatternMap: TPatternMap; |
156 |
PatternMap: TPatternMap; |
| 159 |
NumColumns: Integer); reintroduce; |
157 |
NumColumns: Integer; |
|
|
158 |
NumRows: Integer = 64); reintroduce; |
| 160 |
destructor Destroy; override; |
159 |
destructor Destroy; override; |
| 161 |
end; |
160 |
end; |
| 162 |
|
161 |
|
@@ -311,7 +310,8 @@ constructor TTrackerGrid.Create( |
| 311 |
AOwner: TComponent; |
310 |
AOwner: TComponent; |
| 312 |
Parent: TWinControl; |
311 |
Parent: TWinControl; |
| 313 |
PatternMap: TPatternMap; |
312 |
PatternMap: TPatternMap; |
| 314 |
NumColumns: Integer); |
313 |
NumColumns: Integer; |
|
|
314 |
NumRows: Integer); |
| 315 |
begin |
315 |
begin |
| 316 |
inherited Create(AOwner); |
316 |
inherited Create(AOwner); |
| 317 |
|
317 |
|
@@ -319,6 +319,7 @@ begin |
| 319 |
|
319 |
|
| 320 |
Self.PatternMap := PatternMap; |
320 |
Self.PatternMap := PatternMap; |
| 321 |
Self.NumColumns := NumColumns; |
321 |
Self.NumColumns := NumColumns; |
|
|
322 |
Self.NumRows := NumRows; |
| 322 |
|
323 |
|
| 323 |
SetLength(Patterns, NumColumns); |
324 |
SetLength(Patterns, NumColumns); |
| 324 |
SetLength(PatternNumbers, NumColumns); |
325 |
SetLength(PatternNumbers, NumColumns); |
@@ -357,7 +358,7 @@ begin |
| 357 |
Brush.Color := clBackground; |
358 |
Brush.Color := clBackground; |
| 358 |
Clear; |
359 |
Clear; |
| 359 |
|
360 |
|
| 360 |
for I := 0 to High(TPattern) do begin |
361 |
for I := 0 to NumRows-1 do begin |
| 361 |
if (I mod 4) = 0 then |
362 |
if (I mod 4) = 0 then |
| 362 |
Brush.Color := clLineFour; |
363 |
Brush.Color := clLineFour; |
| 363 |
if (I mod 16) = 0 then |
364 |
if (I mod 16) = 0 then |
@@ -526,8 +527,8 @@ begin |
| 526 |
VK_NEXT: Inc(Cursor.Y, 16); |
527 |
VK_NEXT: Inc(Cursor.Y, 16); |
| 527 |
VK_LEFT: DecSelectionPos(Cursor); |
528 |
VK_LEFT: DecSelectionPos(Cursor); |
| 528 |
VK_RIGHT: IncSelectionPos(Cursor); |
529 |
VK_RIGHT: IncSelectionPos(Cursor); |
| 529 |
VK_HOME: Cursor.Y := Low(TPattern); |
530 |
VK_HOME: Cursor.Y := 0; |
| 530 |
VK_END: Cursor.Y := High(TPattern); |
531 |
VK_END: Cursor.Y := NumRows-1; |
| 531 |
VK_TAB: begin |
532 |
VK_TAB: begin |
| 532 |
if ssShift in Shift then begin |
533 |
if ssShift in Shift then begin |
| 533 |
Dec(Cursor.X); |
534 |
Dec(Cursor.X); |
@@ -554,7 +555,7 @@ begin |
| 554 |
end; |
555 |
end; |
| 555 |
end; |
556 |
end; |
| 556 |
|
557 |
|
| 557 |
if (Cursor.Y > High(TPattern)) or (Cursor.Y < Low(TPattern)) then |
558 |
if (Cursor.Y > NumRows-1) or (Cursor.Y < 0) then |
| 558 |
if Assigned(OnCursorOutOfBounds) then OnCursorOutOfBounds; |
559 |
if Assigned(OnCursorOutOfBounds) then OnCursorOutOfBounds; |
| 559 |
|
560 |
|
| 560 |
if Shift = [] then |
561 |
if Shift = [] then |
@@ -604,7 +605,7 @@ var |
| 604 |
begin |
605 |
begin |
| 605 |
try |
606 |
try |
| 606 |
for Y := 0 to High(Paste) do begin |
607 |
for Y := 0 to High(Paste) do begin |
| 607 |
if not InRange(Where.Y+Y, Low(TPattern), High(TPattern)) then Continue; |
608 |
if not InRange(Where.Y+Y, 0, NumRows-1) then Continue; |
| 608 |
for X := 0 to High(Paste[Y]) do begin |
609 |
for X := 0 to High(Paste[Y]) do begin |
| 609 |
if not InRange(Where.X+X, Low(Patterns), High(Patterns)) then Continue; |
610 |
if not InRange(Where.X+X, Low(Patterns), High(Patterns)) then Continue; |
| 610 |
OverlayCell(Patterns[Where.X + X]^[Where.Y + Y], Paste[Y, X]); |
611 |
OverlayCell(Patterns[Where.X + X]^[Where.Y + Y], Paste[Y, X]); |
@@ -641,7 +642,7 @@ begin |
| 641 |
try |
642 |
try |
| 642 |
Selection := GetPastedCells; |
643 |
Selection := GetPastedCells; |
| 643 |
I := Cursor.Y; |
644 |
I := Cursor.Y; |
| 644 |
while I <= High(TPattern) do begin |
645 |
while I < NumRows do begin |
| 645 |
Cursor.Y := I; |
646 |
Cursor.Y := I; |
| 646 |
PerformPaste(Selection); |
647 |
PerformPaste(Selection); |
| 647 |
Inc(I, High(Selection)+1); |
648 |
Inc(I, High(Selection)+1); |
@@ -812,9 +813,9 @@ begin |
| 812 |
if Other.X > (NumColumns-1) then |
813 |
if Other.X > (NumColumns-1) then |
| 813 |
Other.SelectedPart := High(TCellPart); |
814 |
Other.SelectedPart := High(TCellPart); |
| 814 |
|
815 |
|
| 815 |
Cursor.Y := EnsureRange(Cursor.Y, Low(TPattern), High(TPattern)); |
816 |
Cursor.Y := EnsureRange(Cursor.Y, 0, NumRows-1); |
| 816 |
Cursor.X := EnsureRange(Cursor.X, Low(TPatternGrid), (NumColumns-1)); |
817 |
Cursor.X := EnsureRange(Cursor.X, Low(TPatternGrid), (NumColumns-1)); |
| 817 |
Other.Y := EnsureRange(Other.Y, Low(TPattern), High(TPattern)); |
818 |
Other.Y := EnsureRange(Other.Y, 0, NumRows-1); |
| 818 |
Other.X := EnsureRange(Other.X, Low(TPatternGrid), (NumColumns-1)); |
819 |
Other.X := EnsureRange(Other.X, Low(TPatternGrid), (NumColumns-1)); |
| 819 |
end; |
820 |
end; |
| 820 |
|
821 |
|
@@ -1211,7 +1212,7 @@ begin |
| 1211 |
Y := EnsureRange(Height-1, 0, Y); |
1212 |
Y := EnsureRange(Height-1, 0, Y); |
| 1212 |
|
1213 |
|
| 1213 |
Result.X := Trunc((X/Width)*NumColumns); |
1214 |
Result.X := Trunc((X/Width)*NumColumns); |
| 1214 |
Result.Y := Trunc((Y/Height)*NUM_ROWS); |
1215 |
Result.Y := Trunc((Y/Height)*NumRows); |
| 1215 |
|
1216 |
|
| 1216 |
if OrigX <= 0 then |
1217 |
if OrigX <= 0 then |
| 1217 |
Result.SelectedPart := cpNote |
1218 |
Result.SelectedPart := cpNote |
@@ -1285,7 +1286,7 @@ begin |
| 1285 |
end; |
1286 |
end; |
| 1286 |
|
1287 |
|
| 1287 |
Width := ColumnWidth*NumColumns; |
1288 |
Width := ColumnWidth*NumColumns; |
| 1288 |
Height := RowHeight*64; |
1289 |
Height := RowHeight*NumRows; |
| 1289 |
end; |
1290 |
end; |
| 1290 |
|
1291 |
|
| 1291 |
procedure TTrackerGrid.SetFontSize(AValue: Integer); |
1292 |
procedure TTrackerGrid.SetFontSize(AValue: Integer); |
@@ -1369,7 +1370,7 @@ begin |
| 1369 |
BeginUndoAction; |
1370 |
BeginUndoAction; |
| 1370 |
NormalizeCursors; |
1371 |
NormalizeCursors; |
| 1371 |
|
1372 |
|
| 1372 |
for I := High(TPattern) downto Cursor.Y do |
1373 |
for I := NumRows-1 downto Cursor.Y do |
| 1373 |
Patterns[Pattern]^[I] := Patterns[Pattern]^[I-1]; |
1374 |
Patterns[Pattern]^[I] := Patterns[Pattern]^[I-1]; |
| 1374 |
|
1375 |
|
| 1375 |
BlankCell(Patterns[Pattern]^[Cursor.Y]); |
1376 |
BlankCell(Patterns[Pattern]^[Cursor.Y]); |
@@ -1398,10 +1399,10 @@ begin |
| 1398 |
BeginUndoAction; |
1399 |
BeginUndoAction; |
| 1399 |
NormalizeCursors; |
1400 |
NormalizeCursors; |
| 1400 |
|
1401 |
|
| 1401 |
for I := Cursor.Y to High(TPattern)-1 do |
1402 |
for I := Cursor.Y to NumRows-2 do |
| 1402 |
Patterns[Pattern]^[I] := Patterns[Pattern]^[I+1]; |
1403 |
Patterns[Pattern]^[I] := Patterns[Pattern]^[I+1]; |
| 1403 |
|
1404 |
|
| 1404 |
BlankCell(Patterns[Pattern]^[High(TPattern)]); |
1405 |
BlankCell(Patterns[Pattern]^[NumRows-1]); |
| 1405 |
|
1406 |
|
| 1406 |
Invalidate; |
1407 |
Invalidate; |
| 1407 |
EndUndoAction; |
1408 |
EndUndoAction; |
@@ -1426,7 +1427,7 @@ begin |
| 1426 |
Cursor.Y := 0; |
1427 |
Cursor.Y := 0; |
| 1427 |
Cursor.SelectedPart := cpNote; |
1428 |
Cursor.SelectedPart := cpNote; |
| 1428 |
Other.X := High(Patterns); |
1429 |
Other.X := High(Patterns); |
| 1429 |
Other.Y := High(TPattern); |
1430 |
Other.Y := NumRows-1; |
| 1430 |
Other.SelectedPart := cpEffectParams; |
1431 |
Other.SelectedPart := cpEffectParams; |
| 1431 |
|
1432 |
|
| 1432 |
Invalidate; |
1433 |
Invalidate; |
@@ -1435,7 +1436,7 @@ end; |
| 1435 |
procedure TTrackerGrid.SelectColumn; |
1436 |
procedure TTrackerGrid.SelectColumn; |
| 1436 |
begin |
1437 |
begin |
| 1437 |
Cursor.Y := 0; |
1438 |
Cursor.Y := 0; |
| 1438 |
Other.Y := High(TPattern); |
1439 |
Other.Y := NumRows-1; |
| 1439 |
Cursor.SelectedPart := Low(TCellPart); |
1440 |
Cursor.SelectedPart := Low(TCellPart); |
| 1440 |
Other.SelectedPart := High(TCellPart); |
1441 |
Other.SelectedPart := High(TCellPart); |
| 1441 |
|
1442 |
|