Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding more Color overloads for brush properties #363

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Avalonia.FuncUI/DSL/Base/ContentPresenter.fs
Original file line number Diff line number Diff line change
@@ -21,11 +21,17 @@ module ContentPresenter =
static member background<'t when 't :> ContentPresenter>(color: string) : IAttr<'t> =
Color.Parse(color) |> ImmutableSolidColorBrush |> ContentPresenter.background

static member background<'t when 't :> ContentPresenter>(color: Color) : IAttr<'t> =
color |> ImmutableSolidColorBrush |> ContentPresenter.background

static member borderBrush<'t when 't :> ContentPresenter>(brush: IBrush) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<IBrush>(ContentPresenter.BorderBrushProperty, brush, ValueNone)

static member borderBrush<'t when 't :> ContentPresenter>(color: string) : IAttr<'t> =
Color.Parse(color) |> ImmutableSolidColorBrush |> ContentPresenter.borderBrush

static member borderBrush<'t when 't :> ContentPresenter>(color: Color) : IAttr<'t> =
color |> ImmutableSolidColorBrush |> ContentPresenter.borderBrush

static member borderThickness<'t when 't :> ContentPresenter>(value: Thickness) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<Thickness>(ContentPresenter.BorderThicknessProperty, value, ValueNone)
5 changes: 4 additions & 1 deletion src/Avalonia.FuncUI/DSL/Base/Panel.fs
Original file line number Diff line number Diff line change
@@ -19,4 +19,7 @@ module Panel =
AttrBuilder<'t>.CreateProperty<IBrush>(Panel.BackgroundProperty, value, ValueNone)

static member background<'t when 't :> Panel>(color: string) : IAttr<'t> =
color |> Color.Parse |> ImmutableSolidColorBrush |> Panel.background
color |> Color.Parse |> ImmutableSolidColorBrush |> Panel.background

static member background<'t when 't :> Panel>(color: Color) : IAttr<'t> =
color |> ImmutableSolidColorBrush |> Panel.background
3 changes: 3 additions & 0 deletions src/Avalonia.FuncUI/DSL/Border.fs
Original file line number Diff line number Diff line change
@@ -27,6 +27,9 @@ module Border =

static member borderBrush<'t when 't :> Border>(color: string) : IAttr<'t> =
color |> Color.Parse |> ImmutableSolidColorBrush |> Border.borderBrush

static member borderBrush<'t when 't :> Border>(color: Color) : IAttr<'t> =
color |> ImmutableSolidColorBrush |> Border.borderBrush

static member borderThickness<'t when 't :> Border>(value: Thickness) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<Thickness>(Border.BorderThicknessProperty, value, ValueNone)
3 changes: 3 additions & 0 deletions src/Avalonia.FuncUI/DSL/DataGrid.fs
Original file line number Diff line number Diff line change
@@ -118,6 +118,9 @@ module DataGridTextColumn =
static member foreground<'t when 't :> DataGridTextColumn>(color: string) : IAttr<'t> =
color |> Color.Parse |> ImmutableSolidColorBrush |> DataGridTextColumn.foreground

static member foreground<'t when 't :> DataGridTextColumn>(color: Color) : IAttr<'t> =
color |> ImmutableSolidColorBrush |> DataGridTextColumn.foreground


[<AutoOpen>]
module DataGridCheckBoxColumn =
6 changes: 6 additions & 0 deletions src/Avalonia.FuncUI/DSL/Primitives/TemplatedControl.fs
Original file line number Diff line number Diff line change
@@ -20,11 +20,17 @@ module TemplatedControl =
static member background<'t when 't :> TemplatedControl>(color: string) : IAttr<'t> =
Color.Parse(color) |> ImmutableSolidColorBrush |> TemplatedControl.background

static member background<'t when 't :> TemplatedControl>(color: Color) : IAttr<'t> =
color |> ImmutableSolidColorBrush |> TemplatedControl.background

static member borderBrush<'t when 't :> TemplatedControl>(value: IBrush) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<IBrush>(TemplatedControl.BorderBrushProperty, value, ValueNone)

static member borderBrush<'t when 't :> TemplatedControl>(color: string) : IAttr<'t> =
Color.Parse(color) |> ImmutableSolidColorBrush |> TemplatedControl.borderBrush

static member borderBrush<'t when 't :> TemplatedControl>(color: Color) : IAttr<'t> =
color |> ImmutableSolidColorBrush |> TemplatedControl.borderBrush

static member borderThickness<'t when 't :> TemplatedControl>(value: Thickness) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<Thickness>(TemplatedControl.BorderThicknessProperty, value, ValueNone)
6 changes: 6 additions & 0 deletions src/Avalonia.FuncUI/DSL/Primitives/TextElement.fs
Original file line number Diff line number Diff line change
@@ -18,6 +18,9 @@ module TextElement =

