These are chat archives for AvaloniaUI/Avalonia

13th
Oct 2017
That's... quite a bit
And I don't think we can exclude anything else
Jeremy Koritzinsky
@jkoritzinsky
Oct 13 2017 01:58
I renamed the tag to work with Githubs new integration for the help wanted label.
I think we can punt font fallbacks to our next release. If we aim for monthly/6 week releases instead of 5-6 months between releases we can have more control over feature creep and have each release focus on one big feature and some small features.
Like we could do font fallback in beta 2 or 3 which would come out a few months from now instead of next summer.
Jeremy Koritzinsky
@jkoritzinsky
Oct 13 2017 07:31
@grokys I figured out what's going on in #855. Can you take a look at my comments there? I want to figure out a plan of attack on how we want to fix #855 and I'd like your input if possible.
Steven Kirk
@grokys
Oct 13 2017 07:38
oh nice @jkoritzinsky, let me take a look
ok, i don't understand what happens between 3f "At this point, A.Prop, B.Prop, C.Prop all equal Y."
and 4 "Because B.Prop <--> A.Prop is two-way, B.Prop is set to X"
where did the X come from if all 3 properties == Y?
Matthijs ter Woord
@mterwoord
Oct 13 2017 08:57
@kekekeks why you want to hide stuff from that side?
Nikita Tsukanov
@kekekeks
Oct 13 2017 08:59
ehm, hide?
Matthijs ter Woord
@mterwoord
Oct 13 2017 09:00
" renaming up-for-grabs to help-wanted makes it invisible to http://up-for-grabs.net/"
danwalmsley
@danwalmsley
Oct 13 2017 09:01
@kekekeks did you think that
#1210 fixed the issue for AS
it seems to me its still broken
Nikita Tsukanov
@kekekeks
Oct 13 2017 09:01
Ah, that
Our up-for-grabs label got renamed to help-wanted
I've noticed that and mentioned that it breaks up-for-grabs.net integration
Matthijs ter Woord
@mterwoord
Oct 13 2017 09:02
ah, ok, misinterpreterd your mewssage..
i thought that's what you wanted :)
Nikita Tsukanov
@kekekeks
Oct 13 2017 09:04
@danwalmsley It definitely fixes an issue with capture not being released, so we should merge it even if AS crashes for different reason
danwalmsley
@danwalmsley
Oct 13 2017 09:05
image.png
its still a bug in button, so can that be fixes by just checking if button is still attached to visual tree?
or would that be a hack?
with !hit.IsAttachedToVisualTree
That way you can set the next statement and debug hit-testing for that particular event
danwalmsley
@danwalmsley
Oct 13 2017 09:10
ok breakpoint hit
what now?
do we add that as a condition to that if statement?
image.png
Captured == Button
Nikita Tsukanov
@kekekeks
Oct 13 2017 09:14
So it's removed from the tree, but still captured?
danwalmsley
@danwalmsley
Oct 13 2017 09:14
yup
Nikita Tsukanov
@kekekeks
Oct 13 2017 09:15
That's weird...
danwalmsley
@danwalmsley
Oct 13 2017 09:15
it looks like detached from visual tree hasn't been called then
Nikita Tsukanov
@kekekeks
Oct 13 2017 09:15
I'd suggest to add a check in Captured getter
danwalmsley
@danwalmsley
Oct 13 2017 09:15
as a fix?
Nikita Tsukanov
@kekekeks
Oct 13 2017 09:16
Yep, as a fix for the issue
DetachedFromVisualTree not being called is another issue
danwalmsley
@danwalmsley
Oct 13 2017 09:16
can you add an issue for that
and ill submit a fix
maybe its that #1210 doesn't fix anything then?
yeah
I put this
if (value != null)
                {
                    _capturedSubscription = Observable.FromEventPattern<VisualTreeAttachmentEventArgs>(
                        x => value.DetachedFromVisualTree += x,
                        x => value.DetachedFromVisualTree -= x)
                        .Take(1)
                        .Subscribe(_ =>
                        {
                            Captured = null;
                            Console.WriteLine("Captured set to null.");
                        });
                }
and I never saw anything on the console
Nikita Tsukanov
@kekekeks
Oct 13 2017 09:22
Are you sure that you don't override OnDetachedFromVisualTree without calling the base implementation?
Because, you know, test is passing
danwalmsley
@danwalmsley
Oct 13 2017 09:23
let me check
  <cont:DocumentTabControl Items="{Binding Documents}" SelectedItem="{Binding SelectedDocument, Mode=TwoWay}">
    <cont:DocumentTabControl.HeaderTemplate>
      <DataTemplate>
        <StackPanel Orientation="Horizontal" Gap="2">
          <TextBlock Text="{Binding Title}" Margin="2" FontSize="12"/>
          <Button IsVisble="{Binding IsSelected}" Height="14" Width="14" Command="{Binding CloseCommand}">
