The renderer was using the wrong bounds for text where `TextAlignment != Left` as seen in #1625. To fix this, change `FormattedTextImpl.Size` to `Bounds`, which returns a rect that takes into account the text alignment and similarly change `FormattedText.Measure` to return a `Rect` instead of a `Size.
Fixes#1625.
Whoever needs both the feature, calls then explicitly.
In this way TextPresenter's subscriber for SelectionStart/End doent invalidate measure,
since it should only focus on invalidate formatted text
Fixes#1448
InvalidateFormattedText was doing mainly 2 activities, resets formatted text and resets measure.
Splited it and extracted reset of formatted text in to seprate function and using it over there.
TextPresenter usis obervable stream for SelectionStart/End property, over there inside subscriber instead of calling InvalidateFormatedText now we use only ClearFormatedText.
The reason is SelectionStart/End is not going to make any changes regarding measurement and hence reseting formatted text alone is sufficient enough
Previously `IFormattedTextImpl` had `SetForegroundBrush` which set
mutable state. Make `FormattedText` fully mutable (before it was kinda
mutable, kinda immutable) and create immutable `IFormattedTextImpl`s on
demand.
Because it needs to be shared between the UI thread and the render
thread. This also required making it non-disposable like the other
graphics primitive impls.
Previous its color was immutable but because it inherited from Brush, its Opacity was mutable. This wasn't good, as it meant that e.g. Brushes.Red could be changed. Make it properly immutable by using the IBrush interface everywhere and not inheriting from Brush.
This is needed so that things like the following can be done:
<TreeView>
<TreeView.Styles>
<Style Selector="TreeViewItem">
<Setter Property="IsExpanded" Value="{Binding IsExpanded}"/>
</Style>
</TreeView.Styles>
<TreeView>
(At the moment we have TreeDataTemplate.IsExpanded but this isn't good
enough: it only supports setting IsExpanded on creation of the item with
no binding.)
With this commit, setters can now contain bindings, but they aren't yet
applied correctly. As part of this commit, classes related to binding
have been moved to the Perspex.Data namespace.