<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
- <DefineConstants>DEBUG_FOCUS0;DEBUG_LAYOUTING0;TRACE;DEBUG;__linux__;MEASURE_TIME;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
+ <DefineConstants>DEBUG_FOCUS0;DEBUG_LAYOUTING0;TRACE;DEBUG;MEASURE_TIME;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Compile Include="src\GraphicObjects\Slider.cs" />
<Compile Include="src\GraphicObjects\NumericControl.cs" />
<Compile Include="src\GraphicObjects\Scroller.cs" />
- <Compile Include="src\GraphicObjects\ILayoutable.cs" />
<Compile Include="src\Enums.cs" />
<Compile Include="src\GraphicObjects\GenericStack.cs" />
<Compile Include="src\CompilerServices\CompilerServices.cs" />
/// <returns><c>true</c>, if logical parents are not null</returns>
/// <param name="instance">Start Instance</param>
/// <param name="levelCount">Levels to go upward</param>
- internal static ILayoutable goUpNbLevels(ILayoutable instance, int levelCount){
- ILayoutable tmp = instance;
+ internal static GraphicObject goUpNbLevels(GraphicObject instance, int levelCount){
+ GraphicObject tmp = instance;
int i = 0;
while (tmp != null && i < levelCount) {
tmp = tmp.LogicalParent;
Vertical
}
- public enum Alignment
+ public enum Alignment : byte
{
Top = 0x01,
Left = 0x02,
BottomRight = 0x0c,
Center = 0x10
}
- public enum HorizontalAlignment
+ public enum HorizontalAlignment : byte
{
+ Center,
Left,
Right,
- Center,
}
- public enum VerticalAlignment
+ public enum VerticalAlignment : byte
{
+ Center,
Top,
Bottom,
- Center,
}
}
int tmp = base.measureRawSize (lt);
return tmp < 0 ? tmp : tmp + 2 * BorderWidth;
}
- protected override void onDraw (Cairo.Context gr)
+ unsafe protected override void onDraw (Cairo.Context gr)
{
- Rectangle rBack = new Rectangle (Slot.Size);
+ Rectangle rBack = new Rectangle (nativeHnd->Slot.Size);
//rBack.Inflate (-Margin);
// if (BorderWidth > 0)
updateMouseLocalPos (e.Position);
}
- protected virtual void updateMouseLocalPos(Point mPos){
- Rectangle r = ScreenCoordinates (Slot);
+ unsafe protected virtual void updateMouseLocalPos(Point mPos){
+ Rectangle r = ScreenCoordinates (nativeHnd->Slot);
Rectangle cb = ClientRectangle;
mousePos = mPos - r.Position;
}
}
- public override void OnLayoutChanges (LayoutingType layoutType)
+ unsafe public override void OnLayoutChanges (LayoutingType layoutType)
{
base.OnLayoutChanges (layoutType);
if (layoutType == LayoutingType.Width)
- MinimumPopupSize = new Size (this.Slot.Width, minimumPopupSize.Height);
+ MinimumPopupSize = new Size (this.nativeHnd->Slot.Width, minimumPopupSize.Height);
}
}
}
return base.measureRawSize (lt);
}
- public virtual void ComputeChildrenPositions()
+ unsafe public virtual void ComputeChildrenPositions()
{
int d = 0;
if (Orientation == Orientation.Horizontal) {
foreach (GraphicObject c in Children) {
if (!c.Visible)
continue;
- c.Slot.X = d;
- d += c.Slot.Width + Spacing;
+ c.nativeHnd->Slot.X = d;
+ d += c.nativeHnd->Slot.Width + Spacing;
}
} else {
foreach (GraphicObject c in Children) {
if (!c.Visible)
continue;
- c.Slot.Y = d;
- d += c.Slot.Height + Spacing;
+ c.nativeHnd->Slot.Y = d;
+ d += c.nativeHnd->Slot.Height + Spacing;
}
}
IsDirty = true;
return base.UpdateLayout(layoutType);
}
- public override void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
+ unsafe public override void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
{
GraphicObject go = sender as GraphicObject;
//Debug.WriteLine ("child layout change: " + go.LastSlots.ToString() + " => " + go.Slot.ToString());
if (stretchedGO == null && Width != Measure.Fit)
stretchedGO = go;
else if (stretchedGO != go) {
- go.Slot.Width = 0;
+ go.nativeHnd->Slot.Width = 0;
go.Width = Measure.Fit;
return;
}
} else
- contentSize.Width += go.Slot.Width - go.LastSlots.Width;
+ contentSize.Width += go.nativeHnd->Slot.Width - go.nativeHnd->LastSlot.Width;
if (stretchedGO != null) {
int newW = Math.Max (
stretchedGO.MinimumSize.Width);
if (stretchedGO.MaximumSize.Width > 0)
newW = Math.Min (newW, stretchedGO.MaximumSize.Width);
- if (newW != stretchedGO.Slot.Width) {
- stretchedGO.Slot.Width = newW;
+ if (newW != stretchedGO.nativeHnd->Slot.Width) {
+ stretchedGO.nativeHnd->Slot.Width = newW;
stretchedGO.IsDirty = true;
#if DEBUG_LAYOUTING
Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString());
stretchedGO.LayoutChanged -= OnChildLayoutChanges;
stretchedGO.OnLayoutChanges (LayoutingType.Width);
stretchedGO.LayoutChanged += OnChildLayoutChanges;
- stretchedGO.LastSlots.Width = stretchedGO.Slot.Width;
+ stretchedGO.nativeHnd->LastSlot.Width = stretchedGO.nativeHnd->Slot.Width;
}
}
if (stretchedGO == null && Height != Measure.Fit)
stretchedGO = go;
else if (stretchedGO != go){
- go.Slot.Height = 0;
+ go.nativeHnd->Slot.Height = 0;
go.Height = Measure.Fit;
return;
}
} else
- contentSize.Height += go.Slot.Height - go.LastSlots.Height;
+ contentSize.Height += go.nativeHnd->Slot.Height - go.nativeHnd->LastSlot.Height;
if (stretchedGO != null) {
int newH = Math.Max (
stretchedGO.MinimumSize.Height);
if (stretchedGO.MaximumSize.Height > 0)
newH = Math.Min (newH, stretchedGO.MaximumSize.Height);
- if (newH != stretchedGO.Slot.Height) {
- stretchedGO.Slot.Height = newH;
+ if (newH != stretchedGO.nativeHnd->Slot.Height) {
+ stretchedGO.nativeHnd->Slot.Height = newH;
stretchedGO.IsDirty = true;
#if DEBUG_LAYOUTING
Debug.WriteLine ("\tAdjusting Height of " + stretchedGO.ToString());
stretchedGO.LayoutChanged -= OnChildLayoutChanges;
stretchedGO.OnLayoutChanges (LayoutingType.Height);
stretchedGO.LayoutChanged += OnChildLayoutChanges;
- stretchedGO.LastSlots.Height = stretchedGO.Slot.Height;
+ stretchedGO.nativeHnd->LastSlot.Height = stretchedGO.nativeHnd->Slot.Height;
}
}
using System.Linq;
using System.Diagnostics;
using System.IO;
+using System.Runtime.InteropServices;
namespace Crow
{
- public class GraphicObject : ILayoutable, IValueChange
- {
- internal static ulong currentUid = 0;
- internal ulong uid = 0;
-
- Interface currentInterface = null;
+ [StructLayout(LayoutKind.Sequential)]
+ unsafe public struct NativeGO {
+ public NativeGO* Parent;
+ public int Left;
+ public int Top;
+ public Measure Width;
+ public Measure Height;
+ public int Margin;
+ public Size MinimumSize;
+ public Size MaximumSize;
+ byte visible;
+ public LayoutingType RegisteredLayoutings;
+ /// <summary>
+ /// Current size and position computed during layouting pass
+ /// </summary>
+ public Rectangle Slot;
+ /// <summary>
+ /// keep last slot components for each layouting pass to track
+ /// changes and trigger update of other component accordingly
+ /// </summary>
+ public Rectangle LastSlot;
+ /// <summary>
+ /// keep last slot painted on screen to clear traces if moved or resized
+ /// TODO: we should ensure the whole parsed widget tree is the last painted
+ /// version to clear effective oldslot if parents have been moved or resized.
+ /// IDEA is to add a ScreenCoordinates function that use only lastPaintedSlots
+ /// </summary>
+ public Rectangle LastPaintedSlot;
+ public VerticalAlignment VerticalAlignment;
+ public HorizontalAlignment HorizontalAlignment;
- [XmlIgnore]public Interface CurrentInterface {
- get {
- if (currentInterface == null) {
- currentInterface = Interface.CurrentInterface;
- Initialize ();
- }
- return currentInterface;
- }
+ unsafe public bool Visible {
+ get { return visible > 0; }
set {
- currentInterface = value;
+ if (value)
+ visible = 1;
+ else
+ visible = 0;
}
}
+ }
+ public class GraphicObject : IValueChange, IDisposable
+ {
+ #region PINVOKE
+ const string lib = "/home/jp/devel/testsharedlib/bin/Debug/libcrow.so";
+ [DllImport(lib)]
+ unsafe static extern NativeGO* CreateGO();
+ [DllImport(lib)]
+ unsafe static extern void DestroyGO(NativeGO* go);
+ #endregion
- public Region Clipping = new Region();
+ internal static ulong currentUid = 0;
+ internal ulong uid = 0;
+
+
+ unsafe internal NativeGO* nativeHnd;
#region IValueChange implementation
public event EventHandler<ValueChangeEventArgs> ValueChanged;
#region CTOR
public GraphicObject ()
{
+ unsafe {
+ nativeHnd = CreateGO ();
+ }
#if DEBUG
uid = currentUid;
currentUid++;
loadDefaultValues ();
}
#region private fields
- LayoutingType registeredLayoutings = LayoutingType.All;
- ILayoutable logicalParent;
- ILayoutable parent;
+
+ Interface currentInterface = null;
+ GraphicObject logicalParent;
+ GraphicObject parent;
string name;
Fill background = Color.Transparent;
Fill foreground = Color.White;
Font font = "droid, 10";
- Measure width, height;
- int left, top;
double cornerRadius = 0;
- int margin = 0;
bool focusable = false;
bool hasFocus = false;
bool isActive = false;
bool mouseRepeat;
- protected bool isVisible = true;
bool isEnabled = true;
- VerticalAlignment verticalAlignment = VerticalAlignment.Center;
- HorizontalAlignment horizontalAlignment = HorizontalAlignment.Center;
- Size maximumSize = "0,0";
- Size minimumSize = "0,0";
bool cacheEnabled = false;
bool clipToClientRect = true;
protected object dataSource;
#region public fields
/// <summary>
- /// Current size and position computed during layouting pass
- /// </summary>
- public Rectangle Slot = new Rectangle ();
- /// <summary>
- /// keep last slot components for each layouting pass to track
- /// changes and trigger update of other component accordingly
+ /// The clipping rectangles list
/// </summary>
- public Rectangle LastSlots;
- /// <summary>
- /// keep last slot painted on screen to clear traces if moved or resized
- /// TODO: we should ensure the whole parsed widget tree is the last painted
- /// version to clear effective oldslot if parents have been moved or resized.
- /// IDEA is to add a ScreenCoordinates function that use only lastPaintedSlots
- /// </summary>
- public Rectangle LastPaintedSlot;
+ public Region Clipping = new Region();
/// <summary>Prevent requeuing multiple times the same widget</summary>
public bool IsQueueForRedraw = false;
/// <summary>drawing Cache bitmap</summary>
#endregion
#region ILayoutable
- [XmlIgnore]public LayoutingType RegisteredLayoutings { get { return registeredLayoutings; } set { registeredLayoutings = value; } }
+ [XmlIgnore]unsafe public LayoutingType RegisteredLayoutings {
+ get { return nativeHnd->RegisteredLayoutings; } set { nativeHnd->RegisteredLayoutings = value; } }
//TODO: it would save the recurent cost of a cast in event bubbling if parent type was GraphicObject
// or we could add to the interface the mouse events
/// <summary>
/// Parent in the graphic tree, used for rendering and layouting
/// </summary>
- [XmlIgnore]public virtual ILayoutable Parent {
+ [XmlIgnore]public virtual GraphicObject Parent {
get { return parent; }
set {
if (parent == value)
return;
DataSourceChangeEventArgs e = new DataSourceChangeEventArgs (parent, value);
- lock (this)
+ lock (this) {
parent = value;
+ //nativeHnd->Parent = value?.nativeHnd;
+ }
onParentChanged (this, e);
}
}
- [XmlIgnore]public ILayoutable LogicalParent {
+ [XmlIgnore]public GraphicObject LogicalParent {
get { return logicalParent == null ? Parent : logicalParent; }
set {
if (logicalParent == value)
return;
if (logicalParent != null)
- (logicalParent as GraphicObject).DataSourceChanged -= onLogicalParentDataSourceChanged;
+ logicalParent.DataSourceChanged -= onLogicalParentDataSourceChanged;
DataSourceChangeEventArgs dsce = new DataSourceChangeEventArgs (LogicalParent, null);
logicalParent = value;
dsce.NewDataSource = LogicalParent;
if (logicalParent != null)
- (logicalParent as GraphicObject).DataSourceChanged += onLogicalParentDataSourceChanged;
+ logicalParent.DataSourceChanged += onLogicalParentDataSourceChanged;
onLogicalParentChanged (this, dsce);
}
}
- [XmlIgnore]public virtual Rectangle ClientRectangle {
+ [XmlIgnore]unsafe public virtual Rectangle ClientRectangle {
get {
- Rectangle cb = Slot.Size;
+ Rectangle cb = nativeHnd->Slot.Size;
cb.Inflate ( - Margin);
return cb;
}
}
public virtual Rectangle ContextCoordinates(Rectangle r){
- GraphicObject go = Parent as GraphicObject;
- if (go == null)
+ if (Parent is Interface)
return r + Parent.ClientRectangle.Position;
- return go.CacheEnabled ?
+ return parent.CacheEnabled ?
r + Parent.ClientRectangle.Position :
Parent.ContextCoordinates (r);
}
return
Parent.ScreenCoordinates(r) + Parent.getSlot().Position + Parent.ClientRectangle.Position;
}
- public virtual Rectangle getSlot () { return Slot;}
+ unsafe public virtual Rectangle getSlot () { return nativeHnd->Slot;}
#endregion
#region EVENT HANDLERS
#endregion
#region public properties
+ [XmlIgnore]public Interface CurrentInterface {
+ get {
+ if (currentInterface == null) {
+ currentInterface = Interface.CurrentInterface;
+ Initialize ();
+ }
+ return currentInterface;
+ }
+ set {
+ currentInterface = value;
+ }
+ }
/// <summary>Random value placeholder</summary>
[XmlAttributeAttribute]
public object Tag {
}
}
[XmlAttributeAttribute ()][DefaultValue(VerticalAlignment.Center)]
- public virtual VerticalAlignment VerticalAlignment {
- get { return verticalAlignment; }
+ unsafe public virtual VerticalAlignment VerticalAlignment {
+ get { return nativeHnd->VerticalAlignment; }
set {
- if (verticalAlignment == value)
+ if (nativeHnd->VerticalAlignment == value)
return;
- verticalAlignment = value;
- NotifyValueChanged("VerticalAlignment", verticalAlignment);
+ nativeHnd->VerticalAlignment = value;
+ NotifyValueChanged("VerticalAlignment", nativeHnd->VerticalAlignment);
RegisterForLayouting (LayoutingType.Y);
}
}
[XmlAttributeAttribute()][DefaultValue(HorizontalAlignment.Center)]
- public virtual HorizontalAlignment HorizontalAlignment {
- get { return horizontalAlignment; }
+ unsafe public virtual HorizontalAlignment HorizontalAlignment {
+ get { return nativeHnd->HorizontalAlignment; }
set {
- if (horizontalAlignment == value)
+ if (nativeHnd->HorizontalAlignment == value)
return;
- horizontalAlignment = value;
- NotifyValueChanged("HorizontalAlignment", horizontalAlignment);
+ nativeHnd->HorizontalAlignment = value;
+ NotifyValueChanged("HorizontalAlignment", nativeHnd->HorizontalAlignment);
RegisterForLayouting (LayoutingType.X);
}
}
[XmlAttributeAttribute()][DefaultValue(0)]
public virtual int Left {
- get { return left; }
+ get { unsafe { return nativeHnd->Left; } }
set {
- if (left == value)
+ if (Left == value)
return;
- left = value;
- NotifyValueChanged ("Left", left);
+ unsafe {
+ nativeHnd->Left = value;
+ }
+ NotifyValueChanged ("Left", Left);
this.RegisterForLayouting (LayoutingType.X);
}
}
[XmlAttributeAttribute()][DefaultValue(0)]
public virtual int Top {
- get { return top; }
+ get { unsafe { return nativeHnd->Top; } }
set {
- if (top == value)
+ if (Top == value)
return;
- top = value;
- NotifyValueChanged ("Top", top);
+ unsafe {
+ nativeHnd->Top = value;
+ }
+ NotifyValueChanged ("Top", Top);
this.RegisterForLayouting (LayoutingType.Y);
}
}
}
}
[XmlAttributeAttribute()][DefaultValue("Inherit")]
- public virtual Measure Width {
+ unsafe public virtual Measure Width {
get {
- return width.Units == Unit.Inherit ?
- Parent is GraphicObject ? (Parent as GraphicObject).WidthPolicy :
- Measure.Stretched : width;
+ return nativeHnd->Width.Units == Unit.Inherit ? Parent == null ?
+ Measure.Stretched : Parent.WidthPolicy : nativeHnd->Width;
}
set {
- if (width == value)
+ if (nativeHnd->Width == value)
return;
if (value.IsFixed) {
if (value < MinimumSize.Width || (value > MaximumSize.Width && MaximumSize.Width > 0))
return;
}
Measure lastWP = WidthPolicy;
- width = value;
- NotifyValueChanged ("Width", width);
+ nativeHnd->Width = value;
+ NotifyValueChanged ("Width", nativeHnd->Width);
if (WidthPolicy != lastWP) {
NotifyValueChanged ("WidthPolicy", WidthPolicy);
//contentSize in Stacks are only update on childLayoutChange, and the single stretched
if (parent is GenericStack) {//TODO:check if I should test Group instead
if ((parent as GenericStack).Orientation == Orientation.Horizontal) {
if (lastWP == Measure.Fit)
- (parent as GenericStack).contentSize.Width -= this.LastSlots.Width;
+ (parent as GenericStack).contentSize.Width -= nativeHnd->LastSlot.Width;
else
- (parent as GenericStack).contentSize.Width += this.LastSlots.Width;
+ (parent as GenericStack).contentSize.Width += nativeHnd->LastSlot.Width;
}
}
}
}
}
[XmlAttributeAttribute()][DefaultValue("Inherit")]
- public virtual Measure Height {
+ unsafe public virtual Measure Height {
get {
- return height.Units == Unit.Inherit ?
- Parent is GraphicObject ? (Parent as GraphicObject).HeightPolicy :
- Measure.Stretched : height;
+ return nativeHnd->Height.Units == Unit.Inherit ? Parent == null ?
+ Measure.Stretched : Parent.HeightPolicy : nativeHnd->Height;
}
set {
- if (height == value)
+ if (nativeHnd->Height == value)
return;
if (value.IsFixed) {
if (value < MinimumSize.Height || (value > MaximumSize.Height && MaximumSize.Height > 0))
return;
}
Measure lastHP = HeightPolicy;
- height = value;
- NotifyValueChanged ("Height", height);
+ nativeHnd->Height = value;
+ NotifyValueChanged ("Height", nativeHnd->Height);
if (HeightPolicy != lastHP) {
NotifyValueChanged ("HeightPolicy", HeightPolicy);
if (parent is GenericStack) {
if ((parent as GenericStack).Orientation == Orientation.Vertical) {
if (lastHP == Measure.Fit)
- (parent as GenericStack).contentSize.Height -= this.LastSlots.Height;
+ (parent as GenericStack).contentSize.Height -= nativeHnd->LastSlot.Height;
else
- (parent as GenericStack).contentSize.Height += this.LastSlots.Height;
+ (parent as GenericStack).contentSize.Height += nativeHnd->LastSlot.Height;
}
}
}
-
this.RegisterForLayouting (LayoutingType.Height);
}
}
}
[XmlAttributeAttribute()][DefaultValue(0)]
public virtual int Margin {
- get { return margin; }
+ get { unsafe { return nativeHnd->Margin; } }
set {
- if (value == margin)
+ if (value == Margin)
return;
- margin = value;
- NotifyValueChanged ("Margin", margin);
+ unsafe {
+ nativeHnd->Margin = value;
+ }
+ NotifyValueChanged ("Margin", Margin);
RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute][DefaultValue(true)]
public virtual bool Visible {
- get { return isVisible; }
+ get { unsafe { return nativeHnd->Visible;} }
set {
- if (value == isVisible)
+ if (value == Visible)
return;
-
- isVisible = value;
+ unsafe {
+ nativeHnd->Visible = value;
+ }
RegisterForLayouting (LayoutingType.Sizing);
//trigger a mouse to handle possible hover changes
//CurrentInterface.ProcessMouseMove (CurrentInterface.Mouse.X, CurrentInterface.Mouse.Y);
- NotifyValueChanged ("Visible", isVisible);
+ NotifyValueChanged ("Visible", Visible);
}
}
[XmlAttributeAttribute][DefaultValue(true)]
RegisterForRedraw ();
}
}
- [XmlAttributeAttribute()][DefaultValue("1,1")]
+ [XmlAttributeAttribute][DefaultValue("1,1")]
public virtual Size MinimumSize {
- get { return minimumSize; }
+ get { unsafe { return nativeHnd->MinimumSize;} }
set {
- if (value == minimumSize)
+ if (value == MinimumSize)
return;
- minimumSize = value;
+ unsafe {
+ nativeHnd->MinimumSize = value;
+ }
- NotifyValueChanged ("MinimumSize", minimumSize);
+ NotifyValueChanged ("MinimumSize", MinimumSize);
RegisterForLayouting (LayoutingType.Sizing);
}
}
- [XmlAttributeAttribute()][DefaultValue("0,0")]
+ [XmlAttributeAttribute][DefaultValue("0,0")]
public virtual Size MaximumSize {
- get { return maximumSize; }
+ get { unsafe { return nativeHnd->MaximumSize;} }
set {
- if (value == maximumSize)
+ if (value == MaximumSize)
return;
+ unsafe {
+ nativeHnd->MaximumSize = value;
+ }
- maximumSize = value;
-
- NotifyValueChanged ("MaximumSize", maximumSize);
+ NotifyValueChanged ("MaximumSize", MaximumSize);
RegisterForLayouting (LayoutingType.Sizing);
}
}
get {
return dataSource == null ?
LogicalParent == null ? null :
- LogicalParent is GraphicObject ? (LogicalParent as GraphicObject).DataSource : null :
- dataSource;
+ LogicalParent.DataSource : dataSource;
}
}
protected virtual void onLogicalParentDataSourceChanged(object sender, DataSourceChangeEventArgs e){
/// <summary>
/// Register old and new slot for clipping
/// </summary>
- public virtual void ClippingRegistration(){
+ unsafe public virtual void ClippingRegistration(){
IsQueueForRedraw = false;
if (Parent == null)
return;
- Parent.RegisterClip (LastPaintedSlot);
- Parent.RegisterClip (Slot);
+ Parent.RegisterClip (nativeHnd->LastPaintedSlot);
+ Parent.RegisterClip (nativeHnd->Slot);
}
/// <summary>
/// Add clip rectangle to this.clipping and propagate up to root
/// </summary>
/// <param name="clip">Clip rectangle</param>
- public virtual void RegisterClip(Rectangle clip){
+ unsafe public virtual void RegisterClip(Rectangle clip){
Rectangle r = clip + ClientRectangle.Position;
if (CacheEnabled && !IsDirty)
Clipping.UnionRectangle (r);
GraphicObject p = Parent as GraphicObject;
if (p?.IsDirty == true && p?.CacheEnabled == true)
return;
- Parent.RegisterClip (r + Slot.Position);
+ Parent.RegisterClip (r + nativeHnd->Slot.Position);
}
/// <summary> Full update, taking care of sizing policy </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
layoutType &= (~LayoutingType.ArrangeChildren);
//apply constraints depending on parent type
- if (Parent is GraphicObject)
- (Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType);
+ Parent.ChildrenLayoutingConstraints (ref layoutType);
// //prevent queueing same LayoutingType for this
// layoutType &= (~RegisteredLayoutings);
/// The redrawing will only be triggered if final slot size has changed </summary>
/// <returns><c>true</c>, if layouting was possible, <c>false</c> if conditions were not
/// met and LQI has to be re-queued</returns>
- public virtual bool UpdateLayout (LayoutingType layoutType)
+ unsafe public virtual bool UpdateLayout (LayoutingType layoutType)
{
//unset bit, it would be reset if LQI is re-queued
- registeredLayoutings &= (~layoutType);
+ RegisteredLayoutings &= (~layoutType);
switch (layoutType) {
case LayoutingType.X:
switch (HorizontalAlignment) {
case HorizontalAlignment.Left:
- Slot.X = 0;
+ nativeHnd->Slot.X = 0;
break;
case HorizontalAlignment.Right:
- Slot.X = Parent.ClientRectangle.Width - Slot.Width;
+ nativeHnd->Slot.X = Parent.ClientRectangle.Width - nativeHnd->Slot.Width;
break;
case HorizontalAlignment.Center:
- Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2;
+ nativeHnd->Slot.X = Parent.ClientRectangle.Width / 2 - nativeHnd->Slot.Width / 2;
break;
}
} else
- Slot.X = Left;
-
- if (LastSlots.X == Slot.X)
+ nativeHnd->Slot.X = Left;
+
+ if (nativeHnd->LastSlot.X == nativeHnd->Slot.X)
break;
IsDirty = true;
OnLayoutChanges (layoutType);
- LastSlots.X = Slot.X;
+ nativeHnd->LastSlot.X = nativeHnd->Slot.X;
break;
case LayoutingType.Y:
if (Top == 0) {
switch (VerticalAlignment) {
case VerticalAlignment.Top://this could be processed even if parent Height is not known
- Slot.Y = 0;
+ nativeHnd->Slot.Y = 0;
break;
case VerticalAlignment.Bottom:
- Slot.Y = Parent.ClientRectangle.Height - Slot.Height;
+ nativeHnd->Slot.Y = Parent.ClientRectangle.Height - nativeHnd->Slot.Height;
break;
case VerticalAlignment.Center:
- Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2;
+ nativeHnd->Slot.Y = Parent.ClientRectangle.Height / 2 - nativeHnd->Slot.Height / 2;
break;
}
} else
- Slot.Y = Top;
+ nativeHnd->Slot.Y = Top;
- if (LastSlots.Y == Slot.Y)
+ if (nativeHnd->LastSlot.Y == nativeHnd->Slot.Y)
break;
IsDirty = true;
OnLayoutChanges (layoutType);
- LastSlots.Y = Slot.Y;
+ nativeHnd->LastSlot.Y = nativeHnd->Slot.Y;
break;
case LayoutingType.Width:
if (Visible) {
if (Width.IsFixed)
- Slot.Width = Width;
+ nativeHnd->Slot.Width = Width;
else if (Width == Measure.Fit) {
- Slot.Width = measureRawSize (LayoutingType.Width);
+ nativeHnd->Slot.Width = measureRawSize (LayoutingType.Width);
} else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width))
return false;
else if (Width == Measure.Stretched)
- Slot.Width = Parent.ClientRectangle.Width;
+ nativeHnd->Slot.Width = Parent.ClientRectangle.Width;
else
- Slot.Width = (int)Math.Round ((double)(Parent.ClientRectangle.Width * Width) / 100.0);
+ nativeHnd->Slot.Width = (int)Math.Round ((double)(Parent.ClientRectangle.Width * Width) / 100.0);
- if (Slot.Width < 0)
+ if (nativeHnd->Slot.Width < 0)
return false;
//size constrain
- if (Slot.Width < MinimumSize.Width) {
- Slot.Width = MinimumSize.Width;
+ if (nativeHnd->Slot.Width < MinimumSize.Width) {
+ nativeHnd->Slot.Width = MinimumSize.Width;
//NotifyValueChanged ("WidthPolicy", Measure.Stretched);
- } else if (Slot.Width > MaximumSize.Width && MaximumSize.Width > 0) {
- Slot.Width = MaximumSize.Width;
+ } else if (nativeHnd->Slot.Width > MaximumSize.Width && MaximumSize.Width > 0) {
+ nativeHnd->Slot.Width = MaximumSize.Width;
//NotifyValueChanged ("WidthPolicy", Measure.Stretched);
}
} else
- Slot.Width = 0;
+ nativeHnd->Slot.Width = 0;
- if (LastSlots.Width == Slot.Width)
+ if (nativeHnd->LastSlot.Width == nativeHnd->Slot.Width)
break;
IsDirty = true;
OnLayoutChanges (layoutType);
- LastSlots.Width = Slot.Width;
+ nativeHnd->LastSlot.Width = nativeHnd->Slot.Width;
break;
case LayoutingType.Height:
if (Visible) {
if (Height.IsFixed)
- Slot.Height = Height;
+ nativeHnd->Slot.Height = Height;
else if (Height == Measure.Fit) {
- Slot.Height = measureRawSize (LayoutingType.Height);
+ nativeHnd->Slot.Height = measureRawSize (LayoutingType.Height);
} else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height))
return false;
else if (Height == Measure.Stretched)
- Slot.Height = Parent.ClientRectangle.Height;
+ nativeHnd->Slot.Height = Parent.ClientRectangle.Height;
else
- Slot.Height = (int)Math.Round ((double)(Parent.ClientRectangle.Height * Height) / 100.0);
+ nativeHnd->Slot.Height = (int)Math.Round ((double)(Parent.ClientRectangle.Height * Height) / 100.0);
- if (Slot.Height < 0)
+ if (nativeHnd->Slot.Height < 0)
return false;
//size constrain
- if (Slot.Height < MinimumSize.Height) {
- Slot.Height = MinimumSize.Height;
+ if (nativeHnd->Slot.Height < MinimumSize.Height) {
+ nativeHnd->Slot.Height = MinimumSize.Height;
//NotifyValueChanged ("HeightPolicy", Measure.Stretched);
- } else if (Slot.Height > MaximumSize.Height && MaximumSize.Height > 0) {
- Slot.Height = MaximumSize.Height;
+ } else if (nativeHnd->Slot.Height > MaximumSize.Height && MaximumSize.Height > 0) {
+ nativeHnd->Slot.Height = MaximumSize.Height;
//NotifyValueChanged ("HeightPolicy", Measure.Stretched);
}
} else
- Slot.Height = 0;
+ nativeHnd->Slot.Height = 0;
- if (LastSlots.Height == Slot.Height)
+ if (nativeHnd->LastSlot.Height == nativeHnd->Slot.Height)
break;
IsDirty = true;
OnLayoutChanges (layoutType);
- LastSlots.Height = Slot.Height;
+ nativeHnd->LastSlot.Height = nativeHnd->Slot.Height;
break;
}
//if no layouting remains in queue for item, registre for redraw
- if (this.registeredLayoutings == LayoutingType.None && IsDirty)
+ if (RegisteredLayoutings == LayoutingType.None && IsDirty)
CurrentInterface.EnqueueForRepaint (this);
return true;
#region Rendering
/// <summary> This is the common overridable drawing routine to create new widget </summary>
- protected virtual void onDraw(Context gr)
+ unsafe protected virtual void onDraw(Context gr)
{
- Rectangle rBack = new Rectangle (Slot.Size);
+ Rectangle rBack = new Rectangle (nativeHnd->Slot.Size);
Background.SetAsSource (gr, rBack);
CairoHelpers.CairoRectangle (gr, rBack, cornerRadius);
/// <summary>
/// Internal drawing context creation on a cached surface limited to slot size
/// this trigger the effective drawing routine </summary>
- protected virtual void RecreateCache ()
+ unsafe protected virtual void RecreateCache ()
{
- int stride = 4 * Slot.Width;
+ int stride = 4 * nativeHnd->Slot.Width;
- int bmpSize = Math.Abs (stride) * Slot.Height;
+ int bmpSize = Math.Abs (stride) * nativeHnd->Slot.Height;
bmp = new byte[bmpSize];
IsDirty = false;
using (ImageSurface draw =
- new ImageSurface(bmp, Format.Argb32, Slot.Width, Slot.Height, stride)) {
+ new ImageSurface(bmp, Format.Argb32, nativeHnd->Slot.Width, nativeHnd->Slot.Height, stride)) {
using (Context gr = new Context (draw)) {
gr.Antialias = Interface.Antialias;
onDraw (gr);
draw.Flush ();
}
}
- protected virtual void UpdateCache(Context ctx){
- Rectangle rb = Slot + Parent.ClientRectangle.Position;
- using (ImageSurface cache = new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, 4 * Slot.Width)) {
+ unsafe protected virtual void UpdateCache(Context ctx){
+ Rectangle rb = nativeHnd->Slot + Parent.ClientRectangle.Position;
+ using (ImageSurface cache = new ImageSurface (bmp, Format.Argb32, nativeHnd->Slot.Width, nativeHnd->Slot.Height, 4 * nativeHnd->Slot.Width)) {
if (clearBackground) {
ctx.Save ();
ctx.Operator = Operator.Clear;
}
/// <summary> Chained painting routine on the parent context of the actual cached version
/// of the widget </summary>
- public virtual void Paint (ref Context ctx)
+ unsafe public virtual void Paint (ref Context ctx)
{
//TODO:this test should not be necessary
- if (Slot.Height < 0 || Slot.Width < 0 || parent == null)
+ if (nativeHnd->Slot.Height < 0 || nativeHnd->Slot.Width < 0 || parent == null)
return;
lock (this) {
if (cacheEnabled) {
- if (Slot.Width > Interface.MaxCacheSize || Slot.Height > Interface.MaxCacheSize)
+ if (nativeHnd->Slot.Width > Interface.MaxCacheSize || nativeHnd->Slot.Height > Interface.MaxCacheSize)
cacheEnabled = false;
}
UpdateCache (ctx);
if (!isEnabled)
- paintDisabled (ctx, Slot + Parent.ClientRectangle.Position);
+ paintDisabled (ctx, nativeHnd->Slot + Parent.ClientRectangle.Position);
} else {
- Rectangle rb = Slot + Parent.ClientRectangle.Position;
+ Rectangle rb = nativeHnd->Slot + Parent.ClientRectangle.Position;
ctx.Save ();
ctx.Translate (rb.X, rb.Y);
onDraw (ctx);
if (!isEnabled)
- paintDisabled (ctx, Slot);
+ paintDisabled (ctx, nativeHnd->Slot);
ctx.Restore ();
}
- LastPaintedSlot = Slot;
+ nativeHnd->LastPaintedSlot = nativeHnd->Slot;
}
}
void paintDisabled(Context gr, Rectangle rb){
#endregion
#region Mouse handling
- public virtual bool MouseIsIn(Point m)
+ unsafe public virtual bool MouseIsIn(Point m)
{
try {
if (!(Visible & isEnabled))
return false;
- if (ScreenCoordinates (Slot).ContainsOrIsEqual (m)) {
+ if (ScreenCoordinates (nativeHnd->Slot).ContainsOrIsEqual (m)) {
Scroller scr = Parent as Scroller;
- if (scr == null) {
- if (Parent is GraphicObject)
- return (Parent as GraphicObject).MouseIsIn (m);
- else return true;
- }
+ if (scr == null)
+ return Parent.MouseIsIn (m);
return scr.MouseIsIn (scr.savedMousePos);
}
} catch (Exception ex) {
public virtual void onMouseMove(object sender, MouseMoveEventArgs e)
{
//bubble event to the top
- GraphicObject p = Parent as GraphicObject;
- if (p != null)
- p.onMouseMove(sender,e);
+ if (Parent != null)
+ Parent.onMouseMove(sender,e);
MouseMove.Raise (this, e);
}
}
}
//bubble event to the top
- GraphicObject p = Parent as GraphicObject;
- if (p != null)
- p.onMouseDown(sender,e);
+ if (Parent != null)
+ Parent.onMouseDown(sender,e);
MouseDown.Raise (this, e);
}
public virtual void onMouseUp(object sender, MouseButtonEventArgs e){
//bubble event to the top
- GraphicObject p = Parent as GraphicObject;
- if (p != null)
- p.onMouseUp(sender,e);
+ if (Parent != null)
+ Parent.onMouseUp(sender,e);
MouseUp.Raise (this, e);
onMouseClick (this, e);
}
}
- public virtual void onMouseClick(object sender, MouseButtonEventArgs e){
- GraphicObject p = Parent as GraphicObject;
- if (p != null)
- p.onMouseClick(sender,e);
+ public virtual void onMouseClick(object sender, MouseButtonEventArgs e){
+ if (Parent != null)
+ Parent.onMouseClick(sender,e);
MouseClick.Raise (this, e);
}
- public virtual void onMouseDoubleClick(object sender, MouseButtonEventArgs e){
- GraphicObject p = Parent as GraphicObject;
- if (p != null)
- p.onMouseDoubleClick(sender,e);
+ public virtual void onMouseDoubleClick(object sender, MouseButtonEventArgs e){
+ if (Parent != null)
+ Parent.onMouseDoubleClick(sender,e);
MouseDoubleClick.Raise (this, e);
}
- public virtual void onMouseWheel(object sender, MouseWheelEventArgs e){
- GraphicObject p = Parent as GraphicObject;
- if (p != null)
- p.onMouseWheel(sender,e);
+ public virtual void onMouseWheel(object sender, MouseWheelEventArgs e){
+ if (Parent != null)
+ Parent.onMouseWheel(sender,e);
MouseWheelChanged.Raise (this, e);
}
return Name == "unamed" ? tmp + "." + this.GetType ().Name : tmp + "." + Name;
#endif
}
+ #region IDisposable implementation
+ ~GraphicObject(){
+ Dispose (false);
+ }
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+ bool disposed = false;
+ protected virtual void Dispose (bool disposing){
+ if (disposed)
+ return;
+ Clipping.Dispose ();
+ unsafe{
+ DestroyGO (nativeHnd);
+ }
+ disposed = true;
+ }
+ #endregion
}
}
this.RegisterForLayouting (LayoutingType.ArrangeChildren);
}
}
- public virtual int CaseWidth {
- get { return (Slot.Width - (ColumnCount - 1) * Spacing) / ColumnCount; }
+ unsafe public virtual int CaseWidth {
+ get { return (nativeHnd->Slot.Width - (ColumnCount - 1) * Spacing) / ColumnCount; }
}
- public virtual int CaseHeight {
- get { return (Slot.Height - (RowCount - 1) * Spacing) / RowCount; }
+ unsafe public virtual int CaseHeight {
+ get { return (nativeHnd->Slot.Height - (RowCount - 1) * Spacing) / RowCount; }
}
#endregion
}
gr.Restore ();
}
- protected override void UpdateCache (Context ctx)
+ unsafe protected override void UpdateCache (Context ctx)
{
- Rectangle rb = Slot + Parent.ClientRectangle.Position;
+ Rectangle rb = nativeHnd->Slot + Parent.ClientRectangle.Position;
- using (ImageSurface cache = new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, 4 * Slot.Width)) {
+ using (ImageSurface cache = new ImageSurface (bmp, Format.Argb32, nativeHnd->Slot.Width, nativeHnd->Slot.Height, 4 * nativeHnd->Slot.Width)) {
Context gr = new Context (cache);
if (!Clipping.IsEmpty) {
foreach (GraphicObject c in Children) {
if (!c.Visible)
continue;
- if (Clipping.Contains (c.Slot + ClientRectangle.Position) == RegionOverlap.Out)
+ if (Clipping.Contains (c.nativeHnd->Slot + ClientRectangle.Position) == RegionOverlap.Out)
continue;
c.Paint (ref gr);
}
}
#endregion
- public virtual void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
+ unsafe public virtual void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
{
GraphicObject g = sender as GraphicObject;
case LayoutingType.Width:
if (Width != Measure.Fit)
return;
- if (g.Slot.Width > contentSize.Width) {
+ if (g.nativeHnd->Slot.Width > contentSize.Width) {
largestChild = g;
- contentSize.Width = g.Slot.Width;
+ contentSize.Width = g.nativeHnd->Slot.Width;
} else if (g == largestChild)
searchLargestChild ();
case LayoutingType.Height:
if (Height != Measure.Fit)
return;
- if (g.Slot.Height > contentSize.Height) {
+ if (g.nativeHnd->Slot.Height > contentSize.Height) {
tallestChild = g;
- contentSize.Height = g.Slot.Height;
+ contentSize.Height = g.nativeHnd->Slot.Height;
} else if (g == tallestChild)
searchTallestChild ();
tallestChild = null;
contentSize = 0;
}
- void searchLargestChild(){
+ unsafe void searchLargestChild(){
#if DEBUG_LAYOUTING
Debug.WriteLine("\tSearch largest child");
#endif
continue;
if (children [i].RegisteredLayoutings.HasFlag (LayoutingType.Width))
continue;
- if (Children [i].Slot.Width > contentSize.Width) {
- contentSize.Width = Children [i].Slot.Width;
+ if (Children [i].nativeHnd->Slot.Width > contentSize.Width) {
+ contentSize.Width = Children [i].nativeHnd->Slot.Width;
largestChild = Children [i];
}
}
}
- void searchTallestChild(){
+ unsafe void searchTallestChild(){
#if DEBUG_LAYOUTING
Debug.WriteLine("\tSearch tallest child");
#endif
continue;
if (children [i].RegisteredLayoutings.HasFlag (LayoutingType.Height))
continue;
- if (Children [i].Slot.Height > contentSize.Height) {
- contentSize.Height = Children [i].Slot.Height;
+ if (Children [i].nativeHnd->Slot.Height > contentSize.Height) {
+ contentSize.Height = Children [i].nativeHnd->Slot.Height;
tallestChild = Children [i];
}
}
gr.Fill();
}
- public override void Paint (ref Context ctx)
+ unsafe public override void Paint (ref Context ctx)
{
base.Paint (ref ctx);
- Rectangle rb = Slot + Parent.ClientRectangle.Position;
+ Rectangle rb = nativeHnd->Slot + Parent.ClientRectangle.Position;
ctx.Save ();
ctx.Translate (rb.X, rb.Y);
+++ /dev/null
-//
-// ILayoutable.cs
-//
-// Author:
-// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-
-namespace Crow
-{
- public interface ILayoutable
- {
- /// <summary> Parent in the graphic tree </summary>
- ILayoutable Parent { get; set; }
- /// <summary> The logical parent (used mainly for bindings) as opposed
- /// to the parent in the graphic tree </summary>
- ILayoutable LogicalParent { get; set; }
-
- Rectangle ClientRectangle { get; }
- Rectangle getSlot();
-
- bool ArrangeChildren { get; }
- LayoutingType RegisteredLayoutings { get; set; }
- void RegisterForLayouting(LayoutingType layoutType);
- void RegisterClip(Rectangle clip);
- bool UpdateLayout(LayoutingType layoutType);
-
-
- Rectangle ContextCoordinates(Rectangle r);
- Rectangle ScreenCoordinates (Rectangle r);
-
- }
-}
-
#endregion
#region Mouse handling
- void updatemouseLocalPos(Point mpos){
- mouseLocalPos = mpos - ScreenCoordinates(Slot).TopLeft - ClientRectangle.TopLeft;
+ unsafe void updatemouseLocalPos(Point mpos){
+ mouseLocalPos = mpos - ScreenCoordinates(nativeHnd->Slot).TopLeft - ClientRectangle.TopLeft;
if (mouseLocalPos.X < 0)
mouseLocalPos.X = 0;
if (mouseLocalPos.Y < 0)
_content.LayoutChanged += _content_LayoutChanged;
}
}
- void positionContent(LayoutingType lt){
- ILayoutable tc = Content.Parent;
+ unsafe void positionContent(LayoutingType lt){
+ GraphicObject tc = Content.Parent;
if (tc == null)
return;
- Rectangle r = this.ScreenCoordinates (this.Slot);
+ Rectangle r = this.ScreenCoordinates (this.nativeHnd->Slot);
if (lt == LayoutingType.X) {
if (popDirection.HasFlag (Alignment.Right)) {
- if (r.Right + Content.Slot.Width > tc.ClientRectangle.Right)
- Content.Left = r.Left - Content.Slot.Width;
+ if (r.Right + Content.nativeHnd->Slot.Width > tc.ClientRectangle.Right)
+ Content.Left = r.Left - Content.nativeHnd->Slot.Width;
else
Content.Left = r.Right;
} else if (popDirection.HasFlag (Alignment.Left)) {
- if (r.Left - Content.Slot.Width < tc.ClientRectangle.Left)
+ if (r.Left - Content.nativeHnd->Slot.Width < tc.ClientRectangle.Left)
Content.Left = r.Right;
else
- Content.Left = r.Left - Content.Slot.Width;
+ Content.Left = r.Left - Content.nativeHnd->Slot.Width;
} else {
- if (Content.Slot.Width < tc.ClientRectangle.Width) {
- if (r.Left + Content.Slot.Width > tc.ClientRectangle.Right)
- Content.Left = tc.ClientRectangle.Right - Content.Slot.Width;
+ if (Content.nativeHnd->Slot.Width < tc.ClientRectangle.Width) {
+ if (r.Left + Content.nativeHnd->Slot.Width > tc.ClientRectangle.Right)
+ Content.Left = tc.ClientRectangle.Right - Content.nativeHnd->Slot.Width;
else
Content.Left = r.Left;
} else
Content.Left = 0;
}
}else if (lt == LayoutingType.Y) {
- if (Content.Slot.Height < tc.ClientRectangle.Height) {
+ if (Content.nativeHnd->Slot.Height < tc.ClientRectangle.Height) {
if (PopDirection.HasFlag (Alignment.Bottom)) {
- if (r.Bottom + Content.Slot.Height > tc.ClientRectangle.Bottom)
- Content.Top = r.Top - Content.Slot.Height;
+ if (r.Bottom + Content.nativeHnd->Slot.Height > tc.ClientRectangle.Bottom)
+ Content.Top = r.Top - Content.nativeHnd->Slot.Height;
else
Content.Top = r.Bottom;
} else if (PopDirection.HasFlag (Alignment.Top)) {
- if (r.Top - Content.Slot.Height < tc.ClientRectangle.Top)
+ if (r.Top - Content.nativeHnd->Slot.Height < tc.ClientRectangle.Top)
Content.Top = r.Bottom;
else
- Content.Top = r.Top - Content.Slot.Height;
+ Content.Top = r.Top - Content.nativeHnd->Slot.Height;
} else
Content.Top = r.Top;
}else
protected GraphicObject child;
- internal virtual void SetChild(GraphicObject _child)
+ unsafe internal virtual void SetChild(GraphicObject _child)
{
if (child != null) {
if (child != null) {
child.Parent = this;
child.LayoutChanged += OnChildLayoutChanges;
- contentSize = child.Slot.Size;
+ contentSize = child.nativeHnd->Slot.Size;
child.RegisteredLayoutings = LayoutingType.None;
child.RegisterForLayouting (LayoutingType.Sizing);
}
return;
child.RegisterForLayouting (ltChild);
}
- public virtual void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
+ unsafe public virtual void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
{
GraphicObject g = sender as GraphicObject;
if (arg.LayoutType == LayoutingType.Width) {
if (Width != Measure.Fit)
return;
- contentSize.Width = g.Slot.Width;
+ contentSize.Width = g.nativeHnd->Slot.Width;
this.RegisterForLayouting (LayoutingType.Width);
}else if (arg.LayoutType == LayoutingType.Height){
if (Height != Measure.Fit)
return;
- contentSize.Height = g.Slot.Height;
+ contentSize.Height = g.nativeHnd->Slot.Height;
this.RegisterForLayouting (LayoutingType.Height);
}
}
}
gr.Restore ();
}
- protected override void UpdateCache (Context ctx)
+ unsafe protected override void UpdateCache (Context ctx)
{
- Rectangle rb = Slot + Parent.ClientRectangle.Position;
+ Rectangle rb = nativeHnd->Slot + Parent.ClientRectangle.Position;
- using (ImageSurface cache = new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, 4 * Slot.Width)) {
+ using (ImageSurface cache = new ImageSurface (bmp, Format.Argb32, nativeHnd->Slot.Width, nativeHnd->Slot.Height, 4 * nativeHnd->Slot.Width)) {
Context gr = new Context (cache);
if (!Clipping.IsEmpty) {
gr.Fill();
}
- public override void Paint (ref Context ctx)
+ unsafe public override void Paint (ref Context ctx)
{
base.Paint (ref ctx);
- Rectangle rb = Slot + Parent.ClientRectangle.Position;
+ Rectangle rb = nativeHnd->Slot + Parent.ClientRectangle.Position;
ctx.Save ();
ctx.Translate (rb.X, rb.Y);
set { _scrollbarVisible = value; }
}
[XmlAttributeAttribute][DefaultValue(0.0)]
- public double ScrollX {
+ unsafe public double ScrollX {
get {
return _scrollX;
}
return;
if (value < 0.0)
_scrollX = 0.0;
- else if (value > Child.Slot.Width - ClientRectangle.Width)
- _scrollX = Math.Max(0.0, Child.Slot.Width - ClientRectangle.Width);
+ else if (value > Child.nativeHnd->Slot.Width - ClientRectangle.Width)
+ _scrollX = Math.Max(0.0, Child.nativeHnd->Slot.Width - ClientRectangle.Width);
else
_scrollX = value;
NotifyValueChanged("ScrollX", _scrollX);
}
}
[XmlAttributeAttribute][DefaultValue(0.0)]
- public double ScrollY {
+ unsafe public double ScrollY {
get {
return _scrollY;
}
return;
if (value < 0.0)
_scrollY = 0.0;
- else if (value > Child.Slot.Height - ClientRectangle.Height)
- _scrollY = Math.Max(0.0,Child.Slot.Height - ClientRectangle.Height);
+ else if (value > Child.nativeHnd->Slot.Height - ClientRectangle.Height)
+ _scrollY = Math.Max(0.0,Child.nativeHnd->Slot.Height - ClientRectangle.Height);
else
_scrollY = value;
NotifyValueChanged("ScrollY", _scrollY);
}
[XmlIgnore]
- public int MaximumScroll {
+ unsafe public int MaximumScroll {
get {
try {
return VerticalScrolling ?
- Math.Max(Child.Slot.Height - ClientRectangle.Height,0) :
- Math.Max(Child.Slot.Width - ClientRectangle.Width,0);
+ Math.Max(Child.nativeHnd->Slot.Height - ClientRectangle.Height,0) :
+ Math.Max(Child.nativeHnd->Slot.Width - ClientRectangle.Width,0);
} catch {
return 0;
}
{
return base.ScreenCoordinates (r) - new Point((int)ScrollX,(int)ScrollY);
}
- protected override void onDraw (Context gr)
+ unsafe protected override void onDraw (Context gr)
{
- Rectangle rBack = new Rectangle (Slot.Size);
+ Rectangle rBack = new Rectangle (nativeHnd->Slot.Size);
Background.SetAsSource (gr, rBack);
CairoHelpers.CairoRectangle(gr,rBack, CornerRadius);
#region Mouse handling
internal Point savedMousePos;
- public override bool MouseIsIn (Point m)
+ unsafe public override bool MouseIsIn (Point m)
{
- return Visible ? base.ScreenCoordinates(Slot).ContainsOrIsEqual (m) : false;
+ return Visible ? base.ScreenCoordinates(nativeHnd->Slot).ContainsOrIsEqual (m) : false;
}
public override void checkHoverWidget (MouseMoveEventArgs e)
{
}
#region mouse handling
- public override void onMouseDown (object sender, MouseButtonEventArgs e)
+ unsafe public override void onMouseDown (object sender, MouseButtonEventArgs e)
{
base.onMouseDown (sender, e);
- Rectangle cursInScreenCoord = ScreenCoordinates (cursor + Slot.Position);
+ Rectangle cursInScreenCoord = ScreenCoordinates (cursor + nativeHnd->Slot.Position);
if (cursInScreenCoord.ContainsOrIsEqual (e.Position))
holdCursor = true;
else if (_orientation == Orientation.Horizontal) {
}
#region GraphicObject override
- public override ILayoutable Parent {
+ public override GraphicObject Parent {
get { return base.Parent; }
set {
if (value != null) {
base.onMouseLeave (sender, e);
CurrentInterface.MouseCursor = XCursor.Default;
}
- public override void onMouseDown (object sender, MouseButtonEventArgs e)
+ unsafe public override void onMouseDown (object sender, MouseButtonEventArgs e)
{
base.onMouseDown (sender, e);
go1 = go2 = null;
go2 = gs.Children [ptrSplit + 1];
if (gs.Orientation == Orientation.Horizontal) {
- initSplit (go1.Width, go1.Slot.Width, go2.Width, go2.Slot.Width);
+ initSplit (go1.Width, go1.nativeHnd->Slot.Width, go2.Width, go2.nativeHnd->Slot.Width);
min1 = go1.MinimumSize.Width;
min2 = go2.MinimumSize.Width;
max1 = go1.MaximumSize.Width;
if (init2 >= 0)
go2.Width = init2;
} else {
- initSplit (go1.Height, go1.Slot.Height, go2.Height, go2.Slot.Height);
+ initSplit (go1.Height, go1.nativeHnd->Slot.Height, go2.Height, go2.nativeHnd->Slot.Height);
min1 = go1.MinimumSize.Height;
min2 = go2.MinimumSize.Height;
max1 = go1.MaximumSize.Height;
go2.Height = init2;
}
}
- public override void onMouseMove (object sender, MouseMoveEventArgs e)
+ unsafe public override void onMouseMove (object sender, MouseMoveEventArgs e)
{
base.onMouseMove (sender, e);
if (gs.Orientation == Orientation.Horizontal) {
newDelta -= e.XDelta;
if (size1 < 0)
- size1 = go1.Slot.Width + delta;
+ size1 = go1.nativeHnd->Slot.Width + delta;
if (size2 < 0)
- size2 = go2.Slot.Width - delta;
+ size2 = go2.nativeHnd->Slot.Width - delta;
} else {
newDelta -= e.YDelta;
if (size1 < 0)
- size1 = go1.Slot.Height + delta;
+ size1 = go1.nativeHnd->Slot.Height + delta;
if (size2 < 0)
- size2 = go2.Slot.Height - delta;
+ size2 = go2.nativeHnd->Slot.Height - delta;
}
if (size1 - newDelta < min1 || (max1 > 0 && size1 - newDelta > max1) ||
go2.Height = init2 + delta;
}
}
- public override void onMouseUp (object sender, MouseButtonEventArgs e)
+ unsafe public override void onMouseUp (object sender, MouseButtonEventArgs e)
{
base.onMouseUp (sender, e);
if (init1 >= 0 && u1 == Unit.Percent) {
if (gs.Orientation == Orientation.Horizontal)
go1.Width = new Measure ((int)Math.Ceiling (
- go1.Width.Value * 100.0 / (double)gs.Slot.Width), Unit.Percent);
+ go1.Width.Value * 100.0 / (double)gs.nativeHnd->Slot.Width), Unit.Percent);
else
go1.Height = new Measure ((int)Math.Ceiling (
- go1.Height.Value * 100.0 / (double)gs.Slot.Height), Unit.Percent);
+ go1.Height.Value * 100.0 / (double)gs.nativeHnd->Slot.Height), Unit.Percent);
}
if (init2 >= 0 && u2 == Unit.Percent) {
if (gs.Orientation == Orientation.Horizontal)
go2.Width = new Measure ((int)Math.Floor (
- go2.Width.Value * 100.0 / (double)gs.Slot.Width), Unit.Percent);
+ go2.Width.Value * 100.0 / (double)gs.nativeHnd->Slot.Width), Unit.Percent);
else
go2.Height = new Measure ((int)Math.Floor (
- go2.Height.Value * 100.0 / (double)gs.Slot.Height), Unit.Percent);
+ go2.Height.Value * 100.0 / (double)gs.nativeHnd->Slot.Height), Unit.Percent);
}
}
public override bool UpdateLayout (LayoutingType layoutType)
NotifyValueChanged ("IsSelected", isSelected);
}
}
- protected override void onDraw (Cairo.Context gr)
+ unsafe protected override void onDraw (Cairo.Context gr)
{
gr.Save ();
int spacing = (Parent as TabView).Spacing;
- gr.MoveTo (0.5, TabTitle.Slot.Bottom-0.5);
- gr.LineTo (TabTitle.Slot.Left - spacing, TabTitle.Slot.Bottom-0.5);
+ gr.MoveTo (0.5, TabTitle.nativeHnd->Slot.Bottom-0.5);
+ gr.LineTo (TabTitle.nativeHnd->Slot.Left - spacing, TabTitle.nativeHnd->Slot.Bottom-0.5);
gr.CurveTo (
- TabTitle.Slot.Left - spacing / 2, TabTitle.Slot.Bottom-0.5,
- TabTitle.Slot.Left - spacing / 2, 0.5,
- TabTitle.Slot.Left, 0.5);
- gr.LineTo (TabTitle.Slot.Right, 0.5);
+ TabTitle.nativeHnd->Slot.Left - spacing / 2, TabTitle.nativeHnd->Slot.Bottom-0.5,
+ TabTitle.nativeHnd->Slot.Left - spacing / 2, 0.5,
+ TabTitle.nativeHnd->Slot.Left, 0.5);
+ gr.LineTo (TabTitle.nativeHnd->Slot.Right, 0.5);
gr.CurveTo (
- TabTitle.Slot.Right + spacing / 2, 0.5,
- TabTitle.Slot.Right + spacing / 2, TabTitle.Slot.Bottom-0.5,
- TabTitle.Slot.Right + spacing, TabTitle.Slot.Bottom-0.5);
- gr.LineTo (Slot.Width-0.5, TabTitle.Slot.Bottom-0.5);
+ TabTitle.nativeHnd->Slot.Right + spacing / 2, 0.5,
+ TabTitle.nativeHnd->Slot.Right + spacing / 2, TabTitle.nativeHnd->Slot.Bottom-0.5,
+ TabTitle.nativeHnd->Slot.Right + spacing, TabTitle.nativeHnd->Slot.Bottom-0.5);
+ gr.LineTo (nativeHnd->Slot.Width-0.5, TabTitle.nativeHnd->Slot.Bottom-0.5);
- gr.LineTo (Slot.Width-0.5, Slot.Height-0.5);
- gr.LineTo (0.5, Slot.Height-0.5);
+ gr.LineTo (nativeHnd->Slot.Width-0.5, nativeHnd->Slot.Height-0.5);
+ gr.LineTo (0.5, nativeHnd->Slot.Height-0.5);
gr.ClosePath ();
gr.LineWidth = 2;
Foreground.SetAsSource (gr);
}
#region Mouse Handling
- public override bool MouseIsIn (Point m)
+ unsafe public override bool MouseIsIn (Point m)
{
if (!Visible)
return false;
- bool mouseIsInTitle = TabTitle.ScreenCoordinates (TabTitle.Slot).ContainsOrIsEqual (m);
+ bool mouseIsInTitle = TabTitle.ScreenCoordinates (TabTitle.nativeHnd->Slot).ContainsOrIsEqual (m);
if (!IsSelected)
return mouseIsInTitle;
- return _contentContainer.ScreenCoordinates (_contentContainer.Slot).ContainsOrIsEqual (m)
+ return _contentContainer.ScreenCoordinates (_contentContainer.nativeHnd->Slot).ContainsOrIsEqual (m)
|| mouseIsInTitle;
}
bool holdCursor = false;
holdCursor = false;
(Parent as TabView).UpdateLayout (LayoutingType.ArrangeChildren);
}
- public override void onMouseMove (object sender, MouseMoveEventArgs e)
+ unsafe public override void onMouseMove (object sender, MouseMoveEventArgs e)
{
base.onMouseMove (sender, e);
int tmp = TabOffset + e.XDelta;
if (tmp < tv.Spacing)
TabOffset = tv.Spacing;
- else if (tmp > Parent.getSlot ().Width - TabTitle.Slot.Width - tv.Spacing)
- TabOffset = Parent.getSlot ().Width - TabTitle.Slot.Width - tv.Spacing;
+ else if (tmp > Parent.getSlot ().Width - TabTitle.nativeHnd->Slot.Width - tv.Spacing)
+ TabOffset = Parent.getSlot ().Width - TabTitle.nativeHnd->Slot.Width - tv.Spacing;
else{
int idx = tv.Children.IndexOf (this);
if (idx > 0 && e.XDelta < 0) {
previous = tv.Children [idx - 1] as TabItem;
- if (tmp < previous.TabOffset + previous.TabTitle.Slot.Width / 2) {
+ if (tmp < previous.TabOffset + previous.TabTitle.nativeHnd->Slot.Width / 2) {
tv.Children.RemoveAt (idx);
tv.Children.Insert (idx - 1, this);
tv.SelectedTab = idx - 1;
}else if (idx < tv.Children.Count - 1 && e.XDelta > 0) {
next = tv.Children [idx + 1] as TabItem;
- if (tmp > next.TabOffset - next.TabTitle.Slot.Width / 2){
+ if (tmp > next.TabOffset - next.TabTitle.nativeHnd->Slot.Width / 2){
tv.Children.RemoveAt (idx);
tv.Children.Insert (idx + 1, this);
tv.SelectedTab = idx + 1;
SelectedTab = selectedTab;
}
public override bool ArrangeChildren { get { return true; } }
- public override bool UpdateLayout (LayoutingType layoutType)
+ unsafe public override bool UpdateLayout (LayoutingType layoutType)
{
RegisteredLayoutings &= (~layoutType);
if (Orientation == Orientation.Horizontal) {
if (ti.TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Width))
return false;
- curOffset += ti.TabTitle.Slot.Width + Spacing;
+ curOffset += ti.TabTitle.nativeHnd->Slot.Width + Spacing;
} else {
if (ti.TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Height))
return false;
- curOffset += ti.TabTitle.Slot.Height + Spacing;
+ curOffset += ti.TabTitle.nativeHnd->Slot.Height + Spacing;
}
}
return base.UpdateLayout(layoutType);
}
- protected override void onDraw (Context gr)
+ unsafe protected override void onDraw (Context gr)
{
- Rectangle rBack = new Rectangle (Slot.Size);
+ Rectangle rBack = new Rectangle (nativeHnd->Slot.Size);
Background.SetAsSource (gr, rBack);
CairoHelpers.CairoRectangle(gr,rBack, CornerRadius);
if (SelectedTab > Children.Count - 1)
return;
- if (((Children[SelectedTab] as TabItem).Content.Parent as GraphicObject).MouseIsIn(e.Position))
+ if ((Children[SelectedTab] as TabItem).Content.Parent.MouseIsIn(e.Position))
{
Children[SelectedTab].checkHoverWidget (e);
return;
// } else if (e.LayoutType == LayoutingType.Height)
// _gsList.Height = approxSize;
// }
- int approxSize
+ unsafe int approxSize
{
get {
if (data == null)
return page1.Orientation == Orientation.Horizontal ?
data.Count < itemPerPage ?
-1:
- (int)Math.Ceiling ((double)page1.Slot.Width / (double)itemPerPage * (double)(data.Count+1)):
+ (int)Math.Ceiling ((double)page1.nativeHnd->Slot.Width / (double)itemPerPage * (double)(data.Count+1)):
data.Count < itemPerPage ?
-1:
- (int)Math.Ceiling ((double)page1.Slot.Height / (double)itemPerPage * (double)(data.Count+1));
+ (int)Math.Ceiling ((double)page1.nativeHnd->Slot.Height / (double)itemPerPage * (double)(data.Count+1));
}
}
internal virtual void itemClick(object sender, MouseButtonEventArgs e){
//register ItemClick on the Root node
TreeView tv = this as TreeView;
while (!tv.IsRoot) {
- ILayoutable tmp = tv.Parent;
+ GraphicObject tmp = tv.Parent;
while (!(tmp is TreeView)) {
tmp = tmp.Parent;
}
#endregion
#region GraphicObject Overrides
- public override void onMouseMove (object sender, MouseMoveEventArgs e)
+ unsafe public override void onMouseMove (object sender, MouseMoveEventArgs e)
{
base.onMouseMove (sender, e);
int currentWidth, currentHeight;
if (currentLeft == 0) {
- currentLeft = this.Slot.Left;
+ currentLeft = this.nativeHnd->Slot.Left;
this.Left = currentLeft;
}
if (currentTop == 0) {
- currentTop = this.Slot.Top;
+ currentTop = this.nativeHnd->Slot.Top;
this.Top = currentTop;
}
if (this.Width.IsFixed)
currentWidth = this.Width;
else
- currentWidth = this.Slot.Width;
+ currentWidth = this.nativeHnd->Slot.Width;
if (this.Height.IsFixed)
currentHeight = this.Height;
else
- currentHeight = this.Slot.Height;
+ currentHeight = this.nativeHnd->Slot.Height;
switch (currentDirection) {
case Direction.None:
if (Resizable) {
Direction lastDir = currentDirection;
- if (Math.Abs (e.Position.Y - this.Slot.Y) < Interface.BorderThreshold) {
- if (Math.Abs (e.Position.X - this.Slot.X) < Interface.BorderThreshold)
+ if (Math.Abs (e.Position.Y - this.nativeHnd->Slot.Y) < Interface.BorderThreshold) {
+ if (Math.Abs (e.Position.X - this.nativeHnd->Slot.X) < Interface.BorderThreshold)
currentDirection = Direction.NW;
- else if (Math.Abs (e.Position.X - this.Slot.Right) < Interface.BorderThreshold)
+ else if (Math.Abs (e.Position.X - this.nativeHnd->Slot.Right) < Interface.BorderThreshold)
currentDirection = Direction.NE;
else
currentDirection = Direction.N;
- } else if (Math.Abs (e.Position.Y - this.Slot.Bottom) < Interface.BorderThreshold) {
- if (Math.Abs (e.Position.X - this.Slot.X) < Interface.BorderThreshold)
+ } else if (Math.Abs (e.Position.Y - this.nativeHnd->Slot.Bottom) < Interface.BorderThreshold) {
+ if (Math.Abs (e.Position.X - this.nativeHnd->Slot.X) < Interface.BorderThreshold)
currentDirection = Direction.SW;
- else if (Math.Abs (e.Position.X - this.Slot.Right) < Interface.BorderThreshold)
+ else if (Math.Abs (e.Position.X - this.nativeHnd->Slot.Right) < Interface.BorderThreshold)
currentDirection = Direction.SE;
else
currentDirection = Direction.S;
- } else if (Math.Abs (e.Position.X - this.Slot.X) < Interface.BorderThreshold)
+ } else if (Math.Abs (e.Position.X - this.nativeHnd->Slot.X) < Interface.BorderThreshold)
currentDirection = Direction.W;
- else if (Math.Abs (e.Position.X - this.Slot.Right) < Interface.BorderThreshold)
+ else if (Math.Abs (e.Position.X - this.nativeHnd->Slot.Right) < Interface.BorderThreshold)
currentDirection = Direction.E;
else
currentDirection = Direction.None;
}
#endregion
- protected void onMaximized (object sender, EventArgs e){
+ unsafe protected void onMaximized (object sender, EventArgs e){
lock (CurrentInterface.LayoutMutex) {
if (!IsMinimized)
- savedBounds = this.LastPaintedSlot;
+ savedBounds = nativeHnd->LastPaintedSlot;
this.Left = this.Top = 0;
this.RegisterForLayouting (LayoutingType.Positioning);
this.Width = this.Height = Measure.Stretched;
Unmaximized.Raise (sender, e);
}
- protected void onMinimized (object sender, EventArgs e){
+ unsafe protected void onMinimized (object sender, EventArgs e){
lock (CurrentInterface.LayoutMutex) {
if (IsNormal)
- savedBounds = this.LastPaintedSlot;
+ savedBounds = nativeHnd->LastPaintedSlot;
Width = 200;
Height = 20;
Resizable = false;
{
layoutType &= (~LayoutingType.Positioning);
}
- public override void ComputeChildrenPositions()
+ unsafe public override void ComputeChildrenPositions()
{
int dx = 0;
int dy = 0;
foreach (GraphicObject c in Children) {
if (!c.Visible)
continue;
- if (dx + c.Slot.Width > ClientRectangle.Width) {
+ if (dx + c.nativeHnd->Slot.Width > ClientRectangle.Width) {
dx = 0;
dy += tallestChild + Spacing;
- c.Slot.X = dx;
- c.Slot.Y = dy;
- tallestChild = c.Slot.Height;
+ c.nativeHnd->Slot.X = dx;
+ c.nativeHnd->Slot.Y = dy;
+ tallestChild = c.nativeHnd->Slot.Height;
} else {
- if (tallestChild < c.Slot.Height)
- tallestChild = c.Slot.Height;
- c.Slot.X = dx;
- c.Slot.Y = dy;
+ if (tallestChild < c.nativeHnd->Slot.Height)
+ tallestChild = c.nativeHnd->Slot.Height;
+ c.nativeHnd->Slot.X = dx;
+ c.nativeHnd->Slot.Y = dy;
}
- dx += c.Slot.Width + Spacing;
+ dx += c.nativeHnd->Slot.Width + Spacing;
}
} else {
int largestChild = 0;
foreach (GraphicObject c in Children) {
if (!c.Visible)
continue;
- if (dy + c.Slot.Height > ClientRectangle.Height) {
+ if (dy + c.nativeHnd->Slot.Height > ClientRectangle.Height) {
dy = 0;
dx += largestChild + Spacing;
- c.Slot.X = dx;
- c.Slot.Y = dy;
- largestChild = c.Slot.Width;
+ c.nativeHnd->Slot.X = dx;
+ c.nativeHnd->Slot.Y = dy;
+ largestChild = c.nativeHnd->Slot.Width;
} else {
- if (largestChild < c.Slot.Width)
- largestChild = c.Slot.Width;
- c.Slot.X = dx;
- c.Slot.Y = dy;
+ if (largestChild < c.nativeHnd->Slot.Width)
+ largestChild = c.nativeHnd->Slot.Width;
+ c.nativeHnd->Slot.X = dx;
+ c.nativeHnd->Slot.Y = dy;
}
- dy += c.Slot.Height + Spacing;
+ dy += c.nativeHnd->Slot.Height + Spacing;
}
}
IsDirty = true;
#endregion
#region GraphicObject Overrides
- protected override int measureRawSize (LayoutingType lt)
+ unsafe protected override int measureRawSize (LayoutingType lt)
{
int tmp = 0;
//Wrapper can't fit in the opposite direction of the wrapper, this func is called only if Fit
if (c.Height.Units == Unit.Percent &&
c.RegisteredLayoutings.HasFlag (LayoutingType.Height))
return -1;
- if (dy + c.Slot.Height > ClientRectangle.Height) {
+ if (dy + c.nativeHnd->Slot.Height > ClientRectangle.Height) {
dy = 0;
tmp += largestChild + Spacing;
- largestChild = c.Slot.Width;
- } else if (largestChild < c.Slot.Width)
- largestChild = c.Slot.Width;
+ largestChild = c.nativeHnd->Slot.Width;
+ } else if (largestChild < c.nativeHnd->Slot.Width)
+ largestChild = c.nativeHnd->Slot.Width;
- dy += c.Slot.Height + Spacing;
+ dy += c.nativeHnd->Slot.Height + Spacing;
}
if (dy == 0)
tmp -= Spacing;
if (c.Width.Units == Unit.Percent &&
c.RegisteredLayoutings.HasFlag (LayoutingType.Width))
return -1;
- if (dx + c.Slot.Width > ClientRectangle.Width) {
+ if (dx + c.nativeHnd->Slot.Width > ClientRectangle.Width) {
dx = 0;
tmp += tallestChild + Spacing;
- tallestChild = c.Slot.Height;
- } else if (tallestChild < c.Slot.Height)
- tallestChild = c.Slot.Height;
+ tallestChild = c.nativeHnd->Slot.Height;
+ } else if (tallestChild < c.nativeHnd->Slot.Height)
+ tallestChild = c.nativeHnd->Slot.Height;
- dx += c.Slot.Width + Spacing;
+ dx += c.nativeHnd->Slot.Width + Spacing;
}
if (dx == 0)
tmp -= Spacing;
/// - Keyboard and Mouse logic
/// - the resulting bitmap of the interface
/// </summary>
- public class Interface : ILayoutable
+ public class Interface : GraphicObject
{
#region CTOR
static Interface(){
}
/// <summary>Clipping Rectangles drive the drawing process. For compositing, each object under a clip rectangle should be
/// repainted. If it contains also clip rectangles, its cache will be update, or if not cached a full redraw will take place</summary>
- void processDrawing(){
+ unsafe void processDrawing(){
#if MEASURE_TIME
drawingMeasure.StartCycle();
#endif
GraphicObject p = GraphicTree[i];
if (!p.Visible)
continue;
- if (clipping.Contains (p.Slot) == RegionOverlap.Out)
+ if (clipping.Contains (p.nativeHnd->Slot) == RegionOverlap.Out)
continue;
ctx.Save ();
//check topmost graphicobject first
GraphicObject tmp = HoverWidget;
GraphicObject topc = null;
- while (tmp is GraphicObject) {
+ while (!(tmp is Interface)) {
topc = tmp;
- tmp = tmp.LogicalParent as GraphicObject;
+ tmp = tmp.LogicalParent;
}
int idxhw = GraphicTree.IndexOf (topc);
if (idxhw != 0) {
if (GraphicTree [i].MouseIsIn (e.Position)) {
while (HoverWidget != null) {
HoverWidget.onMouseLeave (HoverWidget, e);
- HoverWidget = HoverWidget.LogicalParent as GraphicObject;
+ HoverWidget = HoverWidget.LogicalParent;
}
GraphicTree [i].checkHoverWidget (e);
} else {
HoverWidget.onMouseLeave (HoverWidget, e);
//seek upward from last focused graph obj's
- while (HoverWidget.LogicalParent as GraphicObject != null) {
- HoverWidget = HoverWidget.LogicalParent as GraphicObject;
+ while (!(HoverWidget.LogicalParent is Interface)) {
+ HoverWidget = HoverWidget.LogicalParent;
if (HoverWidget.MouseIsIn (e.Position)) {
HoverWidget.checkHoverWidget (e);
return true;
_focusedWidget.onKeyPress (this, e);
return true;
}
+ public override void onMouseMove (object sender, MouseMoveEventArgs e) {}
+ public override void onMouseUp (object sender, MouseButtonEventArgs e) {}
+ public override void onMouseDown (object sender, MouseButtonEventArgs e) {}
+ public override void onMouseClick (object sender, MouseButtonEventArgs e) {}
+ public override void onMouseDoubleClick (object sender, MouseButtonEventArgs e) {}
+ public override void onMouseWheel (object sender, MouseWheelEventArgs e) {}
+
#endregion
#region Device Repeat Events
}
#endregion
- #region ILayoutable implementation
- public void RegisterClip(Rectangle r){
+ public override void RegisterClip(Rectangle r){
clipping.UnionRectangle (r);
}
- public bool ArrangeChildren { get { return false; }}
- public int LayoutingTries {
- get { throw new NotImplementedException (); }
+ public override bool ArrangeChildren { get { return false; }}
+ public override void RegisterForLayouting (LayoutingType layoutType) { }
+ public override bool UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); }
+ public override Rectangle ContextCoordinates (Rectangle r) { return r;}
+ public override Rectangle ScreenCoordinates (Rectangle r) { return r; }
+ public override GraphicObject Parent {
+ get { return null; }
set { throw new NotImplementedException (); }
}
- public LayoutingType RegisteredLayoutings {
- get { return LayoutingType.None; }
- set { throw new NotImplementedException (); }
+ public override Rectangle ClientRectangle {
+ get { return clientRectangle; }
}
- public void RegisterForLayouting (LayoutingType layoutType) { throw new NotImplementedException (); }
- public bool UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); }
- public Rectangle ContextCoordinates (Rectangle r) { return r;}
- public Rectangle ScreenCoordinates (Rectangle r) { return r; }
-
- public ILayoutable Parent {
- get { return null; }
+ public override Rectangle getSlot () { return ClientRectangle; }
+ public override Measure WidthPolicy { get { return Measure.Stretched; }}
+ public override Measure HeightPolicy { get { return Measure.Stretched; }}
+ public override Measure Width {
set { throw new NotImplementedException (); }
+ get { return clientRectangle.Width; }
}
- public ILayoutable LogicalParent {
- get { return null; }
+ public override Measure Height {
set { throw new NotImplementedException (); }
+ get { return clientRectangle.Height; }
}
-
- public Rectangle ClientRectangle {
- get { return clientRectangle; }
- }
- public Interface HostContainer {
- get { return this; }
- }
- public Rectangle getSlot () { return ClientRectangle; }
- #endregion
+ public override bool MouseIsIn (Point m) => true;
#if MEASURE_TIME
public PerformanceMeasure clippingMeasure = new PerformanceMeasure("Clipping", 100);
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
+using System.Runtime.InteropServices;
namespace Crow
{
/// <summary>
/// Element class of the LayoutingQueue
/// </summary>
+ [StructLayout(LayoutKind.Sequential)]
public struct LayoutingQueueItem
{
/// <summary> Instance of widget to be layouted</summary>
- public ILayoutable Layoutable;
+ public GraphicObject Layoutable;
/// <summary> Bitfield containing the element of the layout to performs (x|y|width|height)</summary>
public LayoutingType LayoutType;
/// <summary> Unsuccessfull UpdateLayout and requeueing count </summary>
#endif
#region CTOR
- public LayoutingQueueItem (LayoutingType _layoutType, ILayoutable _graphicObject)
+ public LayoutingQueueItem (LayoutingType _layoutType, GraphicObject _graphicObject)
{
LayoutType = _layoutType;
Layoutable = _graphicObject;
#endif
if (LayoutingTries < Interface.MaxLayoutingTries) {
Layoutable.RegisteredLayoutings |= LayoutType;
- (Layoutable as GraphicObject).CurrentInterface.LayoutingQueue.Enqueue (this);
+ Layoutable.CurrentInterface.LayoutingQueue.Enqueue (this);
} else if (DiscardCount < Interface.MaxDiscardCount) {
#if DEBUG_LAYOUTING
Debug.WriteLine ("\t\tDiscarded");
LayoutingTries = 0;
DiscardCount++;
Layoutable.RegisteredLayoutings |= LayoutType;
- (Layoutable as GraphicObject).CurrentInterface.DiscardQueue.Enqueue (this);
+ Layoutable.CurrentInterface.DiscardQueue.Enqueue (this);
}
#if DEBUG_LAYOUTING
else
// THE SOFTWARE.
using System;
+using System.Runtime.InteropServices;
namespace Crow
{
/// <summary>
/// Measurement unit
/// </summary>
- public enum Unit { Pixel, Percent, Inherit }
+ public enum Unit : byte { Pixel, Percent, Inherit }
/// <summary>
/// Measure class allow proportional sizes as well as stretched and fit on content.
/// </summary>
+ [StructLayout(LayoutKind.Sequential)]
public struct Measure
{
/// <summary>
using System;
using Crow;
using System.Runtime.InteropServices;
+using System.Diagnostics;
namespace testDrm
{
unsafe static Rectangle* rect;
unsafe static void Main(){
+ const int count = 10000;
rect = allocate();
- update (150, 160);
- Console.WriteLine (rect->Height);
- rect->Height = 200;
+ Console.WriteLine ("function update");
+ Stopwatch sw = Stopwatch.StartNew ();
+ for (int i = 0; i < count; i++) {
+ update (150, 160);
+ }
+ sw.Stop ();
+ Console.WriteLine ("{0} updates in {1} ticks and {2} ms", count, sw.ElapsedTicks, sw.ElapsedMilliseconds);
+
+ Console.WriteLine ("field update");
+ sw.Restart ();
+ for (int i = 0; i < count; i++) {
+ rect->Height = 200;
+ rect->Width = 250;
+ }
+ sw.Stop ();
+ Console.WriteLine ("{0} updates in {1} ticks and {2} ms", count, sw.ElapsedTicks, sw.ElapsedMilliseconds);
+
Console.WriteLine (rect->Height);
// Rectangle bounds = new Rectangle(0,0,1024,768);
// Interface iface = new Interface();
<Command type="Execute" command="${TargetName}" workingdir="${SolutionDir}/build/${ProjectConfigName}" />
</CustomCommands>
</CustomCommands>
- <StartupObject>testDrm.TestCrow</StartupObject>
+ <StartupObject>testDrm.TestApp</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
- <DefineConstants>DEBUG;</DefineConstants>
+ <DefineConstants>DEBUG;MEASURE_TIME</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<?xml version="1.0"?>
-<Window Caption="Performances" Height="160" Width="200" CornerRadius="5">
+<Window Caption="Performances" Height="160" Width="200" CornerRadius="5" MinimumSize="50,50">
<VerticalStack Width="90%" Height="Fit" Spacing="1" Margin="10">
<HorizontalStack>
<Label Text="Frame:" Style="FpsLabel"/>