Commit 1fd727ce authored by Bas Lijnse's avatar Bas Lijnse

Merge branch '45-close-actions-inside-tab-sets-should-be-put-on-the-tabs-themselves' into 'master'

Move close buttons to the tab if they are in the topmost panel in a tabset

See merge request !82
parents da225ba4 3fbf6419
......@@ -35,7 +35,7 @@ tonic = tonicDashboard []
tonicDashboard :: [TaskAppRenderer] -> Task ()
tonicDashboard rs = ((tonicStaticBrowser rs <<@ Title "Static Blueprints")
-||- (tonicDynamicBrowser rs <<@ Title "Dynamic Blueprints")) <<@ ArrangeWithTabs
-||- (tonicDynamicBrowser rs <<@ Title "Dynamic Blueprints")) <<@ ArrangeWithTabs False
tonicStaticWorkflow :: [TaskAppRenderer] -> Workflow
tonicStaticWorkflow rs = workflow "Tonic Static Browser" "Tonic Static Browser" (tonicStaticBrowser rs)
......
......@@ -204,7 +204,7 @@ where
//Split the screen space
[arrangeWithSideBar 0 TopSide 200 True
//Layout all dynamically added tasks as tabs
,layoutSubUIs (SelectByPath [1]) arrangeWithTabs
,layoutSubUIs (SelectByPath [1]) (arrangeWithTabs False)
]
addNewTask :: !(SharedTaskList ()) -> Task ()
......
......@@ -68,17 +68,34 @@ from Text.JSON import :: JSONNode
// we want to keep only minimal state. Using an opaque function would require
// keeping track of the full state
//Only match children
SelectChildren :== SelectByDepth 1
:: UISelection
= SelectByPath UIPath //Direct addressing
| SelectChildren
//Select only nodes matching the exact path
= SelectByPath UIPath
//Only match nodes at a given depth
| SelectByDepth Int
//Match any descendents of any depth
| SelectDescendents
//Match nodes of a certain type
| SelectByType UIType
//Match nodes that have a matching attribute
| SelectByAttribute String JSONNode
//Match nodes that have the attribute
| SelectByHasAttribute String
| SelectByNumChildren Int //Mostly to match containers with 0 or 1 children
//Relative selection
//Match nodes with exactly the given number of children
| SelectByNumChildren Int
//Match nodes that match the given selection on traversal of the given path
| SelectRelative UIPath UISelection
//Check if another (sub)-selection exists
//For example, to select child nodes that have a UIAction child you use:
//SelectAND
// SelectChildren
// (SelectByContains
// SelectAND
// (SelectByType UIAction)
// (SelectByDepth 2)
// )
| SelectByContains UISelection
//No-op
| SelectNone
......
......@@ -24,8 +24,7 @@ derive JSONDecode LayoutState, LayoutTree, MvUI, MvUIChild
//Test if a specific UI at a path is in the selection
inUISelection :: UISelection UIPath UI -> Bool
inUISelection (SelectByPath p) path _ = p === path
inUISelection (SelectChildren) [_] _ = True
inUISelection (SelectChildren) _ _ = False
inUISelection (SelectByDepth n) p _ = length p == n
inUISelection (SelectDescendents) [_:_] _ = True
inUISelection (SelectDescendents) _ _ = False
inUISelection (SelectByType t) _ (UI type _ _) = t === type
......
......@@ -12,8 +12,9 @@ from iTasks.WF.Definition import :: Task
/**
* Create a tabset with all child items as separate tabs
* The flag denotes whether close buttons should be lifted to the tabs
*/
arrangeWithTabs :: Layout
arrangeWithTabs :: Bool -> Layout
/**
* Extract one child item and put it in a separate panel at the side of the screen
......@@ -62,7 +63,7 @@ beforeStep :: Layout -> Layout
insertToolBar :: [String] -> Layout
//Convenient annotatation types
:: ArrangeWithTabs = ArrangeWithTabs
:: ArrangeWithTabs = ArrangeWithTabs Bool
instance tune ArrangeWithTabs Task
:: ArrangeWithSideBar = ArrangeWithSideBar !Int !UISide !Int !Bool
......
......@@ -10,8 +10,37 @@ import StdBool
from StdFunc import id, const, o
from iTasks.Internal.TaskEval import :: TaskEvalOpts(..), :: TonicOpts
arrangeWithTabs :: Layout
arrangeWithTabs = layoutSubUIs (SelectAND (SelectByPath []) (SelectByType UIParallel)) (setUIType UITabSet)
arrangeWithTabs :: Bool -> Layout
arrangeWithTabs closeable = layoutSubUIs
(SelectAND (SelectByPath []) (SelectByType UIParallel))
(sequenceLayouts (setUIType UITabSet)
(if closeable moveCloseToTab idLayout))
where
moveCloseToTab = layoutSubUIs //Only on children directly containing a clos action
(SelectAND
SelectChildren
(SelectByContains
(SelectAND
(SelectByDepth 2)
selectCloseButton
)
)
)
reallyMoveCloseToTab
selectCloseButton = SelectAND
(SelectByType UIAction)
(SelectByAttribute "actionId" (JSONString "Close"))
reallyMoveCloseToTab = foldl1 sequenceLayouts
[moveSubUIs (SelectAND SelectChildren selectCloseButton) [] 0
,layoutSubUIs (SelectByPath [0]) (modifyUIAttributes SelectAll
(\ui->case 'DM'.get "taskId" ui of
Nothing = ui
Just tid = 'DM'.put "closeTaskId" tid ui))
,copySubUIAttributes (SelectKeys ["closeTaskId"]) [0] []
,removeSubUIs (SelectByPath [0])
]
arrangeWithSideBar :: !Int !UISide !Int !Bool -> Layout
arrangeWithSideBar index side size resize = foldl1 sequenceLayouts
......@@ -124,7 +153,7 @@ where
>>= \icon -> return (iconClsAttr ("icon-"+++icon)))
instance tune ArrangeWithTabs Task
where tune ArrangeWithTabs t = tune (ApplyLayout arrangeWithTabs) t
where tune (ArrangeWithTabs b) t = tune (ApplyLayout (arrangeWithTabs b)) t
instance tune ArrangeWithSideBar Task
where
......
......@@ -61,7 +61,7 @@ runTests suites = application {WebImage|src="/testbench.png",alt="iTasks Testben
,checkExampleApplications <<@ Title "Example applications"
,viewQualityMetrics <<@ Title "Metrics"
,exploreCode <<@ Title "Code"
] <<@ ArrangeWithTabs
] <<@ ArrangeWithTabs False
) @! ()
where
runInteractiveTests
......@@ -166,13 +166,13 @@ where
viewModule (name,MainModule)
= allTasks
[viewSharedInformation (Title "Implementation") [] (sdsFocus (LIBRARY_PATH,name) moduleImplementation)
] <<@ ArrangeWithTabs
] <<@ ArrangeWithTabs False
viewModule (name,AuxModule)
= allTasks
[viewSharedInformation (Title "Definition") [] (sdsFocus (LIBRARY_PATH,name) moduleDefinition)
,viewSharedInformation (Title "Implementation") [] (sdsFocus (LIBRARY_PATH,name) moduleImplementation)
] <<@ ArrangeWithTabs
] <<@ ArrangeWithTabs False
//Begin metrics
//The following section should probably be moved to a separate module
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment