@@ -6,7 +6,7 @@ interface |
| 6 |
|
6 |
|
| 7 |
uses |
7 |
uses |
| 8 |
Classes, SysUtils, Controls, Graphics, Constants, LCLType, math, |
8 |
Classes, SysUtils, Controls, Graphics, Constants, LCLType, math, |
| 9 |
LCLIntf, LMessages, HugeDatatypes; |
9 |
LCLIntf, LMessages, HugeDatatypes, ClipboardUtils; |
| 10 |
|
10 |
|
| 11 |
// TODO: Maybe read these from a config file |
11 |
// TODO: Maybe read these from a config file |
| 12 |
const |
12 |
const |
@@ -20,6 +20,9 @@ const |
| 20 |
clFxPan = clInstrument; |
20 |
clFxPan = clInstrument; |
| 21 |
clFxSong = TColor($00007F); |
21 |
clFxSong = TColor($00007F); |
| 22 |
|
22 |
|
|
|
23 |
clHighlighted = TColor($7A99A9); |
|
|
24 |
clSelected = TColor($9EB4C0); |
|
|
25 |
|
| 23 |
NUM_COLUMNS = 4; |
26 |
NUM_COLUMNS = 4; |
| 24 |
NUM_ROWS = 64; |
27 |
NUM_ROWS = 64; |
| 25 |
|
28 |
|
@@ -75,9 +78,13 @@ type |
| 75 |
|
78 |
|
| 76 |
DigitInputting: Boolean; |
79 |
DigitInputting: Boolean; |
| 77 |
|
80 |
|
|
|
81 |
FHighlightedRow: Integer; |
|
|
82 |
|
| 78 |
procedure RenderRow(Row: Integer); |
83 |
procedure RenderRow(Row: Integer); |
| 79 |
procedure RenderCell(const Cell: TCell); |
84 |
procedure RenderCell(const Cell: TCell); |
| 80 |
|
85 |
|
|
|
86 |
procedure SetHighlightedRow(Row: Integer); |
|
|
87 |
|
| 81 |
function GetEffectColor(EffectCode: Integer): TColor; |
88 |
function GetEffectColor(EffectCode: Integer): TColor; |
| 82 |
function SelectionsToRect(S1, S2: TSelectionPos): TRect; |
89 |
function SelectionsToRect(S1, S2: TSelectionPos): TRect; |
| 83 |
function SelectionToRect(Selection: TSelectionPos): TRect; |
90 |
function SelectionToRect(Selection: TSelectionPos): TRect; |
@@ -87,6 +94,7 @@ type |
| 87 |
public |
94 |
public |
| 88 |
Cursor, Other: TSelectionPos; |
95 |
Cursor, Other: TSelectionPos; |
| 89 |
ColumnWidth, RowHeight: Integer; |
96 |
ColumnWidth, RowHeight: Integer; |
|
|
97 |
property HighlightedRow: Integer read FHighlightedRow write SetHighlightedRow; |
| 90 |
|
98 |
|
| 91 |
procedure LoadPattern(Idx: Integer; Pat: PPattern); |
99 |
procedure LoadPattern(Idx: Integer; Pat: PPattern); |
| 92 |
end; |
100 |
end; |
@@ -132,19 +140,16 @@ begin |
| 132 |
Clear; |
140 |
Clear; |
| 133 |
|
141 |
|
| 134 |
for I := 0 to High(TPattern) do begin |
142 |
for I := 0 to High(TPattern) do begin |
| 135 |
if (I mod 4) = 0 then begin |
143 |
if (I mod 4) = 0 then |
| 136 |
Brush.Color := RGBToColor(216, 209, 195); |
144 |
Brush.Color := RGBToColor(216, 209, 195); |
| 137 |
FillRect(0, I*RowHeight, Width, (I+1)*RowHeight); |
145 |
if (I mod 16) = 0 then |
| 138 |
end; |
|
|
| 139 |
if (I mod 16) = 0 then begin |
|
|
| 140 |
Brush.Color := RGBToColor(206, 197, 181); |
146 |
Brush.Color := RGBToColor(206, 197, 181); |
| 141 |
FillRect(0, I*RowHeight, Width, (I+1)*RowHeight); |
147 |
if I = Cursor.Y then |
| 142 |
end; |
148 |
Brush.Color := clSelected; |
| 143 |
if I = Cursor.Y then begin |
149 |
if I = FHighlightedRow then |
| 144 |
Brush.Color := RGBToColor(169, 153, 122); |
150 |
Brush.Color := clHighlighted; |
| 145 |
FillRect(0, I*RowHeight, Width, (I+1)*RowHeight); |
|
|
| 146 |
end; |
|
|
| 147 |
|
151 |
|
|
|
152 |
FillRect(0, I*RowHeight, Width, (I+1)*RowHeight); |
| 148 |
MoveTo(0, I*RowHeight); |
153 |
MoveTo(0, I*RowHeight); |
| 149 |
RenderRow(I); |
154 |
RenderRow(I); |
| 150 |
end; |
155 |
end; |
@@ -240,13 +245,14 @@ begin |
| 240 |
DigitInputting := False; |
245 |
DigitInputting := False; |
| 241 |
end; |
246 |
end; |
| 242 |
else begin |
247 |
else begin |
| 243 |
case Cursor.SelectedPart of |
248 |
if not (ssCtrl in Shift) then |
| 244 |
cpNote: InputNote(Key); |
249 |
case Cursor.SelectedPart of |
| 245 |
cpInstrument: InputInstrument(Key); |
250 |
cpNote: InputNote(Key); |
| 246 |
cpVolume: InputVolume(Key); |
251 |
cpInstrument: InputInstrument(Key); |
| 247 |
cpEffectCode: InputEffectCode(Key); |
252 |
cpVolume: InputVolume(Key); |
| 248 |
cpEffectParams: InputEffectParams(Key); |
253 |
cpEffectCode: InputEffectCode(Key); |
| 249 |
end; |
254 |
cpEffectParams: InputEffectParams(Key); |
|
|
255 |
end; |
| 250 |
end; |
256 |
end; |
| 251 |
end; |
257 |
end; |
| 252 |
|
258 |
|
@@ -260,15 +266,38 @@ begin |
| 260 |
end; |
266 |
end; |
| 261 |
|
267 |
|
| 262 |
procedure TTrackerGrid.DoPaste(var Msg: TLMessage); |
268 |
procedure TTrackerGrid.DoPaste(var Msg: TLMessage); |
|
|
269 |
var |
|
|
270 |
Paste: TSelection; |
|
|
271 |
X, Y: Integer; |
| 263 |
begin |
272 |
begin |
|
|
273 |
try |
|
|
274 |
Paste := GetPastedCells; |
|
|
275 |
for Y := 0 to High(Paste) do begin |
|
|
276 |
if Cursor.Y+Y > High(TPattern) then Break; |
|
|
277 |
for X := 0 to High(Paste[Y]) do begin |
|
|
278 |
if Cursor.X+X > High(Patterns) then Break; |
|
|
279 |
Patterns[Cursor.X + X]^[Cursor.Y + Y] := Paste[Y, X]; |
|
|
280 |
end; |
|
|
281 |
end; |
|
|
282 |
Other.X := Cursor.X + X; |
|
|
283 |
Other.Y := Cursor.Y + Y; |
|
|
284 |
Other.SelectedPart := High(TCellPart); |
|
|
285 |
except |
|
|
286 |
on E: Exception do |
|
|
287 |
WriteLn(StdErr, 'Clipboard did not contain valid note data!'); |
|
|
288 |
end; |
|
|
289 |
|
|
|
290 |
Invalidate; |
| 264 |
end; |
291 |
end; |
| 265 |
|
292 |
|
| 266 |
procedure TTrackerGrid.DoCopy(var Msg: TLMessage); |
293 |
procedure TTrackerGrid.DoCopy(var Msg: TLMessage); |
| 267 |
begin |
294 |
begin |
|
|
295 |
|
| 268 |
end; |
296 |
end; |
| 269 |
|
297 |
|
| 270 |
procedure TTrackerGrid.DoCut(var Msg: TLMessage); |
298 |
procedure TTrackerGrid.DoCut(var Msg: TLMessage); |
| 271 |
begin |
299 |
begin |
|
|
300 |
|
| 272 |
end; |
301 |
end; |
| 273 |
|
302 |
|
| 274 |
procedure TTrackerGrid.RenderSelectedArea; |
303 |
procedure TTrackerGrid.RenderSelectedArea; |
@@ -419,6 +448,12 @@ begin |
| 419 |
end; |
448 |
end; |
| 420 |
end; |
449 |
end; |
| 421 |
|
450 |
|
|
|
451 |
procedure TTrackerGrid.SetHighlightedRow(Row: Integer); |
|
|
452 |
begin |
|
|
453 |
FHighlightedRow := Row; |
|
|
454 |
if FHighlightedRow >= 0 then Invalidate; |
|
|
455 |
end; |
|
|
456 |
|
| 422 |
function TTrackerGrid.GetEffectColor(EffectCode: Integer): TColor; |
457 |
function TTrackerGrid.GetEffectColor(EffectCode: Integer): TColor; |
| 423 |
begin |
458 |
begin |
| 424 |
Result := clBlack; |
459 |
Result := clBlack; |