{-# LANGUAGE DeriveDataTypeable #-}moduleYi.Tab(Tab,TabRef,tabWindowsA,tabLayoutManagerA,tabDividerPositionA,tkey,tabMiniWindows,tabFocus,forceTab,mapWindows,tabLayout,tabFoldl,makeTab,makeTab1,)whereimportqualifiedPreludeimportYi.PreludeimportqualifiedData.BinaryasBinaryimportData.Accessor.BasicimportqualifiedData.List.PointedListasPLimportYi.Buffer.Basic(WindowRef)importYi.LayoutimportYi.WindowtypeTabRef=Int-- | A tab, containing a collection of windows.dataTab=Tab{tkey::!TabRef,-- ^ For UI sync; fixes #304tabWindows::!(PL.PointedListWindow),-- ^ Visible windowstabLayout::!(LayoutWindowRef),-- ^ Current layout. Invariant: must be the layout generated by 'tabLayoutManager', up to changing the 'divPos's.tabLayoutManager::!AnyLayoutManager-- ^ layout manager (for regenerating the layout when we add/remove windows)}derivingTypeabletabFocus::Tab->WindowtabFocus=PL.focus.tabWindows-- | Returns a list of all mini windows associated with the given tabtabMiniWindows::Tab->[Window]tabMiniWindows=Prelude.filterisMini.toList.tabWindows-- | Accessor for the windows. If the windows (but not the focus) have changed when setting, then a relayout will be triggered to preserve the internal invariant.tabWindowsA::AccessorTab(PL.PointedListWindow)tabWindowsA=fromSetGetsettergetterwheresetterwst=relayoutIf(toListws/=toList(tabWindowst))(t{tabWindows=ws})getter=tabWindows-- | Accessor for the layout manager. When setting, will trigger a relayout if the layout manager has changed.tabLayoutManagerA::AccessorTabAnyLayoutManagertabLayoutManagerA=fromSetGetsettergetterwheresetterlmt=relayoutIf(lm/=tabLayoutManagert)(t{tabLayoutManager=lm})getter=tabLayoutManager-- | Gets / sets the position of the divider with the given reference. The caller must ensure that the DividerRef is valid, otherwise an error will (might!) occur.tabDividerPositionA::DividerRef->AccessorTabDividerPositiontabDividerPositionAref=dividerPositionAref.fromSetGet(\lt->t{tabLayout=l})tabLayoutrelayoutIf::Bool->Tab->TabrelayoutIfFalset=trelayoutIfTruet=relayouttrelayout::Tab->Tabrelayoutt=t{tabLayout=buildLayout(tabWindowst)(tabLayoutManagert)(tabLayoutt)}instanceBinary.BinaryTabwhereput(Tabtkws__)=Binary.puttk>>Binary.putwsget=makeTab<$>Binary.get<*>Binary.get-- | Equality on tab identity (the 'tkey')instanceEqTabwhere(==)t1t2=tkeyt1==tkeyt2instanceShowTabwhereshowt="Tab "++show(tkeyt)-- | A specialised version of "fmap".mapWindows::(Window->Window)->Tab->TabmapWindowsf=modifytabWindowsA(fmapf)-- | Forces all windows in the tabforceTab::Tab->TabforceTabt=foldrseqt(t^.tabWindowsA)-- | Folds over the windows in the tabtabFoldl::(a->Window->a)->a->Tab->atabFoldlfzt=foldlfz(t^.tabWindowsA)-- -- | Run the layout on the given tab, for the given aspect ratiobuildLayout::PL.PointedListWindow->AnyLayoutManager->LayoutWindowRef->LayoutWindowRefbuildLayoutwsml=pureLayoutml.fmapwkey.Prelude.filter(not.isMini).toList$ws-- | Make a tab from multiple windowsmakeTab::TabRef->PL.PointedListWindow->TabmakeTabkeyws=Tabkeyws(buildLayoutwsinitialinitial)initial-- | Make a tab from one windowmakeTab1::TabRef->Window->TabmakeTab1keywin=makeTabkey(PL.singletonwin)