0 | module CyBy.Draw.Event
 1 |
 2 | import CyBy.Draw.Internal.Abbreviations
 3 | import CyBy.Draw.Internal.Atom
 4 | import CyBy.Draw.Internal.Graph
 5 | import Derive.Finite
 6 | import Derive.FromJSON.Simple
 7 | import Derive.ToJSON.Simple
 8 | import Derive.Prelude
 9 | import JSON.Simple
10 | import Text.Molfile
11 | import Web.Canvas
12 |
13 | %default total
14 | %language ElabReflection
15 |
16 | --------------------------------------------------------------------------------
17 | -- Color Schemes
18 | --------------------------------------------------------------------------------
19 |
20 | public export
21 | data ColorScheme = Black | CyBy | Groups | CPK | CDK | JMol | PyMol
22 |
23 | %runElab derive "ColorScheme" [Show,Eq,Ord,Finite,FromJSON,ToJSON]
24 |
25 | --------------------------------------------------------------------------------
26 | --          Event
27 | --------------------------------------------------------------------------------
28 |
29 | ||| Modifier key such as "Shift" or "Ctrl" currently being pressed.
30 | public export
31 | data Modifier = NoMod | Ctrl | Shift
32 |
33 | %runElab derive "Modifier" [Show, Eq]
34 |
35 | ||| Resets the pressed modifier key if it matches the keyboard key being
36 | ||| lifted.
37 | export
38 | reset : (mod, current : Modifier) -> Modifier
39 | reset m c = if m == c then NoMod else c
40 |
41 | ||| A data type for logging messages.
42 | |||
43 | ||| Typically, these will not be handled by cyby-draw directly but
44 | ||| by applications embedding our drawing canvas into their own
45 | ||| UI.
46 | public export
47 | data DrawMsg : Type where
48 |   ||| Data was copied to clipboard
49 |   Copied  : DrawMsg
50 |   
51 |   ||| Invalid data was read from clipboard
52 |   ReadErr : String -> DrawMsg
53 |
54 | %runElab derive "DrawMsg" [Show, Eq]
55 |
56 | public export
57 | data DrawEvent : Type where
58 |   ZoomIn           : (atPos : Bool) -> DrawEvent
59 |   ZoomOut          : (atPos : Bool) -> DrawEvent
60 |   Undo             : DrawEvent
61 |   Redo             : DrawEvent
62 |   SetElem          : Elem -> DrawEvent
63 |   ChgElem          : Elem -> DrawEvent
64 |   ChgCharge        : Charge -> DrawEvent
65 |   ChgMass          : Maybe MassNr -> DrawEvent
66 |   SelAbbr          : Abbreviation -> DrawEvent
67 |   EnableAbbr       : DrawEvent
68 |   SetBond          : MolBond -> DrawEvent
69 |   Move             : (x,y : Double) -> DrawEvent
70 |   LeftDown         : DrawEvent
71 |   LeftUp           : DrawEvent
72 |   MiddleDown       : DrawEvent
73 |   MiddleUp         : DrawEvent
74 |   SetTempl         : CDGraph -> DrawEvent
75 |   Load             : CDGraph -> DrawEvent
76 |   SelectMode       : DrawEvent
77 |   KeyDown          : String -> DrawEvent
78 |   KeyUp            : String -> DrawEvent
79 |   EraseMode        : DrawEvent
80 |   Focus            : DrawEvent
81 |   Blur             : DrawEvent
82 |   Clear            : DrawEvent
83 |   Expand           : DrawEvent
84 |   Center           : DrawEvent
85 |   Redraw           : DrawEvent
86 |   Resize           : (h,w : Double) -> DrawEvent
87 |   StartPSE         : DrawEvent
88 |   SVG              : DrawEvent
89 |   SVGimp           : DrawEvent
90 |
91 | %runElab derive "DrawEvent" [Show, Eq]
92 |