Closed SilkyFowl closed 4 months ago
@JaggerJo @Numpsy In this PR, I've been renaming/removing existing bindings and such when I notice cases, such as:
TextElement.create
... Removed. TextElement is abstract class. Throw exception when used. Other bindings that raise exceptions when used, such as bindings for readonly properties, are also removed.Shape.strokeJoinCap
... Renamed to Shape.strokeJoin
. Property name is wrong. No exceptions will be made, but confusion will occur.Should I include significant changes that require adjustments by users of FuncUI in this PR, other than the above?
Specifically, the change is as follows.
This change allows onDisplayModeChanged
to receive both the new and old values as arguments, which I personally think is a desirable change. However, there is no immediate necessity as using the existing onDisplayModeChanged
does not throw an exception.
diff --git a/src/Avalonia.FuncUI/DSL/Calendar/Calendar.fs b/src/Avalonia.FuncUI/DSL/Calendar/Calendar.fs
index 72008a8..6cc35d1 100644
--- a/src/Avalonia.FuncUI/DSL/Calendar/Calendar.fs
+++ b/src/Avalonia.FuncUI/DSL/Calendar/Calendar.fs
@@ -16,6 +16,19 @@ module Calendar =
type Calendar with
+ static member onDisplayModeChanged<'t when 't :> Calendar>(func: CalendarModeChangedEventArgs -> unit, ?subPatchOptions) : IAttr<'t> =
+ let name = nameof Unchecked.defaultof<'t>.DisplayModeChanged
+ let factory: SubscriptionFactory<CalendarModeChangedEventArgs> =
+ fun (control, func, token) ->
+ let control = control :?> 't
+ let handler = EventHandler<CalendarModeChangedEventArgs>(fun s e -> func e)
+ let event = control.DisplayModeChanged
+
+ event.AddHandler(handler)
+ token.Register(fun () -> event.RemoveHandler(handler)) |> ignore
+
+ AttrBuilder<'t>.CreateSubscription(name, factory, func, ?subPatchOptions = subPatchOptions)
+
static member firstDayOfWeek<'t when 't :> Calendar>(value: DayOfWeek) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<DayOfWeek>(Calendar.FirstDayOfWeekProperty, value, ValueNone)
@@ -31,9 +44,6 @@ module Calendar =
static member displayMode<'t when 't :> Calendar>(value: CalendarMode) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<CalendarMode>(Calendar.DisplayModeProperty, value, ValueNone)
- static member onDisplayModeChanged<'t when 't :> Calendar>(func: CalendarMode -> unit, ?subPatchOptions) : IAttr<'t> =
- AttrBuilder<'t>.CreateSubscription<CalendarMode>(Calendar.DisplayModeProperty, func, ?subPatchOptions = subPatchOptions)
-
static member selectionMode<'t when 't :> Calendar>(value: CalendarSelectionMode) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<CalendarSelectionMode>(Calendar.SelectionModeProperty, value, ValueNone)
Maybe put bigger breaking changes in an extra PR so we can discuss the separately. 👍
Thank you. I will do as you suggested.
@SilkyFowl I'm quite baffled with just how many bindings were missing 😅
@JaggerJo I'm also surprised. I'm thinking of making further changes in a separate PR.
Actually, I'm creating a draft to find the classes and their members that should generate the DSL from the specified assembly. It's incomplete, but I've made a feature to output in markdown format and I'm using it to manage. Originally, I was planning to submit a PR after the bindings update was completed and the analyzer or test function was expected to be completed. However, I'm considering whether I should submit a PR as a draft after describing the current situation in #424, as it seems to be late to submit a PR.
@SilkyFowl can I merge this?
This is a continuation of #420. It adds the bindings that are missing as of Avalonia v11.0.0.
This might become a larger PR than the previous one. Would it be better to create a tracking issue and split the PR?