Merge branch 'ui' into tessallation

This commit is contained in:
Stefan Dresselhaus
2014-04-05 22:03:47 +02:00
2 changed files with 333 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
,toGUIAny $GUIButton 50 400 200 175 2 defaultUIState testMessage
] 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 h) -> do
putStrLn $ "hitting " ++ getShorthand w ++ ": " ++ show (getBoundary w) ++ " " ++ show (getPriority w)
++ " at ["++show x++","++show y++"]"
(b', h') <- onMousePressed x y b h
_ <- onMouseReleased x y b' h'
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, ...