first a big „thank you“ for this great docking Framework
Is it possible to have a Dockable that is build itself from „child“ Dockables, in a way that those child Dockables can only be dragged inside of their parent?
To provide more context, for my application I have two „static“ Dockables like the tool view in photoshop, and a set of „dynamic“ Dockables like the image windows in photoshop (I guess WorkingArea would be the right place for those image windows). Now each image window should consist of the image itself and a properties panel. The image should always be in the center region of the image window. The properties panel should be moveable to any border region of the image window (north, west, …) or be minimzed, and should be resizeable (like normal Dockabels are, Splitpanel like).
Is something like this possible, and if so, may I ask, how?
That should be possible. There are two ways I see how this could be achieved (both require a bit of work):
Just use a CWorkingArea (in Common) for representing a window. Minimizing would then mean for a properties panel to move at the side of your frame.
Use a normal Dockable and place a set of stations (e.g. a CContentArea) inside the Dockable. For your case this seems to be a better solution. You have to ensure that the user is not able to drag the image window into itself and create a loop…
In any case with the help of a DockAcceptance you can forbid any child Dockable of an image window to be dragged anywhere else than you’d like.
Questions: would it not be nicer to have one properties panel that dynamically changes its content depending on the current selection? That would require less space.
Thank you Beni for your fast answer. I’ll try it out.
Using just one dynamically changing properties panel - yes, that would be an option, and the saved space may be what makes it in the end. On the other hand, it is more comfortable and easier to understand having each image with it’s own properties. Having just one dynamically changing properties panel would need that the selection state of the selected image is kept and visible when the user clicks into the properties panel. Is that possible?
It is certainly possible to know which image was selected last (there are some focus-listeners available). And you could change the color or font of the title of the selected Dockable *. I don’t know if that will look well or rather odd.
(I proposed this behavior because that is was Eclipse does (image = editor, properties = outline), and in Eclipse it works well without such an indication.)
use “getFonts” and “getColors” for a CDockable to get a map of all fonts/colors (assuming you are using Common).
I’ve implemented it the way you proposed, it just looked better
Just to share it if anybody has the same need, the following is the code I used. Selection color is Orange, and it is assumed that the „special“ Dockable extends some class (in this example called MyDockable).
control.addFocusListener(new CFocusListener() {
final Color selectionColor = Color.ORANGE;
final String[] selectionColorNames = {
ColorMap.COLOR_KEY_TAB_BACKGROUND,
ColorMap.COLOR_KEY_TAB_BACKGROUND_FOCUSED};
Map<String, Color> backupNotSelectedColors;
MyDockable lastWithFocus;
@Override
public void focusLost(CDockable a) {
}
@Override
public void focusGained(CDockable a) {
if (a instanceof MyDockable) {
MyDockable MyDockable = (MyDockable) a;
setSelected(MyDockable);
}
}
private void setSelected(MyDockable MyDockable) {
if (lastWithFocus != null) {
setSelected(lastWithFocus, false);
}
setSelected(MyDockable, true);
lastWithFocus = MyDockable;
}
private void setSelected(CDockable a, boolean selected) {
if (selected) {
if (backupNotSelectedColors == null) {
backupNotSelectedColors = new HashMap<String, Color>();
for (String colorName : selectionColorNames) {
backupNotSelectedColors.put(colorName, a.getColors().getColor(colorName));
}
}
for (String colorName : selectionColorNames) {
a.getColors().setColor(colorName, selectionColor);
}
} else {
if (backupNotSelectedColors != null) {
for (String colorName : selectionColorNames) {
a.getColors().setColor(colorName, backupNotSelectedColors.get(colorName));
}
}
}
}
});