Skip to content

Commit

Permalink
Implement basic UI for "Create macro from session history" tool
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerhelland committed Jun 19, 2018
1 parent 136385d commit faa9edd
Show file tree
Hide file tree
Showing 8 changed files with 369 additions and 47 deletions.
20 changes: 8 additions & 12 deletions Classes/pdPNG.cls
Expand Up @@ -67,20 +67,21 @@ End Enum
Private m_Header As PD_PNGHeader

'If warnings are encountered during processing, we push their messages onto a string stack. (We may
' decide to report these to the user... I haven't decided yet. Either way, it'll be helpful for debugging.)
' decide to report these to the user... I haven't decided yet. Either way, it's helpful for debugging.)
Private m_Warnings As pdStringStack

'pdStream makes our life much easier!
'pdStream handles actual byte traversal; it also makes our life much easier!
Private m_Stream As pdStream

'At present, we require the caller to pass an identical source file path to every load function.
' (This is a cheap and easy way to ensure no funny business is afoot!)
' (This is a cheap and easy way to ensure no funny business.)
Private m_SourceFilename As String

'In interlaced images, the number of pixels-per-reduced image is non-obvious. We calculate these
' line lengths as part of the decompression pass, and rather than re-calculate them on subsequent passes,
' we simply cache the results and re-use them later. (Note that there is no "y" byte count, because it
' is the same as the pixel count.)
' is the same as the pixel count; x requires a separate value, due to potential multi-byte-per-pixel
' color depths.)
Private m_XPixelCount() As Long, m_YPixelCount() As Long
Private m_XByteCount() As Long

Expand Down Expand Up @@ -1825,14 +1826,9 @@ Private Sub ConstructGrayPalette(ByRef srcPalette() As RGBQuad, ByRef srcPalette

End Sub

'TODO! We can now assemble the image's underlying pixel data. Note that
' the way we do this varies by color-mode and bit-depth. If the image has an ICC profile, we want to leave data
' in its original format in some circumstances (e.g. 16-bit-per-channel images must remain high-bit-depth prior
' to ICC conversion), while in others (e.g. 1-bit images) there is no advantage to leaving pixels in their
' original state. (In fact, we *must* convert them to another color-depth in order to ICC-correct them.)

'NOTE: this function only works if m_Header has been populated! We need access to color-mode and bit-depth data
' in order to calculate interlacing pixel counts.
'Interlaced sub-images have varying sizes depending on the iteration pass. This function returns the
' width and height of a given interlaced sub-image; m_Header *must* be populated for this to work, since it
' relies on color-mode and bit-depth data.
Private Function GetSizeInterlaced(ByRef dstX As Long, ByRef dstY As Long, ByVal intPass As Long)

'Per the spec, each interlacing pass encodes the following pixels from each 8x8 block in the image:
Expand Down
7 changes: 4 additions & 3 deletions Forms/Edit_UndoHistory.frm
Expand Up @@ -3,7 +3,7 @@ Begin VB.Form FormUndoHistory
BackColor = &H80000005&
BorderStyle = 4 'Fixed ToolWindow
Caption = " Undo history"
ClientHeight = 6420
ClientHeight = 6390
ClientLeft = 45
ClientTop = 285
ClientWidth = 9615
Expand All @@ -19,12 +19,13 @@ Begin VB.Form FormUndoHistory
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 428
ScaleHeight = 426
ScaleMode = 3 'Pixel
ScaleWidth = 641
ShowInTaskbar = 0 'False
Begin PhotoDemon.pdLabel lblTitle
Height = 255
Index = 0
Left = 480
Top = 5280
Width = 8895
Expand All @@ -48,7 +49,7 @@ Begin VB.Form FormUndoHistory
Height = 735
Left = 0
TabIndex = 0
Top = 5685
Top = 5655
Width = 9615
_ExtentX = 16960
_ExtentY = 1296
Expand Down
59 changes: 37 additions & 22 deletions Forms/MainWindow.frm
Expand Up @@ -1300,16 +1300,24 @@ Begin VB.Form FormMain
Index = 4
End
Begin VB.Menu MnuTool
Caption = "Record macro"
Caption = "Create macro"
Index = 5
Begin VB.Menu MnuRecordMacro
Caption = "Start recording"
Begin VB.Menu MnuMacroCreate
Caption = "From session history..."
Index = 0
End
Begin VB.Menu MnuRecordMacro
Begin VB.Menu MnuMacroCreate
Caption = "-"
Index = 1
End
Begin VB.Menu MnuMacroCreate
Caption = "Start recording"
Index = 2
End
Begin VB.Menu MnuMacroCreate
Caption = "Stop recording..."
Enabled = 0 'False
Index = 1
Index = 3
End
End
Begin VB.Menu MnuTool
Expand Down Expand Up @@ -1624,6 +1632,29 @@ Attribute m_MetadataTimer.VB_VarHelpID = -1

Private m_AllowedToReflowInterface As Boolean

Private Sub MnuMacroCreate_Click(Index As Integer)

Select Case Index

'Create from session history
Case 0
ShowPDDialog vbModal, FormMacroSession

'(separator)
Case 1

'Start recording
Case 2
Process "Start macro recording", , , UNDO_Nothing

'Stop recording
Case 3
Process "Stop macro recording", True

End Select

End Sub

Private Sub MnuTest_Click()

'Filters_Scientific.InternalFFTTest
Expand Down Expand Up @@ -2374,22 +2405,6 @@ Private Sub mnuRecentMacros_Click(Index As Integer)

End Sub

Private Sub MnuRecordMacro_Click(Index As Integer)

Select Case Index

'Start recording
Case 0
Process "Start macro recording", , , UNDO_Nothing

'Stop recording
Case 1
Process "Stop macro recording", True

End Select

End Sub

Private Sub MnuView_Click(Index As Integer)

Select Case Index
Expand Down Expand Up @@ -4137,7 +4152,7 @@ Private Sub mnuTool_Click(Index As Integer)
'(separator)
Case 4

'Record macro (top-level)
'Create macro (top-level)
Case 5

'Play saved macro
Expand Down

0 comments on commit faa9edd

Please sign in to comment.