[gbrainy] Show total drawing area when in design mode, more validations and little refactoring
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy] Show total drawing area when in design mode, more validations and little refactoring
- Date: Sat, 19 Jan 2013 08:29:43 +0000 (UTC)
commit 728122c9e9738b1c32c5b62502fc0d60f9ccc5f5
Author: Jordi Mas <jmas softcatala org>
Date: Sat Jan 19 09:32:09 2013 +0100
Show total drawing area when in design mode, more validations and little refactoring
src/Core/Main/Game.cs | 8 +++++++
src/Core/Toolkit/Container.cs | 6 +++++
src/Core/Toolkit/HorizontalContainer.cs | 32 ++++++++++++++++++------------
3 files changed, 33 insertions(+), 13 deletions(-)
---
diff --git a/src/Core/Main/Game.cs b/src/Core/Main/Game.cs
index 90640e4..78c9cdb 100644
--- a/src/Core/Main/Game.cs
+++ b/src/Core/Main/Game.cs
@@ -291,6 +291,14 @@ namespace gbrainy.Core.Main
foreach (Toolkit.Container container in containers)
container.Draw (gr, width, height, rtl);
+
+#if DESIGN_MODE
+ gr.Save ();
+ gr.Color = new Cairo.Color (0, 1, 0);
+ gr.Rectangle (0, 0, 1, 1);
+ gr.Stroke ();
+ gr.Restore ();
+#endif
}
public virtual void DrawPreview (CairoContextEx gr, int width, int height, bool rtl)
diff --git a/src/Core/Toolkit/Container.cs b/src/Core/Toolkit/Container.cs
index 9d6006a..106198f 100644
--- a/src/Core/Toolkit/Container.cs
+++ b/src/Core/Toolkit/Container.cs
@@ -45,6 +45,12 @@ namespace gbrainy.Core.Toolkit
if (y < 0 || y > 1)
throw new ArgumentOutOfRangeException ("y");
+ if (width + x < 0 || width + x > 1)
+ throw new ArgumentOutOfRangeException ("width");
+
+ if (height + y < 0 || height + y > 1)
+ throw new ArgumentOutOfRangeException ("height");
+
X = x;
Y = y;
}
diff --git a/src/Core/Toolkit/HorizontalContainer.cs b/src/Core/Toolkit/HorizontalContainer.cs
index 60eb710..1f79ae3 100644
--- a/src/Core/Toolkit/HorizontalContainer.cs
+++ b/src/Core/Toolkit/HorizontalContainer.cs
@@ -32,21 +32,10 @@ namespace gbrainy.Core.Toolkit
public HorizontalContainer (double x, double y, double width, double height) : base (x, y, width, height)
{
- }
+ }
- public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
+ void ValidateDimensions ()
{
- double x = X, y = Y;
-
- this.rtl = rtl;
-
-#if DESIGN_MODE
- gr.Save ();
- gr.Color = new Cairo.Color (0, 0, 1);
- gr.Rectangle (X, Y, Width, Height);
- gr.Stroke ();
- gr.Restore ();
-
double width = 0;
foreach (Widget child in children)
@@ -59,7 +48,24 @@ namespace gbrainy.Core.Toolkit
if (Width < width)
throw new InvalidOperationException (String.Format ("Container witdh too small {0} < {1}", Width, width));
+ }
+
+ public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
+ {
+ double x = X, y = Y;
+
+ this.rtl = rtl;
+
+#if DESIGN_MODE
+ gr.Save ();
+ gr.Color = new Cairo.Color (0, 0, 1);
+ gr.Rectangle (X, Y, Width, Height);
+ gr.Stroke ();
+ gr.Restore ();
+
+ ValidateDimensions ();
#endif
+
//
// Coordinates are stored right to left
//
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]