its just a normal button
    public class DocumentTabControl : UserControl
    {
        public DocumentTabControl()
        {
            InitializeComponent();
        }

        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);
        }
    }
its inside a TabStrip control, and it uses an itemtemplate which contains the button
so its probably something else
@grokys I guess we need to fire some events regardress of what people think about calling the base method
danwalmsley
@danwalmsley
Oct 13 2017 09:32
ok I better fix those
if you don't call base method it breaks that event propagating the tree right?
Steven Kirk
@grokys
Oct 13 2017 11:47
hmm yeah i guess we should raise AttachedToVisualTreein OnAttachedToVisualTreeCore
the usual pattern is for OnX to raise the event and if you override but don't call the base then the event won't get signaled, but in this case i think the event is too important
Steven Kirk
@grokys
Oct 13 2017 12:44
ok, pushed an update to make sure those events are always called
danwalmsley
@danwalmsley
Oct 13 2017 13:01
@grokys il see if that now works thanks
btw I'm developing an editable text block control for Avalon studio, i.e. textblock, but when you double click it, turns into a textbox
would that be suitable for control catalog?
or keep outside avalonia?
Nikita Tsukanov
@kekekeks
Oct 13 2017 13:03
The thing about controls like that
We don't really want them in the main repo
But at the current stage of the project
API/ABI breaks every month
So it will be a bit troublesome to keep them up to date
danwalmsley
@danwalmsley
Oct 13 2017 13:04
I was thinking best to keep outside
Nikita Tsukanov
@kekekeks
Oct 13 2017 13:04
I guess we need some kind of "community extras" repo, that we can update before releases
And may be keep a branch that will be tracking our nightly builds
danwalmsley
@danwalmsley
Oct 13 2017 13:05
like a control pack
Nikita Tsukanov
@kekekeks
Oct 13 2017 13:05
Yep
That control pack probably needs a different release cycle
danwalmsley
@danwalmsley
Oct 13 2017 13:05
I think we can wait until after beta to do that though
Nikita Tsukanov
@kekekeks
Oct 13 2017 13:05
So it can be updated at faster pace
danwalmsley
@danwalmsley
Oct 13 2017 13:06
and then we can have control pack with these kinds of controls and themes, etc
Steven Kirk
@grokys
Oct 13 2017 13:10
yeah, i think that's the best solution, kind of a "Labs" repo
we can put stuff like @JurjenBiewenga's SlicedImage there too
danwalmsley
@danwalmsley
Oct 13 2017 13:11
@grokys even with the last commit
Steven Kirk
@grokys
Oct 13 2017 13:11
also does anyone actualyl use the HtmlRenderer?
danwalmsley
@danwalmsley
Oct 13 2017 13:11
_capturedSubscription = Observable.FromEventPattern<VisualTreeAttachmentEventArgs>(
                        x => value.DetachedFromVisualTree += x,
                        x => value.DetachedFromVisualTree -= x)
                        .Take(1)
                        .Subscribe(_ =>
                        {
                            Captured = null;
                        });
