gbrainy r306 - trunk/src



Author: jmas
Date: Tue Apr 22 19:30:30 2008
New Revision: 306
URL: http://svn.gnome.org/viewvc/gbrainy?rev=306&view=rev

Log:
2008-04-22 Jordi Irazuzta <irazuzta gmail com> and Jordi Mas

	* GameDrawingArea.cs: Use a square drawing area
	* CustomGameDialog.cs: Use a square drawing area
	* gbrainy.glade: Better expansion parameters



Modified:
   trunk/src/ChangeLog
   trunk/src/CustomGameDialog.cs
   trunk/src/GameDrawingArea.cs
   trunk/src/gbrainy.glade

Modified: trunk/src/CustomGameDialog.cs
==============================================================================
--- trunk/src/CustomGameDialog.cs	(original)
+++ trunk/src/CustomGameDialog.cs	Tue Apr 22 19:30:30 2008
@@ -215,12 +215,24 @@
 			if(!IsRealized)
 				return false;
 
-			int w, h;
+			int w, h, nw, nh;
+			double x = 0, y = 0;
 			Cairo.Context cc = Gdk.CairoHelper.Create (args.Window);
 			CairoContextEx cr = new CairoContextEx (cc.Handle);   
 			args.Window.GetSize (out w, out h);
-			puzzle.DrawPreview (cr, w, h);
 
+			nh = nw = Math.Min (w, h);
+
+			if (nw < w) {
+				x = (w - nw) / 2;
+			}
+
+			if (nh < h) {
+				y = (h - nh) / 2;
+			}
+
+			cr.Translate (x, y);
+			puzzle.DrawPreview (cr, nw, nh);
 			((IDisposable)cc).Dispose();
 			((IDisposable)cr).Dispose();
    			return base.OnExposeEvent(args);

Modified: trunk/src/GameDrawingArea.cs
==============================================================================
--- trunk/src/GameDrawingArea.cs	(original)
+++ trunk/src/GameDrawingArea.cs	Tue Apr 22 19:30:30 2008
@@ -109,7 +109,7 @@
 			gr.Paint ();
 			gr.Restore ();
 		}
-		gr.DrawStringWithWrapping (0.21, y + 0.03, line_space, Catalog.GetString ("Logic puzzles. Designed to challenge your reasoning and thinking skills."));
+		gr.DrawStringWithWrapping (0.23, y + 0.03, line_space, Catalog.GetString ("Logic puzzles. Designed to challenge your reasoning and thinking skills."));
 
 		y += space;
 		image = new ImageSurface (Defines.DATA_DIR + "math-games-80.png");
@@ -121,7 +121,7 @@
 			gr.Paint ();
 			gr.Restore ();
 		}
-		gr.DrawStringWithWrapping (0.21, y + 0.03, line_space, Catalog.GetString ("Mental calculation. Based on arithmetical operations that test your mental calculation abilities."));
+		gr.DrawStringWithWrapping (0.23, y + 0.03, line_space, Catalog.GetString ("Mental calculation. Based on arithmetical operations that test your mental calculation abilities."));
 
 		y += space;
 		image = new ImageSurface (Defines.DATA_DIR + "memory-games-80.png");
@@ -133,7 +133,7 @@
 			gr.Paint ();
 			gr.Restore ();
 		}
-		gr.DrawStringWithWrapping (0.21, y + 0.03, line_space, Catalog.GetString ("Memory trainers. To prove and enhance your short term memory."));
+		gr.DrawStringWithWrapping (0.23, y + 0.03, line_space, Catalog.GetString ("Memory trainers. To prove and enhance your short term memory."));
 		gr.Stroke ();
 
 		gr.DrawStringWithWrapping (0.05, y + 0.23, line_space, Catalog.GetString ("Use the Settings to adjust the difficulty level of the game."));
@@ -327,23 +327,37 @@
 		if(!IsRealized)
 			return false;
 
-		int w, h;
+		int w, h, nw, nh;
+		double x = 0, y = 0;
 		args.Window.GetSize (out w, out h);
 		Cairo.Context cc = Gdk.CairoHelper.Create (args.Window);
 		CairoContextEx cr = new CairoContextEx (cc.Handle);
 
