]> O.S.I.I.S - jp/crow.git/commitdiff
scroller x, ide wip
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 14 Mar 2018 20:42:59 +0000 (21:42 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 14 Mar 2018 20:42:59 +0000 (21:42 +0100)
23 files changed:
CrowIDE/CrowIDE.csproj
CrowIDE/src/CrowIDE.cs
CrowIDE/src/Editors/ImlVisualEditor.cs
CrowIDE/src/Editors/SourceEditor.cs
CrowIDE/ui/CrowIDE.crow
CrowIDE/ui/DockWindows/winDesign.crow [new file with mode: 0644]
CrowIDE/ui/ItemTemplates/Enum.template
CrowIDE/ui/MembersView.template
CrowIDE/ui/editors/IMLEdit.itemp
CrowIDE/ui/editors/SourceEditor.crow
Templates/ComboBox.template
Templates/FileDialog.template
Templates/ListBox.template
Templates/ScrollingListBox.template
Templates/TreeView.template
Tests/Interfaces/Divers/clip4.crow
Tests/Interfaces/Divers/welcome.crow
Tests/Interfaces/TemplatedControl/testItemTemplateTag.crow
Tests/Interfaces/Wrapper/2.2.crow
Tests/ui/showcase.crow
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Scroller.cs
src/GraphicObjects/Slider.cs

index 51f6debed3322b9dd33b9bb23ee4365aa41b2f9e..1cae7289c95a09b3ad0899e9c7a0ef6902841203 100644 (file)
     </EmbeddedResource>
     <EmbeddedResource Include="ui\DockWindows\winStyleView.crow" />
     <EmbeddedResource Include="ui\CategoryExp.template" />
+    <EmbeddedResource Include="ui\DockWindows\winDesign.crow" />
   </ItemGroup>
   <ItemGroup>
     <None Include="ui\test.crow">
index 94bec4a435462e51be90b898c5dd5c18239dd5f6..3850a865f8930fb87d7fa3d5245225e8f77148b7 100644 (file)
@@ -42,7 +42,7 @@ namespace Crow.Coding
                CMDUndo, CMDRedo, CMDCut, CMDCopy, CMDPaste, CMDHelp,
                CMDAbout, CMDOptions,
                CMDViewGTExp, CMDViewProps, CMDViewProj, CMDViewProjProps, CMDViewErrors, CMDViewSolution, CMDViewEditor, CMDViewProperties,
-               CMDViewToolbox, CMDViewSchema, CMDViewStyling,
+               CMDViewToolbox, CMDViewSchema, CMDViewStyling,CMDViewDesign,
                CMDCompile;
 
                void initCommands () {
@@ -70,6 +70,8 @@ namespace Crow.Coding
                        { Caption = "Editor Pane"};
                        CMDViewProperties = new Command(new Action(() => loadDockWindow ("#Crow.Coding.ui.DockWindows.winProperties.crow")))
                        { Caption = "Properties"};
+                       CMDViewDesign = new Command(new Action(() => loadDockWindow ("#Crow.Coding.ui.DockWindows.winDesign.crow")))
+                       { Caption = "Quick Design", CanExecute = true};
                        CMDViewToolbox = new Command(new Action(() => loadDockWindow ("#Crow.Coding.ui.DockWindows.winToolbox.crow")))
                        { Caption = "Toolbox", CanExecute = false};
                        CMDViewSchema = new Command(new Action(() => loadDockWindow ("#Crow.Coding.ui.DockWindows.winSchema.crow")))
index 59a8043030932db876a1fd021d6a26653d530602..3ccf62783b95d819e3305a6c6aa645d29d7e9acd 100644 (file)
@@ -58,7 +58,9 @@ namespace Crow.Coding
                Measure designWidth, designHeight;
                bool updateEnabled;
 
-               SvgPicture icoMove, icoStyle;
+               Picture icoMove, icoStyle;
+               Rectangle rIcons = default(Rectangle);
+               Size iconSize = new Size(10,10);
 
                public List<Crow.Command> Commands;
                Crow.Command cmdDelete;
@@ -72,8 +74,8 @@ namespace Crow.Coding
                void initIcons () {
                        icoMove = new SvgPicture ();
                        icoMove.Load (IFace, "#Crow.Coding.icons.move-arrows.svg");
-                       icoStyle = new SvgPicture ();
-                       icoStyle.Load (IFace, "#Crow.Coding.icons.palette.svg");
+//                     icoStyle = new SvgPicture ();
+//                     icoStyle.Load (IFace, "#Crow.Coding.icons.palette.svg");
                }
 
                [DefaultValue(true)]
@@ -283,6 +285,10 @@ namespace Crow.Coding
                }
                protected override void updateCheckPostProcess ()
                {
+                       if (Error != null) {
+                               RegisterForRedraw ();
+                               return;
+                       }
                        imlVE.Update ();
                        bool isDirty = false;
 
@@ -375,8 +381,6 @@ namespace Crow.Coding
                        }
 
                }
-               Rectangle rIcons = default(Rectangle);
-               Size iconSize = new Size(10,10);
 
                protected override void onDraw (Cairo.Context gr)
                {
@@ -411,9 +415,6 @@ namespace Crow.Coding
                                Foreground.SetAsSource (gr, cb);
                                gr.Stroke ();
                        }
