]> O.S.I.I.S - jp/crow.git/commitdiff
docking save/restore; use image surfaces as cache for graphic object instead of backe...
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 4 Dec 2018 13:09:07 +0000 (14:09 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 4 Dec 2018 13:09:07 +0000 (14:09 +0100)
46 files changed:
CrowIDE/src/CrowIDE.cs
CrowIDE/src/DesignInterface.cs
CrowIDE/src/Editors/Editor.cs
CrowIDE/src/Editors/ImlVisualEditor.cs
CrowIDE/src/Editors/SourceEditor.cs
CrowIDE/src/GraphicObjectDesignContainer.cs
CrowIDE/src/Project.cs
CrowIDE/src/ProjectTree/ProjectFile.cs
CrowIDE/ui/MenuItem.template
Default.style
Templates/MenuItem.template
Tests/BasicTests.cs
Tests/GraphicObjects/LaggingGraphicObject.cs [new file with mode: 0644]
Tests/Interfaces/Container/0.crow
Tests/Interfaces/Divers/0.crow
Tests/Interfaces/Divers/testFocus.crow [new file with mode: 0755]
Tests/Interfaces/Divers/testMenu.crow [new file with mode: 0755]
Tests/Interfaces/Experimental/DockWindow.template
Tests/Interfaces/Experimental/testDock.crow
Tests/Interfaces/colorItem2.crow [new file with mode: 0755]
Tests/Tests.csproj
Tests/image/blank-file.svg [new file with mode: 0644]
Tests/test.style
Tests/ui/MenuItem.template [new file with mode: 0644]
Tests/ui/dbgLog.crow
Tests/ui/dbgLogColors.crow [new file with mode: 0755]
src/BmpPicture.cs
src/Configuration.cs
src/GraphicObjects/DockStack.cs
src/GraphicObjects/DockWindow.cs
src/GraphicObjects/GenericStack.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/Image.cs
src/GraphicObjects/Menu.cs
src/GraphicObjects/MenuItem.cs
src/GraphicObjects/TextBox.cs
src/Interface.cs
src/Measure.cs
src/Mono.Cairo/Surface.cs
src/Mono.Cairo/XcbSurface.cs
src/Picture.cs
src/SvgPicture.cs
src/debug/DbgEventTypeColors.cs [new file with mode: 0644]
src/debug/DbgLogViewer.cs
src/debug/DebugLogger.cs

index 235b077f3b63887938dbf311493c913b35286547..5db4af6d4ed7873f87f0338849b4632c4206941c 100644 (file)
@@ -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<string>("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, "<FileDialog Caption='Open File' CurrentDirectory='{²CurrentDirectory}' SearchPattern='*.sln' OkClicked='onFileOpen'/>");
 
-                       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 () {
index 5f979782a3f49b04a7cb69e7a2fb382e082cfc85..9d0bfe9c4bf3ecab6b80736c5cc0eabb8b8b8ab8 100644 (file)
@@ -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);
index 2cd34412594c32ffb84c80c650028c25a9316629..8ede10e3675b3509df3260d6458b684226c995a6 100644 (file)
@@ -94,7 +94,7 @@ namespace Crow.Coding
                                        }
                                        updateCheckPostProcess ();
                                }
-                               Thread.Sleep (10);
+                               Thread.Sleep (100);
                        }       
                }
        }
index 3cb4f86628655b44dd4e4bf93e9c68dffbbd8eef..e20ba1315bd0b8e2c802a0a86f25f28989af4f29 100644 (file)
@@ -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)
index 3cf422b9b88eeb07b811eda08360b8637858708e..1b3b07dd5298b6a68cd46885ecbd7cad0c367dc1 100644 (file)
@@ -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)));
index 4540898baf3518063cc109ef074c793bc4cc4e26..26e61c916bb0e19c4432316375778546cc845078 100644 (file)
@@ -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);
index 2c4eda5958a5ed9cdae9fadee76a75b1aea07c4f..693da8680d6b9fbf62074683261eac9c1a7aa515 100644 (file)
@@ -464,12 +464,8 @@ namespace Crow.Coding
                                solution.DefaultTemplates [clsName] = pi.Path;
                        }
 
-                       foreach (ProjectReference pr in flattenNodes.OfType<ProjectReference>()) {                              
-                               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<Project> ReferencedProjects {
+                       get {
+                               List<Project> tmp = new List<Project> ();
+                               foreach (ProjectReference pr in flattenNodes.OfType<ProjectReference>()) {                              
+                                       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<ProjectFile> ().Where (pp=>pp.Type == ItemType.EmbeddedResource && pp.Extension == ".style")) {
index 2fac2f91e9df7d20207078ff0e3eb1b27f6208c1..c26cb7cfb9d0852d568d2f154c3552288019a3df 100644 (file)
@@ -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))) 
index 2fc29369ac091c1e916a45da9906461ebd8be240..bf01f99ddbb867e8e1fa4c29e347028d1b016b1c 100644 (file)
@@ -14,7 +14,7 @@
                                                Foreground="Transparent"
                                                Background="{./Background}">
                                                <HorizontalStack HorizontalAlignment="Left" Margin="1">
-                                                       <Image MaximumSize="10,10" Picture="{../../../../../Icon}"/>
+                                                       <Image Width="10" Height="10" Picture="{../../../../../Icon}"/>
                                                        <Label Text="{./Caption}"
                                                                Foreground="{./Foreground}"
                                                                Font="{./Font}" />
index 9709eef9864fa73c23be0b31cb6d0725a12f8fb0..c2f553e4b419862bf4ec8672ab7154a80cab6ebe 100644 (file)
@@ -43,6 +43,7 @@ Label {
 Menu {
        Margin = "1";
        Background = "vgradient|0:DimGrey|1:Black";
+       //Background = "Transparent";
        Height = "Fit";
        Width = "Stretched";
        VerticalAlignment = "Top";
@@ -52,10 +53,13 @@ MenuItem {
        Caption = "MenuItem";
        Width = "Stretched";
        Height = "Fit";
-       Background = "Transparent";
+       //Background = "vgradient|0:DimGrey|1:Black";
+       //Background = "Transparent";
        Foreground = "LightGrey";
-       MouseEnter = "{Background = vgradient|0:SteelBlue|1:Jet;Foreground=White;}";
-       MouseLeave = "{Foreground=LightGrey;Background=Transparent;}";
+       MouseEnter = "{Background=SteelBlue;}";
+       MouseLeave = "{Background=Transparent;}";
+       //MouseEnter = "{Background = vgradient|0:SteelBlue|1:Jet;Foreground=White;}";
+       //MouseLeave = "{Foreground=LightGrey;Background=Transparent;}";
        SelectionBackground = "Transparent";
 }
 MessageBox {
index 2c912fee2be4bc1caa07196a228ddb48232591f8..4f77fb46989df61ba2b3d127308fa928d1de99bb 100644 (file)
@@ -1,4 +1,5 @@
 <?xml version="1.0"?>
+<HorizontalStack>
 <Popper Font="{./Font}" Caption="{./Caption}"  Background="{./Background}" PopDirection="{./PopDirection}"
        Foreground = "{./Foreground}" CanPop="{./HasChildren}" MouseClick="./onMI_Click"
        IsPopped="{²./IsOpened}" PopWidth="{./PopWidth}" PopHeight="{./PopHeight}">
@@ -6,10 +7,6 @@
                <CheckBox IsChecked="{²./IsPopped}" Caption="{./Caption}" Background="{./Background}" Foreground="{./Foreground}">
                        <Template>              
                                <Border Name="border1"
-                                               MouseEnter="{Foreground=vgradient|0:White|0.2:Grey|0.9:Grey|1:Black}"
-                                               MouseLeave="{Foreground=Transparent}"
-                                               MouseDown="{Foreground=vgradient|0:Black|0.05:Grey|0.85:Grey|1:White}"
-                                               MouseUp="{Foreground=vgradient|0:White|0.2:Grey|0.9:Grey|1:Black}"
                                                MinimumSize = "60,0"
                                                Foreground="Transparent"
                                                Background="{./Background}">
@@ -21,7 +18,9 @@
                        </Template>             
                </CheckBox>
        </Template>
-       <Border Foreground="DimGrey" Width="{../PopWidth}" Height="{../PopHeight}" Background="Jet">
+       <Border Foreground="DimGrey" Width="{../PopWidth}" Height="{../PopHeight}" Background="vgradient|0:DimGrey|1:Black">
                <VerticalStack Name="ItemsContainer"/>
        </Border>
 </Popper>
+<GraphicObject Background="Green" Width="5" Height="5" Visible="{./AutomaticOpening}"/>
+</HorizontalStack>
index c3d3a78112f82cd6ac1da332058f4129b05d2f7e..c8f71d9d8a9676f2ae8ebf4ccb534c6f22cc35c4 100644 (file)
@@ -2,44 +2,102 @@ using System;
 using System.Runtime.InteropServices;
 using Crow;
 using System.Threading;
+using System.Collections.Generic;
+using System.Linq;
 
 namespace tests
 {
-       class MainClass
+       class MainClass : Interface
        {
-               static Interface app;
+               static MainClass app;
+               public Command CMDTest;
+               public Measure TestWidth = 100;
 
+               IList<Color> testList = Color.ColorDic.Values.ToList();
+               public IList<Color> TestList {
+                       set{
+                               testList = value;
+                               NotifyValueChanged ("TestList", testList);
+                       }
+                       get { return testList; }
+               }
+               public List<KeyValuePair<DbgEvtType, Color>> ColorsKVPList {
+                       get {
+                               return DbgLogViewer.colors.ToList();
+                       }
+               }
+
+               protected override void InitBackend ()
+               {
+                       base.InitBackend ();
+                       Keyboard.KeyDown += App_KeyboardKeyDown;
+               }
                public static void Main(string[] args)
                {
-                       using (app = new Interface ()) {
+                       using (app = new MainClass ()) {
                                //                              XWindow win = new XWindow (app);
                                //                              win.Show ();
                                //app.LoadIMLFragment (@"<SimpleGauge Level='40' Margin='5' Background='Jet' Foreground='Grey' Width='30' Height='50%'/>");
 
-                               app.Keyboard.KeyDown += App_KeyboardKeyDown;
-
+                               app.CMDTest = new Command(new Action(() => Console.WriteLine("test cmd"))) { Caption = "Test", Icon = new SvgPicture("#Tests.image.blank-file.svg"), CanExecute = true};
+                               //app.AddWidget (@"Interfaces/Divers/testFocus.crow").DataSource = app;
+                               //app.AddWidget (@"Interfaces/Divers/testMenu.crow").DataSource = app;
                                //app.AddWidget (@"Interfaces/Divers/0.crow").DataSource = app;
                                //app.AddWidget (@"Interfaces/Splitter/1.crow").DataSource = app;
                                //app.AddWidget (@"Interfaces/Container/0.crow").DataSource = app;
+
+
                                //app.AddWidget (@"Interfaces/Divers/colorPicker.crow").DataSource = app;
                                //app.AddWidget ("Interfaces/Divers/perfMeasures.crow").DataSource = app;
-                               //app.AddWidget ("#Tests.ui.dbgLog.crow").DataSource = app;
+
+                               /*app.AddWidget ("#Tests.ui.dbgLog.crow").DataSource = app;
+
+                               GraphicObject go = app.AddWidget ("#Tests.ui.dbgLogColors.crow");
+                               go.DataSource = app;
+
+                               (go.FindByName("combo") as ComboBox).SelectedItemChanged += combo_selectedItemChanged;
+                               (go.FindByName("kvpList") as ListBox).SelectedItemChanged += kvpList_selectedItemChanged;*/
+
                                app.AddWidget (@"Interfaces/Experimental/testDock.crow").DataSource = app;
 
-                               app.LoadIMLFragment (@"<DockWindow Width='150' Height='150' Name='dock1'/>");
+                               /*app.LoadIMLFragment (@"<DockWindow Width='150' Height='150' Name='dock1'/>");
                                app.LoadIMLFragment (@"<DockWindow Width='150' Height='150' Name='dock2'/>");
                                app.LoadIMLFragment (@"<DockWindow Width='150' Height='150' Name='dock3'/>");
-                               /*app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");
+
+                               app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");
                                app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");
                                app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");*/
 
-               
+                               long cpt = 0;
+                               Measure testWidth = 100;
+                               int increment = 1;
+
                                while (true) {
-                                       #if MEASURE_TIME
+                                       cpt++;
+                                       /*
+                                       testWidth += increment;
+
+                                       if (increment > 0) {
+                                               if (testWidth > 500)
+                                                       increment = -increment;
+                                       } else if (testWidth < 100) 
+                                               increment = -increment;                                 
+                                       app.NotifyValueChanged ("TestWidth", testWidth);
+*/
+
+                                       /*app.NotifyValueChanged ("CPT", cpt);
+
+                                       if (cpt % 2 == 0)
+                                               app.NotifyValueChanged ("TestColor", Color.Red);
+                                       else
+                                               app.NotifyValueChanged ("TestColor", Color.Blue);*/
+                                       
+                                       /*#if MEASURE_TIME
                                        foreach (PerformanceMeasure m in app.PerfMeasures)
                                                m.NotifyChanges ();     
-                                       #endif
-                                       Thread.Sleep(10);
+                                       #endif*/
+                                       app.ProcessEvents ();
+                                       //Thread.Sleep(1);
                                }
                        }
                        /*using (Display disp = new Display())
@@ -60,16 +118,74 @@ namespace tests
             }*/
                }
 
-               static void App_KeyboardKeyDown (object sender, KeyEventArgs e)
+               void onColorUpdate (object sender, MouseButtonEventArgs e)
+               {
+                       DbgLogViewer.colorsConf.Set (selectedEvtType.ToString (), newColor);
+                       DbgLogViewer.colors [selectedEvtType] = newColor;
+                       NotifyValueChanged ("ColorsKVPList", ColorsKVPList);
+               }
+               static DbgEvtType selectedEvtType;
+               static Color newColor;
+
+               static void kvpList_selectedItemChanged (object sender, SelectionChangeEventArgs e)
+               {
+                       if (e.NewValue == null)
+                               return;
+                       selectedEvtType = ((KeyValuePair<DbgEvtType, Color>)e.NewValue).Key;
+               }
+               static void combo_selectedItemChanged (object sender, SelectionChangeEventArgs e)
+               {
+                       newColor = (Color)e.NewValue;
+
+               }
+
+               void App_KeyboardKeyDown (object sender, KeyEventArgs e)
                {
                        Console.WriteLine((byte)e.Key);
                        //#if DEBUG_LOG
-                       /*switch (e.Key) {
+                       switch (e.Key) {
                        case Key.F2:                            
                                DebugLog.save (app);
                                break;
-                       }*/
+                       case Key.F4:                            
+                               app.NotifyValueChanged ("ColorsKVPList", app.ColorsKVPList);
+                               break;
+                       case Key.F6:                            
+                               saveDocking ();
+                               break;
+                       case Key.F7:                            
+                               reloadDocking ();
+                               break;
+                       case Key.F8:                            
+                               app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");
+                               break;
+                       }
                        //#endif
                }
+
+               void saveDocking () {
+                       DockStack ds = FindByName ("mainDock") as DockStack;
+                       if (ds == null) {
+                               Console.WriteLine ("main dock not found in graphic tree");
+                               return;
+                       }
+                       string conf = ds.ExportConfig ();
+                       Console.WriteLine ("docking conf = " + conf);
+                       Configuration.Global.Set ("DockingTests", conf);
+               }
+               void reloadDocking () {
+                       DockStack ds = FindByName ("mainDock") as DockStack;
+                       if (ds == null) {
+                               Console.WriteLine ("main dock not found in graphic tree");
+                               return;
+                       }
+
+                       string conf = Configuration.Global.Get<string> ("DockingTests");
+                       if (string.IsNullOrEmpty (conf))
+                               return;
+
+
+                       ds.ImportConfig (conf);
+               }
        }
 }
diff --git a/Tests/GraphicObjects/LaggingGraphicObject.cs b/Tests/GraphicObjects/LaggingGraphicObject.cs
new file mode 100644 (file)
index 0000000..98aeaf1
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// SimpleGauge.cs
+//
+// Author:
+//       jp <>
+//
+// 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 Crow;
+using System.ComponentModel;
+using Cairo;
+
+namespace Crow
+{
+       public class LaggingGraphicObject : GraphicObject
+       {
+               protected override void onDraw (Context gr)
+               {
+                       base.onDraw (gr);
+
+
+                       for (int i = 0; i < 100000; i++) {
+                               gr.SetSourceColor (Color.Red);
+                               gr.Rectangle (0, 0, 100, 100);
+                               gr.Stroke ();
+
+                       }
+
+                       //System.Threading.Thread.Sleep (1000);
+
+               }
+
+               public override void onMouseMove (object sender, MouseMoveEventArgs e)
+               {
+
+
+                       RegisterForRedraw ();
+               }
+       }               
+}
+
index df2f4733ba92f1a9a088dc1a57b8ca969dd2482a..2f662fe81f7dd37fcef8b95ff2af80cacd33660f 100755 (executable)
@@ -1,5 +1,7 @@
 <?xml version="1.0"?>
-<Container Background="DimGrey" Margin="10" Width="90%" Height="90%">
-       <GraphicObject Margin="10"  Background="SeaGreen"
-                       MinimumSize="50,50"/>
-</Container>
\ No newline at end of file
+<VerticalStack Margin="10" Background="Jet" >
+       <Label Text="{CPT}" Background="Red" Font="mono, 60" Margin="0"/>
+       <LaggingGraphicObject Name="lagging" Margin="10"  Background="{TestColor}"/>
+</VerticalStack>
+               
+
index 9a03ecef9225076e970b9cbd80ef43114a2240cf..b37fdb6a294968bc3d9432c13e7d946eba57ca96 100755 (executable)
@@ -51,7 +51,7 @@
                                </VerticalStack>
                        </HorizontalStack>
                        <HorizontalStack Height="Fit" Margin="5">
-                               <Label Text="MouseEvents" Width="50%" Margin="3"
+                               <Label Text="MouseEvents" Width="50%" Margin="3" Focusable="true"
                                        Background="Jet"
                                        Foreground="DimGrey"
                                        TextAlignment="Center"
diff --git a/Tests/Interfaces/Divers/testFocus.crow b/Tests/Interfaces/Divers/testFocus.crow
new file mode 100755 (executable)
index 0000000..97a5745
--- /dev/null
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<VerticalStack>
+       <Menu>
+               <MenuItem Caption="File" Width="Fit">
+                       <MenuItem Command="{CMDTest}"/>
+                       <MenuItem Caption="Open"/>
+                       <MenuItem Caption="Save"/>
+                       <MenuItem Caption="Quit"/>
+               </MenuItem>
+               <MenuItem Caption="Edit" Name="edit" Width="Fit">
+                       <MenuItem Caption="Cut"/>
+                       <MenuItem Caption="Copy"/>
+                       <MenuItem Caption="Paste"/>
+                       <MenuItem Caption="Special" Name="special" Width="Fit">
+                               <MenuItem Caption="Cut"/>
+                               <MenuItem Caption="Copy"/>
+                               <MenuItem Caption="Paste"/>
+                       </MenuItem>
+                       <MenuItem Caption="Special2" Name="special" Width="Fit">
+                               <MenuItem Caption="Cut"/>
+                               <MenuItem Caption="Copy"/>
+                               <MenuItem Caption="Paste"/>
+                       </MenuItem>
+               </MenuItem>
+               <MenuItem Caption="Help" Width="Fit">
+                       <MenuItem Caption="About"/>
+                       <MenuItem Caption="Help"/>
+               </MenuItem>
+       </Menu>
+       <HorizontalStack Height="Fit">
+               <Label Text="Hover:" Width="50" Foreground="Grey"/>
+               <Label Text="{HoverWidget}"/>
+       </HorizontalStack>
+       <HorizontalStack Height="Fit">
+               <Label Text="Focus:" Width="50" Foreground="Grey"/>
+               <Label Text="{FocusedWidget}"/>
+       </HorizontalStack>
+       <HorizontalStack Height="Fit">
+               <Label Text="Active:" Width="50" Foreground="Grey"/>
+               <Label Text="{ActiveWidget}"/>
+       </HorizontalStack>
+       <Container Fit="true" Margin="50" Background="SlateGrey">
+               <Label Text="MouseEvents" Margin="3" Focusable="true" Fit="true"
+                       Background="Jet"
+                       Foreground="DimGrey"
+                       TextAlignment="Center"
+                       MouseEnter="{Foreground=White}"
+                       MouseLeave="{Foreground=DimGrey}"
+                       MouseDown="{Background=DarkRed}"
+                       MouseClick="{Foreground=Green}"
+                       MouseDoubleClick="{Foreground=Yellow}"
+                       MouseUp="{Background=Jet}"/>
+       </Container>
+       <TextBox Width="300" Margin="10"/>
+       <Slider Width="300" Height="12"/>
+       <ComboBox Data="{TestList}" Width="120">
+               <ItemTemplate DataType="Crow.Color">
+                       <HorizontalStack
+                                               HorizontalAlignment="Left"
+                                               Height="Fit" Width="200" Margin="1" Focusable="true"
+                                               MouseEnter="{Background=hgradient|0:DarkRed|1:Transparent}"
+                                               MouseLeave="{Background=Transparent}">
+                               <GraphicObject Height="12" Width="20" Background="{}" Margin="0" CornerRadius="3"/>
+                               <Label Text="{}" Margin="0" Width="Stretched"/>
+                       </HorizontalStack>
+               </ItemTemplate>
+       </ComboBox>
+       <HorizontalStack Height="Fit" Margin="1" Background="DimGrey" Width="200">
+                               <VerticalStack Spacing="2" Width="50%">
+                                       <CheckBox Caption="test" MouseEnter="{Background=Blue}" MouseLeave="{Background=Transparent}"/>
+                                       <CheckBox />
+                                       <CheckBox />
+                                       <CheckBox IsChecked="true"/>
+                               </VerticalStack>
+                               <VerticalStack Spacing="2" Width="50%">
+                                       <RadioButton Fit="true"/>
+                                       <RadioButton Fit="true" IsChecked="true"/>
+                                       <RadioButton Fit="true"/>
+                                       <RadioButton Fit="true"/>
+                               </VerticalStack>
+                       </HorizontalStack>
+</VerticalStack>
diff --git a/Tests/Interfaces/Divers/testMenu.crow b/Tests/Interfaces/Divers/testMenu.crow
new file mode 100755 (executable)
index 0000000..0882244
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<Menu>
+       <MenuItem Caption="File" Width="Fit">
+               <MenuItem Command="{CMDTest}"/>
+       </MenuItem>
+</Menu>
index 2d39bd4b74a71e2e7c3c4496d1afd16251f4cad4..ab518ad9b1ed032310b51bf5b8b08144d5e98131 100755 (executable)
                        <Label  Text="{./DockingPosition}" TextAlignment="Left" Width="Fit"
                                         Foreground="White" />
                </HorizontalStack>
+               <Label  Text="{./Width}" TextAlignment="Left" Width="Fit"
+                                Foreground="White" />
+               <Label  Text="{./Height}" TextAlignment="Left" Width="Fit"
+                                Foreground="White" />
+
                <HorizontalStack Visible="{./IsDocked}" Height="Fit" Margin="1" Background="Grey">
                        <Label  Text="{./Caption}" TextAlignment="Left" Width="Stretched"
                                         Foreground="Jet" />
index 62a5203c83624b024f1b29471ee14c3f2bfea592..c0e6e96baab5dfb0f0d1dcd40040ffefc715848f 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
-<Window Width="Stretched" Height="Stretched">
-       <DockStack Background="#60101050" Margin="20">
+<Window Width="Stretched" Height="Stretched" Background="Jet">
+       <DockStack Name="mainDock" Background="DarkRed" Margin="20">
        </DockStack>
 </Window>
 <!---          
diff --git a/Tests/Interfaces/colorItem2.crow b/Tests/Interfaces/colorItem2.crow
new file mode 100755 (executable)
index 0000000..4e29d38
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<Border Foreground="Transparent" Focusable="true" HorizontalAlignment="Left" Height="Fit">
+       <HorizontalStack Margin="0"
+                               MouseEnter="{Background=CornflowerBlue}"
+                               MouseLeave="{Background=Transparent}">
+               <GraphicObject Height="8" Width="14" Background="{}" Margin="0" CornerRadius="2"/>
+               <Label Text="{}" Margin="0" Width="Stretched" Font="mono, 8"/>
+       </HorizontalStack>
+</Border>
+
index 049ab6f91557fe5222b3645327a9ca3fe13486f8..2d3717cfe69e17a744d57a4c2c55c0c4d4ccb36d 100644 (file)
     <Compile Include="GraphicObjects\HexaContainer.cs" />
     <Compile Include="GraphicObjects\TechBorder.cs" />
     <Compile Include="keysyms.cs" />
+    <Compile Include="GraphicObjects\LaggingGraphicObject.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include="image\u.svg">
     <None Include="Interfaces\TemplatedContainer\testTabView2.crow">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Include="Interfaces\Divers\testFocus.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Interfaces\Divers\testMenu.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Interfaces\" />
     <EmbeddedResource Include="Interfaces\Experimental\DockWindow.template">
       <LogicalName>Crow.DockWindow.template</LogicalName>
     </EmbeddedResource>
+    <EmbeddedResource Include="ui\MenuItem.template">
+      <LogicalName>Crow.MenuItem.template</LogicalName>
+    </EmbeddedResource>
+    <EmbeddedResource Include="image\blank-file.svg" />
+    <EmbeddedResource Include="ui\dbgLogColors.crow" />
+    <EmbeddedResource Include="Interfaces\colorItem2.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </EmbeddedResource>
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\Crow.csproj">
diff --git a/Tests/image/blank-file.svg b/Tests/image/blank-file.svg
new file mode 100644 (file)
index 0000000..8136979
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generated by IcoMoon.io -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
+<path fill="#FFFFFF" d="M10 0h-8v16h12v-12l-4-4zM9 5h4v10h-10v-14h6v4zM10 4v-3l3 3h-3z"></path>
+</svg>
index 14acbbdfdcfc0d50c8f43495b36d7f5d97618959..7f912f5424c1090c9f181125feb52b245753b0ff 100644 (file)
@@ -38,3 +38,6 @@ DbgLogViewer{
        Foreground = "LightGrey";
        Focusable = "true";
 }
+DockWindow{
+       Background = "0.1,0.1,0.1,0.5";
+}
diff --git a/Tests/ui/MenuItem.template b/Tests/ui/MenuItem.template
new file mode 100644 (file)
index 0000000..bf01f99
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<Popper Font="{./Font}" Caption="{./Caption}"  Background="{./Background}" PopDirection="{./PopDirection}"
+       Foreground = "{./Foreground}" CanPop="{./HasChildren}" MouseClick="./onMI_Click"
+       IsPopped="{²./IsOpened}" PopWidth="{./PopWidth}" PopHeight="{./PopHeight}" IsEnabled="{./IsEnabled}">
+       <Template>
+               <CheckBox IsChecked="{²./IsPopped}" Caption="{./Caption}" Background="{./Background}" Foreground="{./Foreground}">
+                       <Template>
+                               <Border Name="border1"
+                                               MouseEnter="{Foreground=vgradient|0:White|0.2:Grey|0.9:Grey|1:Black}"
+                                               MouseLeave="{Foreground=Transparent}"
+                                               MouseDown="{Foreground=vgradient|0:Black|0.05:Grey|0.85:Grey|1:White}"
+                                               MouseUp="{Foreground=vgradient|0:White|0.2:Grey|0.9:Grey|1:Black}"
+                                               MinimumSize = "40,0"
+                                               Foreground="Transparent"
+                                               Background="{./Background}">
+                                               <HorizontalStack HorizontalAlignment="Left" Margin="1">
+                                                       <Image Width="10" Height="10" Picture="{../../../../../Icon}"/>
+                                                       <Label Text="{./Caption}"
+                                                               Foreground="{./Foreground}"
+                                                               Font="{./Font}" />
+                                               </HorizontalStack>
+                               </Border>
+                       </Template>
+               </CheckBox>
+       </Template>
+       <Border Foreground="DimGrey" Width="{../PopWidth}" Height="{../PopHeight}" Background="Jet">
+               <VerticalStack Name="ItemsContainer"/>
+       </Border>
+</Popper>
index 86ed0edc32fffd9f31d8647ba5442a51d27fa7b3..cf7e2ae4865cdf768c6425694abee390848575e8 100755 (executable)
@@ -1,32 +1,34 @@
 <?xml version="1.0"?>
-<VerticalStack>
-       <HorizontalStack Height="Fit">
-               <Label Text="Scale X:"/>
-               <Label Text="{../../view.XScale}"/>
-               <Label Text="Scroll X:"/>
-               <Label Text="{../../view.ScrollX}"/>
-               <Label Text="Max Scroll X:"/>
-               <Label Text="{../../view.MaxScrollX}"/>
-               <Label Text="Scroll Y:"/>
-               <Label Text="{../../view.ScrollY}"/>
-               <Label Text="Visible Lines:"/>
-               <Label Text="{../../view.VisibleLines}"/>
-               <Label Text="Visible Ticks:"/>
-               <Label Text="{../../view.VisibleTicks}"/>
-               <Label Text="CurrentLine:"/>
-               <Label Text="{../../view.CurrentLine}"/>
-       </HorizontalStack>
-       <HorizontalStack>
-               <DbgLogViewer Margin="0" Name="view" LogFile="debug.log" MouseWheelSpeed="10"/>
-               <ScrollBar Name="scrollbar1" Orientation="Vertical"
-                       Value="{²../view.ScrollY}"     Maximum="{../view.MaxScrollY}" 
-                       CursorSize="{../view.ChildHeightRatio}"
-                       LargeIncrement="{../view.PageHeight}" SmallIncrement="30"
-                       Width="14" />
-       </HorizontalStack>
-       <ScrollBar Style="HScrollBar" Name="scrollbarX" Orientation="Horizontal"
-                       Value="{²../view.ScrollX}" Maximum="{../view.MaxScrollX}" 
-                       CursorSize="{../view.ChildWidthRatio}" 
-                       LargeIncrement="{../view.PageWidth}" SmallIncrement="30"
-                       Height="14" />
-</VerticalStack>
+<Window Width="Stretched" Height="Stretched">
+       <VerticalStack>
+               <HorizontalStack Height="Fit">
+                       <Label Text="Scale X:"/>
+                       <Label Text="{../../view.XScale}"/>
+                       <Label Text="Scroll X:"/>
+                       <Label Text="{../../view.ScrollX}"/>
+                       <Label Text="Max Scroll X:"/>
+                       <Label Text="{../../view.MaxScrollX}"/>
+                       <Label Text="Scroll Y:"/>
+                       <Label Text="{../../view.ScrollY}"/>
+                       <Label Text="Visible Lines:"/>
+                       <Label Text="{../../view.VisibleLines}"/>
+                       <Label Text="Visible Ticks:"/>
+                       <Label Text="{../../view.VisibleTicks}"/>
+                       <Label Text="CurrentLine:"/>
+                       <Label Text="{../../view.CurrentLine}"/>
+               </HorizontalStack>
+               <HorizontalStack>
+                       <DbgLogViewer Margin="0" Name="view" LogFile="debug.log" MouseWheelSpeed="10"/>
+                       <ScrollBar Name="scrollbar1" Orientation="Vertical"
+                               Value="{²../view.ScrollY}"     Maximum="{../view.MaxScrollY}" 
+                               CursorSize="{../view.ChildHeightRatio}"
+                               LargeIncrement="{../view.PageHeight}" SmallIncrement="30"
+                               Width="12" />
+               </HorizontalStack>
+               <ScrollBar Style="HScrollBar" Name="scrollbarX" Orientation="Horizontal"
+                               Value="{²../view.ScrollX}" Maximum="{../view.MaxScrollX}" 
+                               CursorSize="{../view.ChildWidthRatio}" 
+                               LargeIncrement="{../view.PageWidth}" SmallIncrement="30"
+                               Height="12" />
+       </VerticalStack>
+</Window>
\ No newline at end of file
diff --git a/Tests/ui/dbgLogColors.crow b/Tests/ui/dbgLogColors.crow
new file mode 100755 (executable)
index 0000000..cc9fdb2
--- /dev/null
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<Window Template="#Crow.ToolWindow.template" AlwaysOnTop="true" Width="400" Height="300"
+       HorizontalAlignment="Right" VerticalAlignment="Bottom">
+       <VerticalStack>
+               <Button Caption="update" MouseClick="onColorUpdate"/>
+               <HorizontalStack Height="Fit" DataSource="{../kvpList.SelectedItem}" Margin="10">                       
+                       <Label Text="{Key}" Margin="0" Width="Stretched" Font="mono, 8"/>
+                       <ComboBox Data="{TestList}" ItemTemplate="#Tests.Interfaces.colorItem2.crow" Name="combo"
+                               SelectedItem="{Value}">
+                               <Template>
+                                       <Popper Caption="{./SelectedItem}" Name="popper" PopDirection="Bottom" Foreground="{./Foreground}" Background="{./Background}">
+                                               <Template>
+                                                       <CheckBox Caption="{./Caption}" IsChecked="{²./IsPopped}" Foreground="{./Foreground}" Background="{./Background}">
+                                                               <Template>
+                                                                       <Border CornerRadius="0" Foreground="LightGrey">
+                                                                               <HorizontalStack Margin="0" Spacing="1">
+                                                                                       <!---<GraphicObject Height="8" Width="14" Background="{./Caption}" Margin="0" CornerRadius="2"/>-->
+                                                                                       <Label MinimumSize="80,10" Text="{./Caption}" Margin="0" Width="Stretched" Font="mono, 8"/>
+                                                                                       <Button Width="14" Height="14" Focusable="false"
+                                                                                               Template="#Crow.Templates.ArrowBut.template">
+                                                                                               <Image Margin="0"  Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/>
+                                                                                       </Button>
+                                                                               </HorizontalStack>
+                                                                       </Border>
+                                                               </Template>
+                                                       </CheckBox>
+                                               </Template>
+                                               <Border Background="DimGrey" BorderWidth="1" Margin="1"
+                                                       MinimumSize="{../../MinimumPopupSize}" Fit="true">
+                                                       <Scroller Name="scroller1" Margin="2" 
+                                                               MaximumSize="0,200"
+                                                               HorizontalAlignment="Left">
+                                                               <VerticalStack
+                                                                       Height="Fit" Name="ItemsContainer" Margin="0"
+                                                                       HorizontalAlignment="Left"
+                                                                       VerticalAlignment="Top"/>
+                                                       </Scroller>
+                                               </Border>
+                                       </Popper>
+                               </Template>
+                       </ComboBox>
+                       <GraphicObject Height="8" Width="14" Background="{Value}" Margin="0" CornerRadius="2"/>
+               </HorizontalStack>
+               <HorizontalStack>                       
+                       <ListBox Name="kvpList" Data="{ColorsKVPList}" Margin="0"                
+                                Template="#Crow.Templates.ScrollingListBox.template">
+                                <ItemTemplate>
+                                       <Border Foreground="Transparent" Focusable="true" HorizontalAlignment="Left" Height="Fit">
+                                               <HorizontalStack Margin="0"
+                                                                       MouseEnter="{Background=CornflowerBlue}"
+                                                                       MouseLeave="{Background=Transparent}">
+                                                       <GraphicObject Height="8" Width="14" Background="{Value}" Margin="0" CornerRadius="2"/>
+                                                       <Label Text="{Key}" Margin="0" Width="Stretched" Font="mono, 8"/>
+                                               </HorizontalStack>
+                                       </Border>
+                                </ItemTemplate>
+                       </ListBox>       
+               </HorizontalStack>
+       </VerticalStack>
+</Window>
\ No newline at end of file
index e3af9c79781761a5a6abb6fdffce3788b3a17470..1c7250b8ab704ff4d767f1aaced288085d76c604 100644 (file)
@@ -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
index a6328c0a0bb6212a278a983e6a6f1902cfbbd1e8..4acba6af8cc24eb3ffa30e7c169bfb8014214502 100644 (file)
@@ -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>
index f217402480f81dda039698eff3f42a0883645e3b..aa7c33da7fdd5a0ad8bd3cd6ca41b16c7f24ea7c 100644 (file)
@@ -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 ();
+               }
        }
 }
 
index 1ae3b0b450eb3947e3bda6fd95017851429c9133..d6385057a4fcbb62c11b4aa95928494e1449d49b 100644 (file)
@@ -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);
-               }
        }
 }
 
