Use theme aware Markdown list bullets
- Issue MatterHackers/MCCentral#3730
This commit is contained in:
parent
69922437ea
commit
ab8550faf3
3 changed files with 29 additions and 34 deletions
|
|
@ -1,10 +1,9 @@
|
|||
// Copyright (c) 2016-2017 Nicolas Musset. All rights reserved.
|
||||
// This file is licensed under the MIT license.
|
||||
// This file is licensed under the MIT license.
|
||||
// See the LICENSE.md file in the project root for more information.
|
||||
|
||||
using Markdig.Syntax;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl;
|
||||
|
|
@ -15,13 +14,12 @@ namespace Markdig.Renderers.Agg
|
|||
public class ListX : FlowLayoutWidget
|
||||
{
|
||||
public ListX()
|
||||
: base (FlowDirection.TopToBottom)
|
||||
: base(FlowDirection.TopToBottom)
|
||||
{
|
||||
var theme = ApplicationController.Instance.Theme;
|
||||
|
||||
this.VAnchor = VAnchor.Fit;
|
||||
this.HAnchor = HAnchor.Stretch;
|
||||
//this.Margin = new BorderDouble(0, 4, 0, 12);
|
||||
}
|
||||
|
||||
public override void AddChild(GuiWidget childToAdd, int indexInChildrenList = -1)
|
||||
|
|
@ -38,7 +36,6 @@ namespace Markdig.Renderers.Agg
|
|||
|
||||
public class ListItemX : FlowLayoutWidget
|
||||
{
|
||||
private ImageBuffer icon = AggContext.StaticData.LoadIcon("dot.png");
|
||||
private FlowLayoutWidget content;
|
||||
public ListItemX()
|
||||
{
|
||||
|
|
@ -46,11 +43,10 @@ namespace Markdig.Renderers.Agg
|
|||
|
||||
this.VAnchor = VAnchor.Fit;
|
||||
this.HAnchor = HAnchor.Stretch;
|
||||
//this.Margin = new BorderDouble(0, 4, 0, 12);
|
||||
|
||||
base.AddChild(new ImageWidget(icon)
|
||||
base.AddChild(new ImageWidget(AggContext.StaticData.LoadIcon("bullet.png", theme.InvertIcons))
|
||||
{
|
||||
Margin = 3,
|
||||
Margin = new BorderDouble(top: 1), //3,
|
||||
VAnchor = VAnchor.Top,
|
||||
});
|
||||
|
||||
|
|
@ -62,42 +58,41 @@ namespace Markdig.Renderers.Agg
|
|||
|
||||
public override void AddChild(GuiWidget childToAdd, int indexInChildrenList = -1)
|
||||
{
|
||||
// Anything required...?
|
||||
|
||||
// TODOD: Anything else required for list children?
|
||||
content.AddChild(childToAdd, indexInChildrenList);
|
||||
}
|
||||
}
|
||||
|
||||
public class AggListRenderer : AggObjectRenderer<ListBlock>
|
||||
{
|
||||
protected override void Write(AggRenderer renderer, ListBlock listBlock)
|
||||
{
|
||||
//var list = new List();
|
||||
{
|
||||
protected override void Write(AggRenderer renderer, ListBlock listBlock)
|
||||
{
|
||||
//var list = new List();
|
||||
|
||||
//if (listBlock.IsOrdered)
|
||||
//{
|
||||
// list.MarkerStyle = TextMarkerStyle.Decimal;
|
||||
//if (listBlock.IsOrdered)
|
||||
//{
|
||||
// list.MarkerStyle = TextMarkerStyle.Decimal;
|
||||
|
||||
// if (listBlock.OrderedStart != null && (listBlock.DefaultOrderedStart != listBlock.OrderedStart))
|
||||
// {
|
||||
// list.StartIndex = int.Parse(listBlock.OrderedStart);
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// list.MarkerStyle = TextMarkerStyle.Disc;
|
||||
//}
|
||||
// if (listBlock.OrderedStart != null && (listBlock.DefaultOrderedStart != listBlock.OrderedStart))
|
||||
// {
|
||||
// list.StartIndex = int.Parse(listBlock.OrderedStart);
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// list.MarkerStyle = TextMarkerStyle.Disc;
|
||||
//}
|
||||
|
||||
renderer.Push(new ListX()); // list);
|
||||
|
||||
foreach (var item in listBlock)
|
||||
{
|
||||
foreach (var item in listBlock)
|
||||
{
|
||||
renderer.Push(new ListItemX());
|
||||
renderer.WriteChildren(item as ListItemBlock);
|
||||
renderer.Pop();
|
||||
}
|
||||
renderer.WriteChildren(item as ListItemBlock);
|
||||
renderer.Pop();
|
||||
}
|
||||
|
||||
renderer.Pop();
|
||||
}
|
||||
}
|
||||
renderer.Pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue