Skip to content

Commit

Permalink
Few minor additions to the control from earlier.
Browse files Browse the repository at this point in the history
  • Loading branch information
keelin committed Aug 3, 2013
1 parent a6af256 commit e6bb5db
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 10 deletions.
11 changes: 10 additions & 1 deletion ClientServices/UserInterface/Components/ScrollableContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,18 @@ public override void MouseMove(MouseInputEventArgs e)

public override bool MouseWheelMove(MouseInputEventArgs e)
{
MouseInputEventArgs modArgs = new MouseInputEventArgs
(e.Buttons,
e.ShiftButtons,
new Vector2D(e.Position.X - Position.X + scrollbarH.Value, e.Position.Y - Position.Y + scrollbarV.Value),
e.WheelPosition,
e.RelativePosition,
e.WheelDelta,
e.ClickCount);

if (inner_focus != null)
{
if (inner_focus.MouseWheelMove(e))
if (inner_focus.MouseWheelMove(modArgs))
return true;
else
if (scrollbarV.IsVisible() && ClientArea.Contains(new Point((int)e.Position.X, (int)e.Position.Y)))
Expand Down
49 changes: 40 additions & 9 deletions ClientServices/UserInterface/Components/Showcase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ internal class Showcase : GuiComponent
private List<KeyValuePair<ImageButton, Object>> _items = new List<KeyValuePair<ImageButton, object>>();
private int _selected = 0;

public int DisplayAmount = 2; //Number of additional visible columns beside the selection. 1 = 3 total visible. selection + 1 left + 1 right.
public int ItemSpacing = 10; //Additional space between items.
public int AdditionalColumns = 2; //Number of additional visible columns beside the selection. 1 = 3 total visible. selection + 1 left + 1 right.
public int ItemSpacing = 10; //Additional space between items.

public Size Size = new Size(300, 100);

Expand All @@ -48,6 +48,16 @@ public string ButtonLeft
set { _buttonLeft.ImageNormal = value; }
}

public string SelectionBackground
{
get
{
if (_selectionGlow != null) return _selectionGlow.Sprite;
else return "";
}
set { _selectionGlow.Sprite = value; }
}

public event ShowcaseSelectionChangedHandler SelectionChanged;

private SimpleImage _selectionGlow;
Expand All @@ -62,10 +72,7 @@ public Showcase()
_buttonRight = new ImageButton();
_buttonRight.Clicked += new ImageButton.ImageButtonPressHandler(_buttonRight_Clicked);

_selectionGlow = new SimpleImage() //TODO add way to change this.
{
Sprite = "job_glow"
};
_selectionGlow = new SimpleImage();

Update(0);
}
Expand Down Expand Up @@ -153,19 +160,24 @@ public override void Render()

KeyValuePair<ImageButton, Object> selected = _items[_selected];
selected.Key.Position = new Point(ClientArea.Left + (int)(ClientArea.Width / 2f - selected.Key.ClientArea.Width / 2f), ClientArea.Top + (int)(ClientArea.Height / 2f - selected.Key.ClientArea.Height / 2f));
selected.Key.Color = Color.FromArgb(255, Color.White);
selected.Key.Render();

int lastPosLeft = selected.Key.ClientArea.Left - ItemSpacing;
int lastPosRight = selected.Key.ClientArea.Right + ItemSpacing;

for (int i = 1; i <= DisplayAmount; i++)
for (int i = 1; i <= AdditionalColumns; i++)
{
float alphaAdj = 1 + AdditionalColumns - ((float) AdditionalColumns / (float) i);
const float baseAlpha = 200;

//Left
if ((_selected - i) >= 0 && (_selected - i) <= _items.Count - 1)
{
KeyValuePair<ImageButton, Object> selectedLeft = _items[(_selected - i)];
selectedLeft.Key.Position = new Point(lastPosLeft - selectedLeft.Key.ClientArea.Width, ClientArea.Top + (int)(ClientArea.Height / 2f - selectedLeft.Key.ClientArea.Height / 2f));
lastPosLeft = selectedLeft.Key.ClientArea.Left - ItemSpacing;
selectedLeft.Key.Color = Color.FromArgb((int)(baseAlpha / alphaAdj), Color.White);
selectedLeft.Key.Render();
}

Expand All @@ -175,6 +187,7 @@ public override void Render()
KeyValuePair<ImageButton, Object> selectedRight = _items[(_selected + i)];
selectedRight.Key.Position = new Point(lastPosRight, ClientArea.Top + (int)(ClientArea.Height / 2f - selectedRight.Key.ClientArea.Height / 2f));
lastPosRight = selectedRight.Key.ClientArea.Right + ItemSpacing;
selectedRight.Key.Color = Color.FromArgb((int)(baseAlpha / alphaAdj), Color.White);
selectedRight.Key.Render();
}
}
Expand All @@ -196,6 +209,24 @@ public override void Dispose()
GC.SuppressFinalize(this);
}

public override bool MouseWheelMove(MouseInputEventArgs e)
{
if (ClientArea.Contains(new Point((int) e.Position.X, (int) e.Position.Y)))
{
if (e.WheelDelta > 0)
{
if (_selected + 1 <= _items.Count - 1) _selected++;
return true;
}
else if (e.WheelDelta < 0)
{
if (_selected - 1 >= 0) _selected--;
return true;
}
}
return false;
}

public override void MouseMove(MouseInputEventArgs e)
{
if (ClientArea.Contains(new Point((int)e.Position.X, (int)e.Position.Y)))
Expand Down Expand Up @@ -224,7 +255,7 @@ public override bool MouseDown(MouseInputEventArgs e)
KeyValuePair<ImageButton, Object> selected = _items[_selected];
if (selected.Key.MouseDown(e)) return true;

for (int i = 1; i <= DisplayAmount; i++)
for (int i = 1; i <= AdditionalColumns; i++)
{
if ((_selected - i) >= 0 && (_selected - i) <= _items.Count - 1)
{
Expand Down Expand Up @@ -258,7 +289,7 @@ public override bool MouseUp(MouseInputEventArgs e)
KeyValuePair<ImageButton, Object> selected = _items[_selected];
if (selected.Key.MouseUp(e)) return true;

for (int i = 1; i <= DisplayAmount; i++)
for (int i = 1; i <= AdditionalColumns; i++)
{
if ((_selected - i) >= 0 && (_selected - i) <= _items.Count - 1)
{
Expand Down
1 change: 1 addition & 0 deletions ClientServices/UserInterface/LobbyState/JobTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public JobTab(string uniqueName, Size size, IResourceManager resourceManager)
Size = new Size(675, 80),
ButtonLeft = "job_arrowleft",
ButtonRight = "job_arrowright",
SelectionBackground = "job_glow"
};

var job_robo = new ImageButton()
Expand Down

0 comments on commit e6bb5db

Please sign in to comment.