-                       gr.SetSourceColor (Color.Black);
-                       gr.Rectangle (cb, 1.0 / z);
-                       gr.Stroke ();
 
                        lock (imlVE.RenderMutex) {
                                using (Cairo.Surface surf = new Cairo.ImageSurface (imlVE.bmp, Cairo.Format.Argb32,
@@ -423,6 +424,15 @@ namespace Crow.Coding
                                }
                                imlVE.IsDirty = false;
                        }
+                       if (Error == null) {
+                               gr.SetSourceColor (Color.Black);
+                               gr.Rectangle (cb, 1.0 / z);
+                       } else {
+                               gr.SetSourceColor (Color.LavenderBlush);
+                               gr.Rectangle (cb, 2.0 / z);
+                               drawCenteredTextLine(gr, cb.Center, Error.InnerException?.Message);
+                       }
+                       gr.Stroke ();
 
                        Rectangle hr;
 
@@ -481,7 +491,7 @@ namespace Crow.Coding
                        gr.Restore ();
                }
 
-               void drawIcon (Context gr, SvgPicture pic, Rectangle r) {
+               void drawIcon (Context gr, Picture pic, Rectangle r) {
 //                     gr.SetSourceColor (Color.Black);
 //                     CairoHelpers.CairoRectangle (gr, r.Inflated (1), 2, 1.0);
                        gr.SetSourceColor (Color.White);
@@ -544,6 +554,9 @@ namespace Crow.Coding
                        gr.Operator = Operator.Over;                    
                }
 
+               void drawCenteredTextLine (Context gr, Point center, string txt){
+                       drawCenteredTextLine (gr, new PointD(center.X,center.Y), txt);
+               }
                void drawCenteredTextLine (Context gr, PointD center, string txt){
                        FontExtents fe = gr.FontExtents;
                        TextExtents te = gr.TextExtents (txt);
@@ -855,84 +868,6 @@ namespace Crow.Coding
                        return false;
 
                }
-//             public bool ProcessMouseMove(int x, int y)
-//             {
-//                     int deltaX = x - imlVE.Mouse.X;
-//                     int deltaY = y - imlVE.Mouse.Y;
-//                     imlVE.Mouse.X = x;
-//                     imlVE.Mouse.Y = y;
-//                     MouseMoveEventArgs e = new MouseMoveEventArgs (x, y, deltaX, deltaY);
-//                     e.Mouse = imlVE.Mouse;
-//
-//                     if (imlVE.ActiveWidget != null) {
-//                             //TODO, ensure object is still in the graphic tree
-//                             //send move evt even if mouse move outside bounds
-//                             WidgetMouseMove (imlVE.ActiveWidget, e);
-//                             return true;
-//                     }
-//
-//                     if (HoverWidget != null) {
-//                             //TODO, ensure object is still in the graphic tree
-//                             //check topmost graphicobject first
-//                             GraphicObject tmp = HoverWidget;
-//                             GraphicObject topc = null;
-//                             while (tmp is GraphicObject) {
-//                                     topc = tmp;
-//                                     tmp = tmp.LogicalParent as GraphicObject;
-//                             }
-//                             int idxhw = imlVE.GraphicTree.IndexOf (topc);
-//                             if (idxhw != 0) {
-//                                     int i = 0;
-//                                     while (i < idxhw) {                                             
-//                                             if (GraphicTree [i].MouseIsIn (e.Position)) {
-//                                                     while (HoverWidget != null) {
-//                                                             WidgetMouseLeave (imlVE.HoverWidget, e);
-//                                                             HoverWidget = HoverWidget.focusParent;
-//                                                     }
-//
-//                                                     GraphicTree [i].checkHoverWidget (e);
-//                                                     WidgetMouseMove (imlVE.HoverWidget, e);
-//                                                     return true;
-//                                             }
-//                                             i++;
-//                                     }
-//                             }
-//
-//
-//                             if (imlVE.HoverWidget.MouseIsIn (e.Position)) {
-//                                     WidgetCheckOver (imlVE.HoverWidget, (e));
-//                                     WidgetMouseMove (imlVE.HoverWidget, e);
-//                                     return true;
-//                             } else {
-//                                     WidgetMouseLeave (imlVE.HoverWidget, e);
-//                                     //seek upward from last focused graph obj's
-//                                     while (imlVE.HoverWidget.focusParent != null) {
-//                                             imlVE.HoverWidget = imlVE.HoverWidget.LogicalParent as GraphicObject;
-//                                             if (imlVE.HoverWidget.MouseIsIn (e.Position)) {
-//                                                     WidgetCheckOver (imlVE.HoverWidget, e);
-//                                                     WidgetMouseMove (imlVE.HoverWidget, e);
-//                                                     return true;
-//                                             } else
-//                                                     WidgetMouseLeave (imlVE.HoverWidget, e);
-//                                     }
-//                             }
-//                     }
-//
-//                     //top level graphic obj's parsing
-//                     lock (imlVE.GraphicTree) {
-//                             for (int i = 0; i < imlVE.GraphicTree.Count; i++) {
-//                                     GraphicObject g = imlVE.GraphicTree [i];
-//                                     if (g.MouseIsIn (e.Position)) {
-//                                             WidgetCheckOver (g, e);
-//                                             WidgetMouseMove (imlVE.HoverWidget, e);
-//                                             return true;
-//                                     }
-//                             }
-//                     }
-//                     imlVE.HoverWidget = null;
-//                     return false;
-//
-//             }
 
                void GTView_SelectedItemChanged (object sender, SelectionChangeEventArgs e)
                {
index 2fcdc2bd52d4da403c6ab72d57abc84fe5f79981..724def34fa05ed67a4a4276d20053c1ec4f6ab84 100644 (file)
@@ -894,7 +894,8 @@ namespace Crow.Coding
                                if (hoverLine == value)
                                        return;
                                hoverLine = value;
-                               NotifyValueChanged ("HoverLine", hoverLine);                            
+                               NotifyValueChanged ("HoverLine", hoverLine);
+                               NotifyValueChanged ("HoverError", buffer [hoverLine].exception);
                        }
                }
                void updateHoverLine () {
index 9e1b110e2ce3d073cff080f265828824d36a9dd9..7fe511f1936676e6864c59ddc561c188a5599849 100644 (file)
@@ -22,6 +22,7 @@
                                <MenuItem Command="{CMDViewSolution}"/>
                                <MenuItem Command="{CMDViewEditor}"/>
                                <MenuItem Command="{CMDViewProperties}"/>
+                               <MenuItem Command="{CMDViewDesign}"/>
                                <MenuItem Command="{CMDViewStyling}"/>
                                <MenuItem Command="{CMDViewToolbox}"/>
                                <MenuItem Command="{CMDViewErrors}"/>
diff --git a/CrowIDE/ui/DockWindows/winDesign.crow b/CrowIDE/ui/DockWindows/winDesign.crow
new file mode 100644 (file)
index 0000000..4b5125b
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<DockWindow DataSource="{CurrentSolution}" Name="winDesign" Caption="Design" Width="200" Height="50%">
+       <VerticalStack DataSource="{SelectedItemElement}">
+               <ColorPicker SelectedColor="{²Background}"/>
+               <Group Fit="true">
+                       <Border Foreground="Black" Left="25" Top="12" Width="34" Height="21" Background="{Background}"/>
+                       <Border Foreground="Black" Left="1" Top="1" Width="34" Height="21" Background="{Foreground}"/>
+               </Group>
+       </VerticalStack>
+</DockWindow>
index 1df1c7a0bcb680632f02adabc8c5932f0211ee4b..701217c73c49f93c1138a40a859295154322d2ed 100755 (executable)
@@ -23,7 +23,7 @@
                                </Template>
                                <Border Background="White" BorderWidth="1" Margin="1" Foreground="Black"
                                        MinimumSize="{../../MinimumPopupSize}" Fit="true">
-                                       <Scroller Name="scroller1" Margin="2" VerticalScrolling="true"
+                                       <Scroller Name="scroller1" Margin="2" 
                                                MaximumSize="0,200"
                                                HorizontalAlignment="Left">
                                                <VerticalStack LayoutChanged="../../../../_list_LayoutChanged"
index 07938b0e9e99f26cfe10be93dea1bc6d4c3fc186..49f4e190eaa9818efc394f4f04ec002f7107bed2 100755 (executable)
@@ -4,7 +4,7 @@
                <Label TextAlignment="Left" Text="{./SelectedItemName}" Width="Stretched"/>
        </Border>
        <HorizontalStack>
-               <Scroller  Name="scroller1" Margin="1" VerticalScrolling="true"
+               <Scroller  Name="scroller1" Margin="1" 
                        Background="{./Background}"
                        ScrollY="{../scrollbar1.Value}">
                        <VerticalStack Spacing="1"
index fa7efb5d5d4cbe833554549cf76f3723aef390d4..85944b8e40d8f057fb554ed61725a14a4072fe27 100644 (file)
@@ -4,23 +4,18 @@
                <HorizontalStack Height="Fit" Margin="2" Background="DimGray" Spacing="5">
                        <HorizontalStack Width="Fit" Spacing="1">
                                <Label Text="Design Size:"/>
-                               <TextBox Text="{²../../../editor.DesignWidth}" Width="50" TextAlignment="Right"/>
+                               <TextBox Text="{²../../../editor.DesignWidth}" Width="40" TextAlignment="Right"/>
                                <Label Text="X"/>
-                               <TextBox Text="{²../../../editor.DesignHeight}" Width="50" TextAlignment="Right"/>
+                               <TextBox Text="{²../../../editor.DesignHeight}" Width="40" TextAlignment="Right"/>
                        </HorizontalStack>
                        <HorizontalStack Width="Fit" Spacing="1">
                                <Label Text="Zoom:"/>
-                               <Slider Value="{²../../../editor.Zoom}" Width="150" Height="10" Minimum="10" Maximum="400" SmallIncrement="5" LargeIncrement="50"/>
+                               <Slider Value="{²../../../editor.Zoom}" Width="100" Height="10" Minimum="10" Maximum="200" SmallIncrement="10" LargeIncrement="50"/>
                                <Label Text="{../../../editor.Zoom}"/>
                        </HorizontalStack>
-                       <HorizontalStack Width="Fit" Spacing="1">                               
-                               <Label Text="{../../../editor.Width}"/>
-                               <Label Text="X"/>
-                               <Label Text="{../../../editor.Height}"/>
-                       </HorizontalStack>
                        <HorizontalStack Width="Fit" Spacing="1">
                                <Label Text="Grid Spacing:"/>
-                               <Slider Value="{²../../../editor.GridSpacing}" Width="200" Height="10" Minimum="5" Maximum="100" SmallIncrement="5" LargeIncrement="20"/>
+                               <Slider Value="{²../../../editor.GridSpacing}" Width="100" Height="10" Minimum="5" Maximum="100" SmallIncrement="5" LargeIncrement="20"/>
                                <TextBox Text="{../../../editor.GridSpacing}"/>
                        </HorizontalStack>
                </HorizontalStack>
@@ -28,7 +23,7 @@
                <VerticalStack Height="60%" Width="Stretched" Margin="0" MinimumSize="10,10">
                        <HorizontalStack>
                                <Scroller Name="scroller1" 
-                                               Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}">
+                                               Margin="2" ScrollY="{../scrollbar1.Value}">
                                        <ImlVisualEditor  Foreground="SkyBlue" Name="editor" Background="Gray"                                          
                                                VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10"
                                                Width="512" Height="512" ContextCommands="{/Commands}"
                                                UpdateEnabled="{../../../../../IsSelected}"
                                                ProjectNode="{}" SelectedItem="{²SelectedItem}"/>
                                </Scroller>
