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

DockPanel inside a DockPanel #43

Closed
jtpio opened this issue Jan 22, 2020 · 8 comments · Fixed by #137
Closed

DockPanel inside a DockPanel #43

jtpio opened this issue Jan 22, 2020 · 8 comments · Fixed by #137

Comments

@jtpio
Copy link
Member

jtpio commented Jan 22, 2020

Given the following layout (adapted from the DockPanel example), where dock2 is a second DockPanel added to the first one with:

let dock2 = new DockPanel();
dock2.addWidget(g2);
dock2.addWidget(y2, { mode: 'split-right', ref: g2 });
dock2.id = 'dock2';
dock2.title.label = 'Dock 2';
dock.addWidget(dock2, { mode: 'split-bottom', ref: r1});

image

Is is possible to have control on where the widgets of an inner DockPanel can be docked? For example to disallow dropping them outside of "Dock 2":

inner-dockpanel

@jasongrout
Copy link
Contributor

I think this is tricky because the mimetypes from the inner dockpanel match the accepted drops for the outer dockpanel. Perhaps there is a way to override those mimetypes for one or the other to make the inner and outer dockpanels incompatible with each other.

@jasongrout
Copy link
Contributor

jasongrout commented Jan 30, 2020

Yeah, this is the mimetype it is setting and accepting. If you customized that to be different for the inner and outer dockpanels, things might work:

if (event.mimeData.hasData('application/vnd.lumino.widget-factory')) {

mimeData.setData('application/vnd.lumino.widget-factory', factory);

@jasongrout
Copy link
Contributor

jasongrout commented Jan 30, 2020

Perhaps that string should be a class parameter that can be changed for these sorts of issues? It probably ought to be at least a variable so it can be referenced instead of typed out exactly three different places.

@jtpio
Copy link
Member Author

jtpio commented Jan 30, 2020

Yes that's a good point.

It should be possible to try a quick and dirty solution, for example by appending the DockPanel id to the mime data, which would prevent drops to a widget with a different id.

Perhaps that string should be a class parameter that can be changed for these sorts of issues? It probably ought to be at least a variable so it can be referenced instead of typed out exactly three different places.

Or by adding the source to the Drag object here:

this._drag = new Drag({
mimeData, dragImage,
proposedAction: 'move',
supportedActions: 'move',
});

And checking for the source here:

if (event.mimeData.hasData('application/vnd.lumino.widget-factory')) {

@afshin
Copy link
Member

afshin commented Jan 30, 2020 via email

@jtpio
Copy link
Member Author

jtpio commented Jan 30, 2020

Thanks @afshin for the extra context.

Maybe such behavior could still be enabled using an opt-in flag, to let users do something like this if they really want to.

I'll experiment with this and report back, at least to get a feeling of what it looks like in terms of UX.

@dhirschfeld
Copy link
Member

dhirschfeld commented Jan 30, 2020

This functionality might be useful for e.g. variable viewers for the debugger

(though I'm not sure that is an actual improvement over just adding them to the main DockPanel)

@jtpio
Copy link
Member Author

jtpio commented Jan 30, 2020

Reusing the example from above, and implementing the idea from #43 (comment) and using the source field from the Drag object:

dockpanel-source

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants