feat(D.2b): Slice 2 — UiViewport widget (dat Type 0xD) + IUiViewportRenderer seam
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
10cb31223f
commit
ebcdf44c0c
4 changed files with 72 additions and 6 deletions
25
src/AcDream.App/UI/UiViewport.cs
Normal file
25
src/AcDream.App/UI/UiViewport.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System.Numerics;
|
||||
|
||||
namespace AcDream.App.UI;
|
||||
|
||||
/// <summary>Leaf widget for dat Type 0xD (UIElement_Viewport). Blits the texture produced by its
|
||||
/// IUiViewportRenderer (run in the pre-UI hook) as a single sprite at its own rect. The 3-D render
|
||||
/// does NOT happen here (OnDraw only has a 2-D context).</summary>
|
||||
public sealed class UiViewport : UiElement
|
||||
{
|
||||
public override bool ConsumesDatChildren => true;
|
||||
|
||||
/// <summary>Renderer that produces the off-screen texture. Set by GameWindow wiring (later task).</summary>
|
||||
public IUiViewportRenderer? Renderer { get; set; }
|
||||
|
||||
/// <summary>Last GL color-texture handle produced by the pre-UI hook. 0 = nothing to blit.</summary>
|
||||
public uint TextureHandle { get; set; }
|
||||
|
||||
protected override void OnDraw(UiRenderContext ctx)
|
||||
{
|
||||
if (!Visible || TextureHandle == 0) return;
|
||||
// Local origin is already at this widget's Left/Top (PushTransform applied by DrawSelfAndChildren).
|
||||
// Draw the full-texture sprite with UV 0..1 and white tint (no color modulation).
|
||||
ctx.DrawSprite(TextureHandle, 0f, 0f, Width, Height, 0f, 0f, 1f, 1f, Vector4.One);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue