LazMapViewer: Fixed (2) Flickering of component on map, (4) Mark of track points, (5) Selection identification, (6) Red border; from issue #39088.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9552 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alpine-a110 2024-12-26 18:22:25 +00:00
parent 200f5209e3
commit 230cdbbc3b
3 changed files with 82 additions and 27 deletions

View File

@ -902,6 +902,7 @@ type
function GetTracksOnly: TMapEditorTracksFilterEnumerator;
public
function IndexOfObj(const Item: TObject; out Index: Integer): Boolean;
function IsPresent(const Item: TObject): Boolean;
function DelIfPresent(const Item: TObject): Boolean;
function AddIfNotPresent(const Item: TObject): Boolean; inline;
@ -4155,7 +4156,10 @@ begin
// Item has been deleted from its parent collection,
// delete it from the current selection if present.
Item := TMapItem(Data);
FSelection.DelIfPresent(Item);
if FSelection.DelIfPresent(Item) and
(FSelection.Count > 0) and not (FSelection[0] is TMapPoint) // No points left?
then
FSelection.Clear;
end;
procedure TMapEditMark.ObserveItemColl(AItem: TObject);
@ -4270,10 +4274,13 @@ begin
Lon := TMapPoint(AObjs[0]).Longitude;
FLit.Free;
FLit := TMapObjectList.Create(AObjs);
FMapView.Invalidate;
end
else
else if Assigned(FLit) then
begin
FreeAndNil(FLit);
FMapView.Invalidate;
FMapView.Invalidate;
end;
end;
function TMapEditMark.ClickableAt(X, Y: Integer): Boolean;
@ -4283,13 +4290,50 @@ end;
function TMapEditMark.ClickAt(X, Y: Integer): Boolean;
var
O: TObject;
H: Boolean;
O, O1: TObject;
H, Alt: Boolean;
I: Integer;
function GetAlt(P0: TObject): TObject;
var
P: TObject;
LeftOf: Boolean = False;
begin
Result := Nil;
for P in FLit.Points do
if not LeftOf and not FSelection.IsPresent(P) and (Result = Nil) then
Result := P
else if (P = P0) then
LeftOf := True
else if LeftOf and not FSelection.IsPresent(P) then
Exit(P);
end;
begin
Result := True;
if Assigned(FLit) and AroundPt(X, Y, FPt) then
begin
// Ctrl+click adds to selection
FTruncSelection := not (ssCtrl in GetKeyShiftState);
for O in FLit.Points do
if FSelection.IndexOfObj(O, I) then
begin
// Alt+click selects the point below
Alt := ssAlt in GetKeyShiftState;
if Alt then
begin
O1 := GetAlt(O);
if Assigned(O1) then
begin
FSelection[I] := O1;
ObserveItemColl(O1);
end;
end;
if I > 0 then
FSelection.Exchange(I, 0);
Exit;
end;
H := FSelection.DelIfPresent(FLit[0]);
FTruncSelection := not H and FTruncSelection;
FSelection.Insert(0, FLit[0]);
@ -4402,6 +4446,11 @@ begin
Result := Index >= 0;
end;
function TMapEditorList.IsPresent(const Item: TObject): Boolean;
begin
Result := IndexOf(Item) >= 0;
end;
function TMapEditorList.DelIfPresent(const Item: TObject): Boolean;
var
I: Integer;

View File

@ -2,30 +2,28 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
Left = 370
Height = 90
Top = 31
Width = 292
Width = 293
BorderStyle = bsToolWindow
Caption = 'MapViewer Path Editor'
ClientHeight = 90
ClientWidth = 292
LCLVersion = '2.2.4.0'
ClientWidth = 293
object pnlFrame: TPanel
Left = 0
Height = 90
Top = 0
Width = 292
Width = 293
Align = alClient
BevelColor = clRed
ClientHeight = 90
ClientWidth = 292
ClientWidth = 293
TabOrder = 0
object pnlTools: TPanel
Left = 1
Height = 33
Top = 1
Width = 290
Width = 291
Align = alTop
ClientHeight = 33
ClientWidth = 290
ClientWidth = 291
ParentShowHint = False
ShowHint = True
TabOrder = 0
@ -181,30 +179,30 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
end
object lblSelectedPt: TLabel
AnchorSideLeft.Control = pnlFrame
AnchorSideTop.Side = asrCenter
AnchorSideTop.Control = cbSelectedPt
Left = 1
Height = 16
Top = 39
Width = 82
Top = 37
Width = 83
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
AutoSize = False
BorderSpacing.Right = 5
Caption = 'Selection'
Caption = 'Selection:'
ParentColor = False
end
object lblSelectedLayer: TLabel
AnchorSideLeft.Control = pnlFrame
AnchorSideTop.Side = asrCenter
AnchorSideTop.Control = cbSelectedLayer
Left = 1
Height = 16
Top = 63
Width = 82
Top = 62
Width = 83
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
AutoSize = False
BorderSpacing.Right = 5
Caption = 'On Layer'
Caption = 'On Layer:'
ParentColor = False
end
object cbSelectedPt: TEdit
@ -212,7 +210,7 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlFrame
AnchorSideRight.Side = asrBottom
Left = 87
Left = 88
Height = 22
Top = 37
Width = 201
@ -231,7 +229,7 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlFrame
AnchorSideRight.Side = asrBottom
Left = 87
Left = 88
Height = 22
Top = 62
Width = 201

View File

@ -406,6 +406,16 @@ var
PtTxt: String;
PtCnt: Integer = 0;
HaveView, HaveLayer, HaveSel, HavePt: Boolean;
function ItemCap(AItem: TMapItem): String;
begin
Result := AItem.DisplayName;
if Result <> AItem.ClassName then
Result := Result + ': ' + AItem.ClassName;
if Assigned(AItem.Collection) then
Result := Format('%d - ', [AItem.Index]) + Result;
end;
begin
HaveView := Assigned(MapView);
HaveSel := HaveView and MapView.EditMark.HasSelection;
@ -424,7 +434,7 @@ begin
// Update layer name
if HaveLayer
then cbSelectedLayer.Text := MapLayer.DisplayName
then cbSelectedLayer.Text := ItemCap(MapLayer)
else cbSelectedLayer.Text := '(none)';
cbSelectedLayer.Hint := cbSelectedLayer.Text;
@ -437,9 +447,7 @@ begin
P := TMapPoint(MapView.EditMark.Selection[0]);
if PtCnt > 0 then
begin
PtTxt := P.DisplayName;
if PtTxt <> P.ClassName then
PtTxt := PtTxt + ': ' + P.ClassName;
PtTxt := ItemCap(P);
if PtCnt > 1 then
PtTxt := PtTxt + Format(' +%d more', [PtCnt - 1]);
end;