]> O.S.I.I.S - jp/crow.git/commitdiff
ScrollBar derived from NumericControl
authorjpbruyere <jp.bruyere@hotmail.com>
Fri, 5 Feb 2016 15:36:08 +0000 (16:36 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Fri, 5 Feb 2016 15:36:08 +0000 (16:36 +0100)
Templates/ScrollBar.goml
Templates/ScrollingListBox.goml
Tests/GOLIBTests.cs
Tests/Interfaces/testColorList.crow
Tests/Interfaces/testScrollbar.goml
src/GraphicObjects/ScrollBar.cs

index 95271b5e7aa9c338b7887dd6a199c1ddb1024ecc..b643c36bd939de68b5e6c7a5265e92ef2038acfc 100755 (executable)
@@ -6,9 +6,14 @@
                        Template="#Crow.Templates.ArrowButTemplate.crow">
                        <Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="up"/>
                </Button>
-               <Slider Name="Slider" Value="{../../../Scroll}" Maximum="{../../../MaximumScroll}"
+               <Slider Name="Slider"
+                       Orientation="{../../../Orientation}"
+                       Value="{../../../Value}"
+                       Maximum="{../../../Maximum}"
+                       LargeIncrement="{../../../LargeIncrement}"
+                       SmallIncrement="{../../../SmallIncrement}"
                        Background="hgradient|0:DimGray|0,1:Gray|0,95:Gray|1:White"
-                       Width="{../../../TemplatedWidth}" Height="{../../../TemplatedHeight}" Orientation="{../../../Orientation}"
+                       Width="{../../../TemplatedWidth}" Height="{../../../TemplatedHeight}"
                        ValueChanged="../../../onSliderValueChange"/>
                <Button MouseRepeat="true" Width="12" Height="12" MouseClick="../../../onScrollForth"
                        Template="#Crow.Templates.ArrowButTemplate.crow">
index 0c92dcf6b402ddbedef523e1b035ddd499a8a70f..db0973d8e0d005252bcaa22ecc8b53803a5c067a 100644 (file)
@@ -2,12 +2,12 @@
 <Border BorderWidth="1" MinimumSize="20;20" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}">
        <HorizontalStack Margin="1" Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}">
                <Scroller Name="scroller1" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}" 
-                               Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Scroll}">
+                               Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}">
                        <VerticalStack Width="{../../../../TemplatedWidth}" Height="-1" 
                                Name="List" Margin="0" VerticalAlignment="Top" />
                </Scroller>
-               <ScrollBar Name="scrollbar1" Scroll="{../scroller1.ScrollY}" 
-                       MaximumScroll="{../scroller1.MaximumScroll}" Orientation="Vertical" 
+               <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}" 
+                       Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical" 
                        Width="10" Height="{../../../TemplatedHeight}" />
        </HorizontalStack>
 </Border>
\ No newline at end of file
index 026ce11d70a78def71aa23a0c1ed4f25947c5d26..1ac9bdc3be0a33190498e084eff7c142993eac5f 100644 (file)
@@ -37,6 +37,7 @@ namespace test
                int frameCpt = 0;
                int idx = 0;
                string[] testFiles = {
+                       "testScrollbar.goml",
                        "4.crow",
                        "testColorList.crow",
                        "testGroupBox.goml",
@@ -52,7 +53,6 @@ namespace test
                        "testTextBox.crow",
                        "testImage.crow",
                        "test4.goml",
-                       "testScrollbar.goml",
                        "2.crow",
                        "test1.goml",
                        "testWindow2.goml",
index a38e899de482e854f0dda4fb4d24541bc6a38d27..a39547f3a37595fa74b38e39cc88b955ccba8a31 100755 (executable)
@@ -8,12 +8,12 @@
                                <Border BorderWidth="1" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}">
                                        <HorizontalStack Margin="1" Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}" >
                                                <Scroller Name="scroller1" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}" 
