mirror of
https://github.com/fjvallarino/monomer.git
synced 2024-09-20 16:27:49 +03:00
Improve handling of new split position
This commit is contained in:
parent
2c77ca5427
commit
5f68fa381b
@ -120,9 +120,9 @@ handleAppEvent wenv model evt = case evt of
|
||||
_ -> []
|
||||
|
||||
buildUI :: WidgetEnv App AppEvent -> App -> WidgetNode App AppEvent
|
||||
buildUI wenv model = trace "Creating UI" widgetHSplit where
|
||||
widgetHSplit = hsplit (image "assets/images/pecans.jpg" `style` [rangeWidth 200 500], widgetTree)
|
||||
widgetVSplit = vsplit (image "assets/images/pecans.jpg" `style` [rangeHeight 200 500], widgetTree `style` [rangeHeight 200 500])
|
||||
buildUI wenv model = trace "Creating UI" widgetVSplit where
|
||||
widgetHSplit = hsplit (image "assets/images/pecans.jpg" `style` [rangeWidth 200 500], widgetTree `style` [rangeWidth 200 500])
|
||||
widgetVSplit = vsplit (image "assets/images/pecans.jpg" `style` [rangeHeight 200 400], widgetTree `style` [rangeHeight 200 400])
|
||||
mkImg i = vstack [
|
||||
label ("Image: " <> showt i),
|
||||
image ("https://picsum.photos/600/400?ts=" ++ show i)
|
||||
|
@ -229,7 +229,7 @@ makeSplit isHorizontal config state = widget where
|
||||
useOldPos = customPos || ignoreSizeReq || sizeReqEquals
|
||||
handlePos
|
||||
| useOldPos && handlePosSet && validSize = oldHandlePos
|
||||
| otherwise = calcHandlePos areas newSize
|
||||
| otherwise = calcHandlePos newSize oldHandlePos renderArea children
|
||||
(w1, h1)
|
||||
| isHorizontal = ((newSize - handleW) * handlePos, rh)
|
||||
| otherwise = (rw, (newSize - handleW) * handlePos)
|
||||
@ -261,7 +261,7 @@ makeSplit isHorizontal config state = widget where
|
||||
resized = (result, assignedArea)
|
||||
|
||||
getValidHandlePos maxDim rect point children = addPoint origin newPoint where
|
||||
Rect rx ry rw rh = rect
|
||||
Rect rx ry _ _ = rect
|
||||
Point vx vy = rectBoundedPoint rect point
|
||||
origin = Point rx ry
|
||||
isVertical = not isHorizontal
|
||||
@ -281,9 +281,15 @@ makeSplit isHorizontal config state = widget where
|
||||
| isVertical && maxDim - th > maxSize2 = Point tw (maxDim - maxSize2)
|
||||
| otherwise = Point tw th
|
||||
|
||||
calcHandlePos areas newDim = newPos where
|
||||
childSize = selector $ Seq.index areas 0
|
||||
newPos = childSize / newDim
|
||||
calcHandlePos maxDim handlePos rect children = newPos where
|
||||
Rect rx ry _ _ = rect
|
||||
point
|
||||
| isHorizontal = Point (rx + maxDim * handlePos) 0
|
||||
| otherwise = Point 0 (ry + maxDim * handlePos)
|
||||
Point px py = getValidHandlePos maxDim rect point children
|
||||
newPos
|
||||
| isHorizontal = (px - rx) / maxDim
|
||||
| otherwise = (py - ry) / maxDim
|
||||
|
||||
selector
|
||||
| isHorizontal = _rW
|
||||
|
Loading…
Reference in New Issue
Block a user