mirror of
https://github.com/fjvallarino/monomer.git
synced 2024-11-10 11:21:50 +03:00
Remove useHdpi flag
This commit is contained in:
parent
2393bb78b9
commit
61053005e1
@ -44,7 +44,6 @@ main = do
|
||||
--appWindowBorder False,
|
||||
appMaxFps 60,
|
||||
appWindowTitle "This is my title",
|
||||
appUseHdpi True,
|
||||
appTheme theme,
|
||||
appInitEvent InitApp,
|
||||
appDisposeEvent DisposeApp,
|
||||
|
@ -91,13 +91,12 @@ startApp model eventHandler uiBuilder configs = do
|
||||
(window, dpr, epr) <- initSDLWindow config
|
||||
winSize <- getDrawableSize window
|
||||
|
||||
let monomerCtx = initMonomerCtx model window winSize useHdpi dpr epr
|
||||
let monomerCtx = initMonomerCtx model window winSize dpr epr
|
||||
|
||||
runStateT (runAppLoop window appWidget config) monomerCtx
|
||||
detroySDLWindow window
|
||||
where
|
||||
config = mconcat configs
|
||||
useHdpi = fromMaybe defaultUseHdpi (_apcHdpi config)
|
||||
compCfgs
|
||||
= (onInit <$> _apcInitEvent config)
|
||||
++ (onDispose <$> _apcDisposeEvent config)
|
||||
|
@ -10,7 +10,6 @@ Helper functions for SDL platform related operations.
|
||||
-}
|
||||
module Monomer.Main.Platform (
|
||||
defaultWindowSize,
|
||||
defaultUseHdpi,
|
||||
initSDLWindow,
|
||||
detroySDLWindow,
|
||||
getCurrentMousePos,
|
||||
@ -22,6 +21,7 @@ module Monomer.Main.Platform (
|
||||
import Control.Monad.State
|
||||
import Data.Maybe
|
||||
import Data.Text (Text)
|
||||
import Foreign (alloca, peek)
|
||||
import Foreign.C (peekCString, withCString)
|
||||
import Foreign.C.Types
|
||||
import SDL (($=))
|
||||
@ -40,8 +40,6 @@ import Monomer.Main.Types
|
||||
import Monomer.Event.Types
|
||||
import Monomer.Widgets.Composite
|
||||
|
||||
import Foreign
|
||||
|
||||
foreign import ccall unsafe "initGlew" glewInit :: IO CInt
|
||||
foreign import ccall unsafe "initializeDpiAwareness" initializeDpiAwareness :: IO CInt
|
||||
|
||||
@ -49,10 +47,6 @@ foreign import ccall unsafe "initializeDpiAwareness" initializeDpiAwareness :: I
|
||||
defaultWindowSize :: (Int, Int)
|
||||
defaultWindowSize = (640, 480)
|
||||
|
||||
-- | Default use of HDPI or not.
|
||||
defaultUseHdpi :: Bool
|
||||
defaultUseHdpi = True
|
||||
|
||||
-- | Creates and initializes a window using the provided configuration.
|
||||
initSDLWindow :: AppConfig e -> IO (SDL.Window, Double, Double)
|
||||
initSDLWindow config = do
|
||||
@ -77,7 +71,7 @@ initSDLWindow config = do
|
||||
"SDL / OpenGL Example"
|
||||
SDL.defaultWindow {
|
||||
SDL.windowInitialSize = SDL.V2 (round winW) (round winH),
|
||||
SDL.windowHighDPI = windowHiDPI,
|
||||
SDL.windowHighDPI = True,
|
||||
SDL.windowResizable = windowResizable,
|
||||
SDL.windowBorder = windowBorder,
|
||||
SDL.windowGraphicsContext = SDL.OpenGLContext customOpenGL
|
||||
@ -121,7 +115,6 @@ initSDLWindow config = do
|
||||
_ -> defaultWindowSize
|
||||
windowResizable = fromMaybe True (_apcWindowResizable config)
|
||||
windowBorder = fromMaybe True (_apcWindowBorder config)
|
||||
windowHiDPI = fromMaybe defaultUseHdpi (_apcHdpi config)
|
||||
windowFullscreen = case _apcWindowState config of
|
||||
Just MainWindowFullScreen -> True
|
||||
_ -> False
|
||||
|
@ -139,8 +139,6 @@ data AppConfig e = AppConfig {
|
||||
_apcWindowResizable :: Maybe Bool,
|
||||
-- | Whether the main window has a border.
|
||||
_apcWindowBorder :: Maybe Bool,
|
||||
-- | Whether to enable HDPI.
|
||||
_apcHdpi :: Maybe Bool,
|
||||
-- | Max number of FPS the application will run. It does not necessarily mean
|
||||
-- | rendering will happen every frame, but events and schedules will be
|
||||
-- | checked at this rate and may cause it.
|
||||
@ -170,7 +168,6 @@ instance Default (AppConfig e) where
|
||||
_apcWindowTitle = Nothing,
|
||||
_apcWindowResizable = Nothing,
|
||||
_apcWindowBorder = Nothing,
|
||||
_apcHdpi = Nothing,
|
||||
_apcMaxFps = Nothing,
|
||||
_apcFonts = [],
|
||||
_apcTheme = Nothing,
|
||||
@ -188,7 +185,6 @@ instance Semigroup (AppConfig e) where
|
||||
_apcWindowTitle = _apcWindowTitle a2 <|> _apcWindowTitle a1,
|
||||
_apcWindowResizable = _apcWindowResizable a2 <|> _apcWindowResizable a1,
|
||||
_apcWindowBorder = _apcWindowBorder a2 <|> _apcWindowBorder a1,
|
||||
_apcHdpi = _apcHdpi a2 <|> _apcHdpi a1,
|
||||
_apcMaxFps = _apcMaxFps a2 <|> _apcMaxFps a1,
|
||||
_apcFonts = _apcFonts a1 ++ _apcFonts a2,
|
||||
_apcTheme = _apcTheme a2 <|> _apcTheme a1,
|
||||
@ -227,12 +223,6 @@ appWindowBorder border = def {
|
||||
_apcWindowBorder = Just border
|
||||
}
|
||||
|
||||
-- | Whether to enable HDPI.
|
||||
appUseHdpi :: Bool -> AppConfig e
|
||||
appUseHdpi use = def {
|
||||
_apcHdpi = Just use
|
||||
}
|
||||
|
||||
{-|
|
||||
Max number of FPS the application will run. It does not necessarily mean
|
||||
rendering will happen every frame, but events and schedules will be checked at
|
||||
|
@ -40,11 +40,10 @@ initMonomerCtx
|
||||
:: s
|
||||
-> SDL.Window
|
||||
-> Size
|
||||
-> Bool
|
||||
-> Double
|
||||
-> Double
|
||||
-> MonomerCtx s
|
||||
initMonomerCtx model win winSize useHiDPI dpr epr = MonomerCtx {
|
||||
initMonomerCtx model win winSize dpr epr = MonomerCtx {
|
||||
_mcMainModel = model,
|
||||
_mcWindow = win,
|
||||
_mcWindowSize = winSize,
|
||||
|
@ -279,10 +279,10 @@ nodeHandleEvents_ wenv init evtsG node = unsafePerformIO $ do
|
||||
where
|
||||
winSize = _weWindowSize wenv
|
||||
vp = Rect 0 0 (_sW winSize) (_sH winSize)
|
||||
useHdpi = True
|
||||
dpr = 1
|
||||
epr = 1
|
||||
model = _weModel wenv
|
||||
monomerContext = initMonomerCtx model undefined winSize useHdpi dpr
|
||||
monomerContext = initMonomerCtx model undefined winSize dpr epr
|
||||
pathReadyRoot = node
|
||||
& L.info . L.path .~ rootPath
|
||||
& L.info . L.widgetId .~ WidgetId (wenv ^. L.timestamp) rootPath
|
||||
@ -300,11 +300,11 @@ nodeHandleResult
|
||||
-> (HandlerStep s e, MonomerCtx s)
|
||||
nodeHandleResult wenv result = unsafePerformIO $ do
|
||||
let winSize = _weWindowSize wenv
|
||||
let useHdpi = True
|
||||
let dpr = 1
|
||||
let epr = 1
|
||||
let model = _weModel wenv
|
||||
-- Do NOT test code involving SDL Window functions
|
||||
let monomerContext = initMonomerCtx model undefined winSize useHdpi dpr
|
||||
let monomerContext = initMonomerCtx model undefined winSize dpr epr
|
||||
|
||||
flip runStateT monomerContext $ do
|
||||
handleWidgetResult wenv True result
|
||||
|
Loading…
Reference in New Issue
Block a user