mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 06:09:15 +02:00
LCL: attempt to simplify TMenuItem.InternalRethinkLines. Hope it covers all cases. Part of issue #41028.
This commit is contained in:
parent
fbb9eb5f47
commit
c55033b82c
@ -345,9 +345,8 @@ end;
|
|||||||
|
|
||||||
function TMenuItem.InternalRethinkLines(AForced: Boolean): Boolean;
|
function TMenuItem.InternalRethinkLines(AForced: Boolean): Boolean;
|
||||||
var
|
var
|
||||||
LItem: TMenuItem;
|
CurItem, LastVisibleItem: TMenuItem;
|
||||||
LLastVisibleIsLine, HideSeps: Boolean;
|
HideSeps: Boolean;
|
||||||
LLastVisibleItem: TMenuItem;
|
|
||||||
I: Integer;
|
I: Integer;
|
||||||
begin
|
begin
|
||||||
//debugln(['TMenuItem.InternalRethinkLines, AForced=',AForced]);
|
//debugln(['TMenuItem.InternalRethinkLines, AForced=',AForced]);
|
||||||
@ -355,52 +354,39 @@ begin
|
|||||||
if (csDesigning in ComponentState) then
|
if (csDesigning in ComponentState) then
|
||||||
Exit;
|
Exit;
|
||||||
HideSeps := GetAutoLineReduction;
|
HideSeps := GetAutoLineReduction;
|
||||||
|
debugln(['TMenuItem.InternalRethinkLines, AForced=',AForced,', HideSeps=',HideSeps]);
|
||||||
if {AForced or} HideSeps then
|
if {AForced or} HideSeps then
|
||||||
begin
|
begin
|
||||||
LLastVisibleIsLine := True; // to hide head line
|
LastVisibleItem := nil;
|
||||||
LLastVisibleItem := nil;
|
|
||||||
|
|
||||||
for I:= 0 to Count - 1 do
|
for I:= 0 to Count - 1 do
|
||||||
begin
|
begin
|
||||||
LItem := Items[I];
|
CurItem := Items[I];
|
||||||
if LItem.IsLine then
|
if CurItem.IsLine and CurItem.Visible then
|
||||||
begin
|
begin
|
||||||
// hide head or double lines
|
debugln(['TMenuItem.InternalRethinkLines: LastVisibleItem=',dbgsname(LastVisibleItem)]);
|
||||||
if LItem.Visible <> not LLastVisibleIsLine then
|
if (LastVisibleItem = nil) or (LastVisibleItem.IsLine) or (I = Count-1) then
|
||||||
begin
|
begin
|
||||||
LItem.Visible := not LLastVisibleIsLine;
|
CurItem.Visible := False;
|
||||||
Result := True;
|
Result := True;
|
||||||
//debugln(['TMenuItem.InternalRethinkLines: hiding separator with name "',LItem.Name,'"']);
|
debugln(['TMenuItem.InternalRethinkLines: hiding separator with name "',CurItem.Name,'"']);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
if CurItem.Visible then
|
||||||
if LItem.Visible then
|
LastVisibleItem := CurItem;
|
||||||
begin
|
end;//for
|
||||||
LLastVisibleIsLine := LItem.IsLine;
|
end// if AForced or HideSep
|
||||||
LLastVisibleItem := LItem;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// hide end line
|
|
||||||
if (LLastVisibleItem <> nil) and
|
|
||||||
LLastVisibleItem.IsLine and LLastVisibleItem.Visible then
|
|
||||||
begin
|
|
||||||
LLastVisibleItem.Visible := False;
|
|
||||||
Result := True;
|
|
||||||
//debugln(['TMenuItem.InternalRethinkLines: hiding separator with name "',LItem.Name,'"']);
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
//apparently if GetAToLineReduction is False, Delphi sets all separators to be visible
|
|
||||||
begin
|
begin
|
||||||
|
//apparently if GetAutoLineReduction is False, Delphi sets all separators to be visible
|
||||||
for i := 0 to Count - 1 do
|
for i := 0 to Count - 1 do
|
||||||
begin
|
begin
|
||||||
LItem := Items[i];
|
CurItem := Items[i];
|
||||||
if LItem.IsLine and not LItem.Visible then
|
if CurItem.IsLine and not CurItem.Visible then
|
||||||
begin
|
begin
|
||||||
LItem.Visible := True;
|
CurItem.Visible := True;
|
||||||
Result := True;
|
Result := True;
|
||||||
//debugln(['TMenuItem.InternalRethinkLines: unhiding separator with name "',LItem.Name,'"']);
|
debugln(['TMenuItem.InternalRethinkLines: unhiding separator with name "',CurItem.Name,'"']);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user