Skip to content

Commit

Permalink
Fix selection tools mistakenly "grabbing" last interactive...
Browse files Browse the repository at this point in the history
...point when creating many selections in quick succession.
  • Loading branch information
tannerhelland committed Sep 7, 2022
1 parent 80c36f9 commit a93a006
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions Modules/SelectionUI.bas
Original file line number Diff line number Diff line change
Expand Up @@ -321,21 +321,17 @@ End Function
'This sub will return a constant correlating to the nearest selection point. See the relevant enum for details.
Public Function IsCoordSelectionPOI(ByVal imgX As Double, ByVal imgY As Double, ByRef srcImage As pdImage) As PD_PointOfInterest

IsCoordSelectionPOI = poi_Undefined

'If the current selection is...
' 1) raster-type, or...
' 2) inactive...
'...disallow POIs entirely. (These types of selections do not support on-canvas interactions.)
If (srcImage.MainSelection.GetSelectionShape = ss_Raster) Or (Not srcImage.IsSelectionActive) Then
IsCoordSelectionPOI = poi_Undefined
Exit Function
End If
If (srcImage.MainSelection.GetSelectionShape = ss_Raster) Or (Not srcImage.IsSelectionActive) Then Exit Function

'Similarly, POIs are only enabled if the current selection tool matches the current selection shape.
' (If a new selection shape has been selected, the user is definitely not modifying the existing selection.)
If (g_CurrentTool <> SelectionUI.GetRelevantToolFromSelectShape()) Then
IsCoordSelectionPOI = poi_Undefined
Exit Function
End If
If (g_CurrentTool <> SelectionUI.GetRelevantToolFromSelectShape()) Then IsCoordSelectionPOI = poi_Undefined

'We're now going to compare the passed coordinate against a hard-coded list of "points of interest." These POIs
' differ by selection type, as different selections allow for different levels of interaction. (For example, a polygon
Expand Down Expand Up @@ -402,6 +398,10 @@ Public Function IsCoordSelectionPOI(ByVal imgX As Double, ByVal imgY As Double,
IsCoordSelectionPOI = poi_CornerSE
ElseIf (closestPoint = 3) Then
IsCoordSelectionPOI = poi_CornerSW

'Failsafe only
Else
IsCoordSelectionPOI = poi_Undefined
End If

Else
Expand Down Expand Up @@ -708,11 +708,11 @@ Public Sub NotifySelectionKeyUp(ByRef srcCanvas As pdCanvas, ByVal Shift As Shif
End Sub

Public Sub NotifySelectionMouseDown(ByRef srcCanvas As pdCanvas, ByVal imgX As Single, ByVal imgY As Single)


If m_IgnoreUserInput Then Exit Sub

m_MouseDown = True
m_HasMouseMoved = False

If m_IgnoreUserInput Then Exit Sub

'Check to see if a selection is already active. If it is, see if the user is clicking on a POI
' (and initiating a transform) or clicking somewhere else (initiating a new selection).
Expand Down Expand Up @@ -892,7 +892,7 @@ Public Sub NotifySelectionMouseMove(ByRef srcCanvas As pdCanvas, ByVal lmbState
m_HasMouseMoved = True

'Handling varies based on the current mouse state, obviously.
If lmbState Then
If m_MouseDown Then

'Basic selection tools
Select Case g_CurrentTool
Expand Down
2 changes: 1 addition & 1 deletion PhotoDemon.vbp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ Description="PhotoDemon Photo Editor"
CompatibleMode="0"
MajorVer=8
MinorVer=9
RevisionVer=1742
RevisionVer=1743
AutoIncrementVer=1
ServerSupportFiles=0
VersionComments="Copyright 2000-2022 Tanner Helland - photodemon.org"
Expand Down

0 comments on commit a93a006

Please sign in to comment.