static member background<'t when 't :> TextElement>(color: string) : IAttr<'t> =
Color.Parse(color) |> ImmutableSolidColorBrush |> TextElement.background

static member background<'t when 't :> TextElement>(color: Color) : IAttr<'t> =
color |> ImmutableSolidColorBrush |> TextElement.background

static member fontFamily<'t when 't :> TextElement>(value: FontFamily) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<FontFamily>(TextElement.FontFamilyProperty, value, ValueNone)
@@ -39,3 +42,6 @@ module TextElement =

static member foreground<'t when 't :> TextElement>(color: string) : IAttr<'t> =
Color.Parse(color) |> ImmutableSolidColorBrush |> TextElement.foreground

static member foreground<'t when 't :> TextElement>(color: Color) : IAttr<'t> =
color |> ImmutableSolidColorBrush |> TextElement.foreground
6 changes: 6 additions & 0 deletions src/Avalonia.FuncUI/DSL/Shapes/Shape.fs
Original file line number Diff line number Diff line change
@@ -16,6 +16,9 @@ module Shape =

static member fill<'t when 't :> Shape>(color: string) : IAttr<'t> =
color |> Color.Parse |> ImmutableSolidColorBrush |> Shape.fill

static member fill<'t when 't :> Shape>(color: Color) : IAttr<'t> =
color |> ImmutableSolidColorBrush |> Shape.fill

static member stretch<'t when 't :> Shape>(value: Stretch) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<Stretch>(Shape.StretchProperty, value, ValueNone)
@@ -25,6 +28,9 @@ module Shape =

static member stroke<'t when 't :> Shape>(color: string) : IAttr<'t> =
color |> Color.Parse |> ImmutableSolidColorBrush |> Shape.stroke

static member stroke<'t when 't :> Shape>(color: Color) : IAttr<'t> =
color |> ImmutableSolidColorBrush |> Shape.stroke

static member strokeThickness<'t when 't :> Shape>(value: double) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<double>(Shape.StrokeThicknessProperty, value, ValueNone)
6 changes: 6 additions & 0 deletions src/Avalonia.FuncUI/DSL/TextBlock.fs
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@ module TextBlock =

static member background<'t when 't :> TextBlock>(color: string) : IAttr<'t> =
color |> Color.Parse |> ImmutableSolidColorBrush |> TextBlock.background

static member background<'t when 't :> TextBlock>(color: Color) : IAttr<'t> =
color |> ImmutableSolidColorBrush |> TextBlock.background

static member fontFamily<'t when 't :> TextBlock>(value: FontFamily) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<FontFamily>(TextBlock.FontFamilyProperty, value, ValueNone)
@@ -42,6 +45,9 @@ module TextBlock =
static member foreground<'t when 't :> TextBlock>(color: string) : IAttr<'t> =
color |> Color.Parse |> ImmutableSolidColorBrush |> TextBlock.foreground

static member foreground<'t when 't :> TextBlock>(color: Color) : IAttr<'t> =
color |> ImmutableSolidColorBrush |> TextBlock.foreground

static member inlines<'t when 't :> TextBlock>(value: InlineCollection) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<InlineCollection>(TextBlock.InlinesProperty, value, ValueNone)

9 changes: 9 additions & 0 deletions src/Avalonia.FuncUI/DSL/TextBox.fs
Original file line number Diff line number Diff line change
@@ -38,18 +38,27 @@ module TextBox =
static member selectionBrush<'t when 't :> TextBox>(color: string) : IAttr<'t> =
color |> Color.Parse |> ImmutableSolidColorBrush |> TextBox.selectionBrush

static member selectionBrush<'t when 't :> TextBox>(color: Color) : IAttr<'t> =
color |> ImmutableSolidColorBrush |> TextBox.selectionBrush

static member selectionForegroundBrush<'t when 't :> TextBox>(value: IBrush) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<IBrush>(TextBox.SelectionForegroundBrushProperty, value, ValueNone)

static member selectionForegroundBrush<'t when 't :> TextBox>(color: string) : IAttr<'t> =
color |> Color.Parse |> ImmutableSolidColorBrush |> TextBox.selectionForegroundBrush

static member selectionForegroundBrush<'t when 't :> TextBox>(color: Color) : IAttr<'t> =
color |> ImmutableSolidColorBrush |> TextBox.selectionForegroundBrush

static member caretBrush<'t when 't :> TextBox>(value: IBrush) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<IBrush>(TextBox.CaretBrushProperty, value, ValueNone)

static member caretBrush<'t when 't :> TextBox>(color: string) : IAttr<'t> =
color |> Color.Parse |> ImmutableSolidColorBrush |> TextBox.selectionBrush

static member caretBrush<'t when 't :> TextBox>(color: Color) : IAttr<'t> =
color |> ImmutableSolidColorBrush |> TextBox.selectionBrush

static member selectionStart<'t when 't :> TextBox>(value: int) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<int>(TextBox.SelectionStartProperty, value, ValueNone)