-                               <ScrollBar Name="scrollbar1" Value="{²../scroller1.ScrollY}"
-                                       LargeIncrement="{../scroller1.PageHeight}" SmallIncrement="30" CursorSize="{../scroller1.ChildHeightRatio}"
-                                       Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical" 
+                               <ScrollBar Name="scrollbar1" Orientation="Vertical"
+                                       Value="{²../scroller1.ScrollY}"        Maximum="{../scroller1.MaxScrollY}" 
+                                       CursorSize="{../scroller1.ChildHeightRatio}"
+                                       LargeIncrement="{../scroller1.PageHeight}" SmallIncrement="30"
                                        Width="14" />
                        </HorizontalStack>
-                       <!--<ScrollBar Style="HScrollBar" Name="scrollbarX" Value="{²../scroller1.ScrollX}"
-                                       Maximum="{../scroller1.MaxScrollX}" Orientation="Horizontal"
-                                       LargeIncrement="{../editor.VisibleColumns}"
-                                       CursorSize="{../editor.ChildWidthRatio}"
-                                       Height="14" />-->
+                       <ScrollBar Style="HScrollBar" Name="scrollbarX" Orientation="Horizontal"
+                                       Value="{²../scroller1.ScrollX}" Maximum="{../scroller1.MaxScrollX}" 
+                                       CursorSize="{../scroller1.ChildWidthRatio}" 
+                                       LargeIncrement="{../scroller1.PageWidth}" SmallIncrement="30"
+                                       Height="14" />
                </VerticalStack>
                <Splitter/>
                <IMLContainer Path="#Crow.Coding.ui.SourceEditor.crow"/>
