-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[VL.ImGui.Stride.Viewports] #673
base: main
Are you sure you want to change the base?
[VL.ImGui.Stride.Viewports] #673
Conversation
…Gui.Stride.InputSource
…Gui.Stride.InputSource
…Gui.Stride.Viewports
…Gui.Stride.Viewports
known issues: InputHandling need to be checked Didn't work after restart F9 some bugs need to be found
…Gui.Stride.Viewports
maybe fixed SkiaWidget
Remove unused RenderView from RenderWidget ... is now done in vl ClenUp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this huge effort and sorry that it took a while to give it a spin. I left some comments in code.
Was testing a little bit with your demo patch and once you start moving windows out and back in again the input handling seems to fall apart at some point. From the help patch drag out (to the right) the StrideSceneWithInput, it still works. Now move it back in, it stops interacting.
VL.ImGui.Skia/src/SkiaWidget.cs
Outdated
@@ -60,13 +63,14 @@ protected override void Draw(Context context, in ImDrawListPtr drawList, in Syst | |||
public RectangleF? Bounds => !_disposed ? Layer?.Bounds : default; | |||
|
|||
// What is this for? | |||
//SKMatrix? trans; | |||
// it is somehow necessary for the Stride/Skia inputHandleing to work ... is a strange workaround |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm ok, can you point to a patch where these lines of code do make a difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the CallerInfo in Notify has the wrong transformation ... The CallerInfo in Render has the correct ... just set a breakpoint in Notify ... then you can see it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting - so this might be a bug in the Stride-Skia bridge then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, probably that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will have a look..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pushed a fix for the SkiaRenderer
- like you say, it was indeed broken, as one could see with the Stride/Skia overlay help patch. Using a Skia Button there didn't work. Thanks for the pointer. You should be able to remove that above hack now.
// 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 = useWorldSpace ? mouseNotification.PositionInWorldSpace.FromHectoToImGui() : mouseNotification.Position.ToImGui(); | ||
_io.AddMousePosEvent(pos.X, pos.Y); | ||
var flag = ImGui.GetIO().ConfigFlags; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you remember why this change was necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If viewports are enabled, ImGui expects the mouse position in DesktopSpace/ScreenSpace and no longer in WindowSpace
I derived this from the viewport example from ImGui.net
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok but the code comment says it's about the position on touch down events - not about spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was an old code comment from you ... maybe I should have put it out there
I should clean it up again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I wrote it. The comment says that the MouseMove is necessary to allow TouchDown events to be on the right spot, because the down event itself doesn't take a position. You surrounded the whole part in an if statement, which introduces different behavior. You say it was necessary because ImGui expects the positions to be in screen space, in which case I'd argue that we need to feed the right coordinates to the move event, but not skip it entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imgui, in viewport mode, expects a mouse position in the ScreenSpace for each frame. This is set in ImGuiWindows.cs SetPerFrameImGuiData().
I can therefore also put it in an If at this point, as it is set anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, that solves the puzzle. Then either add that piece of info to the if statement or get rid of it entirely and set the mouse position in each frame in existing mode.
@@ -75,6 +75,11 @@ public override void Initialize() | |||
base.Initialize(); | |||
} | |||
|
|||
public void Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling Dispose was not an option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm no longer sure about this ... I think it had a reason ... my Close just calls Destroy ... just tested briefly ... Dispose also works at least ... I'll have to take a closer look again
@@ -1,7 +1,7 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
|
|||
<PropertyGroup> | |||
<TargetFramework>net8.0-windows</TargetFramework> | |||
<TargetFramework>net8.0-windows7.0</TargetFramework> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again this guy ;) Still not sure about it, we have many other projects using net8.0-windows
which do not need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also works without ... is probably a leftover
Because the window out and in again bug, i.e. losing the input handling, I will also take another close look at it. I'm just relatively busy at the moment. But hopefully I'll get back to it tonight or in the next few days. I think it also needs another cleanup |
…its Notify calls (came up in #673)
… path for notifications as normal Skia rendering uses (issue vvvv#672)
@kopffarben My last commit (linked above) seems to have fixed #672 as well. However there was also that boolean flag I had to add as a workaround back in April which I now managed to get rid of by using the same code path for notifications as the normal Skia render path takes (see linked commit in #672, 2b92219). I didn't merge it back to main yet because of our discussion further up which is all about that line. You said in docking branch it expects the screen space coordinates in |
Some Comments
…Gui.Stride.Viewports
remove transformation workaround ... not longer needed ... fixed with 8e87a5a
the AddMousePosEvent is only set if ImGui is not in viewport mode. If ImGui is in viewport mode, the screen space mouse position is set every frame in ImGuiWindows.
So it should not break the current approach |
…eature/VL.ImGui.Stride.Viewports
SO I fixed most of it for now, merged main and the bugfix. The problem with pulling the window in and out still exists. I lose the input source or the appropriate viewport after dragging in and out a few times. Sometimes it goes faster ... but I don't have enough time right now to investigate it more closely. But I will keep at it. |
use VL.ImGui.Stride/src/ImGuiRenderer.cs from kopffarben
known issue ... remove IInputSource from normal Stride Windows
…r.cs Use this Option in WindowCore to has an UniqueName, so save WindowLayout now working remove temp loggiong ... was for debugging
…Gui.Stride.Viewports.WIP
…reen was wron ... width was 0 ... bug in Stride
…Gui.Stride.Viewports.WIP
Refactored `ImGuiWindow` and `ImGuiWindows` classes to use `IResourceHandle<InputManager>` and handle null `Window` objects gracefully. Updated `Dispose` methods across multiple classes to follow the standard dispose pattern, including adding `Dispose(bool disposing)` methods and finalizers. Removed `InputManagerExtension` class. Improved code readability with minor formatting changes.
Introduce UniqueId field to RenderWidget for unique naming. Add constructors to initialize UniqueId. Remove nodeContext property. Update ImGui.BeginChild to use UniqueId for unique names.
- Added new input pins ("Bounds," "Save Bounds," "Enable Camera," "EditMode") and removed some ("Edit Mode," "Node Context") in `VL.ImGui.Stride.vl` to improve functionality. - Modified `HowTo ImGui Windows Docking.vl` - Added `GameWindow` property and modified constructors in `ImGuiWindow.cs` and `ImGuiWindows.cs` to accept `RectangleF bounds`.
…Gui.Stride.Viewports
SO finally I have it ... Yeahhh I also had to use the SourceGenerator to get the layout saving of ImGui to work. Does nothing else than bringing the NodeContext in the Window Widget into the Constructor ... so I have a UniqueID for the names of the windows that I can add to the name name##uniqueID The InputHandling was a really difficult matter ... but now it works completely ... I always capture the correct InputSource ... and the mapping to the SubInputSources always works. Apart from that, I also handle the commands, perfmeters and so on ... Even the EditMode works, oh yes, I also save the bounds of the main window in the InputPin ... Copy from RenderWindow Just take a look at Helppatch ... it's almost a full-blown application ... Windows, save layout, edit layout ... , LightMode/DarkMode ... etc. |
PR Details
Viewports support for VL.Imgui.Stride
Description
This is an attempt to support ImGui viewports in VL.
It already works quite well, there are a few small things that do not work satisfactorily yet.
IssueTracker: https://github.com/kopffarben/VL.StandardLibs/issues
The previous features should all still work. Not 100 percent sure.
The problem with the Skia input should also be fixed.
I think Kairos is still working, but I'm not quite sure as I don't know exactly how it should behave.
In general, it could be cleaned up again, I'm also not completely satisfied with the naming of some classes ... but in principle it's good for now.
I'm also not quite sure if this is the best solution for some things.
I would be very happy about a code review.
Types of changes