]> O.S.I.I.S - jp/crow.git/commitdiff
draw Label in double/RectangleD instead of int/Rectangle
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 5 Feb 2021 00:01:51 +0000 (01:01 +0100)
committerj-p <jp_bruyere@hotmail.com>
Sat, 6 Feb 2021 19:28:02 +0000 (20:28 +0100)
Crow/Default.style
Crow/src/Widgets/Label.cs
Crow/src/Widgets/TextBox.cs

index caf37bb4ab65142be1248e4fe0e03e7f9d6f11df..0dc857635dc66117a9e6fb1d25d7d0dcc4b6cade 100644 (file)
@@ -85,10 +85,10 @@ TextBox {
        Background = "White";
        Foreground = "Black";
        CursorColor = "Black";
-       Selectable = "True";
+       Focusable = "True";
        //Text = "TextBox";
        Margin = "1";
-       MouseCursor = "IBeam";
+       //MouseCursor = "IBeam";
 }
 Menu {
        Margin = "0";
index f22f46e0427af80f9ef46b134a0448a5e59a7e11..e176f8369cb0fb136479c49fd39026e056944873 100644 (file)
@@ -355,7 +355,7 @@ namespace Crow
                protected virtual void drawContent (Context gr) {
                        Rectangle cb = ClientRectangle;
                        fe = gr.FontExtents;
-                       int lineHeight = (int)(fe.Ascent + fe.Descent);
+                       double lineHeight = fe.Ascent + fe.Descent;
 
                        CharLocation selStart = default, selEnd = default;
                        bool selectionNotEmpty = false;
@@ -390,7 +390,7 @@ namespace Crow
 
                                TextExtents extents;
                                Span<byte> bytes = stackalloc byte[128];
-                               int y = cb.Y;
+                               double y = cb.Y;
 
                                for (int i = 0; i < lines.Count; i++) {
                                        if (!cancelLinePrint (lineHeight, y, cb.Height)) {
@@ -409,7 +409,7 @@ namespace Crow
                                                        }
                                                }
 
-                                               Rectangle lineRect = new Rectangle (
+                                               RectangleD lineRect = new RectangleD (
                                                        Width.IsFit && !Multiline ? cb.X : (int)getX (cb.Width, lines[i]) + cb.X,
                                                        y, lines[i].LengthInPixel, lineHeight);
 
@@ -419,27 +419,27 @@ namespace Crow
                                                }
 
                                                if (HasFocus && selectionNotEmpty) {
-                                                       Rectangle selRect = lineRect;
+                                                       RectangleD selRect = lineRect;
                                                        if (_multiline) {
                                                                if (i >= selStart.Line && i <= selEnd.Line) {
                                                                        if (selStart.Line == selEnd.Line) {
-                                                                               selRect.X = (int)selStart.VisualCharXPosition + cb.X;
-                                                                               selRect.Width = (int)(selEnd.VisualCharXPosition - selStart.VisualCharXPosition);
+                                                                               selRect.X = selStart.VisualCharXPosition + cb.X;
+                                                                               selRect.Width = selEnd.VisualCharXPosition - selStart.VisualCharXPosition;
                                                                        } else if (i == selStart.Line) {
-                                                                               int newX = (int)selStart.VisualCharXPosition + cb.X;
-                                                                               selRect.Width -= (newX - selRect.X) - 10;
+                                                                               double newX = selStart.VisualCharXPosition + cb.X;
+                                                                               selRect.Width -= (newX - selRect.X) - 10.0;
                                                                                selRect.X = newX;
                                                                        } else if (i == selEnd.Line) {
-                                                                               selRect.Width = (int)selEnd.VisualCharXPosition - selRect.X;
+                                                                               selRect.Width = selEnd.VisualCharXPosition - selRect.X;
                                                                        } else
-                                                                               selRect.Width += 10;
+                                                                               selRect.Width += 10.0;
                                                                } else {
                                                                        y += lineHeight;
                                                                        continue;
                                                                }
                                                        } else {
-                                                               selRect.X = (int)selStart.VisualCharXPosition + cb.X;
-                                                               selRect.Width = (int)(selEnd.VisualCharXPosition - selStart.VisualCharXPosition);
+                                                               selRect.X = selStart.VisualCharXPosition + cb.X;
+                                                               selRect.Width = selEnd.VisualCharXPosition - selStart.VisualCharXPosition;
                                                        }
 
                                                        gr.SetSource (selBackground);
@@ -467,7 +467,7 @@ namespace Crow
                                (int)Math.Min (Math.Max (0, Math.Floor (mouseLocalPos.Y / (fe.Ascent + fe.Descent))), lines.Count - 1) : 0;
                        hoverLoc = new CharLocation (hoverLine, -1, mouseLocalPos.X);
                }
-               protected virtual bool cancelLinePrint (int lineHeght, int y, int clientHeight) => false;
+               protected virtual bool cancelLinePrint (double lineHeght, double y, int clientHeight) => false;
                RectangleD? textCursor = null;
                internal virtual RectangleD? computeTextCursor (Rectangle cursor) {
                        Rectangle cb = ClientRectangle;
index 632e6ba25a96017fd14f93740a4a105641897e66..fc49df2b838383171e87dfb059346009946b6f46 100644 (file)
@@ -172,7 +172,7 @@ namespace Crow
             base.drawContent (gr);
             gr.Translate (scrollX, scrollY);
         }
-        protected override bool cancelLinePrint (int lineHeght, int y, int clientHeight) =>
+        protected override bool cancelLinePrint (double lineHeght, double y, int clientHeight) =>
             y + lineHeght < scrollY || y - lineHeght > clientHeight + scrollY;
         protected override void updateHoverLocation (Point mouseLocalPos) {
             base.updateHoverLocation (mouseLocalPos + new Point (ScrollX, ScrollY));