-               <Label DataSource="{../editor.Error}" Text="{}"
+<!--           <Label DataSource="{../editor.Error}" Text="{}"
                        Visible="{../editor.HasError}"
                        Height="Fit" Width="Stretched" Background="DarkRed" Foreground="White"
-                       TextAlignment="TopLeft" Multiline="true"/>
+                       TextAlignment="TopLeft" Multiline="true"/>-->
        </VerticalStack>
 </TabItem>
index 32f137f5e08490cdd210a2ef266c7209c0ff7718..6255c96afa9cbe46fd18349fe739b5884bd3eb4b 100644 (file)
                        CursorSize="{../editor.ChildWidthRatio}"
                        Height="14" />                  
        <HorizontalStack Height="Fit">
-               <GraphicObject Height="5" Width="Stretched"/>
+               <Label Text="{../../editor.HoverError}" Width="Stretched"/>
                <GraphicObject Background="Red" Width="5" Height="5" Visible="{IsDirty}"/>
+               <Label Text="Hover Line:" Foreground="Gray"/>
+               <Label Text="{../../editor.HoverLine}"/>
+               <GraphicObject Height="5" Width="10"/>
                <Label Text="Line:" Foreground="Gray"/>
                <Label Text="{CurrentLine}"/>
                <GraphicObject Height="5" Width="10"/>
index aed500aba15220c710b1faa7be4ff5e12c0cc766..7b7e8392a5e3429a56a595a0e042f787090cad56 100755 (executable)
@@ -18,7 +18,7 @@
        </Template>
        <Border Background="DimGray" BorderWidth="1" Margin="1"
                MinimumSize="{../../MinimumPopupSize}" Fit="true">
-               <Scroller Name="scroller1" Margin="2" VerticalScrolling="true"
+               <Scroller Name="scroller1" Margin="2" 
                        MaximumSize="0,200"
                        HorizontalAlignment="Left">
                        <VerticalStack
index e508b3d74d3432e97abf5216419714913a563b32..6fae49c5992cf07cc0a24225910926172845a565 100644 (file)
@@ -32,8 +32,7 @@
                                                        SelectedItemChanged="./onSelectedItemChanged">
                                                        <Template>
                                                                <HorizontalStack>
-                                                                       <Scroller ScrollX="{../scrollbar1.Value}"  Name="scroller1"
-                                                                               VerticalScrolling="true" HorizontalScrolling="false">
+                                                                       <Scroller ScrollX="{../scrollbar1.Value}"  Name="scroller1">
                                                                                <VerticalStack Height="Fit" VerticalAlignment="Top"
                                                                                        Name="ItemsContainer" Margin="0" Spacing="1"/>
                                                                        </Scroller>
index f6d6214db11bfd5b41d1069e33dcef9f2c05041e..a1aea50ff52d703a0386e411ca3411ab6361c9ab 100755 (executable)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <Border BorderWidth="1" Margin="1" MinimumSize="10,10">
-       <Scroller  Name="scroller1" Margin="1" VerticalScrolling="true">
+       <Scroller  Name="scroller1" Margin="1" >
                <VerticalStack
                        Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
        </Scroller>
index 56b08c037b6d163b04b9076a33d7c7896d866d88..3b098df28c63a30bf653a7cf22113a9647610c65 100644 (file)
@@ -2,7 +2,7 @@
 <Border BorderWidth="1" Background="{./Background}">
        <HorizontalStack Margin="1">
                <Scroller Name="scroller1" 
-                               Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}">
+                               Margin="2" ScrollY="{../scrollbar1.Value}">
                        <VerticalStack Height="Fit" MinimumSize="10,10"
                                Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
                </Scroller>
index a1d9bc7237d093463d783599bef2d13cd3c6b015..31514fce05d70cb508a20599da0efff145a5d4b0 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <HorizontalStack>
-       <Scroller  Name="scroller1" Margin="1" VerticalScrolling="true"
+       <Scroller  Name="scroller1" Margin="1"
                Background="{./Background}"
                ScrollY="{../scrollbar1.Value}">
                <VerticalStack