Captured=null still doesn't get called for me
Steven Kirk
@grokys
Oct 13 2017 13:11
hmm
danwalmsley
@danwalmsley
Oct 13 2017 13:11
it must be something breaking visual tree perhaps
Nikita Tsukanov
@kekekeks
Oct 13 2017 13:11
@grokys I think htmlrenderer can be moved to labs repo as well
I'm kinda planning to use it though
Steven Kirk
@grokys
Oct 13 2017 13:12
@danwalmsley ok, i'm going to have to take a deeper look then. does your control's OnDetachedFromVisualTree override get called?
danwalmsley
@danwalmsley
Oct 13 2017 13:13
I have a control that contains a normal buttons
and as far as I can tell I haven't overridden that
but I can override it and see if it does
2 secs
I'm going to merge master into that PR as the other fixes will help me test this, if that's ok?
on detached from visual tree is never getting called for my control
danwalmsley
@danwalmsley
Oct 13 2017 13:19
at least not before the exception happens
Steven Kirk
@grokys
Oct 13 2017 13:28
when the exception happens what's the control's IsAttachedToVisualTree value?
Nikita Tsukanov
@kekekeks
Oct 13 2017 13:29
Since it's explicitly checks for that property before throwing exception
I think it's false
It might have something to do with dispatcher priorities
event triggering with Background or something like that
BTW, I think we need to handle input events by passing them to dispatcher
Steven Kirk
@grokys
Oct 13 2017 13:30
ah, hold on, i made that change for logical tree, not visual tree
d'oh
danwalmsley
@danwalmsley
Oct 13 2017 13:41
is AdornerDecorator class equivalent of Adorner in WPF?
@danwalmsley @kekekeks ok, fixed the visual tree attach/detach events not getting called as well now
does that help?
danwalmsley
@danwalmsley
Oct 13 2017 14:20
Will try in 20mins
I'm out atm
Is there an adorner class?
Steven Kirk
@grokys
Oct 13 2017 14:23
no, you should just use standard controls
adorners in WPF are a pain because you can't do that easily, you need to render everything yourself
we could always add an Adorner control i guess though for compat
Jeremy Koritzinsky
@jkoritzinsky
Oct 13 2017 14:32
@grokys the X at that point comes from the fact that we never finished raising the AvaloniaPropertyChanged event for when we set A.Prop to X. We only did one of the callbacks, not both.
More so we only updated one binding. We never finished telling everyone we were changed to X before everyone was set to Y.
danwalmsley
@danwalmsley
Oct 13 2017 14:52
@grokys still no luck for this particular issue
Steven Kirk
@grokys
Oct 13 2017 15:12
i'm wondering if we should just return hittest == false for controls not attached to the visual tree
because if you can't see them you can't hit them after all
@jkoritzinsky ahhh ok. i understand now.
regarding never hitting a steady state i'm pretty sure WPF etc detect cycles in bindings and give up after a certain point
i wonder how WPF handles the first situation you documented?
Nikita Tsukanov
@kekekeks
Oct 13 2017 16:02

adorners in WPF are a pain because you can't do that easily, you need to render everything yourself

We need an article about that

danwalmsley
@danwalmsley
Oct 13 2017 16:03
@grokys @kekekeks what have I done wrong here:
 public class EditableTextBlock : TemplatedControl
    {
        private TextBox _textBox;

        public static readonly StyledProperty<string> TextProperty = AvaloniaProperty.Register<EditableTextBlock, string>(nameof(Text));

        public string Text
        {
            get { return GetValue(TextProperty); }
            set { SetValue(TextProperty, value); }
        }
<Styles  xmlns="https://github.com/avaloniaui" xmlns:cont="clr-namespace:AvalonStudio.Controls;assembly=AvalonStudio.Extensibility">
  <Style Selector="cont|EditableTextBlock">
    <Setter Property="BorderThickness" Value="0"/>
    <Setter Property="Padding" Value="0"/>
    <Setter Property="Template">
      <ControlTemplate>
        <Grid>
          <TextBlock Text="{TemplateBinding Text}" IsVisible="{TemplateBinding !InEditMode}" />
          <TextBox Text="{TemplateBinding Text}" IsVisible="{TemplateBinding InEditMode}" Name="PART_TextBox" />
        </Grid>
      </ControlTemplate>
    </Setter>
  </Style>
</Styles>
Matthijs ter Woord
@mterwoord
Oct 13 2017 16:04
what happens?
danwalmsley
@danwalmsley
Oct 13 2017 16:04
ok so I had expected that when the TextBox text is edited
that the textblock text would be bound to it and be the same
but I'm not seeing textblock text get updated
Matthijs ter Woord
@mterwoord
Oct 13 2017 16:05
is templatebinding twoway?
danwalmsley
@danwalmsley
Oct 13 2017 16:05
iv tried manually setting that
Matthijs ter Woord
@mterwoord
Oct 13 2017 16:05
does the value reach the TextProperty?
danwalmsley
@danwalmsley
Oct 13 2017 16:06
it just says LocalValue
in dev tools and doesn't get changed
Nikita Tsukanov
@kekekeks
Oct 13 2017 16:08
I think our values from styles or templates are treated as local ones
danwalmsley
@danwalmsley
Oct 13 2017 16:09
I'm not going mad though am I, the textblock and the textbox has its text properties bound together?
Nikita Tsukanov
@kekekeks
Oct 13 2017 16:20

i'm wondering if we should just return hittest == false for controls not attached to the visual tree

Might as well add a check to Captured getter, @grokys

Steven Kirk
@grokys
Oct 13 2017 16:54
@danwalmsley ok finally opened up avalonstudio to actually test what's causing the crash ;)
it's looking really nice!
however on master i'm getting
System.NullReferenceException occurred
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=<Cannot evaluate the exception source>
  StackTrace:
   at AvalonStudio.Controls.EditorViewModel.OnClose() in D:\projects\AvalonStudio\AvalonStudio\AvalonStudio\Controls\Editor\EditorViewModel.cs:line 115
   at AvalonStudio.Controls.DocumentTabViewModel`1.<.ctor>b__0_0() in D:\projects\AvalonStudio\AvalonStudio\AvalonStudio.Extensibility\Documents\GenericDocumentTabViewModel.cs:line 18
   at ReactiveUI.ReactiveCommand.<>c__DisplayClass0_0.<Create>b__1(IObserver`1 observer)
   at System.Reactive.AnonymousObservable`1.SubscribeCore(IObserver`1 observer)
   at System.Reactive.ObservableBase`1.Subscribe(IObserver`1 observer)
