protected override void OnSizeRequested(ref Gtk.Requisition requisition) { base.OnSizeRequested(ref requisition); IWidgetSurface ws = Frontend.Surface; int h, w; if (ws.SizeRequestMode == SizeRequestMode.HeightForWidth) { w = (int)ws.GetPreferredWidth().MinSize; h = (int)ws.GetPreferredHeightForWidth(w).MinSize; } else { h = (int)ws.GetPreferredHeight().MinSize; w = (int)ws.GetPreferredWidthForHeight(h).MinSize; } if (requisition.Width < w) { requisition.Width = w; } if (requisition.Height < h) { requisition.Height = h; } foreach (var cr in children) { cr.Key.SizeRequest(); } }
internal void AdjustSize() { if (child == null) { return; } IWidgetSurface s = child.Surface; var size = shown ? Size : initialBounds.Size; var w = s.GetPreferredWidth(); if (!shown && !widthSet) { size.Width = w.NaturalSize + padding.HorizontalSpacing; } var h = s.GetPreferredHeightForWidth(size.Width - padding.HorizontalSpacing); if (!shown && !heightSet) { size.Height = h.NaturalSize + padding.VerticalSpacing; } if (w.MinSize + padding.HorizontalSpacing > size.Width) { size.Width = w.MinSize + padding.HorizontalSpacing; } if (h.MinSize + padding.VerticalSpacing > size.Height) { size.Height = h.MinSize + padding.VerticalSpacing; } if (!BackendHost.EngineBackend.HandlesSizeNegotiation || !shown) { shown = true; if (size != Size) { if (locationSet) { Backend.Bounds = new Rectangle(initialBounds.X, initialBounds.Y, size.Width, size.Height); } else { Size = size + Backend.ImplicitMinSize; } } else if (locationSet) { Backend.Move(initialBounds.X, initialBounds.Y); } Backend.SetMinSize(Backend.ImplicitMinSize + new Size(w.MinSize + padding.HorizontalSpacing, h.MinSize + padding.VerticalSpacing)); } }
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); } }
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(); } }
WidgetSize GetPreferredLengthForSize(SizeRequestMode mode, Widget w, double width) { IWidgetSurface surface = w; if (mode == SizeRequestMode.WidthForHeight) { return(surface.GetPreferredWidthForHeight(width)); } else { return(surface.GetPreferredHeightForWidth(width)); } }
void AdjustSize() { IWidgetSurface s = child; var w = s.GetPreferredWidth().MinSize; if (w > Width) { Width = w; } var h = s.GetPreferredHeightForWidth(Width).MinSize; if (h > Height) { Height = h; } }