Mapsui / Mapsui

Mapsui is a .NET Map component for: MAUI, WPF, Avalonia, Uno, Blazor, WinUI, Xamarin and Eto
https://mapsui.com
MIT License
1.25k stars 319 forks source link

More options in LabelStyle? #1366

Closed eriove closed 3 years ago

eriove commented 3 years ago

Thanks for a great library.

I'm trying to make a tool tip for features on the map by adding an additional layer with a label. It is working well so far. To make it look like a normal tool tip I would need sharp corners and a border. This isn't supported by the current LabelStyle but would be quite easy to implement in the LabelRenderer.

Would there be an interest in a merge request where I add Rounding, BorderThickness and BorderColor to the LabelStyle and LabelRenderer.

If there's an interest I would create merge requests both for develop/3.0.0 and master.

pauldendulk commented 3 years ago

That would definitely be interesting and something I had hoped happened earlier.

If you do this then please include your changes into the label rendering test.

Something to look into is to RichTextKit. It was introduced into Mapsui by charlenni. It is used for callouts/popups. You can see it in the info sample and in the Xamarin.Forms specific samples. The rendering somehow looks nicer. And in the current implementation has support for some of the features you mention. I think all the text rendering should use it.

Unfortunately there is currently a problem with callouts on iOS. I don't know if this is a general problem with RichTextKit. If this is the case perhaps we need to stick to the SkiaSharp way of rendering text. See https://github.com/Mapsui/Mapsui/issues/1216#issuecomment-963842736.

You could also ignore migration to RichTextKit for now and just improve what we have currently.

eriove commented 3 years ago

I think I'll start with just the small changes, that should be a fairly small change.

If the bug on iOS isn't resolved it is probably better to create a RichTextLabel or something similar so that existing applications don't break.

pauldendulk commented 3 years ago

You mean a RichTextLabelStyle next to the existing LabelStyle, so that will have two options, a pretty one and a 'save' one that will work on all platforms? That is probably the best way to go.

eriove commented 3 years ago

You mean a RichTextLabelStyle next to the existing LabelStyle, so that will have two options, a pretty one and a 'save' one that will work on all platforms? That is probably the best way to go.

Exactly

charlenni commented 3 years ago

That means each time we have a problem with a part in a version, we make a new one to circumvent this problem?

I would say, that the right way to go is to use RichTextKit everywhere. It is very difficult to creat a correct LabelStyle. Think about all the languages out there with different fonts. And keep in mind, that Skia and SkiaSharp ended to support DrawText.

eriove commented 3 years ago

I created merge requests for the 3.x branch and for master. See #1368 and #1369.

eriove commented 3 years ago

That means each time we have a problem with a part in a version, we make a new one to circumvent this problem?

I would say, that the right way to go is to use RichTextKit everywhere. It is very difficult to creat a correct LabelStyle. Think about all the languages out there with different fonts. And keep in mind, that Skia and SkiaSharp ended to support DrawText.

Since the rendering is different when using rich text than the current implementation I would consider changing the rendering a breaking change. Any changes to 3.x would then be safest to put in a new Style. For next major version it is not as clear cut. Do we expect the upstream bug to be fixed before we want to release 4.x? If that's the case the LabelStyle can change. If there's a need for a release before that point, then it is probably safer to create a new Style and Renderer.

I wasn't aware that DrawText was deprecated, that is a good reason to change the existing renderer.

pauldendulk commented 3 years ago

That means each time we have a problem with a part in a version, we make a new one to circumvent this problem?

I would say, that the right way to go is to use RichTextKit everywhere. It is very difficult to create a correct LabelStyle. Think about all the languages out there with different fonts. And keep in mind, that Skia and SkiaSharp ended to support DrawText.

I am also in favor of RichTextKit everywhere, but if the current version has a problem with RichTextKit this is not the right time to make that change. Introducing a new RichTextKitLabelStyle would be a step in the migration process. When RichTextKit is stable all DrawText can be removed. This is how I have done many migrations in the past.

But actually, this morning I had a closer look at CalloutStyle and I think this could function in the role of RichTexKitSLabeltyle, perhaps with a few modifications. So we do not need to introduce RichTextKitSLabeltyle.

Also, I am still not sure if there is a problem with RichTextKit.