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; function GetTracksOnly: TMapEditorTracksFilterEnumerator;
public public
function IndexOfObj(const Item: TObject; out Index: Integer): Boolean; function IndexOfObj(const Item: TObject; out Index: Integer): Boolean;
function IsPresent(const Item: TObject): Boolean;
function DelIfPresent(const Item: TObject): Boolean; function DelIfPresent(const Item: TObject): Boolean;
function AddIfNotPresent(const Item: TObject): Boolean; inline; function AddIfNotPresent(const Item: TObject): Boolean; inline;
@ -4155,7 +4156,10 @@ begin
// Item has been deleted from its parent collection, // Item has been deleted from its parent collection,
// delete it from the current selection if present. // delete it from the current selection if present.
Item := TMapItem(Data); 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; end;
procedure TMapEditMark.ObserveItemColl(AItem: TObject); procedure TMapEditMark.ObserveItemColl(AItem: TObject);
@ -4270,10 +4274,13 @@ begin
Lon := TMapPoint(AObjs[0]).Longitude; Lon := TMapPoint(AObjs[0]).Longitude;
FLit.Free; FLit.Free;
FLit := TMapObjectList.Create(AObjs); FLit := TMapObjectList.Create(AObjs);
FMapView.Invalidate;
end end
else else if Assigned(FLit) then
begin
FreeAndNil(FLit); FreeAndNil(FLit);
FMapView.Invalidate; FMapView.Invalidate;
end;
end; end;
function TMapEditMark.ClickableAt(X, Y: Integer): Boolean; function TMapEditMark.ClickableAt(X, Y: Integer): Boolean;
@ -4283,13 +4290,50 @@ end;
function TMapEditMark.ClickAt(X, Y: Integer): Boolean; function TMapEditMark.ClickAt(X, Y: Integer): Boolean;
var var
O: TObject; O, O1: TObject;
H: Boolean; 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 begin
Result := True; Result := True;
if Assigned(FLit) and AroundPt(X, Y, FPt) then if Assigned(FLit) and AroundPt(X, Y, FPt) then
begin begin
// Ctrl+click adds to selection
FTruncSelection := not (ssCtrl in GetKeyShiftState); 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]); H := FSelection.DelIfPresent(FLit[0]);
FTruncSelection := not H and FTruncSelection; FTruncSelection := not H and FTruncSelection;
FSelection.Insert(0, FLit[0]); FSelection.Insert(0, FLit[0]);
@ -4402,6 +4446,11 @@ begin
Result := Index >= 0; Result := Index >= 0;
end; end;
function TMapEditorList.IsPresent(const Item: TObject): Boolean;
begin
Result := IndexOf(Item) >= 0;
end;
function TMapEditorList.DelIfPresent(const Item: TObject): Boolean; function TMapEditorList.DelIfPresent(const Item: TObject): Boolean;
var var
I: Integer; I: Integer;

View File

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

View File

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