MatterHackers / MatterControl

3D printing software for Windows, Mac and Linux
http://www.mattercontrol.com/
BSD 2-Clause "Simplified" License
460 stars 185 forks source link

Markdig table renderer prototype #5364

Closed jlewin closed 2 years ago

jlewin commented 2 years ago

I came across an open ticket (#5191) and thought it would be interesting to revisit how the Markdig renderers worked and how to map to anything in Agg that might be a start for a table implementation. I'm certain you can quickly revise the layout issues I ran into, and pick more appropriate types for table row/cells. If nothing else, hopefully, this might demystify the Markdig steps needed to plug in something for table support in Agg.

I'm not sure if you'd want to merge as is, but you might consider it and simply disable the ObjectRenderers.Add(new AggTableRenderer()); in release builds.

Next steps would be to eliminate the fixed width values I put in place to demo a quick prototype, and wire up to configuration-based widths from the Markdig parser, and track and use cell content widths rather than the arbitrary fixed constants. Plus, row/column spans and all the other more detailed and challenging next steps.

Prototype

image

larsbrubaker commented 2 years ago

This is great! Thanks for working on it.

I'll try and spend some time thinking about how to make the agg table better. I've written 2 separate table prototypes recently and one of them might be a good candidate for improving to support what is needed here.

jlewin commented 2 years ago

I actually did some follow-up work on this PR that got quite a bit closer to the target, but if you're already working on a different implementation, it might not be worth the confusion and time it would take to consider.

Mainly just added types to track table/column/row/cell state and hooks that can roll up bounds to attempt to enforce minimum width/height constraints. If that seems like something you'd want, let me know and I can do a follow-up PR for consideration.

image

jlewin commented 2 years ago

For reference, branch with follow-on revisions:
https://github.com/MatterHackers/MatterControl/compare/main...jlewin:MatterControl:alt/table?expand=1

larsbrubaker commented 2 years ago

That sounds great. I would not be able to get to anything with this for weeks, if not longer. So anything you do would be a huge benefit to having this functionality.

Thanks.