Browse Source

Symbol browse window fixes

Margers 6 months ago
parent
commit
e46f468c55
1 changed files with 73 additions and 6 deletions
  1. 73 6
      packages/ide/fpsymbol.pas

+ 73 - 6
packages/ide/fpsymbol.pas

@@ -250,6 +250,9 @@ type
     PUnitInfoPanel = ^TUnitInfoPanel;
     PUnitInfoPanel = ^TUnitInfoPanel;
     TUnitInfoPanel = object(TPanel)
     TUnitInfoPanel = object(TPanel)
       InOwnerCall: boolean;
       InOwnerCall: boolean;
+      UnitInfoUsed: PSymbolScopeView;
+      UnitInfoDependent: PSymbolScopeView;
+      procedure SetState(AState: Word; Enable: Boolean); virtual;
       procedure HandleEvent(var Event: TEvent); virtual;
       procedure HandleEvent(var Event: TEvent); virtual;
     end;
     end;
 
 
@@ -265,6 +268,7 @@ type
       function    Disassemble : boolean;
       function    Disassemble : boolean;
       function    GetFlags: longint; virtual;
       function    GetFlags: longint; virtual;
       procedure   SetFlags(AFlags: longint); virtual;
       procedure   SetFlags(AFlags: longint); virtual;
+      procedure   SizeLimits (Var Min, Max: TPoint); Virtual;
       destructor  Done;virtual;
       destructor  Done;virtual;
     private
     private
       BrowserFlags  : Longint;
       BrowserFlags  : Longint;
@@ -1860,11 +1864,22 @@ end;
 
 
 procedure TBrowserTab.SelectItem(Index: Sw_integer);
 procedure TBrowserTab.SelectItem(Index: Sw_integer);
 var P: PBrowserTabItem;
 var P: PBrowserTabItem;
+    PrevTab:Sw_Integer;
 begin
 begin
+  PrevTab:=Current;
   Current:=Index;
   Current:=Index;
+  if PrevTab<>Current then
+  begin
+    P:=GetItem(PrevTab);
+    if (P<>nil) and (P^.Link<>nil) then
+      P^.Link^.SetState(sfVisible,False);
+  end;
   P:=GetItem(Current);
   P:=GetItem(Current);
   if (P<>nil) and (P^.Link<>nil) then
   if (P<>nil) and (P^.Link<>nil) then
+  begin
+    P^.Link^.SetState(sfVisible,True);
     P^.Link^.Focus;
     P^.Link^.Focus;
+  end;
   DrawView;
   DrawView;
 end;
 end;
 
 
@@ -1986,6 +2001,25 @@ begin
   inherited Done;
   inherited Done;
 end;
 end;
 
 
+procedure TUnitInfoPanel.SetState(AState: Word; Enable: Boolean);
+var OState: longint;
+begin
+  OState:=State;
+  inherited SetState(AState,Enable);
+  if ((OState xor State) and sfVisible)<>0 then
+  begin
+    if GetState(sfVisible) then
+      begin
+        { even they are visible already
+          we need to make them visible for focus to work }
+        if assigned(UnitInfoUsed) then
+          UnitInfoUsed^.SetState(sfVisible,true);
+        if assigned(UnitInfoDependent) then
+          UnitInfoDependent^.SetState(sfVisible,true);
+      end;
+  end;
+end;
+
 procedure TUnitInfoPanel.HandleEvent(var Event: TEvent);
 procedure TUnitInfoPanel.HandleEvent(var Event: TEvent);
 begin
 begin
   if (Event.What=evBroadcast) and (Event.Command=cmListItemSelected) and
   if (Event.What=evBroadcast) and (Event.Command=cmListItemSelected) and
@@ -2105,8 +2139,10 @@ begin
       R2.B.Y:=R2.A.Y+3;
       R2.B.Y:=R2.A.Y+3;
       if (Assigned(UsedUnits) or Assigned(DependentUnits))=false then
       if (Assigned(UsedUnits) or Assigned(DependentUnits))=false then
         R2.B.Y:=R3.B.Y;
         R2.B.Y:=R3.B.Y;
-      HSB:=CreateHSB(R2); {UnitInfo^.Insert(HSB); HSB:=nil;}
-      VSB:=CreateVSB(R2);
+      {HSB:=CreateHSB(R2);} {UnitInfo^.Insert(HSB); HSB:=nil;}
+      {VSB:=CreateVSB(R2);}
+      HSB:=nil; { It is for the best to not have HSB at all. M }
+      VSB:=nil;
       {UnitInfo^.Insert(VSB);
       {UnitInfo^.Insert(VSB);
        VSB will be owned by UnitInfoText PM }
        VSB will be owned by UnitInfoText PM }
       New(UnitInfoText, Init(R2,HSB,VSB, nil));
       New(UnitInfoText, Init(R2,HSB,VSB, nil));
@@ -2128,6 +2164,7 @@ begin
       end;
       end;
       UnitInfo^.Insert(UnitInfoText);
       UnitInfo^.Insert(UnitInfoText);
 
 
