rename recomputeStrokes -> redrawStrokes

This commit is contained in:
sheaf 2024-10-12 16:48:21 +02:00
parent 1a8f4b5f5d
commit 47cf66c5dd
5 changed files with 15 additions and 15 deletions

View file

@ -202,7 +202,7 @@ runApplication application = do
testDocuments = newHistory <$> Map.fromList
[ ( docUnique, testDoc ) ]
recomputeStrokesTVar <- STM.newTVarIO False
redrawStrokesTVar <- STM.newTVarIO False
documentRenderTVar <- STM.newTVarIO ( const $ pure () )
activeDocumentTVar <- STM.newTVarIO Nothing
openDocumentsTVar <- STM.newTVarIO testDocuments
@ -344,8 +344,8 @@ runApplication application = do
-- Update the document render data in a separate thread.
_ <- forkIO $ forever do
getRenderDoc <- STM.atomically do
needsRecomputation <- STM.readTVar recomputeStrokesTVar
case needsRecomputation of
needsRedraw <- STM.readTVar redrawStrokesTVar
case needsRedraw of
False -> STM.retry
True -> do
mbDocNow <- fmap ( present . snd ) <$> activeDocument variables
@ -362,7 +362,7 @@ runApplication application = do
fitParameters <- STM.readTVar fitParametersTVar
rootsAlgo <- STM.readTVar rootsAlgoTVar
mbCuspOptions <- STM.readTVar cuspFindingOptionsTVar
STM.writeTVar recomputeStrokesTVar False
STM.writeTVar redrawStrokesTVar False
let
addRulers :: ( ( Int32, Int32 ) -> Cairo.Render () ) -> ( ( Int32, Int32 ) -> Cairo.Render () )
addRulers newRender viewportSize = do

View file

@ -678,7 +678,7 @@ data ToggleGuides = ToggleGuides
deriving stock Show
instance HandleAction ToggleGuides where
handleAction ( UIElements { viewport = Viewport {..} } ) ( Variables { recomputeStrokesTVar, showGuidesTVar } ) _ = do
handleAction ( UIElements { viewport = Viewport {..} } ) ( Variables { redrawStrokesTVar, showGuidesTVar } ) _ = do
_guidesWereShown <- STM.atomically do
guidesWereShown <- STM.readTVar showGuidesTVar
STM.writeTVar showGuidesTVar ( not guidesWereShown )
@ -692,7 +692,7 @@ instance HandleAction ToggleGuides where
-- toggleGuidesWidget = menuItemWidget . toggleGuides . sectionItems . viewMenu4 . menuItemSubmenu . view
-- $ menuObject
--GTK.buttonSetLabel toggleGuidesWidget newText
STM.atomically ( STM.writeTVar recomputeStrokesTVar True )
STM.atomically ( STM.writeTVar redrawStrokesTVar True )
for_ [ rulerCornerDrawingArea, topRulerDrawingArea, leftRulerDrawingArea ] \ drawingArea -> do
GTK.widgetQueueDraw drawingArea
@ -714,7 +714,7 @@ instance HandleAction Confirm where
-- End ongoing drawing on pressing enter key.
Pen -> do
STM.writeTVar partialPathTVar Nothing
STM.writeTVar recomputeStrokesTVar True
STM.writeTVar redrawStrokesTVar True
_ -> pure ()
----------------
@ -812,7 +812,7 @@ instance HandleAction MouseMove where
tool <- STM.readTVar toolTVar
mbPartialPath <- STM.readTVar partialPathTVar
mode <- STM.readTVar modeTVar
STM.writeTVar recomputeStrokesTVar True -- need to keep updating for mouse hover updates
STM.writeTVar redrawStrokesTVar True -- need to keep updating for mouse hover updates
if
| Pen <- tool
, Just pp <- mbPartialPath
@ -1041,7 +1041,7 @@ instance HandleAction MouseClick where
-- Right mouse button: end partial path.
3 -> STM.atomically do
STM.writeTVar partialPathTVar Nothing
STM.writeTVar recomputeStrokesTVar True
STM.writeTVar redrawStrokesTVar True
-- Other mouse buttons: ignored (for the moment at least).
_ -> pure ()
@ -1370,7 +1370,7 @@ instance HandleAction KeyboardPress where
, Just pp <- mbPartialPath
-> STM.atomically do
STM.writeTVar partialPathTVar ( Just $ pp { partialControlPoint = Just mp } )
STM.writeTVar recomputeStrokesTVar True
STM.writeTVar redrawStrokesTVar True
_ -> pure ()
_ -> pure ()

View file

@ -99,7 +99,7 @@ data UIElements
data Variables
= Variables
{ uniqueSupply :: !UniqueSupply
, recomputeStrokesTVar :: !( STM.TVar Bool )
, redrawStrokesTVar :: !( STM.TVar Bool )
, documentRenderTVar :: !( STM.TVar ( ( Int32, Int32 ) -> Cairo.Render () ) )
, activeDocumentTVar :: !( STM.TVar ( Maybe Unique ) )
, openDocumentsTVar :: !( STM.TVar ( Map Unique DocumentHistory ) )

View file

@ -231,7 +231,7 @@ updateUIAction _docChange uiElts@( UIElements { viewport = Viewport {..}, .. } )
GTK.widgetQueueDraw fileBarTab
GTK.widgetQueueDraw fileBarTabCloseArea
updateHistoryState uiElts ( fmap snd mbDocHist )
STM.atomically ( STM.writeTVar recomputeStrokesTVar True )
STM.atomically ( STM.writeTVar redrawStrokesTVar True )
updateTitle :: GTK.IsWindow window => window -> GTK.Label -> Maybe ( Text, Bool ) -> IO ()
updateTitle window titleLabel mbTitleText = do

View file

@ -56,7 +56,7 @@ createToolBar ( Variables {..} ) colours toolBar = do
( second \ toolVal -> STM.atomically do
STM.writeTVar toolTVar toolVal
STM.writeTVar partialPathTVar Nothing
STM.writeTVar recomputeStrokesTVar True
STM.writeTVar redrawStrokesTVar True
)
[ ( selectionTool, Selection ), ( penTool, Pen ) ]
GTK.toggleButtonSetActive selectionTool True
@ -73,7 +73,7 @@ createToolBar ( Variables {..} ) colours toolBar = do
( second \ modeVal -> STM.atomically do
STM.writeTVar modeTVar modeVal
STM.writeTVar partialPathTVar Nothing
STM.writeTVar recomputeStrokesTVar True
STM.writeTVar redrawStrokesTVar True
)
[ ( pathTool, PathMode ), ( brushTool, BrushMode ), ( metaTool, MetaMode ) ]
GTK.toggleButtonSetActive pathTool True
@ -87,7 +87,7 @@ createToolBar ( Variables {..} ) colours toolBar = do
STM.atomically do
STM.writeTVar debugTVar clicked
STM.writeTVar partialPathTVar Nothing
STM.writeTVar recomputeStrokesTVar True
STM.writeTVar redrawStrokesTVar True
GTK.boxAppend toolBar selectionTool
GTK.boxAppend toolBar penTool