From: Jean-Philippe Bruyère Date: Sat, 27 Mar 2021 13:12:47 +0000 (+0100) Subject: wip X-Git-Tag: v0.9.5-beta~45 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=983371d5934520e5a29a105e88ce893eaeca3663;p=jp%2Fcrow.git wip --- diff --git a/Crow/Templates/ToolWindow.template b/Crow/Templates/ToolWindow.template index 7840fb30..b0af1c5d 100644 --- a/Crow/Templates/ToolWindow.template +++ b/Crow/Templates/ToolWindow.template @@ -10,10 +10,10 @@ + MouseClick="./onQuitPress"/> - + diff --git a/Crow/Templates/Window.template b/Crow/Templates/Window.template index dee91bcd..a1de29de 100644 --- a/Crow/Templates/Window.template +++ b/Crow/Templates/Window.template @@ -19,7 +19,7 @@ + MouseClick="./onQuitPress"/> diff --git a/Crow/src/IML/BindingMember.cs b/Crow/src/IML/BindingMember.cs index 0678fb32..2f96f131 100644 --- a/Crow/src/IML/BindingMember.cs +++ b/Crow/src/IML/BindingMember.cs @@ -56,7 +56,7 @@ namespace Crow.IML /// /// Target the template's root node, expression was in the form './name[.name[...]]' or '/name[.name[...]]' /// - public bool IsTemplateBinding { get { return LevelsUp < 0; }} + public bool IsTemplateBinding => LevelsUp < 0; /// /// No level change and expression was '.name' @@ -70,7 +70,7 @@ namespace Crow.IML /// /// no level change, and only a single name in Tokens[], that's dataSource member if property binding /// - public bool IsSingleName { get { return LevelsUp == 0 && Tokens.Length == 1; }} + public bool IsSingleName => LevelsUp == 0 && Tokens.Length == 1; #region CTOR /// diff --git a/Crow/src/Widgets/ColorPicker.cs b/Crow/src/Widgets/ColorPicker.cs index 4f5c0539..3ea8b547 100644 --- a/Crow/src/Widgets/ColorPicker.cs +++ b/Crow/src/Widgets/ColorPicker.cs @@ -33,8 +33,12 @@ namespace Crow NotifyValueChanged ("CurrentColor2", Color.FromHSV (currentColor.Hue, currentColor.Value, currentColor.Saturation, currentColor.A)); } } + public IList AvailableColors => //Enum.GetValues (typeof (Color)).ToList ();// Colors. ColorDic.Values.OrderBy (c => c.Hue).ToList (); + FastEnumUtility.FastEnum.GetValues ().ToList (); - //public IList ColorList => Enum.GetValues (typeof (Color)).ToList ();// Colors. ColorDic.Values.OrderBy (c => c.Hue).ToList (); + public void onSelectedItemChanged(object sender, SelectionChangeEventArgs e) { + CurrentColor = (Color)(Colors)e.NewValue; + } } } diff --git a/Crow/src/Widgets/Popper.cs b/Crow/src/Widgets/Popper.cs index 99b3ef7d..e99bbcbc 100644 --- a/Crow/src/Widgets/Popper.cs +++ b/Crow/src/Widgets/Popper.cs @@ -193,7 +193,7 @@ namespace Crow public virtual void onPop(object sender, EventArgs e) { if (Content != null) { - Content.Visible = true; + Content.IsVisible = true; if (Content.Parent == null) IFace.AddWidget (Content); //if (Content.LogicalParent != this) @@ -206,7 +206,7 @@ namespace Crow public virtual void onUnpop(object sender, EventArgs e) { if (Content != null) { - Content.Visible = false; + Content.IsVisible = false; } Unpoped.Raise (this, e); } diff --git a/Crow/src/Widgets/TabView2.cs b/Crow/src/Widgets/TabView2.cs new file mode 100644 index 00000000..43c6f8c9 --- /dev/null +++ b/Crow/src/Widgets/TabView2.cs @@ -0,0 +1,17 @@ +// Copyright (c) 2013-2020 Jean-Philippe Bruyère +// +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + +namespace Crow +{ + public class TabView2 : TemplatedGroup + { + #region CTOR + protected TabView2 () {} + public TabView2 (Interface iface, string style = null) : base (iface, style) { } + #endregion + + + } +} + diff --git a/Crow/src/Widgets/TextBox.cs b/Crow/src/Widgets/TextBox.cs index 68bcffca..dddcdfb1 100644 --- a/Crow/src/Widgets/TextBox.cs +++ b/Crow/src/Widgets/TextBox.cs @@ -312,7 +312,7 @@ namespace Crow } #endregion - void update (TextChange change) { + protected void update (TextChange change) { lock (linesMutex) { Span tmp = stackalloc char[Text.Length + (change.ChangedText.Length - change.Length)]; //Console.WriteLine ($"{Text.Length,-4} {change.Start,-4} {change.Length,-4} {change.ChangedText.Length,-4} tmp:{tmp.Length,-4}"); diff --git a/Crow/src/Widgets/Window.cs b/Crow/src/Widgets/Window.cs index 374b67d2..e18c1d77 100644 --- a/Crow/src/Widgets/Window.cs +++ b/Crow/src/Widgets/Window.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2013-2019 Bruyère Jean-Philippe jp_bruyere@hotmail.com +// Copyright (c) 2013-2021 Bruyère Jean-Philippe jp_bruyere@hotmail.com // // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) @@ -26,8 +26,7 @@ namespace Crow string _icon; bool resizable; bool movable; - bool modal; - protected bool hoverBorder = false; + bool modal; bool alwaysOnTop = false; Rectangle savedBounds; @@ -77,7 +76,7 @@ namespace Crow #region public properties [DefaultValue("#Crow.Icons.crow.svg")] public string Icon { - get { return _icon; } + get => _icon; set { if (_icon == value) return; @@ -87,9 +86,7 @@ namespace Crow } [DefaultValue(true)] public bool Resizable { - get { - return resizable; - } + get => resizable; set { if (resizable == value) return; @@ -99,9 +96,7 @@ namespace Crow } [DefaultValue(true)] public bool Movable { - get { - return movable; - } + get => movable; set { if (movable == value) return; @@ -111,9 +106,7 @@ namespace Crow } [DefaultValue(false)] public bool Modal { - get { - return modal; - } + get => modal; set { if (modal == value) return; @@ -123,28 +116,23 @@ namespace Crow } [DefaultValue(false)] public bool IsMinimized { - get { return _minimized; } + get => _minimized; set{ if (value == IsMinimized) return; _minimized = value; - _contentContainer.Visible = !_minimized; + _contentContainer.IsVisible = !_minimized; NotifyValueChangedAuto (_minimized); } } - [XmlIgnore]public bool IsMaximized { - get { return Width == Measure.Stretched & Height == Measure.Stretched & !_minimized; } - } - [XmlIgnore]public bool IsNormal { - get { return !(IsMaximized|_minimized); } - } + [XmlIgnore]public bool IsMaximized => + Width == Measure.Stretched & Height == Measure.Stretched & !_minimized; + [XmlIgnore]public bool IsNormal => !(IsMaximized|_minimized); [DefaultValue(false)] public bool AlwaysOnTop { - get { - return modal ? true : alwaysOnTop; - } + get => modal ? true : alwaysOnTop; set { if (alwaysOnTop == value) return; @@ -385,7 +373,7 @@ namespace Crow Minimize.Raise (sender, e); } - protected void butQuitPress (object sender, MouseButtonEventArgs e) + public void onQuitPress (object sender, MouseButtonEventArgs e) { IFace.MouseCursor = MouseCursor.top_left_arrow; close (); diff --git a/Samples/ShowCase/Editor.cs b/Samples/ShowCase/Editor.cs new file mode 100644 index 00000000..315a5a9d --- /dev/null +++ b/Samples/ShowCase/Editor.cs @@ -0,0 +1,44 @@ +// Copyright (c) 2013-2019 Bruyère Jean-Philippe +// +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + +using System; +using Glfw; +using Crow.Text; + +namespace Crow +{ + public class Editor : TextBox { + public override void onKeyDown(object sender, KeyEventArgs e) + { + TextSpan selection = Selection; + if (e.Key == Key.Tab && !selection.IsEmpty) { + int lineStart = lines.GetLocation (selection.Start).Line; + int lineEnd = lines.GetLocation (selection.End).Line; + + if (IFace.Shift) { + for (int l = lineStart; l <= lineEnd; l++) { + if (Text[lines[l].Start] == '\t') + update (new TextChange (lines[l].Start, 1, "")); + else if (Char.IsWhiteSpace (Text[lines[l].Start])) { + int i = 1; + while (i < lines[l].Length && i < Interface.TAB_SIZE && Char.IsWhiteSpace (Text[i])) + i++; + update (new TextChange (lines[l].Start, i, "")); + } + } + + }else{ + for (int l = lineStart; l <= lineEnd; l++) + update (new TextChange (lines[l].Start, 0, "\t")); + } + + selectionStart = new CharLocation (lineStart, 0); + CurrentLoc = new CharLocation (lineEnd, lines[lineEnd].Length); + + return; + } + base.onKeyDown(sender, e); + } + } +} \ No newline at end of file diff --git a/Samples/ShowCase/ui/showcase.crow b/Samples/ShowCase/ui/showcase.crow index 5b0e467c..3d589b3d 100644 --- a/Samples/ShowCase/ui/showcase.crow +++ b/Samples/ShowCase/ui/showcase.crow @@ -29,8 +29,9 @@