mirror of
https://gitlab.com/sheaf/metabrush.git
synced 2024-11-27 17:34:08 +00:00
don't attempt to draw outline when brush is empty
This commit is contained in:
parent
a098eb6471
commit
930fa0ebf9
|
@ -383,6 +383,17 @@ data Redo = Redo
|
|||
instance HandleAction Redo where
|
||||
handleAction _ _ _ = pure ()
|
||||
|
||||
---------------------
|
||||
-- Discard changes --
|
||||
---------------------
|
||||
|
||||
data DiscardChanges = DiscardChanges
|
||||
deriving stock Show
|
||||
|
||||
-- TODO
|
||||
instance HandleAction DiscardChanges where
|
||||
handleAction _ _ _ = pure ()
|
||||
|
||||
---------
|
||||
-- Cut --
|
||||
---------
|
||||
|
|
|
@ -134,16 +134,17 @@ data FileMenu ( rt :: ResourceType )
|
|||
|
||||
data EditMenu ( rt :: ResourceType )
|
||||
= EditMenu
|
||||
{ undo :: !( MenuItem Undo NoSubresource rt )
|
||||
, redo :: !( MenuItem Redo NoSubresource rt )
|
||||
, editSep1 :: !( Separator rt )
|
||||
, cut :: !( MenuItem Cut NoSubresource rt )
|
||||
, copy :: !( MenuItem Copy NoSubresource rt )
|
||||
, paste :: !( MenuItem Paste NoSubresource rt )
|
||||
, duplicate :: !( MenuItem Duplicate NoSubresource rt )
|
||||
, delete :: !( MenuItem Delete NoSubresource rt )
|
||||
, editSep2 :: !( Separator rt )
|
||||
, preferences :: !( MenuItem () NoSubresource rt )
|
||||
{ undo :: !( MenuItem Undo NoSubresource rt )
|
||||
, redo :: !( MenuItem Redo NoSubresource rt )
|
||||
, discardChanges :: !( MenuItem DiscardChanges NoSubresource rt )
|
||||
, editSep1 :: !( Separator rt )
|
||||
, cut :: !( MenuItem Cut NoSubresource rt )
|
||||
, copy :: !( MenuItem Copy NoSubresource rt )
|
||||
, paste :: !( MenuItem Paste NoSubresource rt )
|
||||
, duplicate :: !( MenuItem Duplicate NoSubresource rt )
|
||||
, delete :: !( MenuItem Delete NoSubresource rt )
|
||||
, editSep2 :: !( Separator rt )
|
||||
, preferences :: !( MenuItem () NoSubresource rt )
|
||||
}
|
||||
deriving stock Generic
|
||||
|
||||
|
@ -191,16 +192,17 @@ fileMenuDescription
|
|||
editMenuDescription :: EditMenu Description
|
||||
editMenuDescription
|
||||
= EditMenu
|
||||
{ undo = MenuItemDescription "Undo" [ "submenuItem" ] Undo ( Just ( GDK.KEY_Z, [ Control L ] ) ) NoSubresource
|
||||
, redo = MenuItemDescription "Redo" [ "submenuItem" ] Redo ( Just ( GDK.KEY_Y, [ Control L ] ) ) NoSubresource
|
||||
, editSep1 = SeparatorDescription [ "submenuSeparator" ]
|
||||
, cut = MenuItemDescription "Cut" [ "submenuItem" ] Cut ( Just ( GDK.KEY_X, [ Control L ] ) ) NoSubresource
|
||||
, copy = MenuItemDescription "Copy" [ "submenuItem" ] Copy ( Just ( GDK.KEY_C, [ Control L ] ) ) NoSubresource
|
||||
, paste = MenuItemDescription "Paste" [ "submenuItem" ] Paste ( Just ( GDK.KEY_V, [ Control L ] ) ) NoSubresource
|
||||
, duplicate = MenuItemDescription "Duplicate" [ "submenuItem" ] Duplicate ( Just ( GDK.KEY_D, [ Control L ] ) ) NoSubresource
|
||||
, delete = MenuItemDescription "Delete" [ "submenuItem" ] Delete ( Just ( GDK.KEY_Delete, [] ) ) NoSubresource
|
||||
, editSep2 = SeparatorDescription [ "submenuSeparator" ]
|
||||
, preferences = MenuItemDescription "Preferences" [ "submenuItem" ] () ( Just ( GDK.KEY_P, [ Control L, Shift L ] ) ) NoSubresource
|
||||
{ undo = MenuItemDescription "Undo" [ "submenuItem" ] Undo ( Just ( GDK.KEY_Z, [ Control L ] ) ) NoSubresource
|
||||
, redo = MenuItemDescription "Redo" [ "submenuItem" ] Redo ( Just ( GDK.KEY_Y, [ Control L ] ) ) NoSubresource
|
||||
, discardChanges = MenuItemDescription "Discard changes" [ "submenuItem" ] DiscardChanges ( Just ( GDK.KEY_Z, [ Control L, Shift L ] ) ) NoSubresource
|
||||
, editSep1 = SeparatorDescription [ "submenuSeparator" ]
|
||||
, cut = MenuItemDescription "Cut" [ "submenuItem" ] Cut ( Just ( GDK.KEY_X, [ Control L ] ) ) NoSubresource
|
||||
, copy = MenuItemDescription "Copy" [ "submenuItem" ] Copy ( Just ( GDK.KEY_C, [ Control L ] ) ) NoSubresource
|
||||
, paste = MenuItemDescription "Paste" [ "submenuItem" ] Paste ( Just ( GDK.KEY_V, [ Control L ] ) ) NoSubresource
|
||||
, duplicate = MenuItemDescription "Duplicate" [ "submenuItem" ] Duplicate ( Just ( GDK.KEY_D, [ Control L ] ) ) NoSubresource
|
||||
, delete = MenuItemDescription "Delete" [ "submenuItem" ] Delete ( Just ( GDK.KEY_Delete, [] ) ) NoSubresource
|
||||
, editSep2 = SeparatorDescription [ "submenuSeparator" ]
|
||||
, preferences = MenuItemDescription "Preferences" [ "submenuItem" ] () ( Just ( GDK.KEY_P, [ Control L, Shift L ] ) ) NoSubresource
|
||||
}
|
||||
|
||||
viewMenuDescription :: ViewMenu Description
|
||||
|
|
|
@ -113,9 +113,13 @@ stroke Empty = Left Empty
|
|||
stroke ( spt0 :<| Empty ) = Left . removePointData $ ( Point2D 0 0 --> coords spt0 :: Vector2D Double ) • brushShape @x spt0
|
||||
stroke allPts@( spt0 :<| spt1 :<| spts )
|
||||
| isClosed
|
||||
= Right ( fwdPts, bwdPts )
|
||||
= if null ( brushShape @x spt0 )
|
||||
then Right ( Empty, Empty )
|
||||
else Right ( fwdPts, bwdPts )
|
||||
| otherwise
|
||||
= Left ( startingCap <> fwdPts <> bwdPts )
|
||||
= if null ( brushShape @x spt0 )
|
||||
then Left Empty
|
||||
else Left ( startingCap <> fwdPts <> bwdPts )
|
||||
where
|
||||
|
||||
startOffset, endOffset :: Vector2D Double
|
||||
|
@ -124,9 +128,9 @@ stroke allPts@( spt0 :<| spt1 :<| spts )
|
|||
startOffset = Point2D 0 0 --> coords spt0
|
||||
tgt_start = coords spt0 --> coords spt1
|
||||
( tgt_end, endOffset, brush_end ) = case allPts of
|
||||
_ :|> sptnm1 :|> sptn -> ( coords sptnm1 --> coords sptn, Point2D 0 0 --> coords sptn, brushShape sptn )
|
||||
_ :|> sptnm1 :|> sptn -> ( coords sptnm1 --> coords sptn, Point2D 0 0 --> coords sptn, brushShape @x sptn )
|
||||
_ -> error "impossible"
|
||||
brush_start = brushShape spt0
|
||||
brush_start = brushShape @x spt0
|
||||
|
||||
isClosed :: Bool
|
||||
isClosed = case ( spt1 :<| spts ) of
|
||||
|
|
Loading…
Reference in a new issue