Example #1
0
        private void InternalSetContent(UIElement content)
        {
            if (_window == null)
            {
                _rootBorder = new Border();
                _popupRoot  = new PopupRoot();

                _window = new Grid
                {
                    IsVisualTreeRoot = true,
                    Children         =
                    {
                        _rootBorder,
                        _popupRoot
                        // Message Dialog => Those are currently using Popup, but they be upper
                        // Drag and drop => Those are added only when needed (they are actually not part of the WinUI visual tree and would have a negative perf impact)
                    }
                };

                UIElement.LoadingRootElement(_window);

                Compositor.RootVisual = _window.Visual;

                UIElement.RootElementLoaded(_window);
            }

            if (_rootBorder != null)
            {
                _rootBorder.Child = _content = content;
            }
        }
Example #2
0
        private void InternalSetContent(UIElement content)
        {
            if (_rootVisual == null)
            {
                _rootBorder = new Border();
                CoreServices.Instance.PutVisualRoot(_rootBorder);
                _rootVisual = CoreServices.Instance.MainRootVisual;

                if (_rootVisual == null)
                {
                    throw new InvalidOperationException("The root visual could not be created.");
                }

                CoreWindow.SetInvalidateRender(_rootVisual.XamlRoot.QueueInvalidateRender);

                UIElement.LoadingRootElement(_rootVisual);

                Compositor.RootVisual = _rootVisual.Visual;

                _rootVisual?.XamlRoot.InvalidateMeasure();

                UIElement.RootElementLoaded(_rootVisual);
            }

            if (_rootBorder != null)
            {
                _rootBorder.Child = _content = content;
            }
        }
Example #3
0
        private void InternalSetContent(UIElement content)
        {
            if (_window == null)
            {
                _rootBorder       = new Border();
                _rootScrollViewer = new ScrollViewer()
                {
                    VerticalScrollBarVisibility   = ScrollBarVisibility.Disabled,
                    HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
                    VerticalScrollMode            = ScrollMode.Disabled,
                    HorizontalScrollMode          = ScrollMode.Disabled,
                    Content = _rootBorder
                };
                _popupRoot       = new PopupRoot();
                FocusVisualLayer = new Canvas();
                _window          = new Grid()
                {
                    IsVisualTreeRoot = true,
                    Children         =
                    {
                        _rootScrollViewer,
                        _popupRoot,
                        FocusVisualLayer
                    }
                };
            }

            _rootBorder.Child = _content = content;
            if (content != null)
            {
                if (FeatureConfiguration.FrameworkElement.WasmUseManagedLoadedUnloaded && !_window.IsLoaded)
                {
                    UIElement.LoadingRootElement(_window);
                }

                WebAssemblyRuntime.InvokeJS($"Uno.UI.WindowManager.current.setRootContent({_window.HtmlId});");

                if (FeatureConfiguration.FrameworkElement.WasmUseManagedLoadedUnloaded && !_window.IsLoaded)
                {
                    UIElement.RootElementLoaded(_window);
                }
            }
            else
            {
                WebAssemblyRuntime.InvokeJS($"Uno.UI.WindowManager.current.setRootContent();");

                if (FeatureConfiguration.FrameworkElement.WasmUseManagedLoadedUnloaded && _window.IsLoaded)
                {
                    UIElement.RootElementUnloaded(_window);
                }
            }
        }
Example #4
0
        private void InternalSetContent(UIElement content)
        {
            if (_rootVisual == null)
            {
                _rootBorder       = new Border();
                _rootScrollViewer = new ScrollViewer()
                {
                    VerticalScrollBarVisibility   = ScrollBarVisibility.Disabled,
                    HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
                    VerticalScrollMode            = ScrollMode.Disabled,
                    HorizontalScrollMode          = ScrollMode.Disabled,
                    Content = _rootBorder
                };
                //TODO Uno: We can set and RootScrollViewer properly in case of WASM
                CoreServices.Instance.PutVisualRoot(_rootScrollViewer);
                _rootVisual = CoreServices.Instance.MainRootVisual;

                if (_rootVisual == null)
                {
                    throw new InvalidOperationException("The root visual could not be created.");
                }
            }

            _rootBorder.Child = _content = content;
            if (content != null)
            {
                if (FeatureConfiguration.FrameworkElement.WasmUseManagedLoadedUnloaded && !_rootVisual.IsLoaded)
                {
                    UIElement.LoadingRootElement(_rootVisual);
                }

                WebAssemblyRuntime.InvokeJS($"Uno.UI.WindowManager.current.setRootContent({_rootVisual.HtmlId});");

                if (FeatureConfiguration.FrameworkElement.WasmUseManagedLoadedUnloaded && !_rootVisual.IsLoaded)
                {
                    UIElement.RootElementLoaded(_rootVisual);
                }
            }
            else
            {
                WebAssemblyRuntime.InvokeJS($"Uno.UI.WindowManager.current.setRootContent();");

                if (FeatureConfiguration.FrameworkElement.WasmUseManagedLoadedUnloaded && _rootVisual.IsLoaded)
                {
                    UIElement.RootElementUnloaded(_rootVisual);
                }
            }

            UpdateRootAttributes();
        }
Example #5
0
        private void InternalSetContent(UIElement content)
        {
            if (_window == null)
            {
                _rootBorder = new Border();
                _popupRoot  = new PopupRoot();

                _window = new Grid
                {
                    Children = { _rootBorder, _popupRoot }
                };

                UIElement.LoadingRootElement(_window);

                Compositor.RootVisual = _window.Visual;

                UIElement.RootElementLoaded(_window);
            }

            if (_rootBorder != null)
            {
                _rootBorder.Child = _content = content;
            }
        }
Example #6
0
        private void InternalSetContent(UIElement value)
        {
            if (_rootVisual == null)
            {
                _rootBorder = new Border();
                var coreServices = Uno.UI.Xaml.Core.CoreServices.Instance;
                coreServices.PutVisualRoot(_rootBorder);
                _rootVisual = coreServices.MainRootVisual;

                if (_rootVisual == null)
                {
                    throw new InvalidOperationException("The root visual could not be created.");
                }

                UIElement.LoadingRootElement(_rootVisual);

                _mainController.View         = _rootVisual;
                _rootVisual.Frame            = _window.Frame;
                _rootVisual.AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable;

                UIElement.RootElementLoaded(_rootVisual);
            }

            _rootBorder.Child?.RemoveFromSuperview();
            _rootBorder.Child = _content = value;

            // This is required to get the mouse move while not pressed!
            var options = NSTrackingAreaOptions.MouseEnteredAndExited
                          | NSTrackingAreaOptions.MouseMoved
                          | NSTrackingAreaOptions.ActiveInKeyWindow
                          | NSTrackingAreaOptions.EnabledDuringMouseDrag // We want enter/leave events even if the button is pressed
                          | NSTrackingAreaOptions.InVisibleRect;         // Automagicaly syncs the bounds rect
            var trackingArea = new NSTrackingArea(Bounds, options, _rootVisual, null);

            _rootVisual.AddTrackingArea(trackingArea);
        }