From 64ff340ec1aa5c46de7a1ca78b2ff66a93f514b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Mon, 15 Feb 2021 21:04:06 +0100 Subject: [PATCH] button enabled state with command change, TextChange.reverse, label.getX in any case, register sizing in widget visible state change --- Crow/src/Text/TextChange.cs | 3 +++ Crow/src/Widgets/Button.cs | 4 +++- Crow/src/Widgets/Label.cs | 4 ++-- Crow/src/Widgets/Widget.cs | 7 +++---- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Crow/src/Text/TextChange.cs b/Crow/src/Text/TextChange.cs index 636c732b..deecc5e5 100644 --- a/Crow/src/Text/TextChange.cs +++ b/Crow/src/Text/TextChange.cs @@ -16,5 +16,8 @@ namespace Crow.Text Length = length; ChangedText = changedText; } + public TextChange Inverse (string src) + => new TextChange (Start, string.IsNullOrEmpty (ChangedText) ? 0 : ChangedText.Length, + Length == 0 ? "" : src.AsSpan (Start, Length).ToString ()); } } diff --git a/Crow/src/Widgets/Button.cs b/Crow/src/Widgets/Button.cs index ce514ce0..b7b9326b 100644 --- a/Crow/src/Widgets/Button.cs +++ b/Crow/src/Widgets/Button.cs @@ -113,8 +113,10 @@ namespace Crow void Command_ValueChanged (object sender, ValueChangeEventArgs e) { string mName = e.MemberName; - if (mName == "CanExecute") + if (mName == "CanExecute") { mName = "IsEnabled"; + RegisterForRedraw (); + } NotifyValueChanged (mName, e.NewValue); } diff --git a/Crow/src/Widgets/Label.cs b/Crow/src/Widgets/Label.cs index 9429a516..9183f7d8 100644 --- a/Crow/src/Widgets/Label.cs +++ b/Crow/src/Widgets/Label.cs @@ -417,7 +417,7 @@ namespace Crow } RectangleD lineRect = new RectangleD ( - Width.IsFit && !Multiline ? cb.X : (int)getX (cb.Width, lines[i]) + cb.X, + (int)getX (cb.Width, lines[i]) + cb.X, y + cb.Top, lines[i].LengthInPixel, lineHeight); if (encodedBytes > 0) { @@ -535,7 +535,7 @@ namespace Crow return; TextLine ls = lines[loc.Line]; ReadOnlySpan curLine = _text.GetLine (ls); - double cPos = Width.IsFit && !Multiline ? 0 : getX (clientWidth, ls); + double cPos = getX (clientWidth, ls); if (loc.Column >= 0) { //int encodedBytes = Crow.Text.Encoding2.ToUtf8 (curLine.Slice (0, loc.Column), bytes); diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs index 519d7019..8e44759c 100644 --- a/Crow/src/Widgets/Widget.cs +++ b/Crow/src/Widgets/Widget.cs @@ -889,10 +889,9 @@ namespace Crow isVisible = value; - if (Visible) - RegisterForLayouting (LayoutingType.Sizing); - else + if (!Visible) unshownPostActions (); + RegisterForLayouting (LayoutingType.Sizing); NotifyValueChangedAuto (isVisible); } @@ -1846,7 +1845,7 @@ namespace Crow } void paintDisabled(Context gr, Rectangle rb){ gr.Operator = Operator.Xor; - gr.SetSource (0.6, 0.6, 0.6, 0.3); + gr.SetSource (0.1, 0.1, 0.1, 0.8); gr.Rectangle (rb); gr.Fill (); gr.Operator = Operator.Over; -- 2.47.3