View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0032042 | Lazarus | Widgetset | public | 2017-06-19 23:37 | 2017-09-11 19:16 |
Reporter | CudaText man | Assigned To | Felipe Monteiro de Carvalho | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
OS | OSX 10.8 | ||||
Product Version | 1.9 (SVN) | ||||
Summary | 0032042: Cocoa: MainMenu File forced into "projectname" item | ||||
Description | demo app has mainmenu with 2 top items: File(2 items: aa, bb)/ Edit. Expected menu in app: Project1 - File(with 2 items: aa, bb) - Edit I see menu in app: Project1(with 2 items: aa, bb) - Edit File item missed. | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 55835, 55836, 55837 | ||||
LazTarget | - | ||||
Widgetset | Cocoa | ||||
Attached Files |
|
|
|
|
anchordocking-tanchordockpanel-impl2.patch (19,033 bytes)
Index: components/anchordocking/anchordocking.lpk =================================================================== --- components/anchordocking/anchordocking.lpk (revision 55360) +++ components/anchordocking/anchordocking.lpk (working copy) @@ -2,6 +2,7 @@ <CONFIG> <Package Version="4"> <Name Value="AnchorDocking"/> + <Type Value="RunAndDesignTime"/> <AddToProjectUsesSection Value="True"/> <Author Value="Mattias Gaertner mattias@freepascal.org"/> <CompilerOptions> @@ -18,7 +19,7 @@ <License Value="modified LGPL-2 like LCL "/> <Version Minor="6"/> - <Files Count="7"> + <Files Count="8"> <Item1> <Filename Value="anchordockpkg.pas"/> <Type Value="Main Unit"/> @@ -48,6 +49,11 @@ <Filename Value="anchordockoptionsdlg.lfm"/> <Type Value="LFM"/> </Item7> + <Item8> + <Filename Value="anchordockpanel.pas"/> + <HasRegisterProc Value="True"/> + <UnitName Value="AnchorDockPanel"/> + </Item8> </Files> <LazDoc Paths="doc"/> <i18n> Index: components/anchordocking/anchordocking.pas =================================================================== --- components/anchordocking/anchordocking.pas (revision 55360) +++ components/anchordocking/anchordocking.pas (working copy) @@ -102,7 +102,7 @@ LCLType, LCLIntf, LCLProc, Controls, Forms, ExtCtrls, ComCtrls, Graphics, Themes, Menus, Buttons, LazConfigStorage, Laz2_XMLCfg, LazFileCache, - AnchorDockStr, AnchorDockStorage; + AnchorDockStr, AnchorDockStorage, AnchorDockPanel; {$IFDEF DebugDisableAutoSizing} const ADAutoSizingReason = 'TAnchorDockMaster Delayed'; @@ -307,7 +307,7 @@ OnlyCheckIfPossible: boolean): boolean; function EnlargeSideRotateSplitter(Side: TAnchorKind; OnlyCheckIfPossible: boolean): boolean; - procedure CreateBoundSplitter; + procedure CreateBoundSplitter(disabled:boolean=false); procedure PositionBoundSplitter; public constructor CreateNew(AOwner: TComponent; Num: Integer = 0); override; @@ -590,6 +590,8 @@ procedure MakeDockSite(AForm: TCustomForm; Sites: TAnchors; ResizePolicy: TADMResizePolicy; AllowInside: boolean = false); + procedure MakeDockPanel(APanel:TAnchorDockPanel; + ResizePolicy: TADMResizePolicy); procedure MakeVisible(AControl: TControl; SwitchPages: boolean); function ShowControl(ControlName: string; BringToFront: boolean = false): TControl; procedure CloseAll; @@ -1571,7 +1573,7 @@ end; if (Node.NodeType=adltnCustomSite) then begin AControl:=FindControl(Node.Name); - if IsCustomSite(AControl) then + if (IsCustomSite(AControl))or(AControl is TAnchorDockPanel) then fTreeNameToDocker[Node.Name]:=AControl; end; for i:=0 to Node.Count-1 do @@ -1647,6 +1649,11 @@ if (fTreeNameToDocker[Node.Name]=nil) and (BestSite<>nil) then begin // search the parent site of a child site repeat + if BestSite is TAnchorDockPanel then begin + if fTreeNameToDocker.ControlToName(BestSite)='' then + fTreeNameToDocker[Node.Name]:=BestSite; + break; + end; BestSite:=BestSite.Parent; if BestSite is TAnchorDockHostSite then begin if fTreeNameToDocker.ControlToName(BestSite)='' then @@ -1758,16 +1765,21 @@ aMonitor: TMonitor; aHostSite: TAnchorDockHostSite; begin + if not (tobject (Site) is TAnchorDockPanel) then + begin if Parent=nil then begin if (Node.Monitor>=0) and (Node.Monitor<Screen.MonitorCount) then aMonitor:=Screen.Monitors[Node.Monitor] else aMonitor:=Site.Monitor; + end; WorkArea:=aMonitor.WorkareaRect; {$IFDEF VerboseAnchorDockRestore} debugln(['TAnchorDockMaster.RestoreLayout.SetupSite WorkArea=',dbgs(WorkArea)]); {$ENDIF} - end; + end + else + GetParentForm(Site).BoundsRect:=Node.BoundsRect; if IsCustomSite(Site) then begin aManager:=TAnchorDockManager(Site.DockManager); if Node.Count>0 then begin @@ -1782,8 +1794,15 @@ NewBounds:=Rect(ScaleTopLvlX(NewBounds.Left),ScaleTopLvlY(NewBounds.Top), ScaleTopLvlX(NewBounds.Right),ScaleTopLvlY(NewBounds.Bottom)); end else begin - NewBounds:=Rect(ScaleChildX(NewBounds.Left),ScaleChildY(NewBounds.Top), + if parent is TAnchorDockPanel then + begin + NewBounds:=Rect(0,0,parent.ClientWidth,parent.ClientHeight); + site.Align:=alClient; + end + else + NewBounds:=Rect(ScaleChildX(NewBounds.Left),ScaleChildY(NewBounds.Top), ScaleChildX(NewBounds.Right),ScaleChildY(NewBounds.Bottom)); + end; {$IFDEF VerboseAnchorDockRestore} if Scale then @@ -1791,7 +1810,8 @@ {$ENDIF} Site.BoundsRect:=NewBounds; Site.Visible:=true; - Site.Parent:=Parent; + if not (tobject (Site) is TAnchorDockPanel) then + Site.Parent:=Parent; if IsCustomSite(Parent) then begin aManager:=TAnchorDockManager(Parent.DockManager); Site.Align:=Node.Align; @@ -1808,11 +1828,14 @@ if (Node.NodeType<>adltnPages) and (aHostSite.Pages<>nil) then aHostSite.FreePages; end; + if not (tobject (Site) is TAnchorDockPanel) then + begin if Parent=nil then begin Site.WindowState:=Node.WindowState; end else begin Site.WindowState:=wsNormal; end; + end; end; function GetNodeSite(Node: TAnchorDockLayoutTreeNode): TAnchorDockHostSite; @@ -1875,7 +1898,7 @@ debugln(['TAnchorDockMaster.RestoreLayout.Restore WARNING: can not find control ',Node.Name]); exit; end; - if not IsCustomSite(AControl) then begin + if not (IsCustomSite(AControl)or (AControl is TAnchorDockPanel)) then begin debugln(['TAnchorDockMaster.RestoreLayout.Restore WARNING: ',Node.Name,' is not a custom dock site ',DbgSName(AControl)]); exit; end; @@ -2704,7 +2727,7 @@ AManager: TAnchorDockManager; begin if AForm.Name='' then - raise Exception.Create('TAnchorDockMaster.MakeDockable '+ + raise Exception.Create('TAnchorDockMaster.MakeDockSite '+ adrsMissingControlName); if AForm.DockManager<>nil then raise Exception.Create('TAnchorDockMaster.MakeDockSite DockManager<>nil'); @@ -2733,6 +2756,34 @@ end; end; +procedure TAnchorDockMaster.MakeDockPanel(APanel:TAnchorDockPanel; + ResizePolicy: TADMResizePolicy); +var + AManager: TAnchorDockManager; +begin + if APanel.Name='' then + raise Exception.Create('TAnchorDockMaster.MakeDockPanel '+ + adrsMissingControlName); + if APanel.DockManager<>nil then + raise Exception.Create('TAnchorDockMaster.MakeDockPanel DockManager<>nil'); + APanel.DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TAnchorDockMaster.MakeDockPanel'){$ENDIF}; + try + if FControls.IndexOf(APanel)<0 then begin + FControls.Add(APanel); + APanel.FreeNotification(Self); + end; + AManager:=ManagerClass.Create(APanel); + AManager.DockableSites:=[]; + AManager.InsideDockingAllowed:=true; + AManager.ResizePolicy:=ResizePolicy; + APanel.DockManager:=AManager; + APanel.UseDockManager:=true; + APanel.DockSite:=true; + finally + APanel.EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TAnchorDockMaster.MakeDockPanel'){$ENDIF}; + end; +end; + procedure TAnchorDockMaster.MakeVisible(AControl: TControl; SwitchPages: boolean); begin while AControl<>nil do begin @@ -2806,6 +2857,23 @@ end; end; +function GetParentFormOrDockPanel(Control: TControl): TCustomForm; +begin + while (Control <> nil) and (Control.Parent <> nil) do + begin + if (Control is TAnchorDockPanel) then + Break; + Control := Control.Parent; + end; + if Control is TCustomForm then + Result := TCustomForm(Control) + else + if Control is TAnchorDockPanel then + Result := TCustomForm(Control) + else + Result := nil; +end; + procedure TAnchorDockMaster.SaveMainLayoutToTree(LayoutTree: TAnchorDockLayoutTree); var i: Integer; @@ -2815,6 +2883,28 @@ LayoutNode: TAnchorDockLayoutTreeNode; AForm: TCustomForm; VisibleControls: TStringList; + + procedure saveform(theForm: TCustomForm; SaveChilds:boolean); + begin + // custom dock site + LayoutNode:=LayoutTree.NewNode(LayoutTree.Root); + LayoutNode.NodeType:=adltnCustomSite; + LayoutNode.Assign(theForm,tobject(theForm) is TAnchorDockPanel); + // can have one normal dock site + if SaveChilds then + begin + Site:=TAnchorDockManager(theForm.DockManager).GetChildSite; + if Site<>nil then begin + LayoutNode:=LayoutTree.NewNode(LayoutNode); + Site.SaveLayout(LayoutTree,LayoutNode); + {if Site.BoundSplitter<>nil then begin + LayoutNode:=LayoutTree.NewNode(LayoutNode); + Site.BoundSplitter.SaveLayout(LayoutNode); + end;} + end; + end; + end; + begin SavedSites:=TFPList.Create; VisibleControls:=TStringList.Create; @@ -2823,31 +2913,23 @@ AControl:=Controls[i]; if not DockedControlIsVisible(AControl) then continue; VisibleControls.Add(AControl.Name); - AForm:=GetParentForm(AControl); + AForm:=GetParentFormOrDockPanel(AControl); if AForm=nil then continue; if SavedSites.IndexOf(AForm)>=0 then continue; SavedSites.Add(AForm); debugln(['TAnchorDockMaster.SaveMainLayoutToTree AForm=',DbgSName(AForm)]); DebugWriteChildAnchors(AForm,true,true); - if (AForm is TAnchorDockHostSite) then begin + if (tobject(AForm) is TAnchorDockPanel) then begin + saveform(GetParentFormOrDockPanel(AForm),{false}true); + //LayoutNode:=LayoutTree.NewNode(LayoutTree.Root); + //TAnchorDockPanel(AForm).SaveLayout(LayoutTree,LayoutNode); + end + else if (AForm is TAnchorDockHostSite) then begin Site:=TAnchorDockHostSite(AForm); LayoutNode:=LayoutTree.NewNode(LayoutTree.Root); Site.SaveLayout(LayoutTree,LayoutNode); end else if IsCustomSite(AForm) then begin - // custom dock site - LayoutNode:=LayoutTree.NewNode(LayoutTree.Root); - LayoutNode.NodeType:=adltnCustomSite; - LayoutNode.Assign(AForm); - // can have one normal dock site - Site:=TAnchorDockManager(AForm.DockManager).GetChildSite; - if Site<>nil then begin - LayoutNode:=LayoutTree.NewNode(LayoutNode); - Site.SaveLayout(LayoutTree,LayoutNode); - {if Site.BoundSplitter<>nil then begin - LayoutNode:=LayoutTree.NewNode(LayoutNode); - Site.BoundSplitter.SaveLayout(LayoutNode); - end;} - end; + saveform(AForm,true); end else raise EAnchorDockLayoutError.Create('invalid root control for save: '+DbgSName(AControl)); end; @@ -4778,7 +4860,7 @@ end; end; -procedure TAnchorDockHostSite.CreateBoundSplitter; +procedure TAnchorDockHostSite.CreateBoundSplitter(disabled:boolean=false); begin if BoundSplitter<>nil then exit; FBoundSplitter:=DockMaster.CreateSplitter; @@ -4785,6 +4867,12 @@ BoundSplitter.FreeNotification(Self); BoundSplitter.Align:=Align; BoundSplitter.Parent:=Parent; + if disabled then + begin + BoundSplitter.Width:=0; + BoundSplitter.Height:=0; + BoundSplitter.Visible:=false; + end; end; procedure TAnchorDockHostSite.PositionBoundSplitter; @@ -5544,10 +5632,13 @@ ChildSite:=nil; if Child is TAnchorDockHostSite then begin ChildSite:=TAnchorDockHostSite(Child); - ChildSite.CreateBoundSplitter; + ChildSite.CreateBoundSplitter(Site is TAnchorDockPanel); SplitterWidth:=DockMaster.SplitterWidth; end; + if Site is TAnchorDockPanel then + ADockObject.DropAlign:=alClient; + // resize Site NewSiteBounds:=Site.BoundsRect; case ADockObject.DropAlign of @@ -5555,9 +5646,14 @@ alRight: dec(NewSiteBounds.Right,Child.ClientWidth+SplitterWidth); alTop: dec(NewSiteBounds.Top,Child.ClientHeight+SplitterWidth); alBottom: inc(NewSiteBounds.Bottom,Child.ClientHeight+SplitterWidth); + alClient:begin + Child.BoundsRect:=Site.ClientRect; + Child.Align:=alClient; + end; end; if not StoredConstraintsValid then StoreConstraints; + if ADockObject.DropAlign<>alClient then if ADockObject.DropAlign in [alLeft,alRight] then Site.Constraints.MaxWidth:=0 else @@ -5575,8 +5671,13 @@ alLeft: NewChildBounds:=Bounds(0,0,Child.ClientWidth,Site.ClientHeight); alRight: NewChildBounds:=Bounds(Site.ClientWidth-Child.ClientWidth,0, Child.ClientWidth,Site.ClientHeight); + alClient:begin + NewChildBounds:=Bounds(0,0, + Site.ClientWidth,Site.ClientHeight); + end; end; Child.BoundsRect:=NewChildBounds; + NewChildBounds:=Child.BoundsRect; if ChildSite<>nil then ChildSite.PositionBoundSplitter; @@ -5640,6 +5741,12 @@ or (Site.Parent.Parent<>nil) then Inside:=true; end; + + if Site is TAnchorDockPanel then begin + DockRect:=Bounds(Site.ClientOrigin.x,Site.ClientOrigin.y,Site.ClientWidth,Site.ClientHeight); + exit; + end; + case DropAlign of alLeft: if Inside then @@ -5805,6 +5912,8 @@ case ResizePolicy of admrpChild: begin + if (Child.Parent<>nil)and(not(Child.Parent is TAnchorDockPanel))then + begin if Child.Align in [alLeft,alRight] then Child.Width:=Max(1,Min(ChildMaxSize.X,Child.Width+WidthDiff)) else begin @@ -5814,6 +5923,7 @@ {$ENDIF} Child.Height:=i; end; + end; end; end; end; Index: components/anchordocking/anchordockpanel.pas =================================================================== --- components/anchordocking/anchordockpanel.pas (nonexistent) +++ components/anchordocking/anchordockpanel.pas (working copy) @@ -0,0 +1,80 @@ +unit AnchorDockPanel; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls, + AnchorDockStorage; + +type + TAnchorDockPanel = class(TPanel) + private + + protected + procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState; + var Accept: Boolean); override; + + + public + + procedure SaveLayout(LayoutTree: TAnchorDockLayoutTree; + LayoutNode: TAnchorDockLayoutTreeNode); + function GetOneControl: TControl; + + published + + end; + +procedure Register; + +implementation +uses AnchorDocking; +procedure TAnchorDockPanel.DragOver(Source: TObject; X, Y: Integer; State: TDragState; + var Accept: Boolean); +begin + Accept:=true; +end; + +function TAnchorDockPanel.GetOneControl: TControl; +var + i: Integer; +begin + for i:=0 to ControlCount-1 do begin + Result:=Controls[i]; + if Result.Owner<>Self then exit; + end; + Result:=nil; +end; + +procedure TAnchorDockPanel.SaveLayout( + LayoutTree: TAnchorDockLayoutTree; LayoutNode: TAnchorDockLayoutTreeNode); +var + i: Integer; + Site: TAnchorDockHostSite; + ChildNode: TAnchorDockLayoutTreeNode; + Child: TControl; + Splitter: TAnchorDockSplitter; + OneControl: TControl; +begin + OneControl:=GetOneControl; + if OneControl is TAnchorDockHostSite then + begin + + LayoutNode.NodeType:=adltnControl; + LayoutNode.Assign(Self); + LayoutNode.Name:={OneControl.}Name; + + TAnchorDockHostSite(OneControl).SaveLayout(LayoutTree,LayoutNode); + end; +end; + + +procedure Register; +begin + {$I anchordockpanel_icon.lrs} + RegisterComponents('Additional',[TAnchorDockPanel]); +end; + +end. Index: components/anchordocking/anchordockpanel_icon.lrs =================================================================== --- components/anchordocking/anchordockpanel_icon.lrs (nonexistent) +++ components/anchordocking/anchordockpanel_icon.lrs (working copy) @@ -0,0 +1,9 @@ +LazarusResources.Add('TAnchorDockPanel','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 + +#0#0'xIDATx^'#237#149'A'#10#132'0'#12'E'#127#134'^w'#214#230#8#174#167#23#26 + +#157'k'#204#162'"x'#140'~Q'#232#166#184#146'F'#4#243' '#144#213#127#132'@"9g' + +#136#8#172#16#146#176'$'#148'F563'#245#253'[P '#185'W'#215'}'#216#130'-g'#252 + +#14','#185#1#21')'#253'q'#150'yZP'#243#130#1#143#19#184#192#5'.pA88'#185'v'#2 + +#213'h3Ays'#191'a'#228#213'O'#255#254'K^'#1#166'zsS'#138#185#218'6'#0#0#0#0 + +'IEND'#174'B`'#130 +]); Index: components/anchordocking/anchordockpkg.pas =================================================================== --- components/anchordocking/anchordockpkg.pas (revision 55360) +++ components/anchordocking/anchordockpkg.pas (working copy) @@ -8,8 +8,16 @@ interface uses - AnchorDocking, AnchorDockStorage, AnchorDockStr, AnchorDockOptionsDlg; + AnchorDocking, AnchorDockStorage, AnchorDockStr, AnchorDockOptionsDlg, + AnchorDockPanel, LazarusPackageIntf; implementation +procedure Register; +begin + RegisterUnit('AnchorDockPanel', @AnchorDockPanel.Register); +end; + +initialization + RegisterPackage('AnchorDocking', @Register); end. Index: components/anchordocking/anchordockstorage.pas =================================================================== --- components/anchordocking/anchordockstorage.pas (revision 55360) +++ components/anchordocking/anchordockstorage.pas (working copy) @@ -113,7 +113,7 @@ procedure Clear; function IsEqual(Node: TAnchorDockLayoutTreeNode): boolean; procedure Assign(Node: TAnchorDockLayoutTreeNode); overload; - procedure Assign(AControl: TControl); overload; + procedure Assign(AControl: TControl;OverrideBoundsRect:Boolean=false); overload; procedure LoadFromConfig(Config: TConfigStorage); overload; procedure LoadFromConfig(Path: string; Config: TRttiXMLConfig); overload; procedure SaveToConfig(Config: TConfigStorage); overload; @@ -1113,13 +1113,16 @@ end; end; -procedure TAnchorDockLayoutTreeNode.Assign(AControl: TControl); +procedure TAnchorDockLayoutTreeNode.Assign(AControl: TControl;OverrideBoundsRect:Boolean=false); var AnchorControl: TControl; a: TAnchorKind; begin Name:=AControl.Name; - BoundsRect:=AControl.BoundsRect; + if OverrideBoundsRect then + BoundsRect:=GetParentForm(AControl).BoundsRect + else + BoundsRect:=AControl.BoundsRect; Align:=AControl.Align; if (AControl.Parent=nil) and (AControl is TCustomForm) then begin WindowState:=TCustomForm(AControl).WindowState; |
|
I guess you uploaded this anchordocking file in the wrong issue? |
|
The new implementation support both with the first menu item having apple title (this will be a custom apple menu) and without it (in this case File is the second menu and an Apple menu with only standard items is inserted). |
Date Modified | Username | Field | Change |
---|---|---|---|
2017-06-19 23:37 | CudaText man | New Issue | |
2017-06-19 23:37 | CudaText man | File Added: tst-cocoa-file-menu.zip | |
2017-06-20 22:32 | Andrey Zubarev | File Added: anchordocking-tanchordockpanel-impl2.patch | |
2017-06-22 11:24 | Felipe Monteiro de Carvalho | Note Added: 0101274 | |
2017-06-22 11:32 | Felipe Monteiro de Carvalho | Assigned To | => Felipe Monteiro de Carvalho |
2017-06-22 11:32 | Felipe Monteiro de Carvalho | Status | new => assigned |
2017-09-11 18:22 | Felipe Monteiro de Carvalho | Fixed in Revision | => 55835 |
2017-09-11 18:22 | Felipe Monteiro de Carvalho | LazTarget | => - |
2017-09-11 18:22 | Felipe Monteiro de Carvalho | Status | assigned => resolved |
2017-09-11 18:22 | Felipe Monteiro de Carvalho | Resolution | open => fixed |
2017-09-11 19:08 | Felipe Monteiro de Carvalho | Fixed in Revision | 55835 => 55835, 55836 |
2017-09-11 19:16 | Felipe Monteiro de Carvalho | Fixed in Revision | 55835, 55836 => 55835, 55836, 55837 |
2017-09-11 19:16 | Felipe Monteiro de Carvalho | Note Added: 0102781 |