csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.0 KiB
64 lines
2.0 KiB
using System;
|
|
using Avalonia.Controls.Primitives.PopupPositioning;
|
|
using Avalonia.Native.Interop;
|
|
using Avalonia.Platform;
|
|
|
|
namespace Avalonia.Native
|
|
{
|
|
class PopupImpl : WindowBaseImpl, IPopupImpl
|
|
{
|
|
private readonly IAvaloniaNativeFactory _factory;
|
|
private readonly AvaloniaNativePlatformOptions _opts;
|
|
private readonly GlPlatformFeature _glFeature;
|
|
|
|
public PopupImpl(IAvaloniaNativeFactory factory,
|
|
AvaloniaNativePlatformOptions opts,
|
|
GlPlatformFeature glFeature,
|
|
IWindowBaseImpl parent) : base(opts, glFeature)
|
|
{
|
|
_factory = factory;
|
|
_opts = opts;
|
|
_glFeature = glFeature;
|
|
using (var e = new PopupEvents(this))
|
|
{
|
|
var context = _opts.UseGpu ? glFeature?.DeferredContext : null;
|
|
Init(factory.CreatePopup(e, context?.Context), factory.CreateScreens(), context);
|
|
}
|
|
PopupPositioner = new ManagedPopupPositioner(new OsxManagedPopupPositionerPopupImplHelper(parent, MoveResize));
|
|
}
|
|
|
|
private void MoveResize(PixelPoint position, Size size, double scaling)
|
|
{
|
|
Position = position;
|
|
Resize(size);
|
|
//TODO: We ignore the scaling override for now
|
|
}
|
|
|
|
class PopupEvents : WindowBaseEvents, IAvnWindowEvents
|
|
{
|
|
readonly PopupImpl _parent;
|
|
|
|
public PopupEvents(PopupImpl parent) : base(parent)
|
|
{
|
|
_parent = parent;
|
|
}
|
|
|
|
public void GotInputWhenDisabled()
|
|
{
|
|
// NOP on Popup
|
|
}
|
|
|
|
bool IAvnWindowEvents.Closing()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
void IAvnWindowEvents.WindowStateChanged(AvnWindowState state)
|
|
{
|
|
}
|
|
}
|
|
|
|
public override IPopupImpl CreatePopup() => new PopupImpl(_factory, _opts, _glFeature, this);
|
|
public IPopupPositioner PopupPositioner { get; }
|
|
}
|
|
}
|
|
|