]> O.S.I.I.S - jp/crow.git/commitdiff
Several Lock while debuging for magicCrow, Image Opacity, could be put in GraphicObj
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 14 Feb 2017 23:27:39 +0000 (00:27 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 14 Feb 2017 23:27:39 +0000 (00:27 +0100)
Crow.csproj
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/Image.cs
src/Instantiator.cs
src/Interface.cs

index f5d90aa42e6ee45b570db3a7743f68c051e965df..ab9ff58d4f95a75a7d79e518c783c442ac66d1cb 100644 (file)
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <Description>C# Rapid Open Widget</Description>
     <BaseAddress>4194304</BaseAddress>
-    <ReleaseVersion>0.5</ReleaseVersion>
     <OutputPath>$(SolutionDir)build\$(Configuration)</OutputPath>
     <IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
     <AssemblyOriginatorKeyFile>crow.key</AssemblyOriginatorKeyFile>
-    <ProductVersion>8.0.30703</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
index 7aac41d7eadd1ecfc44ae923f7e513519817c21e..287edd50f7b72714f90cbc72560c3b16476562db 100644 (file)
@@ -135,7 +135,8 @@ namespace Crow
                                if (parent == value)
                                        return;
                                DataSourceChangeEventArgs e = new DataSourceChangeEventArgs (parent, value);
-                               parent = value;
+                               lock (this)
+                                       parent = value;
 
                                onParentChanged (this, e);
                        }
@@ -1115,34 +1116,35 @@ namespace Crow
                public virtual void Paint (ref Context ctx)
                {
                        //TODO:this test should not be necessary
-                       if (Slot.Height < 0 || Slot.Width < 0)
+                       if (Slot.Height < 0 || Slot.Width < 0 || parent == null)
                                return;
+                       lock (this) {
+                               LastPaintedSlot = Slot;
 
-                       LastPaintedSlot = Slot;
+                               if (cacheEnabled) {
+                                       if (Slot.Width > Interface.MaxCacheSize || Slot.Height > Interface.MaxCacheSize)
+                                               cacheEnabled = false;
+                               }
 
-                       if (cacheEnabled) {
-                               if (Slot.Width > Interface.MaxCacheSize || Slot.Height > Interface.MaxCacheSize)
-                                       cacheEnabled = false;
-                       }
+                               if (cacheEnabled) {
+                                       if (IsDirty)
+                                               RecreateCache ();
 
-                       if (cacheEnabled) {
-                               if (IsDirty)
-                                       RecreateCache ();
+                                       UpdateCache (ctx);
+                                       if (!isEnabled)
+                                               paintDisabled (ctx, Slot + Parent.ClientRectangle.Position);
+                               } else {
+                                       Rectangle rb = Slot + Parent.ClientRectangle.Position;
+                                       ctx.Save ();
 
-                               UpdateCache (ctx);
-                               if (!isEnabled)
-                                       paintDisabled (ctx, Slot + Parent.ClientRectangle.Position);
-                       } else {
-                               Rectangle rb = Slot + Parent.ClientRectangle.Position;
-                               ctx.Save ();
+                                       ctx.Translate (rb.X, rb.Y);
 
-                               ctx.Translate (rb.X, rb.Y);
+                                       onDraw (ctx);
+                                       if (!isEnabled)
+                                               paintDisabled (ctx, Slot);
 
-                               onDraw (ctx);
-                               if (!isEnabled)
-                                       paintDisabled (ctx, Slot);
-
-                               ctx.Restore ();
+                                       ctx.Restore ();
+                               }
                        }
                }
                void paintDisabled(Context gr, Rectangle rb){
index 6e470b9538310f31a7fa67883594e9a6aecfb4ee..1e0e7b58b160f217f9b0cfbcedd78c328ec08f00 100644 (file)
@@ -61,11 +61,13 @@ namespace Crow
         }
                public virtual void ClearChildren()
                {
-                       while(Children.Count > 0){
-                               GraphicObject g = Children[Children.Count-1];
-                               g.LayoutChanged -= OnChildLayoutChanges;
-                               g.Parent = null;
-                               Children.RemoveAt(Children.Count-1);
+                       lock (children) {
+                               while (Children.Count > 0) {
+                                       GraphicObject g = Children [Children.Count - 1];
+                                       g.LayoutChanged -= OnChildLayoutChanges;
+                                       g.Parent = null;
+                                       Children.RemoveAt (Children.Count - 1);
+                               }
                        }
 
                        resetChildrenMaxSize ();
@@ -78,16 +80,20 @@ namespace Crow
                {
                        if (Children.Contains(w))
                        {
-                               Children.Remove(w);
-                               Children.Add(w);
+                               lock (children) {
+                                       Children.Remove (w);
+                                       Children.Add (w);
+                               }
                        }
                }
                public void putWidgetOnBottom(GraphicObject w)
                {
                        if (Children.Contains(w))
                        {
-                               Children.Remove(w);
-                               Children.Insert(0, w);
+                               lock (children) {
+                                       Children.Remove (w);
+                                       Children.Insert (0, w);
+                               }
                        }
                }
 
@@ -95,21 +101,25 @@ namespace Crow
                public override void OnDataSourceChanged (object sender, DataSourceChangeEventArgs e)
                {
                        base.OnDataSourceChanged (this, e);
-                       foreach (GraphicObject g in children)
-                               if (g.localDataSourceIsNull & g.localLogicalParentIsNull)
-                                       g.OnDataSourceChanged (sender, e);
+                       lock (children) {
+                               foreach (GraphicObject g in children)
+                                       if (g.localDataSourceIsNull & g.localLogicalParentIsNull)
+                                               g.OnDataSourceChanged (sender, e);
+                       }
                }
                public override GraphicObject FindByName (string nameToFind)
                {
                        if (Name == nameToFind)
                                return this;
-
-                       foreach (GraphicObject w in Children) {
-                               GraphicObject r = w.FindByName (nameToFind);
-                               if (r != null)
-                                       return r;
+                       GraphicObject tmp = null;
+                       lock (children) {
+                               foreach (GraphicObject w in Children) {
+                                       tmp = w.FindByName (nameToFind);
+                                       if (tmp != null)
+                                               break;
+                               }
                        }
-                       return null;
+                       return tmp;
                }
                public override bool Contains (GraphicObject goToFind)
                {
index 281011ad886acd29131ea949bf7c5c405fd97864..1b32d70d2261df4fa44356bd75325e204f26c367 100644 (file)
@@ -12,6 +12,7 @@ namespace Crow
                Picture _pic;
                string _svgSub;
                bool scaled, keepProps;
+               double opacity;
 
                #region Public properties
                [XmlAttributeAttribute][DefaultValue(true)]
@@ -84,6 +85,17 @@ namespace Crow
                                RegisterForGraphicUpdate ();
                        }
                }
+               [XmlAttributeAttribute()][DefaultValue(1.0)]
+               public virtual double Opacity {
+                       get { return opacity; }
+                       set {
+                               if (opacity == value)
+                                       return;
+                               opacity = value;
+                               NotifyValueChanged ("Faded", opacity);
+                               RegisterForRedraw ();
+                       }
+               }
                #endregion
 
                #region CTOR
@@ -129,6 +141,14 @@ namespace Crow
                                return;
 
                        _pic.Paint (gr, ClientRectangle, _svgSub);
+
+                       if (Opacity<1.0) {
+                               gr.SetSourceRGBA (0.0, 0.0, 0.0, 1.0-Opacity);
+                               gr.Operator = Operator.DestOut;
+                               gr.Rectangle (ClientRectangle);
+                               gr.Fill ();
+                               gr.Operator = Operator.Over;
+                       }
                }
                #endregion
        }
index 57e48015b62461d6bbe97f8df79c1a057148e4db..3be86ce46d6dbff759d1dddfdcfc63ec35507ea2 100644 (file)
@@ -863,6 +863,8 @@ namespace Crow
                                il.Emit(OpCodes.Ldc_I4, dmVC);//load index of dynmathod
                                il.Emit (OpCodes.Call, CompilerServices.miDSChangeEmitHelper);
 
+                               il.MarkLabel (cancel);
+
                                if (bindingDef.TwoWay){
                                        il.Emit (OpCodes.Ldarg_1);//arg1: dataSourceChange source, the origine of the binding
                                        il.Emit (OpCodes.Ldstr, bindingDef.SourceMember);//arg2: orig member
@@ -872,7 +874,6 @@ namespace Crow
                                        il.Emit (OpCodes.Call, CompilerServices.miDSReverseBinding);
                                }
 
-                               il.MarkLabel (cancel);
                        }
                        il.Emit (OpCodes.Ret);
 
@@ -901,6 +902,9 @@ namespace Crow
                                Debug.WriteLine ("Member '{0}' not found in new DataSource '{1}' of '{2}'", destMember, dest, orig);
                                return;
                        }
+                       #if DEBUG_BINDING
+                       Debug.WriteLine ("DS Reverse binding: Member '{0}' found in new DS '{1}' of '{2}'", destMember, dest, orig);
+                       #endif
 
                        #region ValueChanged emit
                        DynamicMethod dm = new DynamicMethod ("dyn_valueChanged" + NewId,
index 924f092eb9ccb57a28900e1627dcd2435de88363..e90ae42cd27554701acd34b0523e3945746985f4 100644 (file)
@@ -472,8 +472,12 @@ namespace Crow
                                lock (DrawingQueue)
                                        g = DrawingQueue.Dequeue ();
                                g.IsQueueForRedraw = false;
-                               g.Parent.RegisterClip (g.LastPaintedSlot);
-                               g.Parent.RegisterClip (g.getSlot ());
+                               if (g.Parent == null)
+                                       continue;
+                               lock (g) {
+                                       g.Parent.RegisterClip (g.LastPaintedSlot);
+                                       g.Parent.RegisterClip (g.getSlot ());
+                               }
                        }
 
                        #if MEASURE_TIME