Skip to content

ibaryshnikov/iced-hs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iced-hs

Haskell wrapper for iced gui library. Very experimental, check Roadmap to see progress.

Note: temporarily switched to a fork to provide access to KeyCode from winit. Currently iced provides only logical key, check this pr for more details. Eventually physical key will be added back to iced. When that happens, the iced dependency will be changed back to the original crate. Also, was using latest upstream to get unreleased styles api. Will use the version from crates.io when all the necessary changes are published.

Platform support

Desktop - Windows, macOS, Linux. Supported targets are the same as for iced except the web target, since it's tricky to link wasm produced by different compilers. With some effort it may be possible, just not out of the box.

Example

Check examples for more

import Iced
import Iced.Attribute
import Iced.Attribute.Alignment
import Iced.Theme
import Iced.Widget

data Message = Inc | Dec

update :: Int -> Message -> Int
update value Inc = value + 1
update value Dec = value - 1

view :: Int -> Element
view value =
  container [centerX Fill, centerY Fill] $
  column [alignItems Center, spacing 10] [
    button [onPress Inc] "Increment",
    text [size 50] $ show value,
    button [onPress Dec] "Decrement"
  ]

main :: IO ()
main = Iced.run [theme GruvboxLight] "Counter" 0 update view

Counter preview

Preview

From themes example:

Themes preview

Usage

First, build rust crate to produce libiced_hs.a

./build_rust.sh

then pass it to ghc

ghc -ipath/to/this/repo path/to/libiced_hs.a main.hs

Internals

Credits

Below is a list of inspiring projects

Status

This is a research project. The api may change often. Not recommended for use in production. It still may be a good option if you need a simple way to build some ui.

Roadmap

  • Widgets
    • button
    • checkbox
    • column
    • comboBox
    • container
    • image
    • keyedColumn
    • mouseArea
    • paneGrid
    • progressBar
    • pickList
    • qrCode
    • radio
    • responsive
    • horizontalRule, verticalRule
    • row
    • scrollable
    • slider, verticalSlider
    • horizontalSpace, verticalSpace
    • svg
    • text
    • textEditor
    • textInput
    • toggler
    • tooltip
  • Helper functions
    • lazy
    • themer
    • focusNext, focusPrevious
  • Themes
  • Canvas api
    • canvas widget
    • fill path
    • stroke path
    • path methods - circle, lineTo, moveTo, rectangle
    • more path methods
  • Shader
    • shader widget
    • attributes
  • Multi window
  • Custom widgets
  • Subscriptions
    • subscription attribute for Application
    • Time.every subscription
    • Keyboard
      • onKeyPress
      • onKeyRelease
      • PhysicalKey
        • KeyCode
        • NativeKeyCode
      • LogicalKey
        • Named
        • Character
    • custom subscriptions
    • other events
  • Command api
    • Command.perform for Rust Future
    • Command.performBlocking for blocking tasks
  • Add all attributes from iced for each widget
  • Styles for widgets
    • button
    • checkobx
    • container
    • pickList
    • progressBar
    • radio
    • text
    • textInput
    • textEditor
    • ...

About

Haskell wrapper for iced

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published