Closed LunaeSomnia closed 1 year ago
So the reason that the animations/hiding aren't working with the ResizableStack
is because of the use of css rules to animate the width and hide the panel. The ResizableStack
uses inline properties to set its width when you drag the handle, which overrides the css rules.
To get this to work you'll need to apply the necessary style changes as inline properties as well. The easiest way to do this is with the .bind()
method on handle. So instead of .toggle_class()
you can do something like:
ResizableStack::new(cx, |cx|{
...
})
.bind(LeftBar::hide_browser, |handle, flag|{
if flag.get(handle.cx) {
handle.width(Pixels(0.0));
}
})
This lets you set multiple properties when the bound data changes. However, you'll probably need to store the width in a model somewhere, or in the ResizableStack
itself, so that it can be restored when un-hidden.
For the animations there's a way to build them in Rust code but I just need to figure out the best way to do it. So start with the above and then we'll come back to animating it.
I'll make a commit with these new changes whenever I can. Keep me updated with the animation fix idea!
About the modularization, I wonder if we really need it I imagined that to be something similar to vscode's left bar, where extensions can add a new tab.
I imagined that to be something similar to vscode's left bar, where extensions can add a new tab.
I like the idea of this but it's not clear yet how extensions will work and also how they will interface with the UI. This might be something we should start planning soon but I don't think it's something for MVP.
I like the idea of this but it's not clear yet how extensions will work and also how they will interface with the UI. This might be something we should start planning soon but I don't think it's something for MVP.
Okay. For now I'll just have them hardcoded. We can change that in a future
Just finished reviewing your changes. I'm not too sure about having the
ResizableStackHandle
trait just for handling theon_drag
function,
Unfortunately the trait is required to add methods on the handle, which I'm using to update the stored browser width. The heart of the issue here is that the events happen on the LeftBar
but the width that needs to be tracked is on the browser, which is a child of the left bar. This necessitates using an event to transfer that data up the tree from child to parent. The other option could be to store the entity id of the browser in the left bar and then just look up the width.
and there surely needs to be a way to optimize the dragging animation feature. It could get out of hand pretty quickly. Couldn't we investigate on making it under css? I know the width features are hard-coded into the rust files, but it's worth a shot.
For this I need to think of a more declarative way to define animations. My initial thinking is something like being able to pass animation state directly to property setters like .width()
, but I need to think this through and write a proposal. Unfortunately we can't use css transitions because the width of the resizable stack will override it.
closing because of a rewrite
Testing the implementation of the
LeftBar
.Current things to change:
ResizableStack
doesn't let resizing: You can hide&show the browser if the window is not resized, but you can't otherwise.A better way to modularize the way the browser content is displayed (E.g. adding dynamic content using aHashMap<String, F>
whereF: FnOnce(&mut Context)
or by functions)