diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-02-05 10:17:21 +0100 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-02-05 10:17:21 +0100 |
| commit | 7d507f3dc431e1a052f28cfb935ffad7afc7f074 (patch) | |
| tree | 8bf2a26e33ed6303d0d12924fc0fd0a1240a8e19 | |
| parent | 2d20e043e62bd075b3f5f6c4e4bedb2ab7d910f8 (diff) | |
add Caching property to Group, to allow disabling caching for very often updated surface
| -rw-r--r-- | Crow.userprefs | 16 | ||||
| -rwxr-xr-x | Tests/Interfaces/4.crow | 8 | ||||
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 13 | ||||
| -rw-r--r-- | src/GraphicObjects/Group.cs | 22 |
4 files changed, 39 insertions, 20 deletions
diff --git a/Crow.userprefs b/Crow.userprefs index a89a8f1f..1119c399 100644 --- a/Crow.userprefs +++ b/Crow.userprefs @@ -1,17 +1,11 @@ <Properties GitUserInfo="UsingGIT" StartupItem="Tests/Tests.csproj"> <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|Linux_x86" /> - <MonoDevelop.Ide.Workbench ActiveDocument="Tests/GOLIBTests.cs"> + <MonoDevelop.Ide.Workbench ActiveDocument="src/GraphicObjects/Group.cs"> <Files> - <File FileName="Tests/GOLIBTests.cs" Line="98" Column="2" /> - <File FileName="src/GraphicObjects/GraphicObject.cs" Line="538" Column="3" /> - <File FileName="src/GraphicObjects/Group.cs" Line="197" Column="1" /> - <File FileName="src/GraphicObjects/PrivateContainer.cs" Line="127" Column="1" /> - <File FileName="src/OpenTKGameWindow.cs" Line="328" Column="10" /> - <File FileName="src/Rectangles.cs" Line="90" Column="21" /> - <File FileName="src/GraphicObjects/Scroller.cs" Line="196" Column="1" /> - <File FileName="src/LayoutingQueue.cs" Line="30" Column="4" /> - <File FileName="src/Interface.cs" Line="56" Column="1" /> - <File FileName="UnitTest/NUnitCrowWindow.cs" Line="163" Column="1" /> + <File FileName="Tests/Interfaces/4.crow" Line="371" Column="19" /> + <File FileName="Tests/GOLIBTests.cs" Line="40" Column="6" /> + <File FileName="src/GraphicObjects/Group.cs" Line="247" Column="31" /> + <File FileName="src/GraphicObjects/GraphicObject.cs" Line="462" Column="22" /> </Files> </MonoDevelop.Ide.Workbench> <MonoDevelop.Ide.DebuggingService.Breakpoints> diff --git a/Tests/Interfaces/4.crow b/Tests/Interfaces/4.crow index 833e2bce..ba7cb110 100755 --- a/Tests/Interfaces/4.crow +++ b/Tests/Interfaces/4.crow @@ -1,6 +1,6 @@ <?xml version="1.0"?> <HorizontalStack Fit="true"> - <VerticalStack Fit="true" Name="vsFps" Spacing="10" > + <VerticalStack Fit="true" Spacing="10" Caching="false"> <HorizontalStack Fit="true"> <Label Text="Update:" Width="50" TextAlignment="RightCenter"/> <Label Name="labUpdate" Text="{update}" Font="droid,12" Width="80" TextAlignment="Center" @@ -92,7 +92,7 @@ Background="vgradient|0:AoEnglish|1:Black"/> </HorizontalStack> </VerticalStack> - <VerticalStack Fit="true" Name="vsFps" Spacing="10" > + <VerticalStack Fit="true" Spacing="10" Caching="false"> <HorizontalStack Fit="true"> <Label Text="Update:" Width="50" TextAlignment="RightCenter"/> <Label Name="labUpdate" Text="{update}" Font="droid,12" Width="80" TextAlignment="Center" @@ -184,7 +184,7 @@ Background="vgradient|0:AoEnglish|1:Black"/> </HorizontalStack> </VerticalStack> - <VerticalStack Fit="true" Name="vsFps" Spacing="10" > + <VerticalStack Fit="true" Spacing="10" Caching="false"> <HorizontalStack Fit="true"> <Label Text="Update:" Width="50" TextAlignment="RightCenter"/> <Label Name="labUpdate" Text="{update}" Font="droid,12" Width="80" TextAlignment="Center" @@ -276,7 +276,7 @@ Background="vgradient|0:AoEnglish|1:Black"/> </HorizontalStack> </VerticalStack> - <VerticalStack Fit="true" Name="vsFps" Spacing="10" > + <VerticalStack Fit="true" Spacing="10" Caching="false"> <HorizontalStack Fit="true"> <Label Text="Update:" Width="50" TextAlignment="RightCenter"/> <Label Name="labUpdate" Text="{update}" Font="droid,12" Width="80" TextAlignment="Center" diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index b9b142c0..140e5917 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -79,6 +79,7 @@ namespace Crow HorizontalAlignment _horizontalAlignment = HorizontalAlignment.Center; Size _maximumSize = "0;0"; Size _minimumSize = "0;0"; + bool isRegisteredForRepaint = false; #endregion #region public fields @@ -459,11 +460,16 @@ namespace Crow //test if this speed up a lot to cancel clipping for an uncached group Group p = Parent as Group; if (p != null) { - if (p.bmp == null) + if (p.bmp == null || !p.Caching) { + p.RegisterForRedraw (); return; + } } - if (HostContainer != null) - HostContainer.gobjsToRedraw.Add (this); + if (HostContainer == null || isRegisteredForRepaint) + return; + + HostContainer.gobjsToRedraw.Add (this); + isRegisteredForRepaint = true; } /// <summary> @@ -485,6 +491,7 @@ namespace Crow //this clipping should take only last painted slots in ancestor tree which //is not the case for now. HostContainer.redrawClip.AddRectangle (ScreenCoordinates(LastPaintedSlot)); + isRegisteredForRepaint = false; } /// <summary> return size of content + margins </summary> protected virtual Size measureRawSize () diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index 5107ccc5..a6dfd0c2 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -27,10 +27,14 @@ namespace Crow internal int maxChildrenHeight = 0; bool _multiSelect = false; + bool _caching = false; List<GraphicObject> children = new List<GraphicObject>(); public GraphicObject activeWidget; + + + public virtual List<GraphicObject> Children { get { return children; } set { children = value; } @@ -39,9 +43,23 @@ namespace Crow public bool MultiSelect { get { return _multiSelect; } - set { _multiSelect = value; } + set { + if (value == _multiSelect) + return; + _multiSelect = value; + NotifyValueChanged ("MultiSelect", _multiSelect); + } } - + [XmlAttributeAttribute()][DefaultValue(true)] + public bool Caching { + get { return _caching; } + set { + if (value == _caching) + return; + _caching = value; + NotifyValueChanged ("Caching", _multiSelect); + } + } public virtual T addChild<T>(T child) { |