<Compile Include="src\Mono.Cairo\EGLDevice.cs" />
<Compile Include="src\Mono.Cairo\DRMDevice.cs" />
<Compile Include="src\Mono.Cairo\DRMSurface.cs" />
+ <Compile Include="src\Crow.Native\crow_object_t.cs" />
+ <Compile Include="src\Crow.Native\LibCrow.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Folder Include="src\rsvg\" />
<Folder Include="src\IML\" />
<Folder Include="Icons\" />
+ <Folder Include="src\Crow.Native\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Images\Icons\updown.svg" />
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DRI.net", "..\DRI.net\DRI.net.csproj", "{0189EAEF-DCD4-42F8-A83A-2DEA82926671}"
EndProject
+Project("{2857B73E-F847-4B02-9238-064979017E93}") = "libcrow", "..\libcrow\libcrow.cproj", "{6CD55032-B8D6-4238-AA91-F9145E1217D4}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0189EAEF-DCD4-42F8-A83A-2DEA82926671}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {0189EAEF-DCD4-42F8-A83A-2DEA82926671}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0189EAEF-DCD4-42F8-A83A-2DEA82926671}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0189EAEF-DCD4-42F8-A83A-2DEA82926671}.Release|Any CPU.Build.0 = Release|Any CPU
{4B57740A-75FB-4978-A8E8-8B1793B7474F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4B57740A-75FB-4978-A8E8-8B1793B7474F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B57740A-75FB-4978-A8E8-8B1793B7474F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B57740A-75FB-4978-A8E8-8B1793B7474F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6CD55032-B8D6-4238-AA91-F9145E1217D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6CD55032-B8D6-4238-AA91-F9145E1217D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6CD55032-B8D6-4238-AA91-F9145E1217D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6CD55032-B8D6-4238-AA91-F9145E1217D4}.Release|Any CPU.Build.0 = Release|Any CPU
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Any CPU.Build.0 = Release|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6D911CD-1D09-42FC-B300-9187190F2AE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B6D911CD-1D09-42FC-B300-9187190F2AE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6D911CD-1D09-42FC-B300-9187190F2AE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6D911CD-1D09-42FC-B300-9187190F2AE1}.Release|Any CPU.Build.0 = Release|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
internal static FieldInfo miSetCurIface = typeof(GraphicObject).GetField ("currentInterface", BindingFlags.NonPublic | BindingFlags.Instance);
internal static MethodInfo miFindByName = typeof (GraphicObject).GetMethod ("FindByName");
internal static MethodInfo miGetGObjItem = typeof(List<GraphicObject>).GetMethod("get_Item", new Type[] { typeof(Int32) });
- internal static MethodInfo miLoadDefaultVals = typeof (GraphicObject).GetMethod ("loadDefaultValues");
+ internal static MethodInfo miLoadDefaultVals = typeof (GraphicObject).GetMethod ("loadDefaultValues", BindingFlags.NonPublic | BindingFlags.Instance);
internal static PropertyInfo piStyle = typeof (GraphicObject).GetProperty ("Style");
internal static MethodInfo miGetLogicalParent = typeof(GraphicObject).GetProperty("LogicalParent").GetGetMethod();
internal static MethodInfo miGetDataSource = typeof(GraphicObject).GetProperty("DataSource").GetGetMethod ();
--- /dev/null
+//
+// LibCrow.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.Runtime.InteropServices;
+
+namespace Crow.Native
+{
+ internal static class LibCrow
+ {
+ #region PINVOKE
+ const string lib = "libcrow";
+ [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+ unsafe internal static extern IntPtr crow_context_create ();
+ [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+ unsafe internal static extern void crow_context_destroy (IntPtr ctx);
+ [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+ unsafe internal static extern void crow_context_process_layouting (IntPtr layCtx);
+ [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+ unsafe internal static extern void crow_context_process_clipping (IntPtr ctx);
+
+ [DllImport(lib)]
+ unsafe internal static extern crow_object_t* crow_object_create();
+ [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+ unsafe internal static extern void crow_object_destroy(crow_object_t* go);
+ [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+ unsafe internal static extern void crow_object_set_type (crow_object_t* go, CrowType objType);
+ [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+ unsafe internal static extern byte crow_object_do_layout (crow_object_t* go, LayoutingType layout);
+ [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+ unsafe internal static extern void crow_object_register_layouting (crow_object_t* go, LayoutingType layout);
+ #endregion
+ }
+}
+
--- /dev/null
+//
+// crow_object_t.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.Runtime.InteropServices;
+using System;
+
+namespace Crow.Native {
+ public enum CrowType : byte {
+ Simple,
+ Container,
+ Group,
+ Stack
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ unsafe public struct crow_object_t {
+ public CrowType TypeObj;
+ public IntPtr Context;
+ public int ChildrenCount;
+ public crow_object_t* Parent;
+ public crow_object_t** Children;
+ public int Left;
+ public int Top;
+ public Measure Width;
+ public Measure Height;
+ public int Margin;
+ public Size MinimumSize;
+ public Size MaximumSize;
+ public byte Visible;
+ /// <summary>if true, content has to be recreated</summary>
+ public byte IsDirty;
+ public byte InClippingPool;
+ public IntPtr Clipping;
+ public LayoutingType RegisteredLayoutings;
+ /// <summary>
+ /// Current size and position computed during layouting pass
+ /// </summary>
+ public Rectangle Slot;
+ public Size ContentSize;
+ /// <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;
+ public IntPtr bmp;
+
+ public IntPtr MeasureRawSize;
+ public IntPtr UpdateLayout;
+ public IntPtr OnLayoutChanged;
+ public IntPtr OnChildLayoutChanged;
+ public IntPtr ChildrenLayoutingConstraints;
+ public IntPtr OnDraw;
+
+ }
+}
\ No newline at end of file
#endregion
#region GraphicObject Overrides
- public override bool ArrangeChildren { get { return true; } }
public override void ChildrenLayoutingConstraints (ref LayoutingType layoutType)
{
//Prevent child repositionning in the direction of stacking
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
+using Crow.Native;
namespace Crow
{
- [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;
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate void LayoutChangedCallBack (LayoutingType lt);
- unsafe public bool Visible {
- get { return visible > 0; }
- set {
- 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
-
internal static ulong currentUid = 0;
internal ulong uid = 0;
- unsafe internal NativeGO* nativeHnd;
+ unsafe internal crow_object_t* nativeHnd;
#region IValueChange implementation
public event EventHandler<ValueChangeEventArgs> ValueChanged;
public GraphicObject ()
{
unsafe {
- nativeHnd = CreateGO ();
+ nativeHnd = LibCrow.crow_object_create ();
+ LibCrow.crow_object_set_type (nativeHnd, CrowType.Simple);
+ nativeHnd->Context = Interface.CurrentInterface.layoutingCtx;
+ //nativeHnd->OnLayoutChanged = Marshal.GetFunctionPointerForDelegate((LayoutChangedCallBack)OnLayoutChanges);
}
#if DEBUG
uid = currentUid;
currentUid++;
#endif
}
+ internal protected GraphicObject (bool isInterface){
+ }
#endregion
/// <summary>
public virtual void Initialize(){
if (currentInterface == null)
currentInterface = Interface.CurrentInterface;
+
loadDefaultValues ();
}
#region private fields
public bool IsQueueForRedraw = false;
/// <summary>drawing Cache bitmap</summary>
public byte[] bmp;
- /// <summary>if true, content has to be recreated</summary>
- public bool IsDirty = true;
+
/// <summary>
/// This size is computed on each child' layout changes.
/// In stacking widget, it is used to compute the remaining space for the stretched
/// <summary>
/// Parent in the graphic tree, used for rendering and layouting
/// </summary>
- [XmlIgnore]public virtual GraphicObject Parent {
+ [XmlIgnore]unsafe public virtual GraphicObject Parent {
get { return parent; }
set {
if (parent == value)
DataSourceChangeEventArgs e = new DataSourceChangeEventArgs (parent, value);
lock (this) {
parent = value;
- //nativeHnd->Parent = value?.nativeHnd;
+ if (parent == null)
+ nativeHnd->Parent = null;
+ else
+ nativeHnd->Parent = value.nativeHnd;
}
onParentChanged (this, e);
}
[XmlAttributeAttribute][DefaultValue(true)]
public virtual bool Visible {
- get { unsafe { return nativeHnd->Visible;} }
+ get { unsafe { return nativeHnd->Visible>0;} }
set {
if (value == Visible)
return;
unsafe {
- nativeHnd->Visible = value;
+ if (value)
+ nativeHnd->Visible = 1;
+ else
+ nativeHnd->Visible = 0;
}
RegisterForLayouting (LayoutingType.Sizing);
NotifyValueChanged ("Visible", Visible);
}
}
+ [XmlIgnore]unsafe public bool IsDirty {
+ get { return nativeHnd->IsDirty>0; }
+ set {
+ if (value)
+ nativeHnd->IsDirty = 1;
+ else
+ nativeHnd->IsDirty = 0;
+ }
+ }
+
[XmlAttributeAttribute][DefaultValue(true)]
public virtual bool IsEnabled {
get { return isEnabled; }
#region Default and Style Values loading
/// <summary> Loads the default values from XML attributes default </summary>
- public void loadDefaultValues()
+ internal void loadDefaultValues()
{
#if DEBUG_LOAD
Debug.WriteLine ("LoadDefValues for " + this.ToString ());
il.Emit(OpCodes.Ret);
#endregion
- try {
+ //try {
Interface.DefaultValuesLoader[styleKey] = (Interface.LoaderInvoker)dm.CreateDelegate(typeof(Interface.LoaderInvoker));
Interface.DefaultValuesLoader[styleKey] (this);
- } catch (Exception ex) {
- throw new Exception ("Error applying style <" + styleKey + ">:", ex);
- }
+// } catch (Exception ex) {
+// throw new Exception ("Error applying style <" + styleKey + ">:", ex);
+// }
}
bool getDefaultEvent(EventInfo ei, List<Style> styling,
out string expression){
/// <summary> By default in groups, LayoutingType.ArrangeChildren is reset </summary>
public virtual void ChildrenLayoutingConstraints(ref LayoutingType layoutType){
}
- public virtual bool ArrangeChildren { get { return false; } }
- public virtual void RegisterForLayouting(LayoutingType layoutType){
- if (Parent == null)
- return;
- lock (CurrentInterface.LayoutMutex) {
- //prevent queueing same LayoutingType for this
- layoutType &= (~RegisteredLayoutings);
-
- if (layoutType == LayoutingType.None)
- return;
- //dont set position for stretched item
- if (Width == Measure.Stretched)
- layoutType &= (~LayoutingType.X);
- if (Height == Measure.Stretched)
- layoutType &= (~LayoutingType.Y);
- if (!ArrangeChildren)
- layoutType &= (~LayoutingType.ArrangeChildren);
-
- //apply constraints depending on parent type
- Parent.ChildrenLayoutingConstraints (ref layoutType);
-
-// //prevent queueing same LayoutingType for this
-// layoutType &= (~RegisteredLayoutings);
-
- if (layoutType == LayoutingType.None)
- return;
-
- //enqueue LQI LayoutingTypes separately
- if (layoutType.HasFlag (LayoutingType.Width))
- CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
- if (layoutType.HasFlag (LayoutingType.Height))
- CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
- if (layoutType.HasFlag (LayoutingType.X))
- CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
- if (layoutType.HasFlag (LayoutingType.Y))
- CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
- if (layoutType.HasFlag (LayoutingType.ArrangeChildren))
- CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
- }
+ unsafe public virtual void RegisterForLayouting(LayoutingType layoutType){
+ LibCrow.crow_object_register_layouting (this.nativeHnd, layoutType);
}
/// <summary> trigger dependant sizing component update </summary>
public virtual void OnLayoutChanges(LayoutingType layoutType)
{
#if DEBUG_LAYOUTING
- CurrentInterface.currentLQI.Slot = LastSlots;
- CurrentInterface.currentLQI.NewSlot = Slot;
- Debug.WriteLine ("\t\t{0} => {1}",LastSlots,Slot);
+// CurrentInterface.currentLQI.Slot = LastSlots;
+// CurrentInterface.currentLQI.NewSlot = Slot;
+ unsafe{
+ Debug.WriteLine ("\t\t{0} => {1}", nativeHnd->LastSlot, nativeHnd->Slot);
+ }
#endif
switch (layoutType) {
case LayoutingType.Height:
RegisterForLayouting (LayoutingType.Y);
break;
+ case LayoutingType.X:
+ Console.WriteLine (Name);
+ break;
}
- LayoutChanged.Raise (this, new LayoutingEventArgs (layoutType));
+
+
+ //LayoutChanged.Raise (this, new LayoutingEventArgs (layoutType));
}
internal protected void raiseLayoutChanged(LayoutingEventArgs e){
LayoutChanged.Raise (this, e);
/// met and LQI has to be re-queued</returns>
unsafe public virtual bool UpdateLayout (LayoutingType layoutType)
{
+ if (LibCrow.crow_object_do_layout (nativeHnd, layoutType)==0)
+ return false;
+
//unset bit, it would be reset if LQI is re-queued
- RegisteredLayoutings &= (~layoutType);
+ //RegisteredLayoutings &= (~layoutType);
switch (layoutType) {
- case LayoutingType.X:
- if (Left == 0) {
-
- if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width) ||
- RegisteredLayoutings.HasFlag (LayoutingType.Width))
- return false;
-
- switch (HorizontalAlignment) {
- case HorizontalAlignment.Left:
- nativeHnd->Slot.X = 0;
- break;
- case HorizontalAlignment.Right:
- nativeHnd->Slot.X = Parent.ClientRectangle.Width - nativeHnd->Slot.Width;
- break;
- case HorizontalAlignment.Center:
- nativeHnd->Slot.X = Parent.ClientRectangle.Width / 2 - nativeHnd->Slot.Width / 2;
- break;
- }
- } else
- nativeHnd->Slot.X = Left;
-
- if (nativeHnd->LastSlot.X == nativeHnd->Slot.X)
- break;
-
- IsDirty = true;
-
- OnLayoutChanges (layoutType);
-
- nativeHnd->LastSlot.X = nativeHnd->Slot.X;
- break;
+// case LayoutingType.X:
+// if (nativeHnd->LastSlot.X == nativeHnd->Slot.X)
+// break;
+//
+// IsDirty = true;
+//
+// OnLayoutChanges (layoutType);
+//
+// nativeHnd->LastSlot.X = nativeHnd->Slot.X;
+// break;
case LayoutingType.Y:
if (Top == 0) {
return;
Clipping.Dispose ();
unsafe{
- DestroyGO (nativeHnd);
+ LibCrow.crow_object_destroy (nativeHnd);
}
disposed = true;
}
else
SelectedTab = selectedTab;
}
- public override bool ArrangeChildren { get { return true; } }
unsafe public override bool UpdateLayout (LayoutingType layoutType)
{
RegisteredLayoutings &= (~layoutType);
public override void OnLayoutChanges (LayoutingType layoutType)
{
#if DEBUG_LAYOUTING
- CurrentInterface.currentLQI.Slot = LastSlots;
- CurrentInterface.currentLQI.Slot = Slot;
+// CurrentInterface.currentLQI.Slot = LastSlots;
+// CurrentInterface.currentLQI.Slot = Slot;
#endif
switch (layoutType) {
case LayoutingType.Width:
using System.Xml.Serialization;
using Cairo;
using System.Globalization;
+using Crow.Native;
namespace Crow
{
FontRenderingOptions.HintStyle = HintStyle.Medium;
FontRenderingOptions.SubpixelOrder = SubpixelOrder.Rgb;
}
- public Interface(){
+ public Interface() : base (true){
CurrentInterface = this;
+ layoutingCtx = LibCrow.crow_context_create ();
+ unsafe {
+ nativeHnd = LibCrow.crow_object_create ();
+ }
+
CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
}
#endregion
internal static Interface CurrentInterface;
internal Stopwatch clickTimer = new Stopwatch();
internal GraphicObject eligibleForDoubleClick = null;
+ internal IntPtr layoutingCtx = IntPtr.Zero;
#endregion
#region Events
/// Store loaded resources instances shared among controls to reduce memory footprint
/// </summary>
public Dictionary<string,object> Ressources = new Dictionary<string, object>();
- /// <summary>The Main layouting queue.</summary>
- public Queue<LayoutingQueueItem> LayoutingQueue = new Queue<LayoutingQueueItem> ();
- /// <summary>Store discarded lqi between two updates</summary>
- public Queue<LayoutingQueueItem> DiscardQueue;
/// <summary>Main drawing queue, holding layouted controls</summary>
public Queue<GraphicObject> DrawingQueue = new Queue<GraphicObject>();
public string Clipboard;//TODO:use object instead for complex copy paste
/// not added to the GraphicTree</summary>
public GraphicObject Load (string path)
{
- try {
+ //try {
return GetInstantiator (path).CreateInstance (this);
- } catch (Exception ex) {
- throw new Exception ("Error loading <" + path + ">:", ex);
- }
+ //} catch (Exception ex) {
+ // throw new Exception ("Error loading <" + path + ">:", ex);
+ //}
}
/// <summary>Fetch it from cache or create it</summary>
public static Instantiator GetInstantiator(string path){
#if MEASURE_TIME
layoutingMeasure.StartCycle();
#endif
-
if (Monitor.TryEnter (LayoutMutex)) {
- DiscardQueue = new Queue<LayoutingQueueItem> ();
- //Debug.WriteLine ("======= Layouting queue start =======");
- LayoutingQueueItem lqi;
- while (LayoutingQueue.Count > 0) {
- lqi = LayoutingQueue.Dequeue ();
- #if DEBUG_LAYOUTING
- currentLQI = lqi;
- curLQIsTries.Add(currentLQI);
- #endif
- lqi.ProcessLayouting ();
- }
- LayoutingQueue = DiscardQueue;
+ LibCrow.crow_context_process_layouting (layoutingCtx);
Monitor.Exit (LayoutMutex);
- DiscardQueue = null;
}
-
#if MEASURE_TIME
layoutingMeasure.StopCycle();
#endif
#if MEASURE_TIME
clippingMeasure.StartCycle();
#endif
- GraphicObject g = null;
- while (DrawingQueue.Count > 0) {
- lock (DrawingQueue)
- g = DrawingQueue.Dequeue ();
- lock (g)
- g.ClippingRegistration ();
- }
-
+ LibCrow.crow_context_process_layouting (layoutingCtx);
#if MEASURE_TIME
clippingMeasure.StopCycle();
#endif
public void ProcessResize(Rectangle bounds){
lock (UpdateMutex) {
+ unsafe {
+ nativeHnd->Slot.Width = bounds.Width;
+ nativeHnd->Slot.Height = bounds.Height;
+ }
clientRectangle = bounds;
int stride = 4 * ClientRectangle.Width;
int bmpSize = Math.Abs (stride) * ClientRectangle.Height;
public override void RegisterClip(Rectangle r){
clipping.UnionRectangle (r);
}
- 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 Measure Height {
set { throw new NotImplementedException (); }
- get { return clientRectangle.Height; }
+ get { return clientRectangle.Height; }
}
public override bool MouseIsIn (Point m) => true;
+ #if DEBUG
+ public void DumpTo (string path) {
+ using (surf = new ImageSurface (bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height, ClientRectangle.Width * 4)) {
+ surf.WriteToPng (path);
+ }
+ }
+ #endif
+
#if MEASURE_TIME
public PerformanceMeasure clippingMeasure = new PerformanceMeasure("Clipping", 100);
public PerformanceMeasure layoutingMeasure = new PerformanceMeasure("Layouting", 100);
// }
public LayoutingQueueItem currentLQI;
#else
- public List<LQIList> LQIs = null;//still create the var for CrowIDE
+ //public List<LQIList> LQIs = null;//still create the var for CrowIDE
#endif
+ bool disposed = false;
+ protected override void Dispose (bool disposing)
+ {
+ if (disposed)
+ return;
+
+ if (disposing) {
+ clipping.Dispose ();
+ }
+
+ LibCrow.crow_context_destroy (layoutingCtx);
+
+ disposed = true;
+
+ base.Dispose (disposing);
+ }
}
}
ArrangeChildren = 0x10,
All = 0xFF
}
-
- /// <summary>
- /// Element class of the LayoutingQueue
- /// </summary>
- [StructLayout(LayoutKind.Sequential)]
- public struct LayoutingQueueItem
- {
- /// <summary> Instance of widget to be layouted</summary>
- 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>
- public int LayoutingTries, DiscardCount;
-
- #if DEBUG_LAYOUTING
- public Stopwatch LQITime;
- public GraphicObject graphicObject {
- get { return Layoutable as GraphicObject; }
- }
- public string Name {
- get { return graphicObject.Name; }
- }
- public string FullName {
- get { return graphicObject.ToString(); }
- }
- public Measure Width {
- get { return graphicObject.Width; }
- }
- public Measure Height {
- get { return graphicObject.Height; }
- }
- public Rectangle Slot, NewSlot;
- #endif
-
- #region CTOR
- public LayoutingQueueItem (LayoutingType _layoutType, GraphicObject _graphicObject)
- {
- LayoutType = _layoutType;
- Layoutable = _graphicObject;
- Layoutable.RegisteredLayoutings |= LayoutType;
- LayoutingTries = 0;
- DiscardCount = 0;
- #if DEBUG_LAYOUTING
- LQITime = new Stopwatch();
- Slot = Rectangle.Empty;
- NewSlot = Rectangle.Empty;
- Debug.WriteLine ("\tRegister => " + this.ToString ());
- #endif
- }
- #endregion
-
-
- public void ProcessLayouting()
- {
- if (Layoutable.Parent == null) {//TODO:improve this
- //cancel layouting for object without parent, maybe some were in queue when
- //removed from a listbox
- #if DEBUG_LAYOUTING
- Debug.WriteLine ("ERROR: processLayouting, no parent for: " + this.ToString ());
- #endif
- return;
- }
- #if DEBUG_LAYOUTING
- LQITime.Start();
- Debug.WriteLine ("=> " + this.ToString ());
- #endif
- LayoutingTries++;
- if (!Layoutable.UpdateLayout (LayoutType)) {
- #if DEBUG_LAYOUTING
- Debug.WriteLine ("\t\tRequeued");
- #endif
- if (LayoutingTries < Interface.MaxLayoutingTries) {
- Layoutable.RegisteredLayoutings |= LayoutType;
- Layoutable.CurrentInterface.LayoutingQueue.Enqueue (this);
- } else if (DiscardCount < Interface.MaxDiscardCount) {
- #if DEBUG_LAYOUTING
- Debug.WriteLine ("\t\tDiscarded");
- #endif
- LayoutingTries = 0;
- DiscardCount++;
- Layoutable.RegisteredLayoutings |= LayoutType;
- Layoutable.CurrentInterface.DiscardQueue.Enqueue (this);
- }
- #if DEBUG_LAYOUTING
- else
- Debug.WriteLine ("\tDELETED => " + this.ToString ());
- #endif
- }
- #if DEBUG_LAYOUTING
- else{
- if (LayoutingTries > 2 || DiscardCount > 0)
- Debug.WriteLine (this.ToString ());
- }
- LQITime.Stop();
- #endif
- }
-
- public static implicit operator GraphicObject(LayoutingQueueItem queueItem)
- {
- return queueItem.Layoutable as GraphicObject;
- }
- public static implicit operator LayoutingType(LayoutingQueueItem lqi)
- {
- return lqi.LayoutType;
- }
- public override string ToString ()
- {
- #if DEBUG_LAYOUTING
- return string.Format ("{2};{3};{4} {1}->{0}", LayoutType,Layoutable.ToString(),
- LayoutingTries,DiscardCount,LQITime.ElapsedTicks);
- #else
- return string.Format ("{2};{3} {1}->{0}", LayoutType,Layoutable.ToString(),
- LayoutingTries, DiscardCount);
- #endif
- }
- }
- public class LQIList : List<LayoutingQueueItem>{
-// #if DEBUG_LAYOUTING
-// public List<LayoutingQueueItem> GetRootLQIs(){
-// return this.Where (lqi => lqi.wasTriggeredBy == null).ToList ();
-// }
-// #endif
- }
}
using Crow;
using System.Runtime.InteropServices;
using System.Diagnostics;
+using System.Runtime.CompilerServices;
namespace testDrm
{
public class TestCrow
{
+ //const string lib = "/mnt/data2/devel/crow/libcrow/bin/Debug/libcrow.so";
const string lib = "/home/jp/devel/testsharedlib/bin/Debug/libcrow.so";
- [DllImport(lib)]
- unsafe static extern Rectangle* allocate();
+ [StructLayout(LayoutKind.Sequential)]
+ public struct testStruct {
+ public object instance;
+ public int a;
+ public int b;
+ }
- [DllImport(lib)]
- public static extern void update (int w, int h);
+ public class testClass {
+ public string alpha = "this is a test string";
+ public int a = 10,b=20;
+ }
+ [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+ internal static extern void testAppDomain();
- unsafe static Rectangle* rect;
+ [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int gimmePI (ref testStruct t);
- unsafe static void Main(){
- const int count = 10000;
- rect = allocate();
- 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);
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ internal static extern int gimme (ref testStruct t);
- 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);
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ public extern object UnsafeGetValue (object obj);
- Console.WriteLine (rect->Height);
-// Rectangle bounds = new Rectangle(0,0,1024,768);
-// Interface iface = new Interface();
-// iface.ProcessResize (bounds);
-//
-// iface.LoadInterface ("#testDrm.ui.go.crow");
-//
-// while (true)
-// iface.Update ();
+ static void Main(){
+ using (Interface iface = new Interface ()) {
+ iface.ProcessResize (new Rectangle (0, 0, 1024, 768));
+ iface.LoadInterface ("#testDrm.ui.go.crow");
+ iface.Update ();
+ iface.DumpTo ("/home/jp/test.png");
+ }
}
}
}
<Command type="Execute" command="${TargetName}" workingdir="${SolutionDir}/build/${ProjectConfigName}" />
</CustomCommands>
</CustomCommands>
- <StartupObject>testDrm.TestApp</StartupObject>
+ <StartupObject>testDrm.TestCrow</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <Externalconsole>true</Externalconsole>
<IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
- <OutputPath>$(SolutionDir)build\Debug</OutputPath>
+ <OutputPath>$(SolutionDir)build\$(Configuration)</OutputPath>
<CustomCommands>
<CustomCommands>
- <Command type="BeforeExecute" command="sudo setcap CAP_SYS_ADMIN=+ep ${TargetName}" workingdir="${SolutionDir}/build/${ProjectConfigName}" />
- <Command type="Execute" command="${TargetName}" workingdir="${SolutionDir}/build/${ProjectConfigName}" pauseExternalConsole="True" />
+ <Command type="Execute" command="${TargetName}" workingdir="${SolutionDir}/build/${ProjectConfigName}" externalConsole="True" pauseExternalConsole="True" />
</CustomCommands>
</CustomCommands>
- <Externalconsole>true</Externalconsole>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<ConsolePause>false</ConsolePause>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
- <OutputPath>$(SolutionDir)build\Release</OutputPath>
+ <OutputPath>$(SolutionDir)build\$(Configuration)</OutputPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<?xml version="1.0"?>
-<GraphicObject Width="200" Height="200" Background="Mantis"/>
\ No newline at end of file
+<GraphicObject Width="Stretched" Height="Stretched" Background="Mantis"/>
\ No newline at end of file