vertical-alignment middle support added

This commit is contained in:
Vladimir Enchev
2015-10-14 09:42:29 +03:00
parent d2571e124c
commit 19b03bbbb9
6 changed files with 13 additions and 4 deletions

View File

@ -91,10 +91,13 @@ export function test_setting_minHeight_property_from_CSS_is_applied_to_Style() {
} }
export function test_setting_verticalAlignment_property_from_CSS_is_applied_to_Style() { export function test_setting_verticalAlignment_property_from_CSS_is_applied_to_Style() {
test_property_from_CSS_is_applied_to_style("verticalAlignment", "vertical-align", "bottom"); test_property_from_CSS_is_applied_to_style("verticalAlignment", "vertical-align", "bottom");
} }
export function test_setting_verticalAlignment_middle_is_applied_to_Style() {
test_property_from_CSS_is_applied_to_style("verticalAlignment", "vertical-align", "middle");
}
export function test_setting_horizontalAlignment_property_from_CSS_is_applied_to_Style() { export function test_setting_horizontalAlignment_property_from_CSS_is_applied_to_Style() {
test_property_from_CSS_is_applied_to_style("horizontalAlignment", "horizontal-align", "right"); test_property_from_CSS_is_applied_to_style("horizontalAlignment", "horizontal-align", "right");
} }

View File

@ -717,7 +717,7 @@ export class View extends proxy.ProxyObject implements definition.View {
childTop = top + child.marginTop * density; childTop = top + child.marginTop * density;
break; break;
case enums.VerticalAlignment.center: case enums.VerticalAlignment.center || enums.VerticalAlignment.middle:
childTop = top + (bottom - top - childHeight + (child.marginTop - child.marginBottom) * density) / 2; childTop = top + (bottom - top - childHeight + (child.marginTop - child.marginBottom) * density) / 2;
break; break;

5
ui/enums/enums.d.ts vendored
View File

@ -161,6 +161,11 @@
*/ */
export var center: string; export var center: string;
/**
* Same as center. An element should be aligned in the middle.
*/
export var middle: string;
/** /**
* An element should be bottom aligned. * An element should be bottom aligned.
*/ */

View File

@ -41,6 +41,7 @@ export module HorizontalAlignment {
export module VerticalAlignment { export module VerticalAlignment {
export var top = "top"; export var top = "top";
export var center = "center"; export var center = "center";
export var middle = "middle";
export var bottom = "bottom"; export var bottom = "bottom";
export var stretch = "stretch"; export var stretch = "stretch";
} }

View File

@ -114,7 +114,7 @@ export class StackLayout extends common.StackLayout {
var childRight = right - left - paddingRight; var childRight = right - left - paddingRight;
switch (this.verticalAlignment) { switch (this.verticalAlignment) {
case enums.VerticalAlignment.center: case enums.VerticalAlignment.center || enums.VerticalAlignment.middle:
childTop = (bottom - top - this._totalLength) / 2 + paddingTop - paddingBottom; childTop = (bottom - top - this._totalLength) / 2 + paddingTop - paddingBottom;
break; break;

View File

@ -175,7 +175,7 @@ export class DefaultStyler implements definition.stylers.Styler {
gravity |= android.view.Gravity.TOP; gravity |= android.view.Gravity.TOP;
break; break;
case enums.VerticalAlignment.center: case enums.VerticalAlignment.center || enums.VerticalAlignment.middle:
gravity |= android.view.Gravity.CENTER_VERTICAL; gravity |= android.view.Gravity.CENTER_VERTICAL;
break; break;