IDE: In Project Options show build modes more distinctively. Issue #40816, patch by n7800.

This commit is contained in:
Juha 2024-04-05 17:07:17 +03:00
parent 1fa34e6268
commit f468a36dd0
7 changed files with 225 additions and 170 deletions

View File

@ -245,11 +245,11 @@ const
CompilerOptionsDebugging = 0500;
CompilerOptionsVerbosity = 0600;
CompilerOptionsMessages = 0700;
CompilerOptionsOther = 0800;
CompilerOptionsConditional = 0900; // IDE Macros
CompilerOptionsAdditionsAndOverrides = 1000;
CompilerOptionsInherited = 1100;
CompilerOptionsCompilation = 1200;
CompilerOptionsConditional = 0800; // IDE Macros
CompilerOptionsInherited = 0900;
CompilerOptionsCompilation = 1000;
CompilerOptionsOther = 1100;
CompilerOptionsAdditionsAndOverrides = 1200;
GroupPkgCompiler = 200200;

View File

@ -688,7 +688,6 @@ begin
chkUseAsDefault.Caption := dlgCOSetAsDefault;
chkUseAsDefault.ShowHint := True;
chkUseAsDefault.Hint := lisWhenEnabledTheCurrentOptionsAreSavedToTheTemplateW;
chkUseAsDefault.TabStop := False;
end;
procedure TCompilerPathOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);

View File

