Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<AvaloniaVersion>11.2.1</AvaloniaVersion>
<AvaloniaVersion>11.2.2</AvaloniaVersion>
<FabulousVersion>3.0.0-pre16</FabulousVersion>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions Fabulous.Avalonia.Samples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Solution Items", "_Solutio
Directory.Packages.props = Directory.Packages.props
README.md = README.md
global.json = global.json
Directory.Build.props = Directory.Build.props
EndProjectSection
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Tetris", "samples\Component\Tetris\Tetris.fsproj", "{48A8F92E-CFAD-4B35-9DD4-D3110E259AE6}"
Expand Down
15 changes: 2 additions & 13 deletions samples/Component/DrawingApp/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ open Avalonia.Media
open type Fabulous.Avalonia.View
open type Fabulous.Context


[<AutoOpen>]
module EmptyBorderBuilders =
type Fabulous.Avalonia.View with

/// <summary>Creates an empty Border widget.</summary>
static member EmptyBorder() =
WidgetBuilder<unit, IFabBorder>(Border.WidgetKey)

module ColorPicker =
let view (color: StateValue<Color>) =
Component("ColorPicker") {
Expand All @@ -29,8 +20,7 @@ module ColorPicker =

HStack(5.) {
for item in brushes do
View
.EmptyBorder()
Border()
.width(32.0)
.height(32.0)
.cornerRadius(16.0)
Expand All @@ -55,8 +45,7 @@ module SizePicker =

HStack(5.) {
for item in sizes do
View
.EmptyBorder()
Border()
.width(item)
.height(item)
.cornerRadius(item / 2.0)
Expand Down
13 changes: 2 additions & 11 deletions samples/Component/Tetris/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ open Avalonia.Themes.Fluent
open type Fabulous.Avalonia.View
open type Fabulous.Context


[<AutoOpen>]
module EmptyBorderBuilders =
type Fabulous.Avalonia.View with

/// <summary>Creates a empty Border widget.</summary>
static member EmptyBorder() =
WidgetBuilder<'msg, IFabBorder>(Border.WidgetKey)

// Credits to https://github.com/RyushiAok/Tetris for the original code
type Board =
{ width: int
Expand Down Expand Up @@ -218,7 +209,7 @@ module App =
let colors = toColor tetrimino isOver

for color in colors do
AnyView(Border(View.EmptyBorder().background(color)).padding(0.8))
AnyView(Border(Border().background(color)).padding(0.8))
})
.width(280.)
.height(480.)
Expand All @@ -243,7 +234,7 @@ module App =
| None -> ()
| Some colors ->
for color in colors do
Border(View.EmptyBorder().background(color)).padding(1.5)
Border(Border().background(color)).padding(1.5)
})
.height(70.0)
.width(70.0)
Expand Down
1 change: 1 addition & 0 deletions samples/Gallery/Gallery.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
<Compile Include="Pages\ThemeAwarePage.fs" />
<Compile Include="Pages\ToolTipPage.fs" />
<Compile Include="Pages\TreeView\SimpleTreeView.fs" />
<Compile Include="Pages\TreeView\SimpleTreeViewItem.fs" />
<Compile Include="Pages\TreeView\TreeViewWithNodeInteraction.fs" />
<Compile Include="Pages\TreeView\EditableTreeView.fs" />
<Compile Include="Pages\TreeViewPage.fs" />
Expand Down
20 changes: 4 additions & 16 deletions samples/Gallery/Pages/AdornerLayerPage.fs
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,13 @@ module AdornerLayerPage =
.horizontalAlignment(HorizontalAlignment.Center)

