[gnome-chess] 2D: fix board numbering when Black is on bottom
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess] 2D: fix board numbering when Black is on bottom
- Date: Sat, 20 Jul 2013 02:25:51 +0000 (UTC)
commit fb6393114d4c343bc54db480937f38c01734b017
Author: Michael Catanzaro <mike catanzaro gmail com>
Date: Sun Jul 14 22:35:38 2013 -0500
2D: fix board numbering when Black is on bottom
https://bugzilla.gnome.org/show_bug.cgi?id=703837
src/chess-view-2d.vala | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/src/chess-view-2d.vala b/src/chess-view-2d.vala
index 6bb7d7d..b0daa23 100644
--- a/src/chess-view-2d.vala
+++ b/src/chess-view-2d.vala
@@ -124,9 +124,6 @@ private class ChessView2D : ChessView
if (scene.show_numbering)
{
- string[] files = { "a", "b", "c", "d", "e", "f", "g", "h" };
- string[] ranks = { "8", "7", "6", "5", "4", "3", "2", "1" };
-
/* Files are centered individiual glyph width and combined glyph height,
* ranks are centered on individual glyph widths and heights */
@@ -143,6 +140,27 @@ private class ChessView2D : ChessView
double file_offset = -(square_size * 3.5);
double rank_offset = -(square_size * 3.5);
+ string[] files;
+ string[] ranks;
+
+ Cairo.Matrix matrix = c.get_matrix ();
+
+ if (scene.board_angle == 180.0)
+ {
+ files = { "h", "g", "f", "e", "d", "c", "b", "a" };
+ ranks = { "1", "2", "3", "4", "5", "6", "7", "8" };
+
+ matrix.scale (-1, -1);
+ }
+ else
+ {
+ files = { "a", "b", "c", "d", "e", "f", "g", "h" };
+ ranks = { "8", "7", "6", "5", "4", "3", "2", "1" };
+ }
+
+ c.save ();
+ c.set_matrix (matrix);
+
for (int i = 0; i < 8; i++)
{
c.text_extents (ranks[i], out extents);
@@ -177,6 +195,8 @@ private class ChessView2D : ChessView
file_offset += square_size;
rank_offset += square_size;
}
+
+ c.restore ();
}
/* Draw the pieces */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]