-                                                               Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Scroll}">
+                                                               Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}">
                                                        <VerticalStack Width="{../../../../TemplatedWidth}" Height="-1" MinimumSize="100;100"
                                                                Name="List" Margin="0" VerticalAlignment="Top" />
                                                </Scroller>
-                                               <ScrollBar Name="scrollbar1" Scroll="{../scroller1.ScrollY}" 
-                                                       MaximumScroll="{../scroller1.MaximumScroll}" Orientation="Vertical" 
+                                               <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}" 
+                                                       Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical" 
                                                        Width="14" Height="{../../../TemplatedHeight}" />
                                        </HorizontalStack>
                                </Border>
index 5d522dc6dc8e5dadaa0bfb960a3ba7a3145103f3..ef08abb717abc08c06e4225d5402731557b25359 100755 (executable)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
 <Group Name="TopContainer" Width="400" Height="400"
        Focusable="True" Background="Gray">
-       <ScrollBar Height="0" Orientation="Vertical" Width="16" MaximumScroll="100"/>
+       <ScrollBar Height="0" Orientation="Vertical" Width="16" Maximum="100"/>
 </Group>
\ No newline at end of file
index 3e0954574aaa88465f0b2b3cf1b54003d68923fe..dddd441e7316549aee2efd486b54be80e66b1cf9 100644 (file)
@@ -17,50 +17,18 @@ using System.ComponentModel;
 namespace Crow
 {
        [DefaultTemplate("#Crow.Templates.ScrollBar.goml")]
-       public class ScrollBar : TemplatedControl
+       public class ScrollBar : NumericControl
        {
                Orientation _orientation;
-               Slider _slider;
-               double _maximumScroll;
-               double _scroll;
 
-               public ScrollBar() : base()
-               {
-               }       
-
-               protected override void loadTemplate(GraphicObject template = null)
-               {                       
-                       base.loadTemplate (template);
-                       _slider = this.child.FindByName ("Slider") as Slider;
-               }
+               #region CTOR
+               public ScrollBar() : base()     {}
+               #endregion
 
                [XmlAttributeAttribute()][DefaultValue(0.0)]
-               public virtual double MaximumScroll
-               {
-                       get { return _maximumScroll; }
-                       set {
-                               if (_maximumScroll == value)
-                                       return;
-                               _maximumScroll = value;
-                               registerForGraphicUpdate ();
-                               NotifyValueChanged ("MaximumScroll", _maximumScroll);
-                       }
-               }
-               [XmlAttributeAttribute()][DefaultValue(0.0)]
-               public virtual double Scroll
-               {
-                       get { return _scroll; }
-                       set {
-                               if (_scroll == value)
-                                       return;
-                               _scroll = value;
-                               if (_scroll < 0.0)
-                                       _scroll = 0.0;
-                               else if (_scroll > _maximumScroll)
-                                       _scroll = _maximumScroll;
-                               registerForGraphicUpdate ();
-                               NotifyValueChanged ("Scroll", _scroll);
-                       }
+               public override double Maximum {
+                       get { return base.Maximum; }
+                       set { base.Maximum = value; }
                }
                [XmlAttributeAttribute()][DefaultValue(Orientation.Vertical)]
                public virtual Orientation Orientation
@@ -76,17 +44,16 @@ namespace Crow
                }
                public void onScrollBack (object sender, MouseButtonEventArgs e)
                {
-                       Scroll -= 50;
+                       Value -= SmallIncrement;
                }
                public void onScrollForth (object sender, MouseButtonEventArgs e)
                {
-                       Scroll += 50;
-
+                       Value += SmallIncrement;
                }
 
                public void onSliderValueChange(object sender, ValueChangeEventArgs e){
                        if (e.MemberName == "Value")
-                               Scroll = Convert.ToDouble(e.NewValue);
+                               Value = Convert.ToDouble(e.NewValue);
                }
        }
 }