Permalink
Browse files

redid button positioning

base >= 4
  • Loading branch information...
1 parent a9a8ded commit b7f6245171703635f236efdddda37165ca5fab66 Nik Nyby committed Feb 22, 2011
Showing with 25 additions and 27 deletions.
  1. +24 −23 Menu.hs
  2. +0 −1 Mma.hs
  3. +0 −2 Render.hs
  4. +1 −1 mma.cabal
View
47 Menu.hs
@@ -9,7 +9,6 @@ module Menu (
windowInc,
windowDec,
) where
-import Graphics.UI.GLUT
import Rectangle
import Util
@@ -38,53 +37,55 @@ data MmaMenu = MmaMenu
initialMenu :: MmaMenu
initialMenu = MmaMenu {
- playButton = MmaButton (Rectangle (m!!0) 105 140 60) False,
+ playButton = MmaButton (Rectangle (x!!0) (y!!1) longWidth height) False,
- sprtWindow = MmaWindow (Rectangle (m!!1) 105 140 60) [] (-1),
- nextSprtButton = MmaButton (Rectangle (m!!2) 105 60 60) False,
- prevSprtButton = MmaButton (Rectangle ((m!!2)+70) 105 60 60) False,
+ sprtWindow = MmaWindow (Rectangle (x!!1) (y!!1) longWidth height) [] (-1),
+ nextSprtButton = MmaButton (Rectangle (x!!2) 120 shortWidth shortHeight) False,
+ prevSprtButton = MmaButton (Rectangle (x!!2) 90 shortWidth shortHeight) False,
- bgWindow = MmaWindow (Rectangle (m!!0) 35 140 60) [] (-1),
- nextBgButton = MmaButton (Rectangle (m!!1) 35 60 60) False,
- prevBgButton = MmaButton (Rectangle ((m!!1)+70) 35 60 60) False,
+ saveButton = MmaButton (Rectangle (x!!0) (y!!0) longWidth height) False,
- frameWindow = MmaWindow (Rectangle (m!!2) 35 140 60) [] (-1),
- nextFrameButton = MmaButton (Rectangle (m!!3) 35 60 60) False,
- prevFrameButton = MmaButton (Rectangle ((m!!3)+70) 35 60 60) False,
- saveButton = MmaButton (Rectangle (m!!3) 105 140 60) False
+ bgWindow = MmaWindow (Rectangle (x!!1) (y!!0) longWidth height) [] (-1),
+ nextBgButton = MmaButton (Rectangle (x!!2) 50 shortWidth shortHeight) False,
+ prevBgButton = MmaButton (Rectangle (x!!2) 20 shortWidth shortHeight) False,
+
+ frameWindow = MmaWindow (Rectangle (x!!3) (y!!0) longWidth height) [] (-1),
+ nextFrameButton = MmaButton (Rectangle (x!!4) 50 shortWidth shortHeight) False,
+ prevFrameButton = MmaButton (Rectangle (x!!4) 20 shortWidth shortHeight) False
}
where
- m = mkMenu 640 140 15
+ -- button grid
+ x = [70, 215, 325, 435, 545]
+ y = [40, 100]
+ longWidth = 100
+ shortWidth = 50
+ height = 50
+ shortHeight = 20
buttonMap :: (MmaButton -> MmaButton) -> MmaMenu -> MmaMenu
buttonMap f m = m {
playButton = f $ playButton m,
nextSprtButton = f $ nextSprtButton m,
prevSprtButton = f $ prevSprtButton m,
+ saveButton = f $ saveButton m,
nextBgButton = f $ nextBgButton m,
prevBgButton = f $ prevBgButton m,
nextFrameButton = f $ nextFrameButton m,
- prevFrameButton = f $ prevFrameButton m,
- saveButton = f $ saveButton m
+ prevFrameButton = f $ prevFrameButton m
}
menuButtons :: MmaMenu -> [MmaButton]
menuButtons m = [
playButton m,
nextSprtButton m,
prevSprtButton m,
+ saveButton m,
nextBgButton m,
prevBgButton m,
nextFrameButton m,
- prevFrameButton m,
- saveButton m
+ prevFrameButton m
]
--- A list of button x-positions that fit in a window of width wwd. bwd is
--- button width, and sp is space between buttons.
-mkMenu :: GLdouble -> GLdouble -> GLdouble -> [GLdouble]
-mkMenu wwd bwd sp = [sp, (sp*2)+bwd .. wwd]
-
data MmaButton = MmaButton
{
buttonRect :: Rectangle,
@@ -116,4 +117,4 @@ windowInc w = if windowState w >= length (windowTextures w) - 1
windowDec w = if windowState w <= 0
then w { windowState = length (windowTextures w) - 1 }
- else w { windowState = (windowState w) - 1 }
+ else w { windowState = (windowState w) - 1 }
View
1 Mma.hs
@@ -52,7 +52,6 @@ main = do
trans pos >>= moveCursor >> postRedisplay Nothing)
mainLoop
- -- TODO: stop using all the CPU, silly!
idle :: IORef Env -> IO ()
idle env = do
View
2 Render.hs
@@ -42,10 +42,8 @@ drawSprite s = do
currentColor $= Color4 0.2 0 0.3 0
renderPrimitive Quads $ mapM_ vertex $ spritePoints s
--- TODO: is there a better way????
drawMenu :: MmaMenu -> MmaTextures -> IO ()
drawMenu m t = do
- --drawTexture 0 0 (menuTexture t) 1
drawButton (playButton m) (playButtonTexture t)
drawButton (saveButton m) (saveButtonTexture t)
drawButton (nextSprtButton m) (nextSprtButtonTexture t)
View
2 mma.cabal
@@ -11,4 +11,4 @@ Data-Files: data/*.png
Executable mma
Ghc-Options: -Wall -O2
Main-is: Mma.hs
- Build-Depends: base >= 3, GLUT, SDL, SDL-image
+ Build-Depends: base >= 4, GLUT, SDL, SDL-image

0 comments on commit b7f6245

Please sign in to comment.