1 {-# LANGUAGE FlexibleContexts, MultiParamTypeClasses #-}
3 module RMCA.GUI.MultiBoard where
7 import Data.ReactiveValue
9 import Graphics.UI.Gtk.Board.BoardLink
10 import Graphics.UI.Gtk.Layout.BackgroundContainer
13 import RMCA.GUI.NoteSettings
14 import RMCA.Layer.Layer
17 -- In GTk, a “thing with tabs” has the I think very confusing name
20 createNotebook :: ( ReactiveValueRead addLayer () IO
21 , ReactiveValueRead rmLayer () IO
22 , ReactiveValueRead layer Layer IO
23 , ReactiveValueRead tempo Tempo IO
24 ) => addLayer -> rmLayer -> layer -> tempo
27 , ReactiveFieldRead IO Board
28 , Array Pos (ReactiveFieldWrite IO GUICell)
29 , ReactiveFieldWrite IO [PlayHead]
31 createNotebook addLayerRV rmLayerRV layerRV tempoRV = do
33 --plusImg <- imageNewFromStock gtkMediaAdd IconSizeButton
34 --notebookAppendPageMenu n undefined plusImg undefined
35 ------------------------------------------------------------------------------
37 ------------------------------------------------------------------------------
38 boardCont <- backgroundContainerNew
39 guiBoard <- attachGameRules =<< initGame
40 centerBoard <- alignmentNew 0.5 0.5 0 0
41 containerAdd centerBoard guiBoard
42 containerAdd boardCont centerBoard
44 notebookPrependPage n boardCont "Lol first"
45 notebookPageNumber <- newCBMVarRW 1
47 layer <- reactiveValueRead layerRV
48 tempo <- reactiveValueRead tempoRV
49 (boardRV, pieceArrRV, phRV) <- initBoardRV guiBoard
51 pieceBox <- clickHandling pieceArrRV guiBoard =<< vBoxNew False 10
53 ------------------------------------------------------------------------------
55 ------------------------------------------------------------------------------
57 reactiveValueOnCanRead addLayerRV $ postGUIAsync $ do
58 reactiveValueRead notebookPageNumber
59 >>= reactiveValueWrite notebookPageNumber . (+1)
60 boardCont <- backgroundContainerNew
62 guiBoard <- attachGameRules =<< initGame
63 centerBoard <- alignmentNew 0.5 0.5 0 0
64 containerAdd centerBoard guiBoard
65 containerAdd boardCont centerBoard
67 notebookAppendPage n boardCont "sdlkfhd" >> widgetShowAll n
69 reactiveValueOnCanRead rmLayerRV $ postGUIAsync $ do
70 np <- reactiveValueRead notebookPageNumber
72 notebookRemovePage n =<< notebookGetCurrentPage n
74 reactiveValueRead notebookPageNumber
75 >>= reactiveValueWrite notebookPageNumber . (subtract 1)
81 ------------------------------------------------------------------------------
83 ------------------------------------------------------------------------------
84 return (n, pieceBox, boardRV, pieceArrRV, phRV)