mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-12-29 08:55:13 +03:00
MouseDemo: move clickedExtent into Brick.Main
This commit is contained in:
parent
9154522509
commit
afe2e7eec5
@ -76,7 +76,7 @@ appEvent st ev = do
|
||||
-- If the mouse button was down in the layer and
|
||||
-- we were not already dragging it, start dragging
|
||||
-- the layer.
|
||||
| clickedExtent (c, r) e -> st & lastDragLoc .~ LastLocation mouseLoc True
|
||||
| M.clickedExtent (c, r) e -> st & lastDragLoc .~ LastLocation mouseLoc True
|
||||
-- If the mouse button was down outside the layer,
|
||||
-- start dragging outside the layer.
|
||||
| otherwise -> st & lastDragLoc .~ LastLocation mouseLoc False
|
||||
@ -90,11 +90,6 @@ appEvent st ev = do
|
||||
& draggableLayerLocation %~ if bound then (<> off) else id
|
||||
_ -> st
|
||||
|
||||
clickedExtent :: (Int, Int) -> T.Extent n -> Bool
|
||||
clickedExtent (c, r) (T.Extent _ (T.Location (lc, lr)) (w, h)) =
|
||||
c >= lc && c < (lc + w) &&
|
||||
r >= lr && r < (lr + h)
|
||||
|
||||
aMap :: AttrMap
|
||||
aMap = attrMap V.defAttr
|
||||
[ ("info", V.white `on` V.magenta)
|
||||
|
@ -11,6 +11,7 @@ module Brick.Main
|
||||
, suspendAndResume
|
||||
, lookupViewport
|
||||
, lookupExtent
|
||||
, clickedExtent
|
||||
, getVtyHandle
|
||||
|
||||
-- ** Viewport scrolling
|
||||
@ -272,6 +273,13 @@ applyInvalidations ns cache = foldr (.) id (mkFunc <$> ns) cache
|
||||
lookupViewport :: (Ord n) => n -> EventM n (Maybe Viewport)
|
||||
lookupViewport n = EventM $ asks (M.lookup n . eventViewportMap)
|
||||
|
||||
-- | Did the specified mouse coordinates (column, row) intersect the
|
||||
-- specified extent?
|
||||
clickedExtent :: (Int, Int) -> Extent n -> Bool
|
||||
clickedExtent (c, r) (Extent _ (Location (lc, lr)) (w, h)) =
|
||||
c >= lc && c < (lc + w) &&
|
||||
r >= lr && r < (lr + h)
|
||||
|
||||
-- | Given a name, get the most recent rendering extent for the name (if
|
||||
-- any).
|
||||
lookupExtent :: (Eq n) => n -> EventM n (Maybe (Extent n))
|
||||
|
Loading…
Reference in New Issue
Block a user