Esempio n. 1
0
        void OnChildPreferredSizeChanged()
        {
            IWidgetSurface surface = this;

            if (Parent != null && resizeRequestQueue.Contains(Parent))
            {
                // Size for this widget will be checked when checking the parent
                surface.ResetCachedSizes();
                return;
            }

            // Determine if the size change of the child implies a size change
            // of this widget. If it does, the size change notification
            // has to be propagated to the parent

            var oldWidth  = width;
            var oldHeight = height;

            surface.ResetCachedSizes();

            bool changed = true;

            if (surface.SizeRequestMode == SizeRequestMode.HeightForWidth)
            {
                var nw = surface.GetPreferredWidth();
                if (nw == oldWidth)
                {
                    var nh = surface.GetPreferredHeightForWidth(Backend.Size.Width);
                    if (nh == oldHeight)
                    {
                        changed = false;
                    }
                }
            }
            else
            {
                var nh = surface.GetPreferredHeight();
                if (nh == oldHeight)
                {
                    var nw = surface.GetPreferredWidthForHeight(Backend.Size.Height);
                    if (nw == oldWidth)
                    {
                        changed = false;
                    }
                }
            }
            if (changed)
            {
                NotifySizeChangeToParent();
            }
            else
            {
                QueueForReallocate(this);
            }
        }
Esempio n. 2
0
        protected virtual void OnChildPreferredSizeChanged(Widget w)
        {
            if (Parent != null && (!widthCached || !heightCached))
            {
                Parent.OnChildPreferredSizeChanged(w);
                return;
            }

            var oldWidth  = width;
            var oldHeight = height;

            bool           notifyParent = Parent != null;
            IWidgetSurface surface      = this;

            surface.ResetCachedSizes();

            if (surface.SizeRequestMode == SizeRequestMode.HeightForWidth)
            {
                var nw = surface.GetPreferredWidth();
                if (nw == oldWidth)
                {
                    var nh = surface.GetPreferredHeightForWidth(Backend.Size.Width);
                    if (nh == oldHeight)
                    {
                        notifyParent = false;
                    }
                }
            }
            else
            {
                var nh = surface.GetPreferredHeight();
                if (nh == oldHeight)
                {
                    var nw = surface.GetPreferredWidthForHeight(Backend.Size.Height);
                    if (nw == oldWidth)
                    {
                        notifyParent = false;
                    }
                }
            }
            if (notifyParent)
            {
                if (Parent != null)
                {
                    Parent.OnChildPreferredSizeChanged(this);
                }
            }
            else
            {
                surface.Reallocate();
            }
        }
Esempio n. 3
0
        protected virtual void OnPreferredSizeChanged()
        {
            IWidgetSurface surface = this;

            surface.ResetCachedSizes();
            Backend.UpdateLayout();
            if (Parent != null)
            {
                if (resizeRequestQueue.Count == 0)
                {
                    Application.Invoke(DelayedResizeRequest);
                }
                resizeRequestQueue.Add(this);
            }
        }
Esempio n. 4
0
        protected virtual void OnPreferredSizeChanged()
        {
            // When the preferred size changes, we reset the sizes we have cached
            // The parent also has to be notified of the size change, since it
            // may imply a change of the size of the parent. However, we don't do
            // it immediately, but we queue the resizing request

            IWidgetSurface surface = this;

            surface.ResetCachedSizes();
            Backend.UpdateLayout();
            if (!Application.EngineBackend.HandlesSizeNegotiation)
            {
                NotifySizeChangeToParent();
            }
        }