Lines 16-22
Link Here
|
16 |
|
16 |
|
17 |
import org.eclipse.swt.graphics.Color; |
17 |
import org.eclipse.swt.graphics.Color; |
18 |
|
18 |
|
19 |
import org.eclipse.draw2d.AbstractHintLayout; |
|
|
20 |
import org.eclipse.draw2d.AbstractLayout; |
19 |
import org.eclipse.draw2d.AbstractLayout; |
21 |
import org.eclipse.draw2d.Animation; |
20 |
import org.eclipse.draw2d.Animation; |
22 |
import org.eclipse.draw2d.BorderLayout; |
21 |
import org.eclipse.draw2d.BorderLayout; |
Lines 130-182
Link Here
|
130 |
} |
129 |
} |
131 |
|
130 |
|
132 |
/** |
131 |
/** |
133 |
* Layout manager for the palette stack figure that handles the layout of the |
132 |
* Layout manager for the palette stack header figure that handles the layout of |
134 |
* <code>headerFigure</code>, <code>expandablePane</code>, and |
133 |
* the <code>headerFigure</code> (<code>pinFigure</code>, |
135 |
* <code>pinFigure</code> when in list or details layout mode. |
134 |
* <code>arrowFigure</code>, and the active tool figure) when in list or |
|
|
135 |
* details layout mode. |
136 |
*/ |
136 |
*/ |
137 |
private class PaletteStackListLayout |
137 |
private class HeaderListLayout |
138 |
extends AbstractHintLayout { |
138 |
extends StackLayout { |
139 |
|
139 |
|
140 |
protected boolean isSensitiveVertically(IFigure container) { |
140 |
protected boolean isSensitiveVertically(IFigure container) { |
141 |
return false; |
141 |
return false; |
142 |
} |
142 |
} |
143 |
|
143 |
|
144 |
protected Dimension calculatePreferredSize(IFigure parent, int wHint, int hHint) { |
144 |
protected Dimension calculatePreferredSize(IFigure parent, int wHint, int hHint) { |
145 |
Dimension headerSize = headerFigure.getPreferredSize(wHint, hHint); |
145 |
if (isExpanded()) { |
146 |
|
146 |
Dimension pinSize = pinFigure.getSize(); |
147 |
if (((PinnablePaletteStackFigure) parent).isExpanded()) { |
147 |
Dimension preferredSize = super.calculatePreferredSize(parent, wHint |
148 |
Dimension paneSize = expandablePane.getPreferredSize(wHint, hHint); |
148 |
- pinSize.width, hHint); |
149 |
return new Dimension(Math.max(headerSize.width, paneSize.width), |
149 |
preferredSize.width += pinSize.width; |
150 |
headerSize.height + paneSize.height); |
150 |
return preferredSize; |
151 |
} else { |
151 |
} else { |
152 |
return headerSize; |
152 |
return super.calculatePreferredSize(parent, wHint, hHint); |
153 |
} |
153 |
} |
154 |
} |
154 |
} |
155 |
|
155 |
|
156 |
public void layout(IFigure parent) { |
156 |
public void layout(IFigure parent) { |
157 |
Rectangle clientArea = Rectangle.SINGLETON; |
|
|
158 |
parent.getClientArea(clientArea); |
159 |
int wHint = clientArea.width; |
160 |
int hHint = -1; |
161 |
|
162 |
Rectangle rect = new Rectangle(); |
163 |
rect.setSize(headerFigure.getPreferredSize(wHint, hHint)); |
164 |
rect.setLocation(clientArea.getTopLeft()); |
165 |
headerFigure.setBounds(rect); |
166 |
|
167 |
if (((PinnablePaletteStackFigure) parent).isExpanded()) { |
168 |
rect.translate(0, rect.height); |
169 |
rect.setSize(expandablePane.getPreferredSize(wHint, hHint)); |
170 |
expandablePane.setBounds(rect); |
171 |
|
172 |
rect.setSize(pinFigure.getPreferredSize()); |
173 |
rect.setLocation(headerFigure.getBounds().right() |
174 |
- rect.getSize().width, headerFigure.getBounds().getCenter().y |
175 |
- (rect.getSize().height / 2)); |
176 |
pinFigure.setBounds(rect); |
177 |
|
157 |
|
|
|
158 |
Rectangle r = parent.getClientArea(); |
159 |
List children = parent.getChildren(); |
160 |
IFigure child; |
161 |
|
162 |
Dimension pinSize = isExpanded() ? pinFigure.getPreferredSize() |
163 |
: EMPTY_DIMENSION; |
164 |
|
165 |
for (int i = 0; i < children.size(); i++) { |
166 |
child = (IFigure) children.get(i); |
167 |
if (child == arrowFigure) { |
168 |
Rectangle.SINGLETON.setBounds(r); |
169 |
Rectangle.SINGLETON.width = 11; |
170 |
child.setBounds(Rectangle.SINGLETON); |
171 |
} else if (child == pinFigure) { |
172 |
Rectangle.SINGLETON.setSize(pinSize); |
173 |
Rectangle.SINGLETON.setLocation(r.right() - pinSize.width, r |
174 |
.getCenter().y |
175 |
- (pinSize.height / 2)); |
176 |
child.setBounds(Rectangle.SINGLETON); |
177 |
} else { |
178 |
child.setBounds(r.getResized(-pinSize.width, 0)); |
179 |
} |
178 |
} |
180 |
} |
179 |
|
|
|
180 |
} |
181 |
} |
181 |
} |
182 |
} |
182 |
|
183 |
|
Lines 193-199
Link Here
|
193 |
} |
194 |
} |
194 |
|
195 |
|
195 |
public void layout(IFigure parent) { |
196 |
public void layout(IFigure parent) { |
196 |
if (((PinnablePaletteStackFigure) parent).isExpanded()) { |
197 |
if (isExpanded()) { |
197 |
headerFigure.setBounds(headerBoundsLayoutHint); |
198 |
headerFigure.setBounds(headerBoundsLayoutHint); |
198 |
|
199 |
|
199 |
Rectangle paneBounds = parent.getClientArea(); |
200 |
Rectangle paneBounds = parent.getClientArea(); |
Lines 295-300
Link Here
|
295 |
headerFigure.add(arrowFigure); |
296 |
headerFigure.add(arrowFigure); |
296 |
|
297 |
|
297 |
pinFigure = new PinFigure(); |
298 |
pinFigure = new PinFigure(); |
|
|
299 |
pinFigure.setBorder(new MarginBorder(0, 0, 0, 2)); |
298 |
|
300 |
|
299 |
expandablePane = new Figure(); |
301 |
expandablePane = new Figure(); |
300 |
|
302 |
|
Lines 336-343
Link Here
|
336 |
.getTopRight().getTranslated(-1, 1)); |
338 |
.getTopRight().getTranslated(-1, 1)); |
337 |
g.drawLine(headerBounds.getBottomLeft().getTranslated(1, 0), |
339 |
g.drawLine(headerBounds.getBottomLeft().getTranslated(1, 0), |
338 |
headerBounds.getTopLeft().getTranslated(1, 1)); |
340 |
headerBounds.getTopLeft().getTranslated(1, 1)); |
339 |
g.drawLine(headerBounds.getBottomRight().getTranslated(-1, 0), |
341 |
g.drawLine(headerBounds.getBottomRight().getTranslated(-2, 0), |
340 |
headerBounds.getTopRight().getTranslated(-1, 1)); |
342 |
headerBounds.getTopRight().getTranslated(-2, 1)); |
341 |
|
343 |
|
342 |
g.drawLine(pinAreaBounds.getTopLeft().getTranslated(0, 1), |
344 |
g.drawLine(pinAreaBounds.getTopLeft().getTranslated(0, 1), |
343 |
pinAreaBounds.getTopRight().getTranslated(-1, 1)); |
345 |
pinAreaBounds.getTopRight().getTranslated(-1, 1)); |
Lines 350-359
Link Here
|
350 |
points.addPoint(headerBounds.getTopLeft().getTranslated(0, 2)); |
352 |
points.addPoint(headerBounds.getTopLeft().getTranslated(0, 2)); |
351 |
points.addPoint(headerBounds.getTopLeft().getTranslated(1, 1)); |
353 |
points.addPoint(headerBounds.getTopLeft().getTranslated(1, 1)); |
352 |
points.addPoint(headerBounds.getTopLeft().getTranslated(2, 0)); |
354 |
points.addPoint(headerBounds.getTopLeft().getTranslated(2, 0)); |
353 |
points.addPoint(headerBounds.getTopRight().getTranslated(-2, 0)); |
355 |
points.addPoint(headerBounds.getTopRight().getTranslated(-3, 0)); |
354 |
points.addPoint(headerBounds.getTopRight().getTranslated(-1, 1)); |
356 |
points.addPoint(headerBounds.getTopRight().getTranslated(-2, 1)); |
355 |
points.addPoint(headerBounds.getTopRight().getTranslated(0, 2)); |
357 |
points.addPoint(headerBounds.getTopRight().getTranslated(-1, 2)); |
356 |
points.addPoint(headerBounds.getBottomRight()); |
358 |
points.addPoint(headerBounds.getBottomRight().getTranslated(-1, 0)); |
357 |
points.addPoint(pinAreaBounds.getTopRight().getTranslated(-1, 0)); |
359 |
points.addPoint(pinAreaBounds.getTopRight().getTranslated(-1, 0)); |
358 |
points.addPoint(paneBounds.getBottomRight().getTranslated(-1, -1)); |
360 |
points.addPoint(paneBounds.getBottomRight().getTranslated(-1, -1)); |
359 |
points.addPoint(paneBounds.getBottomLeft().getTranslated(0, -1)); |
361 |
points.addPoint(paneBounds.getBottomLeft().getTranslated(0, -1)); |
Lines 368-376
Link Here
|
368 |
g.drawPoint(pt.x, pt.y); |
370 |
g.drawPoint(pt.x, pt.y); |
369 |
pt = headerBounds.getTopLeft().getTranslated(1, 0); |
371 |
pt = headerBounds.getTopLeft().getTranslated(1, 0); |
370 |
g.drawPoint(pt.x, pt.y); |
372 |
g.drawPoint(pt.x, pt.y); |
371 |
pt = headerBounds.getTopRight().getTranslated(-1, 0); |
373 |
pt = headerBounds.getTopRight().getTranslated(-2, 0); |
372 |
g.drawPoint(pt.x, pt.y); |
374 |
g.drawPoint(pt.x, pt.y); |
373 |
pt = headerBounds.getTopRight().getTranslated(0, 1); |
375 |
pt = headerBounds.getTopRight().getTranslated(-1, 1); |
374 |
g.drawPoint(pt.x, pt.y); |
376 |
g.drawPoint(pt.x, pt.y); |
375 |
} else { |
377 |
} else { |
376 |
|
378 |
|
Lines 427-432
Link Here
|
427 |
return isExpanded() && pinFigure.getModel().isSelected(); |
429 |
return isExpanded() && pinFigure.getModel().isSelected(); |
428 |
} |
430 |
} |
429 |
|
431 |
|
|
|
432 |
/** |
433 |
* Pins or unpins the stack. The stack can be pinned open only when it is |
434 |
* expanded. Attempts to pin it when it is collapsed will do nothing. |
435 |
* |
436 |
* @param pinned |
437 |
* <code>true</code> if the stack is to be pinned |
438 |
*/ |
439 |
public void setPinned(boolean pinned) { |
440 |
if (isExpanded()) { |
441 |
pinFigure.setSelected(pinned); |
442 |
} |
443 |
} |
444 |
|
430 |
public void setExpanded(boolean value) { |
445 |
public void setExpanded(boolean value) { |
431 |
arrowFigure.setSelected(value); |
446 |
arrowFigure.setSelected(value); |
432 |
if (!value) { |
447 |
if (!value) { |
Lines 448-478
Link Here
|
448 |
if (newLayoutMode == PaletteViewerPreferences.LAYOUT_LIST |
463 |
if (newLayoutMode == PaletteViewerPreferences.LAYOUT_LIST |
449 |
|| newLayoutMode == PaletteViewerPreferences.LAYOUT_DETAILS) { |
464 |
|| newLayoutMode == PaletteViewerPreferences.LAYOUT_DETAILS) { |
450 |
|
465 |
|
451 |
headerFigure.setLayoutManager(new StackLayout() { |
466 |
headerFigure.setLayoutManager(new HeaderListLayout()); |
452 |
|
|
|
453 |
public void layout(IFigure figure) { |
454 |
Rectangle r = figure.getClientArea(); |
455 |
List children = figure.getChildren(); |
456 |
IFigure child; |
457 |
for (int i = 0; i < children.size(); i++) { |
458 |
child = (IFigure) children.get(i); |
459 |
if (child == arrowFigure) { |
460 |
Rectangle.SINGLETON.setBounds(r); |
461 |
Rectangle.SINGLETON.width = 11; |
462 |
child.setBounds(Rectangle.SINGLETON); |
463 |
} else { |
464 |
child.setBounds(r); |
465 |
} |
466 |
} |
467 |
} |
468 |
}); |
469 |
|
467 |
|
470 |
expandablePane.setLayoutManager(new ToolbarLayout()); |
468 |
expandablePane.setLayoutManager(new ToolbarLayout()); |
471 |
expandablePane.setBorder(new MarginBorder(1, 0, 1, 0)); |
469 |
expandablePane.setBorder(new MarginBorder(1, 0, 1, 0)); |
472 |
setLayoutManager(new PaletteStackListLayout()); |
470 |
setLayoutManager(new ToolbarLayout()); |
473 |
|
471 |
|
474 |
} else { |
472 |
} else { |
475 |
|
|
|
476 |
headerFigure.setLayoutManager(new BorderLayout()); |
473 |
headerFigure.setLayoutManager(new BorderLayout()); |
477 |
if (activeToolFigure != null) { |
474 |
if (activeToolFigure != null) { |
478 |
headerFigure.setConstraint(activeToolFigure, BorderLayout.CENTER); |
475 |
headerFigure.setConstraint(activeToolFigure, BorderLayout.CENTER); |
Lines 482-488
Link Here
|
482 |
setLayoutManager(new PaletteStackIconLayout()); |
479 |
setLayoutManager(new PaletteStackIconLayout()); |
483 |
|
480 |
|
484 |
// account for space used by pin figure |
481 |
// account for space used by pin figure |
485 |
expandablePane.setBorder(new MarginBorder(18, 2, 2, 2)); |
482 |
expandablePane.setBorder(new MarginBorder(18, 0, 0, 0)); |
486 |
|
483 |
|
487 |
if (layoutMode == PaletteViewerPreferences.LAYOUT_COLUMNS) { |
484 |
if (layoutMode == PaletteViewerPreferences.LAYOUT_COLUMNS) { |
488 |
expandablePane.setLayoutManager(new ColumnsLayout()); |
485 |
expandablePane.setLayoutManager(new ColumnsLayout()); |
Lines 515-526
Link Here
|
515 |
if (isExpanded()) { |
512 |
if (isExpanded()) { |
516 |
if (expandablePane.getParent() != this) { |
513 |
if (expandablePane.getParent() != this) { |
517 |
add(expandablePane); |
514 |
add(expandablePane); |
518 |
add(pinFigure); |
515 |
|
|
|
516 |
if (layoutMode == PaletteViewerPreferences.LAYOUT_LIST |
517 |
|| layoutMode == PaletteViewerPreferences.LAYOUT_DETAILS) { |
518 |
headerFigure.add(pinFigure); |
519 |
} else { |
520 |
add(pinFigure); |
521 |
} |
519 |
} |
522 |
} |
520 |
} else { |
523 |
} else { |
521 |
if (expandablePane.getParent() == this) { |
524 |
if (expandablePane.getParent() == this) { |
522 |
remove(expandablePane); |
525 |
remove(expandablePane); |
523 |
remove(pinFigure); |
526 |
pinFigure.getParent().remove(pinFigure); |
524 |
} |
527 |
} |
525 |
} |
528 |
} |
526 |
} |
529 |
} |