Skip to content

Commit

Permalink
Merge pull request #1773 from bryan-m-hughes/timob-8116
Browse files Browse the repository at this point in the history
Timob 8116 minRowHeight and maxRowHeight.
  • Loading branch information
cb1kenobi committed Mar 21, 2012
2 parents 4c936ba + a2c0099 commit eaa000e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
32 changes: 9 additions & 23 deletions mobileweb/titanium/Ti/UI/TableView.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ define(["Ti/_/declare", "Ti/UI/View", "Ti/_/style", "Ti/_/lang","Ti/UI/MobileWeb

var setStyle = style.set,
is = require.is,
isDef = lang.isDef;
isDef = lang.isDef,
refreshSections = function() {
this._refreshSections();
};

return declare("Ti.UI.TableView", View, {

Expand Down Expand Up @@ -375,38 +378,21 @@ define(["Ti/_/declare", "Ti/UI/View", "Ti/_/style", "Ti/_/lang","Ti/UI/MobileWeb
}
},
maxRowHeight: {
post: function(value) {
this._refreshSections();
return value;
},
value: "100%"
post: refreshSections
},
minRowHeight: {
post: function(value) {
this._refreshSections();
return value;
},
value: "0%"
post: refreshSections
},
rowHeight: {
post: function(value) {
this._refreshSections();
return value;
},
post: refreshSections,
value: "50px"
},
separatorColor: {
post: function(value) {
this._refreshSections();
return value;
},
post: refreshSections,
value: "lightGrey"
},
separatorStyle: {
post: function(value) {
this._refreshSections();
return value;
},
post: refreshSections,
value: TableViewSeparatorStyle.SINGLE_LINE
}
}
Expand Down
6 changes: 3 additions & 3 deletions mobileweb/titanium/Ti/UI/TableViewSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ define(["Ti/_/declare", "Ti/_/lang", "Ti/_/UI/Widget", "Ti/_/style","Ti/UI/Mobil
if (this._tableView) {
// Update the row information
var rows = this._rows.children,
tableView = this._tableView;
tableView = this._tableView,
rowsData = this.constants.rows = [];
for (var i = 1; i < rows.length; i += 2) {
var row = rows[i];
row._defaultHeight = tableView.rowHeight;
setStyle(row.domNode, "minHeight", tableView.minRowHeight);
setStyle(row.domNode, "maxHeight", tableView.maxRowHeight);
row._minHeight = tableView.minRowHeight;
row._maxHeight = tableView.maxRowHeight;
rowsData.push(row);
}

Expand Down
21 changes: 17 additions & 4 deletions mobileweb/titanium/Ti/_/UI/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,11 @@ define(
right: getValue("border-right-width") + getValue("padding-right"),
bottom: getValue("border-bottom-width") + getValue("padding-bottom")
};

function constrainValue(value, minValue, maxValue) {
return (isDef(minValue) && minValue > value ? minValue : // Apply the min width
isDef(maxValue) && maxValue < value ? maxValue : value); // Apply the max width
}

// Calculate the width/left properties if width is NOT SIZE
var calculateWidthAfterChildren = false,
Expand All @@ -510,7 +515,7 @@ define(
left = right - width;
}
}
width -= borderSize.left + borderSize.right;
width = constrainValue(width, this._minWidth, this._maxWidth) - borderSize.left - borderSize.right;
}
if (height === UI.SIZE) {
calculateHeightAfterChildren = true;
Expand All @@ -529,7 +534,7 @@ define(
top = bottom - height;
}
}
height -= borderSize.top + borderSize.bottom;
height = constrainValue(height, this._minHeight, this._maxHeight) - borderSize.top - borderSize.bottom;
}

if (this._getContentSize) {
Expand All @@ -543,8 +548,8 @@ define(
} else {
computedSize = this._layout._computedSize;
}
width === UI.SIZE && (width = computedSize.width);
height === UI.SIZE && (height = computedSize.height);
width === UI.SIZE && (width = constrainValue(computedSize.width, this._minWidth, this._maxWidth));
height === UI.SIZE && (height = constrainValue(computedSize.height, this._minHeight, this._maxHeight));
}

if (calculateWidthAfterChildren) {
Expand Down Expand Up @@ -1133,6 +1138,10 @@ define(
}
},

_minHeight: postLayoutProp,

_maxHeight: postLayoutProp,

height: postLayoutProp,

left: postLayoutProp,
Expand Down Expand Up @@ -1173,6 +1182,10 @@ define(
}
},

_minWidth: postLayoutProp,

_maxWidth: postLayoutProp,

width: postLayoutProp,

zIndex: postLayoutProp
Expand Down

0 comments on commit eaa000e

Please sign in to comment.