(Grid(coldefs = [ Pixel(24.); Auto; Pixel(24.) ], rowdefs = [ Pixel(24.); Auto; Pixel(24.) ]) {
EmptyBorder()
.background(Brushes.Red)
.gridColumn(1)
.gridRow(0)
Border().background(Brushes.Red).gridColumn(1).gridRow(0)

EmptyBorder()
.background(Brushes.Blue)
.gridColumn(0)
.gridRow(1)
Border().background(Brushes.Blue).gridColumn(0).gridRow(1)

EmptyBorder()
.background(Brushes.Green)
.gridColumn(2)
.gridRow(1)
Border().background(Brushes.Green).gridColumn(2).gridRow(1)

EmptyBorder()
.background(Brushes.Yellow)
.gridColumn(1)
.gridRow(2)
Border().background(Brushes.Yellow).gridColumn(1).gridRow(2)

LayoutTransformControl(
Button("Adorner Button", DoNothing)
Expand Down
36 changes: 13 additions & 23 deletions samples/Gallery/Pages/AnimationsPage.fs
Original file line number Diff line number Diff line change
Expand Up @@ -37,62 +37,52 @@ module AnimationsPage =

UserControl(
HWrap() {
EmptyBorder()
Border()
.style(borderTest1)
.classes([ "Test"; "Rect1" ])
.background(Brushes.DarkRed)

EmptyBorder()
Border()
.style(borderTest1)
.classes([ "Test"; "Rect2" ])
.background(Brushes.Magenta)

EmptyBorder()
.style(borderTest2)
.classes([ "Test"; "Rect3" ])
Border().style(borderTest2).classes([ "Test"; "Rect3" ])

EmptyBorder()
Border()
.style(borderTest1)
.classes([ "Test"; "Rect4" ])
.background(Brushes.Navy)

EmptyBorder()
Border()
.style(borderTest1)
.classes([ "Test"; "Rect5" ])
.background(Brushes.SeaGreen)

EmptyBorder()
Border()
.style(borderTest1)
.classes([ "Test"; "Rect6" ])
.background(Brushes.Red)

EmptyBorder()
Border()
.style(borderTest1)
.classes([ "Test"; "Shadow" ])
.cornerRadius(CornerRadius(10.))

EmptyBorder()
Border()
.style(borderTest1)
.classes([ "Test"; "Shadow" ])
.cornerRadius(CornerRadius(0., 30., 60., 0.))

EmptyBorder()
.style(borderTest1)
.classes([ "Test"; "Rect7" ])
Border().style(borderTest1).classes([ "Test"; "Rect7" ])

EmptyBorder()
.style(borderTest1)
.classes([ "Test"; "Rect8" ])
Border().style(borderTest1).classes([ "Test"; "Rect8" ])

EmptyBorder()
.style(borderTest1)
.classes([ "Test"; "Rect9" ])
Border().style(borderTest1).classes([ "Test"; "Rect9" ])

EmptyBorder()
.style(borderTest1)
.classes([ "Test"; "Rect10" ])
Border().style(borderTest1).classes([ "Test"; "Rect10" ])

EmptyBorder()
Border()
.style(borderTest1)
.classes([ "Test"; "Blur" ])
.background(Brushes.AliceBlue)
Expand Down
5 changes: 3 additions & 2 deletions samples/Gallery/Pages/ButtonsPage.fs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ module ButtonsPage =

ThemeVariantScope(ThemeVariant.Dark, Button("Dark Button", Clicked))

HyperlinkButton("Google", "https://www.google.com", model.IsVisited, IsVisitedChanged)
HyperlinkButton("Google", "https://www.google.com")
.onVisitedChanged(model.IsVisited, IsVisitedChanged)

HStack() {
HyperlinkButton("Google", "https://www.google.com")
.isVisited(model.IsVisited)
.onVisitedChanged(model.IsVisited, IsVisitedChanged)

CheckBox("IsVisited", model.IsVisited, Checked)
}
Expand Down
30 changes: 30 additions & 0 deletions samples/Gallery/Pages/CanvasPage.fs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,36 @@ module CanvasPage =
.background(SolidColorBrush(Colors.Yellow))
.size(300., 400.)

Border()
.height(920.)
.width(920.)
.padding(8.)
.background(Brushes.Magenta)
.opacityMask(
VisualBrush(
Border(
Grid(coldefs = [ Star; Star; Star ], rowdefs = [ Star; Star; Star ]) {
Border().background(SolidColorBrush(Colors.Aqua))

Border().gridRow(1).background(SolidColorBrush(Colors.Aqua))

Border().gridRow(2).background(SolidColorBrush(Colors.Aqua))

Border()
.gridColumn(1)
.background(SolidColorBrush(Colors.Aqua))
}
)
.height(200.)
.width(200.)
.padding(20.)

)
.stretch(Stretch.Fill)
.tileMode(TileMode.None)
)


(Canvas() {
Ellipse()
.canvasTop(10.)
Expand Down
19 changes: 12 additions & 7 deletions samples/Gallery/Pages/ComboBoxPage.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,29 @@ module ComboBoxPage =
type Model =
{ Items: string list
Fonts: FontFamily seq
IsDropDownOpen: bool }
IsDropDownOpen: bool
IsSelected: bool }

type Msg = DropDownOpened of bool
type Msg =
| DropDownOpened of bool
| SelectedChanged of bool

let fontComboBox () =
FontManager.Current.SystemFonts |> Seq.map(fun x -> FontFamily(x.Name))

let init () =
{ IsDropDownOpen = false
Items = [ "Inline Items 1"; "Inline Item 2"; "Inline Item 3"; "Inline Item 4" ]
Fonts = fontComboBox() },
Cmd.none
Fonts = fontComboBox()
IsSelected = false }

let update msg model =
match msg with
| DropDownOpened isOpen -> { model with IsDropDownOpen = isOpen }, Cmd.none
| DropDownOpened isOpen -> { model with IsDropDownOpen = isOpen }
| SelectedChanged isSelected -> { model with IsSelected = isSelected }

let program =
Program.statefulWithCmd init update
Program.stateful init update
|> Program.withTrace(fun (format, args) -> Debug.WriteLine(format, box args))
|> Program.withExceptionHandler(fun ex ->
#if DEBUG
Expand Down Expand Up @@ -71,7 +75,8 @@ module ComboBoxPage =
.selectedIndex(0)

(ComboBox() {
ComboBoxItem("Select a font", true)
ComboBoxItem("Select a font")
.onSelectedChanged(model.IsSelected, SelectedChanged)

for font in model.Fonts do
ComboBoxItem(font.Name)
Expand Down
5 changes: 3 additions & 2 deletions samples/Gallery/Pages/DropDownButtonPage.fs
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,18 @@ module DropDownButtonPage =
MenuItem("Item 1")
.icon(Image("avares://Gallery/Assets/Icons/fabulous-icon.png"))

MenuItems("Item 2", Increment) {
MenuItems("Item 2") {
MenuItem("Subitem 1")
MenuItem("Subitem 2")
MenuItem("Subitem 3")
MenuItem("Subitem 4")
MenuItem("Subitem 5")
}
|> _.onClick(Increment)

MenuItem("Item 4").inputGesture(KeyGesture.Parse("Ctrl+A"))
MenuItem("Item 5").inputGesture(KeyGesture.Parse("Ctrl+A"))
MenuItem(TextBlock("Item 6"), Increment)
MenuItem(TextBlock("Item 6")).onClick(Increment)
MenuItem("Item 7")
})
.placement(PlacementMode.BottomEdgeAlignedRight)
Expand Down
2 changes: 1 addition & 1 deletion samples/Gallery/Pages/ExpanderPage.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module ExpanderPage =
let! model = Context.Mvu program

VStack(spacing = 15.) {
Expander("Title", "Mr.").isExpanded(model.IsExpanded)
Expander("Title", "Mr.")

Expander(TextBlock("Title"), "Mr.")
.onExpandedChanged(model.IsExpanded, ExpandChanged)
Expand Down
2 changes: 1 addition & 1 deletion samples/Gallery/Pages/ExpressionAnimation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module ExpressionAnimation =
.dock(Dock.Top)
.margin(12.)

EmptyBorder()
Border()
.background(SolidColorBrush(Colors.Red))
.width(200.)
.height(200.)
Expand Down
8 changes: 4 additions & 4 deletions samples/Gallery/Pages/GesturesPage.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module GesturesPage =
Border(
(Dock() {
Border(
EmptyBorder()
Border()
.width(10.)
.height(10.)
.horizontalAlignment(HorizontalAlignment.Center)
Expand All @@ -66,7 +66,7 @@ module GesturesPage =
.borderThickness(1.)

Border(
EmptyBorder()
Border()
.width(10.)
.name("BottomBall")
.horizontalAlignment(HorizontalAlignment.Center)
Expand All @@ -85,7 +85,7 @@ module GesturesPage =
.borderThickness(1.)

Border(
EmptyBorder()
Border()
.width(10.)
.height(10.)
.name("RightBall")
Expand All @@ -105,7 +105,7 @@ module GesturesPage =
.borderThickness(1.)

Border(
EmptyBorder()
Border()
.width(10.)
.height(10.)
.name("LeftBall")
Expand Down
Loading