Skip to content

Commit

Permalink
[ImGui] Fixes regressions in input handling introduced with merge of #…
Browse files Browse the repository at this point in the history
…667 (7899b16)

This commit breaks the SkiaStrideInputHandling help patch, but existing patches like Kairos Compositor work again. For now this is the better trade off.
  • Loading branch information
azeno committed Apr 10, 2024
1 parent 121cecd commit 88a2174
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
16 changes: 11 additions & 5 deletions VL.ImGui.Skia/src/SkiaWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,26 @@ protected override void Draw(Context context, in ImDrawListPtr drawList, in Syst

// Use Callback instead of Texture to pass Layer ID ... first Layer has ID 1
var id = skiaContext.AddLayer(this, pos, size);

// Why is this no longer necessary?
//if (context.DrawList == DrawList.AtCursor)
// ImGui.Image(0, size);

drawList.AddCallback(id, IntPtr.Zero);
}
}

[Pin(Ignore = true)]
public RectangleF? Bounds => !_disposed ? Layer?.Bounds : default;

SKMatrix? trans;
// What is this for?
//SKMatrix? trans;

public void Render(CallerInfo caller)
{
if (_disposed || Layer is null)
return;
trans = caller.Transformation;
//trans = caller.Transformation;
Layer.Render(caller);
}

Expand All @@ -77,9 +83,9 @@ public bool Notify(INotification notification, CallerInfo caller)
return false;


if (trans != null)
return Layer.Notify(notification, caller.WithTransformation((SKMatrix)trans));
else
//if (trans != null)
// return Layer.Notify(notification, caller.WithTransformation((SKMatrix)trans));
//else
return Layer.Notify(notification, caller); ;
}

Expand Down
2 changes: 1 addition & 1 deletion VL.ImGui.Skia/src/ToSkiaLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public bool Notify(INotification notification, CallerInfo caller)
{
using (_context.MakeCurrent())
{
_io.HandleNotification(notification);
_io.HandleNotification(notification, useWorldSpace: true);

foreach (var layer in _context.Layers)
{
Expand Down
2 changes: 1 addition & 1 deletion VL.ImGui.Stride/src/ImGuiRenderer.InputHandling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ IDisposable SubscribeToInputSource(IInputSource inputSource, RenderDrawContext c
{
using (_context.MakeCurrent())
{
_io.HandleNotification(notification);
_io.HandleNotification(notification, useWorldSpace: false);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions VL.ImGui/src/Helper/RenderHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static unsafe void UpdateUIScaling(float scaling = 1f)
//style.ScaleAllSizes(scale);
}

public static void HandleNotification(this ImGuiIOPtr _io ,INotification notification)
public static void HandleNotification(this ImGuiIOPtr _io, INotification notification, bool useWorldSpace /* HACK - breaks LayerWidget*/)
{
if (notification is KeyNotification keyNotification)
{
Expand Down Expand Up @@ -73,7 +73,7 @@ public static void HandleNotification(this ImGuiIOPtr _io ,INotification notific
}

// The up & down event methods don't take the position as an argument. Therefor make sure it's present, or we end up with wrong clicks when using touch devices.
var pos = mouseNotification.Position;
var pos = useWorldSpace ? mouseNotification.PositionInWorldSpace.FromHectoToImGui() : mouseNotification.Position.ToImGui();
_io.AddMousePosEvent(pos.X, pos.Y);

switch (mouseNotification.Kind)
Expand Down

0 comments on commit 88a2174

Please sign in to comment.