public Renderer(IRenderRoot root, IRenderLoop renderLoop) { Contract.Requires<ArgumentNullException>(root != null); _root = root; _renderLoop = renderLoop; _renderLoop.Tick += OnRenderLoopTick; }
/// <summary> /// Initializes a new instance of the <see cref="DeferredRenderer"/> class. /// </summary> /// <param name="root">The control to render.</param> /// <param name="renderLoop">The render loop.</param> /// <param name="sceneBuilder">The scene builder to use. Optional.</param> /// <param name="layerFactory">The layer factory to use. Optional.</param> /// <param name="dispatcher">The dispatcher to use. Optional.</param> public DeferredRenderer( IRenderRoot root, IRenderLoop renderLoop, ISceneBuilder sceneBuilder = null, IRenderLayerFactory layerFactory = null, IDispatcher dispatcher = null) { Contract.Requires <ArgumentNullException>(root != null); _dispatcher = dispatcher ?? Dispatcher.UIThread; _root = root; _sceneBuilder = sceneBuilder ?? new SceneBuilder(); _scene = new Scene(root); _layerFactory = layerFactory ?? new DefaultRenderLayerFactory(); _layers = new RenderLayers(_layerFactory); _renderLoop = renderLoop; }
/// <summary> /// Initializes a new instance of the <see cref="DeferredRenderer"/> class. /// </summary> /// <param name="root">The control to render.</param> /// <param name="renderLoop">The render loop.</param> /// <param name="sceneBuilder">The scene builder to use. Optional.</param> /// <param name="dispatcher">The dispatcher to use. Optional.</param> /// <param name="rendererLock">Lock object used before trying to access render target</param> public DeferredRenderer( IRenderRoot root, IRenderLoop renderLoop, ISceneBuilder sceneBuilder = null, IDispatcher dispatcher = null, IDeferredRendererLock rendererLock = null) : base(true) { Contract.Requires <ArgumentNullException>(root != null); _dispatcher = dispatcher ?? Dispatcher.UIThread; _root = root; _sceneBuilder = sceneBuilder ?? new SceneBuilder(); Layers = new RenderLayers(); _renderLoop = renderLoop; _lock = rendererLock ?? new ManagedDeferredRendererLock(); _updateSceneIfNeededDelegate = UpdateSceneIfNeeded; }
/// <inheritdoc/> protected override void OnAttachedToVisualTree(IRenderRoot root) { base.OnAttachedToVisualTree(root); if (this.GetVisualParent() != null) { _treeView = this.GetVisualAncestors().OfType<TreeView>().FirstOrDefault(); if (_treeView == null) { throw new InvalidOperationException("TreeViewItems must be added to a TreeView."); } } else { _treeView = null; } }
/// <inheritdoc/> protected override void OnAttachedToVisualTree(IRenderRoot root) { base.OnAttachedToVisualTree(root); if (this.GetVisualParent() != null) { _treeView = this.GetVisualAncestors().OfType <TreeView>().FirstOrDefault(); if (_treeView == null) { throw new InvalidOperationException("TreeViewItems must be added to a TreeView."); } } else { _treeView = null; } }
/// <summary> /// Calls the <see cref="OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)"/> method /// for this control and all of its visual descendents. /// </summary> /// <param name="e">The event args.</param> protected virtual void OnDetachedFromVisualTreeCore(VisualTreeAttachmentEventArgs e) { Logger.Verbose(LogArea.Visual, this, "Detached from visual tree"); VisualRoot = null; if (RenderTransform != null) { RenderTransform.Changed -= RenderTransformChanged; } OnDetachedFromVisualTree(e); if (VisualChildren != null) { foreach (Visual child in VisualChildren.OfType <Visual>()) { child.OnDetachedFromVisualTreeCore(e); } } }
/// <summary> /// Calls the <see cref="OnAttachedToVisualTree(VisualTreeAttachmentEventArgs)"/> method /// for this control and all of its visual descendents. /// </summary> /// <param name="e">The event args.</param> protected virtual void OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs e) { Logger.Verbose(LogArea.Visual, this, "Attached to visual tree"); _visualRoot = e.Root; if (RenderTransform != null) { RenderTransform.Changed += RenderTransformChanged; } OnAttachedToVisualTree(e); InvalidateVisual(); if (VisualChildren != null) { foreach (Visual child in VisualChildren.OfType <Visual>()) { child.OnAttachedToVisualTreeCore(e); } } }
/// <summary> /// Calls the <see cref="OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)"/> method /// for this control and all of its visual descendants. /// </summary> /// <param name="e">The event args.</param> protected virtual void OnDetachedFromVisualTreeCore(VisualTreeAttachmentEventArgs e) { Logger.TryGet(LogEventLevel.Verbose)?.Log(LogArea.Visual, this, "Detached from visual tree"); _visualRoot = null; if (RenderTransform != null) { RenderTransform.Changed -= RenderTransformChanged; } OnDetachedFromVisualTree(e); DetachedFromVisualTree?.Invoke(this, e); e.Root?.Renderer?.AddDirty(this); if (VisualChildren != null) { foreach (Visual child in VisualChildren.OfType <Visual>()) { child.OnDetachedFromVisualTreeCore(e); } } }
/// <summary> /// Called when the <see cref="MenuItem"/> is attached to the visual tree. /// </summary> /// <param name="root">The root of the visual tree.</param> protected override void OnAttachedToVisualTree(IRenderRoot root) { base.OnAttachedToVisualTree(root); var topLevel = root as TopLevel; topLevel.Deactivated += Deactivated; var pointerPress = topLevel.AddHandler( PointerPressedEvent, TopLevelPreviewPointerPress, RoutingStrategies.Tunnel); _subscription = new CompositeDisposable( pointerPress, Disposable.Create(() => topLevel.Deactivated -= Deactivated)); var inputRoot = root as IInputRoot; if (inputRoot != null && inputRoot.AccessKeyHandler != null) { inputRoot.AccessKeyHandler.MainMenu = this; } }
/// <inheritdoc/> protected override void OnDetachedFromVisualTree(IRenderRoot oldRoot) { base.OnDetachedFromVisualTree(oldRoot); if (this.IsDefault) { var inputElement = oldRoot as IInputElement; if (inputElement != null) { this.StopListeningForDefault(inputElement); } } }
public IRenderer CreateRenderer(IRenderRoot root, IRenderLoop renderLoop) { return(new Renderer(root, renderLoop)); }
/// <summary> /// Initializes a new instance of the <see cref="VisualTreeAttachmentEventArgs"/> class. /// </summary> /// <param name="parent">The parent that the visual is being attached to or detached from.</param> /// <param name="root">The root visual.</param> public VisualTreeAttachmentEventArgs(IVisual parent, IRenderRoot root) { Parent = parent ?? throw new ArgumentNullException(nameof(parent)); Root = root ?? throw new ArgumentNullException(nameof(root)); }
public DeferredRendererProxy(IRenderRoot root) { _renderer = new DeferredRenderer(root, this); _rendererTask = (IRenderLoopTask)_renderer; }
/// <summary> /// Initializes a new instance of the <see cref="VisualTreeAttachmentEventArgs"/> class. /// </summary> /// <param name="root">The root visual.</param> public VisualTreeAttachmentEventArgs(IRenderRoot root) { Root = root; }
protected virtual void OnAttachedToVisualTree(IRenderRoot root) { }
/// <summary> /// Called when the control is removed to the visual tree. /// </summary> /// <param name="root">THe root of the visual tree.</param> protected override void OnDetachedFromVisualTree(IRenderRoot root) { base.OnDetachedFromVisualTree(root); _topLevel = null; }
/// <summary> /// Called when the control is attached to a visual tree. /// </summary> /// <param name="root">The root of the visual tree.</param> protected override void OnAttachedToVisualTree(IRenderRoot root) { base.OnAttachedToVisualTree(root); _accessKeys = (root as IInputRoot)?.AccessKeyHandler; if (_accessKeys != null && AccessKey != 0) { _accessKeys.Register(AccessKey, this); } }
public IRenderer CreateRenderer(IRenderRoot root, IRenderLoop renderLoop) { return(_cb?.Invoke(root, renderLoop)); }
/// <summary> /// Initializes a new instance of the <see cref="VisualTreeAttachmentEventArgs"/> class. /// </summary> /// <param name="root">The root visual.</param> /// <param name="nameScope">The name scope.</param> public VisualTreeAttachmentEventArgs(IRenderRoot root, INameScope nameScope) { Root = root; NameScope = nameScope; }
/// <summary> /// Initializes a new instance of the <see cref="VisualTreeAttachmentEventArgs"/> class. /// </summary> /// <param name="root">The root visual.</param> public VisualTreeAttachmentEventArgs(IRenderRoot root) { Contract.Requires <ArgumentNullException>(root != null); Root = root; }
public IRenderer Create(IRenderRoot root, IRenderLoop renderLoop) => new ImmediateRenderer(root);
/// <inheritdoc/> protected override void OnAttachedToVisualTree(IRenderRoot root) { base.OnAttachedToVisualTree(root); _treeView = this.GetVisualAncestors().OfType<TreeView>().FirstOrDefault(); }
public IRenderer CreateRenderer(IRenderRoot root) => AvaloniaHeadlessPlatform.Compositor != null ? new CompositingRenderer(root, AvaloniaHeadlessPlatform.Compositor) : new DeferredRenderer(root, AvaloniaLocator.Current.GetRequiredService <IRenderLoop>());
/// <inheritdoc/> protected override void OnAttachedToVisualTree(IRenderRoot root) { base.OnAttachedToVisualTree(root); this.UpdateIsEnabledCore(); }
public IRenderer CreateRenderer(IRenderRoot root) { return(new DeferredRenderer(root, AvaloniaLocator.Current.GetService <IRenderLoop>()) { }); }
protected override void OnAttachedToVisualTree(IRenderRoot root) { base.OnAttachedToVisualTree(root); _grid = this.GetVisualParent <Grid>(); }
protected override void OnAttachedToVisualTree(IRenderRoot root) { IStyler styler = Locator.Current.GetService <IStyler>(); styler.ApplyStyles(this); }
protected virtual void OnDetachedFromVisualTree(IRenderRoot oldRoot) { }
/// <summary> /// Calls the <see cref="OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)"/> method /// for this control and all of its visual descendents. /// </summary> /// <param name="e">The event args.</param> protected virtual void OnDetachedFromVisualTreeCore(VisualTreeAttachmentEventArgs e) { Logger.Verbose(LogArea.Visual, this, "Detached from visual tree"); VisualRoot = null; if (RenderTransform != null) { RenderTransform.Changed -= RenderTransformChanged; } OnDetachedFromVisualTree(e); if (VisualChildren != null) { foreach (Visual child in VisualChildren.OfType<Visual>()) { child.OnDetachedFromVisualTreeCore(e); } } }
/// <summary> /// Called when the <see cref="Menu"/> is detached from the visual tree. /// </summary> /// <param name="oldRoot">The root of the visual tree being detached from.</param> protected override void OnDetachedFromVisualTree(IRenderRoot oldRoot) { base.OnDetachedFromVisualTree(oldRoot); _subscription.Dispose(); }
/// <summary> /// Calls the <see cref="OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)"/> method /// for this control and all of its visual descendents. /// </summary> /// <param name="e">The event args.</param> private void NotifyDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) { _visualLogger.Verbose("Detached from visual tree"); VisualRoot = null; OnDetachedFromVisualTree(e); if (VisualChildren != null) { foreach (Visual child in VisualChildren.OfType<Visual>()) { child.NotifyDetachedFromVisualTree(e); } } }
/// <summary> /// Called when the control is detached from a visual tree. /// </summary> /// <param name="root">The root of the visual tree.</param> protected override void OnDetachedFromVisualTree(IRenderRoot root) { base.OnDetachedFromVisualTree(root); if (_accessKeys != null && AccessKey != 0) { _accessKeys.Unregister(this); _accessKeys = null; } }
/// <summary> /// Initializes a new instance of the <see cref="VisualTreeAttachmentEventArgs"/> class. /// </summary> /// <param name="root">The root visual.</param> public VisualTreeAttachmentEventArgs(IRenderRoot root) { Contract.Requires<ArgumentNullException>(root != null); Root = root; }
/// <summary> /// Called when the control is added to the visual tree. /// </summary> /// <param name="root">THe root of the visual tree.</param> protected override void OnAttachedToVisualTree(IRenderRoot root) { base.OnAttachedToVisualTree(root); _topLevel = root as TopLevel; }
protected override void OnAttachedToVisualTree(IRenderRoot root) { base.OnAttachedToVisualTree(root); _grid = this.GetVisualParent<Grid>(); }
/// <inheritdoc/> protected override void OnAttachedToVisualTree(IRenderRoot root) { base.OnAttachedToVisualTree(root); _treeView = this.GetVisualAncestors().OfType <TreeView>().FirstOrDefault(); }
/// <inheritdoc/> protected override void OnAttachedToVisualTree(IRenderRoot root) { base.OnAttachedToVisualTree(root); UpdateIsEnabledCore(); }
public IRenderer CreateRenderer(IRenderRoot root) { return(Renderer = new CompositingRenderer(root, _compositor)); }
/// <summary> /// Called when the <see cref="MenuItem"/> is attached to the visual tree. /// </summary> /// <param name="root">The root of the visual tree.</param> protected override void OnAttachedToVisualTree(IRenderRoot root) { base.OnAttachedToVisualTree(root); var topLevel = root as TopLevel; topLevel.Deactivated += this.Deactivated; var pointerPress = topLevel.AddHandler( InputElement.PointerPressedEvent, this.TopLevelPreviewPointerPress, RoutingStrategies.Tunnel); this.subscription = new CompositeDisposable( pointerPress, Disposable.Create(() => topLevel.Deactivated -= this.Deactivated)); var inputRoot = root as IInputRoot; if (inputRoot != null && inputRoot.AccessKeyHandler != null) { inputRoot.AccessKeyHandler.MainMenu = this; } }
/// <summary> /// Calls the <see cref="OnAttachedToVisualTree(VisualTreeAttachmentEventArgs)"/> method /// for this control and all of its visual descendents. /// </summary> /// <param name="e">The event args.</param> private void NotifyAttachedToVisualTree(VisualTreeAttachmentEventArgs e) { _visualLogger.Verbose("Attached to visual tree"); VisualRoot = e.Root; OnAttachedToVisualTree(e); if (VisualChildren != null) { foreach (Visual child in VisualChildren.OfType<Visual>()) { child.NotifyAttachedToVisualTree(e); } } }
/// <summary> /// Called when the <see cref="Menu"/> is detached from the visual tree. /// </summary> /// <param name="oldRoot">The root of the visual tree being detached from.</param> protected override void OnDetachedFromVisualTree(IRenderRoot oldRoot) { base.OnDetachedFromVisualTree(oldRoot); this.subscription.Dispose(); }
public IRenderer CreateRenderer(IRenderRoot root) => new ImmediateRenderer(root);
/// <summary> /// Called when the control is added to a visual tree. /// </summary> /// <param name="root">The root of the visual tree.</param> protected virtual void OnAttachedToVisualTree(IRenderRoot root) { }
/// <inheritdoc/> protected override void OnAttachedToVisualTree(IRenderRoot root) { base.OnAttachedToVisualTree(root); if (this.IsDefault) { var inputElement = root as IInputElement; if (inputElement != null) { this.ListenForDefault(inputElement); } } }
/// <summary> /// Called when the control is removed from a visual tree. /// </summary> /// <param name="root">The root of the visual tree.</param> protected virtual void OnDetachedFromVisualTree(IRenderRoot root) { }
public IRenderer CreateRenderer(IRenderRoot root, IRenderLoop renderLoop) { return new Renderer(root, renderLoop); }
/// <summary> /// Calls the <see cref="OnAttachedToVisualTree(IRenderRoot)"/> method for this control /// and all of its visual descendents. /// </summary> /// <param name="root">The root of the visual tree.</param> private void NotifyAttachedToVisualTree(IRenderRoot root) { this.visualLogger.Verbose("Attached to visual tree"); this.isAttachedToVisualTree = true; this.OnAttachedToVisualTree(root); if (this.visualChildren != null) { foreach (Visual child in this.visualChildren.OfType<Visual>()) { child.NotifyAttachedToVisualTree(root); } } }
/// <inheritdoc/> protected override void OnDetachedFromVisualTree(IRenderRoot oldRoot) { base.OnDetachedFromVisualTree(oldRoot); if (this.IsFocused) { FocusManager.Instance.Focus(null); } }
/// <summary> /// Calls the <see cref="OnDetachedFromVisualTree(IRenderRoot)"/> method for this control /// and all of its visual descendents. /// </summary> /// <param name="root">The root of the visual tree.</param> private void NotifyDetachedFromVisualTree(IRenderRoot root) { this.visualLogger.Verbose("Detached from visual tree"); this.isAttachedToVisualTree = false; this.OnDetachedFromVisualTree(root); if (this.visualChildren != null) { foreach (Visual child in this.visualChildren.OfType<Visual>()) { child.NotifyDetachedFromVisualTree(root); } } }
public IRenderer CreateRenderer(IRenderRoot root) { return(new ImmediateRenderer(root)); }
private ImmediateRenderer(IVisual root, bool updateTransformedBounds) { _root = root ?? throw new ArgumentNullException(nameof(root)); _renderRoot = root as IRenderRoot; _updateTransformedBounds = updateTransformedBounds; }