Skip to content

Commit

Permalink
Update to the latest libui version
Browse files Browse the repository at this point in the history
  • Loading branch information
yamadapc committed Jan 27, 2017
1 parent 75d5773 commit 4d1fad2
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 161 deletions.
1 change: 0 additions & 1 deletion apps/gists/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,5 @@ main = do

wn <- makeWindow gistsC fileMenu

uiWindowCenter wn
uiShow wn
uiMain
1 change: 0 additions & 1 deletion apps/markd/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,5 @@ main = do

wn <- makeWindow fileMenu

uiWindowCenter wn
uiShow wn
uiMain
5 changes: 0 additions & 5 deletions examples/AsciiProgress.hs

This file was deleted.

21 changes: 0 additions & 21 deletions examples/ButtonExample.hs

This file was deleted.

59 changes: 2 additions & 57 deletions examples/ReactiveBananaClickToResize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,51 +32,20 @@ clickSource c = liftIO $ do
c `onClick` fire esclick c
return esclick

positionSource w = liftIO $ do
esposition <- newAddHandler
w `onPositionChanged` do
p <- getPosition w
fire esposition p
return (addHandler esposition)

positionIntervalSource :: CUIWindow -> MomentIO (Event (Int, Int))
positionIntervalSource w = do
esposition <- liftIO $ do
esposition <- newAddHandler
let loop p = do
p' <- getPosition w
when (p /= p') $
fire esposition p'
threadDelay (1000 * 10)
loop p'
forkIO $ loop (0, 0)
return esposition
fromAddHandler (addHandler esposition) -- >>= changes

main :: IO ()
main = do
escounter <- newAddHandler

runUILoop $ mdo
(wnd, counter) <- window' def { uiWindowTitle = "Click to resize"
(wnd, _) <- window' def { uiWindowTitle = "Click to resize"
, uiWindowWidth = 200
, uiWindowHeight = 100
, uiWindowChild = vbox $ mdo
time <- label "Window position"
counter <- label ""
btn <- counterButton def
return counter
return ()
}
wrap wnd

liftIO $ forkIO $ do
threadDelay (1000 * 1000 * 3)
uiQueueMain $ uiWindowCenter wnd
network <- compile $ do
epositionInterval <- positionIntervalSource wnd
reactimate $ showText counter <$> epositionInterval
actuate network

return ()

-- newtype AddHandler = AddHandler { register :: Handler a -> IO (IO ()) }
Expand All @@ -88,27 +57,3 @@ addHandler = fst

fire :: EventSource a -> a -> IO ()
fire = snd

-- setupNetwork escounter (wnd, btn, counter, time) = compile $ do
-- ecounter <- fromAddHandler (addHandler escounter)
-- ecount <- accumE 0 $ (+1) <$ ecounter
-- reactimate $ fmap updateUI ecount
-- where
-- updateUI currentCount = do
-- currentTime <- getCurrentTime
-- wnd `setContentSize` (800, 800)
-- time `setText` ("Simple UI at " ++ show currentTime)
-- counter `setText` show currentCount
-- btn `setText` ("Should be simple " ++ show currentCount)

-- dummyIntervalSource :: CUIWindow -> MomentIO (Event (Future (Int, Int)))
-- dummyIntervalSource _ = do
-- esposition <- liftIO $ do
-- esposition <- newAddHandler
-- let loop = do
-- fire esposition (0, 0)
-- threadDelay (1000 * 10)
-- loop
-- forkIO loop
-- return esposition
-- fromChanges (0, 0) (addHandler esposition) >>= changes
1 change: 0 additions & 1 deletion examples/SimpleControlGallery.hs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ main = do
tabs `appendTabMargined` ("Data Choosers", dataChoosersTab)

uiShow wn
-- uiWindowCenter wn

uiMainSteps
whileM_ getHasMain $ do
Expand Down
4 changes: 0 additions & 4 deletions examples/SimpleCounter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ main = do

uiShow wn

-- forkIO $ do
-- threadDelay (1000 * 1000)
-- uiWindowCenter wn

uiMainSteps
whileM_ getHasMain $ do
h <- uiMainStep 0
Expand Down
4 changes: 0 additions & 4 deletions examples/SimpleMapview.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ main = do
wn `setChild` mapview
putStrLn "[haskell] Map appended"

-- c_uiMapviewSetRegion mapview

uiWindowCenter wn

putStrLn "[haskell] Displaying GUI..."
wn `onClosing` uiQuit
uiOnShouldQuit (uiQuit >> return 0)
Expand Down
2 changes: 0 additions & 2 deletions examples/SimpleWebview.hs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ main = do

wn `onClosing` uiQuit

uiWindowCenter wn

uiOnShouldQuit (uiQuit >> return 0)
uiShow wn
uiMain
40 changes: 1 addition & 39 deletions libui.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ library
./vendor/libui/darwin/util.m
./vendor/libui/darwin/webview.m
./vendor/libui/darwin/window.m
./vendor/libui/darwin/winmoveresize.m
build-depends: async
, base >=4.8 && <5
, c-storable-deriving
Expand Down Expand Up @@ -178,25 +179,6 @@ library
default-language: Haskell2010
ghc-options: -threaded

executable button-example
main-is: ButtonExample.hs
hs-source-dirs:
examples
build-depends: async
, base
, c-storable-deriving
, data-default
, free
, libui
, monad-loops
, mtl
, reactive-banana
, template-haskell
, time
, transformers
default-language: Haskell2010
ghc-options: -threaded

executable libui-simple-progressbar-example
main-is: SimpleProgressBar.lhs
hs-source-dirs:
Expand Down Expand Up @@ -357,26 +339,6 @@ executable libui-reactive-banana-click-to-resize
default-language: Haskell2010
ghc-options: -threaded

executable libui-ascii-progress
main-is: AsciiProgress.hs
hs-source-dirs:
examples
build-depends: ascii-progress
, async
, base
, c-storable-deriving
, data-default
, free
, libui
, monad-loops
, mtl
, reactive-banana
, template-haskell
, time
, transformers
default-language: Haskell2010
ghc-options: -threaded

test-suite hspec
main-is: Spec.hs
type: exitcode-stdio-1.0
Expand Down
26 changes: 0 additions & 26 deletions src/Graphics/LibUI/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -245,32 +245,6 @@ form cs = UI $ do
return (c, [toCUIControl c])
formItem x e = (x, e)

stuff :: IO ()
stuff = runUILoop ui
where
ui :: UI ()
ui = do
menu "File" [ "Open"
, "Save"
, UIMenuItemQuit
]
void $ window "libui Control Gallery" 640 300 True $
void $ tabs $ do
tab "Basic Controls" $ do
hbox $
-- button "Button"
checkbox "Checkbox"
label "This is a label. Right now, labels can only span one line."
void $ group "Entries" $
form [ formItem "Entry" (entry "")
, formItem "Entry" (entry "")
, formItem "Search Entry" (searchEntry "")
]
tab "Basic Controls" $ hbox $ do
void $ group "Numbers" (return ())
void $ group "Lists" (return ())
tab "Data Choosers" mempty

-- ** Windows
instance {-# OVERLAPS #-} ToCUIControlIO' [CUIControl] CUIBox where
toCUIIO cs = do
Expand Down

0 comments on commit 4d1fad2

Please sign in to comment.