index 69fc7f12f7130a4a04c056cd30e33f0999793cff..852a4e879391efa431d14f0db0cf4be1c85aa878 100755 (executable)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <Border Fit="true" BorderWidth="2"  >
-<Scroller CornerRadius="2" VerticalScrolling="true" Height="200" Width="300" Background="DimGray" Margin="2">
+<Scroller CornerRadius="2" Height="200" Width="300" Background="DimGray" Margin="2">
        <VerticalStack Margin="10" VerticalAlignment="Top" Fit="true" Background="vgradient|0:BlueCrayola|1:Black" >
                 <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 1"/>
                 <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 2"/>
index 22dfd7490d5b9074f2aaabbf90aa89bffae3979f..3445ef1c657ac2c536bdf4260176429abed480c0 100644 (file)
@@ -1,21 +1,2 @@
 <?xml version="1.0"?>
-<Border BorderStyle="Sunken" Fit="true" Background="0.7,0.7,0.7,0.5" CornerRadius="10">
-       <VerticalStack Margin="20">
-               <Image Path="#Crow.Images.Icons.crow.svg"/>
-<!--           <Label Font="Times bold, 60" Text="C.R.O.W"/>-->
-               <HorizontalStack Fit="true" DataSource="{CrowVersion}" Spacing="0">
-                       <Label Foreground="Black" Font="mono, 12" Text="version: "/>            
-                       <Label Foreground="Black" Font="mono, 12" Text="{Major}"/>              
-                       <Label Foreground="Black" Font="mono, 12" Text="."/>
-                       <Label Foreground="Black" Font="mono, 12" Text="{Minor}"/>
-                       <Label Foreground="Black" Font="mono, 12" Text="."/>
-                       <Label Foreground="DimGray" Font="mono, 12" Text="{Build}"/>
-               </HorizontalStack>
-               <GraphicObject Height="30"/>
-               <Label Font="20" Text="Press &lt;F2&gt; and &lt;F3&gt; to cycle into the examples"/>
-               <Label Font="20" Text="Those are basic tests used to validate changes,"/>
-               <GraphicObject Height="30"/>
-               <Label Foreground="DimGray" Font="20" Text="&lt;F5&gt; => File dialog example"/>
-               <Label Foreground="DimGray" Font="20" Text="&lt;F6&gt; => Window example"/>
-       </VerticalStack>
-</Border>
\ No newline at end of file
+<GraphicObject Height="30" Width="30" Background="#500000"/>
\ No newline at end of file
index 54ccde153452b802ec4e0b4862d8d1f96b2c9099..90c475a5b518e7ff4cfa41c2e8b15895e5054cb9 100755 (executable)
@@ -7,7 +7,7 @@
                                <Border BorderWidth="1">
                                        <HorizontalStack Margin="1">
                                                <Scroller Name="scroller1" 
-                                                               Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}">
+                                                               Margin="2" ScrollY="{../scrollbar1.Value}">
                                                        <VerticalStack Height="Fit" MinimumSize="10,10"
                                                                Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
                                                </Scroller>
index ceeae253df19ec1f9f78727a21085c551b718017..246a937dd73d3d55f3fffb3dccf30f694bfc2c68 100755 (executable)
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <Window Caption="Horizontal Wrapper" Width="50%" Height="50%">
        <VerticalStack Margin="1">
-               <Scroller Name="scroller1" ScrollX="{../scrollbar1.Value}" VerticalScrolling="False" HorizontalScrolling="true" Margin="1" Background="BlueCrayola">
+               <Scroller Name="scroller1" ScrollX="{../scrollbar1.Value}" Margin="1" Background="BlueCrayola">
                        <Wrapper HorizontalAlignment="Left" Orientation="Horizontal" Height="100%" Width="Fit" Margin="0" Background="MediumSeaGreen" Spacing="1" >
                                <GraphicObject Width="50" Height="50" Background="SeaGreen"/>
                                <GraphicObject Width="50" Height="50" Background="SeaGreen"/>
index bfb234ad6148c627db302dfa22ef26b0232084d6..61df4443bd8aeb0d9c521a317be9c8737107a268 100755 (executable)
@@ -7,7 +7,7 @@
                <Splitter/>
                <HorizontalStack>
                        <Scroller Name="scroller1" Background="White"
-                                       Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}"
+                                       Margin="2" ScrollY="{../scrollbar1.Value}"
                                        ValueChanged="./_scroller_ValueChanged">
                                <TextBox VerticalAlignment="Top" TextChanged="Tb_TextChanged"
                                        Text="{source}" Multiline="true" TextAlignment="TopLeft"
index 2ca07975b0c4373dd700c40471c77f0a7b6cc9d2..2533fb1b74d0fe34d4b57335d9c3468da1d21041 100644 (file)
@@ -1020,13 +1020,16 @@ namespace Crow
                        if (!string.IsNullOrEmpty (Style)) {
                                if (IFace.DefaultValuesLoader.ContainsKey (Style)) {
                                        IFace.DefaultValuesLoader [Style] (this);
+                                       onInitialized (this, null);
                                        return;
                                }
                        } else if (IFace.DefaultValuesLoader.ContainsKey (thisType.FullName)) {
                                IFace.DefaultValuesLoader [thisType.FullName] (this);
+                               onInitialized (this, null);
                                return;
                        } else  if (IFace.DefaultValuesLoader.ContainsKey (thisType.Name)) {
                                IFace.DefaultValuesLoader [thisType.Name] (this);
+                               onInitialized (this, null);
                                return;
                        }
 
index 397d7de03a9d27d9e20d9ada30fdb8c6deb9afed..30dd14800c2d4a05e15d2ae4760c5bba90611c3e 100644 (file)
@@ -42,160 +42,159 @@ namespace Crow
                public Scroller (Interface iface) : base(iface){}
                #endregion
 
