caduandrade / multi_split_view

Provides horizontal or vertical multiple split view for Flutter.
https://caduandrade.github.io/multi_split_view/
MIT License
129 stars 24 forks source link

dividerWidget position above children #23

Closed jkgeorge89 closed 2 years ago

jkgeorge89 commented 2 years ago

Looking through the source code, not 100% sure how easy this would be to implement, but it would be is it possible to implement the position of the border to be 'above' the children within the stack? This would allow the children to fill the total constraints (width or height) and then have the DividerPainter backgroundColor = [Colors.transparent] and only show the border with the highlightedBackgroundColor. This would mean each position is child's left position + 1/2 border thickness and provide for the child to have a border property.

For example, if we think about how VS Code layout is built the primary-side-bar and editor have a resizable 'border' that appears onHover/onFocus. However, the border appears elevated in front of the primary-side-bar and editor (even though the elevation appears to be 0).

caduandrade commented 2 years ago

Hi @jkgeorge89 !

It's an interesting feature. It's not so easy because it would change some things and the internal calculations. I'll think about the best way to do it.

jkgeorge89 commented 2 years ago

@caduandrade it was interesting problem that I tried to solve myself. However, in my project the 'layout' is not always fixed so user can change a setting which would change the nesting and potentially the vertical vs. horizontal attributes. In the end, I went with CustomMultiChildLayout as the number of widgets to be rendered is fixed and I could control the constraints based either on the size of the child or a user input. The layoutChild() would force the box constraints and then the positionChild() would effectively position the widgets.

The challenging item was that inside the child widgets I had to create the resizable_border which I took inspiration from your code for some of the onDrag calculations. In the end, the resizable_border are within the child widget before they are passed to the CustomMultiChildLayout as this made the code simpler. However, I think on v2.0 I will try to render the resizable_borders widget within the layoutChild() of the CustomMultiChildLayout widget and then have the onDrag functions change the box constraints which should trigger shouldRelayout().

Thanks for your work on the multi-split-view as it truly was an inspiration!