Page 10 of 14

Re: BETA: NoesisGUI v2.1.0rc2

Posted: 26 Jan 2018, 05:50
by nokola
hmm...hitting again an issue with VisualTreeHelper.HitTest and this time no very good workaround, like I did before where I had a UserControl and I set the Background to null.

For the following XAML:
<Canvas x:Class="FantasiaPhone.TargetPick"
xmlns="http://schemas.microsoft.com/winfx/2006 ... esentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Rectangle Fill="#B0000000" Width="32" Height="32" Canvas.Top="-16" Canvas.Left="-16" IsHitTestVisible="False"/>
<Line X1="100" Y1="84" X2="100" Y2="115" Stroke="#FFFFFFFF" Width="200" Height="200" Canvas.Left="-100" Canvas.Top="-100" />
<Line X1="84" Y1="100" X2="115" Y2="100" Stroke="#FFFFFFFF" Width="200" Height="200" Canvas.Left="-100" Canvas.Top="-100" />

<Line X1="100" Y1="0" X2="100" Y2="200" Stroke="White" Width="200" Height="200" Canvas.Left="-100" Canvas.Top="-100"
x:Name="line1" Visibility="Collapsed"/>
<Line X1="0" Y1="100" X2="200" Y2="100" Stroke="White" Width="200" Height="200" Canvas.Left="-100" Canvas.Top="-100"
x:Name="line2" Visibility="Collapsed"/>
<TextBlock Foreground="White" Canvas.Left="4" FontSize="11" x:Name="text" />
</Canvas>

I get a hit test result on the Rectangle above. VisualTreeHelper.HitTest() in Noesis also does *not* have the WPF overload that allows a workaround (see https://social.msdn.microsoft.com/Forum ... ?forum=wpf)

What do you think of just fixing the Noesis HitTest to behave as intended and take into account IsHitTestVisible (which is different than WPF?)

Re: BETA: NoesisGUI v2.1.0rc2

Posted: 26 Jan 2018, 06:51
by ai_enabled
I agree that HitTestFilter callback might be useful.
Meanwhile, we're using something like that to workaround the issue:
        public static bool HitTest(Visual fromVisual, Point fromPoint)
        {
            var visual = VisualTreeHelper.HitTest(fromVisual, fromPoint)
                                         .VisualHit as FrameworkElement;
            while (visual != null)
            {
                if (visual.IsHitTestVisible)
                {
                    // hit test successful
                    return true;
                }

                // travel up
                visual = visual.Parent ?? VisualTreeHelper.GetParent(visual) as FrameworkElement;
            }

            return false;
        }
I don't recall why I've added "as FrameworkElement" everywhere :-) .
UPD. You can also use VisualTreeHelper.HitTest() with new Visual on every iteration and then return this Visual if it has IsHitTestVisible.
We just needed to know if we had a hit on visual element (to consume game input; i.e. input was intercepted by UI) or not.

Re: BETA: NoesisGUI v2.1.0rc2

Posted: 26 Jan 2018, 17:05
by nokola
Thanks! Unfortunately, going to parent won't account for the case when we have the child outside of parent (e.g. 0-sized canvas), which is a common case if you want to render on exact pixel coords.

Re: BETA: NoesisGUI v2.1.0rc2

Posted: 26 Jan 2018, 18:49
by ai_enabled
@nokola, I never thought about this case. I think it should not be hard for the Noesis team to just add a simple flag which will avoid returning elements with IsHitTestVisible==false. Full delegate approach as in WPF will be much harder to implement due to C#-to-C++ interop... and I really can't see a good use case for it. A simple HitTest overload with the simple Boolean flag will be more than enough for most cases.

@jsantos, @sfernandez,
I've reported a random crash issue, please check the crash dump from #1227.

Re: BETA: NoesisGUI v2.1.0rc2

Posted: 26 Jan 2018, 19:41
by Wanderer
1. Which version of Blend can I use for Noesis? I have VS 2015, it is ok?

2. I never used Blend before, can I create themes in Blend and use it in Noesis?

Re: BETA: NoesisGUI v2.1.0rc2

Posted: 27 Jan 2018, 02:33
by nokola
re: HitTest, added ai_enabled's suggestion (good one) to the bug I have opened previously for HitTesting - http://www.noesisengine.com/bugs/view.php?id=1222
Would be best indeed to have extra overload to allow circumventing WPF's problematic behavior.

Edit: Update on the other jittery scrolling issue: as I suspected wasn't due to Noesis. We fixed the jittery scrolling on our side.

Re: BETA: NoesisGUI v2.1.0rc2

Posted: 29 Jan 2018, 10:45
by ivan_b
Hi,

I noticed that the loading time for a UserControl in noesis 2.x are much higher then for 1.x.
I would like to know if there is a mechanism to load and parse the xaml in memory and then use the in memory xaml to create a UserControl?

Re: BETA: NoesisGUI v2.1.0rc2

Posted: 29 Jan 2018, 12:28
by ai_enabled
@ivan_b, have you actually checked with the profiler? In our case, v2.x vs v1.x controls loading speed is much faster.
At the time I asked the same question (it's called 1.3 beta then and the NoesisGUI team decided to drop XAML-to-binary compiler completely) and they responded to me that their native XAML parser now is much faster than previous (compiled binary XAML) loader.

Re: BETA: NoesisGUI v2.1.0rc2

Posted: 29 Jan 2018, 14:03
by ivan_b
@ai_enabled
I have checked the profiler and it says that the problem is in noesis, the frame drops to 15 fps on my PC.
The problem is on the iPad when you see the animation freeze, even with some simple views.
That is the reason I have changed my code to never instantiate new UserControls, the problem with this approach is that the memory usage is much higher.

Re: BETA: NoesisGUI v2.1.0rc2

Posted: 29 Jan 2018, 14:35
by sfernandez
@nokola, I never thought about this case. I think it should not be hard for the Noesis team to just add a simple flag which will avoid returning elements with IsHitTestVisible==false. Full delegate approach as in WPF will be much harder to implement due to C#-to-C++ interop... and I really can't see a good use case for it. A simple HitTest overload with the simple Boolean flag will be more than enough for most cases.
We think that the correct approach is to implement the callback version of HitTest function.
@jsantos, @sfernandez,
I've reported a random crash issue, please check the crash dump from #1227.
Thanks, I answered the ticket.