-               bool _verticalScrolling;
-               bool _horizontalScrolling;
-               bool _scrollbarVisible;
-               int _scrollX = 0;
-               int _scrollY = 0;
-               int scrollSpeed;
-
                public event EventHandler<ScrollingEventArgs> Scrolled;
 
+               int scrollX, scrollY, maxScrollX, maxScrollY, scrollSpeed;
+
+               /// <summary>
+               /// if true, key stroke are handled in derrived class
+               /// </summary>
+               protected bool KeyEventsOverrides = false;
+
                #region public properties
-               [XmlAttributeAttribute][DefaultValue(true)]
-               public bool VerticalScrolling {
-                       get { return _verticalScrolling; }
-                       set { _verticalScrolling = value; }
-               }
+               /// <summary> Horizontal Scrolling Position </summary>
+               [XmlAttributeAttribute][DefaultValue(0)]
+               public virtual int ScrollX {
+                       get { return scrollX; }
+                       set {
+                               if (scrollX == value)
+                                       return;
 
-               [XmlAttributeAttribute][DefaultValue(false)]
-        public bool HorizontalScrolling {
-                       get { return _horizontalScrolling; }
-                       set { _horizontalScrolling = value; }
-               }
-               [XmlAttributeAttribute][DefaultValue(true)]
-               public bool ScrollbarVisible {
-                       get { return _scrollbarVisible; }
-                       set { _scrollbarVisible = value; }
+                               int newS = value;
+                               if (newS < 0)
+                                       newS = 0;
+                               else if (newS > maxScrollX)
+                                       newS = maxScrollX;
+
+                               if (newS == scrollX)
+                                       return;
+
+                               scrollX = value;
+
+                               NotifyValueChanged ("ScrollX", scrollX);
+                               RegisterForGraphicUpdate ();
+                       }
                }
+               /// <summary> Vertical Scrolling Position </summary>
                [XmlAttributeAttribute][DefaultValue(0)]
-               public int ScrollX {
-                       get {
-                               return _scrollX;
-                       }
+               public virtual int ScrollY {
+                       get { return scrollY; }
                        set {
-                               if (_scrollX == value)
+                               if (scrollY == value)
                                        return;
-                               if (value < 0)
-                                       _scrollX = 0;
-                               else if (value > Child.Slot.Width - ClientRectangle.Width)
-                                       _scrollX = Math.Max(0, Child.Slot.Width - ClientRectangle.Width);
-                               else
-                                       _scrollX = value;
-                               NotifyValueChanged("ScrollX", _scrollX);
-                               RegisterForRedraw ();
-                               Scrolled.Raise (this, new ScrollingEventArgs (Orientation.Horizontal));
+
+                               int newS = value;
+                               if (newS < 0)
+                                       newS = 0;
+                               else if (newS > maxScrollY)
+                                       newS = maxScrollY;
+
+                               if (newS == scrollY)
+                                       return;
+
+                               scrollY = value;
+
+                               NotifyValueChanged ("ScrollY", scrollY);
+                               RegisterForGraphicUpdate ();
                        }
                }
+               /// <summary> Horizontal Scrolling maximum value </summary>
                [XmlAttributeAttribute][DefaultValue(0)]
-               public int ScrollY {
-                       get {
-                               return _scrollY;
-                       }
+               public virtual int MaxScrollX {
+                       get { return maxScrollX; }
                        set {
-                               if (_scrollY == value)
+                               if (maxScrollX == value)
                                        return;
-                               if (value < 0)
-                                       _scrollY = 0;
-                               else if (value > Child.Slot.Height - ClientRectangle.Height)
-                                       _scrollY = Math.Max(0,Child.Slot.Height - ClientRectangle.Height);
-                               else
-                                       _scrollY = value;
-                               NotifyValueChanged("ScrollY", _scrollY);
-                               RegisterForRedraw ();
-                               Scrolled.Raise (this, new ScrollingEventArgs (Orientation.Vertical));
+
+                               maxScrollX = value;
+
+                               if (scrollX > maxScrollX)
+                                       ScrollX = maxScrollX;
+
+                               NotifyValueChanged ("MaxScrollX", maxScrollX);
+                               RegisterForGraphicUpdate ();
                        }
                }
+               /// <summary> Vertical Scrolling maximum value </summary>
+               [XmlAttributeAttribute][DefaultValue(0)]
+               public virtual int MaxScrollY {
+                       get { return maxScrollY; }
+                       set {
+                               if (maxScrollY == value)
+                                       return;
+
+                               maxScrollY = value;
+
+                               if (scrollY > maxScrollY)
+                                       ScrollY = maxScrollY;
 
-               [XmlIgnore]
-               public int MaximumScroll {
-                       get {
-                               try {
-                                       return VerticalScrolling ?
-                                               Math.Max(Child.Slot.Height - ClientRectangle.Height,0) :
-                                               Math.Max(Child.Slot.Width - ClientRectangle.Width,0);
-                               } catch {
-                                       return 0;
-                               }
+                               NotifyValueChanged ("MaxScrollY", maxScrollY);
+                               RegisterForGraphicUpdate ();
                        }
                }
-
-               [XmlAttributeAttribute][DefaultValue(30)]
-               public int ScrollSpeed {
+               /// <summary> Mouse Wheel Scrolling multiplier </summary>
+               [XmlAttributeAttribute][DefaultValue(50)]
+               public virtual int ScrollSpeed {
                        get { return scrollSpeed; }
                        set {
+                               if (scrollSpeed == value)
+                                       return;
+
                                scrollSpeed = value;
-                               NotifyValueChanged("ScrollSpeed", scrollSpeed);
+
+                               NotifyValueChanged ("ScrollSpeed", scrollSpeed);
                        }
                }
                #endregion
 
-               #region GraphicObject Overrides
-               public override void OnLayoutChanges (LayoutingType layoutType)
+               public override void SetChild (GraphicObject _child)
                {
-                       base.OnLayoutChanges (layoutType);
+                       Group g = child as Group;
+                       if (g != null)
+                               g.ChildrenCleared -= onChildListCleared;
+                       
+                       base.SetChild (_child);
 
-                       NotifyValueChanged("MaximumScroll", MaximumScroll);
-                       if (layoutType == LayoutingType.Height) {
-                               NotifyValueChanged ("PageHeight", Slot.Height);
-                               if (child?.Slot.Height > 0)
-                                       NotifyValueChanged ("ChildHeightRatio", Slot.Height * Slot.Height / child.Slot.Height);
-                       } else {
-                               NotifyValueChanged ("PageWidth", Slot.Width);
-                               if (child?.Slot.Width > 0)
-                                       NotifyValueChanged ("ChildWidthRatio", Slot.Width * Slot.Width / child.Slot.Width);
-                       }
+                       g = _child as Group;
+                       if (g != null)
+                               g.ChildrenCleared += onChildListCleared;                        
                }
-               void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
+               public override void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
                {
-                       //Debug.WriteLine ("scroller childLayoutChanges");
-                       int maxScroll = MaximumScroll;
-                       //Debug.WriteLine ("maxscroll={0}", maxScroll);
-                       if (_verticalScrolling) {
-                               if (arg.LayoutType == LayoutingType.Height) {
-                                       if (maxScroll < ScrollY) {
-                                               //Debug.WriteLine ("scrolly={0} maxscroll={1}", ScrollY, maxScroll);
-                                               ScrollY = maxScroll;
-                                       }
-                                       NotifyValueChanged("MaximumScroll", maxScroll);
-                                       if (child?.Slot.Height > 0)
-                                               NotifyValueChanged ("ChildHeightRatio", Slot.Height * Slot.Height / child.Slot.Height);
-                               }
-                       } else if (arg.LayoutType == LayoutingType.Width) {
-                               if (maxScroll < ScrollX) {
-                                       //Debug.WriteLine ("scrolly={0} maxscroll={1}", ScrollY, maxScroll);
-                                       ScrollX = maxScroll;
-                               }
-                               NotifyValueChanged("MaximumScroll", maxScroll);
-                               if (child?.Slot.Width > 0)
-                                       NotifyValueChanged ("ChildWidthRatio", Slot.Width * Slot.Width / child.Slot.Width);
-                       }
+                       base.OnChildLayoutChanges (sender, arg);
+                       updateMaxScroll (arg.LayoutType);
                }
-               void onChildListCleared(object sender, EventArgs e){
-                       ScrollY = 0;
-                       ScrollX = 0;
+
+
+               #region GraphicObject Overrides
+               public override Rectangle ScreenCoordinates (Rectangle r)
+               {
+                       return base.ScreenCoordinates (r) - new Point((int)ScrollX,(int)ScrollY);
                }
-               public override void SetChild (GraphicObject _child)
+               public override bool PointIsIn (ref Point m)
                {
-                       GraphicObject c = child as GraphicObject;
-                       Group g = child as Group;
-                       if (c != null) {
-                               c.LayoutChanged -= OnChildLayoutChanges;
-                               if (g != null)
-                                       g.ChildrenCleared -= onChildListCleared;
-                       }
-                       c = _child as GraphicObject;
-                       g = _child as Group;
-                       if (c != null) {
-                               c.LayoutChanged += OnChildLayoutChanges;
-                               if (g != null)
-                                       g.ChildrenCleared += onChildListCleared;
-                       }
-                       base.SetChild (_child);
+                       if (!base.PointIsIn(ref m))
+                               return false;
+                       if (!Slot.ContainsOrIsEqual (m) || child==null)
+                               return false;
+                       m += new Point (ScrollX, ScrollY);
+                       return true;
                }
-               public override Rectangle ScreenCoordinates (Rectangle r)
+               public override void RegisterClip (Rectangle clip)
                {
-                       return base.ScreenCoordinates (r) - new Point((int)ScrollX,(int)ScrollY);
+                       base.RegisterClip (clip - new Point(ScrollX,ScrollY));
+               }
+               public override void OnLayoutChanges (LayoutingType layoutType)
+               {
+                       base.OnLayoutChanges (layoutType);
+
+                       if (layoutType == LayoutingType.Height)
+                               NotifyValueChanged ("PageHeight", Slot.Height);
+                       else if (layoutType == LayoutingType.Width)
+                               NotifyValueChanged ("PageWidth", Slot.Width);
+                       else
+                               return;
+                       updateMaxScroll(layoutType);
                }
                protected override void onDraw (Context gr)
                {
@@ -218,50 +217,75 @@ namespace Crow
                        gr.Restore ();
                }
 
-               #region Mouse handling
-               //internal Point savedMousePos;
-
-               public override bool PointIsIn (ref Point m)
-               {
-                       if (!base.PointIsIn(ref m))
-                               return false;
-                       if (!Slot.ContainsOrIsEqual (m) || child==null)
-                               return false;
-                       m += new Point (ScrollX, ScrollY);
-                       return true;
-               }
-//             public override bool MouseIsIn (Point m)
-//             {
-//                     return Visible ? base.ScreenCoordinates(Slot).ContainsOrIsEqual (m) : false;
-//             }
-//             public override void checkHoverWidget (MouseMoveEventArgs e)
-//             {
-//                     savedMousePos = e.Position;
-//                     Point m = e.Position - new Point (ScrollX, ScrollY);
-//                     base.checkHoverWidget (new MouseMoveEventArgs(m.X,m.Y,e.XDelta,e.YDelta));
-//             }
+               #region Mouse & Keyboard
+               /// <summary> Process scrolling vertically, or if shift is down, vertically </summary>
                public override void onMouseWheel (object sender, MouseWheelEventArgs e)
                {
-                       if (Child == null)
-                               return;
-
-                       if (VerticalScrolling )
+                       base.onMouseWheel (sender, e);
+                       if (IFace.Keyboard.IsKeyDown (Key.ShiftLeft))
+                               ScrollX += e.Delta * ScrollSpeed;
+                       else
                                ScrollY -= e.Delta * ScrollSpeed;
-                       if (HorizontalScrolling )
-                               ScrollX -= e.Delta * ScrollSpeed;
                }
-//             public override void onMouseMove (object sender, MouseMoveEventArgs e)
-//             {
-//                     savedMousePos.X += e.XDelta;
-//                     savedMousePos.Y += e.YDelta;
-//                     base.onMouseMove (sender, new MouseMoveEventArgs(savedMousePos.X,savedMousePos.Y,e.XDelta,e.YDelta));
-//             }
-               public override void RegisterClip (Rectangle clip)
+               /// <summary> Process scrolling with arrow keys, home and end keys. </summary>
+               public override void onKeyDown (object sender, KeyboardKeyEventArgs e)
                {
-                       base.RegisterClip (clip - new Point(ScrollX,ScrollY));
+                       base.onKeyDown (sender, e);
+
+                       if (KeyEventsOverrides)
+                               return;
+
+                       switch (e.Key) {
+                       case Key.Up:
+                               ScrollY--;
+                               break;
+                       case Key.Down:
+                               ScrollY++;
+                               break;
+                       case Key.Left:
+                               ScrollX--;
+                               break;
+                       case Key.Right:
+                               ScrollX++;
+                               break;
+                       case Key.Home:
+                               ScrollX = 0;
+                               ScrollY = 0;
+                               break;
+                       case Key.End:
+                               ScrollX = MaxScrollX;
+                               ScrollY = MaxScrollY;
+                               break;
+                       }
                }
                #endregion
 
                #endregion
+
+               void updateMaxScroll (LayoutingType lt){
+                       if (Child == null) {
+                               MaxScrollX = 0;
+                               MaxScrollY = 0;
+                               return;
+                       }
+
+                       Rectangle cb = ClientRectangle;
+
+                       if (lt == LayoutingType.Height) {
+                               MaxScrollY = child.Slot.Height - cb.Height;
+                               if (child.Slot.Height > 0)
+                                       NotifyValueChanged ("ChildHeightRatio", Slot.Height * Slot.Height / child.Slot.Height);                 
+                       } else if (lt == LayoutingType.Width) {
+                               MaxScrollX = child.Slot.Width - cb.Width;
+                               if (child.Slot.Width > 0)
+                                       NotifyValueChanged ("ChildWidthRatio", Slot.Width * Slot.Width / child.Slot.Width);
+                       }
+               }
+               void onChildListCleared(object sender, EventArgs e){
+                       ScrollY = 0;
+                       ScrollX = 0;
+               }
+
+
     }
 }
index 4492c40676e50d2b64f6783eeef6f0d310423760..2bdd5b8ab0c2c8e5693ea39f30384152e19464e8 100644 (file)
@@ -186,16 +186,24 @@ namespace Crow
                        }
                        cursor.Inflate (-1);
         }
-        
+               Point mouseDownInit;
+               double mouseDownInitValue;
+
                #region mouse handling
                public override void onMouseDown (object sender, MouseButtonEventArgs e)
                {
                        base.onMouseDown (sender, e);
-
+                       mouseDownInit = ScreenPointToLocal (e.Position);
+                       mouseDownInitValue = Value;
                        Rectangle cursInScreenCoord = ScreenCoordinates (cursor + Slot.Position);
-                       if (cursInScreenCoord.ContainsOrIsEqual (e.Position))
+                       if (cursInScreenCoord.ContainsOrIsEqual (e.Position)){
+//                             Rectangle r = ClientRectangle;
+//                             if (r.Width - _cursorSize > 0) {
+//                                     double unit = (Maximum - Minimum) / (double)(r.Width - _cursorSize);
+//                                     mouseDownInit += new Point ((int)(Value / unit), (int)(Value / unit));
+//                             }
                                holdCursor = true;
-                       else if (_orientation == Orientation.Horizontal) {
+                       }else if (_orientation == Orientation.Horizontal) {
                                if (e.Position.X < cursInScreenCoord.Left)
                                        Value -= LargeIncrement;
                                else
@@ -216,26 +224,24 @@ namespace Crow
                public override void onMouseMove (object sender, MouseMoveEventArgs e)
                {
                        if (holdCursor) {                               
-                               Point m = ScreenPointToLocal (e.Position);
+                               Point m = ScreenPointToLocal (e.Position) - mouseDownInit;
                                Rectangle r = ClientRectangle;
 
                                if (_orientation == Orientation.Horizontal) {
                                        if (r.Width - _cursorSize == 0)
                                                return;                                 
                                        double unit = (Maximum - Minimum) / (double)(r.Width - _cursorSize);
-                                       double tmp = (double)m.X * unit;
+                                       double tmp = mouseDownInitValue + (double)m.X * unit;
                                        tmp -= tmp % SmallIncrement;
                                        Value = tmp;
                                } else {
                                        if (r.Height - _cursorSize == 0)
                                                return;                                 
                                        double unit = (Maximum - Minimum) / (double)(r.Height - _cursorSize);
-                                       double tmp = (double)m.Y * unit;
+                                       double tmp = mouseDownInitValue + (double)m.Y * unit;
                                        tmp -= tmp % SmallIncrement;
                                        Value = tmp;
                                }
-
-
                        }
                        
                        base.onMouseMove (sender, e);