-
Notifications
You must be signed in to change notification settings - Fork 72
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
UI: add containing View
for each Label
#306
Conversation
Hmm, can we not just adjust the owner window for label and handle the event? |
I think it would significantly complicate the I believe it would be better to delegate this work to the OS, just like for all the other components. |
Thinking more about this, is this really a special case? Will this be needed for all the controls? Can we avoid this by doing a custom draw? The hit testing can be delegated to the OS, and is something I want to expose. |
I think so, it seems
Nope, this is only needed for
Not sure... I'll try.
This would be great, this way there won't be the need to reimplement the system event dispatch logic. I don't really know how to do it though... A similar issue will probably arise once drag-and-drop or other interactions are implemented – these static controls won't be receiving the events properly. |
This would be good to get rebased and prepared to be merged, at least for the Label case. We should figure out how to do this more generically at some point. |
Just rebased this, and it still works for me – the context menus show up on a right-click on labels as expected. |
Hey @egorzhdan, sorry to do this to you, but could you rebase this on top of #434 as I think that is a pretty simple change and I was thinking about a bit more tweaking to this change? |
Thinking about this a bit further, is there any advantage to actually deriving the label from |
8b27859
to
84c7495
Compare
If we get rid of the |
True, but, we end up having to do that in senses anyways - we forward the settings to the subview. At the end of the day, we just need to change the hWnd that the messages are sent to, so that seems no more expensive really, it just is a matter of inlining the call. If I am not mistaken, instead of forwarding the properties, we will just inline the |
Hmm, do you mean changing
So basically calling all the WinSDK methods for creating/repositioning the |
No, that won't work for exactly the reason you mention. However, rather than having the properties forward to another view, which then just invokes
No, the thought that I had was actually the insight that we dont care about the settings for the
If we set the background color to clear, instead of forwarding the font and foreground color we send the proper message to the emebdded view, and set a property observer on the position, we can entirely ignore the embedded window. |
Got it, thanks! I think this should now work the way you expect. |
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 think that this is actually going to be far more important than I first expected. The Label
type really should be a composite type which doesn't leak the members. Thank you so much for working on this!
0, 0, | ||
Int32(staticFrame.size.width), | ||
Int32(staticFrame.size.height), | ||
nil, nil, GetModuleHandleW(nil), nil)! |
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.
Similarly, why not use the bounds from the parent? By making the label the full size of the parent, the fact that it is embedded doesn't actually leak.
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.
Fixed
var staticStyle: LONG = GetWindowLongW(self.staticHWnd, WinSDK.GWL_STYLE) | ||
staticStyle |= WS_CHILD | ||
staticStyle &= ~LONG(bitPattern: WS_POPUP | WS_CAPTION) | ||
_ = SetWindowLongW(self.staticHWnd, WinSDK.GWL_STYLE, staticStyle) |
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.
Is there a reason for the style to be computed? Is it not statically known?
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.
Yeah, we actually only need WS_CHILD
here, so I made it static.
`WC_STATIC` control doesn't receive events like `WM_CONTEXTMENU`. To be able to handle those events, let's create containing views for `WC_STATIC` instances. Co-authored-by: Saleem Abdulrasool <[email protected]>
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! I think that this can be simplified a bit further, but we can do that in a follow up clean up. Assuming it also builds with CMake, I don't think that we need to push this out any further.
/azp run VS2019 |
Azure Pipelines successfully started running 1 pipeline(s). |
Ugh, I think looking into the CMake build can happen later. |
WC_STATIC
control doesn't receive events likeWM_CONTEXTMENU
. To be able to handle those events, let's create containing views forWC_STATIC
instances.