+      UnitInfo^.UnitInfoUsed:=nil;
       if Assigned(UsedUnits) then
       if Assigned(UsedUnits) then
       begin
       begin
         Inc(R2.A.Y,R2.B.Y-R2.A.Y); R2.B.Y:=R2.A.Y+1;
         Inc(R2.A.Y,R2.B.Y-R2.A.Y); R2.B.Y:=R2.A.Y+1;
@@ -2135,36 +2172,51 @@ begin
         CST^.GrowMode:=gfGrowHiX;
         CST^.GrowMode:=gfGrowHiX;
         UnitInfo^.Insert(CST);
         UnitInfo^.Insert(CST);
 
 
-        Inc(R2.A.Y,R2.B.Y-R2.A.Y); R2.B.Y:=R2.A.Y+4;
+        Inc(R2.A.Y,R2.B.Y-R2.A.Y); R2.B.Y:=R2.A.Y+3;
+        Dec(R2.B.X);  { make space for VSB inside Panel }
         if Assigned(DependentUnits)=false then R2.B.Y:=R3.B.Y;
         if Assigned(DependentUnits)=false then R2.B.Y:=R3.B.Y;
         {HSB:=CreateHSB(R2); UnitInfo^.Insert(HSB); }
         {HSB:=CreateHSB(R2); UnitInfo^.Insert(HSB); }
         HSB:=nil;
         HSB:=nil;
         VSB:=CreateVSB(R2);
         VSB:=CreateVSB(R2);
         {UnitInfo^.Insert(VSB);  this created crashes,
         {UnitInfo^.Insert(VSB);  this created crashes,
         that were difficult to findout PM }
         that were difficult to findout PM }
+        { Maybe because it was outside Panle?  M }
+        UnitInfo^.Insert(VSB); { lets try again with VSB inside Panel area }
         New(UnitInfoUsed, Init(R2,UsedUnits,HSB,VSB));
         New(UnitInfoUsed, Init(R2,UsedUnits,HSB,VSB));
+        Inc(R2.B.X); { restore R2 }
         UnitInfoUsed^.GrowMode:=gfGrowHiY+gfGrowHiX;
         UnitInfoUsed^.GrowMode:=gfGrowHiY+gfGrowHiX;
         UnitInfoUsed^.MyBW:=@Self;
         UnitInfoUsed^.MyBW:=@Self;
         UnitInfo^.Insert(UnitInfoUsed);
         UnitInfo^.Insert(UnitInfoUsed);
+        UnitInfo^.UnitInfoUsed:=UnitInfoUsed;
       end;
       end;
 
 
