Skip to content
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

Panels - nodes that are not movable, holding only one tab at a time #164

Draft
wants to merge 16 commits into
base: release-0.15
Choose a base branch
from

Conversation

LiamPClancy
Copy link

I'd like to use the doc control for side bars and bottom bars on my app, to allow users to drag and drop the tabs between these sections.
I have a middle Node that i'm creating that I'd prefer if users couldn't drag it or drop other tabs from other nodes into this tab.

i've added a function to DockArea that allow me to set that no tab labels should be shown - this isn't particularly useful in my use case, as it really prevents the ability to see more than one tab in any node - or drag any of them anywhere.

I've made a couple of changes to enable this functionality,

i've added a prop on Node::Leaf hide_label that allow one to set if they what that node to hide the labels - if there are no labels showing it prevents the ability to drag the tab in the node, and i've also used the same setting to prevent dropping other tabs into the node.

to enble this on a node, i've create the additional functions split_left_single... which only accepts a single tab and creates the Node:Leaf with hide_label set to true.

LennysLounge and others added 16 commits July 2, 2023 00:02
* Add rounding and correctly draw border

* Add TabBodyStyle

* Round the leaf size calculation

If this isn't rounded it is possible that either leaf disappears behind
the separator by one pixel. The rounding here should happen the same
way the rounding happens in `show_separator`

* Deal with stroke width correctly

The stroke of a rectangle expands beyond the original rectangle.
This will make sure that the rectangle is small enough so that when the
stroke expands beyond the rect, it is still inside the original size.

* Add different interaction version of tab style

* Move `fill_tab_bar` to tab bar settings

* Update the examples with the new styling

* Account for the scrollbar in the tab bar

* Use the correct interact style for the tab title

* Rename style structs

* Move hline style to tab style

* Add a prefered width for tabs

* Hide to tab body top border

* Set pointer hand when hovering over a tab

* Update changelog

* Remove todo

* Improve doc and apply suggestions

* Depluralise

* Change preferred width to minimum width

* Change styling a bit

* Change the default styling a bit

* Avoid overdrawing the add button line

* Update CHANGELOG.md

Adjust changelog
* Update egui version in badge

* fix: typo

* feat: double click to reset resizing

---------

Co-authored-by: Adanos020 <[email protected]>
* feat: allow disabling vertical/horizontal splits

in my use case vertical splits are useless, maybe other people
have some use for this. /shrug

* fix: rename vertical/horizontal to leftright/topbottom

* Move `allowed_splits` from `Style` to `DockArea`

* Add split directions to the style editor. Fix panic while dragging tabs with `None` split directions.

* Delete redundant module path

---------

Co-authored-by: Adam Gąsior <[email protected]>
* Allow individual tabs to be closable or not

This fixes Adanos020#113

* Fix clippy warning

---------

Co-authored-by: Adam Gąsior <[email protected]>
* Add the NodeIndex to context_menu() parameter list

* Adapt contex_menu() in hello example
…he tabs, I now want to expand the functionality to I can only show the labels on specific tabs
…bel on a node, Also ensured that if a node that was going to be set to hide the label it would only accept one Tab, as it doesn't make much sense to have multiple tabs if you can't switch between them
Copy link
Owner

@Adanos020 Adanos020 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced that we need all the split_*_single and leaf_with_single methods. They don't do anything special and have the exact same effect as just passing a Vec with a single tab in it to a split_* method.

Having more than one way to achieve the same effect makes the API more confusing to use and therefore I'd get rid of these functions.

I need to think more about the show_label_bar stuff as something doesn't seem right there, it's probably just the naming.

@Vickerinox
Copy link
Contributor

Looking through the changes so far I think it would be better if the implementation relied on a new kind of node (perhaps something like Node::Panel or Node::Single) or a reimagining of Node::Leaf. egui_dock hasn't ever really displayed anything that isn't a leaf before, so by introducing multiple simultaneous types of nodes we should ideally make it as "right" as possible before opening that can of worms.

Ideally any sort of functionality you wish to have (such as restricting a node to only one tab) should be reinforced by the Node type, otherwise we might set a president for tacking on new fields onto Node::Leaf endlessly for new types of nodes, which wouldn't be sustainable long term and annoying for future developers.