when trying to close a tab
also
System.NullReferenceException occurred
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=<Cannot evaluate the exception source>
  StackTrace:
   at AvalonStudio.Languages.CPlusPlus.CPlusPlusLanguageService.UnregisterSourceFile(TextEditor editor, ISourceFile file) in D:\projects\AvalonStudio\AvalonStudio\AvalonStudio.Languages.CPlusPlus\CPlusPlusLanguageService.cs:line 654
   at AvalonStudio.Controls.Standard.CodeEditor.CodeEditor.UnRegisterLanguageService() in D:\projects\AvalonStudio\AvalonStudio\AvalonStudio.Controls.Standard\CodeEditor\CodeEditor.cs:line 691
   at AvalonStudio.Controls.EditorView.Close() in D:\projects\AvalonStudio\AvalonStudio\AvalonStudio\Controls\EditorView.xaml.cs:line 108
   at AvalonStudio.Controls.EditorViewModel.OnClose() in D:\projects\AvalonStudio\AvalonStudio\AvalonStudio\Controls\Editor\EditorViewModel.cs:line 114
   at AvalonStudio.ShellViewModel.RemoveDocument(IDocumentTabViewModel document) in D:\projects\AvalonStudio\AvalonStudio\AvalonStudio\ShellViewModel.cs:line 452
   at AvalonStudio.Controls.DocumentTabViewModel`1.<.ctor>b__0_0() in D:\projects\AvalonStudio\AvalonStudio\AvalonStudio.Extensibility\Documents\GenericDocumentTabViewModel.cs:line 16
   at ReactiveUI.ReactiveCommand.<>c__DisplayClass0_0.<Create>b__1(IObserver`1 observer)
   at System.Reactive.AnonymousObservable`1.SubscribeCore(IObserver`1 observer)
   at System.Reactive.ObservableBase`1.Subscribe(IObserver`1 observer)
should i not be using master?
Steven Kirk
@grokys
Oct 13 2017 17:00
if i work around those problems i'm not able to repro https://github.com/AvaloniaUI/Avalonia/issues/1203#issuecomment-335196899
how do i repro?
Steven Kirk
@grokys
Oct 13 2017 17:11
ah, i think I might know what was causing it anyway, slightly different to what I thought. i've pushed a new fix to the branch, can you see if that fixes it @danwalmsley ?
danwalmsley
@danwalmsley
Oct 13 2017 17:36
Checkout implement-roslyn-workspaces branch
I'm going to test your fix now
danwalmsley
@danwalmsley
Oct 13 2017 17:49
actually develop branch is best option now
Jeremy Koritzinsky
@jkoritzinsky
Oct 13 2017 18:07

@grokys I've taken a look at how WPF does these types of bindings.

In the case of a steady state: it stops at the steady state.

In the case of no steady state: It uses the coerced values from each one.

