]> O.S.I.I.S - jp/crow.git/commitdiff
label: compute correct text cursor when anlign is not left, ColorPicker and num contr...
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 4 Nov 2017 17:01:49 +0000 (18:01 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 4 Nov 2017 17:01:49 +0000 (18:01 +0100)
Templates/ColorPicker.template
src/GraphicObjects/Label.cs
src/GraphicObjects/NumericControl.cs

index cefff59b6584841f4a36d1dcdabb689f6d18ee19..81bb0bd185be440da07ed8f0eeeed21260aa40a3 100755 (executable)
@@ -2,14 +2,14 @@
 <Border Background="{./Background}"    Foreground="{./Foreground}"
                CornerRadius="{./CornerRadius}" BorderWidth="1">
                <HorizontalStack Spacing="0">
-                       <VerticalStack Margin="4">
+                       <VerticalStack Margin="5">
                                <SaturationValueSelector S="{²./S}" V="{²./V}" Focusable="true" Name="colorSelector" Margin="0"
                                        Foreground="{../hueSelector.HueColor}"
-                                       Width="120" Height="120"/>
-                               <HueSelector Hue="{²./H}" Focusable="true" Name="hueSelector" Margin="0" Width="120" Height="20"/>
+                                       Width="128" Height="128"/>
+                               <HueSelector Hue="{²./H}" Focusable="true" Name="hueSelector" Margin="0" Width="128" Height="20"/>
                        </VerticalStack>
-                       <VerticalStack Margin="4" Height="Stretched">
-                               <HorizontalStack Height="Fit" Width="Stretched" Spacing="4">
+                       <VerticalStack Margin="2" Spacing="0">
+                               <HorizontalStack Height="Fit" Width="Stretched" Spacing="2">
                                        <GraphicObject Width="34" Height="21" Background="{./SelectedColor}"/>
                                        <Label Focusable="true" Selectable="true" Width="Stretched" Text="{./HexColor}" />
                                </HorizontalStack>
index 64ee9688c384276c2e6ef1d07acd93026a864794..214e14ed456d4893c4997bbcea79fa35a3255eb6 100644 (file)
@@ -265,6 +265,7 @@ namespace Crow
                {
                        get {
                                return lines [CurrentLine] [CurrentColumn];
+                               //return _currentCol > lines[CurrentLine].Length ? (char)0 : lines [CurrentLine] [CurrentColumn];
                        }
                }
                /// <summary>
@@ -775,6 +776,19 @@ namespace Crow
                        if (CurrentLine >= lines.Count)
                                CurrentLine = lines.Count - 1;
 
+                       switch (TextAlignment) {
+                       case Alignment.Center:
+                       case Alignment.Top:
+                       case Alignment.Bottom:
+                               cPos+= ClientRectangle.Width - gr.TextExtents(lines [CurrentLine]).Width/2.0;
+                               break;
+                       case Alignment.Right:
+                       case Alignment.TopRight:
+                       case Alignment.BottomRight:
+                               cPos += ClientRectangle.Width - gr.TextExtents(lines [CurrentLine]).Width;
+                               break;
+                       }
+
                        for (int i = 0; i < lines[CurrentLine].Length; i++)
                        {
                                string c = lines [CurrentLine].Substring (i, 1);
index 9b511831fdb67ad695da938c3790dafbb4aa2285..8ab60edbc9638b2972d069582ece0a1862d58cbd 100644 (file)
@@ -44,10 +44,24 @@ namespace Crow
 
                #region private fields
                double _actualValue, minValue, maxValue, smallStep, bigStep;
+               int _decimals;
                #endregion
 
                #region public properties
-               [XmlAttributeAttribute()][DefaultValue(0.0)]
+               [XmlAttributeAttribute][DefaultValue(2)]
+               public int Decimals
+               {
+                       get { return _decimals; }
+                       set
+                       {
+                               if (value == _decimals)
+                                       return;
+                               _decimals = value;
+                               NotifyValueChanged("Decimals",  _decimals);
+                               RegisterForGraphicUpdate();
+                       }
+               }
+               [XmlAttributeAttribute][DefaultValue(0.0)]
                public virtual double Minimum {
                        get { return minValue; }
                        set {
@@ -59,7 +73,7 @@ namespace Crow
                                RegisterForRedraw ();
                        }
                }
-               [XmlAttributeAttribute()][DefaultValue(100.0)]
+               [XmlAttributeAttribute][DefaultValue(100.0)]
                public virtual double Maximum
                {
                        get { return maxValue; }
@@ -72,7 +86,7 @@ namespace Crow
                                RegisterForRedraw ();
                        }
                }
-               [XmlAttributeAttribute()][DefaultValue(1.0)]
+               [XmlAttributeAttribute][DefaultValue(1.0)]
                public virtual double SmallIncrement
                {
                        get { return smallStep; }
@@ -85,7 +99,7 @@ namespace Crow
                                RegisterForRedraw ();
                        }
                }
-               [XmlAttributeAttribute()][DefaultValue(5.0)]
+               [XmlAttributeAttribute][DefaultValue(5.0)]
                public virtual double LargeIncrement
                {
                        get { return bigStep; }
@@ -98,7 +112,7 @@ namespace Crow
                                RegisterForRedraw ();
                        }
                }
-               [XmlAttributeAttribute()][DefaultValue(0.0)]
+               [XmlAttributeAttribute][DefaultValue(0.0)]
                public double Value
                {
                        get { return _actualValue; }
@@ -114,6 +128,8 @@ namespace Crow
                                else                    
                                        _actualValue = value;
 
+                               _actualValue = Math.Round (_actualValue, _decimals);
+
                                NotifyValueChanged("Value",  _actualValue);
                                RegisterForGraphicUpdate();
                        }