Skip to content

Commit

Permalink
Minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerhelland committed Dec 19, 2023
1 parent 0585811 commit 2cd98cb
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Classes/pdListSupport.cls
Expand Up @@ -575,7 +575,7 @@ Friend Sub NotifyKeyDown(ByVal Shift As ShiftConstants, ByVal vkCode As Long, ma

markEventHandled = False

'All these keys set a new .ListIndex property. We'll calculate a theoretical new ListIndex, then apply a universal
'Keys can set a new listindex. We'll calculate a theoretical new ListIndex, then apply a universal
' bounds-check at the end.
Dim newListIndex As Long
newListIndex = m_ListIndex
Expand Down
6 changes: 5 additions & 1 deletion Classes/pdPipe.cls
Expand Up @@ -33,6 +33,10 @@ Attribute VB_Exposed = False

Option Explicit

'If TRUE, writes additional pipe creation notifications to the debug log.
' (Turn off in production code!)
Private Const PDPIPE_DEBUG_VERBOSE As Boolean = False

'The type of raised event depends on the pipe's mode (currently only byte mode is implemented).
Public Event BytesArrived(ByVal initStreamPosition As Long, ByVal numOfBytes As Long)

Expand Down Expand Up @@ -140,7 +144,7 @@ Friend Function CreatePipe(ByRef pipeName As String, ByRef instantiatedDstStream
CreatePipe = (m_Pipe <> 0) And (m_Pipe <> INVALID_HANDLE_VALUE)
If CreatePipe Then

PDDebug.LogAction "Successfully created pipe: " & m_Pipe & ", " & Err.LastDllError
If PDPIPE_DEBUG_VERBOSE Then PDDebug.LogAction "Successfully created pipe: " & m_Pipe & ", " & Err.LastDllError

'Point our stream reference at the caller's stream; all pipe data will be placed there
' as it arrives.
Expand Down
8 changes: 2 additions & 6 deletions Controls/pdCanvasView.ctl
Expand Up @@ -236,12 +236,8 @@ Public Function IsCanvasInteractionAllowed() As Boolean
If (Not IsCanvasInteractionAllowed) Then Exit Function

'If there is no active images or valid layers, canvas interactions are also disallowed. (This is primarily a failsafe check.)
If (Not PDImages.IsImageActive) Then
IsCanvasInteractionAllowed = False
Else
If (Not PDImages.GetActiveImage.IsActive) Then IsCanvasInteractionAllowed = False
If (PDImages.GetActiveImage.GetNumOfLayers = 0) Then IsCanvasInteractionAllowed = False
End If
If (Not PDImages.GetActiveImage.IsActive) Then IsCanvasInteractionAllowed = False
If (PDImages.GetActiveImage.GetNumOfLayers = 0) Then IsCanvasInteractionAllowed = False

'If the central processor is active, exit - but *only* if our internal notification flags have not been triggered.
' (If those flags are active, it means an external caller has notified us of something it wants rendered.)
Expand Down
2 changes: 1 addition & 1 deletion Modules/NavKey.bas
Expand Up @@ -223,7 +223,7 @@ Public Function NotifyNavKeypress(ByRef childObject As Object, ByVal navKeyCode

'The only other supported key (at this point) is TAB. Tab keypresses are handled by the object list;
' it's responsible for figuring out which control is next in order.
Else
ElseIf (navKeyCode = pdnk_Tab) Then
m_Forms(formIndex).NotifyTabKey childHwnd, ((Shift And vbShiftMask) <> 0)
NotifyNavKeypress = True
End If
Expand Down
54 changes: 29 additions & 25 deletions Modules/SelectionUI.bas
Expand Up @@ -672,37 +672,41 @@ Public Sub NotifySelectionKeyUp(ByRef srcCanvas As pdCanvas, ByVal Shift As Shif

'Backspace key: for lasso and polygon selections, retreat back one or more coordinates, giving the user a chance to
' correct any potential mistakes.
If (vkCode = VK_BACK) And ((g_CurrentTool = SELECT_LASSO) Or (g_CurrentTool = SELECT_POLYGON)) And PDImages.GetActiveImage.IsSelectionActive And (Not PDImages.GetActiveImage.MainSelection.IsLockedIn) Then
If (vkCode = VK_BACK) And ((g_CurrentTool = SELECT_LASSO) Or (g_CurrentTool = SELECT_POLYGON)) And PDImages.GetActiveImage.IsSelectionActive Then

markEventHandled = True

'Polygons: do not allow point removal if the polygon has already been successfully closed.
If (g_CurrentTool = SELECT_POLYGON) Then
If (Not PDImages.GetActiveImage.MainSelection.GetPolygonClosedState) Then PDImages.GetActiveImage.MainSelection.RemoveLastPolygonPoint

'Lassos: do not allow point removal if the lasso has already been successfully closed.
Else

If (Not PDImages.GetActiveImage.MainSelection.GetLassoClosedState) Then

'Ask the selection object to retreat its position
Dim newImageX As Double, newImageY As Double
PDImages.GetActiveImage.MainSelection.RetreatLassoPosition newImageX, newImageY

'The returned coordinates will be in image coordinates. Convert them to viewport coordinates.
Dim newCanvasX As Double, newCanvasY As Double
Drawing.ConvertImageCoordsToCanvasCoords srcCanvas, PDImages.GetActiveImage(), newImageX, newImageY, newCanvasX, newCanvasY

'Finally, convert the canvas coordinates to screen coordinates, and move the cursor accordingly
srcCanvas.SetCursorToCanvasPosition newCanvasX, newCanvasY
If (Not PDImages.GetActiveImage.MainSelection.IsLockedIn) Then

markEventHandled = True

'Polygons: do not allow point removal if the polygon has already been successfully closed.
If (g_CurrentTool = SELECT_POLYGON) Then
If (Not PDImages.GetActiveImage.MainSelection.GetPolygonClosedState) Then PDImages.GetActiveImage.MainSelection.RemoveLastPolygonPoint

'Lassos: do not allow point removal if the lasso has already been successfully closed.
Else

If (Not PDImages.GetActiveImage.MainSelection.GetLassoClosedState) Then

'Ask the selection object to retreat its position
Dim newImageX As Double, newImageY As Double
PDImages.GetActiveImage.MainSelection.RetreatLassoPosition newImageX, newImageY

'The returned coordinates will be in image coordinates. Convert them to viewport coordinates.
Dim newCanvasX As Double, newCanvasY As Double
Drawing.ConvertImageCoordsToCanvasCoords srcCanvas, PDImages.GetActiveImage(), newImageX, newImageY, newCanvasX, newCanvasY

'Finally, convert the canvas coordinates to screen coordinates, and move the cursor accordingly
srcCanvas.SetCursorToCanvasPosition newCanvasX, newCanvasY

End If

End If

'Redraw the screen to reflect this new change.
Viewport.Stage3_CompositeCanvas PDImages.GetActiveImage(), srcCanvas

End If

'Redraw the screen to reflect this new change.
Viewport.Stage3_CompositeCanvas PDImages.GetActiveImage(), srcCanvas

End If

End Sub
Expand Down

0 comments on commit 2cd98cb

Please sign in to comment.