From: Jean-Philippe Bruyère Date: Tue, 4 Dec 2018 13:09:07 +0000 (+0100) Subject: docking save/restore; use image surfaces as cache for graphic object instead of backe... X-Git-Tag: v0.8.7~29^2~6 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=575b9c56ca21fa1f9cd888c275d3d1f541af2b83;p=jp%2Fcrow.git docking save/restore; use image surfaces as cache for graphic object instead of backend similar which blink too much --- 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}"> - + - +