basic gui working... somehow (no painting yet)

This commit is contained in:
tpajenka
2014-04-03 20:05:49 +02:00
parent 2de621d73f
commit 1898758eb5
2 changed files with 364 additions and 24 deletions

View File

@ -9,14 +9,37 @@ import UI.UITypes
data Pixel = Pixel Int Int
getGUI :: [GUIAny]
getGUI = (GUIAny $ GUIContainer 0 0 120 80 [] 1):(GUIAny $ GUIContainer 50 60 300 700 [(GUIAny $ GUIContainer 55 65 200 400 [] 5)] 1):[]
getGUI = [ toGUIAny $ GUIContainer 0 0 120 80 [] 1
, toGUIAny $ GUIPanel $ GUIContainer 0 0 0 0
[toGUIAny $ GUIContainer 0 80 100 200 [] 4
,GUIAnyB (GUIButton 50 400 200 175 2 (testMessage) defaultUIState)
] 3
]
testMessage :: (Show w) => w -> ScreenUnit -> ScreenUnit -> IO w
testMessage w x y = do
putStrLn ("\tclick on " ++ show x ++ "," ++ show y)
return w
-- | Handler for UI-Inputs.
-- Indicates a primary click on something (e.g. left-click, touch on Touchpad, fire on Gamepad, ...
clickHandler :: Pixel -> Pioneers ()
clickHandler (Pixel x y) = case concat $ map (isInside x y) getGUI of
clickHandler (Pixel x y) = case concatMap (isInside x y) getGUI of
[] -> liftIO $ putStrLn $ unwords ["button press on (",show x,",",show y,")"]
hit -> liftIO $ putStrLn $ unwords $ foldl (++) ["hitting"] ([map (\w -> (show.getBoundary) w ++ ' ':(show.getPriority) w) hit])
hit -> liftIO $ do
_ <- sequence $ map (\w ->
case w of
(GUIAnyB b) -> do
putStrLn $ "hitting " ++ getShorthand w ++ ": " ++ show (getBoundary w) ++ " " ++ show (getPriority w)
++ " at ["++show x++","++show y++"]"
(b', _) <- onMousePressed x y b b
_ <- onMouseReleased x y b' b'
return ()
_ -> putStrLn $ "hitting " ++ getShorthand w ++ ": " ++ show (getBoundary w) ++ " " ++ show (getPriority w)
++ " at ["++show x++","++show y++"]"
) hit
return ()
-- | Handler for UI-Inputs.
-- Indicates an alternate click on something (e.g. right-click, touch&hold on Touchpad, ...