aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2017-01-31 23:29:05 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2017-01-31 23:29:05 +0100
commit48c45e200584ac18efd076e2246c8a6d17f16beb (patch)
treea1e048638263fbb138043f902e971a254e0cf98b /src/GraphicObjects
parent280aa1ec9ce25ad0db63719e329bd349e5edf11b (diff)
debug wrapper layouting, finalyse FileDialog wrapper usage
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/GraphicObject.cs4
-rw-r--r--src/GraphicObjects/Scroller.cs92
-rw-r--r--src/GraphicObjects/TemplatedGroup.cs12
-rw-r--r--src/GraphicObjects/Wrapper.cs11
4 files changed, 63 insertions, 56 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index f7e193e1..e468cce9 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -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>
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
}
}
diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs
index fbb3c4bd..336308cb 100644
--- a/src/GraphicObjects/TemplatedGroup.cs
+++ b/src/GraphicObjects/TemplatedGroup.cs
@@ -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)
diff --git a/src/GraphicObjects/Wrapper.cs b/src/GraphicObjects/Wrapper.cs
index fcf88583..b33b62b7 100644
--- a/src/GraphicObjects/Wrapper.cs
+++ b/src/GraphicObjects/Wrapper.cs
@@ -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
}