├── .editorconfig ├── .github └── FUNDING.yml ├── .gitignore ├── Avalonia.Flexbox.sln ├── Directory.Build.props ├── Directory.Build.targets ├── Icon.ico ├── Icon.png ├── Icon.svg ├── LICENSE.md ├── README.md ├── appveyor.yml ├── build └── Targets │ ├── Import.props │ ├── Import.targets │ ├── PackageProperties.props │ ├── PackageProperties.targets │ ├── PackageVersions.targets │ └── RepoLayout.props ├── samples ├── Avalonia.Flexbox.Demo │ ├── App.axaml │ ├── App.axaml.cs │ ├── Avalonia.Flexbox.Demo.csproj │ ├── Converters │ │ └── NumberToThicknessConverter.cs │ ├── MainWindow.axaml │ ├── MainWindow.axaml.cs │ ├── Resources │ │ └── Icon.png │ └── ViewModels │ │ ├── ItemViewModel.cs │ │ └── MainWindowViewModel.cs └── Directory.Build.props └── src └── Avalonia.Flexbox ├── AlignContent.cs ├── AlignItems.cs ├── Avalonia.Flexbox.csproj ├── Flex.cs ├── FlexDirection.cs ├── FlexLayout.cs ├── FlexPanel.cs ├── FlexWrap.cs ├── IFlexLayout.cs ├── JustifyContent.cs ├── PanelNonVirtualizingLayoutContext.cs └── Uv.cs /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_size = 4 5 | indent_style = space 6 | insert_final_newline = true 7 | trim_trailing_whitespace = true 8 | end_of_line = crlf 9 | 10 | [*.cs] 11 | csharp_style_conditional_delegate_call = true:warning 12 | csharp_style_expression_bodied_accessors = true:suggestion 13 | csharp_style_expression_bodied_constructors = false:warning 14 | csharp_style_expression_bodied_indexers = true:suggestion 15 | csharp_style_expression_bodied_methods = true:suggestion 16 | csharp_style_expression_bodied_operators = true:suggestion 17 | csharp_style_expression_bodied_properties = true:suggestion 18 | csharp_style_inlined_variable_declaration = true:warning 19 | csharp_style_pattern_matching_over_as_with_null_check = true:warning 20 | csharp_style_pattern_matching_over_is_with_cast_check = true:warning 21 | csharp_style_throw_expression = true:warning 22 | csharp_style_var_elsewhere = true:suggestion 23 | csharp_style_var_for_built_in_types = false:none 24 | csharp_style_var_when_type_is_apparent = true:suggestion 25 | 26 | csharp_new_line_before_catch = true:warning 27 | csharp_new_line_before_else = true:warning 28 | csharp_new_line_before_finally = true:warning 29 | csharp_new_line_before_members_in_anonymous_types = true:warning 30 | csharp_new_line_before_members_in_object_initializers = true:warning 31 | #csharp_new_line_before_open_brace = all:warning 32 | csharp_new_line_between_query_expression_clauses = true:warning 33 | 34 | csharp_indent_case_contents = true:warning 35 | csharp_indent_labels = one_less_than_current:suggestion 36 | csharp_indent_switch_labels = true:warning 37 | 38 | csharp_preserve_single_line_blocks = true:suggestion 39 | csharp_preserve_single_line_statements = false:warning 40 | 41 | csharp_space_after_cast = false:warning 42 | csharp_space_after_keywords_in_control_flow_statements = true:warning 43 | csharp_space_between_method_call_parameter_list_parentheses = false:warning 44 | csharp_space_between_method_declaration_parameter_list_parentheses = false:warning 45 | csharp_space_between_parentheses = false:warning 46 | 47 | csharp_prefer_braces = true:warning 48 | csharp_prefer_simple_default_expression = false:none 49 | 50 | dotnet_sort_system_directives_first = true:suggestion 51 | 52 | dotnet_style_coalesce_expression = true:warning 53 | dotnet_style_collection_initializer = true:suggestion 54 | dotnet_style_explicit_tuple_names = true:suggestion 55 | dotnet_style_null_propagation = true:warning 56 | dotnet_style_object_initializer = true:suggestion 57 | dotnet_style_predefined_type_for_locals_parameters_members = true:warning 58 | dotnet_style_predefined_type_for_member_access = false:warning 59 | dotnet_style_qualification_for_event = false:warning 60 | dotnet_style_qualification_for_field = false:warning 61 | dotnet_style_qualification_for_method = false:warning 62 | dotnet_style_qualification_for_property = false:warning 63 | 64 | dotnet_naming_rule.camel_case_for_private_fields.severity = suggestion 65 | dotnet_naming_rule.camel_case_for_private_fields.symbols = private_fields 66 | dotnet_naming_rule.camel_case_for_private_fields.style = camel_case_underscore_style 67 | 68 | dotnet_naming_symbols.private_fields.applicable_kinds = field 69 | dotnet_naming_symbols.private_fields.applicable_accessibilities = private 70 | 71 | dotnet_naming_style.camel_case_underscore_style.required_prefix = _ 72 | dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case 73 | 74 | dotnet_code_quality.ca1801.api_surface = private, internal 75 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: jp2masa 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific files 2 | 3 | .vs/ 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Build results 10 | 11 | [Aa]rtifacts/ 12 | [Bb]in/ 13 | [Oo]bj/ 14 | -------------------------------------------------------------------------------- /Avalonia.Flexbox.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32929.385 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Flexbox", "src\Avalonia.Flexbox\Avalonia.Flexbox.csproj", "{3474C152-4B81-4E94-B149-82BCC1B4A8E8}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4EC01977-A4B9-43F0-A9AD-F800A11B9429}" 9 | ProjectSection(SolutionItems) = preProject 10 | .editorconfig = .editorconfig 11 | appveyor.yml = appveyor.yml 12 | Directory.Build.props = Directory.Build.props 13 | Directory.Build.targets = Directory.Build.targets 14 | EndProjectSection 15 | EndProject 16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{5B227943-8228-466D-BECB-2BAFDC3DDF30}" 17 | EndProject 18 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Targets", "Targets", "{FC21DC29-CDDA-49DA-805A-BFF4A1084B81}" 19 | ProjectSection(SolutionItems) = preProject 20 | build\Targets\Import.props = build\Targets\Import.props 21 | build\Targets\Import.targets = build\Targets\Import.targets 22 | build\Targets\PackageProperties.props = build\Targets\PackageProperties.props 23 | build\Targets\PackageProperties.targets = build\Targets\PackageProperties.targets 24 | build\Targets\PackageVersions.targets = build\Targets\PackageVersions.targets 25 | build\Targets\RepoLayout.props = build\Targets\RepoLayout.props 26 | EndProjectSection 27 | EndProject 28 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Flexbox.Demo", "samples\Avalonia.Flexbox.Demo\Avalonia.Flexbox.Demo.csproj", "{64B2D521-D0AA-4D25-BC01-BBCA35A36948}" 29 | EndProject 30 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{0ED17017-116A-4D3B-A094-40AEDFE95385}" 31 | ProjectSection(SolutionItems) = preProject 32 | samples\Directory.Build.props = samples\Directory.Build.props 33 | EndProjectSection 34 | EndProject 35 | Global 36 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 37 | Debug|Any CPU = Debug|Any CPU 38 | Release|Any CPU = Release|Any CPU 39 | EndGlobalSection 40 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 41 | {3474C152-4B81-4E94-B149-82BCC1B4A8E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 42 | {3474C152-4B81-4E94-B149-82BCC1B4A8E8}.Debug|Any CPU.Build.0 = Debug|Any CPU 43 | {3474C152-4B81-4E94-B149-82BCC1B4A8E8}.Release|Any CPU.ActiveCfg = Release|Any CPU 44 | {3474C152-4B81-4E94-B149-82BCC1B4A8E8}.Release|Any CPU.Build.0 = Release|Any CPU 45 | {64B2D521-D0AA-4D25-BC01-BBCA35A36948}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 46 | {64B2D521-D0AA-4D25-BC01-BBCA35A36948}.Debug|Any CPU.Build.0 = Debug|Any CPU 47 | {64B2D521-D0AA-4D25-BC01-BBCA35A36948}.Release|Any CPU.ActiveCfg = Release|Any CPU 48 | {64B2D521-D0AA-4D25-BC01-BBCA35A36948}.Release|Any CPU.Build.0 = Release|Any CPU 49 | EndGlobalSection 50 | GlobalSection(SolutionProperties) = preSolution 51 | HideSolutionNode = FALSE 52 | EndGlobalSection 53 | GlobalSection(NestedProjects) = preSolution 54 | {5B227943-8228-466D-BECB-2BAFDC3DDF30} = {4EC01977-A4B9-43F0-A9AD-F800A11B9429} 55 | {FC21DC29-CDDA-49DA-805A-BFF4A1084B81} = {5B227943-8228-466D-BECB-2BAFDC3DDF30} 56 | {0ED17017-116A-4D3B-A094-40AEDFE95385} = {4EC01977-A4B9-43F0-A9AD-F800A11B9429} 57 | EndGlobalSection 58 | GlobalSection(ExtensibilityGlobals) = postSolution 59 | SolutionGuid = {8A1CEBA2-78F5-4365-9E9B-84E75DEA43E8} 60 | EndGlobalSection 61 | EndGlobal 62 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildThisFileDirectory) 5 | 6 | 7 | 8 | $(RepoRoot)\Icon.ico 9 | 10 | 11 | 12 | Latest 13 | Enable 14 | 15 | 16 | 17 | 0.3.0-beta.4 18 | -build.$(APPVEYOR_BUILD_NUMBER)+$(APPVEYOR_REPO_COMMIT.Substring(0, 7)) 19 | -localbuild$([System.DateTime]::Now.ToString("yyyyMMddHHmmss")) 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Directory.Build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp2masa/Avalonia.Flexbox/8fcef06197fd97741cb410d5f3e70faf17b1dc17/Icon.ico -------------------------------------------------------------------------------- /Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp2masa/Avalonia.Flexbox/8fcef06197fd97741cb410d5f3e70faf17b1dc17/Icon.png -------------------------------------------------------------------------------- /Icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 21 | 23 | 26 | 30 | 31 | 34 | 38 | 39 | 42 | 46 | 47 | 48 | 68 | 71 | 72 | 74 | 75 | 77 | image/svg+xml 78 | 80 | 81 | 82 | 83 | 84 | 88 | 95 | 102 | 109 | 116 | 123 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright © jp2masa 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated documentation 8 | files (the “Software”), to deal in the Software without 9 | restriction, including without limitation the rights to use, 10 | copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the 12 | Software is furnished to do so, subject to the following 13 | conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | OTHER DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build status](https://ci.appveyor.com/api/projects/status/nmrcxy5hi7v9232n?svg=true)](https://ci.appveyor.com/project/jp2masa/avalonia-flexbox) 2 | 3 | # Avalonia.Flexbox 4 | 5 | ![Avalonia.Flexbox](Icon.png) 6 | 7 | Avalonia.Flexbox is a flexbox implementation for Avalonia. 8 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 0.3.0-build{build} 2 | image: Visual Studio 2022 3 | 4 | shallow_clone: true 5 | clone_folder: c:\Avalonia.Flexbox 6 | 7 | configuration: 8 | - Debug 9 | - Release 10 | platform: Any CPU 11 | 12 | matrix: 13 | fast_finish: true 14 | 15 | nuget: 16 | account_feed: false 17 | project_feed: true 18 | disable_publish_on_pr: true 19 | 20 | build_script: 21 | - cmd: dotnet msbuild /t:Restore;Build;Pack Avalonia.Flexbox.sln 22 | 23 | test: off 24 | 25 | artifacts: 26 | - path: 'artifacts\Debug\nupkg\*.nupkg' 27 | name: DebugNupkg 28 | - path: 'artifacts\Release\nupkg\*.nupkg' 29 | name: ReleaseNupkg 30 | 31 | deploy: 32 | - provider: NuGet 33 | api_key: 34 | secure: xWkQ7tm0o3jWSCcsQ9QiBIPe5VDqJbCzf9aVi+zIgnbhXV2FGT34eOuJetk7QqLU 35 | artifact: ReleaseNupkg 36 | on: 37 | branch: master 38 | configuration: Release 39 | appveyor_repo_tag: true 40 | - provider: NuGet 41 | server: https://www.myget.org/F/jp2masa/api/v2/package 42 | artifact: DebugNupkg 43 | api_key: 44 | secure: puOcEbngEmaVMEnUL20u4mzATgvoyaTPRWGGwE98as1+8KGY3ypOKzt5OV63duwI 45 | on: 46 | branch: master 47 | configuration: Debug 48 | -------------------------------------------------------------------------------- /build/Targets/Import.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /build/Targets/Import.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /build/Targets/PackageProperties.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(PackageVersion)$(PackageVersionSuffix) 5 | 6 | 7 | 8 | Avalonia.Flexbox is a flexbox implementation for Avalonia. 9 | 10 | 11 | 12 | jp2masa 13 | Copyright © $([System.DateTime]::Now.Year) jp2masa 14 | Icon.png 15 | http://github.com/jp2masa/Avalonia.Flexbox 16 | MIT 17 | True 18 | flex flexbox avalonia css dotnet core csharp vb visual basic fsharp 19 | git 20 | https://github.com/jp2masa/Avalonia.Flexbox 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /build/Targets/PackageProperties.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(AssemblyName) 5 | jp2masa.$(PackageId) 6 | $(PackageDescription) 7 | 8 | $(BaseDescription) 9 | $(BaseDescription) 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /build/Targets/PackageVersions.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11.0.0-rc2.1 5 | 7.0.3 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /build/Targets/RepoLayout.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | $(Platform) 7 | 8 | 9 | 10 | $(RepoRoot)artifacts\ 11 | $(ArtifactsDir)$(Configuration)\nupkg\ 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /samples/Avalonia.Flexbox.Demo/App.axaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/Avalonia.Flexbox.Demo/App.axaml.cs: -------------------------------------------------------------------------------- 1 | using Avalonia.Controls.ApplicationLifetimes; 2 | using Avalonia.Markup.Xaml; 3 | using Avalonia.ReactiveUI; 4 | 5 | using Avalonia.Flexbox.Demo.ViewModels; 6 | 7 | namespace Avalonia.Flexbox.Demo 8 | { 9 | public class App : Application 10 | { 11 | public override void Initialize() => AvaloniaXamlLoader.Load(this); 12 | 13 | public override void OnFrameworkInitializationCompleted() 14 | { 15 | if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) 16 | { 17 | desktop.MainWindow = new MainWindow() { DataContext = new MainWindowViewModel() }; 18 | } 19 | 20 | base.OnFrameworkInitializationCompleted(); 21 | } 22 | 23 | public static void Main(string[] args) => BuildAvaloniaApp() 24 | .StartWithClassicDesktopLifetime(args); 25 | 26 | public static AppBuilder BuildAvaloniaApp() => 27 | AppBuilder.Configure() 28 | .UsePlatformDetect() 29 | .UseReactiveUI() 30 | .LogToTrace(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /samples/Avalonia.Flexbox.Demo/Avalonia.Flexbox.Demo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | WinExe 6 | $(IconIcoPath) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /samples/Avalonia.Flexbox.Demo/Converters/NumberToThicknessConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | 4 | using Avalonia.Data.Converters; 5 | 6 | namespace Avalonia.Flexbox.Demo.Converters 7 | { 8 | internal sealed class NumberToThicknessConverter : IValueConverter 9 | { 10 | public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) 11 | { 12 | if (value is int x && targetType.IsAssignableFrom(typeof(Thickness))) 13 | { 14 | var y = 16 + 2 * ((x * 5) % 9); 15 | return new Thickness(2 * y, y); 16 | } 17 | 18 | throw new NotSupportedException(); 19 | } 20 | 21 | public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => 22 | throw new NotSupportedException(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /samples/Avalonia.Flexbox.Demo/MainWindow.axaml: -------------------------------------------------------------------------------- 1 |  13 | 14 | 15 | 17 | 20 | 21 | 24 | 27 | 28 | 31 | 32 | 33 | 34 | 35 | 40 | 43 | 48 | 49 | 50 | 51 | 52 | 55 | 56 | 57 | 58 | 60 | 61 | 62 | 64 | 66 | 67 | 68 | 69 | 70 | 72 | 73 | 74 | 75 | 76 | 78 | 79 | 80 | 81 | 82 | 84 | 85 | 86 | 87 | 88 | 90 | 91 | 92 | 93 | 94 | 96 | 97 | 98 | 99 | 100 | 102 | 103 | 104 | 105 | 106 | 108 | 109 | 110 | 113 | 114 | 115 | 116 | 119 | 120 | 121 | 122 | 123 | 125 | 126 | 127 | 128 | 129 |