diff --git a/README.md b/README.md
index 200b9222..9984736d 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,31 @@
-# Monomer
+
Monomer
+
+A cross-platform GUI library for Haskell
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
An easy to use, cross platform, GUI library for writing native Haskell
applications.
-It provides a framework similar to the Elm Architecture, allowing the creation
+Monomer provides a framework similar to the Elm Architecture, allowing the creation
of GUIs using an extensible set of widgets with pure Haskell.
-## Screenshot
-
-![Project's screenshot](assets/images/monomer-readme.png)
-
## Objectives
- Be easy to learn and use.
@@ -77,11 +93,6 @@ PRs are welcome!
If possible, keep them small and focused. If you are planning on making a large
change, please submit an issue first so we can agree on a solution.
-## Questions?
-
-If you are not sure how something works or you have a usage question, feel free
-to open an issue!
-
## License
This library is licensed under the [BSD-3 license](LICENSE).
diff --git a/assets/images/icon.bmp b/assets/images/icon.bmp
deleted file mode 100644
index a97250e7..00000000
Binary files a/assets/images/icon.bmp and /dev/null differ
diff --git a/assets/images/icon.png b/assets/images/icon.png
new file mode 100644
index 00000000..3d779c46
Binary files /dev/null and b/assets/images/icon.png differ
diff --git a/assets/images/monomer-logo.svg b/assets/images/monomer-logo.svg
new file mode 100644
index 00000000..3a52cd08
--- /dev/null
+++ b/assets/images/monomer-logo.svg
@@ -0,0 +1,13 @@
+
+
+
diff --git a/assets/images/monomer-readme.png b/assets/images/monomer-readme.png
deleted file mode 100644
index 46378b3a..00000000
Binary files a/assets/images/monomer-readme.png and /dev/null differ
diff --git a/examples/books/Main.hs b/examples/books/Main.hs
index 9bd4cdee..a0e354a8 100644
--- a/examples/books/Main.hs
+++ b/examples/books/Main.hs
@@ -190,7 +190,7 @@ main = do
where
config = [
appWindowTitle "Book search",
- appWindowIcon "./assets/images/icon.bmp",
+ appWindowIcon "./assets/images/icon.png",
appTheme customDarkTheme,
appFontDef "Regular" "./assets/fonts/Roboto-Regular.ttf",
appFontDef "Medium" "./assets/fonts/Roboto-Medium.ttf",
diff --git a/examples/generative/Main.hs b/examples/generative/Main.hs
index d29e5ba3..898de9a0 100644
--- a/examples/generative/Main.hs
+++ b/examples/generative/Main.hs
@@ -112,7 +112,7 @@ main = do
model = GenerativeModel CirclesGrid False def def
config = [
appWindowTitle "Generative",
- appWindowIcon "./assets/images/icon.bmp",
+ appWindowIcon "./assets/images/icon.png",
appTheme darkTheme,
appFontDef "Remix" "./assets/fonts/remixicon.ttf",
appFontDef "Regular" "./assets/fonts/Roboto-Regular.ttf",
diff --git a/examples/opengl/Main.hs b/examples/opengl/Main.hs
index 59441846..e3b4aac8 100644
--- a/examples/opengl/Main.hs
+++ b/examples/opengl/Main.hs
@@ -94,7 +94,7 @@ main = do
where
config = [
appWindowTitle "OpenGL",
- appWindowIcon "./assets/images/icon.bmp",
+ appWindowIcon "./assets/images/icon.png",
appTheme darkTheme,
appFontDef "Regular" "./assets/fonts/Roboto-Regular.ttf",
appInitEvent AppInit
diff --git a/examples/ticker/Main.hs b/examples/ticker/Main.hs
index 16c2a1e8..507f09cc 100644
--- a/examples/ticker/Main.hs
+++ b/examples/ticker/Main.hs
@@ -243,7 +243,7 @@ main = do
where
config = [
appWindowTitle "Ticker",
- appWindowIcon "./assets/images/icon.bmp",
+ appWindowIcon "./assets/images/icon.png",
appTheme customDarkTheme,
appFontDef "Regular" "./assets/fonts/Roboto-Regular.ttf",
appFontDef "Remix" "./assets/fonts/remixicon.ttf",
diff --git a/examples/todo/Main.hs b/examples/todo/Main.hs
index bfd03db3..fb328b8a 100644
--- a/examples/todo/Main.hs
+++ b/examples/todo/Main.hs
@@ -245,7 +245,7 @@ main = do
where
config = [
appWindowTitle "Todo list",
- appWindowIcon "./assets/images/icon.bmp",
+ appWindowIcon "./assets/images/icon.png",
appTheme customDarkTheme,
appFontDef "Regular" "./assets/fonts/Roboto-Regular.ttf",
appFontDef "Medium" "./assets/fonts/Roboto-Medium.ttf",
diff --git a/examples/tutorial/Tutorial01_Basics.hs b/examples/tutorial/Tutorial01_Basics.hs
index 6574eeed..1694f0b7 100644
--- a/examples/tutorial/Tutorial01_Basics.hs
+++ b/examples/tutorial/Tutorial01_Basics.hs
@@ -62,7 +62,7 @@ main01 = do
where
config = [
appWindowTitle "Tutorial 01 - Basics",
- appWindowIcon "./assets/images/icon.bmp",
+ appWindowIcon "./assets/images/icon.png",
appTheme darkTheme,
appFontDef "Regular" "./assets/fonts/Roboto-Regular.ttf",
appInitEvent AppInit
diff --git a/examples/tutorial/Tutorial02_Styling.hs b/examples/tutorial/Tutorial02_Styling.hs
index d73dd1b0..55408d13 100644
--- a/examples/tutorial/Tutorial02_Styling.hs
+++ b/examples/tutorial/Tutorial02_Styling.hs
@@ -106,7 +106,7 @@ main02 = do
where
config = [
appWindowTitle "Tutorial 02 - Styling",
- appWindowIcon "./assets/images/icon.bmp",
+ appWindowIcon "./assets/images/icon.png",
appTheme darkTheme,
appFontDef "Regular" "./assets/fonts/Roboto-Regular.ttf",
appFontDef "Medium" "./assets/fonts/Roboto-Medium.ttf",
diff --git a/examples/tutorial/Tutorial03_LifeCycle.hs b/examples/tutorial/Tutorial03_LifeCycle.hs
index 31d1cf72..108a58dd 100644
--- a/examples/tutorial/Tutorial03_LifeCycle.hs
+++ b/examples/tutorial/Tutorial03_LifeCycle.hs
@@ -102,7 +102,7 @@ main03 = do
where
config = [
appWindowTitle "Tutorial 03 - Merging",
- appWindowIcon "./assets/images/icon.bmp",
+ appWindowIcon "./assets/images/icon.png",
appTheme darkTheme,
appFontDef "Regular" "./assets/fonts/Roboto-Regular.ttf",
appInitEvent AppInit
diff --git a/examples/tutorial/Tutorial04_Tasks.hs b/examples/tutorial/Tutorial04_Tasks.hs
index 5550442b..b1ef2060 100644
--- a/examples/tutorial/Tutorial04_Tasks.hs
+++ b/examples/tutorial/Tutorial04_Tasks.hs
@@ -87,7 +87,7 @@ main04 = do
where
config = [
appWindowTitle "Tutorial 04 - Tasks",
- appWindowIcon "./assets/images/icon.bmp",
+ appWindowIcon "./assets/images/icon.png",
appTheme darkTheme,
appFontDef "Regular" "./assets/fonts/Roboto-Regular.ttf",
appFontDef "Bold" "./assets/fonts/Roboto-Bold.ttf"
diff --git a/examples/tutorial/Tutorial05_Producers.hs b/examples/tutorial/Tutorial05_Producers.hs
index 2bdb044a..cabeb009 100644
--- a/examples/tutorial/Tutorial05_Producers.hs
+++ b/examples/tutorial/Tutorial05_Producers.hs
@@ -80,7 +80,7 @@ main05 = do
where
config = [
appWindowTitle "Tutorial 05 - Producers",
- appWindowIcon "./assets/images/icon.bmp",
+ appWindowIcon "./assets/images/icon.png",
appTheme darkTheme,
appFontDef "Regular" "./assets/fonts/Roboto-Regular.ttf",
appFontDef "Bold" "./assets/fonts/Roboto-Bold.ttf",
diff --git a/examples/tutorial/Tutorial06_Composite.hs b/examples/tutorial/Tutorial06_Composite.hs
index 97c7c8d9..6322bb7b 100644
--- a/examples/tutorial/Tutorial06_Composite.hs
+++ b/examples/tutorial/Tutorial06_Composite.hs
@@ -150,7 +150,7 @@ main06 = do
where
config = [
appWindowTitle "Tutorial 06 - Composite",
- appWindowIcon "./assets/images/icon.bmp",
+ appWindowIcon "./assets/images/icon.png",
appTheme darkTheme,
appFontDef "Regular" "./assets/fonts/Roboto-Regular.ttf",
appInitEvent AppInit
diff --git a/examples/tutorial/Tutorial07_CustomWidget.hs b/examples/tutorial/Tutorial07_CustomWidget.hs
index 9868ce6b..856fdbda 100644
--- a/examples/tutorial/Tutorial07_CustomWidget.hs
+++ b/examples/tutorial/Tutorial07_CustomWidget.hs
@@ -168,7 +168,7 @@ main07 = do
where
config = [
appWindowTitle "Tutorial 07 - Custom Widget",
- appWindowIcon "./assets/images/icon.bmp",
+ appWindowIcon "./assets/images/icon.png",
appTheme darkTheme,
appFontDef "Regular" "./assets/fonts/Roboto-Regular.ttf"
]
diff --git a/examples/tutorial/Tutorial08_Themes.hs b/examples/tutorial/Tutorial08_Themes.hs
index f0843f97..bdb6fbcb 100644
--- a/examples/tutorial/Tutorial08_Themes.hs
+++ b/examples/tutorial/Tutorial08_Themes.hs
@@ -115,7 +115,7 @@ main08 = do
where
config = [
appWindowTitle "Tutorial 08 - Themes",
- appWindowIcon "./assets/images/icon.bmp",
+ appWindowIcon "./assets/images/icon.png",
appTheme darkTheme,
appFontDef "Regular" "./assets/fonts/Roboto-Regular.ttf",
appInitEvent AppInit
diff --git a/src/Monomer/Main/Platform.hs b/src/Monomer/Main/Platform.hs
index 4c695aa9..cc6bd474 100644
--- a/src/Monomer/Main/Platform.hs
+++ b/src/Monomer/Main/Platform.hs
@@ -28,12 +28,15 @@ import Control.Monad.Extra (whenJust)
import Control.Monad.State
import Data.Maybe
import Data.Text (Text)
+import Data.Word
import Foreign (alloca, peek)
import Foreign.C (peekCString, withCString)
import Foreign.C.Types
import SDL (($=))
+import qualified Codec.Picture as P
import qualified Data.Text as T
+import qualified Data.Vector.Storable as V
import qualified Foreign.C.String as STR
import qualified SDL
import qualified SDL.Input.Mouse as Mouse
@@ -149,7 +152,7 @@ setWindowIcon :: SDL.Window -> AppConfig e -> IO ()
setWindowIcon (SIT.Window winPtr) config =
forM_ (_apcWindowIcon config) $ \iconPath ->
flip catchAny handleException $ do
- iconSurface <- SVR.loadBMP (T.unpack iconPath)
+ iconSurface <- loadImgToSurface (T.unpack iconPath)
let SVR.Surface iconSurfacePtr _ = iconSurface
finally
-- Note: this can use the high-level setWindowIcon once it is available (https://github.com/haskell-game/sdl2/pull/243)
@@ -251,3 +254,18 @@ setDisableCompositorHint disable = void $
Raw.setHint cHintNameStr cDisableStr
where
disableStr = if disable then "1" else "0"
+
+readImageRGBA8 :: FilePath -> IO (P.Image P.PixelRGBA8)
+readImageRGBA8 path = P.readImage path
+ >>= either fail (return . P.convertRGBA8)
+
+loadImgToSurface :: FilePath -> IO SDL.Surface
+loadImgToSurface path = do
+ rgba8 <- readImageRGBA8 path
+ imgData <- V.thaw (P.imageData rgba8)
+
+ let width = fromIntegral $ P.imageWidth rgba8
+ height = fromIntegral $ P.imageHeight rgba8
+ imgSize = SDL.V2 width height
+
+ SDL.createRGBSurfaceFrom imgData imgSize (4 * width) SDL.ABGR8888