@ -7,17 +7,17 @@ inherited IDEOptionsDialog: TIDEOptionsDialog
Constraints.MinHeight = 350
Constraints.MinWidth = 500
KeyPreview = True
Position = poWorkAreaCenter
OnKeyDown = FormKeyDown
OnShow = FormShow
Position = poWorkAreaCenter
object ButtonPanel: TButtonPanel[0]
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
Left = 6
Height = 56
Top = 438
Height = 34
Top = 460
Width = 788
BorderSpacing.Left = 6
BorderSpacing.Right = 6
@ -35,164 +35,171 @@ inherited IDEOptionsDialog: TIDEOptionsDialog
CancelButton.Name = 'CancelButton'
CancelButton.Hint = '[Esc]'
CancelButton.DefaultCaption = True
TabOrder = 4
TabOrder = 3
ShowButtons = [pbOK, pbCancel, pbHelp]
end
object CatTVSplitter: TSplitter[1]
Left = 255
Height = 438
object Splitter: TSplitter[1]
Left = 261
Height = 460
Top = 0
Width = 4
Width = 6
end
object CategoryPanel: TPanel[2]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 0
Height = 438
object LeftPanel: TPanel[2]
Left = 6
Height = 460
Top = 0
Width = 255
Align = alLeft
BorderSpacing.Left = 6
BevelOuter = bvNone
ClientHeight = 438
ClientHeight = 460
ClientWidth = 255
Constraints.MinWidth = 150
TabOrder = 0
object CategoryTree: TTreeView
AnchorSideLeft.Control = FilterEdit
AnchorSideTop.Control = FilterEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = CategoryPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = SettingsPanel
Left = 6
Height = 388
Top = 44
Width = 249
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 6
ReadOnly = True
ScrollBars = ssAutoBoth
ShowSeparators = False
TabOrder = 1
OnChange = CategoryTreeChange
OnCollapsed = CategoryTreeCollapsed
OnCustomDrawItem = CategoryTreeCustomDrawItem
OnExpanded = CategoryTreeExpanded
OnKeyDown = CategoryTreeKeyDown
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
end
object FilterEdit: TTreeFilterEdit
AnchorSideLeft.Control = CategoryPanel
AnchorSideTop.Control = CategoryPanel
AnchorSideRight.Side = asrBottom
Left = 6
Height = 32
Hint = '[Ctrl+F]'
Top = 6
Width = 249
OnFilterItem = FilterEditFilterItem
ButtonWidth = 23
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 6
NumGlyphs = 1
MaxLength = 0
ParentShowHint = False
ShowHint = True
TabOrder = 0
FilteredTreeview = CategoryTree
ExpandAllInitially = True
end
object SettingsPanel: TPanel
Left = 0
Height = 6
Top = 432
Top = 454
Width = 255
Align = alBottom
AutoSize = True
BevelOuter = bvNone
Constraints.MinHeight = 6
TabOrder = 2
end
end
object BuildModeSelectPanel: TPanel[3]
AnchorSideLeft.Control = CatTVSplitter
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
AnchorSideRight.Control = EditorsPanel
AnchorSideRight.Side = asrBottom
Left = 259
Height = 40
Top = 0
Width = 535
Anchors = [akTop, akLeft, akRight]
BevelOuter = bvNone
ClientHeight = 40
ClientWidth = 535
TabOrder = 2
object BuildModeComboBox: TComboBox
AnchorSideLeft.Control = BuildModesLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = BuildModeSelectPanel
Left = 105
Height = 31
Top = 6
Width = 175
BorderSpacing.Left = 6
BorderSpacing.Top = 6
ItemHeight = 0
OnSelect = BuildModeComboBoxSelect
Style = csDropDownList
TabOrder = 0
end
object BuildModeManageButton: TButton
AnchorSideLeft.Control = BuildModeComboBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = BuildModeComboBox
AnchorSideBottom.Control = BuildModeComboBox
AnchorSideBottom.Side = asrBottom
Left = 281
Height = 31
Top = 6
Width = 23
Anchors = [akTop, akLeft, akBottom]
BorderSpacing.Left = 1
Caption = '...'
OnClick = BuildModeManageButtonClick
object CategoryPanel: TPanel
Left = 0
Height = 454
Top = 0
Width = 255
Align = alClient
BevelOuter = bvNone
ClientHeight = 454
ClientWidth = 255
TabOrder = 1
end
object BuildModesLabel: TLabel
AnchorSideLeft.Control = BuildModeSelectPanel
AnchorSideTop.Control = BuildModeComboBox
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 14
Width = 93
BorderSpacing.Left = 6
Caption = 'BuildModesLabel'
ParentColor = False
object FilterEdit: TTreeFilterEdit
Left = 0
Height = 21
Hint = '[Ctrl+F]'
Top = 6
Width = 255
CharCase = ecNormal
OnFilterItem = FilterEditFilterItem
ButtonWidth = 23
Align = alTop
BorderSpacing.Top = 6
BorderSpacing.Bottom = 6
NumGlyphs = 1
MaxLength = 0
TabOrder = 0
FilteredTreeview = CategoryTree
ExpandAllInitially = True
end
object CategoryTree: TTreeView
Left = 0
Height = 421
Top = 33
Width = 255
Align = alClient
BorderSpacing.Top = 6
ReadOnly = True
ScrollBars = ssAutoBoth
TabOrder = 1
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
OnChange = CategoryTreeChange
OnCollapsed = CategoryTreeCollapsed
OnCustomDrawItem = CategoryTreeCustomDrawItem
OnExpanded = CategoryTreeExpanded
OnKeyDown = CategoryTreeKeyDown
end
end
end
object EditorsPanel: TScrollBox[4]
AnchorSideLeft.Control = CatTVSplitter
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = BuildModeSelectPanel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ButtonPanel
Left = 259
Height = 398
Top = 40
Width = 535
HorzScrollBar.Page = 1
HorzScrollBar.Tracking = True
VertScrollBar.Page = 1
VertScrollBar.Tracking = True
Anchors = [akTop, akLeft, akRight, akBottom]
object RightPanel: TPanel[3]
Left = 267
Height = 454
Top = 6
Width = 527
Align = alClient
BorderSpacing.Top = 6
BorderSpacing.Right = 6
BorderStyle = bsNone
BevelOuter = bvNone
ClientHeight = 454
ClientWidth = 527
TabOrder = 1
object BuildModeSelectPanel: TPanel
Left = 0
Height = 42
Top = 0
Width = 527
Align = alTop
AutoSize = True
BevelOuter = bvNone
ClientHeight = 42
ClientWidth = 527
TabOrder = 1
object BuildModesLabel: TLabel
Left = 0
Height = 21
Top = 0
Width = 94
Align = alLeft
Caption = 'BuildModesLabel'
Font.Style = [fsBold]
Layout = tlCenter
ParentColor = False
ParentFont = False
end
object BuildModeComboBox: TComboBox
Left = 100
Height = 21
Top = 0
Width = 144
Align = alLeft
BorderSpacing.Left = 6
ItemHeight = 13
ParentShowHint = False
ShowHint = True
Style = csDropDownList
TabOrder = 0
OnSelect = BuildModeComboBoxSelect
end
object BuildModeManageButton: TSpeedButton
Left = 248
Height = 21
Top = 0
Width = 23
Align = alLeft
BorderSpacing.Left = 4
ShowHint = True
ParentFont = False
ParentShowHint = False
OnClick = BuildModeManageButtonClick
end
object BuildModeDividerBevel: TDividerBevel
Left = 0
Height = 13
Top = 25
Width = 527
Align = alBottom
BorderSpacing.Top = 4
BorderSpacing.Bottom = 4
Font.Style = [fsBold]
ParentFont = False
end
end
object EditorsPanel: TScrollBox
Left = 0
Height = 406
Top = 42
Width = 527
HorzScrollBar.Page = 1
HorzScrollBar.Tracking = True
VertScrollBar.Page = 1
VertScrollBar.Tracking = True
Align = alClient
BorderSpacing.Bottom = 6
BorderStyle = bsNone
TabOrder = 0
end
end
end

View File

@ -35,12 +35,12 @@ uses
LCLType, Controls, Forms, ComCtrls, Buttons, ButtonPanel, ExtCtrls, StdCtrls,
Dialogs, Graphics,
// LazControls
TreeFilterEdit,
TreeFilterEdit, DividerBevel,
// LazUtils
LazLoggerBase,
// IdeIntf
IDEWindowIntf, IDEOptionsIntf, IDEOptEditorIntf, IDECommands, IDEHelpIntf,
IdeIntfStrConsts, ProjectIntf,
IdeIntfStrConsts, IDEImagesIntf, ProjectIntf,
// IdeConfig
EnvironmentOpts,
// IDE
@ -62,13 +62,16 @@ type
TIDEOptionsDialog = class(TAbstractOptionsEditorDialog)
BuildModeComboBox: TComboBox;
BuildModeManageButton: TButton;
BuildModeManageButton: TSpeedButton;
BuildModeSelectPanel: TPanel;
ButtonPanel: TButtonPanel;
CategoryPanel: TPanel;
CategoryTree: TTreeView;
CatTVSplitter: TSplitter;
Splitter: TSplitter;
EditorsPanel: TScrollBox;
LeftPanel: TPanel;
RightPanel: TPanel;
BuildModeDividerBevel: TDividerBevel;
FilterEdit: TTreeFilterEdit;
BuildModesLabel: TLabel;
SettingsPanel: TPanel;
@ -89,6 +92,8 @@ type
procedure OkButtonClick(Sender: TObject);
procedure CancelButtonClick(Sender: TObject);
private
FTitle: string;
FIsProjectOptionsDialog: boolean;
FEditorsCreated: Boolean;
FEditorToOpen: TAbstractIDEOptionsEditorClass;
FNewLastSelected: PIDEOptionsEditorRec;
@ -112,7 +117,8 @@ type
procedure SetSettings(const AValue: TIDEOptionsEditorSettings);
function AllBuildModes: boolean;
procedure UpdateBuildModeButtons;
procedure SetBuildModeVisibility(AVisibility: Boolean);
procedure UpdateDialogCaption;
procedure SetTitle(ATitle: string);
public
constructor Create(AOwner: TComponent); override;
function ShowModal: Integer; override;
@ -130,6 +136,7 @@ type
procedure ReadAll;
procedure WriteAll(Restore: boolean);
public
property Title: string read FTitle write SetTitle;
property OptionsFilter: TIDEOptionsEditorFilter read FOptionsFilter write FOptionsFilter;
property Settings: TIDEOptionsEditorSettings read FSettings write SetSettings;
property OnLoadIDEOptionsHook: TOnLoadIDEOptions read FOnLoadOptionsHook write FOnLoadOptionsHook;
@ -164,7 +171,7 @@ begin
FPrevEditor := nil;
FEditorsCreated := False;
FEditorToOpen := nil;
SetBuildModeVisibility(False);
BuildModeSelectPanel.Visible := False;
btnApply := AddButton;
btnApply.LoadGlyphFromResource(idButtonRetry);
@ -176,6 +183,7 @@ begin
// caption
Caption := dlgIDEOptions;
FTitle := Caption;
BuildModesLabel.Caption := lisBuildModes;
ButtonPanel.OKButton.Caption := lisBtnOk;
ButtonPanel.CancelButton.Caption := lisCancel;
@ -185,6 +193,12 @@ begin
// hint
ButtonPanel.ShowHint := true;
btnApply.Hint := '[Shift+Enter]';
BuildModeManageButton.Hint := lisEditBuildModes + ' [Ctrl+B]';
BuildModeComboBox.Hint := lisSelectBuildMode + ' [Ctrl+Shift+B]';
FilterEdit.TextHint := lisFindOption + ' [Ctrl+F]';
// images
IDEImages.AssignImage(BuildModeManageButton, 'menu_compiler_options');
BuildModeComboBox.DropDownCount := EnvironmentOptions.DropDownCount;
IDEDialogLayoutList.ApplyLayout(Self);
@ -238,12 +252,17 @@ begin
AEditor := TAbstractIDEOptionsEditor(Node.Data);
GroupClass := FindGroupClass(Node);
end;
FIsProjectOptionsDialog := Assigned(GroupClass)
and (GroupClass.InheritsFrom(TAbstractIDEProjectOptions) or
GroupClass.InheritsFrom(TProjectCompilerOptions));
UpdateDialogCaption;
// Show the Build Mode panel for project compiler options
SetBuildModeVisibility((GroupClass <> nil)
and (GroupClass.InheritsFrom(TProjectCompilerOptions)));
BuildModeSelectPanel.Visible := Assigned(GroupClass)
and GroupClass.InheritsFrom(TProjectCompilerOptions)
and not AEditor.InheritsFrom(TCompOptModeMatrixFrame); // exclude "Additions and Overrides" frame
// Show the Apply button only for global options (not project or package options).
btnApply.Visible := (GroupClass <> nil)
and (GroupClass.InheritsFrom(TAbstractIDEEnvironmentOptions));
btnApply.Visible := Assigned(GroupClass)
and GroupClass.InheritsFrom(TAbstractIDEEnvironmentOptions);
// Hide the old and show the new editor frame
if Assigned(AEditor) then
FNewLastSelected := AEditor.Rec;
@ -252,7 +271,6 @@ begin
FPrevEditor.Visible := False;
if Assigned(AEditor) then begin
AEditor.Align := alClient;
AEditor.BorderSpacing.Around := 6;
SetDropDownCount(AEditor);
AEditor.Visible := True;
end;
@ -262,18 +280,25 @@ end;
procedure TIDEOptionsDialog.BuildModeComboBoxSelect(Sender: TObject);
begin
if not FIsProjectOptionsDialog then exit;
if AllBuildModes then
ShowMessage(lisThisWillAllowChangingAllBuildModesAtOnceNotImpleme)
else begin
Assert(BuildModeSelectPanel.Visible, 'BuildModeComboBoxSelect: BuildModeSelectPanel not Visible');
SwitchBuildMode(BuildModeComboBox.Text);
UpdateDialogCaption;
end;
end;
procedure TIDEOptionsDialog.BuildModeManageButtonClick(Sender: TObject);
begin
if not FIsProjectOptionsDialog then exit;
if ShowBuildModesDlg(Project1.SessionStorage in pssHasSeparateSession) = mrOK then
begin
UpdateBuildModeCombo(BuildModeComboBox);
UpdateDialogCaption;
end;
end;
procedure TIDEOptionsDialog.CategoryTreeCollapsed(Sender: TObject; Node: TTreeNode);
@ -330,6 +355,7 @@ end;
procedure TIDEOptionsDialog.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
// dialog
if (Key = VK_ESCAPE) and (Shift = []) then
begin
CancelButtonClick(Sender);
@ -346,11 +372,30 @@ begin
Key := 0;
end
// filter
else if (Key = VK_F) and (Shift = [ssCtrl]) then
begin
if FilterEdit.CanSetFocus then
FilterEdit.SetFocus;
Key := 0;
end
// build modes
else if (Key = VK_B) and (Shift = [ssCtrl]) then
begin
BuildModeManageButtonClick(Sender);
Key := 0;
end
else if (Key = VK_B) and (Shift = [ssCtrl, ssShift]) then
begin
with BuildModeComboBox do
if FIsProjectOptionsDialog and (Items.Count > 0) then
begin
// next mode (in a circle)
ItemIndex := (ItemIndex + 1) mod Items.Count;
BuildModeComboBoxSelect(Sender);
end;
Key := 0;
end;
end;
@ -401,6 +446,12 @@ begin
ModalResult := mrCancel;
end;
procedure TIDEOptionsDialog.SetTitle(ATitle: string);
begin
FTitle := ATitle;
UpdateDialogCaption;
end;
function TIDEOptionsDialog.FindGroupClass(Node: TTreeNode): TAbstractIDEOptionsClass;
// Find the group category class where this node belongs to.
begin
@ -736,19 +787,13 @@ begin
ModeMatrix.UpdateModes;
end;
procedure TIDEOptionsDialog.SetBuildModeVisibility(AVisibility: Boolean);
procedure TIDEOptionsDialog.UpdateDialogCaption;
begin
BuildModeSelectPanel.Visible := AVisibility;
if AVisibility then
begin
EditorsPanel.AnchorSide[akTop].Control := BuildModeSelectPanel;
EditorsPanel.AnchorSide[akTop].Side := asrBottom;
end
// Show current build mode in Caption for Project options dialog
if FIsProjectOptionsDialog then
Caption := Format('%s [%s]', [FTitle, BuildModeComboBox.Text])
else
begin
EditorsPanel.AnchorSide[akTop].Control := Self;
EditorsPanel.AnchorSide[akTop].Side := asrTop;
end;
Caption := FTitle;
end;
procedure TIDEOptionsDialog.DoOpenEditor(EditorToOpen: TAbstractIDEOptionsEditorClass);
@ -806,8 +851,9 @@ function TIDEOptionsDialog.AddControl(AControlClass: TControlClass): TControl;
begin
Result := AControlClass.Create(Self);
Result.Parent := SettingsPanel;
Result.BorderSpacing.Top := 6;
Result.BorderSpacing.Bottom := 6;
Result.Align := alBottom;
Result.BorderSpacing.Around := 6;
end;
procedure TIDEOptionsDialog.OpenEditor(AEditor: TAbstractIDEOptionsEditorClass);

