Skip to content

Commit

Permalink
(#63) Documentation and member visibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Jan 15, 2023
1 parent 3ffc449 commit e52f296
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 66 deletions.
8 changes: 4 additions & 4 deletions src/WpfMath.Shared/Atoms/StyledAtom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ internal record StyledAtom : Atom, IRow
public StyledAtom(
SourceSpan? source,
Atom? atom,
IPlatformBrush? backgroundColor,
IPlatformBrush? foregroundColor)
IBrush? backgroundColor,
IBrush? foregroundColor)
: base(source)
{
this.RowAtom = new RowAtom(source, atom);
Expand All @@ -21,9 +21,9 @@ public StyledAtom(
// RowAtom to which colors are applied.
public RowAtom RowAtom { get; init; }

public IPlatformBrush? Background { get; init; }
public IBrush? Background { get; init; }

public IPlatformBrush? Foreground { get; init; }
public IBrush? Foreground { get; init; }

public Atom WithPreviousAtom(DummyAtom? previousAtom) =>
this with { RowAtom = (RowAtom) RowAtom.WithPreviousAtom(previousAtom) };
Expand Down
6 changes: 3 additions & 3 deletions src/WpfMath.Shared/Boxes/Box.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected Box()
{
}

protected Box(IPlatformBrush? foreground, IPlatformBrush? background)
protected Box(IBrush? foreground, IBrush? background)
{
this.children = new List<Box>();
this.childrenReadOnly = new ReadOnlyCollection<Box>(this.children);
Expand All @@ -39,13 +39,13 @@ public SourceSpan? Source
set;
}

public IPlatformBrush? Foreground
public IBrush? Foreground
{
get;
set;
}

public IPlatformBrush? Background
public IBrush? Background
{
get;
set;
Expand Down
2 changes: 1 addition & 1 deletion src/WpfMath.Shared/Boxes/HorizontalBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public HorizontalBox(Box box)
this.Add(box);
}

public HorizontalBox(IPlatformBrush? foreground, IPlatformBrush? background)
public HorizontalBox(IBrush? foreground, IBrush? background)
: base(foreground, background)
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/WpfMath.Shared/ExtensionChar.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace WpfMath
{
/// <summary>Extension character that contains character information for each of its parts.</summary>
internal class ExtensionChar
public class ExtensionChar
{
public ExtensionChar(CharInfo? top, CharInfo? middle, CharInfo? bottom, CharInfo? repeat)
{
Expand Down
1 change: 0 additions & 1 deletion src/WpfMath.Shared/Fonts/IFontProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ public interface IFontProvider
{
/// <summary>Reads a TeX font of specified file name from the application's resources.</summary>
/// <param name="fontFileName"></param>
/// <returns></returns>
IFontTypeface ReadFontFile(string fontFileName);
}
4 changes: 4 additions & 0 deletions src/WpfMath.Shared/Fonts/IFontTypeface.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
namespace WpfMath.Fonts;

/// <summary>
/// A marker interface for font typeface. Used to extract font glyphs. Should be casted back in the
/// implementation-specific code (e.g. WPF implementation may cast this to a WPF-specific type).
/// </summary>
public interface IFontTypeface
{
}
74 changes: 37 additions & 37 deletions src/WpfMath.Shared/ITeXFont.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,78 +6,78 @@ namespace WpfMath
public interface ITeXFont
{
/// <summary>Whether the font supports <see cref="CharInfo"/>.</summary>
internal bool SupportsMetrics { get; }
bool SupportsMetrics { get; }

internal double Size { get; }
double Size { get; }

internal ExtensionChar GetExtension(CharInfo charInfo, TexStyle style);
ExtensionChar GetExtension(CharInfo charInfo, TexStyle style);

internal CharFont? GetLigature(CharFont leftChar, CharFont rightChar);
CharFont? GetLigature(CharFont leftChar, CharFont rightChar);

internal CharInfo GetNextLargerCharInfo(CharInfo charInfo, TexStyle style);
CharInfo GetNextLargerCharInfo(CharInfo charInfo, TexStyle style);

internal Result<CharInfo> GetDefaultCharInfo(char character, TexStyle style);
Result<CharInfo> GetDefaultCharInfo(char character, TexStyle style);

internal Result<CharInfo> GetCharInfo(char character, string textStyle, TexStyle style);
Result<CharInfo> GetCharInfo(char character, string textStyle, TexStyle style);

internal Result<CharInfo> GetCharInfo(CharFont charFont, TexStyle style);
Result<CharInfo> GetCharInfo(CharFont charFont, TexStyle style);

internal Result<CharInfo> GetCharInfo(string name, TexStyle style);
Result<CharInfo> GetCharInfo(string name, TexStyle style);

internal double GetKern(CharFont leftChar, CharFont rightChar, TexStyle style);
double GetKern(CharFont leftChar, CharFont rightChar, TexStyle style);

internal double GetQuad(int fontId, TexStyle style);
double GetQuad(int fontId, TexStyle style);

internal double GetSkew(CharFont charFont, TexStyle style);
double GetSkew(CharFont charFont, TexStyle style);

internal bool HasSpace(int fontId);
bool HasSpace(int fontId);

internal bool HasNextLarger(CharInfo charInfo);
bool HasNextLarger(CharInfo charInfo);

internal bool IsExtensionChar(CharInfo charInfo);
bool IsExtensionChar(CharInfo charInfo);

internal int GetMuFontId();
int GetMuFontId();

internal double GetXHeight(TexStyle style, int fontId);
double GetXHeight(TexStyle style, int fontId);

internal double GetSpace(TexStyle style);
double GetSpace(TexStyle style);

internal double GetAxisHeight(TexStyle style);
double GetAxisHeight(TexStyle style);

internal double GetBigOpSpacing1(TexStyle style);
double GetBigOpSpacing1(TexStyle style);

internal double GetBigOpSpacing2(TexStyle style);
double GetBigOpSpacing2(TexStyle style);

internal double GetBigOpSpacing3(TexStyle style);
double GetBigOpSpacing3(TexStyle style);

internal double GetBigOpSpacing4(TexStyle style);
double GetBigOpSpacing4(TexStyle style);

internal double GetBigOpSpacing5(TexStyle style);
double GetBigOpSpacing5(TexStyle style);

internal double GetSub1(TexStyle style);
double GetSub1(TexStyle style);

internal double GetSub2(TexStyle style);
double GetSub2(TexStyle style);

internal double GetSubDrop(TexStyle style);
double GetSubDrop(TexStyle style);

internal double GetSup1(TexStyle style);
double GetSup1(TexStyle style);

internal double GetSup2(TexStyle style);
double GetSup2(TexStyle style);

internal double GetSup3(TexStyle style);
double GetSup3(TexStyle style);

internal double GetSupDrop(TexStyle style);
double GetSupDrop(TexStyle style);

internal double GetNum1(TexStyle style);
double GetNum1(TexStyle style);

internal double GetNum2(TexStyle style);
double GetNum2(TexStyle style);

internal double GetNum3(TexStyle style);
double GetNum3(TexStyle style);

internal double GetDenom1(TexStyle style);
double GetDenom1(TexStyle style);

internal double GetDenom2(TexStyle style);
double GetDenom2(TexStyle style);

internal double GetDefaultLineThickness(TexStyle style);
double GetDefaultLineThickness(TexStyle style);
}
}
3 changes: 3 additions & 0 deletions src/WpfMath.Shared/Rendering/GenericBrush.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace WpfMath.Rendering;

public record GenericBrush<TBrush>(TBrush Value) : IBrush;
3 changes: 0 additions & 3 deletions src/WpfMath.Shared/Rendering/GenericPlatformBrush.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ namespace WpfMath.Rendering;
/// A platform-dependent inheritor of <see cref="IElementRenderer"/> is supposed to cast this to a
/// platform-dependent implementation to extract the containing value.
/// </summary>
public interface IPlatformBrush
public interface IBrush
{
}
2 changes: 1 addition & 1 deletion src/WpfMath.Shared/Rendering/IBrushFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ namespace WpfMath.Rendering;

public interface IBrushFactory
{
public IPlatformBrush FromColor(RgbaColor color);
public IBrush FromColor(RgbaColor color);
}
4 changes: 2 additions & 2 deletions src/WpfMath.Shared/Rendering/IElementRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ public interface IElementRenderer
/// Renders a character denoted by <paramref name="info"/> at the chosen coordinates, using the color
/// <paramref name="foreground"/>. Should use platform default color if passed <c>null</c>.
/// </summary>
void RenderCharacter(CharInfo info, double x, double y, IPlatformBrush? foreground);
void RenderCharacter(CharInfo info, double x, double y, IBrush? foreground);

/// <summary>Renders a rectangle.</summary>
/// <param name="rectangle">Rectangle to render.</param>
/// <param name="foreground">
/// Rectangle foreground color. Should use platform default color if passed <c>null</c>.
/// </param>
void RenderRectangle(Rectangle rectangle, IPlatformBrush? foreground);
void RenderRectangle(Rectangle rectangle, IBrush? foreground);

/// <summary>Renders a box applying the geometry transforms.</summary>
/// <param name="box">A box to render.</param>
Expand Down
4 changes: 2 additions & 2 deletions src/WpfMath.Shared/TexEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ public sealed record TexEnvironment(
TexStyle Style,
ITeXFont MathFont,
ITeXFont TextFont,
IPlatformBrush? Background = null,
IPlatformBrush? Foreground = null)
IBrush? Background = null,
IBrush? Foreground = null)
{
// ID of font that was last used.
private int lastFontId = TexFontUtilities.NoFontId;
Expand Down
4 changes: 2 additions & 2 deletions src/WpfMath.Shared/TexFormula.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal void Add(Atom atom, SourceSpan? rowSource)
}
}

public void SetForeground(IPlatformBrush brush)
public void SetForeground(IBrush brush)
{
if (this.RootAtom is StyledAtom sa)
{
Expand All @@ -73,7 +73,7 @@ public void SetForeground(IPlatformBrush brush)
}
}

public void SetBackground(IPlatformBrush brush)
public void SetBackground(IBrush brush)
{
if (this.RootAtom is StyledAtom sa)
{
Expand Down
4 changes: 2 additions & 2 deletions src/WpfMath/Rendering/GeometryElementRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public GeometryElementRenderer(GeometryGroup geometry, double scale)

public void RenderElement(Box box, double x, double y) => box.RenderTo(this, x, y);

public void RenderCharacter(CharInfo info, double x, double y, IPlatformBrush? foreground)
public void RenderCharacter(CharInfo info, double x, double y, IBrush? foreground)
{
var glyph = info.GetGlyphRun(x, y, _scale);
var glyphGeometry = glyph.BuildGeometry();
_geometry.Children.Add(glyphGeometry);
}

public void RenderRectangle(Rectangle rectangle, IPlatformBrush? foreground)
public void RenderRectangle(Rectangle rectangle, IBrush? foreground)
{
var rectangleGeometry = new RectangleGeometry(GeometryHelper.ScaleRectangle(_scale, rectangle).ToWpf());
_geometry.Children.Add(rectangleGeometry);
Expand Down
4 changes: 2 additions & 2 deletions src/WpfMath/Rendering/WpfBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace WpfMath.Rendering;

internal record WpfBrush : GenericPlatformBrush<Brush>
internal record WpfBrush : GenericBrush<Brush>
{
private WpfBrush(Brush brush) : base(brush)
{
Expand All @@ -15,7 +15,7 @@ private WpfBrush(Brush brush) : base(brush)
internal class WpfBrushFactory : IBrushFactory
{
public static WpfBrushFactory Instance = new();
public IPlatformBrush FromColor(RgbaColor color) =>
public IBrush FromColor(RgbaColor color) =>
new SolidColorBrush(
Color.FromArgb(color.A, color.R, color.G, color.B)).ToPlatform();
}
4 changes: 2 additions & 2 deletions src/WpfMath/Rendering/WpfBrushExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace WpfMath.Rendering;

internal static class WpfBrushExtensions
{
public static Brush? ToWpf(this IPlatformBrush? brush) => ((WpfBrush?)brush)?.Value;
public static Brush? ToWpf(this IBrush? brush) => ((WpfBrush?)brush)?.Value;
[return: NotNullIfNotNull(nameof(brush))]
public static IPlatformBrush? ToPlatform(this Brush? brush) => brush == null ? null : WpfBrush.FromBrush(brush);
public static IBrush? ToPlatform(this Brush? brush) => brush == null ? null : WpfBrush.FromBrush(brush);
}
4 changes: 2 additions & 2 deletions src/WpfMath/Rendering/WpfElementRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public void RenderElement(Box box, double x, double y)
_foregroundContext.Pop();
}

public void RenderCharacter(CharInfo info, double x, double y, IPlatformBrush? foreground)
public void RenderCharacter(CharInfo info, double x, double y, IBrush? foreground)
{
var glyphRun = info.GetGlyphRun(x, y, _scale);
_foregroundContext.DrawGlyphRun(foreground.ToWpf() ?? DefaultForegroundBrush, glyphRun);
}

public void RenderRectangle(Rectangle rectangle, IPlatformBrush? foreground)
public void RenderRectangle(Rectangle rectangle, IBrush? foreground)
{
var scaledRectangle = GeometryHelper.ScaleRectangle(_scale, rectangle);
_foregroundContext.DrawRectangle(
Expand Down

0 comments on commit e52f296

Please sign in to comment.