ctx.Rectangle (clipping.GetRectangle (i));
ctx.Clip ();
- ctx.PushGroup ();
+ //ctx.PushGroup ();
return ctx;
}
public override void FlushUIFrame(IContext ctx)
{
- ctx.PopGroupToSource ();
- ctx.Paint ();
+ /*ctx.PopGroupToSource ();
+ ctx.Paint ();*/
surf.Flush ();
base.FlushUIFrame (ctx);
if (Orientation == Orientation.Horizontal)
//return contentSize.Width + totSpace + 2 * Margin;
return stretchedGO == null ?
- contentSize.Width + totSpace + 2 * Margin :
- contentSize.Width + stretchedGO.measureRawSize(lt) + totSpace + 2 * Margin;
+ contentSize.Width + totSpace + 2 * Margin.Width :
+ contentSize.Width + stretchedGO.measureRawSize(lt) + totSpace + 2 * Margin.Width;
} else if (Orientation == Orientation.Vertical)
//return contentSize.Height + totSpace + 2 * Margin;
return stretchedGO == null ?
- contentSize.Height + totSpace + 2 * Margin :
- contentSize.Height + stretchedGO.measureRawSize(lt) + totSpace + 2 * Margin;
+ contentSize.Height + totSpace + 2 * Margin.Height :
+ contentSize.Height + stretchedGO.measureRawSize(lt) + totSpace + 2 * Margin.Height;
return base.measureRawSize (lt);
} finally {
public override int measureRawSize (LayoutingType lt)
{
if (_pic == null)
- return 2 * Margin;
+ return lt == LayoutingType.Width ? 2 * Margin.Width : 2 * Margin.Height;
if (!_pic.IsLoaded)
_pic.load (IFace);
//_pic = "#Crow.Images.Icons.IconAlerte.svg";
//TODO:take scalling in account
if (lt == LayoutingType.Width)
- return _pic.Dimensions.Width + 2 * Margin;
+ return _pic.Dimensions.Width + 2 * Margin.Width;
else
- return _pic.Dimensions.Height + 2 * Margin;
+ return _pic.Dimensions.Height + 2 * Margin.Width;
}
protected override void onDraw (IContext gr)
{
}
}
DbgLogger.EndEvent(DbgEvtType.GOMeasure);
- return Margin * 2 + (lt == LayoutingType.Height ? cachedTextSize.Height : cachedTextSize.Width);
+ return lt == LayoutingType.Height ? cachedTextSize.Height + 2 * Margin.Height : cachedTextSize.Width + 2 * Margin.Width;
}
protected override void onDraw (IContext gr)
measureTextBounds (gr);
}
}
- return Margin * 2 + (lt == LayoutingType.Height ? cachedTextSize.Height : cachedTextSize.Width);
+ return lt == LayoutingType.Height ? cachedTextSize.Height + 2 * Margin.Height : cachedTextSize.Width + 2 * Margin.Width;
} finally {
DbgLogger.EndEvent(DbgEvtType.GOMeasure);
}
}
}
return lt == LayoutingType.Width ?
- contentSize.Width + 2 * Margin : contentSize.Height + 2 * Margin;
+ contentSize.Width + 2 * Margin.Width : contentSize.Height + 2 * Margin.Height;
}
}
}
double x = 0;
if (VerticalLineWidth > 0) {
gr.LineWidth = VerticalLineWidth;
- x = cb.Left + HeaderRow.Margin + 0.5 * ColumnSpacing + HeaderRow.Children[0].Slot.Width;// - 0.5 * VerticalLineWidth;
+ x = cb.Left + HeaderRow.Margin.Width + 0.5 * ColumnSpacing + HeaderRow.Children[0].Slot.Width;// - 0.5 * VerticalLineWidth;
for (int i = 1; i < HeaderRow.Children.Count ; i++)
{
gr.MoveTo (x, cb.Y);
if (HorizontalLineWidth > 0) {
gr.LineWidth = HorizontalLineWidth;
- x = cb.Top + 0.5 * Spacing + Children[0].Slot.Height;// - 0.5 * HorizontalLineWidth;
+ x = cb.Top + HeaderRow.Margin.Height + 0.5 * Spacing + Children[0].Slot.Height;// - 0.5 * HorizontalLineWidth;
for (int i = 1; i < Children.Count; i++)
{
gr.MoveTo (cb.Left, x);
if (scroller != null && selectedItemContainer != null && itemsContainer is GenericStack gs) {
Rectangle scrollerCb = scroller.ClientRectangle;
Rectangle cb = gs.Slot;
- Rectangle rItem = selectedItemContainer.Slot + new Point (gs.Margin);
+ Rectangle rItem = selectedItemContainer.Slot + gs.Margin;
if (gs.Orientation == Orientation.Vertical) {
if (rItem.Y - scroller.ScrollY < 0)
scroller.ScrollY = rItem.Y;
protected Measure width, height;
int left, top;
double cornerRadius;
- int margin;
+ Size margin;
bool focusable ;
bool hasFocus;
bool isActive;
return Slot;
if (Parent is Widget p)
return Slot + p.RelativeSlot (target).Position + Margin;
- return Slot + new Point(Margin, Margin);
+ return Slot + Margin;
}
/// <summary>
/// Widget coordintate relative to the main drawing surface, normally a GLFW window.
/// </summary>
[DesignCategory ("Appearance")][DefaultValue(0.0)]
public virtual double CornerRadius {
- get { return cornerRadius; }
+ get => cornerRadius;
set {
if (value == cornerRadius)
return;
/// This is a single integer for the 4 direction, a gap between the control and it's container,
/// by default it is filled with the background.
/// </summary>
- [DesignCategory ("Layout")][DefaultValue(0)]
- public virtual int Margin {
- get { return margin; }
+ [DesignCategory ("Layout")][DefaultValue("0,0")]
+ public virtual Size Margin {
+ get => margin;
set {
if (value == margin)
return;
/// <summary>
/// set the visible state of the control, invisible controls does reserve space in the layouting system.
/// </summary>
- [Obsolete][DesignCategory ("Appearance")][DefaultValue(true)]
+ [Obsolete("Use IsVisible instead.")][DesignCategory ("Appearance")][DefaultValue(true)]
public virtual bool Visible {
get => IsVisible;
set => IsVisible = value;
try {
DbgLogger.SetMsg(DbgEvtType.GOMeasure, $"{lt} contentSize:{contentSize}");
return lt == LayoutingType.Width ?
- contentSize.Width + 2 * margin : contentSize.Height + 2 * margin;
+ contentSize.Width + 2 * margin.Width : contentSize.Height + 2 * margin.Height;
} finally {
DbgLogger.EndEvent(DbgEvtType.GOMeasure);
}
if (dy == 0)
tmp -= Spacing;
- return tmp + largestChild + 2 * Margin;
+ return tmp + largestChild + 2 * Margin.Width;
}
} else if (Orientation == Orientation.Horizontal) {
Height = Measure.Stretched;
if (dx == 0)
tmp -= Spacing;
- return tmp + tallestChild + 2 * Margin;
+ return tmp + tallestChild + 2 * Margin.Height;
}
} finally {
DbgLogger.EndEvent(DbgEvtType.GOMeasure);
this.Y -= yDelta;
this.Height += 2 * yDelta;
}
+ public void Inflate(Size delta)
+ {
+ this.X -= delta.Width;
+ this.Width += 2 * delta.Width;
+ this.Y -= delta.Height;
+ this.Height += 2 * delta.Height;
+ }
public void Inflate(int delta)
{
Inflate (delta, delta);
public static bool operator != (Size s, int i) => (s.Width != i || s.Height != i);*/
public static Size operator + (Size s1, Size s2) => new Size (s1.Width + s2.Width, s1.Height + s2.Height);
public static Size operator + (Size s, int i) => new Size (s.Width + i, s.Height + i);
+ public static Size operator - (Size s1, Size s2) => new Size (s1.Width - s2.Width, s1.Height - s2.Height);
+ public static Size operator - (Size s, int i) => new Size (s.Width - i, s.Height - i);
public static Size operator * (Size s, int i) => new Size (s.Width * i, s.Height * i);
public static Size operator / (Size s, int i) => new Size (s.Width / i, s.Height / i);
+ public static Size operator -(Size s) => new Size (-s.Width, -s.Height);
public static Size operator * (Size s, double i) => new Size ((int)(s.Width * i), (int)(s.Height * i));
#endregion
</HorizontalStack>
</ItemTemplate>
</ListBox>
- <Label Width="Stretched" Margin="3" Background="DimGrey" />
- <TextBox Text="TextBox" Multiline="true" Margin="3" />
+ <Label Width="Stretched" Margin="3,1" Background="DimGrey" />
+ <TextBox Text="TextBox" Multiline="true" Margin="3,1" />
<HorizontalStack Height="Fit" Background="Jet" CornerRadius="10" Margin="5">
<VerticalStack Spacing="5" Width="50%">
<CheckBox Fit="true" Caption="test" />