View File

@ -4732,7 +4732,7 @@ resourcestring
lisPckEditCompileEverything = 'Compile everything?';
lisPckEditReCompileThisAndAllRequiredPackages = 'Re-Compile this and all '
+'required packages?';
lisPckEditCompilerOptionsForPackage = 'Compiler Options for Package %s';
lisPckEditOptionsForPackage = 'Options for Package: %s';
lisPckEditSavePackage = 'Save Package';
lisPckEditCompilePackage = 'Compile package';
lisPckEditAddFilesFromFileSystem = 'Add Files from File System';
@ -5912,7 +5912,10 @@ resourcestring
+'sources and compile, but functions like find declaration will show unit-'
+'not-found errors. This can take a minute.';
lisActive = 'Active';
lisBuildModes = 'Build modes';
lisBuildModes = 'Build mode:';
lisEditBuildModes = 'Edit build modes';
lisSelectBuildMode = 'Select build mode';
lisFindOption = 'Find option';
lisAddFcUTF8 = 'Add -FcUTF8';
lisAddFcUTF8Hint = 'May be needed if source files have non-ansistring literals.';
lisInSession = 'In session';

View File

@ -5050,7 +5050,7 @@ begin
IDEOptionsDialog := TIDEOptionsDialog.Create(nil);
try
if ACaption <> '' then
IDEOptionsDialog.Caption := ACaption;
IDEOptionsDialog.Title := ACaption;
if Length(AOptionsFilter) = 0 then
begin
SetLength(OptionsFilter{%H-}, 1);

View File

@ -1249,7 +1249,7 @@ begin
Package1.IDEOptions.OnBeforeRead:=PackageEditors.OnBeforeReadPackage;
Package1.IDEOptions.OnAfterWrite:=PackageEditors.OnAfterWritePackage;
LazarusIDE.DoOpenIDEOptions(nil,
Format(lisPckEditCompilerOptionsForPackage, [LazPackage.IDAsString]),
Format(lisPckEditOptionsForPackage, [LazPackage.IDAsString]),
[TPackageIDEOptions, TPkgCompilerOptions], Settings[LazPackage.ReadOnly]);
UpdateTitle;
UpdateButtons;