never executed always true always false
    1 {-|
    2 Module: Flaw.UI.VisualElement
    3 Description: Adapter for Visual to use it as Element.
    4 License: MIT
    5 -}
    6 
    7 module Flaw.UI.VisualElement
    8   ( VisualElement(..)
    9   , newVisualElement
   10   ) where
   11 
   12 import Control.Concurrent.STM
   13 
   14 import Flaw.Math
   15 import Flaw.UI
   16 import Flaw.UI.Drawer
   17 
   18 data VisualElement = VisualElement
   19   { visualElementVisual :: !SomeVisual
   20   , visualElementSizeVar :: !(TVar Size)
   21   }
   22 
   23 newVisualElement :: Visual v => v -> STM VisualElement
   24 newVisualElement visual = do
   25   sizeVar <- newTVar $ Vec2 0 0
   26   return VisualElement
   27     { visualElementVisual = SomeVisual visual
   28     , visualElementSizeVar = sizeVar
   29     }
   30 
   31 instance Element VisualElement where
   32   layoutElement VisualElement
   33     { visualElementSizeVar = sizeVar
   34     } = writeTVar sizeVar
   35   dabElement _ _ = return False
   36   elementMouseCursor _ = return MouseCursorArrow
   37   renderElement VisualElement
   38     { visualElementVisual = SomeVisual visual
   39     , visualElementSizeVar = sizeVar
   40     } drawer@Drawer
   41     { drawerStyles = DrawerStyles
   42       { drawerFlatStyleVariant = StyleVariant
   43         { styleVariantNormalStyle = style
   44         }
   45       }
   46     } position = do
   47     size <- readTVar sizeVar
   48     renderVisual visual drawer position size style
   49   processInputEvent _ _ _ = return False