[longomatch] Make more configurables the tagger icons sizes
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Make more configurables the tagger icons sizes
- Date: Mon, 7 Jul 2014 11:26:02 +0000 (UTC)
commit 61c28c4961b44bda649d472d83355b41d4cf0781
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Thu May 29 21:06:57 2014 +0200
Make more configurables the tagger icons sizes
LongoMatch.Core/Common/Enums.cs | 8 ++++
LongoMatch.Drawing/CanvasObject/PlayerObject.cs | 35 +++++++++++++------
LongoMatch.Drawing/Widgets/TeamTagger.cs | 41 +++++++++++++++--------
3 files changed, 59 insertions(+), 25 deletions(-)
---
diff --git a/LongoMatch.Core/Common/Enums.cs b/LongoMatch.Core/Common/Enums.cs
index cc8f2f2..7b2f4f5 100644
--- a/LongoMatch.Core/Common/Enums.cs
+++ b/LongoMatch.Core/Common/Enums.cs
@@ -213,5 +213,13 @@ namespace LongoMatch.Common
Multiple,
MultipleWithModifier,
}
+
+ public enum PlayersIconSize {
+ Smallest = 20,
+ Small = 30,
+ Medium = 40,
+ Large = 50,
+ ExtraLarge = 60
+ }
}
diff --git a/LongoMatch.Drawing/CanvasObject/PlayerObject.cs b/LongoMatch.Drawing/CanvasObject/PlayerObject.cs
index ecd350b..3373194 100644
--- a/LongoMatch.Drawing/CanvasObject/PlayerObject.cs
+++ b/LongoMatch.Drawing/CanvasObject/PlayerObject.cs
@@ -34,6 +34,7 @@ namespace LongoMatch.Drawing.CanvasObject
DrawPhoto = true;
SelectedColor = Common.PLAYER_SELECTED_COLOR;
UnSelectedColor = Common.PLAYER_UNSELECTED_COLOR;
+ IconSize = PlayersIconSize.Medium;
}
public Player Player {
@@ -46,14 +47,9 @@ namespace LongoMatch.Drawing.CanvasObject
set;
}
- public double Width {
- get;
+ public PlayersIconSize IconSize {
set;
- }
-
- public double Height {
get;
- set;
}
public bool DrawPhoto {
@@ -71,6 +67,18 @@ namespace LongoMatch.Drawing.CanvasObject
set;
}
+ int Width {
+ get {
+ return (int)IconSize;
+ }
+ }
+
+ int Height {
+ get {
+ return (int)IconSize;
+ }
+ }
+
public Selection GetSelection (Point point, double precision) {
Point position = new Point (Position.X - Width / 2, Position.Y - Height / 2);
@@ -104,14 +112,19 @@ namespace LongoMatch.Drawing.CanvasObject
tk.LineWidth = 5;
tk.DrawRoundedRectangle (position, Width, Height, 5);
- if (!DrawPhoto || Player.Photo == null) {
+ if (!DrawPhoto || Player.Photo == null || IconSize < PlayersIconSize.Medium) {
tk.FillColor = Color.White;
tk.StrokeColor = Color.White;
- tk.FontSize = 30;
+ tk.FontSize = Width / 2;
tk.FontWeight = FontWeight.Bold;
- tk.DrawText (position, Width, Height - 20, Player.Number.ToString());
- tk.FontSize = 8;
- tk.DrawText (new Point (position.X, position.Y + Height - 20), Width, 20,
Player.Name);
+ /* Only draw player number for the smaller size */
+ if (IconSize > PlayersIconSize.Small) {
+ tk.DrawText (position, Width, Height - 20, Player.Number.ToString());
+ tk.FontSize = 8;
+ tk.DrawText (new Point (position.X, position.Y + Height - 20), Width,
20, Player.Name);
+ } else {
+ tk.DrawText (position, Width, Height, Player.Number.ToString());
+ }
} else {
tk.FillColor = Color.Black;
tk.StrokeColor = Color.Black;
diff --git a/LongoMatch.Drawing/Widgets/TeamTagger.cs b/LongoMatch.Drawing/Widgets/TeamTagger.cs
index 3439de0..0796beb 100644
--- a/LongoMatch.Drawing/Widgets/TeamTagger.cs
+++ b/LongoMatch.Drawing/Widgets/TeamTagger.cs
@@ -34,9 +34,6 @@ namespace LongoMatch.Drawing.Widgets
public event PlayersPropertiesHandler PlayersSelectionChangedEvent;
public event PlayersPropertiesHandler ShowMenuEvent;
- const int PLAYER_WIDTH = 60;
- const int PLAYER_HEIGHT = 60;
- const int BENCH_WIDTH = PLAYER_WIDTH * 2;
TeamTemplate homeTeam, awayTeam;
Image background;
double currentWidth, currentHeight, scaleX, scaleY;
@@ -52,6 +49,8 @@ namespace LongoMatch.Drawing.Widgets
SubstitutionsMode = false;
HomeColor = Common.PLAYER_UNSELECTED_COLOR;
AwayColor = Common.PLAYER_UNSELECTED_COLOR;
+ PlayersPorRowInBench = 2;
+ BenchIconSize = PlayersIconSize.Small;
}
public Color HomeColor {
@@ -64,6 +63,16 @@ namespace LongoMatch.Drawing.Widgets
set;
}
+ public int PlayersPorRowInBench {
+ get;
+ set;
+ }
+
+ public PlayersIconSize BenchIconSize {
+ get;
+ set;
+ }
+
public void LoadTeams (TeamTemplate homeTeam, TeamTemplate awayTeam, Image background) {
this.homeTeam = homeTeam;
this.awayTeam = awayTeam;
@@ -115,6 +124,11 @@ namespace LongoMatch.Drawing.Widgets
}
}
+ int BenchWidth {
+ get {
+ return PlayersPorRowInBench * (int)BenchIconSize;
+ }
+ }
void LoadTeam (TeamTemplate template, Team team) {
int index = 0;
@@ -124,10 +138,10 @@ namespace LongoMatch.Drawing.Widgets
width = backgroundWidth / NTeams;
colWidth = width / template.Formation.Length;
if (team == Team.LOCAL) {
- offsetX = BENCH_WIDTH;
+ offsetX = BenchWidth;
color = HomeColor;
} else {
- offsetX = currentWidth - BENCH_WIDTH;
+ offsetX = currentWidth - BenchWidth;
color = AwayColor;
}
@@ -148,8 +162,7 @@ namespace LongoMatch.Drawing.Widgets
for (int row=0; row < template.Formation[col]; row ++) {
Point p = new Point (colX, rowHeight * row + rowHeight / 2);
PlayerObject po = new PlayerObject (template [index], p);
- po.Width = PLAYER_WIDTH;
- po.Height = PLAYER_HEIGHT;
+ po.IconSize = PlayersIconSize.Large;
po.UnSelectedColor = color;
Objects.Add (po);
index ++;
@@ -162,16 +175,16 @@ namespace LongoMatch.Drawing.Widgets
PlayerObject po;
double x, y;
int reli = i - index;
+ int size = (int)BenchIconSize;
- x = PLAYER_WIDTH * (reli % 2) + PLAYER_WIDTH / 2;
- y = PLAYER_HEIGHT * (reli / 2) + PLAYER_HEIGHT / 2;
+ x = size * (reli % PlayersPorRowInBench) + size / 2;
+ y = size * (reli / PlayersPorRowInBench) + size / 2;
if (team == Team.VISITOR) {
- x += BENCH_WIDTH + backgroundWidth;
+ x += BenchWidth + backgroundWidth;
}
po = new PlayerObject (template [i], new Point (x, y));
- po.Width = PLAYER_WIDTH;
- po.Height = PLAYER_HEIGHT;
+ po.IconSize = PlayersIconSize.Small;
po.UnSelectedColor = color;
Objects.Add (po);
}
@@ -180,7 +193,7 @@ namespace LongoMatch.Drawing.Widgets
void Resize () {
currentWidth = widget.Width;
currentHeight = widget.Height;
- backgroundWidth = currentWidth - BENCH_WIDTH * NTeams;
+ backgroundWidth = currentWidth - BenchWidth * NTeams;
if (background != null) {
background.ScaleFactor ((int) backgroundWidth, (int) currentHeight,
@@ -249,7 +262,7 @@ namespace LongoMatch.Drawing.Widgets
/* Background */
if (background != null) {
- tk.DrawImage (new Point (BENCH_WIDTH, 0), backgroundWidth, currentHeight,
+ tk.DrawImage (new Point (BenchWidth, 0), backgroundWidth, currentHeight,
background, false);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]