Minimised and Externalised at the same time!

This is a bug report, but i wanted to upload some images to show more clearly the problem, so I’m doing it here instead, hope it’s ok.

When a dock is dragged to the edge of the docking area, there is a small place at the bottom and at the top where is possible to place the dock so that it will appear minimised and externalised at the same time!

Here is a image of the drag. If the dock is released there, the reported bug will occur.

Can’t check it out here at work, but I would say that’s the same behavior as if you first minimize a Dockable and then click onto the button that represents the Dockable.

So are you saying the reported behaviour is correct? If so, is there a way to customize it? I would like to have, always, the dock showed as minimised or not. That is, if the button that represents the minimised dock is visible, then the dock is not, and vice versa. That seems to me as a more logical behaviour, but its your framework hehe.

This behavior is in the framework since the first version -a change it would be tricky.

And it is not that unlogical :stuck_out_tongue: : if the button is pressed the dockable appears - if not, then not. You might also have noticed that the dockable sticks to the parent-frame: move or resize the frame and the dockable will be moved and resized as well. So this is not exactly externalized.

I agree, its not exactly externalised. The this is, then, can it be made so that when the user drags the dock to the area mentioned, the button will appear, but not the window. If the user wants to do it, he can click the button to show the window. Dragging the window to see it reappear in the same place with the only change being the appearing of a its button is not really what I wanted.

Hm, needs a litte workaround, and I’m not sure whether this will work on all computers. The dockable appears because it still has the focus. So an idea would be to remove the focus as soon the dockable is minimized. Like this:


import java.awt.Color;
import java.awt.EventQueue;
import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;

import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CLocation;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.common.SingleCDockable;
import bibliothek.gui.dock.common.event.CDockableAdapter;
import bibliothek.gui.dock.common.event.CDockableStateListener;
import bibliothek.gui.dock.common.intern.CDockable;

public class Example{
	public static void main( String[] args ){
		JFrame frame = new JFrame();
		
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		
		final CControl control = new CControl( frame );
		
		frame.setLayout( new GridLayout( 1, 1 ) );
		frame.add( control.getContentArea() );
		
		CDockableStateListener listener = new CDockableAdapter(){
			@Override
			public void minimized( CDockable dockable ){
				EventQueue.invokeLater( new Runnable(){
					@Override
					public void run(){
						control.intern().getController().setFocusedDockable( null, false );		
					}
				});
				
			}
		};
		control.addStateListener( listener );
		
		SingleCDockable red = create( "Red", Color.RED );
		SingleCDockable green = create( "Green", Color.GREEN );
		SingleCDockable blue = create( "Blue", Color.BLUE );
		
		control.add( red );
		control.add( green );
		control.add( blue );
		
		red.setVisible( true );
		
		green.setLocation( CLocation.base().normalSouth( 0.4 ));
		green.setVisible( true );
		
		blue.setLocation( CLocation.base().normalEast( 0.3 ) );
		blue.setVisible( true );
		
		frame.setBounds( 20, 20, 400, 400 );
		frame.setVisible( true );
	}
	
	public static SingleCDockable create( String title, Color color ){
		JPanel background = new JPanel();
		background.setOpaque( true );
		background.setBackground( color );
		
		return new DefaultSingleCDockable( title, title, background );
	}
}