index 64841d4b79415dac9f5f9eff1da73b851390b6a3..f281311cd97d9c94e1025c0daa4ad5fb35199a7b 100644 (file)
@@ -242,5 +242,11 @@ namespace Crow
                        else                            
                                adjustStretchedGo (LayoutingType.Height);                       
                }
+
+               public override void ClearChildren ()
+               {
+                       base.ClearChildren ();
+                       stretchedGO = null;
+               }
        }
 }
index 2bf20f27bf2e517b4c0653d3f94b21ddded97307..747609b08619976dcae527d0f7650cf2fce9b140 100644 (file)
@@ -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 ();
index a90947a56cedcce61bca0d052d24cd39c9fbd7b3..ece1f09036baabe338e5fc44c02d603ac7f5400b 100644 (file)
@@ -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 ();
index e83183c003c34ee423b6279791e052b3aa2896da..5960101a3a3ea5f3c2d01d9bb157fcbc86540919 100644 (file)
@@ -173,7 +173,7 @@ namespace Crow
                        else
                                pic = new BmpPicture (path);
 
-                       pic.Load (IFace, path);
+
                        pic.Scaled = scaled;
                        pic.KeepProportions = keepProps;
 
index dbc1d6369012c0d2244a710e9584679893a754a4..0ddb8eaee54cba324aa98137a4813708bf4c0c6d 100644 (file)
@@ -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;
                }
        }
 }
index 47bd978f03c3ff34e5d45c77894e8aec19b97a08..3b25a9fe3ac5243222905c5c3f8cf2434d5db175 100644 (file)
@@ -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;
                        }
                }
index 7d14f8009a2188fb166bc7312804593b5cba7913..5da67e3195a751bdb2d7e5efd45c66e996fc2453 100644 (file)
@@ -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)
index 771377619d15c9effe8bb744a10f0633f3e9eb65..3c586685af454eb69559e4856c58110ef7bc3f8c 100644 (file)
@@ -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 ();
index 0374f5d9d6ebb3c05f86339b45d0a5c6c9543df8..c40c670318bcf1f2a66eedb6955198eb41187e4b 100644 (file)
@@ -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;
index 6a55496a516e155cdccd2e34bcce5e984e026649..e7a2a5e47aee04cde3cf5140ffa30e131ca99f80 100644 (file)
@@ -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 ()
                {
index 142ebf9e31a0530bf5fafa8a4a7cb4e322f0940d..b9995ee633b26186a9eb54a2ae72af628f240169 100644 (file)
@@ -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);
                }
        }
 }
index 3784780b812dbcae8def3491e482634dc238fc46..f2f45261874ccdcf93f176fbb9303c8e3f1f526c 100644 (file)
@@ -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>
index f676a4975d3796be9b280a4cca519415df4695eb..dee6c8e0f2d480ff9a09eaeabd0216891465d1da 100644 (file)
@@ -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 (file)
index 0000000..e088118
--- /dev/null
@@ -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
+}
+
index 7c8a1bdf13895f9894cc4352c7cb11d0046c00ba..6124d6f98e9ecd90820df61a317481805eecdf32 100644 (file)
@@ -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)
                {
index 18e4ae194ce687553bbf52ec7b52bfc4ffd09af7..38cbc2afe345a65fd7f7bad3b3c2198c61a72569 100644 (file)
@@ -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 ());
                        }
                }
        }