Example #1
0
        protected override void OnSizeAllocated(Rectangle allocation)
        {
            base.OnSizeAllocated(allocation);

            int vwidth         = vScrollBar.Visible ? vScrollBar.Requisition.Width : 0;
            int hheight        = hScrollBar.Visible ? hScrollBar.Requisition.Height : 0;
            var childRectangle = new Rectangle(allocation.X + 1, allocation.Y + 1, allocation.Width - vwidth - 1, allocation.Height - hheight - 1);

            if (Child != null)
            {
                Child.SizeAllocate(childRectangle);
            }
            if (vScrollBar.Visible)
            {
                int right           = childRectangle.Right;
                int vChildTopHeight = -1;
                foreach (var child in children.Where(child => child.ChildPosition == ChildPosition.Top))
                {
                    child.Child.SizeAllocate(new Rectangle(right, childRectangle.Y + vChildTopHeight, allocation.Width - vwidth, child.Child.Requisition.Height));
                    vChildTopHeight += child.Child.Requisition.Height;
                }
                int v = vScrollBar is Scrollbar && hScrollBar.Visible ? hScrollBar.Requisition.Height : 0;
                vScrollBar.SizeAllocate(new Rectangle(right + 1, childRectangle.Y + vChildTopHeight, vwidth, Allocation.Height - v - vChildTopHeight - 1));
                vAdjustment.Value = System.Math.Max(System.Math.Min(vAdjustment.Upper - vAdjustment.PageSize, vAdjustment.Value), vAdjustment.Lower);
            }

            if (hScrollBar.Visible)
            {
                int v = vScrollBar.Visible ? vScrollBar.Requisition.Width : 0;
                hScrollBar.SizeAllocate(new Rectangle(allocation.X, childRectangle.Bottom + 1, Allocation.Width - v, hheight));
                hScrollBar.Value = System.Math.Max(System.Math.Min(hAdjustment.Upper - hAdjustment.PageSize, hScrollBar.Value), hAdjustment.Lower);
            }
        }
		protected override void OnSizeAllocated (Gdk.Rectangle allocation)
		{
			base.OnSizeAllocated (allocation);
			if (allocation.Width > leftMargin + rightMargin + leftPadding + rightPadding) {
				allocation.X += leftMargin + leftPadding;
				allocation.Width -= leftMargin + rightMargin + leftPadding + rightPadding;
			}
			if (allocation.Height > topMargin + bottomMargin + topPadding + bottomPadding) {
				allocation.Y += topMargin + topPadding;
				allocation.Height -= topMargin + bottomMargin + topPadding + bottomPadding;
			}
			if (child != null)
				child.SizeAllocate (allocation);
		}
Example #3
0
 void ShowOverlayWidgetAnimation(double value)
 {
     currentOverlayPosition = Allocation.Y + (int)((double)Allocation.Height * (1f - value));
     overlayWidget.SizeAllocate(new Rectangle(Allocation.X, currentOverlayPosition, Allocation.Width, Allocation.Height));
 }
Example #4
0
        protected override void OnSizeAllocated(Gdk.Rectangle alloc)
        {
            int xbase = alloc.X + (int)BorderWidth;
            int ybase = alloc.Y + (int)BorderWidth;

            base.OnSizeAllocated(alloc);

            int  y       = ybase;
            bool visible = true;

            foreach (object obj in lines)
            {
                if (!visible && !(obj is Expander))
                {
                    continue;
                }

                if (obj is Widget)
                {
                    Gtk.Widget w = (Gtk.Widget)obj;
                    if (!w.Visible)
                    {
                        continue;
                    }

                    Gdk.Rectangle   childalloc;
                    Gtk.Requisition childreq;

                    childreq = w.ChildRequisition;

                    if (obj is Expander)
                    {
                        childalloc.X     = xbase;
                        childalloc.Width = alloc.Width - 2 * (int)BorderWidth;
                        visible          = ((Gtk.Expander)obj).Expanded;
                        y += groupPad;
                    }
                    else
                    {
                        childalloc.X     = xbase + indent;
                        childalloc.Width = lwidth;
                        y += linePad;
                    }
                    childalloc.Y      = y;
                    childalloc.Height = childreq.Height;
                    w.SizeAllocate(childalloc);

                    y += childalloc.Height;
                }
                else if (obj is Pair)
                {
                    Pair p = (Pair)obj;
                    if (!p.Editor.Visible)
                    {
                        p.Label.Hide();
                        continue;
                    }
                    else if (!p.Label.Visible)
                    {
                        p.Label.Show();
                    }

                    Gtk.Requisition lreq, ereq;
                    Gdk.Rectangle   lalloc, ealloc;

                    lreq = p.Label.ChildRequisition;
                    ereq = p.Editor.ChildRequisition;

                    lalloc.X = xbase + indent;
                    if (ereq.Height < lineHeight * 2)
                    {
                        lalloc.Y = y + (ereq.Height - lreq.Height) / 2;
                    }
                    else
                    {
                        lalloc.Y = y + (lineHeight - lreq.Height) / 2;
                    }
                    lalloc.Width  = lwidth;
                    lalloc.Height = lreq.Height;
                    p.Label.SizeAllocate(lalloc);

                    ealloc.X      = lalloc.X + lwidth + hPad;
                    ealloc.Y      = y + Math.Max(0, (lineHeight - ereq.Height) / 2);
                    ealloc.Width  = Math.Max(ewidth, alloc.Width - 2 * (int)BorderWidth - ealloc.X);
                    ealloc.Height = ereq.Height;
                    p.Editor.SizeAllocate(ealloc);

                    y += Math.Max(ereq.Height, lineHeight) + linePad;
                }
            }
        }