LCL: A new angle bracket option for TreeViewExpandSignType. Issue #39361, patch by Alexey T.

This commit is contained in:
Juha 2021-10-04 11:28:13 +03:00
parent 7ca9ba2fb6
commit 02eed0c903
2 changed files with 53 additions and 4 deletions

View File

@ -3318,10 +3318,11 @@ const
type
TTreeViewExpandSignType = (
tvestTheme, // use themed sign
tvestPlusMinus, // use +/- sign
tvestArrow, // use blank arrow
tvestArrowFill // use filled arrow
tvestTheme, // use themed sign
tvestPlusMinus, // use +/- sign
tvestArrow, // use blank arrow
tvestArrowFill, // use filled arrow
tvestAngleBracket // use > symbol
);
TTreeViewInsertMarkType = (
@ -3340,6 +3341,7 @@ type
FEditingItem: TTreeNode;
FExpandSignType: TTreeViewExpandSignType;
FExpandSignSize: integer;
FExpandSignWidth: integer;
FThemeExpandSignSize: integer;
FDefItemHeight: integer;
FDefItemSpace: Integer;
@ -3494,6 +3496,7 @@ type
function AllowMultiSelectWithCtrl(AState: TShiftState): Boolean;
function AllowMultiSelectWithShift(AState: TShiftState): Boolean;
procedure SetExpandSignSize(const AExpandSignSize: integer);
procedure SetExpandSignWidth(const AValue: integer);
protected
FChangeTimer: TTimer;
FEditor: TEdit;
@ -3701,6 +3704,7 @@ type
property DropTarget: TTreeNode read GetDropTarget write SetDropTarget;
property ExpandSignColor: TColor read FExpandSignColor write FExpandSignColor default clWindowFrame;
property ExpandSignSize: integer read GetExpandSignSize write SetExpandSignSize stored ExpandSignSizeIsStored;
property ExpandSignWidth: integer read FExpandSignWidth write SetExpandSignWidth default 2;
property ExpandSignType: TTreeViewExpandSignType
read FExpandSignType write SetExpandSignType default tvestTheme;
property Images: TCustomImageList read FImages write SetImages;

View File

@ -3277,6 +3277,7 @@ begin
FDefItemSpace := ScaleY(2, 96);
FExpandSignType := tvestTheme;
FExpandSignSize := -1;
FExpandSignWidth := 2;
Details := ThemeServices.GetElementDetails(ttGlyphOpened);
FThemeExpandSignSize := ThemeServices.GetDetailSize(Details).cx;
FTreeNodes := CreateNodes;
@ -4697,6 +4698,13 @@ begin
Invalidate;
end;
procedure TCustomTreeView.SetExpandSignWidth(const AValue: integer);
begin
if FExpandSignWidth = AValue then Exit;
FExpandSignWidth := AValue;
Invalidate;
end;
function TCustomTreeView.IsEditing: Boolean;
begin
Result:=tvsIsEditing in FStates;
@ -5175,6 +5183,43 @@ var
Brush.Color := PrevColor;
end;
end;
tvestAngleBracket:
begin
// draw an arrow. down for collapse and right for expand
R := Rect(ALeft, ATop, ARight+1, ABottom+1); //+1 for simmetry of arrow
if CollapseSign then
begin
// draw an arrow down
Points[0] := Point(R.Left, MidY - cShiftHorzArrow);
Points[1] := Point(R.Right - 1, MidY - cShiftHorzArrow);
Points[2] := Point(MidX, R.Bottom - 1 - cShiftHorzArrow);
end else
begin
// draw an arrow right
Points[0] := Point(MidX - 2, ATop);
Points[1] := Point(MidX - 2, R.Bottom - 1);
Points[2] := Point(R.Right - 3, MidY);
end;
for SmallIndent := 1 to FExpandSignWidth do
begin
Line(Points[2], Points[0]);
Line(Points[2], Points[1]);
if CollapseSign then
begin
Dec(Points[0].Y);
Dec(Points[1].Y);
Dec(Points[2].Y);
end
else
begin
Dec(Points[0].X);
Dec(Points[1].X);
Dec(Points[2].X);
end;
end;
end;
end;
end;
end;