Commit 976c339c authored by Peter Achten's avatar Peter Achten

distinguish between onclick mouse handler (that responds immediately) and...

distinguish between onclick mouse handler (that responds immediately) and onNclick mouse handler (that must use a small device dependent delay to determine double click events)
parent 9500c75c
Pipeline #24029 failed with stage
in 2 minutes and 58 seconds
...@@ -268,7 +268,7 @@ tuneIf :: !Bool !(Image m) !(attr m) -> Image m | tuneImage attr ...@@ -268,7 +268,7 @@ tuneIf :: !Bool !(Image m) !(attr m) -> Image m | tuneImage attr
instance tuneImage NoAttr, DashAttr, FillAttr, LineEndMarker, LineMidMarker, LineStartMarker, MaskAttr, OpacityAttr, instance tuneImage NoAttr, DashAttr, FillAttr, LineEndMarker, LineMidMarker, LineStartMarker, MaskAttr, OpacityAttr,
StrokeAttr, StrokeWidthAttr, XRadiusAttr, YRadiusAttr, StrokeAttr, StrokeWidthAttr, XRadiusAttr, YRadiusAttr,
OnClickAttr, OnMouseDownAttr, OnMouseUpAttr, OnMouseOverAttr, OnMouseMoveAttr, OnMouseOutAttr, DraggableAttr OnClickAttr, OnNClickAttr, OnMouseDownAttr, OnMouseUpAttr, OnMouseOverAttr, OnMouseMoveAttr, OnMouseOutAttr, DraggableAttr
class margin a where margin :: !a !(Image m) -> Image m class margin a where margin :: !a !(Image m) -> Image m
......
...@@ -138,6 +138,7 @@ instance tuneImage YRadiusAttr where tuneImage image attr = Attr` (BasicImag ...@@ -138,6 +138,7 @@ instance tuneImage YRadiusAttr where tuneImage image attr = Attr` (BasicImag
instance tuneImage DraggableAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerDraggableAttr attr)) image instance tuneImage DraggableAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerDraggableAttr attr)) image
instance tuneImage OnClickAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerOnClickAttr attr)) image instance tuneImage OnClickAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerOnClickAttr attr)) image
instance tuneImage OnNClickAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerOnNClickAttr attr)) image
instance tuneImage OnMouseDownAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerOnMouseDownAttr attr)) image instance tuneImage OnMouseDownAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerOnMouseDownAttr attr)) image
instance tuneImage OnMouseMoveAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerOnMouseMoveAttr attr)) image instance tuneImage OnMouseMoveAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerOnMouseMoveAttr attr)) image
instance tuneImage OnMouseOutAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerOnMouseOutAttr attr)) image instance tuneImage OnMouseOutAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerOnMouseOutAttr attr)) image
......
...@@ -70,6 +70,7 @@ import Graphics.Scalable.Internal.Types ...@@ -70,6 +70,7 @@ import Graphics.Scalable.Internal.Types
:: TextSpan :== Real :: TextSpan :== Real
:: ImgEventhandler m :: ImgEventhandler m
= ImgEventhandlerOnClickAttr !(OnClickAttr m) = ImgEventhandlerOnClickAttr !(OnClickAttr m)
| ImgEventhandlerOnNClickAttr !(OnNClickAttr m)
| ImgEventhandlerOnMouseDownAttr !(OnMouseDownAttr m) | ImgEventhandlerOnMouseDownAttr !(OnMouseDownAttr m)
| ImgEventhandlerOnMouseUpAttr !(OnMouseUpAttr m) | ImgEventhandlerOnMouseUpAttr !(OnMouseUpAttr m)
| ImgEventhandlerOnMouseOverAttr !(OnMouseOverAttr m) | ImgEventhandlerOnMouseOverAttr !(OnMouseOverAttr m)
...@@ -80,12 +81,14 @@ import Graphics.Scalable.Internal.Types ...@@ -80,12 +81,14 @@ import Graphics.Scalable.Internal.Types
= { handler :: !DefuncImgEventhandler`, local :: !Bool } = { handler :: !DefuncImgEventhandler`, local :: !Bool }
:: DefuncImgEventhandler` :: DefuncImgEventhandler`
= ImgEventhandlerOnClickAttr` = ImgEventhandlerOnClickAttr`
| ImgEventhandlerOnNClickAttr`
| ImgEventhandlerOnMouseDownAttr` | ImgEventhandlerOnMouseDownAttr`
| ImgEventhandlerOnMouseUpAttr` | ImgEventhandlerOnMouseUpAttr`
| ImgEventhandlerOnMouseOverAttr` | ImgEventhandlerOnMouseOverAttr`
| ImgEventhandlerOnMouseMoveAttr` | ImgEventhandlerOnMouseMoveAttr`
| ImgEventhandlerOnMouseOutAttr` | ImgEventhandlerOnMouseOutAttr`
| ImgEventhandlerDraggableAttr` | ImgEventhandlerDraggableAttr`
instance == DefuncImgEventhandler`
:: ImgPath :: ImgPath
= { pathPoints :: ![ImageOffset] // the connecting points of the path = { pathPoints :: ![ImageOffset] // the connecting points of the path
, pathSpan :: !ImageSpan // the span of the path (also stored in imgSpans after resolving span-expressions) , pathSpan :: !ImageSpan // the span of the path (also stored in imgSpans after resolving span-expressions)
......
...@@ -137,6 +137,7 @@ imgAttrNode _ = Nothing ...@@ -137,6 +137,7 @@ imgAttrNode _ = Nothing
defunc :: !(ImgEventhandler m) -> ImgEventhandler` defunc :: !(ImgEventhandler m) -> ImgEventhandler`
defunc (ImgEventhandlerOnClickAttr {OnClickAttr | local}) = {ImgEventhandler` | handler = ImgEventhandlerOnClickAttr`, local=local} defunc (ImgEventhandlerOnClickAttr {OnClickAttr | local}) = {ImgEventhandler` | handler = ImgEventhandlerOnClickAttr`, local=local}
defunc (ImgEventhandlerOnNClickAttr {OnNClickAttr | local}) = {ImgEventhandler` | handler = ImgEventhandlerOnNClickAttr`, local=local}
defunc (ImgEventhandlerOnMouseDownAttr {OnMouseDownAttr | local}) = {ImgEventhandler` | handler = ImgEventhandlerOnMouseDownAttr`, local=local} defunc (ImgEventhandlerOnMouseDownAttr {OnMouseDownAttr | local}) = {ImgEventhandler` | handler = ImgEventhandlerOnMouseDownAttr`, local=local}
defunc (ImgEventhandlerOnMouseUpAttr {OnMouseUpAttr | local}) = {ImgEventhandler` | handler = ImgEventhandlerOnMouseUpAttr`, local=local} defunc (ImgEventhandlerOnMouseUpAttr {OnMouseUpAttr | local}) = {ImgEventhandler` | handler = ImgEventhandlerOnMouseUpAttr`, local=local}
defunc (ImgEventhandlerOnMouseOverAttr {OnMouseOverAttr | local}) = {ImgEventhandler` | handler = ImgEventhandlerOnMouseOverAttr`, local=local} defunc (ImgEventhandlerOnMouseOverAttr {OnMouseOverAttr | local}) = {ImgEventhandler` | handler = ImgEventhandlerOnMouseOverAttr`, local=local}
...@@ -630,6 +631,16 @@ where ...@@ -630,6 +631,16 @@ where
add_new_eventhandler p h (Just hs) add_new_eventhandler p h (Just hs)
| any ((match_eventhandler h) o snd) hs = Just hs | any ((match_eventhandler h) o snd) hs = Just hs
| otherwise = Just [(p,h):hs] | otherwise = Just [(p,h):hs]
where
match_eventhandler :: !ImgEventhandler` !ImgEventhandler` -> Bool
match_eventhandler new present
// if onclick or onNclick already present, then new onclick / onNclick attributes are ignored (innermost 'wins')
| present` == ImgEventhandlerOnClickAttr` || present` == ImgEventhandlerOnNClickAttr`
= new` == ImgEventhandlerOnClickAttr` || new` == ImgEventhandlerOnNClickAttr`
| otherwise = new` == present`
where
new` = new.ImgEventhandler`.handler
present` = present.ImgEventhandler`.handler
defaultLineMarkers :: LineMarkers defaultLineMarkers :: LineMarkers
defaultLineMarkers = {LineMarkers | lineStart = Nothing, lineMid = Nothing, lineEnd = Nothing} defaultLineMarkers = {LineMarkers | lineStart = Nothing, lineMid = Nothing, lineEnd = Nothing}
...@@ -649,19 +660,18 @@ ImgEventhandlerConsName (ImgEventhandlerOnMouseOutAttr _) = "ImgEventhandlerOnM ...@@ -649,19 +660,18 @@ ImgEventhandlerConsName (ImgEventhandlerOnMouseOutAttr _) = "ImgEventhandlerOnM
ImgEventhandlerConsName (ImgEventhandlerDraggableAttr _) = "ImgEventhandlerDraggableAttr" ImgEventhandlerConsName (ImgEventhandlerDraggableAttr _) = "ImgEventhandlerDraggableAttr"
ImgEventhandler`ConsName :: !DefuncImgEventhandler` -> String ImgEventhandler`ConsName :: !DefuncImgEventhandler` -> String
ImgEventhandler`ConsName ImgEventhandlerOnClickAttr` = "ImgEventhandlerOnClickAttr" ImgEventhandler`ConsName ImgEventhandlerOnClickAttr` = "ImgEventhandlerOnClickAttr`"
ImgEventhandler`ConsName ImgEventhandlerOnMouseDownAttr` = "ImgEventhandlerOnMouseDownAttr" ImgEventhandler`ConsName ImgEventhandlerOnNClickAttr` = "ImgEventhandlerOnNClickAttr`"
ImgEventhandler`ConsName ImgEventhandlerOnMouseUpAttr` = "ImgEventhandlerOnMouseUpAttr" ImgEventhandler`ConsName ImgEventhandlerOnMouseDownAttr` = "ImgEventhandlerOnMouseDownAttr`"
ImgEventhandler`ConsName ImgEventhandlerOnMouseOverAttr` = "ImgEventhandlerOnMouseOverAttr" ImgEventhandler`ConsName ImgEventhandlerOnMouseUpAttr` = "ImgEventhandlerOnMouseUpAttr`"
ImgEventhandler`ConsName ImgEventhandlerOnMouseMoveAttr` = "ImgEventhandlerOnMouseMoveAttr" ImgEventhandler`ConsName ImgEventhandlerOnMouseOverAttr` = "ImgEventhandlerOnMouseOverAttr`"
ImgEventhandler`ConsName ImgEventhandlerOnMouseOutAttr` = "ImgEventhandlerOnMouseOutAttr" ImgEventhandler`ConsName ImgEventhandlerOnMouseMoveAttr` = "ImgEventhandlerOnMouseMoveAttr`"
ImgEventhandler`ConsName ImgEventhandlerDraggableAttr` = "ImgEventhandlerDraggableAttr" ImgEventhandler`ConsName ImgEventhandlerOnMouseOutAttr` = "ImgEventhandlerOnMouseOutAttr`"
ImgEventhandler`ConsName ImgEventhandlerDraggableAttr` = "ImgEventhandlerDraggableAttr`"
match_eventhandler :: !ImgEventhandler` !ImgEventhandler` -> Bool
match_eventhandler a b = ImgEventhandler`ConsName a.ImgEventhandler`.handler == ImgEventhandler`ConsName b.ImgEventhandler`.handler instance < (ImgEventhandler m) where < a b = ImgEventhandlerConsName a < ImgEventhandlerConsName b
instance == (ImgEventhandler m) where == a b = ImgEventhandlerConsName a == ImgEventhandlerConsName b
instance < (ImgEventhandler m) where < a b = ImgEventhandlerConsName a < ImgEventhandlerConsName b instance == DefuncImgEventhandler` where == a b = ImgEventhandler`ConsName a == ImgEventhandler`ConsName b
instance == (ImgEventhandler m) where == a b = ImgEventhandlerConsName a == ImgEventhandlerConsName b
ImgAttrConsName :: !BasicImgAttr -> String ImgAttrConsName :: !BasicImgAttr -> String
ImgAttrConsName (BasicImgStrokeAttr _) = "BasicImgStrokeAttr" ImgAttrConsName (BasicImgStrokeAttr _) = "BasicImgStrokeAttr"
......
...@@ -54,12 +54,13 @@ instance == LineMarkerPos ...@@ -54,12 +54,13 @@ instance == LineMarkerPos
:: YAlign = AtTop | AtMiddleY | AtBottom :: YAlign = AtTop | AtMiddleY | AtBottom
:: XYAlign :== (!XAlign, !YAlign) :: XYAlign :== (!XAlign, !YAlign)
:: OnClickAttr m = { onclick :: !(Int m -> m), local :: !Bool } :: OnClickAttr m = { onclick :: !(m -> m), local :: !Bool } // handle single mouse click, without delay
:: OnMouseDownAttr m = { onmousedown :: !(m -> m), local :: !Bool } :: OnNClickAttr m = { onNclick :: !(Int m -> m), local :: !Bool } // handle multiple mouse clicks, this comes with a brief (client dependent) delay
:: OnMouseUpAttr m = { onmouseup :: !(m -> m), local :: !Bool } :: OnMouseDownAttr m = { onmousedown :: !(m -> m), local :: !Bool } // handle mouse down event
:: OnMouseOverAttr m = { onmouseover :: !(m -> m), local :: !Bool } :: OnMouseUpAttr m = { onmouseup :: !(m -> m), local :: !Bool } // handle mouse up event
:: OnMouseMoveAttr m = { onmousemove :: !(m -> m), local :: !Bool } :: OnMouseOverAttr m = { onmouseover :: !(m -> m), local :: !Bool } // handle mouse over event (move into associated image)
:: OnMouseOutAttr m = { onmouseout :: !(m -> m), local :: !Bool } :: OnMouseMoveAttr m = { onmousemove :: !(m -> m), local :: !Bool } // handle mouse move event (move inside associated image)
:: OnMouseOutAttr m = { onmouseout :: !(m -> m), local :: !Bool } // handle mouse out event (move away from associated image)
:: DraggableAttr m = { draggable :: !(SVGDragFun m) } :: DraggableAttr m = { draggable :: !(SVGDragFun m) }
:: SVGDragFun m :== (Set ImageTag) (Real,Real) m -> m // \tags (x,y) model: tags is the set of ImageTag-s associated with the 'dragged-on' image, (x,y) the location within that image :: SVGDragFun m :== (Set ImageTag) (Real,Real) m -> m // \tags (x,y) model: tags is the set of ImageTag-s associated with the 'dragged-on' image, (x,y) the location within that image
:: RGB = { r :: !Int, g :: !Int, b :: !Int } :: RGB = { r :: !Int, g :: !Int, b :: !Int }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment