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

feat: allow disabling vertical/horizontal splits #145

Merged
merged 6 commits into from
Jul 23, 2023

Conversation

zkldi
Copy link
Contributor

@zkldi zkldi commented Jun 30, 2023

I have a use case where I never ever want the user to be able to make vertical splits. This PR allows the programmer to disable vertical or horizontal splits via allowed_splits on the Style struct.

@zkldi
Copy link
Contributor Author

zkldi commented Jun 30, 2023

Actually, maybe the Horizontal/Vertical terminology is ambiguous. I'm using a Horizontal split to describe

A | B

splits. but I guess people could interpret "horizontal" as

A
--
B

would totally accept some less ambiguous terminology for this.

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

TopBottom and LeftRight?

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.

Hey, this is a nice feature. I have some comments:

  • SplitTypes affects behaviour and not the look and feel. Therefore it shouldn't be in Style but rather a setting in DockArea.
  • Adding this to Style is a breaking change because all of its fields are public, which means that if someone creates Style manually, their code won't compile until they update it. Which is another argument why this should be in DockArea instead.
  • For the future, I'd prefer if PRs for new features were opened to the release-x.x branch instead of main. Even though this change won't be breaking when you move this new setting to DockArea, it would be better if PRs to main were for non-breaking bug fixes only, so I could release new patch versions more easily.

Also, can you please include the related issue number at the beginning of your PR description, like this?

Closes #147 

