From 575b9c56ca21fa1f9cd888c275d3d1f541af2b83 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Tue, 4 Dec 2018 14:09:07 +0100 Subject: [PATCH] docking save/restore; use image surfaces as cache for graphic object instead of backend similar which blink too much --- CrowIDE/src/CrowIDE.cs | 38 +++-- CrowIDE/src/DesignInterface.cs | 6 +- CrowIDE/src/Editors/Editor.cs | 2 +- CrowIDE/src/Editors/ImlVisualEditor.cs | 6 +- CrowIDE/src/Editors/SourceEditor.cs | 9 +- CrowIDE/src/GraphicObjectDesignContainer.cs | 4 +- CrowIDE/src/Project.cs | 20 ++- CrowIDE/src/ProjectTree/ProjectFile.cs | 6 +- CrowIDE/ui/MenuItem.template | 2 +- Default.style | 10 +- Templates/MenuItem.template | 9 +- Tests/BasicTests.cs | 146 ++++++++++++++++-- Tests/GraphicObjects/LaggingGraphicObject.cs | 59 +++++++ Tests/Interfaces/Container/0.crow | 10 +- Tests/Interfaces/Divers/0.crow | 2 +- Tests/Interfaces/Divers/testFocus.crow | 82 ++++++++++ Tests/Interfaces/Divers/testMenu.crow | 6 + .../Experimental/DockWindow.template | 5 + Tests/Interfaces/Experimental/testDock.crow | 4 +- Tests/Interfaces/colorItem2.crow | 10 ++ Tests/Tests.csproj | 15 ++ Tests/image/blank-file.svg | 6 + Tests/test.style | 3 + Tests/ui/MenuItem.template | 29 ++++ Tests/ui/dbgLog.crow | 64 ++++---- Tests/ui/dbgLogColors.crow | 60 +++++++ src/BmpPicture.cs | 13 +- src/Configuration.cs | 11 +- src/GraphicObjects/DockStack.cs | 96 ++++++++++++ src/GraphicObjects/DockWindow.cs | 11 +- src/GraphicObjects/GenericStack.cs | 6 + src/GraphicObjects/GraphicObject.cs | 36 ++++- src/GraphicObjects/Group.cs | 6 +- src/GraphicObjects/Image.cs | 2 +- src/GraphicObjects/Menu.cs | 11 +- src/GraphicObjects/MenuItem.cs | 12 +- src/GraphicObjects/TextBox.cs | 48 +++--- src/Interface.cs | 31 +++- src/Measure.cs | 4 +- src/Mono.Cairo/Surface.cs | 4 +- src/Mono.Cairo/XcbSurface.cs | 6 +- src/Picture.cs | 2 +- src/SvgPicture.cs | 17 +- src/debug/DbgEventTypeColors.cs | 77 +++++++++ src/debug/DbgLogViewer.cs | 113 +++++++------- src/debug/DebugLogger.cs | 8 +- 46 files changed, 902 insertions(+), 225 deletions(-) create mode 100644 Tests/GraphicObjects/LaggingGraphicObject.cs create mode 100755 Tests/Interfaces/Divers/testFocus.crow create mode 100755 Tests/Interfaces/Divers/testMenu.crow create mode 100755 Tests/Interfaces/colorItem2.crow create mode 100644 Tests/image/blank-file.svg create mode 100644 Tests/ui/MenuItem.template create mode 100755 Tests/ui/dbgLogColors.crow create mode 100644 src/debug/DbgEventTypeColors.cs diff --git a/CrowIDE/src/CrowIDE.cs b/CrowIDE/src/CrowIDE.cs index 235b077f..5db4af6d 100644 --- a/CrowIDE/src/CrowIDE.cs +++ b/CrowIDE/src/CrowIDE.cs @@ -36,6 +36,8 @@ namespace Crow.Coding { class CrowIDE : Interface { + static bool running = true; + public Command CMDNew, CMDOpen, CMDSave, CMDSaveAs, cmdCloseSolution, CMDQuit, CMDUndo, CMDRedo, CMDCut, CMDCopy, CMDPaste, CMDHelp, CMDAbout, CMDOptions, @@ -45,10 +47,10 @@ namespace Crow.Coding void initCommands () { CMDNew = new Command(new Action(() => newFile())) { Caption = "New", Icon = new SvgPicture("#Crow.Coding.ui.icons.blank-file.svg"), CanExecute = true}; - CMDOpen = new Command(new Action(() => openFileDialog())) { Caption = "Open...", Icon = new SvgPicture("#Crow.Coding.ui.icons.outbox.svg")}; - CMDSave = new Command(new Action(() => saveFileDialog())) { Caption = "Save", Icon = new SvgPicture("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false}; - CMDSaveAs = new Command(new Action(() => saveFileDialog())) { Caption = "Save As...", Icon = new SvgPicture("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false}; - //CMDQuit = new Command(new Action(() => Quit (null, null))) { Caption = "Quit", Icon = new SvgPicture("#Crow.Coding.ui.icons.sign-out.svg")}; + CMDOpen = new Command(new Action(() => openFileDialog())) { Caption = "Open...", Icon = new SvgPicture("#Crow.Coding.icons.open.svg")}; + CMDSave = new Command(new Action(() => saveFileDialog())) { Caption = "Save", Icon = new SvgPicture("#Crow.Coding.icons.save.svg"), CanExecute = false}; + CMDSaveAs = new Command(new Action(() => saveFileDialog())) { Caption = "Save As...", Icon = new SvgPicture("#Crow.Coding.icons.save.svg"), CanExecute = false}; + CMDQuit = new Command(new Action(() => running = false)) { Caption = "Quit", Icon = new SvgPicture("#Crow.Coding.ui.icons.sign-out.svg")}; CMDUndo = new Command(new Action(() => undo())) { Caption = "Undo", Icon = new SvgPicture("#Crow.Coding.icons.undo.svg"), CanExecute = false}; CMDRedo = new Command(new Action(() => redo())) { Caption = "Redo", Icon = new SvgPicture("#Crow.Coding.icons.redo.svg"), CanExecute = false}; //CMDCut = new Command(new Action(() => Quit (null, null))) { Caption = "Cut", Icon = new SvgPicture("#Crow.Coding.icons.scissors.svg"), CanExecute = false}; @@ -58,7 +60,7 @@ namespace Crow.Coding CMDOptions = new Command(new Action(() => loadWindow("#Crow.Coding.ui.Options.crow"))) { Caption = "Editor Options", Icon = new SvgPicture("#Crow.Coding.icons.tools.svg")}; cmdCloseSolution = new Command(new Action(() => closeSolution())) - { Caption = "Close Solution", Icon = new SvgPicture("#Crow.Coding.ui.icons.paste-on-document.svg"), CanExecute = false}; + { Caption = "Close Solution", Icon = new SvgPicture("#Crow.Coding.icons.paste-on-document.svg"), CanExecute = false}; CMDViewErrors = new Command(new Action(() => loadWindow ("#Crow.Coding.ui.DockWindows.winErrors.crow",this))) { Caption = "Errors pane"}; @@ -101,6 +103,16 @@ namespace Crow.Coding CurrentSolution = null; } + public void saveWinConfigs() { + Configuration.Global.Set ("WinConfigs", mainDock.ExportConfig ()); + } + public void reloadWinConfigs() { + string conf = Configuration.Global.Get("WinConfigs"); + if (string.IsNullOrEmpty (conf)) + return; + mainDock.ImportConfig (conf, this); + } + static CrowIDE app; [STAThread] static void Main () @@ -111,10 +123,15 @@ namespace Crow.Coding app.Keyboard.KeyDown += App_KeyboardKeyDown; app.initIde (); - while (true) { - - Thread.Sleep(10); + app.reloadWinConfigs (); + + while (running) { + app.ProcessEvents (); + //Thread.Sleep(1); } + + app.saveWinConfigs (); + Thread.Sleep (500); } } @@ -160,7 +177,7 @@ namespace Crow.Coding instFileDlg = Instantiator.CreateFromImlFragment (MainIFace, ""); - DockWindow dw = loadWindow ("#Crow.Coding.ui.DockWindows.winEditor.crow", this) as DockWindow; + /*DockWindow dw = loadWindow ("#Crow.Coding.ui.DockWindows.winEditor.crow", this) as DockWindow; dw.DockingPosition = Alignment.Center; dw.Dock (mainDock); dw = loadWindow ("#Crow.Coding.ui.DockWindows.winSolution.crow", this) as DockWindow; @@ -168,8 +185,9 @@ namespace Crow.Coding dw.Dock (mainDock); dw = loadWindow ("#Crow.Coding.ui.DockWindows.winToolbox.crow", this) as DockWindow; dw.DockingPosition = Alignment.Left; - dw.Dock (mainDock); + dw.Dock (mainDock);*/ + //Console.WriteLine (); } void loadProjProps () { diff --git a/CrowIDE/src/DesignInterface.cs b/CrowIDE/src/DesignInterface.cs index 5f979782..9d0bfe9c 100644 --- a/CrowIDE/src/DesignInterface.cs +++ b/CrowIDE/src/DesignInterface.cs @@ -30,6 +30,7 @@ using System.Threading; using System.Collections.Generic; using System.Diagnostics; using System.IO; +using Cairo; namespace Crow.Coding { @@ -62,15 +63,14 @@ namespace Crow.Coding protected override void InitBackend () { - surf = CrowIDE.MainIFace.surf.CreateSimilar (Cairo.Content.ColorAlpha, 100, 100); + surf = new ImageSurface(Format.Argb32, 100, 100); } public override void ProcessResize (Rectangle bounds) { lock (UpdateMutex) { clientRectangle = bounds; surf.Dispose (); - surf = CrowIDE.MainIFace.surf.CreateSimilar (Cairo.Content.ColorAlpha, clientRectangle.Width, clientRectangle.Height); - + surf = new ImageSurface(Format.Argb32, clientRectangle.Width, clientRectangle.Height); foreach (GraphicObject g in GraphicTree) g.RegisterForLayouting (LayoutingType.All); diff --git a/CrowIDE/src/Editors/Editor.cs b/CrowIDE/src/Editors/Editor.cs index 2cd34412..8ede10e3 100644 --- a/CrowIDE/src/Editors/Editor.cs +++ b/CrowIDE/src/Editors/Editor.cs @@ -94,7 +94,7 @@ namespace Crow.Coding } updateCheckPostProcess (); } - Thread.Sleep (10); + Thread.Sleep (100); } } } diff --git a/CrowIDE/src/Editors/ImlVisualEditor.cs b/CrowIDE/src/Editors/ImlVisualEditor.cs index 3cb4f866..e20ba131 100644 --- a/CrowIDE/src/Editors/ImlVisualEditor.cs +++ b/CrowIDE/src/Editors/ImlVisualEditor.cs @@ -72,8 +72,8 @@ namespace Crow.Coding } void initIcons () { - icoMove = new SvgPicture (); - icoMove.Load (IFace, "#Crow.Coding.icons.move-arrows.svg"); + icoMove = new SvgPicture ("#Crow.Coding.icons.move-arrows.svg"); + // icoStyle = new SvgPicture (); // icoStyle.Load (IFace, "#Crow.Coding.icons.palette.svg"); } @@ -355,7 +355,7 @@ namespace Crow.Coding if (oldHW == newHW) return; - RegisterForRedraw (); + //RegisterForRedraw (); } public override void onMouseEnter (object sender, MouseMoveEventArgs e) diff --git a/CrowIDE/src/Editors/SourceEditor.cs b/CrowIDE/src/Editors/SourceEditor.cs index 3cf422b9..1b3b07dd 100644 --- a/CrowIDE/src/Editors/SourceEditor.cs +++ b/CrowIDE/src/Editors/SourceEditor.cs @@ -900,9 +900,12 @@ namespace Crow.Coding } } void updateHoverLine () { - int hvl = (int)Math.Max (0, Math.Floor (mouseLocalPos.Y / (fe.Ascent+fe.Descent))); - hvl = Math.Min (PrintedLines.Count-1, hvl); - HoverLine = buffer.IndexOf (PrintedLines[hvl]); + if (PrintedLines.Count > 0) { + int hvl = (int)Math.Max (0, Math.Floor (mouseLocalPos.Y / (fe.Ascent + fe.Descent))); + hvl = Math.Min (PrintedLines.Count - 1, hvl); + HoverLine = buffer.IndexOf (PrintedLines [hvl]); + } else + HoverLine = 0; } void updateCurrentPosFromMouseLocalPos(){ PrintedCurrentLine = (int)Math.Max (0, Math.Floor (mouseLocalPos.Y / (fe.Ascent+fe.Descent))); diff --git a/CrowIDE/src/GraphicObjectDesignContainer.cs b/CrowIDE/src/GraphicObjectDesignContainer.cs index 4540898b..26e61c91 100644 --- a/CrowIDE/src/GraphicObjectDesignContainer.cs +++ b/CrowIDE/src/GraphicObjectDesignContainer.cs @@ -53,8 +53,8 @@ namespace Crow.Coding lock (go.IFace.UpdateMutex) { go.IFace.DragImageHeight = dragIconSize; go.IFace.DragImageWidth = dragIconSize; - SvgPicture pic = new SvgPicture (); - pic.Load (go.IFace, IconPath); + SvgPicture pic = new SvgPicture (IconPath); + //pic.Load (go.IFace, IconPath); ImageSurface img = new ImageSurface (Format.Argb32, dragIconSize, dragIconSize); using (Context ctx = new Context (img)) { Rectangle r = new Rectangle (0, 0, dragIconSize, dragIconSize); diff --git a/CrowIDE/src/Project.cs b/CrowIDE/src/Project.cs index 2c4eda59..693da868 100644 --- a/CrowIDE/src/Project.cs +++ b/CrowIDE/src/Project.cs @@ -464,12 +464,8 @@ namespace Crow.Coding solution.DefaultTemplates [clsName] = pi.Path; } - foreach (ProjectReference pr in flattenNodes.OfType()) { - Project p = solution.Projects.FirstOrDefault (pp => pp.ProjectGuid == pr.ProjectGUID); - if (p == null) - throw new Exception ("referenced project not found"); - p.GetDefaultTemplates (); - } + foreach (Project p in ReferencedProjects) + p.GetDefaultTemplates (); } // void searchTemplatesIn(Assembly assembly){ // if (assembly == null) @@ -484,6 +480,18 @@ namespace Crow.Coding // } // } + public List ReferencedProjects { + get { + List tmp = new List (); + foreach (ProjectReference pr in flattenNodes.OfType()) { + Project p = solution.Projects.FirstOrDefault (pp => pp.ProjectGuid == pr.ProjectGUID); + if (p != null) + tmp.Add (p); + } + return tmp; + } + } + public void GetStyling () { try { foreach (ProjectFile pi in flattenNodes.OfType ().Where (pp=>pp.Type == ItemType.EmbeddedResource && pp.Extension == ".style")) { diff --git a/CrowIDE/src/ProjectTree/ProjectFile.cs b/CrowIDE/src/ProjectTree/ProjectFile.cs index 2fac2f91..c26cb7cf 100644 --- a/CrowIDE/src/ProjectTree/ProjectFile.cs +++ b/CrowIDE/src/ProjectTree/ProjectFile.cs @@ -51,11 +51,11 @@ namespace Crow.Coding void initCommands (){ cmdSave = new Crow.Command (new Action (() => Save ())) - { Caption = "Save", Icon = new SvgPicture ("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false }; + { Caption = "Save", Icon = new SvgPicture ("#Crow.Coding.icons.save.svg"), CanExecute = false }; cmdSaveAs = new Crow.Command (new Action (() => SaveAs ())) - { Caption = "Save As ..", Icon = new SvgPicture ("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false }; + { Caption = "Save As ..", Icon = new SvgPicture ("#Crow.Coding.icons.save.svg"), CanExecute = false }; cmdOpen = new Crow.Command (new Action (() => Open ())) - { Caption = "Open", Icon = new SvgPicture ("#Crow.Coding.ui.icons.outbox.svg"), CanExecute = false }; + { Caption = "Open", Icon = new SvgPicture ("#Crow.Coding.icons.open.svg"), CanExecute = false }; cmdUndo = new Crow.Command (new Action (() => Undo (null))) { Caption = "Undo", Icon = new SvgPicture ("#Crow.Coding.icons.undo.svg"), CanExecute = false }; cmdRedo = new Crow.Command (new Action (() => Redo (null))) diff --git a/CrowIDE/ui/MenuItem.template b/CrowIDE/ui/MenuItem.template index 2fc29369..bf01f99d 100644 --- a/CrowIDE/ui/MenuItem.template +++ b/CrowIDE/ui/MenuItem.template @@ -14,7 +14,7 @@ Foreground="Transparent" Background="{./Background}"> - + - +