Comments (6)
@dbriard I'm not really interested in following what Fluent design is doing for the web and what you see in Figma. We have discussed this before but there are a few main reasons:
- XAML corner radius is defined to be the middle of the stroke. I don't think Figma does that and it likely uses the outside of the stroke. So the math is going to be different already.
- We need to match existing behavior from WinUI in this area. There is existing code that expects it to work the way it does.
- What it's doing does actually make sense from a different viewpoint: It's giving you the most radius it possibly can towards the 999 target. Radius is not guaranteed to be circular and will be elliptical if there isn't enough width/height.
To double check what I said above here is what is reproduced in WinUI:
<StackPanel Padding="40" Orientation="Vertical" Background="White" Width="200">
<ContentPresenter Foreground="Black" BorderBrush="Red" Content="OuterBorderEdge" BackgroundSizing="OuterBorderEdge" CornerRadius="9999" BorderThickness="1"/>
<ContentPresenter Foreground="Black" BorderBrush="Red" Content="InnerBorderEdge" BackgroundSizing="InnerBorderEdge" CornerRadius="9999" BorderThickness="1"/>
</StackPanel>
It works exactly as intended and we match the algorithm correctly in these cases. Only CenterBorder needs to be fixed.
from avalonia.
Can you provide the exact XAML you were using? Anything to save time and ensure precise communication is appreciated.
I also want to know how WPF and WinUI work in this situation.
I agree there is an issue as it should not change like this based on BackgroundSizing. However, I suspect inner and outer are actually correct and its center that needs to be fixed. That was my addition to WinUI code. The algorithm attempts to give you exactly what you request and only clips if it has to. There is no guarantee of circular corner radius -- it will give you the most possible in both X and Y direction if you put in 999.
I suggest a converter for your case if you can't guarantee a constant height of the controls.
from avalonia.
@robloo
Sorry, I thought I had included the code but it seems I deleted it by mistake.
Here is another example:
<ContentPresenter BorderBrush="Red" Content="CenterBorder" BackgroundSizing="CenterBorder" CornerRadius="9999" BorderThickness="1"/>
<ContentPresenter BorderBrush="Red" Content="OuterBorderEdge" BackgroundSizing="OuterBorderEdge" CornerRadius="9999" BorderThickness="1"/>
<ContentPresenter BorderBrush="Red" Content="InnerBorderEdge" BackgroundSizing="InnerBorderEdge" CornerRadius="9999" BorderThickness="1"/>
I found the idea of using large CornerRadius in Fluent2 design website
They were using a value of 10000 (by the time I copied their styles) for controls such as PersonPicture, PillButton, etc... In their current website, they are now using a special value of 50% but I suppose css support that.
Also, in Design Tools such as Figma, the CornerRadius work like Center in Avalonia:
I am sure there are more use cases for that behavior, and a converter would be overkill to do that. That is really smart, you just set a large value and get the look you want whatever the height or the content of the control. And I cannot name a single control where the corners look like inner/outer in the above picture.
from avalonia.
I agree with @robloo here. A converter isn't overkill. It's in fact easy to add. You can pass Bounds, get the Min of Width and Height and devide by 2. Done.
Will leave the ticket open for point 3 to track.
from avalonia.
Ok, I can live with a converter, or I can keep my current Border implementation for rounded control, but that will be a breaking change with the original Avalonia center sizing... my last try ;)
from avalonia.
Here is how WPF behaves.
<StackPanel Orientation="Vertical" Background="White" Width="200">
<Border TextElement.Foreground="Black" BorderBrush="Red" CornerRadius="9999" BorderThickness="1">
<TextBlock Text="Border Content" />
</Border>
</StackPanel>
The behavior you are asking for was always a bug if we follow the rendering behavior of existing DirectX/XAML frameworks (and we do most of the time). DirectX likely established this decades ago and is just the standard now. Is it different from other graphical frameworks? Yes. Does it make sense though? Also yes (it's giving you the most it can towards your requested radius and just going elliptical).
The reason we have a problem (a difference) is because we just let Skia handle this case historically and it doesn't work the same as DirectX/XAML should. We will likely have to remove the simple rendering path in this case as well.
from avalonia.
Related Issues (20)
- When DataGrid is not set to a height, dynamically adding rows will not widen the height HOT 4
- Application doesn't terminate when unhandled exception is thrown from ReactiveCommand handler HOT 3
- EagerParentStackEnumerator is incompatible with XAML built with older avalonia versions HOT 2
- DataGridCollectionView with Filter items dissapear or duplicate
- DataGridTextColumn IsReadOnly will be True after AOT HOT 2
- CustomDrawOperation.Render won't be called if only drawingContext.Custom is present in override Render method HOT 1
- Showing Window from WinForms app doesn't allow text input HOT 3
- Regression in 11.1 Beta2 and RC1 concerning EmbeddableControlRoot's EmbeddableWindow implementation on Windows HOT 5
- PointerTouchPadGestureSwipe not work in macos
- AvaloniaResource inclusion results in erroneous embedding when resources are outside of project folder HOT 2
- Changing the resolution of headless rendering
- D3D11CreateDevice+Hardware crashes and fallback doesn't work HOT 1
- Android SystemBar Icons theme (Light, Dark) in 11.1.0-rc1
- IsHitTestVisible set to false on parent element ignores IsHitTestVisible set to true for child elements
- NullReferenceException in Avalonia.Skia when creating a new Bitmap HOT 2
- Regression in 11.1: MultiValueConverter returning BindingNotification throws InvalidCastException HOT 3
- Behaviour of !! operator has changed in 11.1 HOT 5
- Tab Key Navigation not working when OverlayPopups is set to true
- System.InvalidOperationException: Neither DBus nor GTK are available on the system HOT 3
- Change in MultiBinding behaviour in 11.1.0-rc1 compared to 11.0.10 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avalonia.