mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 12:29:30 +02:00
SourceEditor/IDE Layout: more multi-window changes
git-svn-id: trunk@24194 -
This commit is contained in:
parent
e1d960ff51
commit
3e92d4df61
@ -809,6 +809,8 @@ var XMLConfig: TXMLConfig;
|
||||
OldDebuggerType: TDebuggerType;
|
||||
Path: String;
|
||||
CurPath: String;
|
||||
i: Integer;
|
||||
name: String;
|
||||
|
||||
procedure LoadBackupInfo(var BackupInfo: TBackupInfo; const Path:string);
|
||||
var i:integer;
|
||||
@ -878,6 +880,14 @@ begin
|
||||
Path+'ShowCompileDialog/Value',false);
|
||||
|
||||
// windows
|
||||
i := XMLConfig.GetValue(Path+'Desktop/FormIdCount', 0);
|
||||
while i > 0 do begin
|
||||
name := XMLConfig.GetValue(Path+'Desktop/FormIdList/a'+IntToStr(i), '');
|
||||
if (name <> '') and (IDEWindowLayoutList.ItemByFormID(name) = nil) then
|
||||
CreateWindowLayout(name);
|
||||
dec(i);
|
||||
end;
|
||||
|
||||
FIDEWindowLayoutList.LoadFromXMLConfig(XMLConfig,
|
||||
Path+'Desktop/');
|
||||
FIDEDialogLayoutList.LoadFromConfig(FConfigStore,
|
||||
|
@ -91,6 +91,7 @@ end;
|
||||
procedure TWindowOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
|
||||
var
|
||||
Window: TNonModalIDEWindow;
|
||||
i: Integer;
|
||||
begin
|
||||
// windows
|
||||
MinimizeAllOnMinimizeMainCheckBox.Caption := dlgMinimizeAllOnMinimizeMain;
|
||||
@ -108,6 +109,11 @@ begin
|
||||
for Window := Succ(Low(TNonModalIDEWindow)) to High(TNonModalIDEWindow) do
|
||||
Add(GetCaptionFor(Window));
|
||||
Add(dlgObjInsp);
|
||||
for i := 0 to EnvironmentOptions.IDEWindowLayoutList.Count - 1 do
|
||||
if (EnvironmentOptions.IDEWindowLayoutList[i].FormID <> DefaultObjectInspectorName) and
|
||||
(NonModalIDEFormIDToEnum(EnvironmentOptions.IDEWindowLayoutList[i].FormID) = nmiwNone)
|
||||
then
|
||||
Add(EnvironmentOptions.IDEWindowLayoutList[i].FormCaption);
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
@ -253,6 +259,8 @@ begin
|
||||
begin
|
||||
case Index - Ord(High(TNonModalIDEWindow)) of
|
||||
0: Layout := FLayouts.ItemByFormID(DefaultObjectInspectorName);
|
||||
else
|
||||
Layout := FLayouts.ItemByFormCaption(WindowPositionsListBox.Items[Index]);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -172,6 +172,7 @@ type
|
||||
|
||||
TIDEWindowLayout = class
|
||||
private
|
||||
FFormCaption: string;
|
||||
FVisible: boolean;
|
||||
fWindowPlacement: TIDEWindowPlacement;
|
||||
fWindowPlacementsAllowed: TIDEWindowPlacements;
|
||||
@ -222,6 +223,8 @@ type
|
||||
procedure CloseForm;
|
||||
public
|
||||
property FormID: string read GetFormID write SetFormID;
|
||||
function FormBaseID(out SubIndex: Integer): String;
|
||||
property FormCaption: string read FFormCaption;
|
||||
property WindowPlacement: TIDEWindowPlacement
|
||||
read fWindowPlacement write SetWindowPlacement;
|
||||
property WindowPlacementsAllowed: TIDEWindowPlacements
|
||||
@ -265,6 +268,7 @@ type
|
||||
function IndexOf(const FormID: string): integer;
|
||||
function ItemByForm(AForm: TCustomForm): TIDEWindowLayout;
|
||||
function ItemByFormID(const FormID: string): TIDEWindowLayout;
|
||||
function ItemByFormCaption(const aFormCaption: string): TIDEWindowLayout;
|
||||
function ItemByEnum(ID: TNonModalIDEWindow): TIDEWindowLayout;
|
||||
procedure CloseForm(AForm: TCustomForm);
|
||||
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
|
||||
@ -433,6 +437,7 @@ begin
|
||||
P:=GetXMLFormID;
|
||||
if P='' then exit;
|
||||
P:=Path+P+'/';
|
||||
FFormCaption := XMLConfig.GetValue(P+'Caption/Value', fFormID);
|
||||
// placement
|
||||
fWindowPlacement:=StrToIDEWindowPlacement(XMLConfig.GetValue(
|
||||
P+'WindowPlacement/Value',IDEWindowPlacementNames[fWindowPlacement]));
|
||||
@ -468,6 +473,7 @@ begin
|
||||
P:=GetXMLFormID;
|
||||
if P='' then exit;
|
||||
P:=Path+P+'/';
|
||||
XMLConfig.SetDeleteValue(P+'Caption/Value',FFormCaption,'');
|
||||
// placement
|
||||
XMLConfig.SetDeleteValue(P+'WindowPlacement/Value',
|
||||
IDEWindowPlacementNames[fWindowPlacement],
|
||||
@ -527,14 +533,33 @@ end;
|
||||
|
||||
procedure TIDEWindowLayout.CloseForm;
|
||||
begin
|
||||
GetCurrentPosition;
|
||||
Form:=nil;
|
||||
end;
|
||||
|
||||
function TIDEWindowLayout.FormBaseID(out SubIndex: Integer): String;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result := FormID;
|
||||
SubIndex := -1;
|
||||
i := length(Result);
|
||||
while (i > 0) and (Result[i] in ['0'..'9']) do
|
||||
dec(i);
|
||||
if (i < 1) or (i = length(Result)) then
|
||||
exit;
|
||||
SubIndex := StrToInt(copy(Result, i+1, length(Result)));
|
||||
Result := copy(Result, 1, i);
|
||||
end;
|
||||
|
||||
procedure TIDEWindowLayout.SetForm(const AValue: TCustomForm);
|
||||
begin
|
||||
if fForm=AValue then exit;
|
||||
fForm:=AValue;
|
||||
if (Form<>nil) then fFormID:=FForm.Name;
|
||||
if (Form<>nil) then begin
|
||||
fFormID := FForm.Name;
|
||||
FFormCaption := fForm.Caption;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TIDEWindowLayout.GetFormID: string;
|
||||
@ -551,7 +576,9 @@ var
|
||||
begin
|
||||
Result:=GetFormID;
|
||||
for i:=1 to length(Result) do
|
||||
if not (Result[i] in ['A'..'Z','a'..'z','_']) then
|
||||
if not ( (Result[i] in ['A'..'Z','a'..'z','_'])
|
||||
or ( (i > 1) and (Result[i] in ['0'..'9'])) )
|
||||
then
|
||||
Result[i]:='_';
|
||||
end;
|
||||
|
||||
@ -632,11 +659,6 @@ begin
|
||||
Top:=Form.RestoredTop;
|
||||
Width:=Form.RestoredWidth;
|
||||
Height:=Form.RestoredHeight;
|
||||
end else begin
|
||||
Left:=0;
|
||||
Top:=0;
|
||||
Width:=0;
|
||||
Height:=0;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -731,8 +753,11 @@ procedure TIDEWindowLayoutList.SaveToXMLConfig(XMLConfig: TXMLConfig;
|
||||
const Path: string);
|
||||
var i: integer;
|
||||
begin
|
||||
for i:=0 to Count-1 do
|
||||
XMLConfig.SetDeleteValue(Path+'FormIdCount',Count,0);
|
||||
for i:=0 to Count-1 do Begin
|
||||
XMLConfig.SetDeleteValue(Path+'FormIdList/a'+IntToStr(i), Items[i].FormID, '');
|
||||
Items[i].SaveToXMLConfig(XMLConfig,Path);
|
||||
end
|
||||
end;
|
||||
|
||||
function TIDEWindowLayoutList.ItemByForm(AForm: TCustomForm): TIDEWindowLayout;
|
||||
@ -758,6 +783,20 @@ begin
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
function TIDEWindowLayoutList.ItemByFormCaption(const aFormCaption: string
|
||||
): TIDEWindowLayout;
|
||||
var i: integer;
|
||||
begin
|
||||
i := Count - 1;
|
||||
while i >= 0 do begin
|
||||
Result := Items[i];
|
||||
if Result.FormCaption = aFormCaption then
|
||||
exit;
|
||||
dec(i);
|
||||
end;
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
function TIDEWindowLayoutList.ItemByEnum(ID: TNonModalIDEWindow
|
||||
): TIDEWindowLayout;
|
||||
begin
|
||||
|
28
ide/main.pp
28
ide/main.pp
@ -7580,12 +7580,13 @@ var NewSrcEdit: TSourceEditor;
|
||||
SrcNotebook: TSourceNotebook;
|
||||
begin
|
||||
AFilename:=AnUnitInfo.Filename;
|
||||
{$note Todo:remap window index in all unit infos}
|
||||
{$note Todo:remap layout for each windows }
|
||||
if (WindowIndex < 0) then
|
||||
SrcNotebook := SourceEditorManager.ActiveOrNewSourceWindow
|
||||
else if (WindowIndex >= SourceEditorManager.SourceWindowCount) then
|
||||
SrcNotebook := SourceEditorManager.NewSourceWindow
|
||||
else
|
||||
if (WindowIndex >= SourceEditorManager.SourceWindowCount) then begin
|
||||
SrcNotebook := SourceEditorManager.NewSourceWindow;
|
||||
Project1.MoveUnitWindowIndex(WindowIndex, SourceEditorManager.ActiveSourceWindowIndex);
|
||||
end
|
||||
else
|
||||
SrcNotebook := SourceEditorManager.SourceWindows[WindowIndex];
|
||||
|
||||
@ -16367,12 +16368,13 @@ end;
|
||||
|
||||
procedure TMainIDE.OnApplyWindowLayout(ALayout: TIDEWindowLayout);
|
||||
var
|
||||
l: TNonModalIDEWindow;
|
||||
WindowType: TNonModalIDEWindow;
|
||||
BarBottom: Integer;
|
||||
DockingAllowed: Boolean;
|
||||
NewHeight: Integer;
|
||||
NewBounds: TRect;
|
||||
SrcNoteBook: TSourceNotebook;
|
||||
SubIndex: Integer;
|
||||
begin
|
||||
if (ALayout=nil) or (ALayout.Form=nil) then exit;
|
||||
// debugln('TMainIDE.OnApplyWindowLayout ',ALayout.Form.Name,' ',ALayout.Form.Classname,' ',IDEWindowPlacementNames[ALayout.WindowPlacement],' ',ALayout.CustomCoordinatesAreValid,' ',ALayout.Left,' ',ALayout.Top,' ',ALayout.Width,' ',ALayout.Height);
|
||||
@ -16381,9 +16383,13 @@ begin
|
||||
ALayout.Form.Constraints.MaxHeight:=0;
|
||||
end;
|
||||
|
||||
l:=NonModalIDEFormIDToEnum(ALayout.FormID);
|
||||
WindowType:=NonModalIDEFormIDToEnum(ALayout.FormID);
|
||||
SubIndex := -1;
|
||||
if WindowType = nmiwNone then begin
|
||||
WindowType:=NonModalIDEFormIDToEnum(ALayout.FormBaseID(SubIndex));
|
||||
end;
|
||||
if DockingAllowed then begin
|
||||
if l in [nmiwSourceNoteBookName] then
|
||||
if WindowType in [nmiwSourceNoteBookName] then
|
||||
ALayout.WindowPlacement:=iwpDocked;
|
||||
end;
|
||||
|
||||
@ -16432,7 +16438,7 @@ begin
|
||||
// no layout found => use default
|
||||
BarBottom:=MainIDEBar.Top+MainIDEBar.Height;
|
||||
// default window positions
|
||||
case l of
|
||||
case WindowType of
|
||||
nmiwMainIDEName:
|
||||
begin
|
||||
NewHeight:=95;
|
||||
@ -16447,8 +16453,10 @@ begin
|
||||
end;
|
||||
nmiwSourceNoteBookName:
|
||||
begin
|
||||
ALayout.Form.SetBounds(250,BarBottom+30,Max(50,Screen.Width-300),
|
||||
Max(50,Screen.Height-200-BarBottom));
|
||||
if SubIndex < 0 then SubIndex := 0;
|
||||
SubIndex := SubIndex * 30;
|
||||
ALayout.Form.SetBounds(250 + SubIndex, BarBottom + 30 + SubIndex,
|
||||
Max(50,Screen.Width-300-SubIndex), Max(50,Screen.Height-200-BarBottom-SubIndex));
|
||||
if DockingAllowed then begin
|
||||
debugln('TMainIDE.OnApplyWindowLayout ',dbgsName(ALayout.Form));
|
||||
ALayout.Form.ManualDock(MainIDEBar,nil,alBottom,false);
|
||||
|
@ -209,6 +209,7 @@ begin
|
||||
while (i>=0) do begin
|
||||
if Screen.CustomForms[i].Caption=(Sender as TIDEMenuCommand).Caption then
|
||||
begin
|
||||
Screen.CustomForms[i].Show;
|
||||
Screen.CustomForms[i].BringToFront;
|
||||
break;
|
||||
end;
|
||||
|
@ -740,6 +740,7 @@ type
|
||||
procedure RemoveNonExistingFiles(RemoveFromUsesSection: boolean = true);
|
||||
function CreateProjectFile(const Filename: string): TLazProjectFile; override;
|
||||
procedure UpdateVisibleUnit(AnEditor: TSourceEditorInterface; AWindowIndex: Integer);
|
||||
procedure MoveUnitWindowIndex(OldIndex, NewIndex: Integer);
|
||||
// search
|
||||
function IndexOf(AUnitInfo: TUnitInfo): integer;
|
||||
function IndexOfUnitWithName(const AnUnitName: string;
|
||||
@ -2885,6 +2886,36 @@ begin
|
||||
Units[i].IsVisibleTab := Units[i].EditorComponent = AnEditor;
|
||||
end;
|
||||
|
||||
procedure TProject.MoveUnitWindowIndex(OldIndex, NewIndex: Integer);
|
||||
var
|
||||
i: Integer;
|
||||
AnUnitInfo: TUnitInfo;
|
||||
begin
|
||||
i:=UnitCount-1;
|
||||
while (i>=0) do begin
|
||||
AnUnitInfo:=Units[i];
|
||||
|
||||
if (OldIndex < 0) then begin
|
||||
// index inserted
|
||||
if (AnUnitInfo.WindowIndex >= NewIndex) then
|
||||
AnUnitInfo.WindowIndex := AnUnitInfo.WindowIndex + 1;
|
||||
end
|
||||
else if AnUnitInfo.WindowIndex = OldIndex then begin
|
||||
AnUnitInfo.WindowIndex := NewIndex;
|
||||
end
|
||||
else if (OldIndex > NewIndex) then begin
|
||||
if (AnUnitInfo.WindowIndex >= NewIndex) and (AnUnitInfo.WindowIndex < OldIndex) then
|
||||
AnUnitInfo.WindowIndex := AnUnitInfo.WindowIndex + 1;
|
||||
end
|
||||
else if (OldIndex < NewIndex) then begin
|
||||
if (AnUnitInfo.WindowIndex > OldIndex) and (AnUnitInfo.WindowIndex <= NewIndex) then
|
||||
AnUnitInfo.WindowIndex := AnUnitInfo.WindowIndex - 1;
|
||||
end;
|
||||
|
||||
dec(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProject.RemoveNonExistingFiles(RemoveFromUsesSection: boolean);
|
||||
var
|
||||
i: Integer;
|
||||
|
@ -4274,6 +4274,7 @@ end;
|
||||
constructor TSourceNotebook.Create(AOwner: TComponent);
|
||||
var
|
||||
i: Integer;
|
||||
n: TComponent;
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FManager := TSourceEditorManager(AOwner);
|
||||
@ -4281,7 +4282,8 @@ begin
|
||||
FFocusLock := 0;
|
||||
Visible:=false;
|
||||
i := 2;
|
||||
if SourceEditorManager.SourceWindowCount > 0 then begin
|
||||
n := Owner.FindComponent(NonModalIDEWindowNames[nmiwSourceNoteBookName]);
|
||||
if (n <> nil) and (n <> self) then begin
|
||||
while Owner.FindComponent(NonModalIDEWindowNames[nmiwSourceNoteBookName]+IntToStr(i)) <> nil do
|
||||
inc(i);
|
||||
Name := NonModalIDEWindowNames[nmiwSourceNoteBookName] + IntToStr(i);
|
||||
@ -4295,9 +4297,9 @@ begin
|
||||
KeyPreview:=true;
|
||||
FProcessingCommand := false;
|
||||
|
||||
if EnvironmentOptions.IDEWindowLayoutList.ItemByFormID(self.Name) <> nil then {$note create new layouts for extra windows}
|
||||
if EnvironmentOptions.IDEWindowLayoutList.ItemByFormID(self.Name) = nil then
|
||||
EnvironmentOptions.CreateWindowLayout(self.name);
|
||||
EnvironmentOptions.IDEWindowLayoutList.Apply(Self, self.Name);
|
||||
//EnvironmentOptions.IDEWindowLayoutList.Apply(Self,Name);
|
||||
ControlDocker:=TLazControlDocker.Create(Self);
|
||||
ControlDocker.Name:='SourceEditor';
|
||||
{$IFDEF EnableIDEDocking}
|
||||
@ -5089,9 +5091,13 @@ procedure TSourceNotebook.DoClose(var CloseAction: TCloseAction);
|
||||
begin
|
||||
inherited DoClose(CloseAction);
|
||||
{$IFDEF MultiSrcWindow}
|
||||
if PageCount = 0 then {$NOTE maybe keep the last one}
|
||||
CloseAction := caFree
|
||||
else
|
||||
if PageCount = 0 then begin { $NOTE maybe keep the last one}
|
||||
if EnvironmentOptions.IDEWindowLayoutList.ItemByFormID(Self.Name) <> nil then
|
||||
EnvironmentOptions.IDEWindowLayoutList.ItemByFormID(Self.Name).CloseForm;
|
||||
// Make the name unique, because it may not immediately be released
|
||||
Name := Name + '___' + IntToStr(PtrInt(Pointer(Self)));
|
||||
CloseAction := caFree;
|
||||
end else
|
||||
{$ENDIF}
|
||||
CloseAction := caHide;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user