]> O.S.I.I.S - jp/crow.git/commitdiff
debug wrapper layouting, finalyse FileDialog wrapper usage
authorjpbruyere <jp.bruyere@hotmail.com>
Tue, 31 Jan 2017 22:29:05 +0000 (23:29 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Tue, 31 Jan 2017 22:29:05 +0000 (23:29 +0100)
Default.style
Templates/FileDialog.template
Tests/Interfaces/Wrapper/1.1.crow [new file with mode: 0755]
Tests/Interfaces/Wrapper/2.1.crow [new file with mode: 0755]
Tests/Interfaces/Wrapper/2.2.crow [new file with mode: 0755]
Tests/Tests.csproj
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Scroller.cs
src/GraphicObjects/TemplatedGroup.cs
src/GraphicObjects/Wrapper.cs

index 489783f595b732fcc38eb49d4a57b80a48897feb..0f4d81e185d064cf5ecbbac45b081d91dca3e6bd 100644 (file)
@@ -99,6 +99,9 @@ ScrollBar {
        Maximum = 0;
        Value = 0;
 }
+Scroller {
+       CacheEnabled = false;
+}
 Icon {
        Margin=1;
        Width=12;
index 2545303297b5031061add935d217784b2e83a6cb..018df8f6e44b04894da4a256f246d04a088b9ac2 100644 (file)
                        <GraphicObject Width="5"/>
                </HorizontalStack>
                <Container Name="Content" MinimumSize="50,50" Background="Onyx">
-                       <VerticalStack Margin="5">
+                       <VerticalStack Margin="1">
                                <TextBox Text="{²./CurrentDirectory}"/>
-                               <HorizontalStack>
+                               <HorizontalStack Spacing="1">
                                        <DirectoryView ShowFiles="false" Name="dv" CurrentDirectory="{²./CurrentDirectory}" SelectedItemChanged="./Tv_SelectedItemChanged"
-                                               Width="50%" Margin="1">
+                                               Width="50%" Margin="0">
                                                <Template>
                                                        <TreeView IsRoot="true" Name="treeView" Data="{./FileSystemEntries}"
                                                                        SelectedItemChanged="./onSelectedItemChanged">
                                        </DirectoryView>
                                        <Splitter/>
                                        <DirectoryView ShowFiles="true" Name="dv" CurrentDirectory="{../dv.SelectedItem}" 
-                                               Width="50%" Margin="1">
+                                               Width="100%" Margin="0">
                                                <Template>
                                                        <ListBox Name="fileView" Data="{./FileSystemEntries}">
                                                                <Template>
-                                                                       <Border BorderWidth="1" Margin="1" MinimumSize="10,10">
-                                                                               <Scroller  Name="scroller1" Margin="1" VerticalScrolling="true">
-                                                                                       <Wrapper Orientation="Horizontal" Height="Fit"
-                                                                                               Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
-                                                                               </Scroller>
+                                                                       <Border BorderWidth="1" Margin="0" MinimumSize="10,10">
+                                                                               <VerticalStack>
+                                                                                       <Scroller ScrollX="{../scrollbar1.Value}"  Name="scroller1"
+                                                                                               VerticalScrolling="False" HorizontalScrolling="true">
+                                                                                               <Wrapper Orientation="Horizontal" Width="Fit" HorizontalAlignment="Left"
+                                                                                                       Name="ItemsContainer" Margin="0" Spacing="1"/>
+                                                                                       </Scroller>
+                                                                                       <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollX}" 
+                                                                                               Maximum="{../scroller1.MaximumScroll}" Orientation="Horizontal" 
+                                                                                               Height="14" />
+                                                                               </VerticalStack>
                                                                        </Border>
                                                                </Template>
                                                                <ItemTemplate DataType="System.IO.FileInfo">
diff --git a/Tests/Interfaces/Wrapper/1.1.crow b/Tests/Interfaces/Wrapper/1.1.crow
new file mode 100755 (executable)
index 0000000..ab8a993
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<Window Caption="Vertical Wrapper" Width="50%" Height="50%">
+       <Wrapper Orientation="Vertical" Height="Fit" Width="90%" Margin="5" Background="Teal" Spacing="1" >
+               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+               <GraphicObject Width="50%" Height="50" Background="Mantis"/>
+               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+               <GraphicObject Width="50" Height="50%" Background="Mantis"/>
+               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+       </Wrapper>
+</Window>
\ No newline at end of file
diff --git a/Tests/Interfaces/Wrapper/2.1.crow b/Tests/Interfaces/Wrapper/2.1.crow
new file mode 100755 (executable)
index 0000000..a5ce996
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<Window Caption="Horizontal Wrapper" Width="50%" Height="50%">
+       <Wrapper Orientation="Horizontal" Height="90%" Width="Fit" Margin="5" Background="Teal" Spacing="1" >
+               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+               <GraphicObject Width="50%" Height="50" Background="Mantis"/>
+               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+               <GraphicObject Width="50" Height="50%" Background="Mantis"/>
+               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+       </Wrapper>
+</Window>
\ No newline at end of file
diff --git a/Tests/Interfaces/Wrapper/2.2.crow b/Tests/Interfaces/Wrapper/2.2.crow
new file mode 100755 (executable)
index 0000000..ce4f3f1
--- /dev/null
@@ -0,0 +1,39 @@
+<?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">
+                       <Wrapper HorizontalAlignment="Left" Orientation="Horizontal" Height="100%" Width="Fit" Margin="0" Background="Teal" Spacing="1" >
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50%" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50%" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50%" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50%" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50%" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50%" Background="Mantis"/>
+                               <GraphicObject Width="50" Height="50" Background="Mantis"/>
+                       </Wrapper>
+               </Scroller>
+               <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollX}" 
+                       Maximum="{../scroller1.MaximumScroll}" Orientation="Horizontal" 
+                       Height="14" />
+       </VerticalStack>
+</Window>
\ No newline at end of file
index 9c1e2ba3405a664e2626a9274e88f795f5cd7293..044c4b9bd35b2e1855f31ee30f5167ccc74cd253 100644 (file)
@@ -41,9 +41,6 @@
     <Reference Include="System.Xml" />
     <Reference Include="System.Drawing" />
        <Reference Include="cairo-sharp"/>
