Пример #1
0
		public override Bound Apply (StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
		{
			base.Apply (stylesheet, styleBound, maxBound);

			float offset = _behaviour.OffsetByIndex;
			_view.ContentOffset = new PointF (0, offset);
			return styleBound;
		}
Пример #2
0
        protected override Bound LayoutChildren(StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
        {
           Bound bound = LayoutBehaviour.Vertical(stylesheet, this, Childrens, styleBound, maxBound, true);

            if (Childrens.Count > 0)
            {
                Behavour.Borders.Add(Childrens[0].Frame.Top);
                foreach (IControl<View> control in Childrens)
                    Behavour.Borders.Add(control.Frame.Bottom);
            }
            Behavour.ScrolledMeasure = bound.Height;
            return bound;
        }
Пример #3
0
		protected override Bound LayoutChildren (StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
		{
			_behaviour.ScrolledMeasure = styleBound.Height;

			Bound bound = LayoutBehaviour.Vertical (stylesheet, this, _controls, styleBound, maxBound, true);

			if (_controls.Count > 0) {
				_behaviour.Borders.Add (_controls [0].Frame.Top);
				foreach (var control in _controls) 
					_behaviour.Borders.Add(control.Frame.Bottom);
			}

			return bound;
		}
Пример #4
0
        public override Bound Apply(StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
        {
            var bound = new Bound(BitBrowserApp.Current.Width, BitBrowserApp.Current.Height);

            base.Apply(stylesheet, bound, bound);

			//background color
            _view.SetBackgroundColor(Android.Graphics.Color.White);

            if (OnLoad != null)
                OnLoad.Execute();

            Frame = new Rectangle(0, 0, bound);

            return bound;
        }
Пример #5
0
 protected override Bound LayoutChildren(StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
 {
    return LayoutBehaviour.Dock(stylesheet, this, Childrens, styleBound, maxBound);
 }
Пример #6
0
        public static Bound Vertical(StyleSheet.StyleSheet stylesheet
            , ILayoutable parent
            , IEnumerable<ILayoutable> controls
            , Bound styleBound
            , Bound maxBound
            , bool extensible = false)
        {
            IStyleSheetHelper style = stylesheet.Helper;

            float parentW = styleBound.Width;
            float parentH = styleBound.Height;
            float paddingL = style.Padding<PaddingLeft>(parent, parentW);
            float paddingT = style.Padding<PaddingTop>(parent, parentH);
            float paddingR = style.Padding<PaddingRight>(parent, parentW);
            float paddingB = style.Padding<PaddingBottom>(parent, parentH);
            float borderWidth = style.BorderWidth(parent);

            float off = paddingT + borderWidth;

            foreach (ILayoutable control in controls)
            {
                float w = style.Width(control, parentW);
                float h = style.Height(control, parentH);

                float marginL = style.Margin<MarginLeft>(control, parentW);
                float marginT = style.Margin<MarginTop>(control, parentH);
                float marginR = style.Margin<MarginRight>(control, parentW);
                float marginB = style.Margin<MarginBottom>(control, parentH);

                off += marginT;

                float left = borderWidth + paddingL + marginL;
                float top = off;
                float right = parentW - (paddingR + marginR) - borderWidth;
                float bottom = parentH - (paddingB + marginB) - borderWidth;

                float maxW = right - left;
                maxW = maxW > 0 ? maxW : 0;

                float maxH = extensible ? float.MaxValue : bottom - top;
                maxH = maxH > 0 ? maxH : 0;

                if (!extensible && maxH < h)
                    h = maxH;

                w = w > maxW ? maxW : w;

                Bound bound = control.Apply(stylesheet, new Bound(w, h), new Bound(maxW, maxH));
                w = bound.Width;
                h = bound.Height;

                InitializeImageContainer(stylesheet, control, ref w, ref h);

                if (!extensible && maxH < h)
                    h = maxH;

                if (w < maxW)
                {
                    HorizontalAlign.Align align = style.HorizontalAlign(control);
                    switch (align)
                    {
                        case HorizontalAlign.Align.Left:
                            break;
                        case HorizontalAlign.Align.Central:
                            float delta = (right - left - w) / 2;
                            left += delta;
                            break;
                        case HorizontalAlign.Align.Right:
                            left = right - w;
                            break;
                    }
                }

                control.Frame = new Rectangle(left, top, w, h);

                off += h + marginB;
            }

            return new Bound(styleBound.Width, styleBound.Height, parentW, off + paddingB + borderWidth);
        }
Пример #7
0
        public static Bound Screen(StyleSheet.StyleSheet stylesheet
            , ILayoutable parent
            , ILayoutable control
            , Bound screenBound)
        {
            IStyleSheetHelper style = stylesheet.Helper;

            float parentW = screenBound.Width;
            float parentH = screenBound.Height;
            float paddingL = style.Padding<PaddingLeft>(parent, parentW);
            float paddingT = style.Padding<PaddingTop>(parent, parentH);
            float paddingR = style.Padding<PaddingRight>(parent, parentW);
            float paddingB = style.Padding<PaddingBottom>(parent, parentH);
            float borderWidth = style.BorderWidth(parent);

            float w = style.Width(control, parentW);
            float h = style.Height(control, parentH);
            float marginL = style.Margin<MarginLeft>(control, parentW);
            float marginT = style.Margin<MarginTop>(control, parentH);
            float marginR = style.Margin<MarginRight>(control, parentW);
            float marginB = style.Margin<MarginBottom>(control, parentH);

            InitializeImageContainer(stylesheet, control, ref w, ref h);

            float maxW = parentW - (marginL + marginR) - (paddingL + paddingR) - 2 * borderWidth;
            if (parentW < paddingL + marginL + w + marginR + paddingR + 2 * borderWidth)
                w = maxW;

            float maxH = parentH - (marginT + marginB) - (paddingT + paddingB) - 2 * borderWidth;
            if (parentH < paddingT + marginT + h + marginB + paddingB + 2 * borderWidth)
                h = maxH;

            float l = borderWidth + paddingL + marginL;
            float t = borderWidth + paddingT + marginT;

            Bound bound = control.Apply(stylesheet, new Bound(w, h), new Bound(maxW, maxH));
            w = bound.Width > maxW ? maxW : bound.Width;
            h = bound.Height > maxH ? maxH : bound.Height;

            control.Frame = new Rectangle(l, t, w, h);
            return screenBound;
        }
Пример #8
0
        public static Bound Dock(StyleSheet.StyleSheet stylesheet
            , ILayoutable parent
            , IEnumerable<ILayoutable> controls
            , Bound styleBound
            , Bound maxBound)
        {
            IStyleSheetHelper style = stylesheet.Helper;

            float parentW = styleBound.Width;
            float parentH = styleBound.Height;
            float paddingL = style.Padding<PaddingLeft>(parent, parentW);
            float paddingT = style.Padding<PaddingTop>(parent, parentH);
            float paddingR = style.Padding<PaddingRight>(parent, parentW);
            float paddingB = style.Padding<PaddingBottom>(parent, parentH);
            float borderWidth = style.BorderWidth(parent);

            float layoutL = borderWidth + paddingL;
            float layoutT = borderWidth + paddingT;
            float layoutW = parentW - (paddingL + paddingR) - 2 * borderWidth;
            float layoutH = parentH - (paddingT + paddingB) - 2 * borderWidth;

            foreach (ILayoutable control in controls)
            {
                float w = style.Width(control, parentW);
                float h = style.Height(control, parentH);

                float marginL = style.Margin<MarginLeft>(control, parentW);
                float marginT = style.Margin<MarginTop>(control, parentH);
                float marginR = style.Margin<MarginRight>(control, parentW);
                float marginB = style.Margin<MarginBottom>(control, parentH);

                float maxW = layoutW - (marginL + marginR);
                maxW = maxW > 0 ? maxW : 0;

                float maxH = layoutH - (marginT + marginB);
                maxH = maxH > 0 ? maxH : 0;

                if (layoutW < marginL + w + marginR)
                    w = maxW;
                if (layoutH < marginT + h + marginB)
                    h = maxH;

                Bound bound = control.Apply(stylesheet, new Bound(w, h), new Bound(maxW, maxH));
                w = bound.Width;
                h = bound.Height;

                InitializeImageContainer(stylesheet, control, ref w, ref h);

                if (layoutW < marginL + w + marginR)
                    w = maxW;
                if (layoutH < marginT + h + marginB)
                    h = maxH;

                float offsetL = layoutL;
                float offsetT = layoutT;

                DockAlign.Align align = style.DockAlign(control);
                switch (align)
                {
                    case DockAlign.Align.Left:
                        offsetL += marginL;
                        offsetT += marginT;
                        layoutL = offsetL + w + marginR;
                        layoutW -= marginL + w + marginR;
                        break;
                    case DockAlign.Align.Top:
                        offsetL += marginL;
                        offsetT += marginT;
                        layoutT = offsetT + h + marginB;
                        layoutH -= marginT + h + marginB;
                        break;
                    case DockAlign.Align.Right:
                        offsetL += layoutW - (w + marginR);
                        offsetT += marginT;
                        layoutW -= marginL + w + marginR;
                        break;
                    case DockAlign.Align.Bottom:
                        offsetL += marginL;
                        offsetT += layoutH - (h + marginB);
                        layoutH -= marginT + h + marginB;
                        break;
                }
                control.Frame = new Rectangle(offsetL, offsetT, w, h);
            }

            return styleBound;
        }
Пример #9
0
 public Rectangle(float left, float top, Bound bound)
     : this(left, top, bound.Width, bound.Height)
 {
 }
Пример #10
0
		protected override Bound LayoutChildren (StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
		{
			return LayoutBehaviour.Horizontal (stylesheet, this, _controls, styleBound, maxBound);
		}