Fix typo
This commit is contained in:
Родитель
1888edbc9a
Коммит
dfaa60c1e2
|
@ -37,7 +37,7 @@ namespace Xwt
|
|||
|
||||
class TestCanvas: Canvas
|
||||
{
|
||||
protected override Size OnGetPreferredSize (SizeContraint widthConstraint, SizeContraint heightConstraint)
|
||||
protected override Size OnGetPreferredSize (SizeConstraint widthConstraint, SizeConstraint heightConstraint)
|
||||
{
|
||||
return new Size (10, 10);
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ namespace Xwt.GtkBackend
|
|||
IWidgetEventSink eventSink;
|
||||
WidgetEvent enabledEvents;
|
||||
bool destroyed;
|
||||
SizeContraint currentWidthConstraint = SizeContraint.Unconstrained;
|
||||
SizeContraint currentHeightConstraint = SizeContraint.Unconstrained;
|
||||
SizeConstraint currentWidthConstraint = SizeConstraint.Unconstrained;
|
||||
SizeConstraint currentHeightConstraint = SizeConstraint.Unconstrained;
|
||||
|
||||
bool minSizeSet;
|
||||
|
||||
|
@ -243,7 +243,7 @@ namespace Xwt.GtkBackend
|
|||
}
|
||||
}
|
||||
|
||||
public void SetSizeConstraints (SizeContraint widthConstraint, SizeContraint heightConstraint)
|
||||
public void SetSizeConstraints (SizeConstraint widthConstraint, SizeConstraint heightConstraint)
|
||||
{
|
||||
currentWidthConstraint = widthConstraint;
|
||||
currentHeightConstraint = heightConstraint;
|
||||
|
@ -269,7 +269,7 @@ namespace Xwt.GtkBackend
|
|||
return new Point (x + widgetCoordinates.X, y + widgetCoordinates.Y);
|
||||
}
|
||||
|
||||
public virtual Size GetPreferredSize (SizeContraint widthConstraint, SizeContraint heightConstraint)
|
||||
public virtual Size GetPreferredSize (SizeConstraint widthConstraint, SizeConstraint heightConstraint)
|
||||
{
|
||||
try {
|
||||
SetSizeConstraints (widthConstraint, heightConstraint);
|
||||
|
|
|
@ -258,7 +258,7 @@ namespace Xwt.Mac
|
|||
public void UpdateContentSize (bool animate)
|
||||
{
|
||||
if (expanded) {
|
||||
var s = ((IViewObject)ContentView).Backend.Frontend.Surface.GetPreferredSize ((float)Frame.Size.Width, SizeContraint.Unconstrained);
|
||||
var s = ((IViewObject)ContentView).Backend.Frontend.Surface.GetPreferredSize ((float)Frame.Size.Width, SizeConstraint.Unconstrained);
|
||||
SetFrameSize (new SizeF (Frame.Width, (float)s.Height), animate);
|
||||
} else
|
||||
SetFrameSize (new SizeF (Frame.Width, DefaultCollapsedHeight), animate);
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace Xwt.Mac
|
|||
return h;
|
||||
}
|
||||
|
||||
public override Size GetPreferredSize (SizeContraint widthConstraint, SizeContraint heightConstraint)
|
||||
public override Size GetPreferredSize (SizeConstraint widthConstraint, SizeConstraint heightConstraint)
|
||||
{
|
||||
var width = (double) Widget.TextStorage.Size.Width;
|
||||
if (widthConstraint.IsConstrained)
|
||||
|
|
|
@ -114,10 +114,10 @@ namespace Xwt.Mac
|
|||
ViewBackend c = (ViewBackend)child;
|
||||
Size s;
|
||||
if (horizontalScrollPolicy == ScrollPolicy.Never) {
|
||||
s = c.Frontend.Surface.GetPreferredSize (SizeContraint.RequireSize (Widget.ContentView.Frame.Width), SizeContraint.Unconstrained);
|
||||
s = c.Frontend.Surface.GetPreferredSize (SizeConstraint.RequireSize (Widget.ContentView.Frame.Width), SizeConstraint.Unconstrained);
|
||||
}
|
||||
else if (verticalScrollPolicy == ScrollPolicy.Never) {
|
||||
s = c.Frontend.Surface.GetPreferredSize (SizeContraint.Unconstrained, SizeContraint.RequireSize (Widget.ContentView.Frame.Width));
|
||||
s = c.Frontend.Surface.GetPreferredSize (SizeConstraint.Unconstrained, SizeConstraint.RequireSize (Widget.ContentView.Frame.Width));
|
||||
}
|
||||
else {
|
||||
s = c.Frontend.Surface.GetPreferredSize ();
|
||||
|
|
|
@ -336,7 +336,7 @@ namespace Xwt.Mac
|
|||
return lastFittingSize;
|
||||
}
|
||||
|
||||
public virtual Size GetPreferredSize (SizeContraint widthConstraint, SizeContraint heightConstraint)
|
||||
public virtual Size GetPreferredSize (SizeConstraint widthConstraint, SizeConstraint heightConstraint)
|
||||
{
|
||||
return GetNaturalSize ();
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace Xwt.Backends
|
|||
this.sourceWidget = sourceWidget;
|
||||
}
|
||||
|
||||
protected override Size OnGetPreferredSize (SizeContraint widthConstraint, SizeContraint heightConstraint)
|
||||
protected override Size OnGetPreferredSize (SizeConstraint widthConstraint, SizeConstraint heightConstraint)
|
||||
{
|
||||
if (sourceWidget != null)
|
||||
return sourceWidget.Surface.GetPreferredSize (widthConstraint, heightConstraint);
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace Xwt.Backends
|
|||
|
||||
void UpdateLayout ();
|
||||
|
||||
Size GetPreferredSize (SizeContraint widthConstraint, SizeContraint heightConstraint);
|
||||
Size GetPreferredSize (SizeConstraint widthConstraint, SizeConstraint heightConstraint);
|
||||
|
||||
object NativeWidget { get; }
|
||||
|
||||
|
@ -142,7 +142,7 @@ namespace Xwt.Backends
|
|||
void OnMouseScrolled(MouseScrolledEventArgs args);
|
||||
|
||||
// Events
|
||||
Size GetPreferredSize (SizeContraint widthConstraint = default(SizeContraint), SizeContraint heightConstraint = default(SizeContraint));
|
||||
Size GetPreferredSize (SizeConstraint widthConstraint = default(SizeConstraint), SizeConstraint heightConstraint = default(SizeConstraint));
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the frontend that the preferred size of this widget has changed
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace Xwt.Backends
|
|||
Surface.Reallocate ();
|
||||
}
|
||||
|
||||
Size IWidgetBackend.GetPreferredSize (SizeContraint widthConstraint, SizeContraint heightConstraint)
|
||||
Size IWidgetBackend.GetPreferredSize (SizeConstraint widthConstraint, SizeConstraint heightConstraint)
|
||||
{
|
||||
return Surface.GetPreferredSize (widthConstraint, heightConstraint);
|
||||
}
|
||||
|
|
|
@ -271,7 +271,7 @@ namespace Xwt
|
|||
double width = bp.NextSize >= 0 ? bp.NextSize : 0;
|
||||
double height = size.Height - bp.Child.Margin.VerticalSpacing;
|
||||
if (bp.Child.VerticalPlacement != WidgetPlacement.Fill)
|
||||
height = Math.Min (bp.Child.Surface.GetPreferredSize (width, SizeContraint.Unconstrained).Height, height);
|
||||
height = Math.Min (bp.Child.Surface.GetPreferredSize (width, SizeConstraint.Unconstrained).Height, height);
|
||||
double x = bp.PackOrigin == PackOrigin.Start ? xs : xe;
|
||||
double y = (size.Height - bp.Child.Margin.VerticalSpacing - height) * bp.Child.VerticalPlacement.GetValue ();
|
||||
|
||||
|
@ -292,7 +292,7 @@ namespace Xwt
|
|||
double height = bp.NextSize >= 0 ? bp.NextSize : 0;
|
||||
double width = size.Width - bp.Child.Margin.HorizontalSpacing;
|
||||
if (bp.Child.HorizontalPlacement != WidgetPlacement.Fill)
|
||||
width = Math.Min (bp.Child.Surface.GetPreferredSize (SizeContraint.Unconstrained, height).Width, width);
|
||||
width = Math.Min (bp.Child.Surface.GetPreferredSize (SizeConstraint.Unconstrained, height).Width, width);
|
||||
double x = (size.Width - bp.Child.Margin.HorizontalSpacing - width) * bp.Child.HorizontalPlacement.GetValue();
|
||||
double y = bp.PackOrigin == PackOrigin.Start ? ys : ye;
|
||||
|
||||
|
@ -317,8 +317,8 @@ namespace Xwt
|
|||
double requiredSize = 0;
|
||||
double availableSize = vertical ? height : width;
|
||||
|
||||
var widthConstraint = vertical ? SizeContraint.RequireSize (width) : SizeContraint.Unconstrained;
|
||||
var heightConstraint = vertical ? SizeContraint.Unconstrained : SizeContraint.RequireSize (height);
|
||||
var widthConstraint = vertical ? SizeConstraint.RequireSize (width) : SizeConstraint.Unconstrained;
|
||||
var heightConstraint = vertical ? SizeConstraint.Unconstrained : SizeConstraint.RequireSize (height);
|
||||
|
||||
var visibleChildren = children.Where (b => b.Child.Visible).ToArray ();
|
||||
var sizes = new Dictionary<BoxPlacement,double> ();
|
||||
|
@ -355,14 +355,14 @@ namespace Xwt
|
|||
}
|
||||
}
|
||||
|
||||
protected override Size OnGetPreferredSize (SizeContraint widthConstraint, SizeContraint heightConstraint)
|
||||
protected override Size OnGetPreferredSize (SizeConstraint widthConstraint, SizeConstraint heightConstraint)
|
||||
{
|
||||
Size s = new Size ();
|
||||
int count = 0;
|
||||
|
||||
if (direction == Orientation.Horizontal) {
|
||||
foreach (var cw in Children.Where (b => b.Visible)) {
|
||||
var wsize = cw.Surface.GetPreferredSize (SizeContraint.Unconstrained, heightConstraint);
|
||||
var wsize = cw.Surface.GetPreferredSize (SizeConstraint.Unconstrained, heightConstraint);
|
||||
s.Width += wsize.Width + cw.Margin.HorizontalSpacing;
|
||||
if (wsize.Height + cw.Margin.VerticalSpacing > s.Height)
|
||||
s.Height = wsize.Height + cw.Margin.VerticalSpacing;
|
||||
|
@ -372,7 +372,7 @@ namespace Xwt
|
|||
s.Width += spacing * (double)(count - 1);
|
||||
} else {
|
||||
foreach (var cw in Children.Where (b => b.Visible)) {
|
||||
var wsize = cw.Surface.GetPreferredSize (widthConstraint, SizeContraint.Unconstrained);
|
||||
var wsize = cw.Surface.GetPreferredSize (widthConstraint, SizeConstraint.Unconstrained);
|
||||
s.Height += wsize.Height + cw.Margin.VerticalSpacing;
|
||||
if (wsize.Width + cw.Margin.HorizontalSpacing > s.Width)
|
||||
s.Width = wsize.Width + cw.Margin.HorizontalSpacing;
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace Xwt
|
|||
/// </remarks>
|
||||
public void AddChild (Widget w, double x, double y)
|
||||
{
|
||||
var s = w.Surface.GetPreferredSize (SizeContraint.Unconstrained, SizeContraint.Unconstrained);
|
||||
var s = w.Surface.GetPreferredSize (SizeConstraint.Unconstrained, SizeConstraint.Unconstrained);
|
||||
AddChild (w, new Rectangle (x, y, s.Width, s.Height));
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace Xwt
|
|||
/// The returned size is >= 0. If a constraint is specified, the returned size will not
|
||||
/// be bigger than the constraint.
|
||||
/// </remarks>
|
||||
Size GetPreferredSize (SizeContraint widthConstraint, SizeContraint heightConstraint, bool includeMargin = false);
|
||||
Size GetPreferredSize (SizeConstraint widthConstraint, SizeConstraint heightConstraint, bool includeMargin = false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the preferred size of the widget
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace Xwt
|
|||
}
|
||||
}
|
||||
|
||||
protected override Size OnGetPreferredSize (SizeContraint widthConstraint, SizeContraint heightConstraint)
|
||||
protected override Size OnGetPreferredSize (SizeConstraint widthConstraint, SizeConstraint heightConstraint)
|
||||
{
|
||||
if (child != null) {
|
||||
var s = new Size (child.Margin.HorizontalSpacing + Padding.HorizontalSpacing, child.Margin.VerticalSpacing + Padding.VerticalSpacing);
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace Xwt
|
|||
}
|
||||
}
|
||||
|
||||
protected override Size OnGetPreferredSize (SizeContraint widthConstraint, SizeContraint heightConstraint)
|
||||
protected override Size OnGetPreferredSize (SizeConstraint widthConstraint, SizeConstraint heightConstraint)
|
||||
{
|
||||
if (widthConstraint.IsConstrained)
|
||||
widthConstraint.RequiredSize -= 2 * padding;
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace Xwt
|
|||
{
|
||||
base.OnReallocate ();
|
||||
if (child != null && !child.SupportsCustomScrolling)
|
||||
Backend.SetChildSize (child.Surface.GetPreferredSize (SizeContraint.Unconstrained, SizeContraint.Unconstrained));
|
||||
Backend.SetChildSize (child.Surface.GetPreferredSize (SizeConstraint.Unconstrained, SizeConstraint.Unconstrained));
|
||||
}
|
||||
|
||||
public ScrollPolicy VerticalScrollPolicy {
|
||||
|
|
|
@ -27,22 +27,22 @@ using System;
|
|||
|
||||
namespace Xwt
|
||||
{
|
||||
public struct SizeContraint
|
||||
public struct SizeConstraint
|
||||
{
|
||||
// The value '0' is used for Unconstrained, since that's the default value of SizeContraint
|
||||
// Since a constraint of '0' is valid, we use NegativeInfinity as a marker for constraint=0.
|
||||
double value;
|
||||
|
||||
public static readonly SizeContraint Unconstrained;
|
||||
public static readonly SizeConstraint Unconstrained;
|
||||
|
||||
static public implicit operator SizeContraint (double size)
|
||||
static public implicit operator SizeConstraint (double size)
|
||||
{
|
||||
return new SizeContraint () { RequiredSize = size };
|
||||
return new SizeConstraint () { RequiredSize = size };
|
||||
}
|
||||
|
||||
public static SizeContraint RequireSize (double size)
|
||||
public static SizeConstraint RequireSize (double size)
|
||||
{
|
||||
return new SizeContraint () { RequiredSize = size };
|
||||
return new SizeConstraint () { RequiredSize = size };
|
||||
}
|
||||
|
||||
public double RequiredSize {
|
||||
|
@ -64,35 +64,35 @@ namespace Xwt
|
|||
get { return value != 0; }
|
||||
}
|
||||
|
||||
public static bool operator == (SizeContraint s1, SizeContraint s2)
|
||||
public static bool operator == (SizeConstraint s1, SizeConstraint s2)
|
||||
{
|
||||
return (s1.value == s2.value);
|
||||
}
|
||||
|
||||
public static bool operator != (SizeContraint s1, SizeContraint s2)
|
||||
public static bool operator != (SizeConstraint s1, SizeConstraint s2)
|
||||
{
|
||||
return (s1.value != s2.value);
|
||||
}
|
||||
|
||||
public static SizeContraint operator + (SizeContraint c, double s)
|
||||
public static SizeConstraint operator + (SizeConstraint c, double s)
|
||||
{
|
||||
if (!c.IsConstrained)
|
||||
return c;
|
||||
else
|
||||
return SizeContraint.RequireSize (c.RequiredSize + s);
|
||||
return SizeConstraint.RequireSize (c.RequiredSize + s);
|
||||
}
|
||||
|
||||
public static SizeContraint operator - (SizeContraint c, double s)
|
||||
public static SizeConstraint operator - (SizeConstraint c, double s)
|
||||
{
|
||||
if (!c.IsConstrained)
|
||||
return c;
|
||||
else
|
||||
return SizeContraint.RequireSize (Math.Max (c.RequiredSize - s, 0));
|
||||
return SizeConstraint.RequireSize (Math.Max (c.RequiredSize - s, 0));
|
||||
}
|
||||
|
||||
public override bool Equals (object ob)
|
||||
{
|
||||
return (ob is SizeContraint) && this == (SizeContraint)ob;
|
||||
return (ob is SizeConstraint) && this == (SizeConstraint)ob;
|
||||
}
|
||||
|
||||
public override int GetHashCode ()
|
||||
|
|
|
@ -318,11 +318,11 @@ namespace Xwt
|
|||
var bp = visibleChildren[n];
|
||||
Size s;
|
||||
if (useWidthConstraint)
|
||||
s = bp.Child.Surface.GetPreferredSize (SizeContraint.RequireSize (bp.NextWidth - bp.Child.Margin.HorizontalSpacing), SizeContraint.Unconstrained);
|
||||
s = bp.Child.Surface.GetPreferredSize (SizeConstraint.RequireSize (bp.NextWidth - bp.Child.Margin.HorizontalSpacing), SizeConstraint.Unconstrained);
|
||||
else if (useHeightConstraint)
|
||||
s = bp.Child.Surface.GetPreferredSize (SizeContraint.Unconstrained, SizeContraint.RequireSize (bp.NextHeight - bp.Child.Margin.VerticalSpacing));
|
||||
s = bp.Child.Surface.GetPreferredSize (SizeConstraint.Unconstrained, SizeConstraint.RequireSize (bp.NextHeight - bp.Child.Margin.VerticalSpacing));
|
||||
else
|
||||
s = bp.Child.Surface.GetPreferredSize (SizeContraint.Unconstrained, SizeContraint.Unconstrained);
|
||||
s = bp.Child.Surface.GetPreferredSize (SizeConstraint.Unconstrained, SizeConstraint.Unconstrained);
|
||||
s.Width += bp.Child.Margin.HorizontalSpacing;
|
||||
s.Height += bp.Child.Margin.VerticalSpacing;
|
||||
sizes [n] = s;
|
||||
|
@ -689,7 +689,7 @@ namespace Xwt
|
|||
}
|
||||
}
|
||||
|
||||
protected override Size OnGetPreferredSize (SizeContraint widthConstraint, SizeContraint heightConstraint)
|
||||
protected override Size OnGetPreferredSize (SizeConstraint widthConstraint, SizeConstraint heightConstraint)
|
||||
{
|
||||
TablePlacement[] visibleChildren = VisibleChildren ();
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ namespace Xwt
|
|||
List<Widget> children;
|
||||
WidgetSpacing margin;
|
||||
Size cachedSize;
|
||||
SizeContraint cachedWidthConstraint;
|
||||
SizeContraint cachedHeightConstraint;
|
||||
SizeConstraint cachedWidthConstraint;
|
||||
SizeConstraint cachedHeightConstraint;
|
||||
bool sizeCached;
|
||||
DragOperation currentDragOperation;
|
||||
Widget contentWidget;
|
||||
|
@ -185,7 +185,7 @@ namespace Xwt
|
|||
Parent.OnKeyReleased (args);
|
||||
}
|
||||
|
||||
Size IWidgetEventSink.GetPreferredSize (SizeContraint widthConstraint, SizeContraint heightConstraint)
|
||||
Size IWidgetEventSink.GetPreferredSize (SizeConstraint widthConstraint, SizeConstraint heightConstraint)
|
||||
{
|
||||
return Parent.OnGetPreferredSize (widthConstraint, heightConstraint);
|
||||
}
|
||||
|
@ -943,10 +943,10 @@ namespace Xwt
|
|||
|
||||
Size IWidgetSurface.GetPreferredSize (bool includeMargin)
|
||||
{
|
||||
return ((IWidgetSurface)this).GetPreferredSize (SizeContraint.Unconstrained, SizeContraint.Unconstrained, includeMargin);
|
||||
return ((IWidgetSurface)this).GetPreferredSize (SizeConstraint.Unconstrained, SizeConstraint.Unconstrained, includeMargin);
|
||||
}
|
||||
|
||||
Size IWidgetSurface.GetPreferredSize (SizeContraint widthConstraint, SizeContraint heightConstraint, bool includeMargin)
|
||||
Size IWidgetSurface.GetPreferredSize (SizeConstraint widthConstraint, SizeConstraint heightConstraint, bool includeMargin)
|
||||
{
|
||||
if (includeMargin) {
|
||||
return Surface.GetPreferredSize (widthConstraint - margin.HorizontalSpacing, heightConstraint - margin.VerticalSpacing, false) + new Size (Margin.HorizontalSpacing, Margin.VerticalSpacing);
|
||||
|
@ -996,7 +996,7 @@ namespace Xwt
|
|||
/// <summary>
|
||||
/// Gets the preferred size of the widget (it must not include the widget margin)
|
||||
/// </summary>
|
||||
protected virtual Size OnGetPreferredSize (SizeContraint widthConstraint, SizeContraint heightConstraint)
|
||||
protected virtual Size OnGetPreferredSize (SizeConstraint widthConstraint, SizeConstraint heightConstraint)
|
||||
{
|
||||
return Backend.GetPreferredSize (widthConstraint, heightConstraint);
|
||||
}
|
||||
|
@ -1017,7 +1017,7 @@ namespace Xwt
|
|||
|
||||
ResetCachedSizes ();
|
||||
|
||||
var s = Surface.GetPreferredSize (SizeContraint.Unconstrained, SizeContraint.Unconstrained);
|
||||
var s = Surface.GetPreferredSize (SizeConstraint.Unconstrained, SizeConstraint.Unconstrained);
|
||||
if (s != oldSize)
|
||||
NotifySizeChangeToParent ();
|
||||
else
|
||||
|
|
|
@ -195,8 +195,8 @@ namespace Xwt
|
|||
|
||||
var size = shown ? Size : initialBounds.Size;
|
||||
|
||||
var wc = widthSet ? SizeContraint.RequireSize (size.Width - padding.HorizontalSpacing) : SizeContraint.Unconstrained;
|
||||
var hc = heightSet ? SizeContraint.RequireSize (size.Height - padding.VerticalSpacing) : SizeContraint.Unconstrained;
|
||||
var wc = widthSet ? SizeConstraint.RequireSize (size.Width - padding.HorizontalSpacing) : SizeConstraint.Unconstrained;
|
||||
var hc = heightSet ? SizeConstraint.RequireSize (size.Height - padding.VerticalSpacing) : SizeConstraint.Unconstrained;
|
||||
|
||||
var ws = s.GetPreferredSize (wc, hc);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче