Layer class
This class is used to set the position and size of child elements.
Each child element has three values associated with each axis: {left, right, width} on the horizontal axis, and {top, bottom, height} on the vertical axis. Precisely two of three values may be set at a time, or the system will be over- or under-contrained. For this reason, the following methods are provided for setting these values:
- {@link Layout.Layer#setLeftRight}
- {@link Layout.Layer#setLeftWidth}
- {@link Layout.Layer#setRightWidth}
- {@link Layout.Layer#setTopBottom}
- {@link Layout.Layer#setTopHeight}
- {@link Layout.Layer#setBottomHeight}
By default, each layer is set to fill the entire parent (i.e., {left, top, right, bottom} = {0, 0, 0, 0}).
class Layer { dart_html.Element container, child; Object userObject; bool setLeft = false, setRight = false, setTop = false, setBottom = false, setWidth = false, setHeight = false; bool setTargetLeft = true, setTargetRight = true, setTargetTop = true, setTargetBottom = true, setTargetWidth = false, setTargetHeight = false; Unit leftUnit, topUnit, rightUnit, bottomUnit, widthUnit, heightUnit; Unit targetLeftUnit = Unit.PX, targetTopUnit = Unit.PX, targetRightUnit = Unit.PX, targetBottomUnit = Unit.PX, targetWidthUnit, targetHeightUnit; double left = 0.0, top = 0.0, right = 0.0, bottom = 0.0, width = 0.0, height = 0.0; double sourceLeft = 0.0, sourceTop = 0.0, sourceRight = 0.0, sourceBottom = 0.0, sourceWidth = 0.0, sourceHeight = 0.0; double targetLeft = 0.0, targetTop = 0.0, targetRight = 0.0, targetBottom = 0.0, targetWidth = 0.0, targetHeight = 0.0; Alignment hPos = Alignment.STRETCH, vPos = Alignment.STRETCH; bool visible = true; Layer(dart_html.Element container, dart_html.Element child, Object userObject) { this.container = container; this.child = child; this.userObject = userObject; } /** * Gets the container element associated with this layer. * * <p> * This is the element that sits between the parent and child elements. It * is normally necessary to operate on this element only when you need to * modify CSS properties that are not directly modeled by the Layer class. * </p> * * @return the container element */ dart_html.Element getContainerElement() { return container; } /** * Gets the user-data associated with this layer. * * @return the layer's user-data object */ Object getUserObject() { return this.userObject; } /** * Sets the layer's bottom and height values. * * @param bottom * @param bottomUnit * @param height * @param heightUnit */ void setBottomHeight(double bottom, Unit bottomUnit, double height, Unit heightUnit) { this.setTargetBottom = this.setTargetHeight = true; this.setTargetTop = false; this.targetBottom = bottom; this.targetHeight = height; this.targetBottomUnit = bottomUnit; this.targetHeightUnit = heightUnit; } /** * Sets the child element's horizontal position within the layer. * * @param position */ void setChildHorizontalPosition(Alignment position) { this.hPos = position; } /** * Sets the child element's vertical position within the layer. * * @param position */ void setChildVerticalPosition(Alignment position) { this.vPos = position; } /** * Sets the layer's left and right values. * * @param left * @param leftUnit * @param right * @param rightUnit */ void setLeftRight(double left, Unit leftUnit, double right, Unit rightUnit) { this.setTargetLeft = this.setTargetRight = true; this.setTargetWidth = false; this.targetLeft = left; this.targetRight = right; this.targetLeftUnit = leftUnit; this.targetRightUnit = rightUnit; } /** * Sets the layer's left and width values. * * @param left * @param leftUnit * @param width * @param widthUnit */ void setLeftWidth(double left, Unit leftUnit, double width, Unit widthUnit) { this.setTargetLeft = this.setTargetWidth = true; this.setTargetRight = false; this.targetLeft = left; this.targetWidth = width; this.targetLeftUnit = leftUnit; this.targetWidthUnit = widthUnit; } /** * Sets the layer's right and width values. * * @param right * @param rightUnit * @param width * @param widthUnit */ void setRightWidth(double right, Unit rightUnit, double width, Unit widthUnit) { this.setTargetRight = this.setTargetWidth = true; this.setTargetLeft = false; this.targetRight = right; this.targetWidth = width; this.targetRightUnit = rightUnit; this.targetWidthUnit = widthUnit; } /** * Sets the layer's top and bottom values. * * @param top * @param topUnit * @param bottom * @param bottomUnit */ void setTopBottom(double top, Unit topUnit, double bottom, Unit bottomUnit) { this.setTargetTop = this.setTargetBottom = true; this.setTargetHeight = false; this.targetTop = top; this.targetBottom = bottom; this.targetTopUnit = topUnit; this.targetBottomUnit = bottomUnit; } /** * Sets the layer's top and height values. * * @param top * @param topUnit * @param height * @param heightUnit */ void setTopHeight(double top, Unit topUnit, double height, Unit heightUnit) { this.setTargetTop = this.setTargetHeight = true; this.setTargetBottom = false; this.targetTop = top; this.targetHeight = height; this.targetTopUnit = topUnit; this.targetHeightUnit = heightUnit; } /** * Sets the layer's visibility. * * @param visible */ void setVisible(bool visible) { this.visible = visible; } }
Constructors
new Layer(Element container, Element child, Object userObject) #
Creates a new Object instance.
Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.
Layer(dart_html.Element container, dart_html.Element child, Object userObject) { this.container = container; this.child = child; this.userObject = userObject; }
Properties
double bottom #
double left = 0.0, top = 0.0, right = 0.0, bottom = 0.0
Element child #
dart_html.Element container, child
Element container #
dart_html.Element container
double height #
double left = 0.0, top = 0.0, right = 0.0, bottom = 0.0, width = 0.0, height = 0.0
double left #
double left = 0.0
double right #
double left = 0.0, top = 0.0, right = 0.0
bool setBottom #
bool setLeft = false, setRight = false, setTop = false, setBottom = false
bool setHeight #
bool setLeft = false, setRight = false, setTop = false, setBottom = false, setWidth = false, setHeight = false
bool setLeft #
bool setLeft = false
bool setRight #
bool setLeft = false, setRight = false
bool setTargetBottom #
bool setTargetLeft = true, setTargetRight = true, setTargetTop = true, setTargetBottom = true
bool setTargetHeight #
bool setTargetLeft = true, setTargetRight = true, setTargetTop = true, setTargetBottom = true, setTargetWidth = false, setTargetHeight = false
bool setTargetLeft #
bool setTargetLeft = true
bool setTargetRight #
bool setTargetLeft = true, setTargetRight = true
bool setTargetTop #
bool setTargetLeft = true, setTargetRight = true, setTargetTop = true
bool setTargetWidth #
bool setTargetLeft = true, setTargetRight = true, setTargetTop = true, setTargetBottom = true, setTargetWidth = false
bool setTop #
bool setLeft = false, setRight = false, setTop = false
bool setWidth #
bool setLeft = false, setRight = false, setTop = false, setBottom = false, setWidth = false
double sourceBottom #
double sourceLeft = 0.0, sourceTop = 0.0, sourceRight = 0.0, sourceBottom = 0.0
double sourceHeight #
double sourceLeft = 0.0, sourceTop = 0.0, sourceRight = 0.0, sourceBottom = 0.0, sourceWidth = 0.0, sourceHeight = 0.0
double sourceLeft #
double sourceLeft = 0.0
double sourceRight #
double sourceLeft = 0.0, sourceTop = 0.0, sourceRight = 0.0
double sourceTop #
double sourceLeft = 0.0, sourceTop = 0.0
double sourceWidth #
double sourceLeft = 0.0, sourceTop = 0.0, sourceRight = 0.0, sourceBottom = 0.0, sourceWidth = 0.0
double targetBottom #
double targetLeft = 0.0, targetTop = 0.0, targetRight = 0.0, targetBottom = 0.0
Unit targetBottomUnit #
Unit targetLeftUnit = Unit.PX, targetTopUnit = Unit.PX, targetRightUnit = Unit.PX, targetBottomUnit = Unit.PX
double targetHeight #
double targetLeft = 0.0, targetTop = 0.0, targetRight = 0.0, targetBottom = 0.0, targetWidth = 0.0, targetHeight = 0.0
Unit targetHeightUnit #
Unit targetLeftUnit = Unit.PX, targetTopUnit = Unit.PX, targetRightUnit = Unit.PX, targetBottomUnit = Unit.PX, targetWidthUnit, targetHeightUnit
double targetLeft #
double targetLeft = 0.0
double targetRight #
double targetLeft = 0.0, targetTop = 0.0, targetRight = 0.0
Unit targetRightUnit #
Unit targetLeftUnit = Unit.PX, targetTopUnit = Unit.PX, targetRightUnit = Unit.PX
double targetTop #
double targetLeft = 0.0, targetTop = 0.0
double targetWidth #
double targetLeft = 0.0, targetTop = 0.0, targetRight = 0.0, targetBottom = 0.0, targetWidth = 0.0
Unit targetWidthUnit #
Unit targetLeftUnit = Unit.PX, targetTopUnit = Unit.PX, targetRightUnit = Unit.PX, targetBottomUnit = Unit.PX, targetWidthUnit
double top #
double left = 0.0, top = 0.0
Object userObject #
Object userObject
bool visible #
bool visible = true
double width #
double left = 0.0, top = 0.0, right = 0.0, bottom = 0.0, width = 0.0
Methods
Element getContainerElement() #
Gets the container element associated with this layer.
This is the element that sits between the parent and child elements. It is normally necessary to operate on this element only when you need to modify CSS properties that are not directly modeled by the Layer class.
@return the container element
dart_html.Element getContainerElement() { return container; }
Object getUserObject() #
Gets the user-data associated with this layer.
@return the layer's user-data object
Object getUserObject() { return this.userObject; }
void setBottomHeight(double bottom, Unit bottomUnit, double height, Unit heightUnit) #
Sets the layer's bottom and height values.
@param bottom @param bottomUnit @param height @param heightUnit
void setBottomHeight(double bottom, Unit bottomUnit, double height, Unit heightUnit) { this.setTargetBottom = this.setTargetHeight = true; this.setTargetTop = false; this.targetBottom = bottom; this.targetHeight = height; this.targetBottomUnit = bottomUnit; this.targetHeightUnit = heightUnit; }
void setChildHorizontalPosition(Alignment position) #
Sets the child element's horizontal position within the layer.
@param position
void setChildHorizontalPosition(Alignment position) { this.hPos = position; }
void setChildVerticalPosition(Alignment position) #
Sets the child element's vertical position within the layer.
@param position
void setChildVerticalPosition(Alignment position) { this.vPos = position; }
void setLeftRight(double left, Unit leftUnit, double right, Unit rightUnit) #
Sets the layer's left and right values.
@param left @param leftUnit @param right @param rightUnit
void setLeftRight(double left, Unit leftUnit, double right, Unit rightUnit) { this.setTargetLeft = this.setTargetRight = true; this.setTargetWidth = false; this.targetLeft = left; this.targetRight = right; this.targetLeftUnit = leftUnit; this.targetRightUnit = rightUnit; }
void setLeftWidth(double left, Unit leftUnit, double width, Unit widthUnit) #
Sets the layer's left and width values.
@param left @param leftUnit @param width @param widthUnit
void setLeftWidth(double left, Unit leftUnit, double width, Unit widthUnit) { this.setTargetLeft = this.setTargetWidth = true; this.setTargetRight = false; this.targetLeft = left; this.targetWidth = width; this.targetLeftUnit = leftUnit; this.targetWidthUnit = widthUnit; }
void setRightWidth(double right, Unit rightUnit, double width, Unit widthUnit) #
Sets the layer's right and width values.
@param right @param rightUnit @param width @param widthUnit
void setRightWidth(double right, Unit rightUnit, double width, Unit widthUnit) { this.setTargetRight = this.setTargetWidth = true; this.setTargetLeft = false; this.targetRight = right; this.targetWidth = width; this.targetRightUnit = rightUnit; this.targetWidthUnit = widthUnit; }
void setTopBottom(double top, Unit topUnit, double bottom, Unit bottomUnit) #
Sets the layer's top and bottom values.
@param top @param topUnit @param bottom @param bottomUnit
void setTopBottom(double top, Unit topUnit, double bottom, Unit bottomUnit) { this.setTargetTop = this.setTargetBottom = true; this.setTargetHeight = false; this.targetTop = top; this.targetBottom = bottom; this.targetTopUnit = topUnit; this.targetBottomUnit = bottomUnit; }
void setTopHeight(double top, Unit topUnit, double height, Unit heightUnit) #
Sets the layer's top and height values.
@param top @param topUnit @param height @param heightUnit
void setTopHeight(double top, Unit topUnit, double height, Unit heightUnit) { this.setTargetTop = this.setTargetHeight = true; this.setTargetBottom = false; this.targetTop = top; this.targetHeight = height; this.targetTopUnit = topUnit; this.targetHeightUnit = heightUnit; }
void setVisible(bool visible) #
Sets the layer's visibility.
@param visible
void setVisible(bool visible) { this.visible = visible; }