Skip to content

Commit

Permalink
Add hotkey to change instrument for selected notes
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperDisk committed Dec 8, 2023
1 parent ce24f3a commit 4b7ead0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/tracker.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ object frmTracker: TfrmTracker
Height = 684
Top = 0
Width = 1103
ActivePage = GeneralTabSheet
ActivePage = InstrumentTabSheet
Align = alClient
ParentFont = False
TabIndex = 0
TabIndex = 2
TabOrder = 0
object GeneralTabSheet: TTabSheet
Caption = 'General'
Expand Down Expand Up @@ -411,7 +411,7 @@ object frmTracker: TfrmTracker
BorderSpacing.Right = 7
BorderSpacing.Bottom = 7
Caption = 'Instrument'
ClientHeight = 269
ClientHeight = 254
ClientWidth = 276
ParentFont = False
TabOrder = 0
Expand Down Expand Up @@ -633,7 +633,7 @@ object frmTracker: TfrmTracker
BorderSpacing.Right = 7
BorderSpacing.Bottom = 7
Caption = 'Envelope'
ClientHeight = 132
ClientHeight = 117
ClientWidth = 578
ParentFont = False
TabOrder = 1
Expand Down Expand Up @@ -688,16 +688,16 @@ object frmTracker: TfrmTracker
Top = 0
Width = 270
BevelOuter = bvLowered
ClientHeight = 100
ClientWidth = 266
ClientHeight = 104
ClientWidth = 270
ParentFont = False
TabOrder = 1
object EnvelopePaintbox: TPaintBox
Left = 1
Height = 98
Height = 102
Hint = 'Preview of the volume envelope'
Top = 1
Width = 264
Width = 268
Align = alClient
ParentFont = False
OnPaint = EnvelopePaintboxPaint
Expand Down Expand Up @@ -737,7 +737,7 @@ object frmTracker: TfrmTracker
BorderSpacing.Right = 7
BorderSpacing.Bottom = 7
Caption = 'Square'
ClientHeight = 165
ClientHeight = 150
ClientWidth = 315
ParentFont = False
TabOrder = 2
Expand Down Expand Up @@ -868,7 +868,7 @@ object frmTracker: TfrmTracker
BorderSpacing.Right = 7
BorderSpacing.Bottom = 7
Caption = 'Wave'
ClientHeight = 165
ClientHeight = 150
ClientWidth = 293
ParentFont = False
TabOrder = 3
Expand Down Expand Up @@ -928,16 +928,16 @@ object frmTracker: TfrmTracker
Top = 80
Width = 272
BevelOuter = bvLowered
ClientHeight = 55
ClientWidth = 268
ClientHeight = 59
ClientWidth = 272
ParentFont = False
TabOrder = 1
object WavePaintbox: TPaintBox
Left = 1
Height = 53
Height = 57
Hint = 'Preview of the waveform associated with this instrument'
Top = 1
Width = 266
Width = 270
Align = alClient
Color = clBlack
ParentColor = False
Expand Down Expand Up @@ -2796,6 +2796,11 @@ object frmTracker: TfrmTracker
ShortCut = 16459
OnClick = MenuItem31Click
end
object MenuItem56: TMenuItem
Caption = 'Change Instrument'
ShortCut = 16457
OnClick = MenuItem56Click
end
object MenuItem30: TMenuItem
Caption = '-'
end
Expand Down
7 changes: 7 additions & 0 deletions src/tracker.pas
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ TfrmTracker = class(TForm)
MenuItem26: TMenuItem;
MenuItem42: TMenuItem;
MenuItem55: TMenuItem;
MenuItem56: TMenuItem;
RevertMenuItem: TMenuItem;
Splitter2: TSplitter;
TBMOpenDialog: TOpenDialog;
Expand Down Expand Up @@ -303,6 +304,7 @@ TfrmTracker = class(TForm)
procedure MenuItem15Click(Sender: TObject);
procedure MenuItem26Click(Sender: TObject);
procedure MenuItem55Click(Sender: TObject);
procedure MenuItem56Click(Sender: TObject);
procedure OrderEditStringGridMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure RevertMenuItemClick(Sender: TObject);
Expand Down Expand Up @@ -2087,6 +2089,11 @@ procedure TfrmTracker.MenuItem55Click(Sender: TObject);
end;
end;

procedure TfrmTracker.MenuItem56Click(Sender: TObject);
begin
(ActiveControl as TTrackerGrid).ChangeSelectionInstrument;
end;

procedure TfrmTracker.OrderEditStringGridMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Expand Down
26 changes: 26 additions & 0 deletions src/trackergrid.pas
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ TTrackerGrid = class(TCustomControl)
procedure TransposeSelection(Semitones: Integer);
procedure IncrementSelection(Note, Instrument, Volume, EffectCode, EffectParam: Integer);
procedure InterpolateSelection;
procedure ChangeSelectionInstrument;
procedure OpenEffectEditor;

constructor Create(
Expand Down Expand Up @@ -946,6 +947,31 @@ procedure TTrackerGrid.InterpolateSelection;
EndUndoAction
end;

procedure TTrackerGrid.ChangeSelectionInstrument;
var
Pos: TSelectionPos;
R: Integer;
begin
BeginUndoAction;

NormalizeCursors;

for R := Cursor.Y to Other.Y do begin
Pos := Cursor;
Pos.Y := R;
while Pos <= Other do begin
with Patterns[Pos.X]^[Pos.Y] do
if Note <> NO_NOTE then
Instrument := SelectedInstrument;

IncSelectionPos(Pos);
end;
end;

Invalidate;
EndUndoAction;
end;

procedure TTrackerGrid.OpenEffectEditor;
begin
BeginUndoAction;
Expand Down

0 comments on commit 4b7ead0

Please sign in to comment.