How to make a vertical resizable panel?


#1

I write a module terminal-status, open a panel below the editor. I want to make the terminal panel vertical resizable. Is the view system support this feature.


#2

The tree-view package allows resizing, maybe you can see some useful code there.


#3

While I too am digging into the tree-view package for this type of problem, as a new Atom dev I’m wondering why the code to handle resizing of panels isn’t part of Atom itself. Packages add their views to the Panels, which are managed by Atom. If every package wanted resizing capability, then every package would have to implement the same logic. That seems bad to me.


#4

Having developed a plugin with a side panel, I was also surprised that this wasn’t part of Atom. Even some very popular packages that have horizontal build output displays don’t support drag-resizing panels because of this. Is there an architecture issue that makes it difficult to incorporate into Atom’s panels?


#5

We wanted this functionality in Nuclide as well and so grabbed the PaneContainer constructor in order to use it: https://github.com/facebook/nuclide/blob/master/pkg/nuclide/atom-helpers/lib/create-pane-container.js

let PaneContainerClass = atom.views.providers.filter((provider) =>
  provider.modelConstructor.name === 'PaneContainer'
)[0].modelConstructor;

You can then instantiate the pane container, get its active pane via getActivePane, and imperatively build your resizable UI:

let paneContainer = new PaneContainerClass();
let leftPane = paneContainer.getActivePane();
let rightPane = leftPane.splitRight({
  flexScale: 2, // Sets initial `flex` value of the panel
  item: document.createElement('div'), // Mount whatever you like
});

This is picking apart internal APIs, so proceed with caution.


#6

Can this code be contributed back to Atom Core rather than have it in another app?


#7

It doesn’t seem like a priority for the core team given the lack of activity on https://github.com/atom/atom/issues/672. The functionality exists in core, but the PaneContainer class is not exported. It sounds like they didn’t want to export it in anticipation of a rewrite, but it’s been over a year since that last comment.


#8

Is this still not a thing?