Commit c468bdfd authored by Peter Achten's avatar Peter Achten
Browse files

(PA) bug fixes wrt window activation/scrolling

parent d8ca2bf2
......@@ -566,7 +566,7 @@ where
moveControlViewFrame` :: !Id Vector2 !*WState -> *WState
moveControlViewFrame` id v wState=:{wIds,wRep,wTb,wMetrics}
# (wH,tb) = movecontrolviewframe id v wMetrics wIds wRep wTb
wH = invalidateWindowClipState` wH
// wH = invalidateWindowClipState` wH PA: seems to me that this is a bit exagerated
= {wState & wRep=wH,wTb=tb}
......
......@@ -10,7 +10,7 @@ import StdControlClass
from StdId import getParentId
from StdPSt import appPIO, accPIO
from StdSystem import maxScrollWindowSize
import commondef, controlpos, iostate, windowaccess, windowcreate, windowdevice, windowhandle, windowupdate, wstate
import commondef, controlpos, iostate, scheduler, windowaccess, windowcreate, windowdevice, windowhandle, windowupdate, wstate
from controlinternal import enablecontrols, disablecontrols
from controllayout import layoutControls
from controlrelayout import relayoutControls
......@@ -180,7 +180,7 @@ setActiveWindow wId pState
# wHs = windows.whsWindows
(modal,modeless) = Uspan ismodalwindow wHs
(isModal,modal) = UContains (identifyWindowStateHandle wid) modal
| isModal // Modal windows should be activated
| isModal // Modal windows should not be activated
= {pState & io=IOStSetDevice (WindowSystemState {windows & whsWindows=modal++modeless}) ioState}
# (osdInfo,ioState) = IOStGetOSDInfo ioState
isSDI = getOSDInfoDocumentInterface osdInfo==SDI
......@@ -194,7 +194,11 @@ setActiveWindow wId pState
activatePtr = if (isSDI && wids.wPtr==clientPtr) framePtr wids.wPtr // Do not activate SDI client, but SDI frame
showAction = if shown id (snd o OSshowWindow activatePtr True)
# ioState = IOStSetDevice (WindowSystemState {windows & whsWindows=[wsH:others]}) ioState
# (delayinfo,ioState) = accIOToolbox (OSactivateWindow osdInfo activatePtr o showAction) ioState
// # (delayinfo,ioState) = accIOToolbox (OSactivateWindow osdInfo activatePtr o showAction) ioState
# (tb,ioState) = getIOToolbox ioState
# pState = {pState & io=ioState}
# (delayinfo,pState,tb) = OSactivateWindow osdInfo activatePtr handleOSEvent pState (showAction tb)
# ioState = setIOToolbox tb pState.io
# ioState = bufferDelayedEvents delayinfo ioState
= {pState & io=ioState}
| otherwise // There are modal windows, so put activated window behind last modal
......@@ -216,6 +220,12 @@ where
# (mode,wsH) = getWindowStateHandleWindowMode wsH
= (mode==Modal,wsH)
// handleOSEvent turns handleOneEventForDevices into the form required by OSactivateWindow.
handleOSEvent :: !OSEvent !(!PSt .l,!*OSToolbox) -> (!PSt .l,!*OSToolbox)
handleOSEvent osEvent (pState,tb)
= (thd3 (handleOneEventForDevices (ScheduleOSEvent osEvent []) pState),tb)
/* getActiveWindow returns the Id of the currently active window.
*/
getActiveWindow :: !(IOSt .l) -> (!Maybe Id, !IOSt .l)
......
......@@ -1160,21 +1160,27 @@ where
= (done,{itemH & wItems`=itemHs},updRgn_tb)
| newOrigin==oldOrigin
= (True,itemH,updRgn_tb)
# (updRgn,tb) = updRgn_tb
# tb = setsliderthumb hasHScroll miOSMetrics itemPtr True (minx,newOrigin.x,maxx) viewx (toTuple itemSize) tb
# tb = setsliderthumb hasVScroll miOSMetrics itemPtr False (miny,newOrigin.y,maxy) viewy (toTuple itemSize) tb
info = {info & compoundOrigin=newOrigin}
clipRect1 = IntersectRects contentRect clipRect
| isEmpty itemH.wItems`
# itemH = {itemH & wItemInfo`=CompoundInfo` info}
# (itemH,tb) = drawCompoundLook` miOSMetrics ableContext1 wPtr clipRect1 itemH tb
= (True,itemH,(updRgn,tb))
| otherwise
# (updRgn,tb) = updRgn_tb
# tb = setsliderthumb hasHScroll miOSMetrics itemPtr True (minx,newOrigin.x,maxx) viewx (toTuple itemSize) tb
# tb = setsliderthumb hasVScroll miOSMetrics itemPtr False (miny,newOrigin.y,maxy) viewy (toTuple itemSize) tb
oldItems` = itemH.wItems`
# oldItems` = itemH.wItems`
orientation` = [(domain,newOrigin):miOrientation]
# (_,newItems`,tb) = layoutControls` miOSMetrics hMargins` vMargins` spaces` itemSize itemSize orientation` oldItems` tb
newItems` = shiftControls` (toVector itemPos) newItems`
info = {info & compoundOrigin=newOrigin}
itemH = {itemH & wItems`=newItems`,wItemInfo`=CompoundInfo` info}
# tb = case updRgn of
Just rgn -> osdisposergn rgn tb
nothing -> tb
# (itemH, tb) = forceValidCompoundClipState` miOSMetrics True wPtr defaultId shownContext itemH tb
# (updRgn,tb) = relayoutControls` miOSMetrics ableContext1 shownContext1 contentRect contentRect itemPos itemPos itemPtr defaultId oldItems` itemH.wItems` tb
# (itemH, tb) = drawCompoundLook` miOSMetrics ableContext1 wPtr clipRect1 itemH tb
= (True,itemH,(Just updRgn,tb))
where
info = getWItemCompoundInfo` itemH.wItemInfo`
......@@ -1257,26 +1263,28 @@ where
= (done,{itemH & wItems`=itemHs},updRgn_tb)
| newDomain==oldDomain
= (True,itemH,updRgn_tb)
# (updRgn,tb) = updRgn_tb
# (minx,maxx,viewx) = (newDomainRect.rleft,newDomainRect.rright, newContentSize.w)
(miny,maxy,viewy) = (newDomainRect.rtop, newDomainRect.rbottom,newContentSize.h)
newOrigin = {x=SetBetween oldOrigin.x minx (max minx (maxx-viewx)),y=SetBetween oldOrigin.y miny (max miny (maxy-viewy))}
# tb = setsliderthumb hasHScroll miOSMetrics itemPtr True (minx,newOrigin.x,maxx) viewx itemSize` tb
# tb = setsliderthumb hasVScroll miOSMetrics itemPtr False (miny,newOrigin.y,maxy) viewy itemSize` tb
oldItems` = itemH.wItems`
orientation` = [(newDomain,newOrigin):miOrientation]
# (_,newItems`,tb) = layoutControls` miOSMetrics hMargins` vMargins` spaces` itemSize itemSize orientation` oldItems` tb
newItems` = shiftControls` (toVector itemPos) newItems`
info = {info & compoundOrigin=newOrigin,compoundDomain=newDomainRect}
itemH = {itemH & wItems`=newItems`,wItemInfo`=CompoundInfo` info}
# tb = case updRgn of
Just rgn -> osdisposergn rgn tb
nothing -> tb
# (itemH, tb) = forceValidCompoundClipState` miOSMetrics True wPtr defaultId shownContext itemH tb
# (updRgn,tb) = relayoutControls` miOSMetrics ableContext1 shownContext1 newContentRect newContentRect itemPos itemPos itemPtr defaultId
oldItems` itemH.wItems` tb
| shownContext1
# (itemH,tb) = drawCompoundLook` miOSMetrics ableContext1 wPtr (IntersectRects newContentRect clipRect) itemH tb
= (True,itemH,(Just updRgn,tb))
| otherwise
# (updRgn,tb) = updRgn_tb
# (minx,maxx,viewx) = (newDomainRect.rleft,newDomainRect.rright, newContentSize.w)
(miny,maxy,viewy) = (newDomainRect.rtop, newDomainRect.rbottom,newContentSize.h)
newOrigin = {x=SetBetween oldOrigin.x minx (max minx (maxx-viewx)),y=SetBetween oldOrigin.y miny (max miny (maxy-viewy))}
# tb = setsliderthumb hasHScroll miOSMetrics itemPtr True (minx,newOrigin.x,maxx) viewx itemSize` tb
# tb = setsliderthumb hasVScroll miOSMetrics itemPtr False (miny,newOrigin.y,maxy) viewy itemSize` tb
oldItems` = itemH.wItems`
orientation` = [(newDomain,newOrigin):miOrientation]
# (_,newItems`,tb) = layoutControls` miOSMetrics hMargins` vMargins` spaces` itemSize itemSize orientation` oldItems` tb
newItems` = shiftControls` (toVector itemPos) newItems`
info = {info & compoundOrigin=newOrigin,compoundDomain=newDomainRect}
itemH = {itemH & wItems`=newItems`,wItemInfo`=CompoundInfo` info}
# tb = case updRgn of
Just rgn -> osdisposergn rgn tb
nothing -> tb
# (itemH, tb) = forceValidCompoundClipState` miOSMetrics True wPtr defaultId shownContext itemH tb
# (updRgn,tb) = relayoutControls` miOSMetrics ableContext1 shownContext1 newContentRect newContentRect itemPos itemPos itemPtr defaultId
oldItems` itemH.wItems` tb
# (itemH,tb) = drawCompoundLook` miOSMetrics ableContext1 wPtr (IntersectRects newContentRect clipRect) itemH tb
= (True,itemH,(Just updRgn,tb))
where
info = getWItemCompoundInfo` itemH.wItemInfo`
......
......@@ -396,12 +396,6 @@ where
visVScroll = hasVScroll && OSscrollbarIsVisible (domainRect.rtop, domainRect.rbottom) h
(w`,h`) = (w+wMetrics.osmVSliderWidth,h+wMetrics.osmHSliderHeight)
validateControlMargin :: !(!Int,!Int) -> (!Int,!Int)
validateControlMargin (a,b) = (max 0 a,max 0 b)
validateControlItemSpace :: !(!Int,!Int) -> (!Int,!Int)
validateControlItemSpace (hspace,vspace) = (max 0 hspace,max 0 vspace)
layoutScrollbars :: !OSWindowMetrics !Size !CompoundInfo -> CompoundInfo
layoutScrollbars wMetrics size info=:{compoundHScroll,compoundVScroll}
= { info & compoundHScroll=layoutScrollbar hRect compoundHScroll
......@@ -474,12 +468,6 @@ where
validateDerivedSize wMetrics derSize reqSize
| reqSize==zero = derSize
| otherwise = reqSize
validateControlMargin :: !(!Int,!Int) -> (!Int,!Int)
validateControlMargin (a,b) = (max 0 a,max 0 b)
validateControlItemSpace :: !(!Int,!Int) -> (!Int,!Int)
validateControlItemSpace (hspace,vspace) = (max 0 hspace,max 0 vspace)
getLayoutWItem _ _ _ _ _ _ _ _ _ _
= controllayoutFatalError "getLayoutWItem" "unmatched control implementation alternative"
......@@ -517,7 +505,7 @@ getLayoutItems` wMetrics hMargins vMargins spaces orientations prevIds prevId cI
where
getLayoutItem` :: !OSWindowMetrics !(!Int,!Int) !(!Int,!Int) !(!Int,!Int) ![(ViewDomain,Origin)]
[Id] Id !Int !WElementHandle` !*OSToolbox
-> (![LayoutItem],[Id],Id,!Int,!WElementHandle`,!*OSToolbox)
-> (![LayoutItem],[Id],Id,!Int,!WElementHandle`,!*OSToolbox)
getLayoutItem` wMetrics hMargins vMargins spaces orientations prevIds prevId cId (WItemHandle` itemH=:{wItemVirtual`}) tb
| wItemVirtual`
= ([],prevIds,prevId,cId,WItemHandle` itemH,tb)
......@@ -748,12 +736,6 @@ where
w` = w+wMetrics.osmVSliderWidth
h` = h+wMetrics.osmHSliderHeight
validateControlMargin :: !(!Int,!Int) -> (!Int,!Int)
validateControlMargin (a,b) = (max 0 a,max 0 b)
validateControlItemSpace :: !(!Int,!Int) -> (!Int,!Int)
validateControlItemSpace (hspace,vspace) = (max 0 hspace,max 0 vspace)
layoutScrollbars :: !OSWindowMetrics !Size !CompoundInfo -> CompoundInfo
layoutScrollbars wMetrics size info=:{compoundHScroll,compoundVScroll}
= { info & compoundHScroll=layoutScrollbar hRect compoundHScroll
......@@ -826,12 +808,6 @@ where
validateDerivedSize wMetrics derSize reqSize
| reqSize==zero = derSize
| otherwise = reqSize
validateControlMargin :: !(!Int,!Int) -> (!Int,!Int)
validateControlMargin (a,b) = (max 0 a,max 0 b)
validateControlItemSpace :: !(!Int,!Int) -> (!Int,!Int)
validateControlItemSpace (hspace,vspace) = (max 0 hspace,max 0 vspace)
getLayoutWItem` _ _ _ _ _ _ _ _ _ _
= controllayoutFatalError "getLayoutWItem`" "unmatched control implementation alternative"
......@@ -849,7 +825,13 @@ where
getLayoutItems` _ _ _ _ _ prevIds prevId cId [] tb
= ([],prevIds,prevId,cId,[],tb)
validateControlMargin :: !(!Int,!Int) -> (!Int,!Int)
validateControlMargin (a,b) = (max 0 a,max 0 b)
validateControlItemSpace :: !(!Int,!Int) -> (!Int,!Int)
validateControlItemSpace (hspace,vspace) = (max 0 hspace,max 0 vspace)
toColumns :: !RowsOrColumns ![x] -> [[x]]
toColumns (Columns n) items
= repeat_splitting perColumn items
......
......@@ -26,9 +26,19 @@ controlposFatalError function error
*/
movewindowviewframe :: !OSWindowMetrics !Vector2 !WIDS !(WindowHandle .ls .pst) !*OSToolbox -> (!WindowHandle .ls .pst,!*OSToolbox)
movewindowviewframe wMetrics v wids=:{wPtr} wH=:{whWindowInfo,whItems=oldItems,whSize,whAtts,whSelect,whShow} tb
| newOrigin==oldOrigin
| newOrigin==oldOrigin // origin has not changed
= (wH,tb)
| otherwise
| isEmpty oldItems // there are no controls: do only visual updates
# tb = setsliderthumb hasHScroll wMetrics wPtr True (minx,newOrigin.x,maxx) vieww (toTuple whSize) tb
# tb = setsliderthumb hasVScroll wMetrics wPtr False (miny,newOrigin.y,maxy) viewh (toTuple whSize) tb
windowInfo = {windowInfo & windowOrigin=newOrigin}
wH = {wH & whWindowInfo=WindowInfo windowInfo}
(updArea,updAction) = if (not lookInfo.lookSysUpdate || toMuch)
([newFrame],return []) (calcScrollUpdateArea oldOrigin newOrigin contentRect)
updState = {oldFrame=PosSizeToRectangle oldOrigin contentSize,newFrame=newFrame,updArea=updArea}
# (wH,tb) = drawwindowlook` wMetrics wPtr updAction updState wH tb
= (wH,tb)
| otherwise // there are controls: recalculate layout and do visual updates
# tb = setsliderthumb hasHScroll wMetrics wPtr True (minx,newOrigin.x,maxx) vieww (toTuple whSize) tb
# tb = setsliderthumb hasVScroll wMetrics wPtr False (miny,newOrigin.y,maxy) viewh (toTuple whSize) tb
reqSize = {w=contentSize.w-fst hMargins-snd hMargins,h=contentSize.h-fst vMargins-snd vMargins}
......@@ -41,8 +51,6 @@ movewindowviewframe wMetrics v wids=:{wPtr} wH=:{whWindowInfo,whItems=oldItems,w
_ -> controlposFatalError "movewindowviewframe" "unexpected whWindowInfo field"
# (updRgn,tb) = relayoutControls wMetrics whSelect whShow contentRect contentRect zero zero wPtr wH.whDefaultId oldItems wH.whItems tb
# (wH,tb) = updatewindowbackgrounds wMetrics updRgn wids wH tb
newFrame = PosSizeToRectangle newOrigin contentSize
toMuch = (abs (newOrigin.x-oldOrigin.x)>=w`) || (abs (newOrigin.y-oldOrigin.y)>=h`)
(updArea,updAction) = if (not lookInfo.lookSysUpdate || toMuch || not isRect)
([newFrame],return []) (calcScrollUpdateArea oldOrigin newOrigin areaRect)
updState = {oldFrame=PosSizeToRectangle oldOrigin contentSize,newFrame=newFrame,updArea=updArea}
......@@ -62,6 +70,8 @@ where
newOrigin = { x = SetBetween (oldOrigin.x+v.vx) minx (max minx (maxx-vieww))
, y = SetBetween (oldOrigin.y+v.vy) miny (max miny (maxy-viewh))
}
newFrame = PosSizeToRectangle newOrigin contentSize
toMuch = (abs (newOrigin.x-oldOrigin.x)>=w`) || (abs (newOrigin.y-oldOrigin.y)>=h`)
(defMinW,defMinH) = OSMinWindowSize
minSize = {w=defMinW,h=defMinH}
hMargins = getWindowHMargins IsWindow wMetrics whAtts
......
......@@ -26,22 +26,22 @@ import relayout, windowaccess, windowclipstate, wstateaccess
relayoutControls :: !OSWindowMetrics !Bool !Bool !Rect !Rect !Point2 !Point2 !OSWindowPtr !(Maybe Id)
![WElementHandle .ls .pst] ![WElementHandle .ls .pst] !*OSToolbox -> (!OSRgnHandle,!*OSToolbox)
relayoutControls wMetrics isAble isVisible oldFrame newFrame oldParentPos newParentPos wPtr defaultId oldHs newHs tb
= relayoutItems wMetrics isAble oldFrame newFrame oldParentPos newParentPos wPtr
(WElementHandlesToRelayoutItems isVisible oldHs [])
(WElementHandlesToRelayoutItems isVisible newHs [])
= relayoutItems wMetrics oldFrame newFrame oldParentPos newParentPos wPtr
(WElementHandlesToRelayoutItems isAble isVisible oldHs [])
(WElementHandlesToRelayoutItems isAble isVisible newHs [])
tb
where
WElementHandlesToRelayoutItems :: !Bool ![WElementHandle .ls .pst] ![RelayoutItem] -> [RelayoutItem]
WElementHandlesToRelayoutItems isVisible [itemH:itemHs] items
= WElementHandleToRelayoutItems isVisible itemH (WElementHandlesToRelayoutItems isVisible itemHs items)
WElementHandlesToRelayoutItems :: !Bool !Bool ![WElementHandle .ls .pst] ![RelayoutItem] -> [RelayoutItem]
WElementHandlesToRelayoutItems isAble isVisible [itemH:itemHs] items
= WElementHandleToRelayoutItems isAble isVisible itemH (WElementHandlesToRelayoutItems isAble isVisible itemHs items)
where
WElementHandleToRelayoutItems :: !Bool !(WElementHandle .ls .pst) ![RelayoutItem] -> [RelayoutItem]
WElementHandleToRelayoutItems isVisible (WItemHandle itemH=:{wItemKind}) items
= WItemHandleToRelayoutItems wItemKind isVisible itemH items
WElementHandleToRelayoutItems :: !Bool !Bool !(WElementHandle .ls .pst) ![RelayoutItem] -> [RelayoutItem]
WElementHandleToRelayoutItems isAble isVisible (WItemHandle itemH=:{wItemKind}) items
= WItemHandleToRelayoutItems wItemKind isAble isVisible itemH items
where
WItemHandleToRelayoutItems :: !ControlKind !Bool !(WItemHandle .ls .pst) ![RelayoutItem] -> [RelayoutItem]
WItemHandleToRelayoutItems controlKind=:IsRadioControl isVisible itemH=:{wItemSelect,wItemShow} items
= RadioItemToRelayoutItems wItemSelect (isVisible && wItemShow) (getWItemRadioInfo itemH.wItemInfo).radioItems items
WItemHandleToRelayoutItems :: !ControlKind !Bool !Bool !(WItemHandle .ls .pst) ![RelayoutItem] -> [RelayoutItem]
WItemHandleToRelayoutItems controlKind=:IsRadioControl isAble isVisible itemH=:{wItemSelect,wItemShow} items
= RadioItemToRelayoutItems (isAble && wItemSelect) (isVisible && wItemShow) (getWItemRadioInfo itemH.wItemInfo).radioItems items
where
RadioItemToRelayoutItems :: !Bool !Bool ![RadioItemInfo *(.ls,.pst)] ![RelayoutItem] -> [RelayoutItem]
RadioItemToRelayoutItems isAble isVisible [radio:radios] items
......@@ -63,8 +63,8 @@ where
RadioItemToRelayoutItems _ _ _ items
= items
WItemHandleToRelayoutItems controlKind=:IsCheckControl isVisible itemH=:{wItemSelect,wItemShow} items
= CheckItemToRelayoutItems wItemSelect (isVisible && wItemShow) (getWItemCheckInfo itemH.wItemInfo).checkItems items
WItemHandleToRelayoutItems controlKind=:IsCheckControl isAble isVisible itemH=:{wItemSelect,wItemShow} items
= CheckItemToRelayoutItems (isAble && wItemSelect) (isVisible && wItemShow) (getWItemCheckInfo itemH.wItemInfo).checkItems items
where
CheckItemToRelayoutItems :: !Bool !Bool ![CheckItemInfo *(.ls,.pst)] ![RelayoutItem] -> [RelayoutItem]
CheckItemToRelayoutItems isAble isVisible [check:checks] items
......@@ -86,12 +86,12 @@ where
CheckItemToRelayoutItems _ _ _ items
= items
WItemHandleToRelayoutItems controlKind isVisible itemH=:{wItemPtr,wItemPos,wItemSize,wItemSelect,wItemShow} items
WItemHandleToRelayoutItems controlKind isAble isVisible itemH=:{wItemPtr,wItemPos,wItemSize,wItemSelect,wItemShow} items
#! item = { rliItemKind = controlKind
, rliItemPtr = wItemPtr
, rliItemPos = wItemPos
, rliItemSize = wItemSize
, rliItemSelect = wItemSelect
, rliItemSelect = isAble`
, rliItemShow = isVisible`
, rliItemInfo = info
, rliItemLook = look
......@@ -99,55 +99,56 @@ where
}
= [item:items]
where
isAble` = isAble && wItemSelect
isVisible` = isVisible && wItemShow
(info,look,items`) = getinfo controlKind isVisible` itemH
(info,look,items`) = getinfo controlKind isAble` isVisible` itemH
getinfo :: !ControlKind !Bool !(WItemHandle .ls .pst) -> (CompoundInfo,LookInfo,![RelayoutItem])
getinfo IsCompoundControl isVisible {wItemInfo,wItems}
= (info,info.compoundLookInfo.compoundLook,WElementHandlesToRelayoutItems isVisible wItems [])
getinfo :: !ControlKind !Bool !Bool !(WItemHandle .ls .pst) -> (CompoundInfo,LookInfo,![RelayoutItem])
getinfo IsCompoundControl isAble isVisible {wItemInfo,wItems}
= (info,info.compoundLookInfo.compoundLook,WElementHandlesToRelayoutItems isAble isVisible wItems [])
where
info = getWItemCompoundInfo wItemInfo
getinfo IsCustomButtonControl _ {wItemInfo}
getinfo IsCustomButtonControl _ _ {wItemInfo}
= (undef,(getWItemCustomButtonInfo wItemInfo).cButtonInfoLook,[])
getinfo IsCustomControl _ {wItemInfo}
getinfo IsCustomControl _ _ {wItemInfo}
= (undef,(getWItemCustomInfo wItemInfo).customInfoLook,[])
getinfo IsLayoutControl isVisible {wItems}
= (undef,undef,WElementHandlesToRelayoutItems isVisible wItems [])
getinfo _ _ _
getinfo IsLayoutControl isAble isVisible {wItems}
= (undef,undef,WElementHandlesToRelayoutItems isAble isVisible wItems [])
getinfo _ _ _ _
= (undef,undef,[])
WElementHandleToRelayoutItems isVisible (WListLSHandle itemHs) items
= WElementHandlesToRelayoutItems isVisible itemHs items
WElementHandleToRelayoutItems isAble isVisible (WListLSHandle itemHs) items
= WElementHandlesToRelayoutItems isAble isVisible itemHs items
WElementHandleToRelayoutItems isVisible (WExtendLSHandle {wExtendItems=itemHs}) items
= WElementHandlesToRelayoutItems isVisible itemHs items
WElementHandleToRelayoutItems isAble isVisible (WExtendLSHandle {wExtendItems=itemHs}) items
= WElementHandlesToRelayoutItems isAble isVisible itemHs items
WElementHandleToRelayoutItems isVisible (WChangeLSHandle {wChangeItems=itemHs}) items
= WElementHandlesToRelayoutItems isVisible itemHs items
WElementHandleToRelayoutItems isAble isVisible (WChangeLSHandle {wChangeItems=itemHs}) items
= WElementHandlesToRelayoutItems isAble isVisible itemHs items
WElementHandlesToRelayoutItems _ _ items
WElementHandlesToRelayoutItems _ _ _ items
= items
relayoutControls` :: !OSWindowMetrics !Bool !Bool !Rect !Rect !Point2 !Point2 !OSWindowPtr !(Maybe Id)
![WElementHandle`] ![WElementHandle`] !*OSToolbox -> (!OSRgnHandle,!*OSToolbox)
relayoutControls` wMetrics isAble isVisible oldFrame newFrame oldParentPos newParentPos wPtr defaultId oldHs newHs tb
= relayoutItems wMetrics isAble oldFrame newFrame oldParentPos newParentPos wPtr
(WElementHandles`ToRelayoutItems isVisible oldHs [])
(WElementHandles`ToRelayoutItems isVisible newHs [])
= relayoutItems wMetrics oldFrame newFrame oldParentPos newParentPos wPtr
(WElementHandles`ToRelayoutItems isAble isVisible oldHs [])
(WElementHandles`ToRelayoutItems isAble isVisible newHs [])
tb
where
WElementHandles`ToRelayoutItems :: !Bool ![WElementHandle`] ![RelayoutItem] -> [RelayoutItem]
WElementHandles`ToRelayoutItems isVisible [itemH:itemHs] items
= WElementHandle`ToRelayoutItems isVisible itemH (WElementHandles`ToRelayoutItems isVisible itemHs items)
WElementHandles`ToRelayoutItems :: !Bool !Bool ![WElementHandle`] ![RelayoutItem] -> [RelayoutItem]
WElementHandles`ToRelayoutItems isAble isVisible [itemH:itemHs] items
= WElementHandle`ToRelayoutItems isAble isVisible itemH (WElementHandles`ToRelayoutItems isAble isVisible itemHs items)
where
WElementHandle`ToRelayoutItems :: !Bool !WElementHandle` ![RelayoutItem] -> [RelayoutItem]
WElementHandle`ToRelayoutItems isVisible (WItemHandle` itemH=:{wItemKind`}) items
= WItemHandle`ToRelayoutItems wItemKind` isVisible itemH items
WElementHandle`ToRelayoutItems :: !Bool !Bool !WElementHandle` ![RelayoutItem] -> [RelayoutItem]
WElementHandle`ToRelayoutItems isAble isVisible (WItemHandle` itemH=:{wItemKind`}) items
= WItemHandle`ToRelayoutItems wItemKind` isAble isVisible itemH items
where
WItemHandle`ToRelayoutItems :: !ControlKind !Bool !WItemHandle` ![RelayoutItem] -> [RelayoutItem]
WItemHandle`ToRelayoutItems controlKind=:IsRadioControl isVisible itemH=:{wItemSelect`,wItemShow`} items
= RadioItem`ToRelayoutItems wItemSelect` (isVisible && wItemShow`) (getWItemRadioInfo` itemH.wItemInfo`).radioItems` items
WItemHandle`ToRelayoutItems :: !ControlKind !Bool !Bool !WItemHandle` ![RelayoutItem] -> [RelayoutItem]
WItemHandle`ToRelayoutItems controlKind=:IsRadioControl isAble isVisible itemH=:{wItemSelect`,wItemShow`} items
= RadioItem`ToRelayoutItems (isAble && wItemSelect`) (isVisible && wItemShow`) (getWItemRadioInfo` itemH.wItemInfo`).radioItems` items
where
RadioItem`ToRelayoutItems :: !Bool !Bool ![RadioItemInfo`] ![RelayoutItem] -> [RelayoutItem]
RadioItem`ToRelayoutItems isAble isVisible [radio:radios] items
......@@ -169,8 +170,8 @@ where
RadioItem`ToRelayoutItems _ _ _ items
= items
WItemHandle`ToRelayoutItems controlKind=:IsCheckControl isVisible itemH=:{wItemSelect`,wItemShow`} items
= CheckItem`ToRelayoutItems wItemSelect` (isVisible && wItemShow`) (getWItemCheckInfo` itemH.wItemInfo`).checkItems` items
WItemHandle`ToRelayoutItems controlKind=:IsCheckControl isAble isVisible itemH=:{wItemSelect`,wItemShow`} items
= CheckItem`ToRelayoutItems (isAble && wItemSelect`) (isVisible && wItemShow`) (getWItemCheckInfo` itemH.wItemInfo`).checkItems` items
where
CheckItem`ToRelayoutItems :: !Bool !Bool ![CheckItemInfo`] ![RelayoutItem] -> [RelayoutItem]
CheckItem`ToRelayoutItems isAble isVisible [check:checks] items
......@@ -192,12 +193,12 @@ where
CheckItem`ToRelayoutItems _ _ _ items
= items
WItemHandle`ToRelayoutItems controlKind isVisible itemH=:{wItemPtr`,wItemPos`,wItemSize`,wItemSelect`,wItemShow`} items
WItemHandle`ToRelayoutItems controlKind isAble isVisible itemH=:{wItemPtr`,wItemPos`,wItemSize`,wItemSelect`,wItemShow`} items
#! item = { rliItemKind = controlKind
, rliItemPtr = wItemPtr`
, rliItemPos = wItemPos`
, rliItemSize = wItemSize`
, rliItemSelect = wItemSelect`
, rliItemSelect = isAble`
, rliItemShow = isVisible`
, rliItemInfo = info
, rliItemLook = look
......@@ -205,25 +206,26 @@ where
}
= [item:items]
where
isAble` = isAble && wItemSelect`
isVisible` = isVisible && wItemShow`
(info,look,items`) = getinfo controlKind isVisible` itemH
(info,look,items`) = getinfo controlKind isAble` isVisible` itemH
getinfo :: !ControlKind !Bool !WItemHandle` -> (CompoundInfo,LookInfo,![RelayoutItem])
getinfo IsCompoundControl isVisible {wItemInfo`,wItems`}
= (info,info.compoundLookInfo.compoundLook,WElementHandles`ToRelayoutItems isVisible wItems` [])
getinfo :: !ControlKind !Bool !Bool !WItemHandle` -> (CompoundInfo,LookInfo,![RelayoutItem])
getinfo IsCompoundControl isAble isVisible {wItemInfo`,wItems`}
= (info,info.compoundLookInfo.compoundLook,WElementHandles`ToRelayoutItems isAble isVisible wItems` [])
where
info = getWItemCompoundInfo` wItemInfo`
getinfo IsCustomButtonControl _ {wItemInfo`}
getinfo IsCustomButtonControl _ _ {wItemInfo`}
= (undef,(getWItemCustomButtonInfo` wItemInfo`).cButtonInfoLook,[])
getinfo IsCustomControl _ {wItemInfo`}
getinfo IsCustomControl _ _ {wItemInfo`}
= (undef,(getWItemCustomInfo` wItemInfo`).customInfoLook,[])
getinfo IsLayoutControl isVisible {wItems`}
= (undef,undef,WElementHandles`ToRelayoutItems isVisible wItems` [])
getinfo _ _ _
getinfo IsLayoutControl isAble isVisible {wItems`}
= (undef,undef,WElementHandles`ToRelayoutItems isAble isVisible wItems` [])
getinfo _ _ _ _
= (undef,undef,[])
WElementHandle`ToRelayoutItems isVisible (WRecursiveHandle` itemHs _) items
= WElementHandles`ToRelayoutItems isVisible itemHs items
WElementHandle`ToRelayoutItems isAble isVisible (WRecursiveHandle` itemHs _) items
= WElementHandles`ToRelayoutItems isAble isVisible itemHs items
WElementHandles`ToRelayoutItems _ _ items
WElementHandles`ToRelayoutItems _ _ _ items
= items
......@@ -20,8 +20,7 @@ from oswindow import OSWindowMetrics, Font
, rliItems :: ![RelayoutItem] // If the control kind is Is(Compound/Layout)Control: its elements; otherwise: []
}
relayoutItems :: !OSWindowMetrics !Bool !Rect !Rect !Point2 !Point2 !OSWindowPtr ![RelayoutItem] ![RelayoutItem] !*OSToolbox
-> (!OSRgnHandle,!*OSToolbox)
relayoutItems :: !OSWindowMetrics !Rect !Rect !Point2 !Point2 !OSWindowPtr ![RelayoutItem] ![RelayoutItem] !*OSToolbox -> (!OSRgnHandle,!*OSToolbox)
/* relayoutItems resizes and moves changed items.
The two Rect arguments are the window frames in which the elements reside.
The two Point2 arguments are the positions of the parent window/compound.
......
......@@ -49,8 +49,8 @@ relayoutFatalError function error
* the area to be updated equals validRegion - invalidRegion (so if its empty, then no update is required)
relayoutItems returns the update region.
*/
relayoutItems :: !OSWindowMetrics !Bool !Rect !Rect !Point2 !Point2 !OSWindowPtr ![RelayoutItem] ![RelayoutItem] !*OSToolbox -> (!OSRgnHandle,!*OSToolbox)
relayoutItems wMetrics isAble oldFrame newFrame oldParentPos newParentPos wPtr oldHs newHs tb
relayoutItems :: !OSWindowMetrics !Rect !Rect !Point2 !Point2 !OSWindowPtr ![RelayoutItem] ![RelayoutItem] !*OSToolbox -> (!OSRgnHandle,!*OSToolbox)
relayoutItems wMetrics oldFrame newFrame oldParentPos newParentPos wPtr oldHs newHs tb
#! (clipRgn,tb) = osnewrectrgn newFrame tb
#! (validRgn,tb) = osnewrectrgn zero tb
#! (invalidRgn,tb) = osnewrectrgn zero tb
......@@ -58,9 +58,9 @@ relayoutItems wMetrics isAble oldFrame newFrame oldParentPos newParentPos wPtr o
#! picture = packPicture zero defaultPen True osPict tb
#! ((clipRgn,validRgn,invalidRgn),picture)
= accClipPicture (toRegion (RectToRectangle newFrame))
(relayoutItems` wPtr wMetrics isAble newArea (oldFrame,oldParentPos,oldHs)
(newFrame,newParentPos,newHs)
(clipRgn,validRgn,invalidRgn)
(relayoutItems` wPtr wMetrics newArea (oldFrame,oldParentPos,oldHs)
(newFrame,newParentPos,newHs)
(clipRgn,validRgn,invalidRgn)
) picture
#! (_,_,_,osPict,tb)= unpackPicture picture
#! tb = OSreleaseWindowPictContext wPtr osPict tb
......@@ -70,37 +70,39 @@ relayoutItems wMetrics isAble oldFrame newFrame oldParentPos newParentPos wPtr o
where
newArea = SubtractRects newFrame oldFrame
relayoutItems` :: !OSWindowPtr !OSWindowMetrics !Bool ![Rect] !(!Rect,!Point2,![RelayoutItem]) !(!Rect,!Point2,![RelayoutItem])
relayoutItems` :: !OSWindowPtr !OSWindowMetrics ![Rect] !(!Rect,!Point2,![RelayoutItem]) !(!Rect,!Point2,![RelayoutItem])
!(!OSRgnHandle,!OSRgnHandle,!OSRgnHandle) !*Picture
-> (!(!OSRgnHandle,!OSRgnHandle,!OSRgnHandle),!*Picture)
relayoutItems` wPtr wMetrics isAble newArea (oldFrame,oldParentPos,[oldH:oldHs]) (newFrame,newParentPos,[newH:newHs]) rgnHs picture
# (rgnHs,picture) = relayoutItem wPtr wMetrics isAble newArea (oldFrame,oldParentPos,oldH) (newFrame,newParentPos,newH) rgnHs picture
# (rgnHs,picture) = relayoutItems` wPtr wMetrics isAble newArea (oldFrame,oldParentPos,oldHs) (newFrame,newParentPos,newHs) rgnHs picture
relayoutItems` wPtr wMetrics newArea (oldFrame,oldParentPos,[oldH:oldHs]) (newFrame,newParentPos,[newH:newHs]) rgnHs picture
# (rgnHs,picture) = relayoutItem wPtr wMetrics newArea (oldFrame,oldParentPos,oldH) (newFrame,newParentPos,newH) rgnHs picture
# (rgnHs,picture) = relayoutItems` wPtr wMetrics newArea (oldFrame,oldParentPos,oldHs) (newFrame,newParentPos,newHs) rgnHs picture
= (rgnHs,picture)
where
relayoutItem :: !OSWindowPtr !OSWindowMetrics !Bool ![Rect] !(!Rect,!Point2,!RelayoutItem) !(!Rect,!Point2,!RelayoutItem)
relayoutItem :: !OSWindowPtr !OSWindowMetrics ![Rect] !(!Rect,!Point2,!RelayoutItem) !(!Rect,!Point2,!RelayoutItem)
!(!OSRgnHandle,!OSRgnHandle,!OSRgnHandle) !*Picture
-> (!(!OSRgnHandle,!OSRgnHandle,!OSRgnHandle),!*Picture)
relayoutItem wPtr wMetrics isAble newArea old=:(_,_,{rliItemKind=k1}) new=:(_,_,{rliItemKind=k2}) rgnHs picture
| k1==k2 = relayout wPtr wMetrics isAble newArea k1 old new rgnHs picture
| otherwise = relayoutFatalError "relayoutItem" "mismatching RelayoutItems"
relayoutItem wPtr wMetrics newArea old=:(_,_,{rliItemShow,rliItemKind=k1}) new=:(_,_,{rliItemKind=k2}) rgnHs picture
| k1<>k2 = relayoutFatalError "relayoutItem" "mismatching RelayoutItems"
// | not rliItemShow = (rgnHs,picture) // the items are invisible, so nothing needs to be relayn out
| otherwise = relayout wPtr wMetrics newArea k1 old new rgnHs picture
where
/* relayout assumes that the two RelayoutItem arguments
have the same ControlKind (fifth argument) and differ only in size or position or both.
In addition, it can be assumed safely that the element is visible.
*/
relayout :: !OSWindowPtr !OSWindowMetrics !Bool ![Rect] !ControlKind !(!Rect,!Point2,!RelayoutItem) !(!Rect,!Point2,!RelayoutItem)
relayout :: !OSWindowPtr !OSWindowMetrics ![Rect] !ControlKind !(!Rect,!Point2,!RelayoutItem) !(!Rect,!Point2,!RelayoutItem)