+      UnitInfo^.UnitInfoDependent:=nil;
       if Assigned(DependentUnits) then
       if Assigned(DependentUnits) then
       begin
       begin
         Inc(R2.A.Y,R2.B.Y-R2.A.Y); R2.B.Y:=R2.A.Y+1;
         Inc(R2.A.Y,R2.B.Y-R2.A.Y); R2.B.Y:=R2.A.Y+1;
         New(CST, Init(R2,#180' Dependent units '#195+CharStr(#196,255),ColorIndex(12),false));
         New(CST, Init(R2,#180' Dependent units '#195+CharStr(#196,255),ColorIndex(12),false));
         CST^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY;
         CST^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY;
+        if not Assigned(UsedUnits) then CST^.GrowMode:=gfGrowHiX;
         UnitInfo^.Insert(CST);
         UnitInfo^.Insert(CST);
 
 
         Inc(R2.A.Y,R2.B.Y-R2.A.Y); R2.B.Y:=R3.B.Y;
         Inc(R2.A.Y,R2.B.Y-R2.A.Y); R2.B.Y:=R3.B.Y;
+        Dec(R2.B.X); { make space for VSB inside Panel }
         {HSB:=CreateHSB(R2); UnitInfo^.Insert(HSB); }
         {HSB:=CreateHSB(R2); UnitInfo^.Insert(HSB); }
         HSB:=nil;
         HSB:=nil;
         VSB:=CreateVSB(R2);
         VSB:=CreateVSB(R2);
         { UnitInfo^.Insert(VSB);  this created crashes,
         { UnitInfo^.Insert(VSB);  this created crashes,
         that were difficult to findout PM }
         that were difficult to findout PM }
+        { Maybe because it was outside Panle?  M }
+        UnitInfo^.Insert(VSB); { lets try again with VSB inside Panel area }
+        if Assigned(UsedUnits) then
+          VSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowLoX+gfGrowHiY;
         New(UnitInfoDependent, Init(R2,DependentUnits,HSB,VSB));
         New(UnitInfoDependent, Init(R2,DependentUnits,HSB,VSB));
         UnitInfoDependent^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY;
         UnitInfoDependent^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY;
+        if not Assigned(UsedUnits) then
+          UnitInfoDependent^.GrowMode:=gfGrowHiY+gfGrowHiX;
         UnitInfoDependent^.MyBW:=@Self;
         UnitInfoDependent^.MyBW:=@Self;
         UnitInfo^.Insert(UnitInfoDependent);
         UnitInfo^.Insert(UnitInfoDependent);
+        UnitInfo^.UnitInfoDependent:=UnitInfoDependent;
       end;
       end;
 
 
       if Assigned(UnitInfoText) then
       if Assigned(UnitInfoText) then
@@ -2173,6 +2225,13 @@ begin
       Insert(UnitInfo);
       Insert(UnitInfo);
     end;
     end;
 
 
+  { hide not active pages so that scrollbars do not overlap }
+  if assigned(ScopeView) then ScopeView^.SetState(sfVisible,False);
+  if assigned(ReferenceView) then ReferenceView^.SetState(sfVisible,False);
+  if assigned(InheritanceView) then InheritanceView^.SetState(sfVisible,False);
+  if assigned(MemInfoView) then MemInfoView^.SetState(sfVisible,False);
+  if assigned(UnitInfo) then UnitInfo^.SetState(sfVisible,False);
+
   GetExtent(R); R.Grow(-1,-1); R.Move(0,1); R.B.Y:=R.A.Y+1;
   GetExtent(R); R.Grow(-1,-1); R.Move(0,1); R.B.Y:=R.A.Y+1;
   New(PageTab, Init(R,
   New(PageTab, Init(R,
     NewBrowserTabItem(label_browsertab_scope,ScopeView,
     NewBrowserTabItem(label_browsertab_scope,ScopeView,
@@ -2254,14 +2313,14 @@ begin
               end;
               end;
             if (Event.InfoPtr=UnitInfoUsed) then
             if (Event.InfoPtr=UnitInfoUsed) then
               begin
               begin
-                S:=UnitInfoUsed^.Symbols^.At(UnitInfoUsed^.Focused);
+                S:=PHollowSymbol(UnitInfoUsed^.FilteredSym^.At(UnitInfoUsed^.Focused)^.Sym);
                 MakeGlobal(UnitInfoUsed^.Origin,P);
                 MakeGlobal(UnitInfoUsed^.Origin,P);
                 Desktop^.MakeLocal(P,P); Inc(P.Y,UnitInfoUsed^.Focused-UnitInfoUsed^.TopItem);
                 Desktop^.MakeLocal(P,P); Inc(P.Y,UnitInfoUsed^.Focused-UnitInfoUsed^.TopItem);
                 Inc(P.Y);
                 Inc(P.Y);
               end;
               end;
             if (Event.InfoPtr=UnitInfoDependent) then
             if (Event.InfoPtr=UnitInfoDependent) then
               begin
               begin
-                S:=UnitInfoDependent^.Symbols^.At(UnitInfoDependent^.Focused);
+                S:=PHollowSymbol(UnitInfoDependent^.FilteredSym^.At(UnitInfoDependent^.Focused)^.Sym);
                 MakeGlobal(UnitInfoDependent^.Origin,P);
                 MakeGlobal(UnitInfoDependent^.Origin,P);
                 Desktop^.MakeLocal(P,P); Inc(P.Y,UnitInfoDependent^.Focused-UnitInfoDependent^.TopItem);
                 Desktop^.MakeLocal(P,P); Inc(P.Y,UnitInfoDependent^.Focused-UnitInfoDependent^.TopItem);
                 Inc(P.Y);
                 Inc(P.Y);
@@ -2277,7 +2336,7 @@ begin
                 if (S^.GetReferenceCount>0) or (assigned(Symbols) and (Symbols^.Count>0)) or (Anc<>nil) then
                 if (S^.GetReferenceCount>0) or (assigned(Symbols) and (Symbols^.Count>0)) or (Anc<>nil) then
                  OpenSymbolBrowser(Origin.X-1,P.Y,
                  OpenSymbolBrowser(Origin.X-1,P.Y,
                    S^.GetName,
                    S^.GetName,
-                   ScopeView^.GetText(ScopeView^.Focused,255),
+                   S^.GetText {ScopeView^.GetText(ScopeView^.Focused,255)},
                    S^.Sym,@self,
                    S^.Sym,@self,
                    Symbols,S^.References,Anc,S^.MemInfo);
                    Symbols,S^.References,Anc,S^.MemInfo);
                 ClearEvent(Event);
                 ClearEvent(Event);
@@ -2375,6 +2434,14 @@ begin
       Message(Desktop,evBroadcast,cmClearLineHighlights,nil);}
       Message(Desktop,evBroadcast,cmClearLineHighlights,nil);}
 end;
 end;
 
 
+procedure TBrowserWindow.SizeLimits (Var Min, Max: TPoint);
+begin
+  Min.X:=20;
+  Min.Y:=15; { Scrollbars in unit info page is still usable }
+  Max.X:=ScreenWidth;
+  Max.Y:=ScreenHeight-2;
+end;
+
 procedure TBrowserWindow.Close;
 procedure TBrowserWindow.Close;
 begin
 begin
   inherited Close;
   inherited Close;