GithubHelp home page GithubHelp logo

diogenesmota / haskell-libui Goto Github PK

View Code? Open in Web Editor NEW

This project forked from beijaflor-io/haskell-libui

0.0 2.0 0.0 4.94 MB

Haskell bindings to the libui C library.

License: GNU General Public License v3.0

Makefile 1.34% Haskell 95.83% Objective-C 1.67% Emacs Lisp 0.61% Shell 0.55%

haskell-libui's Introduction

haskell-libui

GPLv3


Haskell bindings to the libui C library.

The library is currently only an FFI wrapper.

Useful top-level modules are:

  • Graphics.LibUI
  • Graphics.LibUI.OSX

They export general and OSX specific functionality in raw C and "wrapped" Haskell APIs.

Important

This package needs some splitting and cleaning-up, as well as some more work, but the bits exposed by Graphics.LibUI.FFI (Graphics.LibUI.FFI.Wrapped, Graphics.LibUI.FFI.Raw & OSX variants) should be ok to use.

They aren't used in anything serious right now. You'd be courageous to do it.

Usage

import Graphics.LibUI
main = do
    uiInit
    wn <- uiNewWindow "Haskell on GUIs" 220 100 True
    btn <- uiNewButton "Click me"
    wn `setChild` btn
    wn `setMargined` True
    uiShow wn
    uiWindowCenter wn
    uiMain

You can run this example with:

git clone https://github.com/beijaflor-io/haskell-libui
cd haskell-libui
make READMEExample
./READMEExample

Examples

There're several examples on the examples directory. The Simple... examples only use the Graphics.LibUI.FFI part of the library and are what you want to look.at first.

apps/markd is an example application (currently only working on OSX), which previews how a file is rendered by pandoc.


Roadmap

  • Raw FFI available in Graphics.LibUI.FFI.Raw
    • All functions from the FFI mirror their libui names prefixed with c_
    • Document the FFI
  • Haskell callback based API in Graphics.LibUI.FFI.Wrapped
    • Data-wrappers for uiControl type
    • Callback based API
  • Higher-level API on examples and Graphics.LibUI.Types and Graphics.LibUI.MonadUI
    • Building concrete representations of UI controls based on declarative code
    • Currently in the examples Wrap the callback based code under an FRP layer
    • Library consistency
      • Containers return their concrete representation and their children's return value
      • MonadUI shouldn't wrap IO actions, but abstract commands:
        • data UI = UI [UIControl]
        • class MonadUI m b where runUI :: UI -> m b
        • instance MonadUI IO CUIControl where runUI = toCUIControlIO

The aim of Graphics.LibUI.Types and friends is to end-up with code that looks like:

runUILoop 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

Tested on OSX and Ubuntu 14.04. A Vagrantfile is available.

License

This code is published under the GPLv3 license

haskell-libui's People

Contributors

yamadapc avatar

Watchers

James Cloos avatar Diogenes Mota avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.