-       <Reference Include="gdk-sharp"/>
-       <Reference Include="gio-sharp"/>
-       <Reference Include="glib-sharp"/>
     <Reference Include="OpenTK">
       <HintPath>$(SolutionDir)packages\OpenTK.2.0.0\lib\net20\OpenTK.dll</HintPath>
       <Package>opentk</Package>
     <None Include="Interfaces\Divers\perfMeasures.crow">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Include="Interfaces\Wrapper\2.1.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Interfaces\Wrapper\1.1.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Interfaces\Wrapper\2.2.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Interfaces\" />
index f7e193e18a81437c0f6364d54e9129020a06861f..e468cce923e012fcc41186481c4f6696c33a9e8d 100644 (file)
@@ -908,7 +908,9 @@ namespace Crow
                        }
                        LayoutChanged.Raise (this, new LayoutingEventArgs (layoutType));
                }
-
+               internal protected void raiseLayoutChanged(LayoutingEventArgs e){
+                       LayoutChanged.Raise (this, e);
+               }
                /// <summary> Update layout component only one at a time, this is where the computation of alignement
                /// and size take place.
                /// The redrawing will only be triggered if final slot size has changed </summary>
index 4b83b0cb1bde26ad9ba10887f5b13a6cc7e332d6..d14f74b0cf6ed7c96b46ae9ef6d15e2d54cf7033 100644 (file)
@@ -44,7 +44,7 @@ namespace Crow
                        get { return _verticalScrolling; }
                        set { _verticalScrolling = value; }
                }
-        
+
                [XmlAttributeAttribute][DefaultValue(false)]
         public bool HorizontalScrolling {
                        get { return _horizontalScrolling; }
@@ -54,7 +54,7 @@ namespace Crow
                public bool ScrollbarVisible {
                        get { return _scrollbarVisible; }
                        set { _scrollbarVisible = value; }
-               }                       
+               }
                [XmlAttributeAttribute][DefaultValue(0.0)]
                public double ScrollX {
                        get {
@@ -73,7 +73,7 @@ namespace Crow
                                RegisterForRedraw ();
                                Scrolled.Raise (this, new ScrollingEventArgs (Orientation.Horizontal));
                        }
-               }                       
+               }
                [XmlAttributeAttribute][DefaultValue(0.0)]
                public double ScrollY {
                        get {
@@ -98,9 +98,9 @@ namespace Crow
                public int MaximumScroll {
                        get {
                                try {
-                                       return VerticalScrolling ? 
+                                       return VerticalScrolling ?
                                                Math.Max(Child.Slot.Height - ClientRectangle.Height,0) :
-                                               Math.Max(Child.Slot.Width - ClientRectangle.Width,0);                                   
+                                               Math.Max(Child.Slot.Width - ClientRectangle.Width,0);
                                } catch {
                                        return 0;
                                }
@@ -121,26 +121,30 @@ namespace Crow
             : base(){}
 
                #region GraphicObject Overrides
-               //TODO:put this override in style
-               [XmlAttributeAttribute()][DefaultValue(false)]
-               public override bool CacheEnabled {
-                       get { return base.CacheEnabled; }
-                       set { base.CacheEnabled = value; }
+               public override void OnLayoutChanges (LayoutingType layoutType)
+               {
+                       base.OnLayoutChanges (layoutType);
+
+                       NotifyValueChanged("MaximumScroll", MaximumScroll);
                }
                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);
+                                               //Debug.WriteLine ("scrolly={0} maxscroll={1}", ScrollY, maxScroll);
                                                ScrollY = 0;
                                        }
                                        NotifyValueChanged("MaximumScroll", maxScroll);
                                }
                        } else if (arg.LayoutType == LayoutingType.Width) {
-                               if (maxScroll < ScrollX)
+                               if (maxScroll < ScrollX) {
+                                       //Debug.WriteLine ("scrolly={0} maxscroll={1}", ScrollY, maxScroll);
                                        ScrollX = 0;
+                               }
                                NotifyValueChanged("MaximumScroll", maxScroll);
                        }
                }
@@ -149,7 +153,7 @@ namespace Crow
                        ScrollX = 0;
                }
                public override void SetChild (GraphicObject _child)
-               {                       
+               {
                        GraphicObject c = child as GraphicObject;
                        Group g = child as Group;
                        if (c != null) {
@@ -162,17 +166,40 @@ namespace Crow
                        if (c != null) {
                                c.LayoutChanged += OnChildLayoutChanges;
                                if (g != null)
-                                       g.ChildrenCleared += onChildListCleared;                                
+                                       g.ChildrenCleared += onChildListCleared;
                        }
                        base.SetChild (_child);
                }
-               #endregion
+               public override Rectangle ScreenCoordinates (Rectangle r)
+               {
+                       return base.ScreenCoordinates (r) - new Point((int)ScrollX,(int)ScrollY);
+               }
+               protected override void onDraw (Context gr)
+               {
+                       Rectangle rBack = new Rectangle (Slot.Size);
+
+                       Background.SetAsSource (gr, rBack);
+                       CairoHelpers.CairoRectangle(gr,rBack, CornerRadius);
+                       gr.Fill ();
+
+                       gr.Save ();
+                       if (ClipToClientRect) {
+                               //clip to scrolled client zone
+                               CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
+                               gr.Clip ();
+                       }
+
+                       gr.Translate (-ScrollX, -ScrollY);
+                       if (child != null)
+                               child.Paint (ref gr);
+                       gr.Restore ();
+               }
 
                #region Mouse handling
                internal Point savedMousePos;
                public override bool MouseIsIn (Point m)
-               {                       
-                       return Visible ? base.ScreenCoordinates(Slot).ContainsOrIsEqual (m) : false; 
+               {
+                       return Visible ? base.ScreenCoordinates(Slot).ContainsOrIsEqual (m) : false;
                }
                public override void checkHoverWidget (MouseMoveEventArgs e)
                {
@@ -184,12 +211,12 @@ namespace Crow
                {
                        if (Child == null)
                                return;
-                       
+
                        if (VerticalScrolling )
                                ScrollY -= e.Delta * ScrollSpeed;
-            if (HorizontalScrolling )
+                       if (HorizontalScrolling )
                                ScrollX -= e.Delta * ScrollSpeed;
-        }
+               }
                public override void onMouseMove (object sender, MouseMoveEventArgs e)
                {
                        savedMousePos.X += e.XDelta;
@@ -202,29 +229,6 @@ namespace Crow
                }
                #endregion
 
-               public override Rectangle ScreenCoordinates (Rectangle r)
-               {
-                       return base.ScreenCoordinates (r) - new Point((int)ScrollX,(int)ScrollY);
-               }
-               protected override void onDraw (Context gr)
-               {
-                       Rectangle rBack = new Rectangle (Slot.Size);
-
-                       Background.SetAsSource (gr, rBack);
-                       CairoHelpers.CairoRectangle(gr,rBack, CornerRadius);
-                       gr.Fill ();
-
-                       gr.Save ();
-                       if (ClipToClientRect) {
-                               //clip to scrolled client zone
-                               CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
-                               gr.Clip ();
-                       }
-
-                       gr.Translate (-ScrollX, -ScrollY);
-                       if (child != null)
-                               child.Paint (ref gr);
-                       gr.Restore ();
-               }
+               #endregion
     }
 }
index fbb3c4bd3b3d166391eb437ab09f564cbdfbe822..336308cb1f7cbe8f91416628fd8dd8a58f0608db 100644 (file)
@@ -324,10 +324,10 @@ namespace Crow
                        #endif
 
                        Group page;
-                       if (typeof(Wrapper).IsAssignableFrom (items.GetType ())){
+                       if (typeof(Wrapper).IsAssignableFrom (items.GetType ())) {
                                page = items;
                                itemPerPage = int.MaxValue;
-                       }else if (typeof(GenericStack).IsAssignableFrom (items.GetType ())) {
+                       } else if (typeof(GenericStack).IsAssignableFrom (items.GetType ())) {
                                GenericStack gs = new GenericStack ();
                                gs.CurrentInterface = items.CurrentInterface;
                                gs.Initialize ();
@@ -337,11 +337,11 @@ namespace Crow
                                gs.VerticalAlignment = items.VerticalAlignment;
                                gs.HorizontalAlignment = items.HorizontalAlignment;
                                page = gs;
-
-                       }else
+                               page.Name = "page" + pageNum;
+                       } else {
                                page = Activator.CreateInstance (items.GetType ()) as Group;
-
-                       page.Name = "page" + pageNum;
+                               page.Name = "page" + pageNum;
+                       }
 
                        for (int i = (pageNum - 1) * itemPerPage; i < pageNum * itemPerPage; i++) {
                                if (i >= data.Count)
index fcf88583155f8dc9f4a120b42c4fb0dc8a3f570c..b33b62b734cc390550577d46902e7d893a5b89b5 100644 (file)
@@ -82,19 +82,21 @@ namespace Crow
                {
                        //children can't stretch in a wrapper
                        GraphicObject go = sender as GraphicObject;
-                       //Debug.WriteLine ("child layout change: " + go.LastSlots.ToString() + " => " + go.Slot.ToString());
+                       //System.Diagnostics.Debug.WriteLine ("wrapper child layout change: " + go.LastSlots.ToString() + " => " + go.Slot.ToString());
                        switch (arg.LayoutType) {
                        case LayoutingType.Width:
-                               if (Orientation == Orientation.Horizontal && go.Width.Units == Unit.Percent) {
+                               if (Orientation == Orientation.Horizontal && go.Width.Units == Unit.Percent){
                                        go.Width = Measure.Fit;
                                        return;
                                }
+                               this.RegisterForLayouting (LayoutingType.Width);
                                break;
                        case LayoutingType.Height:
                                if (Orientation == Orientation.Vertical && go.Height.Units == Unit.Percent) {
                                        go.Height = Measure.Fit;
                                        return;
                                }
+                               this.RegisterForLayouting (LayoutingType.Height);
                                break;
                        default:
                                return;
@@ -107,7 +109,7 @@ namespace Crow
                protected override int measureRawSize (LayoutingType lt)
                {
                        int tmp = 0;
-                       //Wrapper can't fit in the direction of the wrapper
+                       //Wrapper can't fit in the opposite direction of the wrapper, this func is called only if Fit
                        if (lt == LayoutingType.Width) {
                                if (Orientation == Orientation.Vertical) {
                                        Width = Measure.Stretched;
@@ -194,7 +196,6 @@ namespace Crow
                        CurrentInterface.currentLQI.Slot = LastSlots;
                        CurrentInterface.currentLQI.Slot = Slot;
                        #endif
-
                        switch (layoutType) {
                        case LayoutingType.Width:
                                foreach (GraphicObject c in Children) {
@@ -218,7 +219,7 @@ namespace Crow
                                return;
                        }
                        RegisterForLayouting (LayoutingType.ArrangeChildren);
-                       //LayoutChanged.Raise (this, new LayoutingEventArgs (layoutType));
+                       raiseLayoutChanged (new LayoutingEventArgs (layoutType));
                }
                #endregion
        }