diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2017-01-31 23:29:05 +0100 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2017-01-31 23:29:05 +0100 |
| commit | 48c45e200584ac18efd076e2246c8a6d17f16beb (patch) | |
| tree | a1e048638263fbb138043f902e971a254e0cf98b /src/GraphicObjects/Scroller.cs | |
| parent | 280aa1ec9ce25ad0db63719e329bd349e5edf11b (diff) | |
debug wrapper layouting, finalyse FileDialog wrapper usage
Diffstat (limited to 'src/GraphicObjects/Scroller.cs')
| -rw-r--r-- | src/GraphicObjects/Scroller.cs | 92 |
1 files changed, 48 insertions, 44 deletions
diff --git a/src/GraphicObjects/Scroller.cs b/src/GraphicObjects/Scroller.cs index 4b83b0cb..d14f74b0 100644 --- a/src/GraphicObjects/Scroller.cs +++ b/src/GraphicObjects/Scroller.cs @@ -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 } } |