Skip to content

feat: Support ImGui docking#56

Closed
CrushedPixel wants to merge 3 commits intojbrd:mainfrom
CrushedPixel:feat/docking
Closed

feat: Support ImGui docking#56
CrushedPixel wants to merge 3 commits intojbrd:mainfrom
CrushedPixel:feat/docking

Conversation

@CrushedPixel
Copy link
Contributor

This addresses #1.

Overview

These are three commits:

  1. Added a feature docking that enables imgui/docking feature.

  2. Added ImguiContext::with_io_mut to allow users to mutate Imgui's I/O struct. Without being able to modify the I/O struct, there is no way for a user to enable or configure docking.

  3. Add a field config_flags to ImguiPlugin that defaults to enabling docking when the docking feature is enabled. This makes it possible to configure Imgui via config flags without having to use with_io_mut.

The third commit is technically a breaking change, as it changes ImguiPlugin's struct layout, so existing code will need to be updated. Therefore, I understand if you don't want to merge this third commit - the first 2 are sufficient to properly use Imgui with docking. Just let me know if I should remove it from this branch.

Demo

With the docking feature enabled, I added a Startup system that runs:

imgui.with_io_mut(|io| {
    io.config_flags |= ConfigFlags::DOCKING_ENABLE;
    io.config_docking_always_tab_bar = true;
});

And now my windows are dockable, without any additional Imgui API calls:
Screenshot 2025-06-25 at 17 30 41

Please let me know your thoughts!

@CrushedPixel CrushedPixel changed the title feat: Add "docking" feature feat: Support ImGui docking Jun 25, 2025
@jbrd
Copy link
Owner

jbrd commented Jun 26, 2025

This looks great, thanks for contributing this :) I'll focus on getting the invalid slice fix through first, and then jump back to reviewing this.

@jbrd
Copy link
Owner

jbrd commented Jul 23, 2025

I haven't forgotten about this one - I'll move onto this next, and I will probably spend a bit more time with it and its likely that it will be part of a more major 0.8.0 release, where breaking changes are more acceptable

@jbrd
Copy link
Owner

jbrd commented Jul 30, 2025

Thanks for your contribution @CrushedPixel, overall I think this looks great. I've left a few pieces of minor feedback. I'd be happy to merge this once addressed...


// enable docking by default if the feature is enabled
if cfg!(feature = "docking") {
config_flags |= ConfigFlags::DOCKING_ENABLE;
Copy link
Owner

Choose a reason for hiding this comment

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

This fails to build when the docking feature is not enabled, since ConfigFlags::DOCKING_ENABLE doesn't exist

F: FnOnce(&mut imgui::Io) -> R,
{
unsafe {
let mut ctx = self.ctx.write().unwrap();
Copy link
Owner

Choose a reason for hiding this comment

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

Prefer expect over unwrap, so that we can provide a decent error message here (e.g. "Failed to acquire write access to ImGui context"...)

where
F: FnOnce(&mut imgui::Io) -> R,
{
unsafe {
Copy link
Owner

Choose a reason for hiding this comment

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

This unsafe block is unnecessary...

@CrushedPixel
Copy link
Contributor Author

Thanks, I'll look to address these shortly :)

@jbrd
Copy link
Owner

jbrd commented Dec 8, 2025

Superseded by #68

@jbrd jbrd closed this Dec 8, 2025
@jbrd
Copy link
Owner

jbrd commented Dec 10, 2025

Fix published in crate 0.8.0

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.

2 participants

Comments