Move SizeReq to Core

This commit is contained in:
Francisco Vallarino 2021-02-26 10:05:09 -03:00
parent 403faa7310
commit 81ec297d45
4 changed files with 16 additions and 16 deletions

View File

@ -1,6 +1,7 @@
module Monomer.Core (
module Monomer.Core.BasicTypes,
module Monomer.Core.FromFractional,
module Monomer.Core.SizeReq,
module Monomer.Core.Style,
module Monomer.Core.StyleUtil,
module Monomer.Core.Util,
@ -10,6 +11,7 @@ module Monomer.Core (
import Monomer.Core.BasicTypes
import Monomer.Core.FromFractional
import Monomer.Core.SizeReq
import Monomer.Core.Style
import Monomer.Core.StyleUtil
import Monomer.Core.Util

View File

@ -1,4 +1,4 @@
module Monomer.Widgets.Util.SizeReq (
module Monomer.Core.SizeReq (
SizeReqUpdater(..),
clearExtra,
sizeReqBound,
@ -16,17 +16,16 @@ module Monomer.Widgets.Util.SizeReq (
) where
import Control.Lens ((&), (^.), (.~))
import Data.Bits
import Data.Default
import Data.Maybe
import Data.Sequence ((|>))
import Monomer.Core
import Monomer.Event
import Monomer.Widgets.Util.Style
import Monomer.Widgets.Util.Widget
import Monomer.Core.BasicTypes
import Monomer.Core.StyleTypes
import Monomer.Core.StyleUtil
import Monomer.Core.Util
import qualified Monomer.Core.Lens as L
import Data.Bits
type SizeReqUpdater = (SizeReq, SizeReq) -> (SizeReq, SizeReq)
@ -103,11 +102,12 @@ sizeReqMergeMax req1 req2 = newReq where
}
modifySizeReq :: SizeReq -> (Double -> Double) -> SizeReq
modifySizeReq (SizeReq fixed flex extra factor) fn = def
& L.fixed .~ (if fixed > 0 then fn fixed else 0)
& L.flex .~ (if flex > 0 then fn flex else 0)
& L.extra .~ (if extra > 0 then fn extra else 0)
& L.factor .~ factor
modifySizeReq (SizeReq fixed flex extra factor) fn = SizeReq {
_szrFixed = if fixed > 0 then fn fixed else 0,
_szrFlex = if flex > 0 then fn flex else 0,
_szrExtra = if extra > 0 then fn extra else 0,
_szrFactor = factor
}
doubleInRange :: Double -> Double -> Double -> Bool
doubleInRange minValue maxValue curValue = validMin && validMax where

View File

@ -1,7 +1,6 @@
module Monomer.Widgets.Util (
module Monomer.Widgets.Util.Focus,
module Monomer.Widgets.Util.Hover,
module Monomer.Widgets.Util.SizeReq,
module Monomer.Widgets.Util.Style,
module Monomer.Widgets.Util.Text,
module Monomer.Widgets.Util.Theme,
@ -11,7 +10,6 @@ module Monomer.Widgets.Util (
import Monomer.Widgets.Util.Focus
import Monomer.Widgets.Util.Hover
import Monomer.Widgets.Util.SizeReq
import Monomer.Widgets.Util.Style
import Monomer.Widgets.Util.Text
import Monomer.Widgets.Util.Theme

View File

@ -524,6 +524,8 @@
- Think about using stack resize logic in box
- Add option to modify size req
- Add maxLines config option to label
- Check Fixed+Flex sum/max criteria. Is a new Fixed+Flex type needed?
- Review dialogs after change is in place
- Pending
- Add header in all files, indicating license and documenting what the module does
@ -537,8 +539,6 @@ Next
- Composite example
- Validate nested structures update correctly when disabling/enabling parent
- Something of generative art (OpenGL example)
- Check Fixed+Flex sum/max criteria. Is a new Fixed+Flex type needed?
- Review dialogs after change is in place
- Move SizeReq to Core
- Add concept of active layout direction (needed to have a single spacer/filler)
- Make button use label + box (way too much duplicated code)