Browse Source

Moving styling into namespace/interfaces.

pull/4/head
grokys 12 years ago
parent
commit
a24f83da36
  1. 1
      Perspex.UnitTests/StyleTests.cs
  2. 1
      Perspex/Application.cs
  3. 3
      Perspex/Controls/Control.cs
  4. 12
      Perspex/Perspex.csproj
  5. 2
      Perspex/PerspexObject.cs
  6. 4
      Perspex/Styling/IStyle.cs
  7. 35
      Perspex/Styling/IStyleable.cs
  8. 4
      Perspex/Styling/Match.cs
  9. 4
      Perspex/Styling/Selectors.cs
  10. 8
      Perspex/Styling/Style.cs
  11. 4
      Perspex/Styling/Styles.cs
  12. 1
      Perspex/Themes/Default/ButtonStyle.cs
  13. 1
      Perspex/Themes/Default/DefaultTheme.cs
  14. 3
      TestApplication/Program.cs

1
Perspex.UnitTests/StyleTests.cs

@ -10,6 +10,7 @@ namespace Perspex.UnitTests
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Perspex.Controls;
using Perspex.Styling;
[TestClass]
public class StyleTests

1
Perspex/Application.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Perspex.Styling;
namespace Perspex
{

3
Perspex/Controls/Control.cs

@ -14,6 +14,7 @@ namespace Perspex.Controls
using Perspex.Input;
using Perspex.Layout;
using Perspex.Media;
using Perspex.Styling;
public enum HorizontalAlignment
{
@ -31,7 +32,7 @@ namespace Perspex.Controls
Bottom,
}
public abstract class Control : Interactive, ILayoutable
public abstract class Control : Interactive, ILayoutable, IStyleable
{
public static readonly ReadOnlyPerspexProperty<Control> ParentProperty =
new ReadOnlyPerspexProperty<Control>(ParentPropertyRW);

12
Perspex/Perspex.csproj

@ -79,7 +79,8 @@
<Compile Include="ControlTemplate.cs" />
<Compile Include="Input\MouseEventArgs.cs" />
<Compile Include="Interactive.cs" />
<Compile Include="IStyle.cs" />
<Compile Include="Styling\IStyleable.cs" />
<Compile Include="Styling\IStyle.cs" />
<Compile Include="PriorityValue.cs" />
<Compile Include="Layout\ILayoutable.cs" />
<Compile Include="Layout\ILayoutManager.cs" />
@ -100,16 +101,16 @@
<Compile Include="PerspexPropertyChangedEventArgs.cs" />
<Compile Include="Point.cs" />
<Compile Include="ReadOnlyPerspexProperty.cs" />
<Compile Include="Match.cs" />
<Compile Include="Styling\Match.cs" />
<Compile Include="RoutedEventArgs.cs" />
<Compile Include="Selectors.cs" />
<Compile Include="Styling\Selectors.cs" />
<Compile Include="ServiceLocator.cs" />
<Compile Include="Setter.cs" />
<Compile Include="Size.cs" />
<Compile Include="Rect.cs" />
<Compile Include="Controls\TemplatedControl.cs" />
<Compile Include="Style.cs" />
<Compile Include="Styles.cs" />
<Compile Include="Styling\Style.cs" />
<Compile Include="Styling\Styles.cs" />
<Compile Include="Themes\Default\ButtonStyle.cs" />
<Compile Include="Themes\Default\DefaultTheme.cs" />
<Compile Include="Thickness.cs" />
@ -134,6 +135,7 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

2
Perspex/PerspexObject.cs

@ -398,7 +398,7 @@ namespace Perspex
}
/// <summary>
/// Binds a <see cref="PerspexProperty"/> to an style.
/// Binds a <see cref="PerspexProperty"/> to a style.
/// </summary>
/// <param name="property">The property.</param>
/// <param name="value">The activated value.</param>

4
Perspex/IStyle.cs → Perspex/Styling/IStyle.cs

@ -4,12 +4,12 @@
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex
namespace Perspex.Styling
{
using Perspex.Controls;
public interface IStyle
{
void Attach(Control control);
void Attach(IStyleable control);
}
}

35
Perspex/Styling/IStyleable.cs

@ -0,0 +1,35 @@
// -----------------------------------------------------------------------
// <copyright file="IStyleable.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Styling
{
using System;
using Perspex.Controls;
/// <summary>
/// Interface for styleable elements.
/// </summary>
public interface IStyleable
{
/// <summary>
/// Gets the list of classes for the control.
/// </summary>
PerspexList<string> Classes { get; }
/// <summary>
/// Binds a <see cref="PerspexProperty"/> to a style.
/// </summary>
/// <param name="property">The property.</param>
/// <param name="value">The activated value.</param>
/// <param name="activator">An observable which activates the value.</param>
/// <remarks>
/// Style bindings have a lower precedence than local value bindings. They are toggled
/// on or off by <paramref name="activator"/> and can be unbound by the activator
/// completing.
/// </remarks>
void SetValue(PerspexProperty property, object value, IObservable<bool> activator);
}
}

4
Perspex/Match.cs → Perspex/Styling/Match.cs

@ -4,7 +4,7 @@
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex
namespace Perspex.Styling
{
using System;
using System.Collections.Generic;
@ -14,7 +14,7 @@ namespace Perspex
public class Match
{
public Control Control
public IStyleable Control
{
get;
set;

4
Perspex/Selectors.cs → Perspex/Styling/Selectors.cs

@ -4,7 +4,7 @@
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex
namespace Perspex.Styling
{
using System;
using System.Collections.Generic;
@ -18,7 +18,7 @@ namespace Perspex
public static class Selectors
{
public static Match Select<T>(this Control control)
public static Match Select<T>(this IStyleable control)
{
Contract.Requires<ArgumentNullException>(control != null);

8
Perspex/Style.cs → Perspex/Styling/Style.cs

@ -4,7 +4,7 @@
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex
namespace Perspex.Styling
{
using System;
using System.Collections.Generic;
@ -20,13 +20,13 @@ namespace Perspex
this.Setters = new List<Setter>();
}
public Style(Func<Control, Match> selector)
public Style(Func<IStyleable, Match> selector)
: this()
{
this.Selector = selector;
}
public Func<Control, Match> Selector
public Func<IStyleable, Match> Selector
{
get;
set;
@ -38,7 +38,7 @@ namespace Perspex
set;
}
public void Attach(Control control)
public void Attach(IStyleable control)
{
Match match = this.Selector(control);

4
Perspex/Styles.cs → Perspex/Styling/Styles.cs

@ -4,13 +4,13 @@
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex
namespace Perspex.Styling
{
using Perspex.Controls;
public class Styles : PerspexList<IStyle>, IStyle
{
public void Attach(Control control)
public void Attach(IStyleable control)
{
foreach (IStyle style in this)
{

1
Perspex/Themes/Default/ButtonStyle.cs

@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using Perspex.Controls;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default
{

1
Perspex/Themes/Default/DefaultTheme.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Perspex.Styling;
namespace Perspex.Themes.Default
{

3
TestApplication/Program.cs

@ -8,6 +8,7 @@ using System.Threading.Tasks;
using Perspex;
using Perspex.Controls;
using Perspex.Media;
using Perspex.Styling;
using Perspex.Themes.Default;
using Perspex.Windows;
using Perspex.Windows.Media;
@ -41,7 +42,7 @@ namespace TestApplication
Application application = new Application
{
Styles = new Styles
Styles = new Styles
{
new DefaultTheme(),
}

Loading…
Cancel
Save