[longomatch] Add a new base class for a canvas with a scaled background image
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add a new base class for a canvas with a scaled background image
- Date: Mon, 7 Jul 2014 11:28:58 +0000 (UTC)
commit 4255e88c75b3b230aa7a7c41754e1d20a966f276
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Tue Jun 17 18:51:04 2014 +0200
Add a new base class for a canvas with a scaled background image
LongoMatch.Drawing/Canvas.cs | 38 +++++++++++++++++++++++++++++++++++++-
1 files changed, 37 insertions(+), 1 deletions(-)
---
diff --git a/LongoMatch.Drawing/Canvas.cs b/LongoMatch.Drawing/Canvas.cs
index f425c2d..8c91b1f 100644
--- a/LongoMatch.Drawing/Canvas.cs
+++ b/LongoMatch.Drawing/Canvas.cs
@@ -211,7 +211,43 @@ namespace LongoMatch.Drawing
}
lastTime = time;
}
+ }
+
+ public abstract class BackgroundCanvas: SelectionCanvas
+ {
+
+ Image background;
+
+ public BackgroundCanvas (IWidget widget): base (widget) {
+ widget.SizeChangedEvent += HandleSizeChangedEvent;;
+ }
+
+ public Image Background {
+ set {
+ background = value;
+ HandleSizeChangedEvent ();
+ }
+ get {
+ return background;
+ }
+ }
+ protected virtual void HandleSizeChangedEvent ()
+ {
+ if (background != null) {
+ background.ScaleFactor ((int) widget.Width, (int) widget.Height, out scaleX,
+ out scaleY, out translation);
+ }
+ }
+
+ protected override void HandleDraw (object context, Area area)
+ {
+ tk.Context = context;
+ tk.Begin ();
+ tk.TranslateAndScale (translation, new Point (scaleX, scaleY));
+ tk.DrawImage (Background);
+ tk.End ();
+ base.HandleDraw (context, area);
+ }
}
}
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]