@Adanos020 Adanos020 changed the base branch from main to release-0.7 July 1, 2023 23:00
@Adanos020 Adanos020 linked an issue Jul 23, 2023 that may be closed by this pull request
@Adanos020 Adanos020 merged commit df50088 into Adanos020:release-0.7 Jul 23, 2023
4 checks passed
Adanos020 added a commit that referenced this pull request Aug 28, 2023
* 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 <adanos020@gmail.com>
@Adanos020 Adanos020 mentioned this pull request Sep 18, 2023
Adanos020 added a commit that referenced this pull request Sep 18, 2023
* Expand styling options for tabs (#139)

* 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

* feat: double click on separator to reset size (#146)

* Update egui version in badge

* fix: typo

* feat: double click to reset resizing

---------

Co-authored-by: Adanos020 <adanos020@gmail.com>

* Update version number and changelog

* feat: allow disabling vertical/horizontal splits (#145)

* 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 <adanos020@gmail.com>

* Rename `SplitTypes` to `AllowedSplits`. Update changelog.

* Allow individual tabs to be closable or not (#150)

* Allow individual tabs to be closable or not

This fixes #113

* Fix clippy warning

---------

Co-authored-by: Adam Gąsior <adanos020@gmail.com>

* Remove blank space where the close button is not enabled (#153)

* Add the NodeIndex to context_menu() parameter list (#157)

* Add the NodeIndex to context_menu() parameter list

* Adapt contex_menu() in hello example

* Support for undocking and docking tabs as windows (#149)

* Support for undocking and docking tabs as windows

This commit adds support for undocking and docking tabs as windows. this includes a new widget shown on panels where tabs can be dropped which is inspired by other guis and originally implemented by micfong-z.

* Added Surfaces!

Restructured Tree to have the top level indexing be done via the new type Surface! Surfaces can either mean the root panel or a window. This contains broken examples and major breaking changes in api that will be addressed

* Renamings and restructure

Additions:
windows can now be resized
undocked tabs that become windows now reflect their old size

Changes:
-Renamed NodeTree back to Tree
-Renamed Tree to DockState
-Added new methods to DockState to reflect old API and fix examples
-New methods iter_nodes, root, root_mut,

* Further Renaming and window rejecting tabs

this commit creates several breaking API changes and adds the ability for tabs to reject being created as a window. This is done via ``TabViewer``. A new example has been added to showcase this feature.

* Support for undocking and docking tabs as windows

This commit adds support for undocking and docking tabs as windows. this includes a new widget shown on panels where tabs can be dropped which is inspired by other guis and originally implemented by micfong-z.

* Added Surfaces!

Restructured Tree to have the top level indexing be done via the new type Surface! Surfaces can either mean the root panel or a window. This contains broken examples and major breaking changes in api that will be addressed

* Renamings and restructure

Additions:
windows can now be resized
undocked tabs that become windows now reflect their old size

Changes:
-Renamed NodeTree back to Tree
-Renamed Tree to DockState
-Added new methods to DockState to reflect old API and fix examples
-New methods iter_nodes, root, root_mut,

* Further Renaming and window rejecting tabs

this commit creates several breaking API changes and adds the ability for tabs to reject being created as a window. This is done via ``TabViewer``. A new example has been added to showcase this feature.

* Delete abstract_tree

* Experimental changes

-bugfixes
-namechanges
[TEMPORARY]

* Small bugfixes

-removing all tabs on root surface doesn't panic
-tabs can be added to an empty surface

* Surfaces, Focus and expanding windows Bugfix

-fixed a bug where closing all tabs in a window could result in a panic
-fixed a scenario where the dockarea may attempt to remove the root surface.
-Leaf rects are now trimmed down to never expand beyond root node rects to try and prevent pixel roundings causing windows and other surfaces to infinitely expand.

* bugfixes and consistency changes

-changed set_focused_node_and_surface to be more consistent with set_focused_node
-fixed a panic condition where move_tab tries to delete the root surface

* Addition to splits

-Allowed parent nodes to be split

* Panic condition fix

Fixed a panic condition where the emptying of the root surface can cause an out of bounds error for indexing the empty node tree

* changed interactions with overlay

-tab drop overlay is now always on top of everything in the dock area,
-style has been changed to accomodate overlay properties
-when overlay is shown hovering over buttons will lock the hover data until the mouse reaches outside their influence

* Further Overlay changes

-implemented ops::BitAnd for AllowedSplits
-when trying to drop a tab on an empty surface, only the insert button will be shown

* Hold time for overlay lock

replaced lock in hoverdata with an ``Option<Instant>`` to allow for a user specified max hold time before the overlay may switch to another node if a node from another surface is above it

* faded windows first part

* Fading windows part 2

windows now fade whenever a surface that isn't theirs is being hovered

* Removed Fade Animation

removed the fading animation for windows and relevant style fields

* Hightlighting rect on hovered leaves

dragged tabs now show a highlight rect on the leaf theyre about to be dropped on
small changes have been made to examples and new methods which existed for tree but not dock state has beeen implemented for dock state

* Formatting; partial highlighting of overlay icons for better target indication

* Cleanup and fix clippy warnings

* Fix tests

* Dedicated button color fields for overlay buttons

Added ``button_color`` and ``button_border``stroke`` to overlaystyle, as well as slightly changed the documentation to be more accurate and consistent

* Fix overlay icon proportions

* Cleanup, rename `allow_in_windows` to `allowed_in_windows`, eject context menu option pt. 1

* Small clarity change to hover data

* changes to old overlay and hello example

this is one of several parts in chaning the old overlay to match the new needs of egui_docks. as well as starting to make changes to the hello example to inclulde the new overlay options.

* changes to hello example and overlay style

made changes to hello example to include more parameters from the overlay style and divided overlay style into style and feel

* refactoring HoverData

This is the first part in refactoring HoverData to fit the new ergonomics of the crate, this commit introduces DragAndDropState, which carries info which isn't relevant to HoverData or DragData, this commit doesn't change behavior in any way for egui_dock, however a future commit probably will

* Close context menu upon clicking on one of the options

* Only show the 'Eject' option for docked tabs

* Minor refactorings

* Quick fix to window fade

fixed window fade problem introduced during hoverdata refactor

* Second hotfix for new HoverData

this hotfix addresses the problems with stolen focus, as well as a bug with the drag and drop of tabs

* refining fix to nodes stealing focus

this commit fixes the problem with nodes stealing focus they aren't supposed to, as it previously didnt allow for focus to be switched while interacting with a widget that consumes clicks or drags.

* Make tab windows movable by dragging from any point in the tab body

* Minor cleanup

* Reworking Hoverdata part 2

this commit is meant to finish the rework of hoverata (with some polishing still needing to be done)

also includes a couple of refactors in order to declutter the dock_area module

* Polishing overlay

fixed certain edgecases and polished the overlay

* Changes to overlay

changed the way dropping a tab in its original node behaves

* update to Highlighted areas overlay

changes how the highlighted areas overlay behaves on same node drags to be consistent with the icon based overlay

* Window bounds, finished hello example

Changed hello example to reflect the entirety of ``OverlayStyle``
added the option to put a bound on where windows can reside, being restricted to the screen rect by default.
-moved selection_color
-added a from_egui method for OverlayStyle

* correction of documentation

corrects part of documentation for dock area

* Correct typos in examples/hello.rs

* Make clippy happy and clean up comments&documentation.

* Fix rustfmt errors

* Fix doc errors

* improved documentation

this commit updates some of the documentation to include examples and further details about certain methods, and will be one of many to come in very high likelyhood

* Consistency changes, improved documentation

-More examples in documentation
-Clarifications in documentaion
-Removed ``root_..`` methods
-renamed "root surface" to "main surface"

* removed unneccesary links

removed unneccesary bool links

* Improve documentation in lib.rs

* Make `Node::split` panic if `fraction` isn't in range 0..=1

* Reformat

* Write more about surfaces and trees

* Fix doc test

* Clarifications in the docs

* Add a section about `style`

* Polishing `style`

* Documentation grooming

* Make clippy happy

* Fix cargo doc errors

* Update changelog

* added buttons to windows (+setting) restructured dock area

this commit restructures the contents of `DockArea` so that mod.rs isn't a 1000+ line behemoth. As well as adding collapse and close buttons to window surfaces.

* updated changelog, hello example, and window behavior

this commit fixes the behaviour where windows are collapsed by default, as well as updates the changlog to include the "show window heads" setting and a checkbox in the hello example to showcase the feature

* updated behaviour to windows

- added seperate settings for close and collapse buttons on windows.
- shows title of selected node when collapsed

* fixed oversights

slight code restructure to windows as well as an oversight where the wrong fields was used

* Update readme

* final touches

final touches on windows

* Disable closing non-closeable tabs with middle click

* Update changelog

* changed sizes on window titles

changed window titles to appear with the same style as tab titles

* Fix clippy errors

* Fix docs

---------

Co-authored-by: Adanos020 <adanos020@gmail.com>

* pdate tab's scroll

* update tab's scroll

* update scroll mode for every tab

* update scroll mode for every tab

* update scroll mode for every tab

* Finish up rebase

* Reformat

* Enable/disable scroll bars on individual tabs. (#160)

* Update mod.rs

* update tab's scroll

* update tab's scroll

* fix cargo fmt

* update scroll mode for every tab

* update scroll mode for every tab

* update scroll mode for every tab

---------

Co-authored-by: Adam Gąsior <adanos020@gmail.com>

* Reformat

* Update changelog and contribution guide

* Make `TabViewer::{on_add,add_popup}` accept corresponding surface index (#167)

* Make `TabViewer::{on_add,add_popup}` accept corresponding surface index

* Fix `TabViewer::context_menu` while I'm at it

* Update changelog

* Fix examples

* Fix bug #168 (#171)

fixes the bug addressed in #168, by always ignoring window hovers when dragging a non window tab.

* Fix for issue #172 (#173)

* Minor clarifications to documentation and changelog

* Add `serde` attributes to `DockState` and all types stored in it

* Make `DockState` and types related to it debugable

* Fix for issue #174 (#176)

* Fix for issue #174 (removed instant)

fixes issue #174 by removing the use of ``Instant`` inside the drag/drop state. since it's not allowed on wasm.

* ran cargo fmt

ran cargo fmt on last commit.

* finishing touches

fixed ``widnow_fade`` which also made use of ``Instant``

* Fixes to small bugs (#177)

fixes the bugs discussed in the discord egui_dock channel

* Translations (#178)

* First working implementation of translations

* API change

* Remove unnecessary imports of `Translations`

* Clean up

* Update changelog, rename one of the translations structs

* Add guide section about translations

* Fix hover_pos on touch screens (#180)

* Fix hover_pos on touch screens

* Rename to last_hover_pos & replace all occurrences

* Reorder state assignment in show_inside

* Update changelog

* New demo GIF

---------

Co-authored-by: Leonard Schüngel <schuengel.leonard@gmail.com>
Co-authored-by: zkldi <zkldi.dev@gmail.com>
Co-authored-by: Peter Kristensen <peter@ptx.dk>
Co-authored-by: 12089897411 <108512675+12089897411@users.noreply.github.com>
Co-authored-by: ToppDev <dev@topp.cc>
Co-authored-by: Vikrinox <51887867+Vickerinox@users.noreply.github.com>
Co-authored-by: 12089897411 <13019317170@163.com>
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.

None yet

3 participants