-
Notifications
You must be signed in to change notification settings - Fork 253
transparent StackView layers #254
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
Conversation
Thank you very much for the work! You're right, silently changing A simple solution would be, from your PR, to simply rename fn add_layer<T>(&mut self, view: T)
where T: IntoBoxedView,
{
self.add_transparent_layer(Layer::new(view));
} Unfortunately, thinking about it more, we have the same problem we had with the optional The solution is the same we had back then: add a variant to the This means adding This may sound like an uncontrolled explosion in methods or variants, but:
Going this road, I don't think it makes sense to backfill in Dialogs or Panels anymore. |
That turned out pretty well, only |
// Some views don't (fullscreen views mostly) | ||
Plain(Layer<T>), | ||
Plain(T), |
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.
(Kept the Plain
name for now, I think it's still a good fit)
src/views/stack_view.rs
Outdated
@@ -77,18 +83,22 @@ impl<T: View> ChildWrapper<T> { | |||
/// Returns a reference to the inner view | |||
pub fn get_inner(&self) -> &View { | |||
match *self { | |||
ChildWrapper::Shadow(ref shadow) => shadow.get_inner().get_inner(), | |||
ChildWrapper::Plain(ref layer) => layer.get_inner(), | |||
ChildWrapper::Shadow(ref shadow) => shadow.get_inner(), |
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 we still want the absolute inner view here, so it would be get_inner().get_inner()
(just like before this PR)?
src/views/stack_view.rs
Outdated
} | ||
} | ||
|
||
/// Returns a mutable reference to the inner view | ||
pub fn get_inner_mut(&mut self) -> &mut View { | ||
match *self { | ||
ChildWrapper::Shadow(ref mut shadow) => { | ||
shadow.get_inner_mut().get_inner_mut() | ||
shadow.get_inner_mut() |
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.
Same thing here, any reason you removed a round of get_inner_mut()
?
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.
No, those are my fault, it seems I haven't properly restored everything after the previous attempt.
Good catch! I added a test that would have caught my mistake. |
test StackView::get()
Awesome, thanks! |
In response to #117 (comment) I removed the
Layer
fromStackView
, added a background toDialog
andPanel
, and adapted usages. On the caller's side that leads to the following situation:add_layer(Layer::new(…))
By default there will be no background so in its current state this silently breaks many applications and is not very intuitive / easy to do wrong. You can see how many occurrences I had to update in the examples. Because the background is not cleared this also causes artifacts when scrolling text.
Maybe we should keep the default behavior and just add something like
add_transparent_layer()
? I'd like to agree on the API changes before I go ahead.