diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2015-08-21 13:31:52 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2015-08-21 13:31:52 +0200 |
| commit | 24c01f34ad393be4da4af6b25a37e434cbc9cd44 (patch) | |
| tree | 384be6cd3d44efa8e6feb4769fce972e7ed4b705 /src/GraphicObjects | |
| parent | 61aeb72522c4ad315fed13d8ddd3d73f7a21bc2a (diff) | |
Documentation, analog meter tests
Diffstat (limited to 'src/GraphicObjects')
| -rw-r--r-- | src/GraphicObjects/AnalogMeter.cs | 18 | ||||
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 37 | ||||
| -rw-r--r-- | src/GraphicObjects/NumericControl.cs | 8 | ||||
| -rw-r--r-- | src/GraphicObjects/Scroller.cs | 15 | ||||
| -rw-r--r-- | src/GraphicObjects/Slider.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/Window.cs | 2 |
6 files changed, 50 insertions, 32 deletions
diff --git a/src/GraphicObjects/AnalogMeter.cs b/src/GraphicObjects/AnalogMeter.cs index dd248cee..bf7f1c24 100644 --- a/src/GraphicObjects/AnalogMeter.cs +++ b/src/GraphicObjects/AnalogMeter.cs @@ -5,6 +5,7 @@ using Cairo; namespace go { + [DefaultTemplate("#go.Templates.AnalogMeter0.goml")] public class AnalogMeter : NumericControl { #region CTOR @@ -20,29 +21,34 @@ namespace go protected override void loadTemplate (GraphicObject template = null) { - throw new NotImplementedException (); + base.loadTemplate (template); } #endregion #region GraphicObject Overrides protected override void onDraw (Context gr) - { + { base.onDraw (gr); Rectangle r = ClientRectangle; Point m = r.Center; + gr.Save (); + + double aUnit = Math.PI*2.0 / (Maximum - Minimum); - gr.Translate (m.X, m.Y); - gr.Rotate (Value * aUnit); + gr.Translate (m.X, r.Height *1.1); + gr.Rotate (Value/4.0 * aUnit - Math.PI/4.0); gr.Translate (-m.X, -m.Y); gr.LineWidth = 2; gr.Color = Foreground; - gr.MoveTo (m); - gr.LineTo (m.X, 0); + gr.MoveTo (m.X,0.0); + gr.LineTo (m.X, -m.Y*0.5); gr.Stroke (); + + gr.Restore (); } #endregion } diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index cb26bca8..4e13b34d 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -130,7 +130,7 @@ namespace go NotifyValueChanged("Name", _verticalAlignment);
}
}
- [XmlAttributeAttribute()][DefaultValue(VerticalAlignment.Center)]
+ [XmlAttributeAttribute ()][DefaultValue(VerticalAlignment.Center)]
public virtual VerticalAlignment VerticalAlignment {
get { return _verticalAlignment; }
set {
@@ -275,6 +275,7 @@ namespace go get { return _hasFocus; }
set { _hasFocus = value; }
}
+ //TODO: only used in group, should be removed from base go object
[XmlIgnore]public virtual bool DrawingIsValid
{ get { return bmp == null ?
false :
@@ -299,6 +300,10 @@ namespace go }
#endregion
+ /// <summary>
+ /// allow selection of svg subobject to draw in goml, should be improved
+ /// ex: allow access to backgroundImage.subimg from goml
+ /// </summary>
public string BackImgSub = null;
/// <summary>
@@ -368,32 +373,42 @@ namespace go bmp = null;
if (TopContainer != null)
TopContainer.gobjsToRedraw.Add (this);
- //RegisterForLayouting ();
- //registerForRedraw ();
- //Interface.registerForGraphicUpdate(this);
}
/// <summary>
/// Add clipping region in redraw list of interface, dont update cached object content
/// </summary>
public virtual void RegisterForRedraw ()
{
- bmp = null;
TopContainer.gobjsToRedraw.Add (this);
}
+ /// <summary>
+ /// keep last slot components for each layouting pass to track
+ /// changes and trigger update of other component accordingly
+ /// </summary>
public Rectangle LastSlots;
+ /// <summary>
+ /// keep last slot painted on screen to clear traces if moved or resized
+ /// TODO: we should ensure the whole parsed widget tree is the last painted
+ /// version to clear effective oldslot if parents have been moved or resized.
+ /// IDEA is to add a ScreenCoordinates function that use only lastPaintedSlots
+ /// </summary>
public Rectangle LastPaintedSlot;
public virtual void registerClipRect()
{
TopContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot));
+ //this clipping should take only last painted slots in ancestor tree which
+ //is not the case for now.
TopContainer.redrawClip.AddRectangle (ScreenCoordinates(LastPaintedSlot));
}
+ /// <summary> return size of content + margins </summary>
protected virtual Size measureRawSize ()
{
return Bounds.Size;
}
-
+ /// <summary> clear current layoutingQueue items for object and
+ /// trigger a new layouting pass for a layoutType </summary>
public virtual void RegisterForLayouting(int layoutType)
{
if (Parent == null)
@@ -439,6 +454,7 @@ namespace go }
+ /// <summary> trigger dependant sizing component update </summary>
protected virtual void OnLayoutChanges(LayoutingType layoutType)
{
switch (layoutType) {
@@ -465,6 +481,8 @@ namespace go }
LayoutChanged.Raise (this, new LayoutChangeEventArgs (layoutType));
}
+ /// <summary> Update layout component, this is where the computation of alignement
+ /// and size take place </summary>
public virtual void UpdateLayout (LayoutingType layoutType)
{
switch (layoutType) {
@@ -572,6 +590,7 @@ namespace go this.RegisterForRedraw ();
}
+ /// <summary> This is the common overridable drawing routine to create new widget </summary>
protected virtual void onDraw(Context gr)
{
Rectangle rBack = new Rectangle (Slot.Size);
@@ -586,6 +605,9 @@ namespace go BackgroundImage.Paint (gr, rBack, BackImgSub);
}
+ /// <summary>
+ /// Interfal drawing context creation on a chached surface limited to slot size
+ /// this trigger the effective drawing routine </summary>
protected virtual void UpdateGraphic ()
{
LastPaintedSlot = Slot;
@@ -605,7 +627,8 @@ namespace go //draw.WriteToPng ("/mnt/data/test.png");
}
}
-
+ /// <summary> Chained painting routine on the parent context of the actual cached version
+ /// of the widget </summary>
public virtual void Paint (ref Context ctx, Rectangles clip = null)
{
if (!Visible)
diff --git a/src/GraphicObjects/NumericControl.cs b/src/GraphicObjects/NumericControl.cs index d989f668..d22180be 100644 --- a/src/GraphicObjects/NumericControl.cs +++ b/src/GraphicObjects/NumericControl.cs @@ -20,8 +20,6 @@ namespace go } #endregion - - #region private fields double _actualValue, minValue, maxValue, smallStep, bigStep; #endregion @@ -38,7 +36,7 @@ namespace go } } - [XmlAttributeAttribute()][DefaultValue(10.0)] + [XmlAttributeAttribute()][DefaultValue(100.0)] public virtual double Maximum { get { return maxValue; } @@ -50,7 +48,7 @@ namespace go } } - [XmlAttributeAttribute()][DefaultValue(0.5)] + [XmlAttributeAttribute()][DefaultValue(1.0)] public virtual double SmallIncrement { get { return smallStep; } @@ -62,7 +60,7 @@ namespace go } } - [XmlAttributeAttribute()][DefaultValue(2.0)] + [XmlAttributeAttribute()][DefaultValue(5.0)] public virtual double LargeIncrement { get { return bigStep; } diff --git a/src/GraphicObjects/Scroller.cs b/src/GraphicObjects/Scroller.cs index b19c93ca..a413da94 100644 --- a/src/GraphicObjects/Scroller.cs +++ b/src/GraphicObjects/Scroller.cs @@ -76,8 +76,8 @@ namespace go [XmlIgnore]
public int MaximumScroll {
get {
- return VerticalScrolling ?
- Child.Slot.Height - ClientRectangle.Height :
+ return VerticalScrolling ?
+ child == null ? 0 : Child.Slot.Height - ClientRectangle.Height :
Child.Slot.Width - ClientRectangle.Width;
}
}
@@ -134,9 +134,6 @@ namespace go if (VerticalScrolling )
{
- //add redraw call with old bounds to errase old position
- RegisterForRedraw();
-
ScrollY -= e.Delta * ScrollSpeed;
if (ScrollY < 0.0)
@@ -147,9 +144,6 @@ namespace go }
if (HorizontalScrolling )
{
- //add redraw call with old bounds to errase old position
- RegisterForRedraw();
-
ScrollX -= e.Delta * ScrollSpeed;
if (ScrollX < 0.0)
@@ -157,11 +151,6 @@ namespace go else if (ScrollX > Child.Slot.Width - ClientRectangle.Width)
ScrollX = Child.Slot.Width - ClientRectangle.Width;
}
-
-
- //renderBounds.Y = -scrollY;
- //RegisterForRedraw();
- //Parent.registerForGraphicUpdate ();
}
#endregion
diff --git a/src/GraphicObjects/Slider.cs b/src/GraphicObjects/Slider.cs index cc9f2b05..0f5ba5d0 100644 --- a/src/GraphicObjects/Slider.cs +++ b/src/GraphicObjects/Slider.cs @@ -87,6 +87,8 @@ namespace go get { return base.Focusable; }
set { base.Focusable = value; }
}
+ //TODO:seems strange to trigger layout computation in an
+ //overriding of updateGraphic
protected override void UpdateGraphic ()
{
if (Maximum > 0)
diff --git a/src/GraphicObjects/Window.cs b/src/GraphicObjects/Window.cs index aae75a54..7eb910cc 100644 --- a/src/GraphicObjects/Window.cs +++ b/src/GraphicObjects/Window.cs @@ -54,7 +54,7 @@ namespace go void butQuitPress (object sender, MouseButtonEventArgs e) { - TopContainer.Quit (); + TopContainer.DeleteWidget (this); } |