mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-10 15:08:28 +02:00
IDE: Editor-Macros window: added buttons for play and record
git-svn-id: trunk@37721 -
This commit is contained in:
parent
204c6e854c
commit
f274a81bb1
@ -12,25 +12,25 @@ object MacroListView: TMacroListView
|
||||
Left = 0
|
||||
Height = 194
|
||||
Top = 0
|
||||
Width = 239
|
||||
Width = 221
|
||||
Align = alLeft
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Right = 12
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 194
|
||||
ClientWidth = 239
|
||||
ClientWidth = 221
|
||||
TabOrder = 0
|
||||
object lbRecordedView: TListView
|
||||
Left = 0
|
||||
Height = 172
|
||||
Top = 22
|
||||
Width = 239
|
||||
Width = 221
|
||||
Align = alClient
|
||||
AutoWidthLastColumn = True
|
||||
BorderSpacing.Top = 6
|
||||
Columns = <
|
||||
item
|
||||
Width = 10
|
||||
Width = 217
|
||||
end>
|
||||
RowSelect = True
|
||||
ShowColumnHeaders = False
|
||||
@ -42,7 +42,7 @@ object MacroListView: TMacroListView
|
||||
Left = 0
|
||||
Height = 16
|
||||
Top = 0
|
||||
Width = 239
|
||||
Width = 221
|
||||
Align = alTop
|
||||
Caption = 'lblRecordedTitle'
|
||||
ParentColor = False
|
||||
@ -66,15 +66,16 @@ object MacroListView: TMacroListView
|
||||
ShowButtons = [pbClose]
|
||||
end
|
||||
object pnlButtons: TPanel
|
||||
Left = 251
|
||||
Left = 233
|
||||
Height = 194
|
||||
Top = 0
|
||||
Width = 99
|
||||
Width = 117
|
||||
Align = alRight
|
||||
AutoSize = True
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 194
|
||||
ClientWidth = 99
|
||||
ClientWidth = 117
|
||||
Constraints.MinHeight = 150
|
||||
TabOrder = 2
|
||||
object btnSelect: TButton
|
||||
AnchorSideLeft.Control = pnlButtons
|
||||
@ -85,7 +86,7 @@ object MacroListView: TMacroListView
|
||||
Left = 6
|
||||
Height = 25
|
||||
Top = 6
|
||||
Width = 87
|
||||
Width = 105
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 6
|
||||
@ -97,15 +98,15 @@ object MacroListView: TMacroListView
|
||||
end
|
||||
object btnRename: TButton
|
||||
AnchorSideLeft.Control = pnlButtons
|
||||
AnchorSideTop.Control = btnSelect
|
||||
AnchorSideTop.Control = btnPlay
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = pnlButtons
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 25
|
||||
Top = 37
|
||||
Width = 87
|
||||
Top = 68
|
||||
Width = 105
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 6
|
||||
@ -115,5 +116,67 @@ object MacroListView: TMacroListView
|
||||
OnClick = btnRenameClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object btnPlay: TButton
|
||||
AnchorSideLeft.Control = pnlButtons
|
||||
AnchorSideTop.Control = btnSelect
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = pnlButtons
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 25
|
||||
Top = 37
|
||||
Width = 105
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 6
|
||||
BorderSpacing.Right = 6
|
||||
Caption = 'btnPlay'
|
||||
OnClick = btnPlayClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object btnRecord: TButton
|
||||
AnchorSideLeft.Control = pnlButtons
|
||||
AnchorSideTop.Control = btnRename
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = pnlButtons
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = pnlButtons
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 25
|
||||
Top = 163
|
||||
Width = 105
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Right = 6
|
||||
BorderSpacing.Bottom = 6
|
||||
Caption = 'btnRecord'
|
||||
OnClick = btnRecordClick
|
||||
TabOrder = 3
|
||||
end
|
||||
object btnRecordStop: TButton
|
||||
AnchorSideLeft.Control = pnlButtons
|
||||
AnchorSideTop.Control = btnRename
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = pnlButtons
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = btnRecord
|
||||
Left = 6
|
||||
Height = 25
|
||||
Top = 132
|
||||
Width = 105
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Right = 6
|
||||
BorderSpacing.Bottom = 6
|
||||
Caption = 'btnRecordStop'
|
||||
OnClick = btnRecordStopClick
|
||||
TabOrder = 4
|
||||
Visible = False
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5,8 +5,9 @@ unit EditorMacroListViewer;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, SynMacroRecorder, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
||||
ButtonPanel, ComCtrls, ExtCtrls, MainBar, IDEWindowIntf, IDEImagesIntf, LazarusIDEStrConsts;
|
||||
Classes, SysUtils, FileUtil, SynMacroRecorder, SynEdit, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, ButtonPanel, ComCtrls, ExtCtrls, MainBar, IDEWindowIntf, IDEImagesIntf,
|
||||
LazarusIDEStrConsts, SrcEditorIntf;
|
||||
|
||||
type
|
||||
|
||||
@ -36,6 +37,9 @@ type
|
||||
{ TMacroListView }
|
||||
|
||||
TMacroListView = class(TForm)
|
||||
btnPlay: TButton;
|
||||
btnRecord: TButton;
|
||||
btnRecordStop: TButton;
|
||||
btnSelect: TButton;
|
||||
btnRename: TButton;
|
||||
ButtonPanel1: TButtonPanel;
|
||||
@ -44,6 +48,9 @@ type
|
||||
Panel1: TPanel;
|
||||
pnlButtons: TPanel;
|
||||
RenameButton: TPanelBitBtn;
|
||||
procedure btnPlayClick(Sender: TObject);
|
||||
procedure btnRecordClick(Sender: TObject);
|
||||
procedure btnRecordStopClick(Sender: TObject);
|
||||
procedure btnRenameClick(Sender: TObject);
|
||||
procedure btnSelectClick(Sender: TObject);
|
||||
procedure lbRecordedViewSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean);
|
||||
@ -53,6 +60,7 @@ type
|
||||
FImageSel: Integer;
|
||||
procedure DoOnMacroListChange(Sender: TObject);
|
||||
procedure UpdateDisplay;
|
||||
procedure UpdateButtons;
|
||||
protected
|
||||
procedure DoEditorMacroStateChanged;
|
||||
public
|
||||
@ -126,6 +134,38 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMacroListView.btnPlayClick(Sender: TObject);
|
||||
begin
|
||||
if EditorMacroRecorder.State <> msStopped then exit;
|
||||
if lbRecordedView.ItemIndex < 0 then exit;
|
||||
|
||||
EditorMacroRecorder.AssignEventsFrom(EditorMacroList.Macros[lbRecordedView.ItemIndex]);
|
||||
EditorMacroRecorder.PlaybackMacro(TCustomSynEdit(SourceEditorManagerIntf.ActiveEditor.EditorControl));
|
||||
|
||||
EditorMacroRecorder.AssignEventsFrom(CurrentActiveMacro);
|
||||
end;
|
||||
|
||||
procedure TMacroListView.btnRecordClick(Sender: TObject);
|
||||
begin
|
||||
if EditorMacroRecorder.State = msStopped then begin
|
||||
EditorMacroRecorder.RecordMacro(TCustomSynEdit(SourceEditorManagerIntf.ActiveEditor.EditorControl));
|
||||
end
|
||||
else
|
||||
if EditorMacroRecorder.State = msRecording then begin
|
||||
EditorMacroRecorder.Pause;
|
||||
end
|
||||
else
|
||||
if EditorMacroRecorder.State = msPaused then begin
|
||||
EditorMacroRecorder.Resume;
|
||||
end;
|
||||
SourceEditorManagerIntf.ActiveEditor.EditorControl.SetFocus;
|
||||
end;
|
||||
|
||||
procedure TMacroListView.btnRecordStopClick(Sender: TObject);
|
||||
begin
|
||||
EditorMacroRecorder.Stop;
|
||||
end;
|
||||
|
||||
procedure TMacroListView.btnSelectClick(Sender: TObject);
|
||||
begin
|
||||
if EditorMacroRecorder.State <> msStopped then exit;
|
||||
@ -140,8 +180,7 @@ end;
|
||||
procedure TMacroListView.lbRecordedViewSelectItem(Sender: TObject; Item: TListItem;
|
||||
Selected: Boolean);
|
||||
begin
|
||||
btnSelect.Enabled := (EditorMacroRecorder.State = msStopped) and (lbRecordedView.ItemIndex >= 0);
|
||||
btnRename.Enabled := (lbRecordedView.ItemIndex >= 0);
|
||||
UpdateButtons;
|
||||
end;
|
||||
|
||||
procedure TMacroListView.DoOnMacroListChange(Sender: TObject);
|
||||
@ -177,6 +216,24 @@ begin
|
||||
lbRecordedView.ItemIndex := -1;
|
||||
|
||||
lbRecordedViewSelectItem(nil, nil, False);
|
||||
UpdateButtons;
|
||||
end;
|
||||
|
||||
procedure TMacroListView.UpdateButtons;
|
||||
begin
|
||||
btnSelect.Enabled := (EditorMacroRecorder.State = msStopped) and (lbRecordedView.ItemIndex >= 0);
|
||||
btnRename.Enabled := (lbRecordedView.ItemIndex >= 0);
|
||||
btnPlay.Enabled := (lbRecordedView.ItemIndex >= 0);
|
||||
|
||||
btnRecord.Enabled := (EditorMacroRecorder.State in [msStopped, msPaused, msRecording]);
|
||||
btnRecordStop.Visible := (EditorMacroRecorder.State in [msPaused, msRecording]);
|
||||
|
||||
if (EditorMacroRecorder.State = msRecording) then
|
||||
btnRecord.Caption := lisPause
|
||||
else if (EditorMacroRecorder.State = msPaused) then
|
||||
btnRecord.Caption := lisContinue
|
||||
else
|
||||
btnRecord.Caption := lisRecord;
|
||||
end;
|
||||
|
||||
procedure TMacroListView.DoEditorMacroStateChanged;
|
||||
@ -192,12 +249,15 @@ begin
|
||||
lblRecordedTitle.Caption := lisRecordedMacros;
|
||||
btnSelect.Caption := lisMenuSelect;
|
||||
btnRename.Caption := lisRename2;
|
||||
btnPlay.Caption := lisPlay;
|
||||
btnRecord.Caption := lisRecord;
|
||||
btnRecordStop.Caption := lisStop;
|
||||
lbRecordedView.SmallImages := IDEImages.Images_16;
|
||||
FImageRec := IDEImages.LoadImage(16, 'Record'); // red dot
|
||||
FImagePlay := IDEImages.LoadImage(16, 'menu_run'); // green triangle
|
||||
FImageSel := IDEImages.LoadImage(16, 'arrow_right');
|
||||
|
||||
lbRecordedViewSelectItem(nil, nil, False);
|
||||
UpdateButtons;
|
||||
end;
|
||||
|
||||
{ TEditorMacroList }
|
||||
|
@ -5535,6 +5535,8 @@ resourcestring
|
||||
lisRename2 = 'Rename ...';
|
||||
lisNewMacroName = 'Macro %d';
|
||||
lisEditorMacros = 'Editor macros';
|
||||
lisPlay = 'Play';
|
||||
lisRecord = 'Record';
|
||||
|
||||
implementation
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user