-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Feature: menu widget #877
Feature: menu widget #877
Conversation
This adds some padding at the top and the bottom of a menu. It also moves the dismiss action from the MenuItem widget into the new Menu widget.
This is required for menus (with sub-menus) which will render their shadow on their own.
Thus sub-menus will have shadows, too. Also menus outside of pop-ups will have shadows.
Hmm, thanks for all of this, it's really coming together. I see that the reason for making popup shadow optional is to allow the menu to draw it's own shadow - this seems a little strange. |
widget/popup_test.go
Outdated
require.GreaterOrEqual(t, len(r.Objects()), expectedObjectCount) | ||
|
||
bgIdx := 0 | ||
if tt.castShadow { |
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.
This doesn't test the no-shadow state does 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.
Not explicitly, good catch!
If the pop-up would cast a shadow with hideShadow == true
, the following assertion regarding the background would fail. I’ll add an explicity assertion to clarify the intention.
Because menus will be allowed to have submenus in the next PR (tests just finished). These have to draw another shadow. |
I don’t follow sorry - won’t submenus look like top level menus? A list of items with a shadow around it... |
Exactly, and who should draw the shadow? |
internal/widget/shadow.go
Outdated
@@ -27,6 +27,7 @@ const ( | |||
ButtonLevel ElevationLevel = 2 | |||
PopUpLevel ElevationLevel = 8 | |||
SubmergedContentLevel ElevationLevel = 8 | |||
MenuLevel ElevationLevel = 4 |
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.
nit: move up 2 lines
… which has another shadow level.
…lay” PopUpMenu Thus the changes to PopUp can be reverted. This implicitly fixes fyne-io#892.
I'm having difficulty reading this PR now sorry. The modifications to PopUp coming and going seem to be interleaved with the commits that get to this finished menu. My other question is around the internal Overlay widget - it is only used by the new PopUpMenu - my normal rule of thumb is to not create an abstraction until there are multiple uses of it, so is the additional code really needed at this time? |
I don’t think this is an abstraction. As I already mentioned in #707 a widget should not be an overlay and another widget at the same time. The |
Technically: yes. |
Hmm, I see what you mean. And yet we publicly expose the AddOverlay but hide the Overlay widget. Alternatively we could make a much more sweeping change that requires Overlays are in fact Overlays... |
I think using a different name is the best way. |
Presenter is a bit of a trigger word as it's used for defined purposes in MVP https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93presenter. OverlayBackground sounds servicable, I just proposed Container as we have used that elsewhere. It is both a background and a container I guess. Perhaps background sounds alittle more passive than the object is? |
It’s fyne for me if you prefer |
Good by me, though I think Stuart had an open review too? |
Now everything should be in @stuartmscott @andydotxyz |
Description:
This PR contains the first part of the menu change:
internal/widget/menu
.This widget replaces the box that is used for menus up to now.
Checklist: