mirror of
https://github.com/rgleichman/glance.git
synced 2024-09-11 06:55:42 +03:00
Move findElementsByPosition
This commit is contained in:
parent
f58cebe4cd
commit
9fd3203c10
26
gui/Main.hs
26
gui/Main.hs
@ -125,6 +125,19 @@ updateBackground _canvas state = do
|
||||
setSourceRGB 1 0 0
|
||||
traverse drawNode (_asElements stateVal)
|
||||
|
||||
findElementByPosition :: IntMap.IntMap Element -> (Double, Double) -> Maybe (Int)
|
||||
findElementByPosition elements (mouseX, mouseY) =
|
||||
let
|
||||
mouseInElement (_elementId, Element{_elPosition, _elSize}) =
|
||||
let
|
||||
(x, y) = _elPosition
|
||||
(width, height) = _elSize
|
||||
in
|
||||
mouseX >= x && mouseX <= (x + width) &&
|
||||
mouseY >= y && mouseY <= (y + height)
|
||||
in
|
||||
fst <$> find mouseInElement (IntMap.toList elements)
|
||||
|
||||
startApp :: Gtk.Application -> IO ()
|
||||
startApp app = do
|
||||
state <- newIORef emptyAppState
|
||||
@ -251,19 +264,6 @@ startApp app = do
|
||||
#showAll window
|
||||
pure ()
|
||||
|
||||
findElementByPosition :: IntMap.IntMap Element -> (Double, Double) -> Maybe (Int)
|
||||
findElementByPosition elements (mouseX, mouseY) =
|
||||
let
|
||||
mouseInElement (_elementId, Element{_elPosition, _elSize}) =
|
||||
let
|
||||
(x, y) = _elPosition
|
||||
(width, height) = _elSize
|
||||
in
|
||||
mouseX >= x && mouseX <= (x + width) &&
|
||||
mouseY >= y && mouseY <= (y + height)
|
||||
in
|
||||
fst <$> find mouseInElement (IntMap.toList elements)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
app <- new Gtk.Application []
|
||||
|
Loading…
Reference in New Issue
Block a user