It looks like it doesn't update bindings via their equivalent of AvaloniaPropertyChanged if the OldValue isn't equal to the previous value or something like that.
Jeremy Koritzinsky
@jkoritzinsky
Oct 13 2017 18:12
After a little more tracing, it looks like WPF updates the sources of bindings before the AvaloniaObject that was directly assigned.
danwalmsley
@danwalmsley
Oct 13 2017 18:45
@grokys confirmed, #1210 now fixes the issue
Darnell Williams
@Seeker1437
Oct 13 2017 18:49
@grokys I think I asked this before, but for some reason I can't find the answer, did we ever do more stuff with animation and if not, can what we do have handle keyframes and such?
Jeremy Koritzinsky
@jkoritzinsky
Oct 13 2017 19:07
We haven't gotten to animation yet
Jeremy Koritzinsky
@jkoritzinsky
Oct 13 2017 19:15
@grokys Any reason a binding set via the Bind extension method with the Binding class doesn't create a PriorityValueEntry, but a binding created via the indexer does? I'm trying to figure out how to fix the stackoverflow, and I'm hitting an issue with ActiveBindingIndex preventing the value from propogating up, which is only happening when we use the indexer to bind.
danwalmsley
@danwalmsley
Oct 13 2017 19:28
@grokys if you do get bored and checkout develop branch on as, if you press tools->options you can change the theme to light theme, and it will repro the dynamic resources bug that i haven't been able to work out
I added a review comment to #1210 too
Steven Kirk
@grokys
Oct 13 2017 19:44
@jkoritzinsky no, creating via Bind and the indexer should be the same
Jeremy Koritzinsky
@jkoritzinsky
Oct 13 2017 19:49
That's what confused me so much. They should act the same, but they aren't.
Maybe it's the use of Source on the Binding object that's causing the difference? I'm not sure.
Steven Kirk
@grokys
Oct 13 2017 20:11
hmm
i don't think that should make a difference
thing is, it all should go via BindingOperations.Apply in the end
which should call IAvaloniaObject.Bind
Jeremy Koritzinsky
@jkoritzinsky
Oct 13 2017 20:13
Maybe it's because of GetObservable?
Because there's definitely a difference in observable behavior between the two
Steven Kirk
@grokys
Oct 13 2017 20:15
is one a one-way binding and the other two-way?
[!Property] is one-way - [!!Property] is two way
Jeremy Koritzinsky
@jkoritzinsky
Oct 13 2017 20:17
They're both two-way.
Steven Kirk
@grokys
Oct 13 2017 20:19
ahh, you're using [~~Property] - we need to remove that
Jeremy Koritzinsky
@jkoritzinsky
Oct 13 2017 20:19
Even when I can get most of the changes showing up correctly, I still can't get the values to propogate back with the [!!Property] binding.
Steven Kirk
@grokys
Oct 13 2017 20:19
that binds the property with style priority
Jeremy Koritzinsky
@jkoritzinsky
Oct 13 2017 20:19
Not on the test I'm having issues with.
Steven Kirk
@grokys
Oct 13 2017 20:19
oh
Steven Kirk
@grokys
Oct 13 2017 20:20
ah ok, i was looking at the commented out code.
i can't take a look right now, but will take a look hopefully tomorrow morning if you don't get any further
i'd take a look there to try and work out what's different
danwalmsley
@danwalmsley
Oct 13 2017 21:24
@grokys if i capture the mouse, then press outside the control, should IsPointerover be true?
Steven Kirk
@grokys
Oct 13 2017 21:34
it shouldn't matter if you press or not, if the mouse is captured IsPointerOver should be true
danwalmsley
@danwalmsley
Oct 13 2017 21:45
I'm basically trying to work out how you detect when someone clicked outside your control
is was kind of thinking IsPointerOver was like a hittest
i.e. for editable textblock
double click goes into editing mode, you see textbox
and mouse is captured
then you click anywhere outside the control
I want to release capture and leave editing mode, just showing textblock
protected override void OnPointerPressed(PointerPressedEventArgs e)
        {
            base.OnPointerPressed(e);

            if (!InEditMode)
            {
                e.Device.Capture(this);

                if (e.MouseButton == MouseButton.Middle)
                {
                    InEditMode = true;
                }
                else if (e.ClickCount == 2)
                {
                    InEditMode = true;
                }
            }

            if(InEditMode && !IsPointerOver)
            {
                e.Device.Capture(null);

                InEditMode = false;                
            }
        }
so basically my question is what do I replace my IsPointerOver condition with, or is there a much better way to do this?
danwalmsley
@danwalmsley
Oct 13 2017 22:06
ok worked it out
else if (!new Rect(Bounds.Size).Contains(e.GetPosition(this)))
            {
                e.Device.Capture(null);

                InEditMode = false;
            }
shall I submit a PR for an extension method that does that?
ie. Control.Contains(Point)
or bool e.HitTest(this)
something like that?
Steven Kirk
@grokys
Oct 13 2017 23:14
it's not really a hit test though, it's testing if a point is within the controls bounds. so control.Bounds.Contains(point) seems like a decent way to express that
if you want to do a hit test you can do control.GetVisualsAt(point) - now maybe that should be called control.HitTest()
Steven Kirk
@grokys
Oct 13 2017 23:20
but that's not really the same thing