Im also not fond of the idea of being able to disable all nodes from having their tab bars disabled via DockArea, since it sounds like a backalley way of achieving a typical TopBottomPanel/SidePanel ui in vanilla egui. It could also introduce further confusion for developers who aren't familiar with the bigger picture of the api. So I think it's better if it was left to being decided on a node to node basis only.

However it's decided that this implementation should move forward i would highly recommend considdering how future features may come into play, eg. by generalising DockArea to accept displaying multiple kinds of nodes rather than just Node::Leaf or generalising tabs inside Node::Leaf to allow for multiple tab configurations with good customization.

@LiamPClancy
Copy link
Author

hey @Adanos020 I can remove the show_label_bar option, don't need it for my use case, just put it in initially to help me follow the code and agree with the comments from @Vickerinox that when turned on it's really just reproducing the native egui functionality.

i'm currently using the leaf_with_single calls to set the additional hide_label prop on the node - which is then used in the show_inside method to prevent showing the label bar on the node.
the split_..._single methods only accept a single Tab rather than an array - to prevent people passing multiple Tabs when creating a node that will not show the title bar and therefore will not allow switching tabs in the node.

happy to explore the other option @Vickerinox of creating a different node type, like Node::Single
would probably then need the four different split methods to generate the nodes, and could add functionality to DockArea for rendering the nodes, to remove changes from the Node::Leaf implementation in the current PR.

let me know if you'd be interested in me moving forward with this other approach?

@Adanos020
Copy link
Owner

i'm currently using the leaf_with_single calls to set the additional hide_label prop on the node - which is then used in the show_inside method to prevent showing the label bar on the node.
the split_..._single methods only accept a single Tab rather than an array - to prevent people passing multiple Tabs when creating a node that will not show the title bar and therefore will not allow switching tabs in the node.

Once we switch to the Node::Panel approach, we could still do fine without these methods. Instead, I'd opt for creating an enum like this:

enum InsertTabs<Tab> {
    Panel(Tab),
    Leaf(Vec<Tab>),
}

which could be passed to the split_* methods instead of the Vec<Tab>. This way we could keep the number of methods to a minimum while still ensuring that the correct number of tabs is passed every time.

@Adanos020 Adanos020 changed the title Release 0.7 preventing tab drag Panels - nodes that are not movable, holding only one tab at a time Aug 25, 2023
@LiamPClancy
Copy link
Author

ok, I'll see what I can do - i'll hopefully get an opportunity to have a look at it over the next couple of weeks.

@Adanos020
Copy link
Owner

Changing this to a draft as the implementation needs redesigning and probably won't make it to 0.7.

@Adanos020 Adanos020 changed the base branch from release-0.7 to release-0.8 September 18, 2023 17:28
@Adanos020 Adanos020 changed the base branch from release-0.8 to release-0.9 September 28, 2023 19:36
@Adanos020 Adanos020 deleted the branch Adanos020:release-0.15 November 23, 2023 20:09
@Adanos020 Adanos020 closed this Nov 23, 2023
@Adanos020 Adanos020 reopened this Nov 25, 2023
@Adanos020 Adanos020 changed the base branch from release-0.9 to release-0.10 November 25, 2023 21:59
@Adanos020 Adanos020 changed the base branch from release-0.10 to release-0.11 February 1, 2024 14:42
@Adanos020 Adanos020 changed the base branch from release-0.11 to release-0.12 February 6, 2024 19:44
iostat added a commit to iostat/egui_dock that referenced this pull request Mar 18, 2024
@Adanos020 Adanos020 deleted the branch Adanos020:release-0.15 April 5, 2024 20:51
@Adanos020 Adanos020 closed this Apr 5, 2024
@Adanos020 Adanos020 reopened this Apr 5, 2024
@Adanos020 Adanos020 changed the base branch from release-0.12 to release-0.13 April 5, 2024 20:56
@Adanos020 Adanos020 deleted the branch Adanos020:release-0.15 July 3, 2024 18:40
@Adanos020 Adanos020 closed this Jul 3, 2024
@Adanos020 Adanos020 reopened this Jul 3, 2024
@Adanos020 Adanos020 changed the base branch from release-0.13 to release-0.14 July 3, 2024 19:01
@Adanos020 Adanos020 changed the base branch from release-0.14 to release-0.15 October 14, 2024 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow hiding the labels on specific Nodes, and prevent dragging other tabs into them.
8 participants