2020-09-06 12:54:18 +00:00
|
|
|
module MetaBrush.Action where
|
|
|
|
|
|
|
|
-- base
|
|
|
|
import Data.Word
|
|
|
|
( Word32 )
|
|
|
|
|
|
|
|
-- gi-gtk
|
|
|
|
import qualified GI.Gtk as GTK
|
|
|
|
|
2021-04-21 15:08:33 +00:00
|
|
|
-- hashable
|
|
|
|
import Data.Hashable
|
|
|
|
( Hashable )
|
|
|
|
|
|
|
|
-- text
|
|
|
|
import Data.Text
|
|
|
|
( Text )
|
|
|
|
|
2020-09-06 12:54:18 +00:00
|
|
|
-- MetaBrush
|
2023-01-08 16:16:14 +00:00
|
|
|
import Math.Linear
|
2020-09-06 12:54:18 +00:00
|
|
|
( Point2D, Vector2D )
|
|
|
|
import {-# SOURCE #-} MetaBrush.Context
|
|
|
|
( UIElements, Variables )
|
|
|
|
import {-# SOURCE #-} MetaBrush.UI.FileBar
|
|
|
|
( TabLocation(..) )
|
|
|
|
import MetaBrush.UI.Viewport
|
|
|
|
( Ruler(..) )
|
|
|
|
import MetaBrush.Unique
|
|
|
|
( Unique )
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
2021-04-21 15:08:33 +00:00
|
|
|
data ActionName
|
|
|
|
= AppAction { actionSimpleName :: !Text }
|
|
|
|
| WinAction { actionSimpleName :: !Text }
|
|
|
|
|
|
|
|
instance Eq ActionName
|
|
|
|
instance Ord ActionName
|
|
|
|
instance Show ActionName
|
|
|
|
instance Hashable ActionName
|
|
|
|
|
2020-09-06 12:54:18 +00:00
|
|
|
class HandleAction action where
|
|
|
|
handleAction :: UIElements -> Variables -> action -> IO ()
|
|
|
|
|
|
|
|
instance HandleAction ()
|
|
|
|
|
2021-05-10 15:46:31 +00:00
|
|
|
data NewFile = NewFile !TabLocation
|
2020-09-06 12:54:18 +00:00
|
|
|
instance HandleAction NewFile
|
|
|
|
|
2021-05-10 15:46:31 +00:00
|
|
|
data OpenFile = OpenFile !TabLocation
|
2020-09-06 12:54:18 +00:00
|
|
|
instance HandleAction OpenFile
|
|
|
|
|
2021-05-10 15:46:31 +00:00
|
|
|
data OpenFolder = OpenFolder !TabLocation
|
2020-09-06 12:54:18 +00:00
|
|
|
instance HandleAction OpenFolder
|
|
|
|
|
|
|
|
data Save = Save
|
|
|
|
instance HandleAction Save
|
|
|
|
|
|
|
|
data SaveAs = SaveAs
|
|
|
|
instance HandleAction SaveAs
|
|
|
|
|
|
|
|
data Close
|
|
|
|
= CloseActive
|
|
|
|
| CloseThis
|
2021-04-21 15:08:33 +00:00
|
|
|
{ docToClose :: !Unique }
|
2020-09-06 12:54:18 +00:00
|
|
|
instance HandleAction Close
|
|
|
|
|
2021-04-21 15:08:33 +00:00
|
|
|
data SwitchFromTo =
|
|
|
|
SwitchFromTo
|
|
|
|
{ mbPrevActiveDocUnique :: !( Maybe Unique )
|
|
|
|
, newActiveDocUnique :: !Unique
|
|
|
|
}
|
|
|
|
instance HandleAction SwitchFromTo
|
2020-09-06 12:54:18 +00:00
|
|
|
|
|
|
|
data Quit = Quit
|
|
|
|
instance HandleAction Quit
|
2021-04-21 15:08:33 +00:00
|
|
|
quitEverything :: GTK.IsWindow window => GTK.Application -> window -> IO ()
|
2020-09-06 12:54:18 +00:00
|
|
|
|
|
|
|
data Undo = Undo
|
|
|
|
instance HandleAction Undo
|
|
|
|
|
|
|
|
data Redo = Redo
|
|
|
|
instance HandleAction Redo
|
|
|
|
|
|
|
|
data Cut = Cut
|
|
|
|
instance HandleAction Cut
|
|
|
|
|
|
|
|
data Copy = Copy
|
|
|
|
instance HandleAction Copy
|
|
|
|
|
|
|
|
data Paste = Paste
|
|
|
|
instance HandleAction Paste
|
|
|
|
|
|
|
|
data Duplicate = Duplicate
|
|
|
|
instance HandleAction Duplicate
|
|
|
|
|
|
|
|
data Delete = Delete
|
|
|
|
instance HandleAction Delete
|
|
|
|
|
|
|
|
data ToggleGuides = ToggleGuides
|
|
|
|
instance HandleAction ToggleGuides
|
|
|
|
|
|
|
|
data Confirm = Confirm
|
|
|
|
instance HandleAction Confirm
|
|
|
|
|
|
|
|
data About = About
|
|
|
|
instance HandleAction About
|
|
|
|
|
2021-05-10 15:46:31 +00:00
|
|
|
data MouseMove = MouseMove !( Point2D Double )
|
2020-09-06 12:54:18 +00:00
|
|
|
instance HandleAction MouseMove
|
|
|
|
|
|
|
|
data ActionOrigin
|
|
|
|
= ViewportOrigin
|
2021-05-10 15:46:31 +00:00
|
|
|
| RulerOrigin !Ruler
|
2020-09-06 12:54:18 +00:00
|
|
|
data MouseClickType
|
|
|
|
= SingleClick
|
|
|
|
| DoubleClick
|
2021-05-24 15:30:25 +00:00
|
|
|
data MouseClick =
|
|
|
|
MouseClick
|
|
|
|
{ clickOrigin :: !ActionOrigin
|
|
|
|
, clickType :: !MouseClickType
|
|
|
|
, clickButton :: !Word32
|
|
|
|
, clickCoords :: !( Point2D Double )
|
|
|
|
}
|
2020-09-06 12:54:18 +00:00
|
|
|
instance HandleAction MouseClick
|
|
|
|
|
2021-05-10 15:46:31 +00:00
|
|
|
data MouseRelease = MouseRelease !Word32 !( Point2D Double )
|
2020-09-06 12:54:18 +00:00
|
|
|
instance HandleAction MouseRelease
|
|
|
|
|
2021-05-10 15:46:31 +00:00
|
|
|
data Scroll = Scroll !( Maybe ( Point2D Double ) ) !( Vector2D Double )
|
2020-09-06 12:54:18 +00:00
|
|
|
instance HandleAction Scroll
|
|
|
|
|
2021-05-10 15:46:31 +00:00
|
|
|
data KeyboardPress = KeyboardPress !Word32
|
2020-09-06 12:54:18 +00:00
|
|
|
instance HandleAction KeyboardPress
|
|
|
|
|
2021-05-10 15:46:31 +00:00
|
|
|
data KeyboardRelease = KeyboardRelease !Word32
|
2020-09-06 12:54:18 +00:00
|
|
|
instance HandleAction KeyboardRelease
|