Rename Resize request to ResizeWidgets

This commit is contained in:
Francisco Vallarino 2020-11-19 11:28:20 -03:00
parent 8a16a95ef1
commit f2a7d77f0e
6 changed files with 15 additions and 14 deletions

View File

@ -59,7 +59,7 @@ data WidgetState
data WidgetRequest s
= IgnoreParentEvents
| IgnoreChildrenEvents
| Resize
| ResizeWidgets
| MoveFocus FocusDirection
| SetFocus Path
| GetClipboard Path
@ -242,7 +242,7 @@ data WidgetInstance s e =
instance Show (WidgetRequest s) where
show IgnoreParentEvents = "IgnoreParentEvents"
show IgnoreChildrenEvents = "IgnoreChildrenEvents"
show Resize = "Resize"
show ResizeWidgets = "ResizeWidgets"
show (MoveFocus dir) = "MoveFocus: " ++ show dir
show (SetFocus path) = "SetFocus: " ++ show path
show (GetClipboard path) = "GetClipboard: " ++ show path

View File

@ -102,7 +102,7 @@ handleWidgetResult
-> m (HandlerStep s e)
handleWidgetResult wenv (WidgetResult reqs events evtRoot) =
handleRequests reqs (wenv, events, evtRoot)
>>= handleResize reqs
>>= handleResizeWidgets reqs
handleRequests
:: (MonomerM s m)
@ -113,7 +113,7 @@ handleRequests reqs step = foldM handleRequest step reqs where
handleRequest step req = case req of
IgnoreParentEvents -> return step
IgnoreChildrenEvents -> return step
Resize -> return step
ResizeWidgets -> return step
MoveFocus dir -> handleMoveFocus dir step
SetFocus path -> handleSetFocus path step
GetClipboard path -> handleGetClipboard path step
@ -129,14 +129,14 @@ handleRequests reqs step = foldM handleRequest step reqs where
RunTask path handler -> handleRunTask path handler step
RunProducer path handler -> handleRunProducer path handler step
handleResize
handleResizeWidgets
:: (MonomerM s m)
=> Seq (WidgetRequest s)
-> HandlerStep s e
-> m (HandlerStep s e)
handleResize reqs previousStep =
case Seq.filter isResize reqs of
Resize :<| _ -> do
handleResizeWidgets reqs previousStep =
case Seq.filter isResizeWidgets reqs of
ResizeWidgets :<| _ -> do
windowSize <- use L.windowSize
let (wenv, events, widgetRoot) = previousStep
@ -309,9 +309,9 @@ addFocusReq _ reqs = reqs
sendMessage :: TChan e -> e -> IO ()
sendMessage channel message = atomically $ writeTChan channel message
isResize :: WidgetRequest s -> Bool
isResize Resize = True
isResize _ = False
isResizeWidgets :: WidgetRequest s -> Bool
isResizeWidgets ResizeWidgets = True
isResizeWidgets _ = False
cursorToSDL :: CursorIcon -> SDLE.SystemCursor
cursorToSDL CursorArrow = SDLE.SDL_SYSTEM_CURSOR_ARROW

View File

@ -462,7 +462,7 @@ toParentReqs reqs = fmap fromJust $ Seq.filter isJust $ fmap toParentReq reqs
toParentReq :: WidgetRequest s -> Maybe (WidgetRequest sp)
toParentReq IgnoreParentEvents = Just IgnoreParentEvents
toParentReq IgnoreChildrenEvents = Just IgnoreChildrenEvents
toParentReq Resize = Just Resize
toParentReq ResizeWidgets = Just ResizeWidgets
toParentReq (MoveFocus dir) = Just (MoveFocus dir)
toParentReq (SetFocus path) = Just (SetFocus path)
toParentReq (GetClipboard path) = Just (GetClipboard path)

View File

@ -153,7 +153,7 @@ makeImage imgPath config state = widget where
newInst = inst {
_wiWidget = makeImage imgPath config newState
}
result = Just $ resultReqs [Resize] newInst
result = Just $ resultReqs [ResizeWidgets] newInst
getSizeReq wenv inst = sizeReq where
style = activeStyle wenv inst

View File

@ -142,7 +142,7 @@ handleSizeChange wenv target evt cfg inst = reqs where
newSizeReqH = _wiSizeReqH instReqs
sizeReqChanged = oldSizeReqW /= newSizeReqW || oldSizeReqH /= newSizeReqH
-- Result
reqs = [ Resize | checkSize && sizeReqChanged ]
reqs = [ ResizeWidgets | checkSize && sizeReqChanged ]
handleCursorChange
:: WidgetEnv s e

View File

@ -293,6 +293,7 @@ Maybe postponed after release?
- Handle window title, maximize, etc
- Also handle as requests?
- Provide a way of exiting application/close window handler
- Think about label size (fixed by default? lower factor)
- VStack should set itself to a fixed size if all children are fixed
- ZStack should set _weIsTopLayer based on used space
- Restore focus to previous widget when zstack changes (dialog situation)