diff options
64 files changed, 696 insertions, 352 deletions
diff --git a/Crow/Crow.csproj b/Crow/Crow.csproj index d5912c8a..2771f658 100644 --- a/Crow/Crow.csproj +++ b/Crow/Crow.csproj @@ -2,7 +2,7 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <!-- <TargetFrameworks>netstandard2.0</TargetFrameworks>--> - <TargetFramework>netstandard2.1</TargetFramework> + <TargetFramework>netcoreapp3.0</TargetFramework> <AssemblyVersion>$(CrowVersion)</AssemblyVersion> <PackageVersion>$(CrowPackageVersion)</PackageVersion> diff --git a/Crow/Templates/DockWindow.template b/Crow/Templates/DockWindow.template index 9e8e623a..f54974fb 100644 --- a/Crow/Templates/DockWindow.template +++ b/Crow/Templates/DockWindow.template @@ -20,7 +20,7 @@ </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"/> + <Widget Width="5"/> <Image Margin="1" Width="10" Height="10" Path="{./Icon}"/> <Label Width="Stretched" Foreground="White" Margin="1" TextAlignment="Left" Text="{./CurDir}" /> <ListBox Data="{./DockCommands}" Fit="true"> diff --git a/Crow/Templates/FileDialog.template b/Crow/Templates/FileDialog.template index 71ed5c2b..04c4b39c 100644 --- a/Crow/Templates/FileDialog.template +++ b/Crow/Templates/FileDialog.template @@ -28,14 +28,14 @@ SelectedItemChanged="./onSelectedItemChanged"> <Template> <HorizontalStack> - <Scroller Name="scroller1"> + <Scroller Name="ItemsScroller" KeyEventsOverrides="true" > <VerticalStack Height="Fit" VerticalAlignment="Top" Name="ItemsContainer" Margin="0" Spacing="1"/> </Scroller> <ScrollBar Name="scrollbar1" Orientation="Vertical" - Value="{²../scroller1.ScrollY}" Maximum="{../scroller1.MaxScrollY}" - CursorRatio="{../scroller1.ChildHeightRatio}" - LargeIncrement="{../scroller1.PageHeight}" SmallIncrement="30" + Value="{²../ItemsScroller.ScrollY}" Maximum="{../ItemsScroller.MaxScrollY}" + CursorRatio="{../ItemsScroller.ChildHeightRatio}" + LargeIncrement="{../ItemsScroller.PageHeight}" SmallIncrement="30" Width="14" /> </HorizontalStack> </Template> diff --git a/Crow/Templates/FileItems.template b/Crow/Templates/FileItems.template index 2fad3384..d9f529d3 100644 --- a/Crow/Templates/FileItems.template +++ b/Crow/Templates/FileItems.template @@ -3,6 +3,7 @@ </ItemTemplate> <ItemTemplate DataType="System.IO.FileInfo"> <ListItem Height="Fit" + BubbleEvents="All" Selected = "{Background=${ControlHighlight}}" Unselected = "{Background=Transparent}"> <HorizontalStack> @@ -13,6 +14,7 @@ </ItemTemplate> <ItemTemplate DataType="System.IO.DirectoryInfo"> <ListItem Height="Fit" + BubbleEvents="All" Selected = "{Background=${ControlHighlight}}" Unselected = "{Background=Transparent}"> <HorizontalStack> diff --git a/Crow/src/2d/Rectangle.cs b/Crow/src/2d/Rectangle.cs index a0e5ccf8..278decb5 100644 --- a/Crow/src/2d/Rectangle.cs +++ b/Crow/src/2d/Rectangle.cs @@ -7,7 +7,7 @@ using System.Runtime.InteropServices; namespace Crow { [StructLayout(LayoutKind.Sequential)] public struct Rectangle - { + { public static readonly Rectangle Zero = new Rectangle (0, 0, 0, 0); public int X, Y, Width, Height; @@ -15,34 +15,34 @@ namespace Crow { #region ctor public Rectangle(Point p, Size s): this (p.X, p.Y, s.Width, s.Height) { } public Rectangle(Size s) : this (0, 0, s.Width, s.Height) { } - public Rectangle(int x, int y, int width, int height) { + public Rectangle(int x, int y, int width, int height) { X = x; Y = y; Width = width; Height = height; - } + } #endregion #region PROPERTIES [XmlIgnore]public int Left{ get => X; - set { X = value; } - } + set { X = value; } + } [XmlIgnore]public int Top{ - get => Y; - set { Y = value; } - } + get => Y; + set { Y = value; } + } [XmlIgnore] public int Right => X + Width; [XmlIgnore]public int Bottom => Y + Height; [XmlIgnore]public Size Size{ get => new Size (Width, Height); - set { - Width = value.Width; - Height = value.Height; - } - } + set { + Width = value.Width; + Height = value.Height; + } + } [XmlIgnore] - public SizeD SizeD => new SizeD (Width, Height); + public SizeD SizeD => new SizeD (Width, Height); [XmlIgnore]public Point Position{ get => new Point (X, Y); set { @@ -53,13 +53,13 @@ namespace Crow { [XmlIgnore]public Point TopLeft{ get => new Point (X, Y); set { - X = value.X; - Y = value.Y; - } - } + X = value.X; + Y = value.Y; + } + } [XmlIgnore] public Point TopRight => new Point (Right, Y); [XmlIgnore] public Point BottomLeft => new Point (X, Bottom); - [XmlIgnore] public Point BottomRight => new Point (Right, Bottom); + [XmlIgnore] public Point BottomRight => new Point (Right, Bottom); [XmlIgnore] public Point Center => new Point (Left + Width / 2, Top + Height / 2); [XmlIgnore] public Point CenterD => new PointD (Left + Width / 2.0, Top + Height / 2.0); @@ -67,12 +67,12 @@ namespace Crow { #region FUNCTIONS public void Inflate(int xDelta, int yDelta) - { - this.X -= xDelta; - this.Width += 2 * xDelta; - this.Y -= yDelta; - this.Height += 2 * yDelta; - } + { + this.X -= xDelta; + this.Width += 2 * xDelta; + this.Y -= yDelta; + this.Height += 2 * yDelta; + } public void Inflate(int delta) { Inflate (delta, delta); @@ -83,54 +83,74 @@ namespace Crow { r.Inflate (deltaX, deltaY); return r; } + public void Scale (double factor) { + X = (int)Math.Round(factor * X); + Y = (int)Math.Round(factor * Y); + Width = (int)Math.Round(factor * Width); + Height = (int)Math.Round(factor * Height); + } + public Rectangle Scaled (double factor) { + return new Rectangle ( + (int)Math.Round(factor * X), + (int)Math.Round(factor * Y), + (int)Math.Round(factor * Width), + (int)Math.Round(factor * Height)); + } + public RectangleD ScaledD (double factor) { + return new RectangleD ( + factor * X, + factor * Y, + factor * Width, + factor * Height); + } public bool ContainsOrIsEqual (Point p) => (p.X >= X && p.X <= X + Width && p.Y >= Y && p.Y <= Y + Height); public bool ContainsOrIsEqual (Rectangle r) => r.TopLeft >= this.TopLeft && r.BottomRight <= this.BottomRight; - public bool Intersect(Rectangle r) - { - int maxLeft = Math.Max(this.Left, r.Left); - int minRight = Math.Min(this.Right, r.Right); - int maxTop = Math.Max(this.Top, r.Top); - int minBottom = Math.Min(this.Bottom, r.Bottom); + public bool Intersect(Rectangle r) + { + int maxLeft = Math.Max(this.Left, r.Left); + int minRight = Math.Min(this.Right, r.Right); + int maxTop = Math.Max(this.Top, r.Top); + int minBottom = Math.Min(this.Bottom, r.Bottom); return (maxLeft < minRight) && (maxTop < minBottom); - } - public Rectangle Intersection(Rectangle r) - { - Rectangle result = new Rectangle(); - - if (r.Left >= Left) - result.Left = r.Left; - else - result.TopLeft = TopLeft; + } + public Rectangle Intersection(Rectangle r) + { + Rectangle result = new Rectangle(); - if (r.Right >= Right) - result.Width = Right - result.Left; - else - result.Width = r.Right - result.Left; + if (r.Left >= Left) + result.Left = r.Left; + else + result.TopLeft = TopLeft; - if (r.Top >= Top) - result.Top = r.Top; - else - result.Top = Top; + if (r.Right >= Right) + result.Width = Right - result.Left; + else + result.Width = r.Right - result.Left; - if (r.Bottom >= Bottom) - result.Height = Bottom - result.Top; - else - result.Height = r.Bottom - result.Top; + if (r.Top >= Top) + result.Top = r.Top; + else + result.Top = Top; - return result; - } + if (r.Bottom >= Bottom) + result.Height = Bottom - result.Top; + else + result.Height = r.Bottom - result.Top; + + return result; + } #endregion - #region operators - public static Rectangle operator +(Rectangle r1, Rectangle r2) - { - int x = Math.Min(r1.X, r2.X); - int y = Math.Min(r1.Y, r2.Y); - int x2 = Math.Max(r1.Right, r2.Right); - int y2 = Math.Max(r1.Bottom, r2.Bottom); - return new Rectangle(x, y, x2 - x, y2 - y); - } + #region operators + public static Rectangle operator +(Rectangle r1, Rectangle r2) + { + int x = Math.Min(r1.X, r2.X); + int y = Math.Min(r1.Y, r2.Y); + int x2 = Math.Max(r1.Right, r2.Right); + int y2 = Math.Max(r1.Bottom, r2.Bottom); + return new Rectangle(x, y, x2 - x, y2 - y); + } public static Rectangle operator + (Rectangle r, Point p) => new Rectangle (r.X + p.X, r.Y + p.Y, r.Width, r.Height); public static Rectangle operator - (Rectangle r, Point p) => new Rectangle (r.X - p.X, r.Y - p.Y, r.Width, r.Height); public static bool operator == (Rectangle r1, Rectangle r2) => r1.TopLeft == r2.TopLeft && r1.Size == r2.Size; @@ -140,16 +160,16 @@ namespace Crow { (int)Math.Round (r.Width), (int)Math.Round (r.Height)); #endregion - public override string ToString () => $"{X},{Y},{Width},{Height}"; - public static Rectangle Parse(string s) - { - string[] d = s.Split(new char[] { ',' }); - return new Rectangle( - int.Parse(d[0]), - int.Parse(d[1]), - int.Parse(d[2]), - int.Parse(d[3])); - } + public override string ToString () => $"{X},{Y},{Width},{Height}"; + public static Rectangle Parse(string s) + { + string[] d = s.Split(new char[] { ',' }); + return new Rectangle( + int.Parse(d[0]), + int.Parse(d[1]), + int.Parse(d[2]), + int.Parse(d[3])); + } public override int GetHashCode () { unchecked // Overflow is fine, just wrap @@ -165,5 +185,5 @@ namespace Crow { } public override bool Equals (object obj) => (obj == null || obj.GetType () != typeof (Rectangle)) ? false : this == (Rectangle)obj; - } + } } diff --git a/Crow/src/Configuration.cs b/Crow/src/Configuration.cs index 5b99761d..f3dadd18 100644 --- a/Crow/src/Configuration.cs +++ b/Crow/src/Configuration.cs @@ -135,7 +135,7 @@ namespace Crow void savingThread(){ while(true){ if (isDirty) - Save (); + Save (); Thread.Sleep (100); } } diff --git a/Crow/src/CrowThread.cs b/Crow/src/CrowThread.cs index 01558753..7d894168 100644 --- a/Crow/src/CrowThread.cs +++ b/Crow/src/CrowThread.cs @@ -33,7 +33,7 @@ namespace Crow public void Cancel(){ if (thread.IsAlive & !cancelRequested){ cancelRequested = true; - while (thread.IsAlive) + while (thread.IsAlive) Thread.Sleep (1); thread.Join (); } diff --git a/Crow/src/IML/BindingMember.cs b/Crow/src/IML/BindingMember.cs index 2f96f131..f0b00ef3 100644 --- a/Crow/src/IML/BindingMember.cs +++ b/Crow/src/IML/BindingMember.cs @@ -36,7 +36,7 @@ namespace Crow.IML /// - '../' => 1 level up in graphic tree /// - './' or '/' => template root level /// - '.Name1.Name2' current level properties - /// - 'name.prop' named descendant in graphic tree, search with 'FindByName' method of GraphicObject + /// - 'name.prop' named descendant in graphic tree, search with 'FindByName' method of Widget /// </summary> public class BindingMember { diff --git a/Crow/src/IML/CompilerServices.cs b/Crow/src/IML/CompilerServices.cs index 3888ceaf..ba6e2935 100644 --- a/Crow/src/IML/CompilerServices.cs +++ b/Crow/src/IML/CompilerServices.cs @@ -280,7 +280,7 @@ namespace Crow.IML #if DEBUG_BINDING_FUNC_CALLS Console.WriteLine ($"getMemberInfoWithReflexion ({instance},{member}); type:{t}"); #endif - MemberInfo mi = t.GetMember (member)?.FirstOrDefault(); + MemberInfo mi = t.GetMember (member, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)?.FirstOrDefault(); if (mi == null) mi = CompilerServices.SearchExtMethod (t, member); return mi; @@ -507,7 +507,7 @@ namespace Crow.IML emitGetChild (il, dest [i].CrowType, dest [i + 1].Index); } /// <summary> - /// Emits msil to fetch chil instance of current GraphicObject on the stack + /// Emits msil to fetch chil instance of current Widget on the stack /// </summary> /// <param name="il">Il generator</param> /// <param name="parentType">Parent type</param> @@ -879,12 +879,16 @@ namespace Crow.IML return dataType; } foreach (Assembly a in Interface.crowAssemblies) { - foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name != strDataType && expT.FullName != strDataType) - continue; - if (!knownTypes.ContainsKey(strDataType)) - knownTypes.Add (strDataType, expT); - return expT; + try { + foreach (Type expT in a.GetExportedTypes ()) { + if (expT.Name != strDataType && expT.FullName != strDataType) + continue; + if (!knownTypes.ContainsKey(strDataType)) + knownTypes.Add (strDataType, expT); + return expT; + } + }catch (Exception e) { + Debug.WriteLine ($"Crow.getTypeFromeName error: {e.Message}"); } } knownTypes.Add (strDataType, null); diff --git a/Crow/src/IML/IMLContext.cs b/Crow/src/IML/IMLContext.cs index a69f7b2d..16ace24e 100644 --- a/Crow/src/IML/IMLContext.cs +++ b/Crow/src/IML/IMLContext.cs @@ -47,7 +47,7 @@ namespace Crow.IML il.DeclareLocal (typeof (Widget)); il.Emit (OpCodes.Nop); - //set local GraphicObject to root object + //set local Widget to root object ConstructorInfo ci = rootType.GetConstructor ( BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, null, Type.EmptyTypes, null); diff --git a/Crow/src/IML/Instantiator.cs b/Crow/src/IML/Instantiator.cs index 2acace29..e338e714 100644 --- a/Crow/src/IML/Instantiator.cs +++ b/Crow/src/IML/Instantiator.cs @@ -41,9 +41,7 @@ namespace Crow.IML { { #region Dynamic Method ID generation static long curId = 0; - internal static long NewId { - get { return curId++; } - } + internal static long NewId => curId++; #endregion internal static Dictionary<string, Type> knownGOTypes = new Dictionary<string, Type> (); @@ -141,7 +139,7 @@ namespace Crow.IML { #endregion /// <summary> - /// Creates a new instance of the GraphicObject compiled in the instantiator + /// Creates a new instance of the Widget compiled in the instantiator /// </summary> /// <returns>The new graphic object instance</returns> public Widget CreateInstance(){ @@ -205,7 +203,7 @@ namespace Crow.IML { loader = (InstanciatorInvoker)ctx.dm.CreateDelegate (typeof (InstanciatorInvoker), this); } /// <summary> - /// read first node to set GraphicObject class for loading + /// read first node to set Widget class for loading /// and let reader position on that node /// </summary> Type findRootType (XmlReader reader) @@ -1500,7 +1498,12 @@ namespace Crow.IML { il.Emit (OpCodes.Stfld, mi as FieldInfo); else if (mi.MemberType == MemberTypes.Property) { MethodInfo mt = (mi as PropertyInfo).GetSetMethod (); - il.Emit (mt.IsVirtual?OpCodes.Callvirt:OpCodes.Call, mt); + if (mt == null) { + Console.WriteLine ($"[emitSetValue]No set method found for: {mi}"); + il.Emit (OpCodes.Pop);//pop value + il.Emit (OpCodes.Pop);//pop set target instance + } else + il.Emit (mt.IsVirtual?OpCodes.Callvirt:OpCodes.Call, mt); } else throw new NotImplementedException (); } diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index 0901b9bc..d0431985 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -89,9 +89,26 @@ namespace Crow } } + static IntPtr resolveUnmanaged(Assembly assembly, String libraryName) + { + + switch (libraryName) + { + /*case "glfw3": + return NativeLibrary.Load("glfw", assembly, null);*/ + case "rsvg-2.40": + return NativeLibrary.Load("rsvg-2", assembly, null); + } + Console.WriteLine($"[UNRESOLVE] {assembly} {libraryName}"); + return IntPtr.Zero; + } + + #region CTOR static Interface () { + System.Runtime.Loader.AssemblyLoadContext.GetLoadContext(Assembly.GetExecutingAssembly()).ResolvingUnmanagedDll += resolveUnmanaged; + CROW_CONFIG_ROOT = System.IO.Path.Combine ( Environment.GetFolderPath (Environment.SpecialFolder.UserProfile), @@ -426,7 +443,7 @@ namespace Crow #region events delegates static CursorPosDelegate HandleCursorPosDelegate = (window, xPosition, yPosition) => { - windows [window].OnMouseMove ((int)xPosition, (int)yPosition); + windows [window].OnMouseMove ((int)(xPosition / windows [window].ZoomFactor), (int)(yPosition / windows [window].ZoomFactor)); }; static MouseButtonDelegate HandleMouseButtonDelegate = (IntPtr window, MouseButton button, InputAction action, Modifier mods) => { if (action == InputAction.Release) @@ -634,8 +651,8 @@ namespace Crow public static Antialias Antialias = Antialias.Subpixel; /// <summary> - /// Each control need a ref to the root interface containing it, if not set in GraphicObject.currentInterface, - /// the ref of this one will be stored in GraphicObject.currentInterface + /// Each control need a ref to the root interface containing it, if not set in Widget.currentInterface, + /// the ref of this one will be stored in Widget.currentInterface /// </summary> //protected static Interface CurrentInterface; #endregion @@ -972,7 +989,7 @@ namespace Crow return Instantiator.CreateFromImlFragment (this, imlFragment); } /// <summary> - /// Create an instance of a GraphicObject and add it to the GraphicTree of this Interface + /// Create an instance of a Widget and add it to the GraphicTree of this Interface /// </summary> /// <returns>new instance of graphic object created</returns> /// <param name="path">path of the iml file to load</param> @@ -1001,7 +1018,7 @@ namespace Crow } } /// <summary> - /// Create an instance of a GraphicObject linked to this interface but not added to the GraphicTree + /// Create an instance of a Widget linked to this interface but not added to the GraphicTree /// </summary> /// <returns>new instance of graphic object created</returns> /// <param name="path">path of the iml file to load</param> @@ -1273,7 +1290,21 @@ namespace Crow Debug.WriteLine ("SolidBackground property only available on unix."); } } - + double zoomFactor = 1.0; + public double ZoomFactor { + get => zoomFactor; + set { + if (zoomFactor == value) + return; + zoomFactor = value; + NotifyValueChanged (zoomFactor); + lock (UpdateMutex) { + foreach (Widget g in GraphicTree) + g.RegisterForLayouting (LayoutingType.All); + registerRefreshClientRectangle (); + } + } + } /// <summary>Clipping Rectangles drive the drawing process. For compositing, each object under a clip rectangle should be /// repainted. If it contains also clip rectangles, its cache will be update, or if not cached a full redraw will take place</summary> @@ -1282,6 +1313,8 @@ namespace Crow PerformanceMeasure.Begin (PerformanceMeasure.Kind.Drawing); if (!clipping.IsEmpty) { + ctx.Scale (zoomFactor,zoomFactor); + #if VKVG clear (ctx); #else @@ -1692,7 +1725,7 @@ namespace Crow /// Ask OS to force the mouse position to the actual coordinate of Interface.MousePosition /// </summary> public virtual void ForceMousePosition () { - Glfw3.SetCursorPosition (hWin, MousePosition.X, MousePosition.Y); + Glfw3.SetCursorPosition (hWin, MousePosition.X * ZoomFactor, MousePosition.Y * ZoomFactor); } /// <summary>Processes mouse move events from the root container, this function @@ -2169,8 +2202,8 @@ namespace Crow set { throw new NotImplementedException (); } } - public Rectangle ClientRectangle => clientRectangle; - public Rectangle GetClientRectangleForChild (ILayoutable child) => clientRectangle; + public Rectangle ClientRectangle => clientRectangle.Scaled (1.0/zoomFactor); + public Rectangle GetClientRectangleForChild (ILayoutable child) => ClientRectangle; public Interface HostContainer => this; public Rectangle getSlot () => ClientRectangle; diff --git a/Crow/src/Text/SpanCharReader.cs b/Crow/src/Text/SpanCharReader.cs index 5b206575..ae55d64f 100644 --- a/Crow/src/Text/SpanCharReader.cs +++ b/Crow/src/Text/SpanCharReader.cs @@ -144,5 +144,12 @@ namespace Crow.Text (Peak == '\xD' && (buffer [curPos + 1] == '\xA' || buffer [curPos + 1] == '\x85')); } + /// <summary> + /// next char sequence has already been tested as eol, advance 1 or two char depending on eol format. + /// </summary> + public void ReadEol () { + if (Read () == '\xD') + Advance(); + } } } diff --git a/Crow/src/Text/TextChange.cs b/Crow/src/Text/TextChange.cs index 75948da8..6aae62b1 100644 --- a/Crow/src/Text/TextChange.cs +++ b/Crow/src/Text/TextChange.cs @@ -14,8 +14,9 @@ namespace Crow.Text public readonly string ChangedText; public int End => Start + Length; + public int End2 => Start + (string.IsNullOrEmpty (ChangedText) ? 0 : CharDiff); - public int CharDiff => ChangedText.Length - Length; + public int CharDiff => string.IsNullOrEmpty (ChangedText) ? - Length : ChangedText.Length - Length; public TextChange (int position, int length, string changedText) { Start = position; Length = length; diff --git a/Crow/src/Text/TextSpan.cs b/Crow/src/Text/TextSpan.cs index 929d5054..83fbc68d 100644 --- a/Crow/src/Text/TextSpan.cs +++ b/Crow/src/Text/TextSpan.cs @@ -33,5 +33,7 @@ namespace Crow.Text public override string ToString() => $"{Start},{End}"; public bool Contains (int absolutePosition) => absolutePosition >= Start && absolutePosition < End; + public bool Contains (TextSpan span) + => Start <= span.Start && End >= span.End; } } diff --git a/Crow/src/Widgets/Border.cs b/Crow/src/Widgets/Border.cs index 47358100..1957498f 100644 --- a/Crow/src/Widgets/Border.cs +++ b/Crow/src/Widgets/Border.cs @@ -86,7 +86,7 @@ namespace Crow } #endregion - #region GraphicObject override + #region Widget override /*[XmlIgnore]public override Rectangle ClientRectangle { get { Rectangle cb = base.ClientRectangle; diff --git a/Crow/src/Widgets/Button.cs b/Crow/src/Widgets/Button.cs index a6b57687..cdd9c590 100644 --- a/Crow/src/Widgets/Button.cs +++ b/Crow/src/Widgets/Button.cs @@ -24,7 +24,7 @@ namespace Crow public event EventHandler Pressed; public event EventHandler Released; - #region GraphicObject Overrides + #region Widget Overrides public override void onMouseDown (object sender, MouseButtonEventArgs e) { IsPressed = true; diff --git a/Crow/src/Widgets/DirectoryView.cs b/Crow/src/Widgets/DirectoryView.cs index 89f388d1..1d6f005f 100644 --- a/Crow/src/Widgets/DirectoryView.cs +++ b/Crow/src/Widgets/DirectoryView.cs @@ -33,7 +33,7 @@ namespace Crow get { return _selectedItem; } - set { + set { if (value == _selectedItem) return; _selectedItem = value; diff --git a/Crow/src/Widgets/DirectoryView2.cs b/Crow/src/Widgets/DirectoryView2.cs index 174708d4..3a966447 100644 --- a/Crow/src/Widgets/DirectoryView2.cs +++ b/Crow/src/Widgets/DirectoryView2.cs @@ -97,7 +97,7 @@ namespace Crow currentDirectory = value; NotifyValueChangedAuto (currentDirectory); NotifyValueChanged ("FileSystemEntries", FileSystemEntries); - updateFileSystemEntries(); + Data = FileSystemEntries; } } [XmlIgnore]public FileSystemInfo[] FileSystemEntries { @@ -120,38 +120,148 @@ namespace Crow } //set template and itemTemplates depending on view configuration void updateItemTemplates () { - return; - ItemTemplate = fileItemTemplates; + lock (IFace.UpdateMutex) { + Template = dvTemplate; + switch (ViewStyle) { + case DirectoryViewStyle.Icons: + ItemTemplate = iconViewItmp; + break; + case DirectoryViewStyle.Detailed: + ItemTemplate = detailedViewITmp; + break; + case DirectoryViewStyle.Compact: + ItemTemplate = compactViewITmp; + break; + } + } + RegisterForGraphicUpdate(); } - void updateFileSystemEntries () { - + /// <summary> + /// Default template in DirectoryView is set depending on 'ViewStyle' + /// </summary> + /// <param name="template"></param> + protected override void loadTemplate (Widget template = null) + { + if (template == null) + base.loadTemplate (IFace.CreateITorFromIMLFragment (dvTemplate).CreateInstance()); + else + base.loadTemplate (template); } - string fileItemTemplates => @" - + string compactViewITmp => $@" <ItemTemplate DataType='System.IO.FileInfo'> <ListItem Fit='true' BubbleEvents='All' - Selected = '{Background=${ControlHighlight}}' - Unselected = '{Background=Transparent}'> - <HorizontalStack> - <Image Margin='2' Width='ICON_SIZE' Height='ICON_SIZE' Path='${FileIcon}'/> - <Label Text='{Name}' /> + Selected = '{{Background=${{ControlHighlight}}}}' + Unselected = '{{Background=Transparent}}'> + <HorizontalStack Margin='1' > + <Image Width='20' Height='20' Path='${{FileIcon}}'/> + <Label Text='{{Name}}' /> </HorizontalStack> </ListItem> </ItemTemplate> <ItemTemplate DataType='System.IO.DirectoryInfo'> <ListItem Fit='true' BubbleEvents='All' - Selected = '{Background=${ControlHighlight}}' - Unselected = '{Background=Transparent}'> - <HorizontalStack> - <Image Margin='2' Width='ICON_SIZE' Height='ICON_SIZE' Path='${FolderIcon}'/> - <Label Text='{Name}' /> - <!--<Label Text='{LastAccessTime}' />--> + Selected = '{{Background=${{ControlHighlight}}}}' + Unselected = '{{Background=Transparent}}'> + <HorizontalStack Margin='1' > + <Image Width='20' Height='20' Path='${{FolderIcon}}'/> + <Label Text='{{Name}}' /> + <!--<Label Text='{{LastAccessTime}}' />--> </HorizontalStack> </ListItem> </ItemTemplate> -".Replace ("ICON_SIZE", iconSize.ToString()); +"; + string iconViewItmp => $@" +<ItemTemplate DataType='System.IO.FileInfo'> + <ListItem Width='70' Height='60' + BubbleEvents='All' + Selected = '{{Background=${{ControlHighlight}}}}' + Unselected = '{{Background=Transparent}}'> + <VerticalStack> + <Image Margin='8' Width='Fit' Height='Stretched' Path='${{FileIcon}}' Scaled='true'/> + <Label Text='{{Name}}' Background='Jet' Width='Stretched' TextAlignment='Center' Multiline='true' Font='sans,9' /> + </VerticalStack> + </ListItem> +</ItemTemplate> +<ItemTemplate DataType='System.IO.DirectoryInfo'> + <ListItem Width='90' Height='60' + BubbleEvents='All' + Selected = '{{Background=${{ControlHighlight}}}}' + Unselected = '{{Background=Transparent}}'> + <VerticalStack> + <Image Margin='0' Width='Fit' Height='Stretched' Path='${{FolderIcon}}' Scaled='true'/> + <Label Text='{{Name}}' Background='Jet' Width='Stretched' TextAlignment='Center' Multiline='true' Font='sans,9' /> + </VerticalStack> + </ListItem> +</ItemTemplate> +"; + string detailedViewITmp => $@" +<ItemTemplate DataType='System.IO.DirectoryInfo'> + <TableRow Width='Stretched' Height='Fit' Focusable='true' + BubbleEvents='All' Tooltip='{{Name}}' + Selected='{{Background=${{ControlHighlight}}}}' + Unselected='{{Background=Transparent}}'> + <Image Width='Stretched' Height='Stretched' Path='${{FolderIcon}}' Margin='0' /> + <Label Text='{{Name}}' Width='Fit' Font='sans,11' Margin='3'/> + <Label Text='' Font='sans,9'/> + <Label Text='{{LastAccessTime}}' Font='sans,9'/> + </TableRow> +</ItemTemplate> +<ItemTemplate DataType='System.IO.FileInfo'> + <TableRow Width='Stretched' Height='Fit' Focusable='true' + BubbleEvents='All' Tooltip='{{Name}}' + Selected='{{Background=${{ControlHighlight}}}}' + Unselected='{{Background=Transparent}}'> + <Image Width='Stretched' Height='Stretched' Path='${{FileIcon}}' Margin='2' /> + <Label Text='{{Name}}' Width='Fit' Font='sans,11' Margin='3'/> + <Label Text='{{Length}}' Font='sans,9' TextAlignment='Right'/> + <Label Text='{{LastAccessTime}}' Font='sans,9'/> + </TableRow> +</ItemTemplate> +"; + +string dvTemplate => ViewStyle == DirectoryViewStyle.Compact ? +$@" +<VerticalStack Margin='5'> + <Scroller Name='scroller1'> + <Wrapper Orientation='Horizontal' Height='Stretched' Width='Fit' HorizontalAlignment='Left' + Name='ItemsContainer' Margin='0' Spacing='2'/> + </Scroller> + <ScrollBar Style='HScrollBar' + Value='{{²../scroller1.ScrollX}}' Maximum='{{../scroller1.MaxScrollX}}' + CursorRatio='{{../scroller1.ChildWidthRatio}}' + LargeIncrement='{{../scroller1.PageWidth}}' SmallIncrement='30' /> +</VerticalStack> +" +: ViewStyle == DirectoryViewStyle.Detailed ? +$@" +<HorizontalStack Margin='5'> + <Scroller Name='scroller1'> + <Table Columns=',20;Name,Stretched;Size,100;Accessed,Fit' Height='Fit' Width='Stretched' VerticalAlignment='Top' + Name='ItemsContainer' Margin='0' Spacing='0' RowsMargin='0' ColumnSpacing='10' + HorizontalLineWidth='0' VerticalLineWidth='1' /> + </Scroller> + <ScrollBar + Value='{{²../scroller1.ScrollY}}' Maximum='{{../scroller1.MaxScrollY}}' + CursorRatio='{{../scroller1.ChildHeightRatio}}' + LargeIncrement='{{../scroller1.PageHeight}}' SmallIncrement='30'/> +</HorizontalStack> +" +: +$@" +<HorizontalStack Margin='5'> + <Scroller Name='scroller1'> + <Wrapper Orientation='Vertical' Height='Fit' VerticalAlignment='Top' + Name='ItemsContainer' Margin='0' Spacing='2'/> + </Scroller> + <ScrollBar + Value='{{²../scroller1.ScrollY}}' Maximum='{{../scroller1.MaxScrollY}}' + CursorRatio='{{../scroller1.ChildHeightRatio}}' + LargeIncrement='{{../scroller1.PageHeight}}' SmallIncrement='30'/> +</HorizontalStack> +" +; } } diff --git a/Crow/src/Widgets/DockStack.cs b/Crow/src/Widgets/DockStack.cs index 3d70a84e..d75df567 100644 --- a/Crow/src/Widgets/DockStack.cs +++ b/Crow/src/Widgets/DockStack.cs @@ -9,7 +9,7 @@ namespace Crow { [DesignIgnore] public class DockStack : GenericStack - { + { #region CTor public DockStack () {} public DockStack (Interface iface, string style = null) : base (iface, style) { } @@ -37,7 +37,7 @@ namespace Crow } /*public override bool PointIsIn (ref Point m) - { + { if (!base.PointIsIn(ref m)) return false; @@ -65,7 +65,7 @@ namespace Crow // base.OnLayoutChanges (layoutType); // // if ((layoutType & LayoutingType.Sizing) > 0) -// computeRects(); +// computeRects(); // } Rectangle rIn = default(Rectangle); @@ -95,7 +95,7 @@ namespace Crow public void onDragMouseMove (object sender, MouseMoveEventArgs e) { - //if (IsDropTarget) { + //if (IsDropTarget) { DockWindow dw = IFace.DragAndDropOperation.DragSource as DockWindow; if (dw == null || dw.IsDocked) { base.onMouseMove (sender, e); @@ -121,14 +121,14 @@ namespace Crow if (lm.X < cb.Left + cb.Width / dockWidthDivisor) dw.DockingPosition = Alignment.Left; else if (lm.X > cb.Right - cb.Width / dockWidthDivisor) - dw.DockingPosition = Alignment.Right; + dw.DockingPosition = Alignment.Right; } else { getFocusedChild (lm); if (focusedChild != null) { if (lm.Y < rIn.Top + rIn.Height / dockWidthDivisor) dw.DockingPosition = Alignment.Top; else if (lm.Y > rIn.Bottom - rIn.Height / dockWidthDivisor) - dw.DockingPosition = Alignment.Bottom; + dw.DockingPosition = Alignment.Bottom; } } } @@ -137,18 +137,18 @@ namespace Crow if (lm.Y < cb.Top + cb.Height / dockWidthDivisor) dw.DockingPosition = Alignment.Top; else if (lm.Y > cb.Bottom - cb.Height / dockWidthDivisor) - dw.DockingPosition = Alignment.Bottom; + dw.DockingPosition = Alignment.Bottom; } else { getFocusedChild (lm); if (focusedChild != null) { if (lm.X < rIn.Left + rIn.Width / dockWidthDivisor) dw.DockingPosition = Alignment.Left; else if (lm.X > rIn.Right - rIn.Width / dockWidthDivisor) - dw.DockingPosition = Alignment.Right; + dw.DockingPosition = Alignment.Right; } } } - + } if (curDockPos != dw.DockingPosition) @@ -160,7 +160,7 @@ namespace Crow protected override void onDragEnter (object sender, DragDropEventArgs e) { base.onDragEnter (sender, e); - + } public override void onDragLeave (object sender, DragDropEventArgs e) { @@ -168,16 +168,16 @@ namespace Crow //if (dw != null) // dw.DockingPosition = Alignment.Undefined; base.onDragLeave (sender, e); - + } - + public void Dock(DockWindow dw){ DockStack activeStack = this; if (Children.Count == 1) { Orientation = dw.DockingPosition.GetOrientation (); if (Children [0] is DockWindow dwc) - dwc.DockingPosition = dw.DockingPosition.GetOpposite (); + dwc.DockingPosition = dw.DockingPosition.GetOpposite (); } else if (Children.Count > 0 && dw.DockingPosition.GetOrientation () != Orientation) { activeStack = new DockStack (IFace); activeStack.Orientation = dw.DockingPosition.GetOrientation (); @@ -201,7 +201,7 @@ namespace Crow System.Diagnostics.Debug.WriteLine ("Docking {0} as {2} in {1}", dw.Name, activeStack.Name, dw.DockingPosition); switch (dw.DockingPosition) { - case Alignment.Top: + case Alignment.Top: dw.Height = vTreshold; dw.Width = Measure.Stretched; activeStack.InsertChild (0, dw); @@ -233,7 +233,7 @@ namespace Crow } dw.IsDocked = true; } - public void Undock (DockWindow dw){ + public void Undock (DockWindow dw){ int idx = Children.IndexOf(dw); System.Diagnostics.Debug.WriteLine ("undocking child index: {0} ; name={1}; pos:{2} ; childcount:{3}",idx, dw.Name, dw.DockingPosition, Children.Count); @@ -242,8 +242,8 @@ namespace Crow if (Children.Count == 0)//TODO:empty Stack should be removed if not root stack I guess return; - - if (dw.DockingPosition == Alignment.Left || dw.DockingPosition == Alignment.Top) { + + if (dw.DockingPosition == Alignment.Left || dw.DockingPosition == Alignment.Top) { RemoveChild (idx); if (stretchedChild == dw) { stretchedChild = Children [idx]; @@ -262,7 +262,7 @@ namespace Crow if (dsp == null) { Children [0].Width = Children [0].Height = Measure.Stretched; return; - } + } //remove level and move remaining obj to level above Widget g = Children [0]; RemoveChild (g); @@ -316,10 +316,10 @@ namespace Crow DockWindow dw = null; string wName = getConfAttrib (conf, ref i).ToString(); try { - dw = IFace.CreateInstance (wName) as DockWindow; + dw = IFace.CreateInstance (wName) as DockWindow; } catch (Exception ex){ Console.WriteLine ($"[importDockWinConfig]{ex}"); - dw = new DockWindow (IFace); + dw = new DockWindow (IFace); } dw.Name = wName; @@ -329,14 +329,14 @@ namespace Crow dw.savedSlot = Rectangle.Parse (getConfAttrib (conf, ref i).ToString()); dw.wasResizable = Boolean.Parse (getConfAttrib (conf, ref i).ToString()); dw.Resizable = false; - + dw.DataSource = dataSource; return dw; } - void importConfig (ReadOnlySpan<char> conf, ref int i, object dataSource) { + void importConfig (ReadOnlySpan<char> conf, ref int i, object dataSource) { if (conf [i++] != '(') return; - DockWindow dw = null; + DockWindow dw = null; while (i < conf.Length - 4) { string sc = conf.Slice (i, 4).ToString(); i += 4; @@ -346,7 +346,7 @@ namespace Crow tv.Width = Measure.Parse (getConfAttrib (conf, ref i).ToString()); tv.Height = Measure.Parse (getConfAttrib (conf, ref i).ToString()); this.AddChild (tv); - i++; + i++; while (conf [i] != ')') { dw = importDockWinConfig (conf, ref i, dataSource); tv.AddItem (dw); @@ -354,8 +354,8 @@ namespace Crow } i++; break; - case "WIN;": - dw = importDockWinConfig (conf, ref i, dataSource); + case "WIN;": + dw = importDockWinConfig (conf, ref i, dataSource); this.AddChild (dw); dw.IsDocked = true; break; @@ -386,19 +386,19 @@ namespace Crow StringBuilder tmp = new StringBuilder("("); for (int i = 0; i < Children.Count; i++) { - if (Children [i] is DockWindow dw) + if (Children [i] is DockWindow dw) tmp.Append (dw.GetDockConfigString()); else if (Children [i] is TabView tv) { tmp.Append ($"TVI;{tv.Width};{tv.Height};("); foreach (DockWindow d in tv.Items) - tmp.Append (d.GetDockConfigString().Substring(4)); + tmp.Append (d.GetDockConfigString().Substring(4)); tmp.Append (")"); }else if (Children [i] is DockStack ds) tmp.Append ($"STK;{ds.Width};{ds.Height};{ds.Orientation};{ds.exportConfig()}"); - else if (Children [i] is Splitter sp) + else if (Children [i] is Splitter sp) tmp.Append (string.Format("SPL;{0};{1};{2};", sp.Width, sp.Height, sp.Thickness)); if (i < Children.Count - 1) - tmp.Append ("|"); + tmp.Append ("|"); } tmp.Append (")"); diff --git a/Crow/src/Widgets/GenericStack.cs b/Crow/src/Widgets/GenericStack.cs index a605f02d..4c0a85d9 100644 --- a/Crow/src/Widgets/GenericStack.cs +++ b/Crow/src/Widgets/GenericStack.cs @@ -46,7 +46,7 @@ namespace Crow { } #endregion - #region GraphicObject Overrides + #region Widget Overrides public override bool ArrangeChildren => true; public override void ChildrenLayoutingConstraints (ILayoutable layoutable, ref LayoutingType layoutType) { //Prevent child repositionning in the direction of stacking diff --git a/Crow/src/Widgets/Grid.cs b/Crow/src/Widgets/Grid.cs index 14122843..4d7edced 100644 --- a/Crow/src/Widgets/Grid.cs +++ b/Crow/src/Widgets/Grid.cs @@ -99,12 +99,12 @@ namespace Crow #endregion - #region GraphicObject Overrides + #region Widget Overrides // protected override Size measureRawSize () // { // Size tmp = new Size (); // -// foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) { +// foreach (Widget c in Children.Where(ch=>ch.Visible)) { // tmp.Width = Math.Max (tmp.Width, c.Slot.Width); // tmp.Height = Math.Max (tmp.Height, c.Slot.Height); // } diff --git a/Crow/src/Widgets/Group.cs b/Crow/src/Widgets/Group.cs index 90ff4e64..e6e6caf6 100644 --- a/Crow/src/Widgets/Group.cs +++ b/Crow/src/Widgets/Group.cs @@ -98,7 +98,7 @@ namespace Crow ChildrenCleared.Raise (this, new EventArgs ()); } - #region GraphicObject overrides + #region Widget overrides public override int measureRawSize (LayoutingType lt) { DbgLogger.StartEvent(DbgEvtType.GOMeasure, this, lt); diff --git a/Crow/src/Widgets/GroupBase.cs b/Crow/src/Widgets/GroupBase.cs index 8c98d0b6..bed807e0 100644 --- a/Crow/src/Widgets/GroupBase.cs +++ b/Crow/src/Widgets/GroupBase.cs @@ -164,7 +164,7 @@ namespace Crow } } - #region GraphicObject overrides + #region Widget overrides public override Widget FindByName (string nameToFind) { if (Name == nameToFind) diff --git a/Crow/src/Widgets/Image.cs b/Crow/src/Widgets/Image.cs index 0473893b..eb6ee0d0 100644 --- a/Crow/src/Widgets/Image.cs +++ b/Crow/src/Widgets/Image.cs @@ -112,7 +112,7 @@ namespace Crow /// <summary> /// Opacity parameter for the image /// </summary> - // TODO:could be moved in GraphicObject + // TODO:could be moved in Widget [DefaultValue(1.0)] public virtual double Opacity { get { return opacity; } @@ -157,7 +157,7 @@ namespace Crow } #endregion - #region GraphicObject overrides + #region Widget overrides public override int measureRawSize (LayoutingType lt) { if (_pic == null) diff --git a/Crow/src/Widgets/Label.cs b/Crow/src/Widgets/Label.cs index 9a16bf87..9379e5d2 100644 --- a/Crow/src/Widgets/Label.cs +++ b/Crow/src/Widgets/Label.cs @@ -606,7 +606,7 @@ namespace Crow selectionStart = null; } - #region GraphicObject overrides + #region Widget overrides public override bool UpdateLayout (LayoutingType layoutType) { if ((LayoutingType.Sizing | layoutType) != LayoutingType.None) { if (!System.Threading.Monitor.TryEnter (linesMutex)) diff --git a/Crow/src/Widgets/Popper.cs b/Crow/src/Widgets/Popper.cs index b1529e4a..e8ba3fe9 100644 --- a/Crow/src/Widgets/Popper.cs +++ b/Crow/src/Widgets/Popper.cs @@ -178,7 +178,7 @@ namespace Crow positionContent (LayoutingType.Y); } - #region GraphicObject overrides + #region Widget overrides public override void onMouseLeave (object sender, MouseMoveEventArgs e) { IsPopped = false; diff --git a/Crow/src/Widgets/PrivateContainer.cs b/Crow/src/Widgets/PrivateContainer.cs index b5e9fbc2..d0bd9859 100644 --- a/Crow/src/Widgets/PrivateContainer.cs +++ b/Crow/src/Widgets/PrivateContainer.cs @@ -34,9 +34,7 @@ namespace Crow #endif protected Widget child; #if DEBUG_LOG - internal Widget getTemplateRoot { - get { return child; } - } + internal Widget getTemplateRoot => child; #endif protected virtual void SetChild(Widget _child) @@ -71,7 +69,7 @@ namespace Crow g.Dispose (); } - #region GraphicObject Overrides + #region Widget Overrides public override Widget FindByName (string nameToFind) { diff --git a/Crow/src/Widgets/RadioButton.cs b/Crow/src/Widgets/RadioButton.cs index 116863b4..8d53c6b1 100644 --- a/Crow/src/Widgets/RadioButton.cs +++ b/Crow/src/Widgets/RadioButton.cs @@ -23,7 +23,7 @@ namespace Crow public event EventHandler Checked; public event EventHandler Unchecked; - #region GraphicObject overrides + #region Widget overrides public override void onMouseDown (object sender, MouseButtonEventArgs e) { Group pg = Parent as Group; diff --git a/Crow/src/Widgets/Scroller.cs b/Crow/src/Widgets/Scroller.cs index 4e754a3d..8eb9aaf3 100644 --- a/Crow/src/Widgets/Scroller.cs +++ b/Crow/src/Widgets/Scroller.cs @@ -26,7 +26,16 @@ namespace Crow /// <summary> /// if true, key stroke are handled in derrived class /// </summary> - protected bool KeyEventsOverrides = false; + bool keyEventsOverrides; + public bool KeyEventsOverrides { + get => keyEventsOverrides; + set { + if (keyEventsOverrides == value) + return; + keyEventsOverrides = value; + NotifyValueChangedAuto (keyEventsOverrides); + } + } #region public properties /// <summary> Horizontal Scrolling Position </summary> @@ -150,7 +159,7 @@ namespace Crow } - #region GraphicObject Overrides + #region Widget Overrides public override Rectangle ScreenCoordinates (Rectangle r) { return base.ScreenCoordinates (r) - new Point((int)ScrollX,(int)ScrollY); @@ -222,7 +231,7 @@ namespace Crow { base.onKeyDown (sender, e); - if (KeyEventsOverrides) + if (keyEventsOverrides) return; switch (e.Key) { diff --git a/Crow/src/Widgets/Splitter.cs b/Crow/src/Widgets/Splitter.cs index 663177d0..d1f2d97d 100644 --- a/Crow/src/Widgets/Splitter.cs +++ b/Crow/src/Widgets/Splitter.cs @@ -33,7 +33,7 @@ namespace Crow } } - #region GraphicObject override + #region Widget override public override ILayoutable Parent { get => base.Parent; set { diff --git a/Crow/src/Widgets/TemplatedContainer.cs b/Crow/src/Widgets/TemplatedContainer.cs index 5977203c..c9566032 100644 --- a/Crow/src/Widgets/TemplatedContainer.cs +++ b/Crow/src/Widgets/TemplatedContainer.cs @@ -56,7 +56,7 @@ namespace Crow _contentContainer = this.child.FindByName ("Content") as Container; } -#region GraphicObject overrides +#region Widget overrides public override Widget FindByName (string nameToFind) { if (Name == nameToFind) diff --git a/Crow/src/Widgets/TemplatedControl.cs b/Crow/src/Widgets/TemplatedControl.cs index c1e20eae..dc22896a 100644 --- a/Crow/src/Widgets/TemplatedControl.cs +++ b/Crow/src/Widgets/TemplatedControl.cs @@ -39,13 +39,12 @@ namespace Crow string caption; /// <summary> - /// Template path + /// Template path or IML fragment. /// </summary> /// <remark> /// The 'null' default value with the 'NOT_SET' field init value force a loading /// of the default template by passing the first equality check. /// </remark> - //TODO: this property should be renamed 'TemplatePath' [DefaultValue(null)] public string Template { get => _template; @@ -56,6 +55,8 @@ namespace Crow if (string.IsNullOrEmpty(_template)) loadTemplate (); + else if (_template.Trim().StartsWith('<'))//imlfragment + loadTemplate (IFace.CreateITorFromIMLFragment (_template).CreateInstance()); else loadTemplate (IFace.CreateInstance (_template)); } @@ -74,9 +75,9 @@ namespace Crow } } - #region GraphicObject overrides + #region Widget overrides /// <summary> - /// override search method from GraphicObject to prevent + /// override search method from Widget to prevent /// searching inside template /// </summary> /// <returns>widget identified by name, or null if not found</returns> diff --git a/Crow/src/Widgets/TemplatedGroup.cs b/Crow/src/Widgets/TemplatedGroup.cs index bc00a0f3..ed955d72 100644 --- a/Crow/src/Widgets/TemplatedGroup.cs +++ b/Crow/src/Widgets/TemplatedGroup.cs @@ -85,7 +85,7 @@ namespace Crow { /// <summary> /// Keep track of expanded subnodes and closed time to unload /// </summary> - //Dictionary<GraphicObject, Stopwatch> nodes = new Dictionary<GraphicObject, Stopwatch>(); + //Dictionary<Widget, Stopwatch> nodes = new Dictionary<Widget, Stopwatch>(); internal List<Widget> nodes = new List<Widget>();//TODO:close time tracking /// <summary> /// Item templates file path, on disk or embedded. @@ -353,7 +353,7 @@ namespace Crow { } - #region GraphicObject overrides + #region Widget overrides public override Widget FindByName (string nameToFind) { if (Name == nameToFind) @@ -725,10 +725,34 @@ namespace Crow { if (SelectedIndex < Items.Count - 1) SelectedIndex++; break; + case Glfw.Key.PageUp: + pagedSelection (true); + break; + case Glfw.Key.PageDown: + pagedSelection (false); + break; + case Glfw.Key.Home: + SelectedIndex = 0; + break; + case Glfw.Key.End: + SelectedIndex = Items.Count - 1; + break; default: base.onKeyDown(sender, e); break; } } + + void pagedSelection (bool up) { + if (scroller != null && selectedItemContainer != null && itemsContainer is GenericStack gs) { + Rectangle scrollerCb = scroller.ClientRectangle; + Rectangle itemCb = selectedItemContainer.Slot; + int itemsPerPage = gs.Orientation == Orientation.Vertical ? scrollerCb.Height / itemCb.Height : scrollerCb.Width / itemCb.Width; + if (up) + SelectedIndex = Math.Max (0, SelectedIndex - itemsPerPage); + else + SelectedIndex = Math.Min (Items.Count - 1, SelectedIndex + itemsPerPage); + } + } } } diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs index a7f50e78..5422460a 100644 --- a/Crow/src/Widgets/Widget.cs +++ b/Crow/src/Widgets/Widget.cs @@ -246,7 +246,7 @@ namespace Crow /// <summary> /// This constructor **must** be used when creating widget from code. /// - /// When creating new widgets derived from GraphicObject, both parameterless and this constructors are + /// When creating new widgets derived from Widget, both parameterless and this constructors are /// facultatives, the compiler will create the parameterless one automaticaly if no other one exists. /// But if you intend to be able to create instances of the new widget in code and override the constructor /// with the Interface parameter, you **must** also provide the override of the parameterless constructor because @@ -350,7 +350,7 @@ namespace Crow get => requiredLayoutings; set => requiredLayoutings = value; } - //TODO: it would save the recurent cost of a cast in event bubbling if parent type was GraphicObject + //TODO: it would save the recurent cost of a cast in event bubbling if parent type was Widget // or we could add to the interface the mouse events /// <summary> /// Parent in the graphic tree, used for rendering and layouting @@ -531,7 +531,7 @@ namespace Crow } } /// <summary> - /// If true, rendering of GraphicObject is clipped inside client rectangle + /// If true, rendering of Widget is clipped inside client rectangle /// </summary> [DesignCategory ("Appearance")][DefaultValue(true)] public virtual bool ClipToClientRect { @@ -875,7 +875,7 @@ namespace Crow } } /// <summary> - /// Font being used in many controls, it is defined in the base GraphicObject class. + /// Font being used in many controls, it is defined in the base Widget class. /// </summary> [DesignCategory ("Appearance")][DefaultValue("sans, 12")] public virtual Font Font { @@ -1198,7 +1198,7 @@ namespace Crow il = dm.GetILGenerator(256); il.DeclareLocal(typeof (object));//store root il.Emit(OpCodes.Nop); - //set local GraphicObject to root object passed as 1st argument + //set local Widget to root object passed as 1st argument il.Emit (OpCodes.Ldarg_0); il.Emit (OpCodes.Stloc_0); diff --git a/Crow/src/Widgets/Window.cs b/Crow/src/Widgets/Window.cs index c1bf5b8b..73d89f1d 100644 --- a/Crow/src/Widgets/Window.cs +++ b/Crow/src/Widgets/Window.cs @@ -375,7 +375,7 @@ namespace Crow bool maySize => sizingHandle != null && resizable && sizingHandle.IsHover; bool mayMove => moveHandle != null && movable; - #region GraphicObject Overrides + #region Widget Overrides public override void onMouseMove (object sender, MouseMoveEventArgs e) { base.onMouseMove (sender, e); diff --git a/Crow/src/Widgets/Wrapper.cs b/Crow/src/Widgets/Wrapper.cs index 71ef6a0d..ef7d627a 100644 --- a/Crow/src/Widgets/Wrapper.cs +++ b/Crow/src/Widgets/Wrapper.cs @@ -93,7 +93,7 @@ namespace Crow } #endregion - #region GraphicObject Overrides + #region Widget Overrides public override int measureRawSize (LayoutingType lt) { int tmp = 0; diff --git a/Crow/src/styling/StyleReader.cs b/Crow/src/styling/StyleReader.cs index a056283a..e0bc07b9 100644 --- a/Crow/src/styling/StyleReader.cs +++ b/Crow/src/styling/StyleReader.cs @@ -14,9 +14,18 @@ using System.Text; namespace Crow { /// <summary> - /// Parser for style files. + /// Parser for style files. Only the first occurence of a key/value pair is kept. + /// Theme styles will override any style, then the startup application styles have priority. /// </summary> + /// <remark> + /// The order of style loading during application startup is as follow: + /// - Optional theme styles + /// - Style from entry assembly, the executable + /// - crowAssemblies list are loaded in order. + /// - default style from the crow assembly. + /// </remark> //TODO: style key shared by different class may use only first encouneter class setter, which can cause bug. + //TODO: ensure alphabetic order of loading inside single assembly. public class StyleReader : StreamReader { enum States { classNames, members, value, endOfStatement } diff --git a/Directory.Build.props b/Directory.Build.props index c0160dcb..a5cc8f97 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -26,6 +26,6 @@ <!-- Experimental vkvg backend, testing only--> <CrowVkvgBackend>false</CrowVkvgBackend> - <GlfwSharpVersion>0.2.12-beta</GlfwSharpVersion> + <GlfwSharpVersion>0.2.14</GlfwSharpVersion> </PropertyGroup> </Project> diff --git a/Samples/BasicTests/BasicTests.cs b/Samples/BasicTests/BasicTests.cs index 3b4e6bb2..59b0e1ca 100644 --- a/Samples/BasicTests/BasicTests.cs +++ b/Samples/BasicTests/BasicTests.cs @@ -38,7 +38,7 @@ namespace Samples //testFiles = new string [] { @"Interfaces/Stack/StretchedInFit4.crow" }; //testFiles = new string [] { @"Interfaces/TemplatedGroup/1.crow" }; //testFiles = new string [] { @"Interfaces/Divers/colorPicker2.crow" }; - testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/GraphicObject", "*.crow")).ToArray (); + testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Widget", "*.crow")).ToArray (); testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Container", "*.crow")).ToArray (); testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Group", "*.crow")).ToArray (); testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Stack", "*.crow")).ToArray (); diff --git a/Samples/HelloWorld/HelloWorld.csproj b/Samples/HelloWorld/HelloWorld.csproj index 7ceb582d..178d4537 100644 --- a/Samples/HelloWorld/HelloWorld.csproj +++ b/Samples/HelloWorld/HelloWorld.csproj @@ -1,9 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <TargetFramework>netcoreapp3.1</TargetFramework> + <OutputType>Exe</OutputType> + </PropertyGroup> <ItemGroup> - <EmbeddedResource Include="ui\**\*.*"> - <LogicalName>HelloWorld.%(Filename)%(Extension)</LogicalName> - </EmbeddedResource> + <PackageReference Include="Crow" /> </ItemGroup> </Project>
\ No newline at end of file diff --git a/Samples/HelloWorld/main.cs b/Samples/HelloWorld/main.cs index dc5e2a13..e60b9782 100644 --- a/Samples/HelloWorld/main.cs +++ b/Samples/HelloWorld/main.cs @@ -4,21 +4,10 @@ using Samples; namespace HelloWorld { - class Program : SampleBase { - public CommandGroup CMDTest = new CommandGroup ( - new ActionCommand("Action", ()=> Console.WriteLine ("Action executed")) - ); + class Program { static void Main (string[] args) { - DbgLogger.IncludedEvents.AddRange ( new DbgEvtType[] { - DbgEvtType.MouseEnter, - DbgEvtType.MouseLeave, - DbgEvtType.WidgetMouseDown, - DbgEvtType.WidgetMouseUp, - DbgEvtType.WidgetMouseClick, - DbgEvtType.HoverWidget - }); - using (Interface app = new Program ()) { - app.Initialized += (sender, e) => (sender as Interface).Load ("#HelloWorld.helloworld.crow").DataSource = sender; + using (Interface app = new Interface ()) { + app.Initialized += (sender, e) => app.LoadIMLFragment (@"<Label Text='Hello World'/>"); app.Run (); } } diff --git a/Samples/HelloWorld/ui/helloworld.crow b/Samples/HelloWorld/ui/helloworld.crow deleted file mode 100644 index a9dad40c..00000000 --- a/Samples/HelloWorld/ui/helloworld.crow +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0"?> -<VerticalStack Margin="50" Spacing="20"> - <HorizontalStack Height="Fit"> - <Label Text="Hover:" Width="50" Foreground="Grey"/> - <Label Text="{HoverWidget}" Font="mono, 8"/> - </HorizontalStack> - <HorizontalStack Height="Fit"> - <Label Text="Focus:" Width="50" Foreground="Grey"/> - <Label Text="{FocusedWidget}" Font="mono, 8"/> - </HorizontalStack> - <HorizontalStack Height="Fit"> - <Label Text="Active:" Width="50" Foreground="Grey"/> - <Label Text="{ActiveWidget}" Font="mono, 8"/> - </HorizontalStack> - <Border Height="Fit" Margin="2" Background="Blue" ContextCommands="{CMDTest}" Focusable="true" - MouseEnter="{Background=Red}" - MouseLeave="{Background=Blue}"> - <Label Margin="5" Text="Hello World" /> - </Border> - <Border Height="Fit" Margin="2" Background="Blue" ContextCommands="{CMDTest}" Focusable="true" - MouseEnter="{Background=Red}" - MouseLeave="{Background=Blue}"> - <Label Margin="5" Text="Hello World" /> - </Border> - <Border Height="Fit" Margin="2" Background="Blue" ContextCommands="{CMDTest}" Focusable="true" - MouseEnter="{Background=Red}" - MouseLeave="{Background=Blue}"> - <Label Margin="5" Text="Hello World" /> - </Border> - <Border Height="Fit" Margin="2" Background="Blue" ContextCommands="{CMDTest}" Focusable="true" - MouseEnter="{Background=Red}" - MouseLeave="{Background=Blue}"> - <Label Margin="5" Text="Hello World" /> - </Border> - <Border Height="Fit" Margin="2" Background="Blue" ContextCommands="{CMDTest}" Focusable="true" - MouseEnter="{Background=Red}" - MouseLeave="{Background=Blue}"> - <Label Margin="5" Text="Hello World" /> - </Border> -</VerticalStack> diff --git a/Samples/ShowCase/ShowCase.cs b/Samples/ShowCase/ShowCase.cs index 71556f01..9d257160 100644 --- a/Samples/ShowCase/ShowCase.cs +++ b/Samples/ShowCase/ShowCase.cs @@ -37,6 +37,8 @@ namespace ShowCase app.SetWindowIcon ("#Crow.Icons.crow.png"); //app.Theme = @"C:\Users\Jean-Philippe\source\Crow\Themes\TestTheme"; CurrentProgramInstance = app; + Interface.UPDATE_INTERVAL = 50; + Interface.POLLING_INTERVAL = 5; app.Run (); } diff --git a/Samples/common/src/SampleBase.cs b/Samples/common/src/SampleBase.cs index 3e0ef714..ce043b37 100644 --- a/Samples/common/src/SampleBase.cs +++ b/Samples/common/src/SampleBase.cs @@ -11,31 +11,13 @@ using System.Runtime.InteropServices; using System.Threading; using Crow.Drawing; +using System.Diagnostics; namespace Samples { public class SampleBase : Interface { -#if NETCOREAPP - static IntPtr resolveUnmanaged(Assembly assembly, String libraryName) - { - switch (libraryName) - { - case "glfw3": - return NativeLibrary.Load("glfw", assembly, null); - case "rsvg-2.40": - return NativeLibrary.Load("rsvg-2", assembly, null); - } - Console.WriteLine($"[UNRESOLVE] {assembly} {libraryName}"); - return IntPtr.Zero; - } - - 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) : @@ -436,5 +418,63 @@ namespace Samples } return base.OnKeyDown(e); } + public IEnumerable<RandomProgress> RandomProgressList { + get { + for (int i=0; i< RandomProgressItemCount; i++) + yield return new RandomProgress (); + } + } + int randomProgressItemCount = 10; + public int RandomProgressItemCount { + get => randomProgressItemCount; + set { + if (randomProgressItemCount == value) + return; + randomProgressItemCount = value; + NotifyValueChanged (randomProgressItemCount); + NotifyValueChanged ("RandomProgressList", RandomProgressList); + } + } + + public class RandomProgress : IValueChange { + static Random rnd = new Random(); + public event EventHandler<ValueChangeEventArgs> ValueChanged; + public void NotifyValueChanged(object _value, [CallerMemberName] string caller = null) + => ValueChanged.Raise(this, new ValueChangeEventArgs(caller, _value)); + public void NotifyValueChanged(string membername, object _value) + => ValueChanged.Raise(this, new ValueChangeEventArgs(membername, _value)); + public RandomProgress () { + step = rnd.Next (10); + max = rnd.Next (100, 1000); + sleep = rnd.Next (2,200); + Thread t = new Thread(increment); + t.IsBackground = true; + t.Start (); + + NotifyValueChanged ("Maximum", max); + } + int val, step, max, sleep; + public int Value { + get => val; + set { + if (val == value) + return; + val = value; + NotifyValueChanged (val); + } + } + public int Maximum => max; + + void increment() { + Stopwatch sw = Stopwatch.StartNew(); + while (sw.ElapsedMilliseconds < 10000) { + Value += step; + if (Value > max) + Value = 0; + Thread.Sleep (sleep); + } + Value = max; + } + } } }
\ No newline at end of file diff --git a/Samples/common/ui/Interfaces/Container/3.crow b/Samples/common/ui/Interfaces/Container/3.crow index 4d6d1ec3..79df9e91 100644 --- a/Samples/common/ui/Interfaces/Container/3.crow +++ b/Samples/common/ui/Interfaces/Container/3.crow @@ -1,4 +1,10 @@ <?xml version="1.0"?> <Container Background="Blue" Margin="10" Fit="true"> - <Label Text="test" Margin="10" Fit="true" Background="SeaGreen"/> + <Label Multiline="true" Text="this is a test of a multiline textbox +and another line +and another line +and another line a little bit longuer +and another line +and another line +" Margin="10" Fit="true" Background="SeaGreen" TextAlignment="Center"/> </Container>
\ No newline at end of file diff --git a/Samples/common/ui/Interfaces/Divers/testFileDialogTemplate.crow b/Samples/common/ui/Interfaces/Divers/testFileDialogTemplate.crow new file mode 100644 index 00000000..7aed370f --- /dev/null +++ b/Samples/common/ui/Interfaces/Divers/testFileDialogTemplate.crow @@ -0,0 +1,91 @@ +<?xml version="1.0"?> +<FileDialog Caption="Open File" CurrentDirectory="/" SearchPattern="*.*"> + <Template> + <Border Name="SizeHandle" Style="winBorder" CornerRadius="{./CornerRadius}" Background="{./Background}"> + <VerticalStack Spacing="0"> + <HorizontalStack Background="${WindowTitleBarBackground}" Margin="0" Spacing="0" Height="Fit"> + <Widget Width="5"/> + <Image Margin="1" Width="12" Height="12" Path="{./Icon}"/> + <Label Name="MoveHandle" Width="Stretched" Foreground="${WindowTitleBarForeground" Margin="2" TextAlignment="Center" Text="{./Caption}" /> + <Border CornerRadius="0" BorderWidth="1" Foreground="Transparent" Height="12" Width="12" + 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> + <Widget Width="5"/> + </HorizontalStack> + <Container Name="Content" MinimumSize="50,50" Background="Jet"> + <VerticalStack Margin="1"> + <HorizontalStack Height="Fit"> + <Button Fit="true" Caption="Up" MouseClick="./goUpDirClick"> + <Image Margin="2" Width="14" Height="14" + Path="#Crow.Icons.level-up.svg"/> + </Button> + <TextBox Style="TxtInFileDialog" Text="{²./CurrentDirectory}"/> + </HorizontalStack> + <DirectoryView ShowHidden="{²../cbShowHidden.IsChecked}" FileMask="{²../txtFileMask.Text}" ShowFiles="{²../cbShowFiles.IsChecked}" + Name="fv" CurrentDirectory="{./CurrentDirectory}" SelectedItemChanged="./onFVSelectedItemChanged" + Width="100%" Margin="0" MouseDoubleClick="./onFileSelectDblClick"> + <Template> + <ListBox Name="fileView" Data="{./FileSystemEntries}" + SelectedItemChanged="./onSelectedItemChanged"> + <Template> + <HorizontalStack> + <Scroller Name="scroller1"> + <VerticalStack Height="Fit" VerticalAlignment="Top" + Name="ItemsContainer" Margin="0" Spacing="1"/> + </Scroller> + <ScrollBar Name="scrollbar1" Orientation="Vertical" + Value="{²../scroller1.ScrollY}" Maximum="{../scroller1.MaxScrollY}" + CursorRatio="{../scroller1.ChildHeightRatio}" + LargeIncrement="{../scroller1.PageHeight}" SmallIncrement="30" + Width="14" /> + </HorizontalStack> + </Template> + <ItemTemplate> + <Widget Height="16" Background="Red"/> + </ItemTemplate> + <ItemTemplate DataType="System.IO.FileInfo"> + <ListItem Height="Fit" + Selected = "{Background=${ControlHighlight}}" + Unselected = "{Background=Transparent}"> + <HorizontalStack> + <Image Margin="2" Width="16" Height="16" Path="#Crow.Icons.file.svg"/> + <Label Text="{Name}" Width="Stretched"/> + </HorizontalStack> + </ListItem> + </ItemTemplate> + <ItemTemplate DataType="System.IO.DirectoryInfo"> + <ListItem Height="Fit" + Selected = "{Background=${ControlHighlight}}" + Unselected = "{Background=Transparent}"> + <HorizontalStack> + <Image Margin="2" Width="16" Height="16" Path="#Crow.Icons.folder.svg"/> + <Label Text="{Name}" Width="Stretched"/> + <Label Text="{LastAccessTime}" /> + </HorizontalStack> + </ListItem> + </ItemTemplate> + </ListBox> + </Template> + </DirectoryView> + <HorizontalStack Height="Fit"> + <TextBox Style="TxtInFileDialog" Text="{²./SelectedFile}"/> + <TextBox Style="TxtInFileDialog" Width="50" Name="txtFileMask" Text="{²./SearchPattern}"/> + </HorizontalStack> + <HorizontalStack Margin="5" Fit="true" HorizontalAlignment="Right"> + <CheckBox Style="CheckBoxAlt" Name="cbShowFiles" Caption="Show Files" IsChecked="{²./ShowFiles}"/> + <CheckBox Style="CheckBoxAlt" Name="cbShowHidden" Caption="Show Hidden" IsChecked="{²./ShowHidden}"/> + </HorizontalStack> + <HorizontalStack Fit="true" HorizontalAlignment="Right" Margin="3" Spacing="3"> + <Button Caption="Ok" Command="{./CMDOk}"/> + <Button Caption="Cancel" Command="{./CMDCancel}"/> + </HorizontalStack> + </VerticalStack> + </Container> + </VerticalStack> + </Border> + + </Template> +</FileDialog> + diff --git a/Samples/common/ui/Interfaces/Experimental/directoryView2-dyn.crow b/Samples/common/ui/Interfaces/Experimental/directoryView2-dyn.crow new file mode 100644 index 00000000..811b3dba --- /dev/null +++ b/Samples/common/ui/Interfaces/Experimental/directoryView2-dyn.crow @@ -0,0 +1,5 @@ +<VerticalStack> + <EnumSelector Caption="View Style" EnumValue="{²../dv.ViewStyle}"/> + <Spinner Value="{²../dv.IconSize}" SmallIncrement="1" LargeIncrement="1"/> + <DirectoryView2 Name="dv" CurrentDirectory="/mnt/devel" MouseDoubleClick="./onFileSelectDblClick"/> +</VerticalStack>
\ No newline at end of file diff --git a/Samples/common/ui/Interfaces/Experimental/directoryView2.crow b/Samples/common/ui/Interfaces/Experimental/directoryView2.crow index 8035f749..9bfebe72 100644 --- a/Samples/common/ui/Interfaces/Experimental/directoryView2.crow +++ b/Samples/common/ui/Interfaces/Experimental/directoryView2.crow @@ -1,7 +1,8 @@ -<DirectoryView2 CurrentDirectory="/mnt/devel" Data="{/FileSystemEntries}"> - <Template> - <VerticalStack> - <Spinner Value="{²./IconSize}" SmallIncrement="1" LargeIncrement="1"/> +<VerticalStack> + <EnumSelector Caption="View Style" EnumValue="{²../dv.ViewStyle}"/> + <Spinner Value="{²../dv.IconSize}" SmallIncrement="1" LargeIncrement="1"/> + <DirectoryView2 UseLoadingThread="false" Name="dv" CurrentDirectory="/mnt/devel" Data="{/FileSystemEntries}"> + <Template> <HorizontalStack Background="Grey" Margin="5"> <Scroller Name="scroller1"> <Wrapper Orientation="Vertical" Height="Fit" VerticalAlignment="Top" @@ -13,8 +14,7 @@ LargeIncrement="{../scroller1.PageHeight}" SmallIncrement="30" Width="14" /> </HorizontalStack> - </VerticalStack> - </Template> + </Template> <ItemTemplate DataType="System.IO.FileInfo"> <ListItem Width="70" Height="60" BubbleEvents="All" Tooltip="{Name}" @@ -37,4 +37,5 @@ </VerticalStack> </ListItem> </ItemTemplate> -</DirectoryView2>
\ No newline at end of file +</DirectoryView2> +</VerticalStack>
\ No newline at end of file diff --git a/Samples/common/ui/Interfaces/Experimental/directoryView3.crow b/Samples/common/ui/Interfaces/Experimental/directoryView3.crow index 1dd1d88d..45d811a2 100644 --- a/Samples/common/ui/Interfaces/Experimental/directoryView3.crow +++ b/Samples/common/ui/Interfaces/Experimental/directoryView3.crow @@ -1,35 +1,38 @@ -<DirectoryView2 CurrentDirectory="/mnt/devel" Data="{/FileSystemEntries}"> - <Template> - <VerticalStack> - <Spinner Value="{²./IconSize}" SmallIncrement="1" LargeIncrement="1"/> - <VerticalStack Background="Grey" Margin="5"> - <Scroller Name="scroller1"> - <Wrapper Orientation="Horizontal" Height="Stretched" Width="Fit" HorizontalAlignment="Left" - Name="ItemsContainer" Margin="0" Spacing="2"/> - </Scroller> +<VerticalStack> + <EnumSelector Caption="View Style" EnumValue="{²../dv.ViewStyle}"/> + <Spinner Value="{²../dv.IconSize}" SmallIncrement="1" LargeIncrement="1"/> + <DirectoryView2 Name="dv" CurrentDirectory="/mnt/devel" Data="{/FileSystemEntries}"> + <Template> + <VerticalStack> + <VerticalStack Background="Grey" Margin="5"> + <Scroller Name="scroller1"> + <Wrapper Orientation="Horizontal" Height="Stretched" Width="Fit" HorizontalAlignment="Left" + Name="ItemsContainer" Margin="0" Spacing="2"/> + </Scroller> + </VerticalStack> </VerticalStack> - </VerticalStack> - </Template> - <ItemTemplate DataType="System.IO.FileInfo"> - <ListItem Width="Fit" Height="Fit" - BubbleEvents="All" Tooltip="{Name}" - Selected = "{Background=${ControlHighlight}}" - Unselected = "{Background=Transparent}"> - <HorizontalStack Spacing="5"> - <Image Margin="0" Width="16" Height="16" Path="${FileIcon}" Scaled="true"/> - <Label Text="{Name}" Width="Fit" Font="sans,9" /> - </HorizontalStack> - </ListItem> - </ItemTemplate> - <ItemTemplate DataType="System.IO.DirectoryInfo"> - <ListItem Width="Fit" Height="Fit" - BubbleEvents="All" Tooltip="{Name}" - Selected = "{Background=${ControlHighlight}}" - Unselected = "{Background=Transparent}"> - <HorizontalStack Spacing="5"> - <Image Margin="0" Width="16" Height="16" Path="${FolderIcon}" Scaled="true"/> - <Label Text="{Name}" Width="Fit" Font="sans,9"/> - </HorizontalStack> - </ListItem> - </ItemTemplate> -</DirectoryView2>
\ No newline at end of file + </Template> + <ItemTemplate DataType="System.IO.FileInfo"> + <ListItem Width="Fit" Height="Fit" + BubbleEvents="All" Tooltip="{Name}" + Selected = "{Background=${ControlHighlight}}" + Unselected = "{Background=Transparent}"> + <HorizontalStack Spacing="5"> + <Image Margin="0" Width="16" Height="16" Path="${FileIcon}" Scaled="true"/> + <Label Text="{Name}" Width="Fit" Font="sans,9" /> + </HorizontalStack> + </ListItem> + </ItemTemplate> + <ItemTemplate DataType="System.IO.DirectoryInfo"> + <ListItem Width="Fit" Height="Fit" + BubbleEvents="All" Tooltip="{Name}" + Selected = "{Background=${ControlHighlight}}" + Unselected = "{Background=Transparent}"> + <HorizontalStack Spacing="5"> + <Image Margin="0" Width="16" Height="16" Path="${FolderIcon}" Scaled="true"/> + <Label Text="{Name}" Width="Fit" Font="sans,9"/> + </HorizontalStack> + </ListItem> + </ItemTemplate> + </DirectoryView2> +</VerticalStack>
\ No newline at end of file diff --git a/Samples/common/ui/Interfaces/Experimental/directoryView5.crow b/Samples/common/ui/Interfaces/Experimental/directoryView5.crow index 62b743ab..5b59a0f6 100644 --- a/Samples/common/ui/Interfaces/Experimental/directoryView5.crow +++ b/Samples/common/ui/Interfaces/Experimental/directoryView5.crow @@ -1,36 +1,40 @@ -<DirectoryView2 CurrentDirectory="/mnt/devel" Data="{/FileSystemEntries}"> - <Template> - <VerticalStack> - <Spinner Value="{²./IconSize}" SmallIncrement="1" LargeIncrement="1"/> - <VerticalStack Background="DarkGrey" Margin="0"> - <Scroller Name="scroller1"> - <Table Columns=",20;Name,Stretched;Size,100;Accessed,Fit" Height="Fit" Width="Stretched" VerticalAlignment="Top" - Name="ItemsContainer" Margin="0" Spacing="0" RowsMargin="0" ColumnSpacing="10" - HorizontalLineWidth="0" VerticalLineWidth="1" /> - </Scroller> +<VerticalStack> + <EnumSelector Caption="View Style" EnumValue="{²../dv.ViewStyle}"/> + <Spinner Value="{²../dv.IconSize}" SmallIncrement="1" LargeIncrement="1"/> + <DirectoryView2 Name="dv" CurrentDirectory="/mnt/devel" Data="{/FileSystemEntries}"> + <Template> + <VerticalStack> + <Spinner Value="{²./IconSize}" SmallIncrement="1" LargeIncrement="1"/> + <VerticalStack Background="DarkGrey" Margin="0"> + <Scroller Name="scroller1"> + <Table Columns=",20;Name,Stretched;Size,100;Accessed,Fit" Height="Fit" Width="Stretched" VerticalAlignment="Top" + Name="ItemsContainer" Margin="0" Spacing="0" RowsMargin="0" ColumnSpacing="10" + HorizontalLineWidth="0" VerticalLineWidth="1" /> + </Scroller> + </VerticalStack> </VerticalStack> - </VerticalStack> - </Template> - <ItemTemplate DataType="System.IO.DirectoryInfo"> - <TableRow Width="Stretched" Height="Fit" Focusable="true" - BubbleEvents="All" Tooltip="{Name}" - Selected="{Background=${ControlHighlight}}" - Unselected="{Background=Transparent}"> - <Image Width="Stretched" Height="Stretched" Path="${FolderIcon}" Margin="0" /> - <Label Text="{Name}" Width="Fit" Font="sans,11" Margin="3"/> - <Label Text="" Font="sans,9"/> - <Label Text="{LastAccessTime}" Font="sans,9"/> - </TableRow> - </ItemTemplate> - <ItemTemplate DataType="System.IO.FileInfo"> - <TableRow Width="Stretched" Height="Fit" Focusable="true" - BubbleEvents="All" Tooltip="{Name}" - Selected="{Background=${ControlHighlight}}" - Unselected="{Background=Transparent}"> - <Image Width="Stretched" Height="Stretched" Path="${FileIcon}" Margin="2" /> - <Label Text="{Name}" Width="Fit" Font="sans,11" Margin="3"/> - <Label Text="{Length}" Font="sans,9" TextAlignment="Right"/> - <Label Text="{LastAccessTime}" Font="sans,9"/> - </TableRow> - </ItemTemplate> -</DirectoryView2>
\ No newline at end of file + </Template> + <ItemTemplate DataType="System.IO.DirectoryInfo"> + <TableRow Width="Stretched" Height="Fit" Focusable="true" + BubbleEvents="All" Tooltip="{Name}" + Selected="{Background=${ControlHighlight}}" + Unselected="{Background=Transparent}"> + <Image Width="Stretched" Height="Stretched" Path="${FolderIcon}" Margin="0" /> + <Label Text="{Name}" Width="Fit" Font="sans,11" Margin="3"/> + <Label Text="" Font="sans,9"/> + <Label Text="{LastAccessTime}" Font="sans,9"/> + </TableRow> + </ItemTemplate> + <ItemTemplate DataType="System.IO.FileInfo"> + <TableRow Width="Stretched" Height="Fit" Focusable="true" + BubbleEvents="All" Tooltip="{Name}" + Selected="{Background=${ControlHighlight}}" + Unselected="{Background=Transparent}"> + <Image Width="Stretched" Height="Stretched" Path="${FileIcon}" Margin="2" /> + <Label Text="{Name}" Width="Fit" Font="sans,11" Margin="3"/> + <Label Text="{Length}" Font="sans,9" TextAlignment="Right"/> + <Label Text="{LastAccessTime}" Font="sans,9"/> + </TableRow> + </ItemTemplate> + </DirectoryView2> +</VerticalStack>
\ No newline at end of file diff --git a/Samples/common/ui/Interfaces/Experimental/fileDialog.crow b/Samples/common/ui/Interfaces/Experimental/fileDialog.crow index 977cbf31..c26e3a7a 100644 --- a/Samples/common/ui/Interfaces/Experimental/fileDialog.crow +++ b/Samples/common/ui/Interfaces/Experimental/fileDialog.crow @@ -12,7 +12,7 @@ <Label Text="{ActiveWidget}" Font="mono, 8"/> </HorizontalStack> <Container> - <FileDialog Focusable="true" Resizable="true"> + <FileDialog Focusable="true" Resizable="true" Width="80%" Height="80%"> <Template> <Border Name="SizeHandle" Style="winBorder" CornerRadius="{./CornerRadius}" Background="{./Background}"> <VerticalStack Spacing="0"> @@ -65,7 +65,7 @@ Selected = "{Background=${ControlHighlight}}" Unselected = "{Background=Transparent}"> <HorizontalStack Spacing="5"> - <Image Width="20" Height="20" Path="#Crow.Icons.file.svg"/> + <Image Width="16" Height="16" Path="#Crow.Icons.file.svg"/> <Label Margin="2" Text="{Name}" Width="Stretched"/> </HorizontalStack> </ListItem> @@ -76,7 +76,7 @@ Selected = "{Background=${ControlHighlight}}" Unselected = "{Background=Transparent}"> <HorizontalStack Spacing="5"> - <Image Width="20" Height="20" Path="#Crow.Icons.folder.svg"/> + <Image Width="16" Height="16" Path="#Crow.Icons.folder.svg"/> <Label Margin="2" Text="{Name}" Width="Stretched"/> <Label Margin="2" Text="{LastAccessTime}" /> </HorizontalStack> diff --git a/Samples/common/ui/Interfaces/Experimental/randomProgress.crow b/Samples/common/ui/Interfaces/Experimental/randomProgress.crow new file mode 100644 index 00000000..9b63b81a --- /dev/null +++ b/Samples/common/ui/Interfaces/Experimental/randomProgress.crow @@ -0,0 +1,18 @@ +<VerticalStack> + <VerticalStack Width="Fit" Background="DarkSlateGrey" Margin="10" Height="Fit"> + <HorizontalStack Height="Fit" Spacing="10"> + <Label Text="Value:"/> + <Label Text="{../../slider.Value}" Background="Onyx" Margin="1" Width="40" TextAlignment="Right"/> + </HorizontalStack> + <Slider Name="slider" Height="10" Width="200" Background="DarkGrey" LargeIncrement="20" SmallIncrement="5" + Minimum="10" Maximum="1000" Value="{²RandomProgressItemCount}"/> + </VerticalStack> + <ListBox UseLoadingThread="false" Data="{RandomProgressList}"> + <Template> + <Wrapper Name="ItemsContainer"/> + </Template> + <ItemTemplate> + <ProgressBar Maximum="{Maximum}" Value="{Value}" Height="10" Width="50"/> + </ItemTemplate> + </ListBox> +</VerticalStack>
\ No newline at end of file diff --git a/Samples/common/ui/Interfaces/GraphicObject/0.crow b/Samples/common/ui/Interfaces/Widget/0.crow index a58dcb8d..a58dcb8d 100644 --- a/Samples/common/ui/Interfaces/GraphicObject/0.crow +++ b/Samples/common/ui/Interfaces/Widget/0.crow diff --git a/Samples/common/ui/Interfaces/GraphicObject/1.crow b/Samples/common/ui/Interfaces/Widget/1.crow index d74f4949..d74f4949 100644 --- a/Samples/common/ui/Interfaces/GraphicObject/1.crow +++ b/Samples/common/ui/Interfaces/Widget/1.crow diff --git a/Samples/common/ui/Interfaces/GraphicObject/2.crow b/Samples/common/ui/Interfaces/Widget/2.crow index af2998ac..af2998ac 100644 --- a/Samples/common/ui/Interfaces/GraphicObject/2.crow +++ b/Samples/common/ui/Interfaces/Widget/2.crow diff --git a/Samples/common/ui/Interfaces/GraphicObject/4.crow b/Samples/common/ui/Interfaces/Widget/4.crow index 81d386c9..81d386c9 100644 --- a/Samples/common/ui/Interfaces/GraphicObject/4.crow +++ b/Samples/common/ui/Interfaces/Widget/4.crow diff --git a/Samples/common/ui/Interfaces/GraphicObject/5.crow b/Samples/common/ui/Interfaces/Widget/5.crow index 535623a3..535623a3 100644 --- a/Samples/common/ui/Interfaces/GraphicObject/5.crow +++ b/Samples/common/ui/Interfaces/Widget/5.crow diff --git a/Samples/common/ui/Interfaces/GraphicObject/6.crow b/Samples/common/ui/Interfaces/Widget/6.crow index f537a71d..f537a71d 100644 --- a/Samples/common/ui/Interfaces/GraphicObject/6.crow +++ b/Samples/common/ui/Interfaces/Widget/6.crow diff --git a/Samples/common/ui/Interfaces/GraphicObject/7.crow b/Samples/common/ui/Interfaces/Widget/7.crow index 0ac9b19f..0ac9b19f 100644 --- a/Samples/common/ui/Interfaces/GraphicObject/7.crow +++ b/Samples/common/ui/Interfaces/Widget/7.crow diff --git a/Samples/common/ui/Interfaces/GraphicObject/blueLine.crow b/Samples/common/ui/Interfaces/Widget/blueLine.crow index 32d5c166..32d5c166 100644 --- a/Samples/common/ui/Interfaces/GraphicObject/blueLine.crow +++ b/Samples/common/ui/Interfaces/Widget/blueLine.crow diff --git a/Samples/common/ui/Interfaces/GraphicObject/label.crow b/Samples/common/ui/Interfaces/Widget/label.crow index ad47ccf7..ad47ccf7 100644 --- a/Samples/common/ui/Interfaces/GraphicObject/label.crow +++ b/Samples/common/ui/Interfaces/Widget/label.crow diff --git a/Samples/common/ui/Interfaces/GraphicObject/textBox.crow b/Samples/common/ui/Interfaces/Widget/textBox.crow index 2094de4b..2094de4b 100644 --- a/Samples/common/ui/Interfaces/GraphicObject/textBox.crow +++ b/Samples/common/ui/Interfaces/Widget/textBox.crow diff --git a/Samples/common/ui/templates/testWindow.goml.sav b/Samples/common/ui/templates/testWindow.goml.sav index 42b4b744..268f7af4 100644 --- a/Samples/common/ui/templates/testWindow.goml.sav +++ b/Samples/common/ui/templates/testWindow.goml.sav @@ -7,7 +7,7 @@ <HorizontalStack Width="0" Height="-1" Margin="10" Background="BlueCrayola"> <Checkbox Height="-1" Width="80"/> - <GraphicObject Width="0"/> + <Widget Width="0"/> <Checkbox Height="-1" Width="80"/> </HorizontalStack> <Groupbox Text="test" Height="-1" Width="-1" Margin="5"> |