+		// We want a square drawing area for the puzzles then the figures are shown as designed. 
+		// For example, squares are squares. This also makes sure that proportions are kept when resizing
+		nh = nw = Math.Min (w, h);
+
+		if (nw < w) {
+			x = (w - nw) / 2;
+		}
+
+		if (nh < h) {
+			y = (h - nh) / 2;
+		}
+
+		cr.Translate (x, y);
 		switch (mode) {
 		case Modes.Welcome:
-			DrawWelcome (cr, w, h);
+			DrawWelcome (cr, nw, nh);
 			break;
 		case Modes.Scores:
-			DrawScores (cr, w, h);
+			DrawScores (cr, nw, nh);
 			break;	
 		case Modes.Puzzle:
-			puzzle.Draw (cr, w, h);
+			puzzle.Draw (cr, nw, nh);
 			break;
 		case Modes.CountDown:
-			DrawCountDown (cr, w, h);
+			DrawCountDown (cr, nw, nh);
 			break;
 		}
 

Modified: trunk/src/gbrainy.glade
==============================================================================
--- trunk/src/gbrainy.glade	(original)
+++ trunk/src/gbrainy.glade	Tue Apr 22 19:30:30 2008
@@ -205,7 +205,7 @@
 	</widget>
 	<packing>
 	  <property name="padding">0</property>
-	  <property name="expand">True</property>
+	  <property name="expand">False</property>
 	  <property name="fill">True</property>
 	</packing>
       </child>
@@ -261,7 +261,7 @@
 	</widget>
 	<packing>
 	  <property name="padding">0</property>
-	  <property name="expand">True</property>
+	  <property name="expand">False</property>
 	  <property name="fill">True</property>
 	</packing>
       </child>
@@ -320,13 +320,14 @@
 	</widget>
 	<packing>
 	  <property name="padding">0</property>
-	  <property name="expand">True</property>
+	  <property name="expand">False</property>
 	  <property name="fill">True</property>
 	</packing>
       </child>
 
       <child>
 	<widget class="GtkVBox" id="vbox5">
+	  <property name="width_request">500</property>
 	  <property name="visible">True</property>
 	  <property name="homogeneous">False</property>
 	  <property name="spacing">0</property>
@@ -369,28 +370,6 @@
 	      </child>
 
 	      <child>
-		<widget class="GtkEntry" id="answer_entry">
-		  <property name="visible">True</property>
-		  <property name="can_focus">True</property>
-		  <property name="editable">True</property>
-		  <property name="visibility">True</property>
-		  <property name="max_length">0</property>
-		  <property name="text" translatable="yes"></property>
-		  <property name="has_frame">True</property>
-		  <property name="invisible_char">â</property>
-		  <property name="activates_default">False</property>
-		  <signal name="activate" handler="OnAnswerActivate" last_modification_time="Mon, 17 Sep 2007 17:14:48 GMT"/>
-		</widget>
-		<packing>
-		  <property name="left_attach">1</property>
-		  <property name="right_attach">2</property>
-		  <property name="top_attach">0</property>
-		  <property name="bottom_attach">1</property>
-		  <property name="y_options"></property>
-		</packing>
-	      </child>
-
-	      <child>
 		<widget class="GtkButton" id="answer_button">
 		  <property name="visible">True</property>
 		  <property name="can_focus">True</property>
@@ -573,6 +552,29 @@
 		  <property name="y_options"></property>
 		</packing>
 	      </child>
+
+	      <child>
+		<widget class="GtkEntry" id="answer_entry">
+		  <property name="visible">True</property>
+		  <property name="can_focus">True</property>
+		  <property name="editable">True</property>
+		  <property name="visibility">True</property>
+		  <property name="max_length">0</property>
+		  <property name="text" translatable="yes"></property>
+		  <property name="has_frame">True</property>
+		  <property name="invisible_char">â</property>
+		  <property name="activates_default">False</property>
+		  <signal name="activate" handler="OnAnswerActivate" last_modification_time="Mon, 17 Sep 2007 17:14:48 GMT"/>
+		</widget>
+		<packing>
+		  <property name="left_attach">1</property>
+		  <property name="right_attach">2</property>
+		  <property name="top_attach">0</property>
+		  <property name="bottom_attach">1</property>
+		  <property name="x_options">expand|shrink|fill</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
 	    </widget>
 	    <packing>
 	      <property name="padding">0</property>
@@ -583,7 +585,7 @@
 	</widget>
 	<packing>
 	  <property name="padding">0</property>
-	  <property name="expand">True</property>
+	  <property name="expand">False</property>
 	  <property name="fill">True</property>
 	</packing>
       </child>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]