Move ScrollItem upstream
This commit is contained in:
@@ -183,6 +183,7 @@
|
||||
<Compile Include="Utilities.cs" />
|
||||
<Compile Include="Traits\Waypoint.cs" />
|
||||
<Compile Include="Traits\Activities\Activity.cs" />
|
||||
<Compile Include="Widgets\ScrollItem.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
54
OpenRA.Game/Widgets/ScrollItem.cs
Normal file
54
OpenRA.Game/Widgets/ScrollItem.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using OpenRA.Graphics;
|
||||
|
||||
namespace OpenRA.Widgets
|
||||
{
|
||||
public class ScrollItemWidget : ButtonWidget
|
||||
{
|
||||
public ScrollItemWidget()
|
||||
: base()
|
||||
{
|
||||
IsVisible = () => false;
|
||||
}
|
||||
|
||||
protected ScrollItemWidget(ScrollItemWidget other)
|
||||
: base(other)
|
||||
{
|
||||
IsVisible = () => false;
|
||||
}
|
||||
|
||||
public Func<bool> IsSelected = () => false;
|
||||
|
||||
public override void DrawInner()
|
||||
{
|
||||
var state = IsSelected() ? "scrollitem-selected" :
|
||||
RenderBounds.Contains(Viewport.LastMousePos) ? "scrollitem-hover" :
|
||||
null;
|
||||
|
||||
if (state != null)
|
||||
WidgetUtils.DrawPanel(state, RenderBounds);
|
||||
}
|
||||
|
||||
public override Widget Clone() { return new ScrollItemWidget(this); }
|
||||
|
||||
public static ScrollItemWidget Setup(ScrollItemWidget template, Func<bool> isSelected, Action onClick)
|
||||
{
|
||||
var w = template.Clone() as ScrollItemWidget;
|
||||
w.IsVisible = () => true;
|
||||
w.IsSelected = isSelected;
|
||||
w.OnClick = onClick;
|
||||
return w;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -226,43 +226,5 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
ShowDropPanel(w, dropDown, dismissAfter, () => true);
|
||||
}
|
||||
}
|
||||
|
||||
public class ScrollItemWidget : ButtonWidget
|
||||
{
|
||||
public ScrollItemWidget()
|
||||
: base()
|
||||
{
|
||||
IsVisible = () => false;
|
||||
}
|
||||
|
||||
protected ScrollItemWidget(ScrollItemWidget other)
|
||||
: base(other)
|
||||
{
|
||||
IsVisible = () => false;
|
||||
}
|
||||
|
||||
public Func<bool> IsSelected = () => false;
|
||||
|
||||
public override void DrawInner()
|
||||
{
|
||||
var state = IsSelected() ? "button-pressed" :
|
||||
RenderBounds.Contains(Viewport.LastMousePos) ? "button-hover" :
|
||||
null;
|
||||
|
||||
if (state != null)
|
||||
WidgetUtils.DrawPanel(state, RenderBounds);
|
||||
}
|
||||
|
||||
public override Widget Clone() { return new ScrollItemWidget(this); }
|
||||
|
||||
public static ScrollItemWidget Setup(ScrollItemWidget template, Func<bool> isSelected, Action onClick)
|
||||
{
|
||||
var w = template.Clone() as ScrollItemWidget;
|
||||
w.IsVisible = () => true;
|
||||
w.IsSelected = isSelected;
|
||||
w.OnClick = onClick;
|
||||
return w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +120,31 @@ progressbar-thumb: chrome.png
|
||||
corner-bl: 0,190,2,2
|
||||
corner-br: 62,190,2,2
|
||||
|
||||
|
||||
# A copy of button-hover
|
||||
scrollitem-hover: chrome.png
|
||||
background: 2,130,60,60
|
||||
border-r: 62,132,2,60
|
||||
border-l: 0,130,2,60
|
||||
border-b: 2,190,60,2
|
||||
border-t: 2,128,60,2
|
||||
corner-tl: 0,128,2,2
|
||||
corner-tr: 62,128,2,2
|
||||
corner-bl: 0,190,2,2
|
||||
corner-br: 62,190,2,2
|
||||
|
||||
# A copy of button-pressed
|
||||
scrollitem-selected: chrome.png
|
||||
background: 66,194,60,60
|
||||
border-r: 126,194,2,60
|
||||
border-l: 64,194,2,60
|
||||
border-b: 66,254,60,2
|
||||
border-t: 66,192,60,2
|
||||
corner-tl: 64,192,2,2
|
||||
corner-tr: 126,192,2,2
|
||||
corner-bl: 64,254,2,2
|
||||
corner-br: 126,254,2,2
|
||||
|
||||
panel-black: chrome.png
|
||||
background: 66,2,60,60
|
||||
border-r: 126,2,2,60
|
||||
|
||||
Reference in New Issue
Block a user