From ebe2370046170e5cf8ef9d8c463180eee9e3784b Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Wed, 15 Mar 2023 14:18:19 +1300 Subject: [PATCH] Draft additional layout inputs. --- haphaestus.cabal | 2 +- src/Main.hs | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/haphaestus.cabal b/haphaestus.cabal index ec5c446..7cb819f 100644 --- a/haphaestus.cabal +++ b/haphaestus.cabal @@ -25,7 +25,7 @@ executable haphaestus xml-conduit, containers, stylist >= 2.5, stylist-traits, css-syntax, xml-conduit-stylist >=3, text >= 2, bytestring, - cattrap >= 0.1 && <0.2, + cattrap >= 0.1 && <0.2, fontconfig-pure, sdl2 >= 2.5.4, gl, mtl hs-source-dirs: src default-language: Haskell2010 diff --git a/src/Main.hs b/src/Main.hs index bb72973..63eb668 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -30,8 +30,9 @@ import Data.HTML2CSS (el2stylist) import Graphics.Layout.CSS (CSSBox(..), finalizeCSS') import Graphics.Layout.CSS.Internal (placeholderFont) -import Graphics.Layout.Box (zeroBox, PaddedBox(..), Size(..)) +import Graphics.Layout.Box as B (zeroBox, PaddedBox(..), Size(..)) import Graphics.Layout (boxLayout) +import Graphics.Text.Font.Choose (nameParse) import SDL hiding (rotate) import Graphics.GL.Core32 @@ -119,7 +120,7 @@ main = do appName = "haphaestus" } - [arg] <- getArgs + [arg, scale'] <- getArgs let uri = nullURI `fromMaybe` parseURIReference arg `relativeTo` pageURL referer page <- fetchDocument sess referer uri @@ -130,10 +131,6 @@ main = do let style = CSSTxt.resolve $ inlinePseudos' $ stylize css' $ el2stylist $ documentRoot $ html page - let outerbox = zeroBox -- FIXME: Parameterize! - let sysfont = placeholderFont -- FIXME: Parameterize! - let layout = boxLayout zeroBox (finalizeCSS' sysfont style) False - SDL.initializeAll let openGL = defaultOpenGL { glProfile = Core Debug 3 3 } wcfg = defaultWindow { @@ -152,6 +149,12 @@ main = do sz@(V2 dw dh) <- glGetDrawableSize w glViewport 0 0 (fromIntegral dw) (fromIntegral dh) + let size = B.Size (fromIntegral dw) (fromIntegral dh) + let outerbox = zeroBox { B.min = size, B.size = size, B.max = size } + let sysfont = (pattern2font (nameParse "serif-12") temp + placeholderFont placeholderfont) { scale = read scale' } + let layout = boxLayout outerbox (finalizeCSS' sysfont style) False + glSwapWindow w unless (QuitEvent `elem` events) loop return () -- 2.30.2