diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-04-11 15:25:22 +0200 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-04-11 15:25:22 +0200 |
| commit | 8d1522d4cb7ff6db0a9f0c7a61dd75faa887fdd7 (patch) | |
| tree | 148186f17a068129ead511363616c02727d73ab6 /Samples | |
| parent | af75526e0ba507bad1b32963437491a4f752330e (diff) | |
debug docking windows
Diffstat (limited to 'Samples')
| -rw-r--r-- | Samples/common/SampleBase.cs | 586 | ||||
| -rw-r--r-- | Samples/common/samples.style | 12 | ||||
| -rw-r--r-- | Samples/common/ui/icons/Crow.DockStack.svg (renamed from Samples/common/ui/icons/Crow.Docker.svg) | 0 | ||||
| -rw-r--r-- | Samples/common/ui/icons/Crow.DockWindow.svg | 6 | ||||
| -rw-r--r-- | Samples/dockableWindows/dockableWindows.cs | 27 | ||||
| -rw-r--r-- | Samples/dockableWindows/ui/TabView.template | 32 | ||||
| -rw-r--r-- | Samples/dockableWindows/ui/dock.style | 12 | ||||
| -rw-r--r-- | Samples/dockableWindows/ui/dockWin.template | 24 | ||||
| -rw-r--r-- | Samples/dockableWindows/ui/test.crow | 11 | ||||
| -rw-r--r-- | Samples/dragNdrop/dragNdrop.cs | 8 |
10 files changed, 441 insertions, 277 deletions
diff --git a/Samples/common/SampleBase.cs b/Samples/common/SampleBase.cs index a17eaf92..22d1fb0b 100644 --- a/Samples/common/SampleBase.cs +++ b/Samples/common/SampleBase.cs @@ -12,301 +12,371 @@ using System.Threading; namespace Crow { - public class SampleBase : Interface - { + public class SampleBase : Interface + { #if NETCOREAPP - static IntPtr resolveUnmanaged (Assembly assembly, String libraryName) { - + static IntPtr resolveUnmanaged(Assembly assembly, String libraryName) + { + switch (libraryName) { case "glfw3": - return NativeLibrary.Load("glfw", assembly, null); + return NativeLibrary.Load("glfw", assembly, null); case "rsvg-2.40": - return NativeLibrary.Load("rsvg-2", assembly, null); + return NativeLibrary.Load("rsvg-2", assembly, null); } - Console.WriteLine ($"[UNRESOLVE] {assembly} {libraryName}"); + Console.WriteLine($"[UNRESOLVE] {assembly} {libraryName}"); return IntPtr.Zero; } - static SampleBase () { - System.Runtime.Loader.AssemblyLoadContext.GetLoadContext(Assembly.GetExecutingAssembly()).ResolvingUnmanagedDll+=resolveUnmanaged; + static SampleBase() + { + System.Runtime.Loader.AssemblyLoadContext.GetLoadContext(Assembly.GetExecutingAssembly()).ResolvingUnmanagedDll += resolveUnmanaged; } #endif - public SampleBase (IntPtr hWin) : base (800,600,hWin){} - public SampleBase () : base (800,600,true,true){} - public SampleBase (int width, int height, bool startUIThread, bool createSurface) : - base (width, height, startUIThread, createSurface){ - - } + public SampleBase(IntPtr hWin) : base(800, 600, hWin) { } + public SampleBase() : base(800, 600, true, true) { } + public SampleBase(int width, int height, bool startUIThread, bool createSurface) : + base(width, height, startUIThread, createSurface) + { + + } - public Version CrowVersion => Assembly.GetAssembly (typeof (Widget)).GetName ().Version; + public Version CrowVersion => Assembly.GetAssembly(typeof(Widget)).GetName().Version; - #region Test values for Binding - public CommandGroup Commands; - public CommandGroup EditCommands = new CommandGroup( - new Command("command 1", () => Console.WriteLine("command1 pressed"))); + #region Test values for Binding + public CommandGroup Commands, AllCommands; + public CommandGroup EditCommands = new CommandGroup("Edit Commands", + new Command("Edit command 1", () => Console.WriteLine("edit command1 pressed")), + new Command("Edit command 2", () => Console.WriteLine("edit command2 pressed")), + new Command("Edit command 3", () => Console.WriteLine("edit command3 pressed")) + ); + public CommandGroup FileCommands = new CommandGroup("File Commands", + new Command("File command 1", () => Console.WriteLine("File command1 pressed")), + new Command("File command 2", () => Console.WriteLine("File command2 pressed")), + new Command("File command 3", () => Console.WriteLine("File command3 pressed")) + ); - public int intValue = 500; - VerticalAlignment currentVAlign; + void initCommands() + { + Commands = new CommandGroup("commands msg boxes", + new Command("Action 1", () => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 1 clicked")), + new Command("Action 2", () => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 2 clicked")), + new Command("Action 3", () => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 3 clicked")) + ); + AllCommands = new CommandGroup ("All Commands", + EditCommands, + FileCommands, + new Command("Action A", () => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu A clicked")) + ); + } + public int intValue = 500; + VerticalAlignment currentVAlign; - DirectoryInfo curDir = new DirectoryInfo (Path.GetDirectoryName (Assembly.GetEntryAssembly ().Location)); - public FileSystemInfo[] CurDirectory => curDir.GetFileSystemInfos (); - public string MultilineText = - $"Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit. Sed non risus.\n\nSuspendisse lectus tortor,\nLorem ipsum dolor sit amet,\nconsectetur adipiscing elit. Sed non risus.\n\nSuspendisse lectus tortor,"; - //public string MultilineText = $"a\n"; - TextAlignment textAlignment = TextAlignment.Left; - public TextAlignment TextAlignment { - get => textAlignment; - set { - if (textAlignment == value) - return; - textAlignment = value; - NotifyValueChanged (textAlignment); - } - } + DirectoryInfo curDir = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); + public FileSystemInfo[] CurDirectory => curDir.GetFileSystemInfos(); + public string MultilineText = + $"Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit. Sed non risus.\n\nSuspendisse lectus tortor,\nLorem ipsum dolor sit amet,\nconsectetur adipiscing elit. Sed non risus.\n\nSuspendisse lectus tortor,"; + //public string MultilineText = $"a\n"; + TextAlignment textAlignment = TextAlignment.Left; + public TextAlignment TextAlignment + { + get => textAlignment; + set + { + if (textAlignment == value) + return; + textAlignment = value; + NotifyValueChanged(textAlignment); + } + } - public int IntValue { - get => intValue; - set { - if (IntValue == value) - return; - intValue = value; - NotifyValueChanged ("IntValue", intValue); - } - } - public VerticalAlignment CurrentVAlign { - get => currentVAlign; - set { - if (currentVAlign == value) - return; - currentVAlign = value; - NotifyValueChanged ("CurrentVAlign", currentVAlign); - } - } - void onSpinnerValueChange (object sender, ValueChangeEventArgs e) { - if (e.MemberName != "Value") - return; - intValue = Convert.ToInt32 (e.NewValue); - } - void change_alignment (object sender, EventArgs e) { - RadioButton rb = sender as RadioButton; - if (rb == null) - return; - NotifyValueChanged ("alignment", Enum.Parse (typeof (Alignment), rb.Caption)); - } - public IEnumerable<String> List2 = new List<string> (new string[] - { - "string1", - "string2", - "string3", - "string4", - "string5", - "string6", - "string7", - "string8", - "string8", - "string8", - "string8", - "string8", - "string8", - "string9" - } - ); - public IEnumerable<String> TestList2 { - set { - List2 = value; - NotifyValueChanged ("TestList2", testList); - } - get { return List2; } - } - public class TestClass - { - public string Prop1 { get; set; } - public string Prop2 { get; set; } + public int IntValue + { + get => intValue; + set + { + if (IntValue == value) + return; + intValue = value; + NotifyValueChanged("IntValue", intValue); + } + } + public VerticalAlignment CurrentVAlign + { + get => currentVAlign; + set + { + if (currentVAlign == value) + return; + currentVAlign = value; + NotifyValueChanged("CurrentVAlign", currentVAlign); + } + } + void onSpinnerValueChange(object sender, ValueChangeEventArgs e) + { + if (e.MemberName != "Value") + return; + intValue = Convert.ToInt32(e.NewValue); + } + void change_alignment(object sender, EventArgs e) + { + RadioButton rb = sender as RadioButton; + if (rb == null) + return; + NotifyValueChanged("alignment", Enum.Parse(typeof(Alignment), rb.Caption)); + } + public IEnumerable<String> List2 = new List<string>(new string[] + { + "string1", + "string2", + "string3", + "string4", + "string5", + "string6", + "string7", + "string8", + "string8", + "string8", + "string8", + "string8", + "string8", + "string9" + } + ); + public IEnumerable<String> TestList2 + { + set + { + List2 = value; + NotifyValueChanged("TestList2", testList); + } + get { return List2; } + } + public class TestClass + { + public string Prop1 { get; set; } + public string Prop2 { get; set; } - public override string ToString () - => $"{Prop1}, {Prop2}"; + public override string ToString() + => $"{Prop1}, {Prop2}"; - public void OnValidateCommand (Object sender, ValidateEventArgs e) { - Console.WriteLine ($"Validation: {e.ValidatedText}"); + public void OnValidateCommand(Object sender, ValidateEventArgs e) + { + Console.WriteLine($"Validation: {e.ValidatedText}"); + } + } + public class TestClassVC : IValueChange + { + public event EventHandler<ValueChangeEventArgs> ValueChanged; + public void NotifyValueChanged(object _value, [CallerMemberName] string caller = null) + => ValueChanged.Raise(this, new ValueChangeEventArgs(caller, _value)); + string prop1, prop2; + public string Prop1 + { + get => prop1; + set + { + if (prop1 == value) + return; + prop1 = value; + NotifyValueChanged(prop1); + } } - } - public class TestClassVC : IValueChange - { - public event EventHandler<ValueChangeEventArgs> ValueChanged; - public void NotifyValueChanged (object _value, [CallerMemberName] string caller = null) - => ValueChanged.Raise (this, new ValueChangeEventArgs (caller, _value)); - string prop1, prop2; - public string Prop1 { - get => prop1; - set { - if (prop1 == value) - return; - prop1 = value; - NotifyValueChanged (prop1); - } - } - public string Prop2 { - get => prop2; - set { - if (prop2 == value) - return; - prop2 = value; - NotifyValueChanged (prop2); - } + public string Prop2 + { + get => prop2; + set + { + if (prop2 == value) + return; + prop2 = value; + NotifyValueChanged(prop2); + } - } + } + + public override string ToString() + => $"{Prop1}, {Prop2}"; - public override string ToString () - => $"{Prop1}, {Prop2}"; + } + TestClass tcInstance = new TestClass() { Prop1 = "instance 0 prop1 value", Prop2 = "instance 0 prop2 value" }; + TestClassVC tcVCInstance;// = new TestClassVC () { Prop1 = "instance 0 prop1 value", Prop2 = "instance 0 prop2 value" }; + TestClass tcInstance1 = new TestClass() { Prop1 = "instance 1 prop1 value", Prop2 = "instance 1 prop2 value" }; + TestClassVC tcVCInstance1 = new TestClassVC() { Prop1 = "instance 1 prop1 value", Prop2 = "instance 1 prop2 value" }; + TestClass tcInstance2 = new TestClass() { Prop1 = "instance 2 prop1 value", Prop2 = "instance 2 prop2 value" }; + TestClassVC tcVCInstance2 = new TestClassVC() { Prop1 = "instance 2 prop1 value", Prop2 = "instance 2 prop2 value" }; - } - TestClass tcInstance = new TestClass () { Prop1 = "instance 0 prop1 value", Prop2 = "instance 0 prop2 value" }; - TestClassVC tcVCInstance;// = new TestClassVC () { Prop1 = "instance 0 prop1 value", Prop2 = "instance 0 prop2 value" }; - TestClass tcInstance1 = new TestClass () { Prop1 = "instance 1 prop1 value", Prop2 = "instance 1 prop2 value" }; - TestClassVC tcVCInstance1 = new TestClassVC () { Prop1 = "instance 1 prop1 value", Prop2 = "instance 1 prop2 value" }; - TestClass tcInstance2 = new TestClass () { Prop1 = "instance 2 prop1 value", Prop2 = "instance 2 prop2 value" }; - TestClassVC tcVCInstance2 = new TestClassVC () { Prop1 = "instance 2 prop1 value", Prop2 = "instance 2 prop2 value" }; + public TestClass TcInstance + { + get => tcInstance; + set + { + if (tcInstance == value) + return; + tcInstance = value; + NotifyValueChanged(tcInstance); + } + } + public TestClassVC TcVCInstance + { + get => tcVCInstance; + set + { + if (tcVCInstance == value) + return; + tcVCInstance = value; + NotifyValueChanged(tcVCInstance); + } + } - public TestClass TcInstance { - get => tcInstance; - set { - if (tcInstance == value) - return; - tcInstance = value; - NotifyValueChanged (tcInstance); - } - } - public TestClassVC TcVCInstance { - get => tcVCInstance; - set { - if (tcVCInstance == value) - return; - tcVCInstance = value; - NotifyValueChanged (tcVCInstance); - } - } + void tcInstance_ChangeProperties_MouseClick(object sender, MouseButtonEventArgs e) + { + } + public void tcInstance_ChangeInstance_MouseClick(object sender, MouseButtonEventArgs e) + { + if (TcInstance == tcInstance1) + TcInstance = tcInstance2; + else + TcInstance = tcInstance1; + } + void tcVCInstance_ChangeInstance_MouseClick(object sender, MouseButtonEventArgs e) + { + TcVCInstance = new TestClassVC() { Prop1 = "prop1 value changed", Prop2 = "prop2 value changed" }; + } - void tcInstance_ChangeProperties_MouseClick (object sender, MouseButtonEventArgs e) { - } - public void tcInstance_ChangeInstance_MouseClick (object sender, MouseButtonEventArgs e) { - if (TcInstance == tcInstance1) - TcInstance = tcInstance2; - else - TcInstance = tcInstance1; - } - void tcVCInstance_ChangeInstance_MouseClick (object sender, MouseButtonEventArgs e) { - TcVCInstance = new TestClassVC () { Prop1 = "prop1 value changed", Prop2 = "prop2 value changed" }; - } + public IEnumerable<TestClass> List3 = new List<TestClass>(new TestClass[] + { + new TestClass { Prop1 = "string1", Prop2="prop2-1" }, + new TestClass { Prop1 = "string2", Prop2="prop2-2" }, + new TestClass { Prop1 = "string3", Prop2="prop2-3" }, + } + ); + public IEnumerable<string> TestList3Props1 => List3.Select(sc => sc.Prop1).ToList(); + public IEnumerable<TestClass> TestList3 + { + set + { + List3 = value; + NotifyValueChanged("TestList3", testList); + } + get { return List3; } + } + string testString; + public string TestString + { + get => testString; + set + { + if (testString == value) + return; + testString = value; - public IEnumerable<TestClass> List3 = new List<TestClass> (new TestClass[] - { - new TestClass { Prop1 = "string1", Prop2="prop2-1" }, - new TestClass { Prop1 = "string2", Prop2="prop2-2" }, - new TestClass { Prop1 = "string3", Prop2="prop2-3" }, - } - ); - public IEnumerable<string> TestList3Props1 => List3.Select (sc => sc.Prop1).ToList (); - public IEnumerable<TestClass> TestList3 { - set { - List3 = value; - NotifyValueChanged ("TestList3", testList); - } - get { return List3; } - } - string prop1; - public string TestList3SelProp1 { - get => prop1; - set { - if (prop1 == value) - return; - prop1 = value; + NotifyValueChanged(testString); + } + } + string prop1; + public string TestList3SelProp1 + { + get => prop1; + set + { + if (prop1 == value) + return; + prop1 = value; - NotifyValueChanged (prop1); - } - } + NotifyValueChanged(prop1); + } + } - string selString; - public string TestList2SelectedString { - get => selString; - set { - if (selString == value) - return; - selString = value; - NotifyValueChanged (selString); - } - } + string selString; + public string TestList2SelectedString + { + get => selString; + set + { + if (selString == value) + return; + selString = value; + NotifyValueChanged(selString); + } + } - IList<Colors> testList = (IList<Colors>)FastEnumUtility.FastEnum.GetValues<Colors> ().ToList ();//.ColorDic.Values//.OrderBy(c=>c.Hue) - //.ThenBy(c=>c.Value).ThenBy(c=>c.Saturation) - //.ToList (); - public IList<Colors> TestList { - set { - testList = value; - NotifyValueChanged ("TestList", testList); - } - get { return testList; } - } - void OnClear (object sender, MouseButtonEventArgs e) => TestList = null; - void OnLoadList (object sender, MouseButtonEventArgs e) => TestList = (IList<Colors>)FastEnumUtility.FastEnum.GetValues<Colors> ().ToList (); + IList<Colors> testList = (IList<Colors>)FastEnumUtility.FastEnum.GetValues<Colors>().ToList();//.ColorDic.Values//.OrderBy(c=>c.Hue) + //.ThenBy(c=>c.Value).ThenBy(c=>c.Saturation) + //.ToList (); + public IList<Colors> TestList + { + set + { + testList = value; + NotifyValueChanged("TestList", testList); + } + get { return testList; } + } + void OnClear(object sender, MouseButtonEventArgs e) => TestList = null; + void OnLoadList(object sender, MouseButtonEventArgs e) => TestList = (IList<Colors>)FastEnumUtility.FastEnum.GetValues<Colors>().ToList(); - string curSources = ""; - public string CurSources { - get { return curSources; } - set { - if (value == curSources) - return; - curSources = value; - NotifyValueChanged (curSources); - } - } - bool boolVal = true; - public bool BoolVal { - get { return boolVal; } - set { - if (boolVal == value) - return; - boolVal = value; - NotifyValueChanged (boolVal); - } - } + string curSources = ""; + public string CurSources + { + get { return curSources; } + set + { + if (value == curSources) + return; + curSources = value; + NotifyValueChanged(curSources); + } + } + bool boolVal = true; + public bool BoolVal + { + get { return boolVal; } + set + { + if (boolVal == value) + return; + boolVal = value; + NotifyValueChanged(boolVal); + } + } - #endregion + #endregion - protected override void OnInitialized () { - Commands = new CommandGroup ( - new Command("Action 1", () => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 1 clicked")), - new Command("Action 2", () => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 2 clicked")), - new Command("Action 3", () => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 3 clicked")) - ); - base.OnInitialized (); - } + protected override void OnInitialized() + { + initCommands(); + base.OnInitialized(); + } - public override bool OnKeyDown (Key key) { + public override bool OnKeyDown(Key key) + { - switch (key) { - case Key.F5: - Load ("Interfaces/Divers/testFileDialog.crow").DataSource = this; - return true; - case Key.F6: - Load ("Interfaces/Divers/0.crow").DataSource = this; - return true; - case Key.F7: - Load ("Interfaces/Divers/perfMeasures.crow").DataSource = this; - return true; - case Key.F2: - if (IsKeyDown (Key.LeftShift)) - DbgLogger.Reset (); - DbgLogger.Save (this); - return true; - } - return base.OnKeyDown (key); - } - } + switch (key) + { + case Key.F5: + Load("Interfaces/Divers/testFileDialog.crow").DataSource = this; + return true; + case Key.F6: + Load("Interfaces/Divers/0.crow").DataSource = this; + return true; + case Key.F7: + Load("Interfaces/Divers/perfMeasures.crow").DataSource = this; + return true; + case Key.F2: + if (IsKeyDown(Key.LeftShift)) + DbgLogger.Reset(); + DbgLogger.Save(this); + return true; + } + return base.OnKeyDown(key); + } + } }
\ No newline at end of file diff --git a/Samples/common/samples.style b/Samples/common/samples.style index 50f91f4a..7c33bd9d 100644 --- a/Samples/common/samples.style +++ b/Samples/common/samples.style @@ -52,6 +52,16 @@ DbgLogViewer{ DockWindow{ Background = "0.1,0.1,0.1,0.5"; } +DockStack { + Margin="0"; + Spacing="0"; + AllowDrop = "true"; + AllowedDropTypes = "Crow.DockWindow"; + Focusable="true"; + //DragEnter="{Background=Blue}"; + //DragLeave="{Background=Transparent}"; + //EndDrag="{Background=Jet}"; +} valignStyle { Template="#ui.enumSingleSVG.itmp"; @@ -69,4 +79,4 @@ valignStyle2 { } smallLabel { Font="consolas, 8"; -}
\ No newline at end of file +} diff --git a/Samples/common/ui/icons/Crow.Docker.svg b/Samples/common/ui/icons/Crow.DockStack.svg index e38a283e..e38a283e 100644 --- a/Samples/common/ui/icons/Crow.Docker.svg +++ b/Samples/common/ui/icons/Crow.DockStack.svg diff --git a/Samples/common/ui/icons/Crow.DockWindow.svg b/Samples/common/ui/icons/Crow.DockWindow.svg new file mode 100644 index 00000000..74b0a24b --- /dev/null +++ b/Samples/common/ui/icons/Crow.DockWindow.svg @@ -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="#dddddd" d="M0 4v11h16v-14h-16v3zM14 2h1v1h-1v-1zM1 4h14v10h-14v-10z"></path> +</svg> diff --git a/Samples/dockableWindows/dockableWindows.cs b/Samples/dockableWindows/dockableWindows.cs index 27a9612a..8bf42a0b 100644 --- a/Samples/dockableWindows/dockableWindows.cs +++ b/Samples/dockableWindows/dockableWindows.cs @@ -17,31 +17,40 @@ namespace tests Colors.Blue, Colors.Red, Colors.Green, - Colors.Yellow, - Colors.Grey, - Colors.Onyx, + Colors.DarkOrchid, + Colors.DarkOrange, + Colors.DarkOliveGreen, Colors.Cyan, Colors.Chartreuse, }; + DockStack mainStack; protected override void OnInitialized () { Load ("#ui.test.crow").DataSource = this; - AddWidget (new DockWindow (this) { Background = Colors.Blue, Left = 10, Top = 110, Resizable = true }); - AddWidget (new DockWindow (this) { Background = Colors.Red, Left = 30, Top = 130, Resizable = true }); - AddWidget (new DockWindow (this) { Background = Colors.Green, Left = 50, Top = 150, Resizable = true }); - AddWidget (new DockWindow (this) { Background = Colors.Yellow, Left = 70, Top = 170, Resizable = true }); - AddWidget (new DockWindow (this) { Background = Colors.Grey, Left = 90, Top = 190, Resizable = true }); + mainStack = FindByName ("mainDock") as DockStack; + AddWidget (new DockWindow (this) { Background = Colors.Blue, Left = 10, Top = 110, Resizable = true, Caption = "win1" }); + AddWidget (new DockWindow (this) { Background = Colors.Red, Left = 30, Top = 130, Resizable = true, Caption = "win2" }); + AddWidget (new DockWindow (this) { Background = Colors.Green, Left = 50, Top = 150, Resizable = true, Caption = "win3" }); + AddWidget (new DockWindow (this) { Background = Colors.BurlyWood, Left = 70, Top = 170, Resizable = true, Caption = "win4" }); + AddWidget (new DockWindow (this) { Background = Colors.DarkOrchid, Left = 90, Top = 190, Resizable = true, Caption = "win5" }); } private void refreshGraphicTree (object sender, MouseButtonEventArgs e) { NotifyValueChanged ("GraphicTree", (object)null); NotifyValueChanged ("GraphicTree", GraphicTree); } int colorIdx = 0; + int nameIdx = 6; public override bool OnKeyDown (Key key) { if (colorIdx >= colors.Length) colorIdx = 0; switch (key) { case Key.F6: - AddWidget (new DockWindow (this) { Background = colors[colorIdx++], Left = 90, Top = 190, Resizable = true }); + AddWidget (new DockWindow (this) { Background = colors[colorIdx++], Left = 90, Top = 190, Resizable = true, Caption = $"win{nameIdx++}" }); + return true; + case Key.F2: + Configuration.Global.Set<string> ("WindowConfigTest", mainStack.ExportConfig()); + return true; + case Key.F3: + mainStack.ImportConfig (Configuration.Global.Get<string> ("WindowConfigTest")); return true; default: return base.OnKeyDown (key); diff --git a/Samples/dockableWindows/ui/TabView.template b/Samples/dockableWindows/ui/TabView.template new file mode 100644 index 00000000..9490aa7f --- /dev/null +++ b/Samples/dockableWindows/ui/TabView.template @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<VerticalStack Spacing="0" Background="{./Background}"> + <ListBox Data="{./Items}" Fit="true" HorizontalAlignment="Left" VerticalAlignment="Top" SelectedItem="{²./SelectedItem}"> + <Template> + <HorizontalStack Name="ItemsContainer" /> + </Template> + <ItemTemplate> + <!--<ListItem Fit="true" Background="Transparent" IsSelected="{IsVisible}" + Selected="{.DataSource.Visible='true'};{Background=.DataSource.Background}" + Unselected="{.DataSource.Visible='false'};{Background=Transparent}"> + <Label Text="{Caption}" Margin="5" /> + </ListItem>--> + <ListItem Fit="true" Background="Transparent" IsSelected="{IsVisible}" + Selected="{.DataSource.Visible='true'};{Background=.DataSource.Background}" + Unselected="{.DataSource.Visible='false'};{Background=Transparent}"> + <HorizontalStack Margin="2" > + <Label Text="{Caption}" Margin="3" /> + <Border CornerRadius="6" BorderWidth="1" Foreground="Transparent" Height="10" Width="10" VerticalAlignment="Center" + MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}"> + <Image Focusable="true" Name="Image" Margin="0" Width="Stretched" Height="Stretched" Path="#Crow.Icons.exit2.svg" + MouseClick="onQuitPress"/> + </Border> + </HorizontalStack> + </ListItem> + </ItemTemplate> + </ListBox> + <VerticalStack> + <Group Name="ItemsContainer" /> + <Label DataSource="{../../../SelectedItem}" Text="{Caption}" Background="White" Foreground="Black"/> + </VerticalStack> +</VerticalStack> + diff --git a/Samples/dockableWindows/ui/dock.style b/Samples/dockableWindows/ui/dock.style new file mode 100644 index 00000000..ef3f43e1 --- /dev/null +++ b/Samples/dockableWindows/ui/dock.style @@ -0,0 +1,12 @@ +DockStack { + Margin="0"; + Spacing="0"; + //Background="DimGrey"; +} +DockWindow { + Template="#ui.dockWin.template"; +} +TabView { + Template="#ui.TabView.template"; + //Background="Onyx"; +}
\ No newline at end of file diff --git a/Samples/dockableWindows/ui/dockWin.template b/Samples/dockableWindows/ui/dockWin.template new file mode 100644 index 00000000..c53b260c --- /dev/null +++ b/Samples/dockableWindows/ui/dockWin.template @@ -0,0 +1,24 @@ +<?xml version="1.0"?> +<Border Name="SizeHandle" BorderWidth="1" Foreground="Black" CornerRadius="{./CornerRadius}" StickyMouse="8" StickyMouseEnabled="{./IsFloating}" + Background="{./Background}"> + <VerticalStack Spacing="0"> + <HorizontalStack Height="Fit" IsVisible="{./IsDocked}" Background="Black"> + <Label Text="{./Caption}"/> + <Label Text="{./DockingPosition}"/> + </HorizontalStack> + <HorizontalStack Background="vgradient|0:0.5,0.6,0.5,0.5|1:0.2,0.3,0.3,0.7" + Name="hs" Margin="0" Spacing="0" Height="Fit" Visible="{./IsFloating}"> + <Widget Width="5"/> + <Image Margin="1" Width="10" Height="10" Path="{./Icon}"/> + <Label Text="{./Caption}"/> + <Label Width="Stretched" Foreground="White" Margin="1" TextAlignment="Left" Text="{./DockingPosition}" /> + <Border CornerRadius="6" BorderWidth="1" Foreground="Transparent" Height="10" Width="10" + MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}"> + <Image Focusable="true" Name="Image" Margin="0" Path="#Crow.Icons.exit2.svg" + MouseClick="./onQuitPress"/> + </Border> + <Widget Width="5"/> + </HorizontalStack> + <Container Name="Content" MinimumSize="50,50"/> + </VerticalStack> +</Border> diff --git a/Samples/dockableWindows/ui/test.crow b/Samples/dockableWindows/ui/test.crow index f576fbbd..1e4e81e4 100644 --- a/Samples/dockableWindows/ui/test.crow +++ b/Samples/dockableWindows/ui/test.crow @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<VerticalStack> +<VerticalStack Background="DimGrey"> <VerticalStack Name="Watches" Background="Black" Height="Fit" Width="Stretched"> <HorizontalStack Height="Fit"> <Label Style="smallLabel" Text="hover:" Width="50"/> @@ -14,11 +14,11 @@ <Label Style="smallLabel" Text="{ActiveWidget}"/> </HorizontalStack> </VerticalStack> - <Label Text="Press 'F6' to add new windows"/> - <DockStack Name="mainDock" Height="Stretched"/> + <Label Text="Press 'F6' to add new windows, 'F2'/'F3' for save/restore"/> + <DockStack Name="mainDock" Height="Stretched" /> <!--<Splitter/> <Button Caption="Refresh tree" MouseClick="refreshGraphicTree"/> - <TreeView IsRoot="true" Name="treeView" Data="{GraphicTree}"> + <TreeView IsRoot="true" Name="treeView" Data="{GraphicTree}" Height="200"> <ItemTemplate> <Border Width="Stretched" Focusable="true" Foreground="Transparent"> <HorizontalStack Spacing="5"> @@ -28,6 +28,7 @@ </Border> <Widget Width="2" Height="5" Background="Blue" Visible="{IsHover}"/> <Widget Width="5" Height="5" Background="Green" Visible="{Visible}"/> + <Label Text="{Caption}" Width="Fit"/> <Label Text="{Name}" Width="Fit"/> <Label Text="{LogicalParent}" Width="Stretched" Foreground="Yellow"/> </HorizontalStack> @@ -41,5 +42,5 @@ Path="#ui.GTreeExp.itemp"/> <ItemTemplate DataType="Crow.TemplatedGroup" Data="GetChildren" Path="#ui.GTreeExp.itemp"/> - </TreeView> --> + </TreeView>--> </VerticalStack> diff --git a/Samples/dragNdrop/dragNdrop.cs b/Samples/dragNdrop/dragNdrop.cs index 281cfe19..89785c82 100644 --- a/Samples/dragNdrop/dragNdrop.cs +++ b/Samples/dragNdrop/dragNdrop.cs @@ -25,16 +25,16 @@ namespace tests private void W_StartDrag (object sender, DragDropEventArgs e) { + Rectangle r = e.DragSource.LastPaintedSlot; startGroup = e.DragSource.Parent as Group; - DragImageHeight = e.DragSource.LastPaintedSlot.Height; - DragImageWidth = e.DragSource.LastPaintedSlot.Width; - Crow.Cairo.Surface dragImg = surf.CreateSimilar (Crow.Cairo.Content.ColorAlpha, DragImageWidth, DragImageHeight); + Crow.Cairo.Surface dragImg = surf.CreateSimilar (Crow.Cairo.Content.ColorAlpha, + r.Width, r.Height); using (Crow.Cairo.Context gr = new Crow.Cairo.Context(dragImg)) { gr.SetSource (e.DragSource.bmp, 0, 0); gr.Paint (); } - DragImage = dragImg; + CreateDragImage (dragImg) /*lock (UpdateMutex) startGroup.RemoveChild (e.DragSource);*/ } |