summaryrefslogtreecommitdiff
path: root/Bustle.hs
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2008-11-13 15:45:05 +0000
committerWill Thompson <will.thompson@collabora.co.uk>2008-11-13 15:45:05 +0000
commitb62429b8dd91a848dd5a2007f5152c3ff9043b8e (patch)
tree6f6c0b3fb07608d1e4e58b1390dc920032f1fd12 /Bustle.hs
parent2ded157c4205fddd4153981f93256fdbb727ca19 (diff)
Calculate image size from bounding boxes
Diffstat (limited to 'Bustle.hs')
-rw-r--r--Bustle.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/Bustle.hs b/Bustle.hs
index 41dfa00..37fd21e 100644
--- a/Bustle.hs
+++ b/Bustle.hs
@@ -21,6 +21,8 @@ module Main where
import Prelude hiding (catch, log)
import Control.Exception (catch)
+import Control.Arrow ((&&&))
+
import Paths_bustle
import Bustle.Parser
import Bustle.Renderer
@@ -51,14 +53,17 @@ run :: FilePath -> [Message] -> IO ()
run filename log = do
initGUI
- let (width, height, shapes) = process log
- let boundsAndShapes = zip (map bounds shapes) shapes
+ let shapes :: [(Rect, Shape)]
+ shapes = map (bounds &&& id) $ process log
+
+ (width, height) = (maximum *** maximum) $
+ unzip [ (x2, y2) | ((_, _, x2, y2), _) <- shapes ]
window <- mkWindow filename
layout <- layoutNew Nothing Nothing
layoutSetSize layout (floor width) (floor height)
- layout `onExpose` update layout boundsAndShapes
+ layout `onExpose` update layout shapes
scrolledWindow <- scrolledWindowNew Nothing Nothing
scrolledWindowSetPolicy scrolledWindow PolicyAutomatic PolicyAlways
containerAdd scrolledWindow layout