[longomatch] Add support for images in dashboard buttons
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add support for images in dashboard buttons
- Date: Wed, 8 Oct 2014 00:11:33 +0000 (UTC)
commit 8c587430b323b971805e531ecf74c7c20dac0a93
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sun Oct 5 20:05:13 2014 +0200
Add support for images in dashboard buttons
Start with drawing the team shield for timer buttons
LongoMatch.Core/Store/DashboardButton.cs | 5 ++
LongoMatch.Drawing/CanvasObjects/ButtonObject.cs | 45 +++++++++++++------
LongoMatch.Drawing/CanvasObjects/CategoryObject.cs | 1 +
LongoMatch.Drawing/CanvasObjects/ScoreObject.cs | 23 +++-------
LongoMatch.Drawing/CanvasObjects/TagObject.cs | 21 +++------
LongoMatch.Drawing/CanvasObjects/TaggerObject.cs | 29 ++++++++++---
LongoMatch.Drawing/CanvasObjects/TimerObject.cs | 15 +++++++
LongoMatch.Drawing/Widgets/DashboardCanvas.cs | 13 +++++-
LongoMatch.GUI/Gui/Component/DashboardWidget.cs | 1 +
9 files changed, 102 insertions(+), 51 deletions(-)
---
diff --git a/LongoMatch.Core/Store/DashboardButton.cs b/LongoMatch.Core/Store/DashboardButton.cs
index 2d9687e..7b61f17 100644
--- a/LongoMatch.Core/Store/DashboardButton.cs
+++ b/LongoMatch.Core/Store/DashboardButton.cs
@@ -71,6 +71,11 @@ namespace LongoMatch.Core.Store
set;
}
+ public virtual Image BackgroundImage {
+ get;
+ set;
+ }
+
[JsonIgnore]
public Color LightColor {
get {
diff --git a/LongoMatch.Drawing/CanvasObjects/ButtonObject.cs
b/LongoMatch.Drawing/CanvasObjects/ButtonObject.cs
index 4af4fa5..06d924c 100644
--- a/LongoMatch.Drawing/CanvasObjects/ButtonObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/ButtonObject.cs
@@ -29,6 +29,7 @@ namespace LongoMatch.Drawing.CanvasObjects
public ButtonObject () {
BackgroundColor = Config.Style.PaletteBackground;
BorderColor = Config.Style.PaletteBackgroundDark;
+ TextColor = Config.Style.PaletteText;
}
public virtual Point Position {
@@ -46,7 +47,7 @@ namespace LongoMatch.Drawing.CanvasObjects
set;
}
- public string Text {
+ public virtual string Text {
get;
set;
}
@@ -61,6 +62,11 @@ namespace LongoMatch.Drawing.CanvasObjects
set;
}
+ public virtual Color TextColor {
+ get;
+ set;
+ }
+
protected Color CurrentBackgroundColor {
get {
if (!Active) {
@@ -71,12 +77,12 @@ namespace LongoMatch.Drawing.CanvasObjects
}
}
- public Image BackgroundImage {
+ public virtual Image BackgroundImage {
get;
set;
}
- public Image BackgroundImageActive {
+ public virtual Image BackgroundImageActive {
get;
set;
}
@@ -166,25 +172,36 @@ namespace LongoMatch.Drawing.CanvasObjects
tk.DrawButton (DrawPosition, Width, Height, 3, BorderColor, CurrentBackgroundColor);
}
- public override void Draw (IDrawingToolkit tk, Area area)
+ protected void DrawImage (IDrawingToolkit tk)
{
- Point pos = new Point (Position.X + BORDER_SIZE / 2, Position.Y + BORDER_SIZE / 2);
-
- if (!UpdateDrawArea (tk, area, new Area (Position, Width, Height))) {
- return;
- }
- tk.Begin ();
- DrawButton (tk);
- DrawSelectionArea (tk);
-
+ Point pos = new Point (DrawPosition.X + BORDER_SIZE / 2, DrawPosition.Y + BORDER_SIZE
/ 2);
+
if (Active && BackgroundImageActive != null) {
tk.DrawImage (pos, Width - BORDER_SIZE, Height - BORDER_SIZE,
BackgroundImageActive, true);
} else if (BackgroundImage != null) {
tk.DrawImage (pos, Width - BORDER_SIZE, Height - BORDER_SIZE,
BackgroundImage, true);
}
+ }
+
+ protected void DrawText (IDrawingToolkit tk)
+ {
if (Text != null) {
- tk.DrawText (Position, Width, Height, Text);
+ tk.FillColor = TextColor;
+ tk.StrokeColor = TextColor;
+ tk.DrawText (DrawPosition, Width, Height, Text);
+ }
+ }
+
+ public override void Draw (IDrawingToolkit tk, Area area)
+ {
+ if (!UpdateDrawArea (tk, area, new Area (Position, Width, Height))) {
+ return;
}
+ tk.Begin ();
+ DrawButton (tk);
+ DrawImage (tk);
+ DrawSelectionArea (tk);
+ DrawText (tk);
tk.End ();
}
}
diff --git a/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs
b/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs
index 13e15dd..7a297be 100644
--- a/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs
@@ -152,6 +152,7 @@ namespace LongoMatch.Drawing.CanvasObjects
/* Draw Rectangle */
DrawButton (tk);
+ DrawImage (tk);
/* Draw header */
tk.FillColor = LongoMatch.Core.Common.Color.Grey2;
diff --git a/LongoMatch.Drawing/CanvasObjects/ScoreObject.cs b/LongoMatch.Drawing/CanvasObjects/ScoreObject.cs
index 6174f94..bef8725 100644
--- a/LongoMatch.Drawing/CanvasObjects/ScoreObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/ScoreObject.cs
@@ -35,24 +35,15 @@ namespace LongoMatch.Drawing.CanvasObjects
set;
}
- public override void Draw (IDrawingToolkit tk, Area area)
- {
- if (!UpdateDrawArea (tk, area, new Area (Position, Width, Height))) {
- return;
+ public override string Text {
+ get {
+ return Button.Name;
}
+ }
- tk.Begin ();
-
- /* Draw Rectangle */
- DrawButton (tk);
-
- /* Draw header */
- tk.LineWidth = 2;
- tk.StrokeColor = Button.TextColor;
- tk.FillColor = Button.TextColor;
- tk.DrawText (DrawPosition, Button.Width, Button.Height, Button.Score.Name);
- DrawSelectionArea (tk);
- tk.End ();
+ public override void Draw (IDrawingToolkit tk, Area area)
+ {
+ base.Draw (tk, area);
}
}
}
diff --git a/LongoMatch.Drawing/CanvasObjects/TagObject.cs b/LongoMatch.Drawing/CanvasObjects/TagObject.cs
index ca53ef3..eb1b3e7 100644
--- a/LongoMatch.Drawing/CanvasObjects/TagObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/TagObject.cs
@@ -36,22 +36,15 @@ namespace LongoMatch.Drawing.CanvasObjects
set;
}
- public override void Draw (IDrawingToolkit tk, Area area)
- {
- if (!UpdateDrawArea (tk, area, new Area (Position, Width, Height))) {
- return;
+ public override string Text {
+ get {
+ return TagButton.Tag.Value;
}
+ }
- tk.Begin ();
- /* Draw Rectangle */
- DrawButton (tk);
- /* Draw header */
- tk.LineWidth = 2;
- tk.StrokeColor = TagButton.TextColor;
- tk.FillColor = TagButton.TextColor;
- tk.DrawText (DrawPosition, TagButton.Width, TagButton.Height, TagButton.Tag.Value);
- DrawSelectionArea (tk);
- tk.End ();
+ public override void Draw (IDrawingToolkit tk, Area area)
+ {
+ base.Draw (tk, area);
}
}
}
diff --git a/LongoMatch.Drawing/CanvasObjects/TaggerObject.cs
b/LongoMatch.Drawing/CanvasObjects/TaggerObject.cs
index 3d33d4a..bb5ab00 100644
--- a/LongoMatch.Drawing/CanvasObjects/TaggerObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/TaggerObject.cs
@@ -25,7 +25,7 @@ using LongoMatch.Core.Handlers;
namespace LongoMatch.Drawing.CanvasObjects
{
- public class TaggerObject: ButtonObject, ICanvasSelectableObject
+ public class TaggerObject: ButtonObject, ICanvasSelectableObject
{
public TaggerObject (DashboardButton tagger)
@@ -46,22 +46,22 @@ namespace LongoMatch.Drawing.CanvasObjects
Tagger.Position = value;
}
}
-
+
public override double Width {
get {
return Tagger.Width;
}
set {
- Tagger.Width = (int) value;
+ Tagger.Width = (int)value;
}
}
-
+
public override double Height {
get {
return Tagger.Height;
}
set {
- Tagger.Height = (int) value;
+ Tagger.Height = (int)value;
}
}
@@ -77,6 +77,24 @@ namespace LongoMatch.Drawing.CanvasObjects
}
}
+ public override Color TextColor {
+ get {
+ return Tagger.TextColor;
+ }
+ }
+
+ public override Image BackgroundImage {
+ get {
+ return Tagger.BackgroundImage;
+ }
+ }
+
+ public override Image BackgroundImageActive {
+ get {
+ return Tagger.BackgroundImage;
+ }
+ }
+
public virtual int NRows {
get {
return 1;
@@ -87,7 +105,6 @@ namespace LongoMatch.Drawing.CanvasObjects
get;
set;
}
-
}
}
diff --git a/LongoMatch.Drawing/CanvasObjects/TimerObject.cs b/LongoMatch.Drawing/CanvasObjects/TimerObject.cs
index 0c2a812..abe9017 100644
--- a/LongoMatch.Drawing/CanvasObjects/TimerObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/TimerObject.cs
@@ -27,6 +27,7 @@ namespace LongoMatch.Drawing.CanvasObjects
public class TimerObject: TaggerObject
{
Time currentTime;
+ Image backgroundImage;
public TimerObject (TimerButton timer): base (timer)
{
@@ -79,6 +80,19 @@ namespace LongoMatch.Drawing.CanvasObjects
}
}
+ public override Image BackgroundImage {
+ get {
+ if (backgroundImage != null) {
+ return backgroundImage;
+ } else {
+ return Button.BackgroundImage;
+ }
+ }
+ set {
+ backgroundImage = value;
+ }
+ }
+
public override void ClickReleased ()
{
TimeNode tn;
@@ -113,6 +127,7 @@ namespace LongoMatch.Drawing.CanvasObjects
tk.Begin ();
/* Draw Rectangle */
DrawButton (tk);
+ DrawImage (tk);
/* Draw header */
tk.LineWidth = 2;
diff --git a/LongoMatch.Drawing/Widgets/DashboardCanvas.cs b/LongoMatch.Drawing/Widgets/DashboardCanvas.cs
index e6696f5..517bef6 100644
--- a/LongoMatch.Drawing/Widgets/DashboardCanvas.cs
+++ b/LongoMatch.Drawing/Widgets/DashboardCanvas.cs
@@ -53,6 +53,11 @@ namespace LongoMatch.Drawing.Widgets
AddTag = new Tag ("", "");
}
+ public Project Project {
+ get;
+ set;
+ }
+
public Dashboard Template {
set {
template = value;
@@ -221,7 +226,6 @@ namespace LongoMatch.Drawing.Widgets
co.AddTag = AddTag;
AddObject (co);
}
-
foreach (PenaltyCardButton c in template.List.OfType<PenaltyCardButton>()) {
CardObject co = new CardObject (c);
co.ClickedEvent += HandleTaggerClickedEvent;
@@ -239,6 +243,13 @@ namespace LongoMatch.Drawing.Widgets
TimerObject to = new TimerObject (t);
to.ClickedEvent += HandleTaggerClickedEvent;
to.Mode = TagMode;
+ if (Project != null && t.BackgroundImage == null) {
+ if (t.Timer.Team == Team.LOCAL) {
+ to.BackgroundImage = Project.LocalTeamTemplate.Shield;
+ } else if (t.Timer.Team == Team.VISITOR) {
+ to.BackgroundImage = Project.VisitorTeamTemplate.Shield;
+ }
+ }
AddObject (to);
}
Edited = false;
diff --git a/LongoMatch.GUI/Gui/Component/DashboardWidget.cs b/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
index c743d72..8025792 100644
--- a/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
@@ -138,6 +138,7 @@ namespace LongoMatch.Gui.Component
public Project Project {
set {
project = value;
+ tagger.Project = project;
Template = project.Dashboard;
positionsbox.Visible = false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]