-
Notifications
You must be signed in to change notification settings - Fork 569
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
Cross Platform WinHandler
#13
Comments
I'll just dump a few thoughts, as I haven't gone through all issues. First, I think of this problem as morphing druid-win-shell into druid-shell, and shedding Windows dependencies in the process. Since the I'm not sure whether to use a trait-made-concrete (like RenderContext, also gfx-hal is a model of this pattern), or just different impls. One model for the latter is the filesystem in the Rust std lib. One good reason to use the trait is to enable generic code that can use multiple impls, perhaps in the same binary. I think that will be much less important at the "shell" level than drawing. Keyboard and mouse constants are an issue. I think basing them on the web is a very good idea, as this is well-trodden terrain. Exactly what should implement the One other thought. Windows uses "dpi" where 96 is nominal, but I think I would rather use a dpi scale where 1.0 is nominal. On Windows, dpi scale = dpi / 96, but on other platforms this wouldn't be strictly true. I also tend to talk about px units, using roughly the same definition as the Web. (Terminology for this is really confusing, on Mac these are called "points", not to be confused with the print unit of the same name). |
As part of platform independence, rename druid-win-shell to remove the reference to a specific platform. Also fixes druid-shell examples, which were slightly broken. Normalizes line endings to LF (not CRLF). Part of #13
All the windows specific code is now in the windows subdir. The goal of this patch is to preserve druid-shell function on windows, and have it compile (with basically no functionality) on mac. Part of #13
Closing this, as we've been cross platform for a while, and I think all other relevant details are captured in other issues. |
With #11 drawing will be cross platform. The question is then "what next?". I propose we next try to make
WinHandler
cross platform.WinHandler
is the trait that defines how to respond to window events like painting, size changes and keyboard/mouse events.Here's a list of items that need to be addressed:
WinHandler::connect
takes aWindowHandle
which has a weak reference to aWindowState
which is highly Windows specific as it has a reference toHWND
andWndProc
.connect
stores theWindowHandle
on the state'sLayoutContext
. The handle is used for the following: invalidating widgets, closing the window, file dialog, converting physical pixels to px units, getting the current dpi. Perhaps this can all be abstracted away in a trait that is made concrete in a similar way that we do withpiet-common
WinHandler::mouse
,WinHandler::mouse_move
andWinHandler::size
all use the windows specificWindowHandle
that is stored on theUiState
'sLayoutContext
WinHandler::destroy
calls the windows specificwin_main::request_quit()
Thoughts on how to abstract
WindowHandle
and how to handle modifier keys?The text was updated successfully, but these errors were encountered: