aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-12-04 14:09:07 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-12-04 14:09:07 +0100
commit9d381671ec0b1266448eddbf4c4935cdc7d23a9f (patch)
tree34e9b4b0296eea8dba03024491934413bcd54083 /src
parenta64627699d4919d389522d92032ce4f05704d313 (diff)
docking save/restore; use image surfaces as cache for graphic object instead of backend similar which blink too much
Diffstat (limited to 'src')
-rw-r--r--src/BmpPicture.cs13
-rw-r--r--src/Configuration.cs11
-rw-r--r--src/GraphicObjects/DockStack.cs96
-rw-r--r--src/GraphicObjects/DockWindow.cs11
-rw-r--r--src/GraphicObjects/GenericStack.cs6
-rw-r--r--src/GraphicObjects/GraphicObject.cs36
-rw-r--r--src/GraphicObjects/Group.cs6
-rw-r--r--src/GraphicObjects/Image.cs2
-rw-r--r--src/GraphicObjects/Menu.cs11
-rw-r--r--src/GraphicObjects/MenuItem.cs12
-rw-r--r--src/GraphicObjects/TextBox.cs48
-rw-r--r--src/Interface.cs31
-rw-r--r--src/Measure.cs4
-rw-r--r--src/Mono.Cairo/Surface.cs4
-rw-r--r--src/Mono.Cairo/XcbSurface.cs6
-rw-r--r--src/Picture.cs2
-rw-r--r--src/SvgPicture.cs17
-rw-r--r--src/debug/DbgEventTypeColors.cs77
-rw-r--r--src/debug/DbgLogViewer.cs113
-rw-r--r--src/debug/DebugLogger.cs8
20 files changed, 382 insertions, 132 deletions
diff --git a/src/BmpPicture.cs b/src/BmpPicture.cs
index e3af9c79..1c7250b8 100644
--- a/src/BmpPicture.cs
+++ b/src/BmpPicture.cs
@@ -55,19 +55,18 @@ namespace Crow
/// load the image for rendering from the path given as argument
/// </summary>
/// <param name="path">image path, may be embedded</param>
- public override void Load (Interface iface, string path)
- {
- Path = path;
- if (sharedResources.ContainsKey (path)) {
- sharedPicture sp = sharedResources [path];
+ void Load ()
+ {
+ if (sharedResources.ContainsKey (Path)) {
+ sharedPicture sp = sharedResources [Path];
image = (byte[])sp.Data;
Dimensions = sp.Dims;
return;
}
- using (Stream stream = iface.GetStreamFromPath (path)) {
+ using (Stream stream = Interface.StaticGetStreamFromPath (Path)) {
loadBitmap (new System.Drawing.Bitmap (stream));
}
- sharedResources [path] = new sharedPicture (image, Dimensions);
+ sharedResources [Path] = new sharedPicture (image, Dimensions);
}
//load image via System.Drawing.Bitmap, cairo load png only
diff --git a/src/Configuration.cs b/src/Configuration.cs
index a6328c0a..4acba6af 100644
--- a/src/Configuration.cs
+++ b/src/Configuration.cs
@@ -29,6 +29,7 @@ using System.Reflection;
using System.IO;
using System.Collections.Generic;
using System.Threading;
+using System.Linq;
namespace Crow
{
@@ -102,6 +103,7 @@ namespace Crow
}
startSavingThread ();
}
+
static Configuration ()
{
string configRoot =
@@ -128,6 +130,13 @@ namespace Crow
}
globalConfig = new Configuration (globalConfigPath);
}
+
+ public string[] Names {
+ get {
+ return items.Keys.ToArray ();
+ }
+ }
+
void startSavingThread(){
Thread t = new Thread (savingThread);
t.IsBackground = true;
@@ -139,7 +148,7 @@ namespace Crow
save ();
isDirty = false;
}
- Thread.Sleep (1000);
+ Thread.Sleep (100);
}
}
/// <summary>
diff --git a/src/GraphicObjects/DockStack.cs b/src/GraphicObjects/DockStack.cs
index f2174024..aa7c33da 100644
--- a/src/GraphicObjects/DockStack.cs
+++ b/src/GraphicObjects/DockStack.cs
@@ -26,6 +26,8 @@
using System;
using Crow.IML;
using System.Linq;
+using System.Text;
+using System.IO;
namespace Crow
{
@@ -369,6 +371,100 @@ namespace Crow
if (dw != null)
dw.DockingPosition = (Orientation == Orientation.Horizontal ? Alignment.Right : Alignment.Bottom);
}
+
+ //read next value in config string until next ';'
+ string getConfAttrib (string conf, ref int i) {
+ int nextI = conf.Substring (i).IndexOf (';');
+ string tmp = conf.Substring (i, nextI);
+ i += nextI + 1;
+ return tmp;
+ }
+ /// <summary>
+ /// Imports the config.
+ /// </summary>
+ /// <param name="conf">Conf.</param>
+ /// <param name="dataSource">Data source for the docked windows</param>
+ public void ImportConfig (string conf, object dataSource = null) {
+ lock (IFace.UpdateMutex) {
+ ClearChildren ();
+ stretchedChild = null;
+ int i = 0;
+ Orientation = (Orientation)Enum.Parse (typeof(Orientation), getConfAttrib (conf, ref i));
+ importConfig (conf, ref i, dataSource);
+ }
+ }
+ public string ExportConfig () {
+ return Orientation.ToString() + ";" + exportConfig();
+ }
+ void importConfig (string conf, ref int i, object dataSource) {
+ if (conf [i++] != '(')
+ return;
+ while (i < conf.Length - 4) {
+ string sc = conf.Substring (i, 4);
+ i += 4;
+ switch (sc) {
+ case "WIN;":
+ DockWindow dw = null;
+ string wName = getConfAttrib (conf, ref i);
+ try {
+ dw = IFace.Load (wName) as DockWindow;
+ } catch {
+ dw = new DockWindow (IFace);
+ }
+
+ dw.Name = wName;
+ dw.Width = Measure.Parse (getConfAttrib (conf, ref i));
+ dw.Height = Measure.Parse (getConfAttrib (conf, ref i));
+ dw.DockingPosition = (Alignment)Enum.Parse (typeof(Alignment), getConfAttrib (conf, ref i));
+ dw.IsDocked = true;
+ dw.DataSource = dataSource;
+ this.AddChild (dw);
+
+ break;
+ case "STK;":
+ DockStack ds = new DockStack (IFace);
+ ds.Width = Measure.Parse (getConfAttrib (conf, ref i));
+ ds.Height = Measure.Parse (getConfAttrib (conf, ref i));
+ ds.Orientation = (Orientation)Enum.Parse (typeof(Orientation), getConfAttrib (conf, ref i));
+
+ this.AddChild (ds);
+
+ ds.importConfig (conf, ref i, dataSource);
+ break;
+ case "SPL;":
+ Splitter sp = new Splitter (IFace);
+ sp.Width = Measure.Parse (getConfAttrib (conf, ref i));
+ sp.Height = Measure.Parse (getConfAttrib (conf, ref i));
+ sp.Thickness = int.Parse (getConfAttrib (conf, ref i));
+ this.AddChild (sp);
+ break;
+ }
+ char nextC = conf [i++];
+ if (nextC == ')')
+ break;
+ }
+ }
+ string exportConfig () {
+ StringBuilder tmp = new StringBuilder("(");
+
+ for (int i = 0; i < Children.Count; i++) {
+ if (Children [i] is DockWindow) {
+ DockWindow dw = Children [i] as DockWindow;
+ tmp.Append (string.Format("WIN;{0};{1};{2};{3};",dw.Name, dw.Width, dw.Height, dw.DockingPosition));
+ } else if (Children [i] is DockStack) {
+ DockStack ds = Children [i] as DockStack;
+ tmp.Append (string.Format("STK;{0};{1};{2};{3}", ds.Width, ds.Height, ds.Orientation, ds.exportConfig()));
+ } else if (Children [i] is Splitter) {
+ Splitter sp = Children [i] as Splitter;
+ tmp.Append (string.Format("SPL;{0};{1};{2};", sp.Width, sp.Height, sp.Thickness));
+ }
+ if (i < Children.Count - 1)
+ tmp.Append ("|");
+ }
+
+ tmp.Append (")");
+ return tmp.ToString ();
+ }
}
}
diff --git a/src/GraphicObjects/DockWindow.cs b/src/GraphicObjects/DockWindow.cs
index 1ae3b0b4..d6385057 100644
--- a/src/GraphicObjects/DockWindow.cs
+++ b/src/GraphicObjects/DockWindow.cs
@@ -31,12 +31,11 @@ namespace Crow
public class DockWindow : Window
{
#region CTOR
- public DockWindow () : base ()
- {
- }
+ public DockWindow () {}
+ public DockWindow (Interface iface) : base (iface) {}
#endregion
- int undockThreshold = 4;
+ int undockThreshold = 10;
bool isDocked = false;
Alignment docking = Alignment.Undefined;
@@ -170,10 +169,6 @@ namespace Crow
Undock ();
base.close ();
}
-
- public string ExportWinConfigs () {
- return string.Format ("{0};{1};{2}", this.Name, DockingPosition, savedSlot);
- }
}
}
diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs
index 64841d4b..f281311c 100644
--- a/src/GraphicObjects/GenericStack.cs
+++ b/src/GraphicObjects/GenericStack.cs
@@ -242,5 +242,11 @@ namespace Crow
else
adjustStretchedGo (LayoutingType.Height);
}
+
+ public override void ClearChildren ()
+ {
+ base.ClearChildren ();
+ stretchedGO = null;
+ }
}
}
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 2bf20f27..747609b0 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -945,11 +945,17 @@ namespace Crow
if (value != null)
rootDataLevel = true;
-
+
+ #if DEBUG_LOG
+ DbgEvent dbgEvt = DebugLog.AddEvent(DbgEvtType.GOLockLayouting, this);
+ #endif
lock (IFace.LayoutMutex) {
OnDataSourceChanged (this, dse);
NotifyValueChanged ("DataSource", DataSource);
}
+ #if DEBUG_LOG
+ dbgEvt.end = DebugLog.chrono.ElapsedTicks;
+ #endif
}
get {
return rootDataLevel ? dataSource : dataSource == null ?
@@ -1358,8 +1364,13 @@ namespace Crow
public virtual void RegisterClip(Rectangle clip){
#if DEBUG_LOG
DbgEvent dbgEvt = DebugLog.AddEvent(DbgEvtType.GORegisterClip, this);
- #endif
- Rectangle r = clip + ClientRectangle.Position;
+ #endif
+ Rectangle cb = ClientRectangle;
+ Rectangle r = clip + cb.Position;
+ if (r.Right > cb.Right)
+ r.Width -= r.Right - cb.Right;
+ if (r.Bottom > cb.Bottom)
+ r.Height -= r.Bottom - cb.Bottom;
if (CacheEnabled && !IsDirty)
Clipping.UnionRectangle (r);
if (Parent == null)
@@ -1372,7 +1383,7 @@ namespace Crow
dbgEvt.end = DebugLog.chrono.ElapsedTicks;
#endif
}
- /// <summary> Full update, taking care of sizing policy </summary>
+ /// <summary> Full update, content and layouting, taking care of sizing policy </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void RegisterForGraphicUpdate ()
{
@@ -1382,7 +1393,7 @@ namespace Crow
else if (RegisteredLayoutings == LayoutingType.None)
IFace.EnqueueForRepaint (this);
}
- /// <summary> query an update of the content, a redraw </summary>
+ /// <summary> query an update of the content without layouting changes</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void RegisterForRedraw ()
{
@@ -1641,14 +1652,21 @@ namespace Crow
#if DEBUG_LOG
DbgEvent dbgEvt = DebugLog.AddEvent(DbgEvtType.GORecreateCache, this);
#endif
- IsDirty = false;
+
+ /*if (bmp == null)
+ bmp = IFace.surf.CreateSimilar (Content.ColorAlpha, Slot.Width, Slot.Height);
+ else if (LastPaintedSlot.Width != Slot.Width || LastPaintedSlot.Height != Slot.Height)
+ bmp.SetSize (Slot.Width, Slot.Height);*/
bmp?.Dispose ();
- bmp = IFace.surf.CreateSimilar(Content.ColorAlpha, Slot.Width, Slot.Height);
+ bmp = new ImageSurface(Format.Argb32, Slot.Width, Slot.Height);
+
using (Context gr = new Context (bmp)) {
gr.Antialias = Interface.Antialias;
onDraw (gr);
}
- bmp.Flush ();
+
+ IsDirty = false;
+
#if DEBUG_LOG
dbgEvt.end = DebugLog.chrono.ElapsedTicks;
#endif
@@ -1657,6 +1675,7 @@ namespace Crow
#if DEBUG_LOG
DbgEvent dbgEvt = DebugLog.AddEvent(DbgEvtType.GOUpdateCacheAndPaintOnCTX, this);
#endif
+
Rectangle rb = Slot + Parent.ClientRectangle.Position;
if (clearBackground) {
ctx.Save ();
@@ -1665,6 +1684,7 @@ namespace Crow
ctx.Fill ();
ctx.Restore ();
}
+
ctx.SetSourceSurface (bmp, rb.X, rb.Y);
ctx.Paint ();
Clipping.Dispose ();
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs
index a90947a5..ece1f090 100644
--- a/src/GraphicObjects/Group.cs
+++ b/src/GraphicObjects/Group.cs
@@ -340,7 +340,11 @@ namespace Crow
childrenRWLock.ExitReadLock ();
#if DEBUG_CLIP_RECTANGLE
- Clipping.stroke (gr, Color.Amaranth.AdjustAlpha (0.8));
+ /*gr.LineWidth = 1;
+ gr.SetSourceColor(Color.DarkMagenta.AdjustAlpha (0.8));
+ for (int i = 0; i < Clipping.NumRectangles; i++)
+ gr.Rectangle(Clipping.GetRectangle(i));
+ gr.Stroke ();*/
#endif
}
gr.Dispose ();
diff --git a/src/GraphicObjects/Image.cs b/src/GraphicObjects/Image.cs
index e83183c0..5960101a 100644
--- a/src/GraphicObjects/Image.cs
+++ b/src/GraphicObjects/Image.cs
@@ -173,7 +173,7 @@ namespace Crow
else
pic = new BmpPicture (path);
- pic.Load (IFace, path);
+
pic.Scaled = scaled;
pic.KeepProportions = keepProps;
diff --git a/src/GraphicObjects/Menu.cs b/src/GraphicObjects/Menu.cs
index dbc1d636..0ddb8eae 100644
--- a/src/GraphicObjects/Menu.cs
+++ b/src/GraphicObjects/Menu.cs
@@ -51,10 +51,15 @@ namespace Crow
NotifyValueChanged ("Orientation", orientation);
}
}
- [XmlIgnore]public bool AutomaticOpenning
+ [XmlIgnore]public bool AutomaticOpening
{
get { return autoOpen; }
- set { autoOpen = value; }
+ set {
+ if (autoOpen == value)
+ return;
+ autoOpen = value;
+ NotifyValueChanged ("AutomaticOpening", autoOpen);
+ }
}
#endregion
@@ -70,7 +75,7 @@ namespace Crow
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
{
base.onMouseLeave (sender, e);
- AutomaticOpenning = false;
+ AutomaticOpening = false;
}
}
}
diff --git a/src/GraphicObjects/MenuItem.cs b/src/GraphicObjects/MenuItem.cs
index 47bd978f..3b25a9fe 100644
--- a/src/GraphicObjects/MenuItem.cs
+++ b/src/GraphicObjects/MenuItem.cs
@@ -46,7 +46,7 @@ namespace Crow
Measure popWidth, popHeight;
#region Public properties
- [XmlAttributeAttribute][DefaultValue(false)]
+ [DefaultValue(false)]
public bool IsOpened {
get { return isOpened; }
set {
@@ -58,12 +58,12 @@ namespace Crow
if (isOpened) {
onOpen (this, null);
if (LogicalParent is Menu)
- (LogicalParent as Menu).AutomaticOpenning = true;
+ (LogicalParent as Menu).AutomaticOpening = true;
}else
onClose (this, null);
}
}
- [XmlAttributeAttribute][DefaultValue(null)]
+ [DefaultValue(null)]
public virtual Command Command {
get { return command; }
set {
@@ -148,7 +148,7 @@ namespace Crow
closeMenu ();
}
if(!IsOpened)
- (LogicalParent as Menu).AutomaticOpenning = false;
+ (LogicalParent as Menu).AutomaticOpening = false;
}
protected virtual void onOpen (object sender, EventArgs e){
Open.Raise (this, null);
@@ -167,7 +167,7 @@ namespace Crow
Menu menu = LogicalParent as Menu;
if (menu == null)
return;
- if (menu.AutomaticOpenning && items.Children.Count>0)
+ if (menu.AutomaticOpening && items.Children.Count>0)
IsOpened = true;
}
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
@@ -181,6 +181,8 @@ namespace Crow
MenuItem tmp = LogicalParent as MenuItem;
while (tmp != null) {
tmp.IsOpened = false;
+ tmp.Background = Color.Transparent;
+ tmp.AutomaticOpening = false;
tmp = tmp.LogicalParent as MenuItem;
}
}
diff --git a/src/GraphicObjects/TextBox.cs b/src/GraphicObjects/TextBox.cs
index 7d14f800..5da67e31 100644
--- a/src/GraphicObjects/TextBox.cs
+++ b/src/GraphicObjects/TextBox.cs
@@ -69,7 +69,7 @@ namespace Crow
public override void onKeyDown (object sender, KeyEventArgs e)
{
base.onKeyDown (sender, e);
- /*
+
Key key = e.Key;
switch (key)
@@ -85,12 +85,12 @@ namespace Crow
if (selectionIsEmpty) {
if (!MoveRight ())
return;
- }else if (e.Shift)
+ }else if (IFace.Keyboard.Shift)
IFace.Clipboard = this.SelectedText;
this.DeleteChar ();
break;
- case Key.ISO_Enter:
case Key.KP_Enter:
+ case Key.Return:
if (!selectionIsEmpty)
this.DeleteChar ();
if (Multiline)
@@ -104,46 +104,46 @@ namespace Crow
SelRelease = -1;
break;
case Key.Home:
- if (e.Shift) {
+ if (IFace.Keyboard.Shift) {
if (selectionIsEmpty)
SelBegin = new Point (CurrentColumn, CurrentLine);
- if (e.Control)
+ if (IFace.Keyboard.Ctrl)
CurrentLine = 0;
CurrentColumn = 0;
SelRelease = new Point (CurrentColumn, CurrentLine);
break;
}
SelRelease = -1;
- if (e.Control)
+ if (IFace.Keyboard.Ctrl)
CurrentLine = 0;
CurrentColumn = 0;
break;
case Key.End:
- if (e.Shift) {
+ if (IFace.Keyboard.Shift) {
if (selectionIsEmpty)
SelBegin = CurrentPosition;
- if (e.Control)
+ if (IFace.Keyboard.Ctrl)
CurrentLine = int.MaxValue;
CurrentColumn = int.MaxValue;
SelRelease = CurrentPosition;
break;
}
SelRelease = -1;
- if (e.Control)
+ if (IFace.Keyboard.Ctrl)
CurrentLine = int.MaxValue;
CurrentColumn = int.MaxValue;
break;
case Key.Insert:
- if (e.Shift)
+ if (IFace.Keyboard.Shift)
this.Insert (IFace.Clipboard);
- else if (e.Control && !selectionIsEmpty)
+ else if (IFace.Keyboard.Ctrl && !selectionIsEmpty)
IFace.Clipboard = this.SelectedText;
break;
case Key.Left:
- if (e.Shift) {
+ if (IFace.Keyboard.Shift) {
if (selectionIsEmpty)
SelBegin = new Point(CurrentColumn, CurrentLine);
- if (e.Control)
+ if (IFace.Keyboard.Ctrl)
GotoWordStart ();
else if (!MoveLeft ())
return;
@@ -151,16 +151,16 @@ namespace Crow
break;
}
SelRelease = -1;
- if (e.Control)
+ if (IFace.Keyboard.Ctrl)
GotoWordStart ();
else
MoveLeft();
break;
case Key.Right:
- if (e.Shift) {
+ if (IFace.Keyboard.Shift) {
if (selectionIsEmpty)
SelBegin = CurrentPosition;
- if (e.Control)
+ if (IFace.Keyboard.Ctrl)
GotoWordEnd ();
else if (!MoveRight ())
return;
@@ -168,13 +168,13 @@ namespace Crow
break;
}
SelRelease = -1;
- if (e.Control)
+ if (IFace.Keyboard.Ctrl)
GotoWordEnd ();
else
MoveRight ();
break;
case Key.Up:
- if (e.Shift) {
+ if (IFace.Keyboard.Shift) {
if (selectionIsEmpty)
SelBegin = CurrentPosition;
CurrentLine--;
@@ -185,7 +185,7 @@ namespace Crow
CurrentLine--;
break;
case Key.Down:
- if (e.Shift) {
+ if (IFace.Keyboard.Shift) {
if (selectionIsEmpty)
SelBegin = CurrentPosition;
CurrentLine++;
@@ -197,13 +197,11 @@ namespace Crow
break;
case Key.Menu:
break;
- case Key.NumLock:
- break;
- case Key.PageDown:
+ case Key.Num_Lock:
break;
- case Key.PageUp:
+ case Key.Page_Down:
break;
- case Key.RWin:
+ case Key.Page_Up:
break;
case Key.Tab:
this.Insert ("\t");
@@ -211,7 +209,7 @@ namespace Crow
default:
break;
}
- */
+
RegisterForGraphicUpdate();
}
public override void onKeyPress (object sender, KeyPressEventArgs e)
diff --git a/src/Interface.cs b/src/Interface.cs
index 77137761..3c586685 100644
--- a/src/Interface.cs
+++ b/src/Interface.cs
@@ -119,6 +119,7 @@ namespace Crow
}
#endregion
+ protected bool running;
protected virtual void InitBackend () {
backend = new Crow.XCB.XCBBackend ();
//backend = new Crow.XLib.XLibBackend ();
@@ -128,8 +129,10 @@ namespace Crow
Keyboard.KeyUp += Keyboard_KeyUp;
Keyboard.KeyPress += Keyboard_KeyPress;
- initTooltip ();
- initContextMenus ();
+ //initTooltip ();
+ //initContextMenus ();
+
+ running = true;
Thread t = new Thread (interfaceThread);
t.IsBackground = true;
@@ -168,10 +171,10 @@ namespace Crow
void interfaceThread()
{
- while (true) {
+ while (running) {
Update ();
- backend.ProcessEvents ();
+ Thread.Sleep (1);
}
}
@@ -208,6 +211,9 @@ namespace Crow
}
#endregion
+ public void ProcessEvents() {
+ backend.ProcessEvents ();
+ }
public void Init () {
CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
@@ -575,10 +581,15 @@ namespace Crow
_activeWidget = value;
+ #if DEBUG_FOCUS
+ NotifyValueChanged("ActiveWidget", _activeWidget);
+ #endif
+
if (_activeWidget != null)
{
_activeWidget.IsActive = true;
#if DEBUG_FOCUS
+ NotifyValueChanged("ActiveWidget", _activeWidget);
Debug.WriteLine("Active => " + _activeWidget.ToString());
}else
Debug.WriteLine("Active => null");
@@ -599,6 +610,9 @@ namespace Crow
_hoverWidget.IsHover = false;
_hoverWidget = value;
+ #if DEBUG_FOCUS
+ NotifyValueChanged("HoverWidget", _hoverWidget);
+ #endif
if (_hoverWidget != null)
{
@@ -621,6 +635,9 @@ namespace Crow
if (_focusedWidget != null)
_focusedWidget.HasFocus = false;
_focusedWidget = value;
+ #if DEBUG_FOCUS
+ NotifyValueChanged("FocusedWidget", _focusedWidget);
+ #endif
if (_focusedWidget != null)
_focusedWidget.HasFocus = true;
}
@@ -810,7 +827,11 @@ namespace Crow
}
#if DEBUG_CLIP_RECTANGLE
- clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5));
+ ctx.LineWidth = 1;
+ ctx.SetSourceColor(Color.Magenta.AdjustAlpha (0.5));
+ for (int i = 0; i < clipping.NumRectangles; i++)
+ ctx.Rectangle(clipping.GetRectangle(i));
+ ctx.Stroke ();
#endif
clipping.Dispose ();
diff --git a/src/Measure.cs b/src/Measure.cs
index 0374f5d9..c40c6703 100644
--- a/src/Measure.cs
+++ b/src/Measure.cs
@@ -31,7 +31,7 @@ namespace Crow
/// <summary>
/// Measurement unit
/// </summary>
- public enum Unit { Pixel, Percent, Inherit }
+ public enum Unit {Undefined, Pixel, Percent, Inherit }
/// <summary>
/// Measure class allow proportional sizes as well as stretched and fit on content.
/// </summary>
@@ -114,7 +114,7 @@ namespace Crow
public static Measure Parse(string s){
if (string.IsNullOrEmpty (s))
- return Measure.Stretched;
+ return default(Measure);
string st = s.Trim ();
int tmp = 0;
diff --git a/src/Mono.Cairo/Surface.cs b/src/Mono.Cairo/Surface.cs
index 6a55496a..e7a2a5e4 100644
--- a/src/Mono.Cairo/Surface.cs
+++ b/src/Mono.Cairo/Surface.cs
@@ -120,7 +120,7 @@ namespace Cairo {
IntPtr p = NativeMethods.cairo_surface_create_similar (
this.Handle, content, width, height);
- return new Cairo.Surface (p, true);
+ return Surface.Lookup(p, true);
}
~Surface ()
@@ -152,6 +152,8 @@ namespace Cairo {
NativeMethods.cairo_surface_destroy (handle);
handle = IntPtr.Zero;
}
+ public virtual void SetSize (int width, int height) {
+ }
public Status Finish ()
{
diff --git a/src/Mono.Cairo/XcbSurface.cs b/src/Mono.Cairo/XcbSurface.cs
index 142ebf9e..b9995ee6 100644
--- a/src/Mono.Cairo/XcbSurface.cs
+++ b/src/Mono.Cairo/XcbSurface.cs
@@ -45,10 +45,10 @@ namespace Cairo {
IntPtr ptr = NativeMethods.cairo_xcb_surface_create_for_bitmap (connection, bitmap, screen, width, height);
return new XcbSurface (ptr, true);
}
-
- public void SetSize (int width, int height)
- {
+ public override void SetSize (int width, int height)
+ {
NativeMethods.cairo_xcb_surface_set_size (Handle, width, height);
+ Console.WriteLine ("new size ({0},{1})", width, height);
}
}
}
diff --git a/src/Picture.cs b/src/Picture.cs
index 3784780b..f2f45261 100644
--- a/src/Picture.cs
+++ b/src/Picture.cs
@@ -96,7 +96,7 @@ namespace Crow
/// load the image for rendering from the stream given as argument
/// </summary>
/// <param name="stream">picture stream</param>
- public abstract void Load(Interface iface, string path);
+ //public abstract void Load(Interface iface, string path);
#endregion
/// <summary>
diff --git a/src/SvgPicture.cs b/src/SvgPicture.cs
index f676a497..dee6c8e0 100644
--- a/src/SvgPicture.cs
+++ b/src/SvgPicture.cs
@@ -48,19 +48,20 @@ namespace Crow
/// </summary>
/// <param name="path">image path, may be embedded</param>
public SvgPicture (string path) : base(path)
- {}
+ {
+ Load ();
+ }
#endregion
- public override void Load (Interface iface, string path)
- {
- Path = path;
- if (sharedResources.ContainsKey (path)) {
- sharedPicture sp = sharedResources [path];
+ void Load ()
+ {
+ if (sharedResources.ContainsKey (Path)) {
+ sharedPicture sp = sharedResources [Path];
hSVG = (Rsvg.Handle)sp.Data;
Dimensions = sp.Dims;
return;
}
- using (Stream stream = iface.GetStreamFromPath (path)) {
+ using (Stream stream = Interface.StaticGetStreamFromPath (Path)) {
using (MemoryStream ms = new MemoryStream ()) {
stream.CopyTo (ms);
@@ -68,7 +69,7 @@ namespace Crow
Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height);
}
}
- sharedResources [path] = new sharedPicture (hSVG, Dimensions);
+ sharedResources [Path] = new sharedPicture (hSVG, Dimensions);
}
public void LoadSvgFragment (string fragment) {
diff --git a/src/debug/DbgEventTypeColors.cs b/src/debug/DbgEventTypeColors.cs
new file mode 100644
index 00000000..e0881182
--- /dev/null
+++ b/src/debug/DbgEventTypeColors.cs
@@ -0,0 +1,77 @@
+//
+// DbgEventTypeColors.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 Cairo;
+using System.Linq;
+
+namespace Crow
+{
+ #if DEBUG_LOG
+ public class DbgEventTypeColors : GraphicObject
+ {
+ protected override void onDraw (Context gr)
+ {
+ base.onDraw (gr);
+
+ gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+ gr.SetFontSize (Font.Size);
+ gr.FontOptions = Interface.FontRenderingOptions;
+ gr.Antialias = Interface.Antialias;
+
+ DbgEvtType[] types = DbgLogViewer.colors.Keys.ToArray ();
+ Color[] colors = DbgLogViewer.colors.Values.ToArray ();
+
+ Rectangle r = ClientRectangle;
+ FontExtents fe = gr.FontExtents;
+
+ double penY = fe.Height + r.Top;
+ double penX = (double)r.Left;
+
+
+ for (int i = 0; i < types.Length; i++) {
+ string n = types [i].ToString();
+ Color c = colors[i];
+ Foreground.SetAsSource (gr);
+
+ gr.MoveTo (penX + 25.0, penY - fe.Descent);
+ gr.ShowText (n);
+
+ Rectangle rc = new Rectangle((int)penX, (int)(penY - fe.Height), 20, (int)fe.Height);
+ rc.Inflate (-2);
+ gr.Rectangle (rc);
+ gr.StrokePreserve ();
+
+ gr.SetSourceColor (c);
+ gr.Fill ();
+
+ penY += fe.Height;
+
+ }
+ }
+ }
+ #endif
+}
+
diff --git a/src/debug/DbgLogViewer.cs b/src/debug/DbgLogViewer.cs
index 7c8a1bdf..6124d6f9 100644
--- a/src/debug/DbgLogViewer.cs
+++ b/src/debug/DbgLogViewer.cs
@@ -34,8 +34,12 @@ namespace Crow
{
public class DbgLogViewer : ScrollingObject
{
+ public static Dictionary<DbgEvtType,Color> colors;
+
+ public static Configuration colorsConf = new Configuration("dbgcolor.conf");
+
#region debug viewer private classes
- class DbgData {
+ public class DbgData {
public int objInstanceNum;
public LayoutingType layout;
public LayoutingQueueItem.Result result;
@@ -44,7 +48,7 @@ namespace Crow
objInstanceNum = _obj;
}
}
- class DbgEvent {
+ public class DbgEvent {
public long begin, end;
public DbgEvtType type;
public DbgData data = null;
@@ -99,7 +103,19 @@ namespace Crow
}
#endregion
+ public static void reloadColors () {
+ colors = new Dictionary<DbgEvtType, Color>();
+ foreach (string n in colorsConf.Names) {
+ DbgEvtType t = (DbgEvtType)Enum.Parse (typeof(DbgEvtType), n);
+ Color c = colorsConf.Get<Color> (n);
+ colors.Add (t, c);
+ }
+
+ }
#region CTOR
+ static DbgLogViewer() {
+ reloadColors ();
+ }
protected DbgLogViewer () : base(){}
public DbgLogViewer (Interface iface) : base(iface){}
#endregion
@@ -156,8 +172,13 @@ namespace Crow
void storeEvent (DbgEvent evt) {
if (evt.data == null)//global events
events.Add (evt);
- else
- objs.Where (o => o.instanceNum == evt.data.objInstanceNum).FirstOrDefault ().events.Add (evt);
+ else {
+ DbgGo go = objs.Where (o => o.instanceNum == evt.data.objInstanceNum).FirstOrDefault ();
+ if (go == null)
+ Console.WriteLine ("Unknown instance: " + evt.data.objInstanceNum);
+ else
+ go.events.Add (evt);
+ }
}
void loadDebugFile() {
@@ -289,50 +310,7 @@ namespace Crow
}
}
- Crow.Color getObjEventColor (DbgEvent evt) {
- if (evt.type.HasFlag (DbgEvtType.GOLayouting)) {
- if (evt.type == DbgEvtType.GOProcessLayouting) {
- switch (evt.data.result) {
- case LayoutingQueueItem.Result.Success:
- return Crow.Color.Green;
- case LayoutingQueueItem.Result.Deleted:
- return Crow.Color.Red;
- case LayoutingQueueItem.Result.Discarded:
- return Crow.Color.DarkRed;
- case LayoutingQueueItem.Result.Requeued:
- return Crow.Color.Orange;
- }
- } else if (evt.type == DbgEvtType.GOProcessLayoutingWithNoParent)
- return Color.IndianRed;
- else
- return Crow.Color.Blue;
- }
- switch (evt.type) {
- case DbgEvtType.GOClassCreation:
- return Color.GhostWhite;
- case DbgEvtType.GOInitialization:
- return Color.Cyan;
- case DbgEvtType.GOClippingRegistration:
- return Color.Cyan;
- case DbgEvtType.GORegisterClip:
- return Color.Cyan;
- case DbgEvtType.GORegisterForGraphicUpdate:
- return Color.Cyan;
- case DbgEvtType.GOEnqueueForRepaint:
- return Color.Cyan;
- case DbgEvtType.GODraw:
- return Color.Cyan;
- case DbgEvtType.GORecreateCache:
- return Color.Cyan;
- case DbgEvtType.GOUpdateCacheAndPaintOnCTX:
- return Color.Cyan;
- case DbgEvtType.GOPaint:
- return Color.Cyan;
- case DbgEvtType.GONewDataSource:
- return Color.Cyan;
- }
- return Crow.Color.RebeccaPurple;
- }
+
protected override void onDraw (Cairo.Context gr)
{
@@ -341,7 +319,7 @@ namespace Crow
gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
gr.SetFontSize (Font.Size);
gr.FontOptions = Interface.FontRenderingOptions;
- gr.Antialias = Interface.Antialias;
+ gr.Antialias = Cairo.Antialias.None;
if (objs == null)
return;
@@ -353,13 +331,19 @@ namespace Crow
double penY = topMargin + ClientRectangle.Top;
for (int i = 0; i < visibleLines; i++) {
+ if (i + ScrollY >= objs.Count)
+ break;
DbgGo g = objs [i + ScrollY];
+
foreach (DbgEvent evt in g.events) {
+
+
if (evt.end - minTicks <= ScrollX)
continue;
if (evt.begin - minTicks > ScrollX + visibleTicks)
break;
+
double x = xScale * (evt.begin - minTicks - ScrollX) ;
double w = Math.Max (Math.Max(2.0, 2.0 * xScale), (double)(evt.end - evt.begin) * xScale);
if (x < 0.0) {
@@ -373,11 +357,32 @@ namespace Crow
//if (x + w > cb.Right)
// continue;
- gr.SetSourceColor (getObjEventColor (evt));
+ Color c = Color.Black;
+
+ if (evt.type == DbgEvtType.GOProcessLayouting) {
+ switch (evt.data.result) {
+ case LayoutingQueueItem.Result.Success:
+ c = Crow.Color.Green;
+ break;
+ case LayoutingQueueItem.Result.Deleted:
+ c = Crow.Color.Red;
+ break;
+ case LayoutingQueueItem.Result.Discarded:
+ c = Crow.Color.OrangeRed;
+ break;
+ case LayoutingQueueItem.Result.Requeued:
+ c = Crow.Color.Orange;
+ break;
+ }
+ } else if (colors.ContainsKey (evt.type))
+ c = colors [evt.type];
+ else
+ System.Diagnostics.Debugger.Break ();
+
+ gr.SetSourceColor (c);
gr.Rectangle (x, penY, w, fe.Height);
gr.Fill ();
-
}
penY += fe.Height;
@@ -458,7 +463,9 @@ namespace Crow
gr.MoveTo (x- 0.5 * te.Width, penY - gr.FontExtents.Descent);
gr.SetSourceColor (Crow.Color.Jet);
gr.ShowText (s);
+
}
+
}
public override void Paint (ref Cairo.Context ctx)
{
@@ -569,7 +576,9 @@ namespace Crow
if (selStart >= 0 && IFace.Mouse.IsButtonDown(MouseButton.Left))
selEnd = currentTick;
- RegisterForRedraw ();
+ if (RegisteredLayoutings == LayoutingType.None && !IsDirty)
+ IFace.EnqueueForRepaint (this);
+
}
public override void onMouseDown (object sender, MouseButtonEventArgs e)
{
diff --git a/src/debug/DebugLogger.cs b/src/debug/DebugLogger.cs
index 18e4ae19..38cbc2af 100644
--- a/src/debug/DebugLogger.cs
+++ b/src/debug/DebugLogger.cs
@@ -65,6 +65,11 @@ namespace Crow
GOUpdateCacheAndPaintOnCTX = 0x020c,
GOPaint = 0x020d,
GONewDataSource = 0x020e,
+ GOLock = 0x0800,
+ GOLockUpdate = 0x0a01,
+ GOLockClipping = 0x0a02,
+ GOLockRender = 0x0a03,
+ GOLockLayouting = 0x0a04,
}
/// <summary>
@@ -162,7 +167,8 @@ namespace Crow
s.WriteLine ("[Events]");
foreach (DbgEvent e in events)
- s.WriteLine (e.ToString ());
+ if (e != null)
+ s.WriteLine (e.ToString ());
}
}
}