Commit 617dc9e3 authored by Bas Lijnse's avatar Bas Lijnse

More small layout tweaks

parent 82da3500
itasks.TextView = {
container: false,
paddingTop: 5,
paddingRight: 5,
paddingBottom: 5,
paddingLeft: 5,
initDOMEl: function() {
this.domEl.innerHTML = this.value || '';
},
......@@ -13,6 +17,12 @@ itasks.TextView = {
}
};
itasks.HtmlView = {
//Default padding
paddingTop: 5,
paddingRight: 5,
paddingBottom: 5,
paddingLeft: 5,
initDOMEl: function() {
this.domEl.innerHTML = this.value || '';
},
......@@ -28,6 +38,7 @@ itasks.HtmlView = {
itasks.ProgressBar = {
domTag: 'progress',
width: 'flex',
height: 'wrap',
initDOMEl: function() {
var me = this,
el = this.domEl;
......
......@@ -21,6 +21,7 @@ itasks.TextField = {
};
itasks.TextArea = {
domTag: 'textarea',
height: 150,
initDOMEl: function() {
var me = this,
el = this.domEl;
......@@ -244,7 +245,6 @@ itasks.Slider = {
itasks.Button = {
domTag: 'a',
cssCls: 'button',
container: false,
height: 'wrap',
width: 'wrap',
enabled: true,
......
......@@ -42,7 +42,6 @@ itasks.Dropdown = {
itasks.RadioGroup = {
domTag: 'ul',
cssCls: 'choice-radiogroup',
container: false,
initDOMEl: function() {
var me = this,
el = me.domEl,
......@@ -116,7 +115,6 @@ itasks.Grid = {
cssCls: 'choicegrid',
width: 'flex',
height: 'flex',
container: false,
initDOMEl: function() {
var me = this,
......
......@@ -72,10 +72,8 @@ itasks.Component = {
me.initDOMElSize();
//Set margins and alignment
me.initDOMElMargins();
me.initContainerEl();
if(me.container) {
me.initContainerEl();
}
//Add the the child renderings
me.children.forEach(function(child) {
me.containerEl.appendChild(child.domEl);
......@@ -129,8 +127,7 @@ itasks.Component = {
var me = this,
el = me.domEl,
width = me.width,
height = me.height,
margins = (me.margins && me.margins.split(' ')) || ['0','0','0','0'];
height = me.height;
if(!me.parentCmp) { //Do not set margins on the root component, let the embedding page handle that
return;
......@@ -144,7 +141,7 @@ itasks.Component = {
isLast = (curIdx == lastIdx);
//Set left and right margins as specified
if(me.marginLeft) { el.style.marginLeft = me.marginLeft + 'px' ; }
if(me.marginLeft) { el.style.marginLeft = me.marginLeft + 'px'; }
if(me.marginRight) { el.style.marginRight = me.marginRight + 'px' ; }
//Because vertical borders 'collapse' into each other, we never set the
......@@ -156,9 +153,6 @@ itasks.Component = {
el.style.marginTop = ((me.marginTop || 0) + (me.parentCmp.children[curIdx - 1].marginBottom || 0)) + 'px';
}
//if(me.marginTop) { el.style.marginTop = me.marginTop + 'px' ; }
//if(me.marginBottom) { el.style.marginBottom = me.marginBottom + 'px' ; }
//Set margins to auto based on alignment of parent
if(parentDirection == 'vertical') {
if(width !== 'flex') {
......
......@@ -82,31 +82,31 @@ marginsAttr :: !Int !Int !Int !Int -> UIAttributes
marginsAttr top right bottom left = 'DM'.fromList [("marginTop",JSONInt top),("marginRight",JSONInt right),("marginBottom",JSONInt bottom),("marginLeft",JSONInt left)]
topMarginAttr :: !Int -> UIAttributes
topMarginAttr top = 'DM'.fromList [("topMargin",JSONInt top)]
topMarginAttr top = 'DM'.fromList [("marginTop",JSONInt top)]
rightMarginAttr :: !Int -> UIAttributes
rightMarginAttr right = 'DM'.fromList [("rightMargin",JSONInt right)]
rightMarginAttr right = 'DM'.fromList [("marginRight",JSONInt right)]
bottomMarginAttr :: !Int -> UIAttributes
bottomMarginAttr bottom = 'DM'.fromList [("bottomMargin",JSONInt bottom)]
bottomMarginAttr bottom = 'DM'.fromList [("marginBottom",JSONInt bottom)]
leftMarginAttr :: !Int -> UIAttributes
leftMarginAttr left = 'DM'.fromList [("leftMargin",JSONInt left)]
leftMarginAttr left = 'DM'.fromList [("marginLeft",JSONInt left)]
paddingAttr :: !Int !Int !Int !Int -> UIAttributes
paddingAttr top right bottom left = 'DM'.fromList [("paddingTop",JSONInt top),("paddingRight",JSONInt right),("paddingBottom",JSONInt bottom),("paddingLeft",JSONInt left)]
topPaddingAttr :: !Int -> UIAttributes
topPaddingAttr top = 'DM'.fromList [("topPadding",JSONInt top)]
topPaddingAttr top = 'DM'.fromList [("paddingTop",JSONInt top)]
rightPaddingAttr :: !Int -> UIAttributes
rightPaddingAttr right = 'DM'.fromList [("rightPadding",JSONInt right)]
rightPaddingAttr right = 'DM'.fromList [("paddingRight",JSONInt right)]
bottomPaddingAttr :: !Int -> UIAttributes
bottomPaddingAttr bottom = 'DM'.fromList [("bottomPadding",JSONInt bottom)]
bottomPaddingAttr bottom = 'DM'.fromList [("paddingBottom",JSONInt bottom)]
leftPaddingAttr :: !Int -> UIAttributes
leftPaddingAttr left = 'DM'.fromList [("leftPadding",JSONInt left)]
leftPaddingAttr left = 'DM'.fromList [("paddingLeft",JSONInt left)]
titleAttr :: !String -> UIAttributes
titleAttr title = 'DM'.fromList [("title",JSONString title)]
......
......@@ -34,7 +34,8 @@ setNodeType :: UINodeType -> Layout
// == Changing attributes ===
setAttributes :: UIAttributes -> Layout
copyAttributes :: NodePath NodePath -> Layout
copyAttributes :: [String] NodePath NodePath -> Layout
copyAllAttributes :: NodePath NodePath -> Layout
// === Changing the structure of the tree ===
......
......@@ -59,10 +59,18 @@ where
= (ChangeUI attrChanges itemChanges,s)
layout (change,s) = (change,s)
copyAttributes :: NodePath NodePath -> Layout
copyAttributes src dst = layout //TODO: Also handle attribute updates in the src location, and partial replacements along the path
copyAttributes :: [String] NodePath NodePath -> Layout
copyAttributes selection src dst = copyAttributes` (Just selection) src dst
copyAllAttributes :: NodePath NodePath -> Layout
copyAllAttributes src dst = copyAttributes` Nothing src dst
copyAttributes` :: (Maybe [String]) NodePath NodePath -> Layout
copyAttributes` selection src dst = layout //TODO: Also handle attribute updates in the src location, and partial replacements along the path
where
layout (ReplaceUI ui,s) = case selectAttr src ui of
layout (ReplaceUI ui,s) = case selectAttr src ui of
Just attr = (ReplaceUI (addAttr attr dst ui),s)
Nothing = (ReplaceUI ui,s)
layout (change,s) = (change,s)
......@@ -72,11 +80,14 @@ where
| s < length items = selectAttr ss (items !! s)
= Nothing
addAttr extra [] (UI type attr items) = UI type (foldl (\m (k,v) -> 'DM'.put k v m) attr ('DM'.toList extra)) items
addAttr extra [] (UI type attr items)
= UI type (foldl (\m (k,v) -> 'DM'.put k v m) attr [(k,v) \\ (k,v) <- 'DM'.toList extra | condition k]) items
addAttr extra [s:ss] (UI type attr items)
| s < length items = UI type attr (updateAt s (addAttr extra ss (items !! s)) items)
= UI type attr items
condition = maybe (const True) (flip isMember) selection
wrapUI :: UINodeType -> Layout
wrapUI type = layout
where
......
......@@ -14,8 +14,8 @@ where
arrangeWithSideBar :: !Int !UISide !Int !Bool -> Layout
arrangeWithSideBar index side size resize = sequenceLayouts
[wrapUI UIPanel //Push the current container down a level
,copyAttributes [0] [] //Keep the attributes from the original UI
[wrapUI UIPanel //Push the current container down a level
,copyAllAttributes [0] [] //Keep the attributes from the original UI
,setAttributes (directionAttr direction)
,insertSubAt [sidePanelIndex] (ui UIComponent) //Make sure we have a target for the move
,moveSubAt [mainPanelIndex,index] [sidePanelIndex,0]
......
......@@ -35,7 +35,7 @@ finalizeInteract = conditionalLayout isInteract layout
where
layout = sequenceLayouts
[layoutSubAt [1] finalizeEditor
,copyAttributes [0] []
,copyAttributes ["title"] [0] []
,removeEmptyPrompt
,setNodeType UIPanel
]
......@@ -161,7 +161,7 @@ labelControl attributes
Just (JSONString label)
# optional = maybe False (\(JSONBool b) -> b) ('DM'.get "optional" attributes)
# (UI type attr items) = stringDisplay (formatLabel optional label)
# attr = 'DM'.unions [widthAttr (ExactSize LABEL_WIDTH),leftMarginAttr 4, attr]
# attr = 'DM'.unions [widthAttr (ExactSize LABEL_WIDTH), attr]
= Just (UI type attr items)
_ = Nothing
......
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