diff --git a/src/app/MetaBrush/Action.hs b/src/app/MetaBrush/Action.hs index 3b4904d..d783709 100644 --- a/src/app/MetaBrush/Action.hs +++ b/src/app/MetaBrush/Action.hs @@ -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 -- --------- diff --git a/src/app/MetaBrush/UI/Menu.hs b/src/app/MetaBrush/UI/Menu.hs index 76f3134..96cd2bd 100644 --- a/src/app/MetaBrush/UI/Menu.hs +++ b/src/app/MetaBrush/UI/Menu.hs @@ -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 diff --git a/src/lib/Math/Bezier/Stroke.hs b/src/lib/Math/Bezier/Stroke.hs index a854d22..fe7c744 100644 --- a/src/lib/Math/Bezier/Stroke.hs +++ b/src/lib/Math/Bezier/Stroke.hs @@ -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