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

PoC - FlyoutPaletteComposite with custom area #692

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2024 IBM Corporation and others.
* Copyright (c) 2004, 2025 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -134,6 +134,7 @@
private PaletteViewer externalViewer;
private IMemento capturedPaletteState;
private Control graphicalControl;
private final Control customArea;
private final Composite sash;
private final PaletteViewerProvider provider;
private final FlyoutPreferences prefs;
Expand Down Expand Up @@ -187,6 +188,7 @@
provider = pvProvider;
prefs = preferences;
sash = createSash();
customArea = createCustomArea();
paletteContainer = createPaletteContainer();
hookIntoWorkbench(page.getWorkbenchWindow());

Expand Down Expand Up @@ -223,6 +225,28 @@
});
}

/**
* Creates and returns the contents of an area which appears to the right (if
* the palette is docked west) or to the left (if the palette is docked east) of
* the sash.
* <p>
* The default implementation of this method returns {@code null}. Subclasses
* may override.
* </p>
*
* @since 3.21
*/
protected Control createCustomArea() {
Composite c = new Composite(this, SWT.NONE) {
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
return new Point(15, -1);
}
};
c.setBackground(ColorConstants.darkGreen);
return c;
}

private void addListenerToCtrlHierarchy(Control parent, int eventType, Listener listener) {
parent.addListener(eventType, listener);
if (!(parent instanceof Composite)) {
Expand Down Expand Up @@ -331,6 +355,11 @@
return;
}

int customWidth = 0;
if (customArea != null) {
customWidth = customArea.computeSize(-1, -1).x;
}

int sashWidth = sash.computeSize(-1, -1).x;
int pWidth = paletteWidth;
int maxWidth = Math.min(area.width / 2, MAX_PALETTE_SIZE);
Expand All @@ -357,13 +386,16 @@
setRedraw(false);
}
if (isInState(STATE_HIDDEN)) {
if (customArea != null) {
customArea.setVisible(false);
}
sash.setVisible(false);
paletteContainer.setVisible(false);
graphicalControl.setBounds(area);
} else if (dock == PositionConstants.EAST) {
layoutComponentsEast(area, sashWidth, pWidth);
layoutComponentsEast(area, sashWidth, pWidth, customWidth);
} else {
layoutComponentsWest(area, sashWidth, pWidth);
layoutComponentsWest(area, sashWidth, pWidth, customWidth);
}
sash.layout();
// #65892 see above
Expand All @@ -373,12 +405,15 @@
update();
}

private void layoutComponentsEast(Rectangle area, int sashWidth, int pWidth) {
private void layoutComponentsEast(Rectangle area, int sashWidth, int pWidth, int customWidth) {
if (isInState(STATE_COLLAPSED)) {
paletteContainer.setVisible(false);
sash.setBounds(area.x + area.width - sashWidth, area.y, sashWidth, area.height);
sash.setVisible(true);
graphicalControl.setBounds(area.x, area.y, area.width - sashWidth, area.height);
if (customArea != null) {
customArea.setVisible(false);
}
} else if (isInState(STATE_EXPANDED)) {
paletteContainer.moveAbove(graphicalControl);
sash.moveAbove(paletteContainer);
Expand All @@ -387,21 +422,35 @@
sash.setVisible(true);
paletteContainer.setVisible(true);
graphicalControl.setBounds(area.x, area.y, area.width - sashWidth, area.height);
if (customArea != null) {
customArea.setVisible(true);
customArea.setBounds(area.x + area.width - pWidth - sashWidth - customWidth, area.y, customWidth,
area.height);
customArea.moveAbove(sash);
}
} else if (isInState(STATE_PINNED_OPEN)) {
sash.setBounds(area.x + area.width - pWidth - sashWidth, area.y, sashWidth, area.height);
paletteContainer.setBounds(area.x + area.width - pWidth, area.y, pWidth, area.height);
sash.setVisible(true);
paletteContainer.setVisible(true);
graphicalControl.setBounds(area.x, area.y, area.width - sashWidth - pWidth, area.height);
graphicalControl.setBounds(area.x, area.y, area.width - sashWidth - pWidth - customWidth, area.height);
if (customArea != null) {
customArea.setVisible(true);
customArea.setBounds(area.x + area.width - pWidth - sashWidth - customWidth, area.y, customWidth,
area.height);
}
}
}

private void layoutComponentsWest(Rectangle area, int sashWidth, int pWidth) {
private void layoutComponentsWest(Rectangle area, int sashWidth, int pWidth, int customWidth) {
if (isInState(STATE_COLLAPSED)) {
paletteContainer.setVisible(false);
sash.setBounds(area.x, area.y, sashWidth, area.height);
sash.setVisible(true);
graphicalControl.setBounds(area.x + sashWidth, area.y, area.width - sashWidth, area.height);
if (customArea != null) {
customArea.setVisible(false);
}
} else if (isInState(STATE_EXPANDED)) {
paletteContainer.setVisible(true);
paletteContainer.moveAbove(graphicalControl);
Expand All @@ -410,13 +459,22 @@
paletteContainer.setBounds(area.x, area.y, pWidth, area.height);
sash.setVisible(true);
graphicalControl.setBounds(area.x + sashWidth, area.y, area.width - sashWidth, area.height);
if (customArea != null) {
customArea.setVisible(true);
customArea.setBounds(area.x + pWidth + sashWidth, area.y, customWidth, area.height);
customArea.moveAbove(sash);
}
} else if (isInState(STATE_PINNED_OPEN)) {
paletteContainer.setVisible(true);
sash.setBounds(area.x + pWidth, area.y, sashWidth, area.height);
paletteContainer.setBounds(area.x, area.y, pWidth, area.height);
sash.setVisible(true);
graphicalControl.setBounds(area.x + pWidth + sashWidth, area.y, area.width - sashWidth - pWidth,
area.height);
graphicalControl.setBounds(area.x + pWidth + sashWidth + customWidth, area.y,
area.width - sashWidth - pWidth - customWidth, area.height);
if (customArea != null) {
customArea.setVisible(true);
customArea.setBounds(area.x + pWidth + sashWidth, area.y, customWidth, area.height);
}
}
}

Expand Down Expand Up @@ -907,7 +965,7 @@

private class TitleDragManager extends MouseAdapter implements Listener, MouseTrackListener {
protected boolean switchDock = false;
protected boolean dragging = false;

Check warning on line 968 in org.eclipse.gef/src/org/eclipse/gef/ui/palette/FlyoutPaletteComposite.java

View check run for this annotation

Jenkins - Eclipse GEF / Java Compiler

tycho-compiler:compile

NORMAL:
protected int threshold;

public TitleDragManager(Control ctrl) {
Expand Down Expand Up @@ -1565,17 +1623,17 @@
if (cursors[code] == null) {
switch (code) {
case LEFT:
cursors[LEFT] = createCursor(ISharedImages.IMG_OBJS_DND_LEFT_SOURCE,

Check warning on line 1626 in org.eclipse.gef/src/org/eclipse/gef/ui/palette/FlyoutPaletteComposite.java

View check run for this annotation

Jenkins - Eclipse GEF / Java Compiler

tycho-compiler:compile

NORMAL:
ISharedImages.IMG_OBJS_DND_LEFT_MASK);

Check warning on line 1627 in org.eclipse.gef/src/org/eclipse/gef/ui/palette/FlyoutPaletteComposite.java

View check run for this annotation

Jenkins - Eclipse GEF / Java Compiler

tycho-compiler:compile

NORMAL:
break;
case RIGHT:
cursors[RIGHT] = createCursor(ISharedImages.IMG_OBJS_DND_RIGHT_SOURCE,

Check warning on line 1630 in org.eclipse.gef/src/org/eclipse/gef/ui/palette/FlyoutPaletteComposite.java

View check run for this annotation

Jenkins - Eclipse GEF / Java Compiler

tycho-compiler:compile

NORMAL:
ISharedImages.IMG_OBJS_DND_RIGHT_MASK);

Check warning on line 1631 in org.eclipse.gef/src/org/eclipse/gef/ui/palette/FlyoutPaletteComposite.java

View check run for this annotation

Jenkins - Eclipse GEF / Java Compiler

tycho-compiler:compile

NORMAL:
break;
default:
case INVALID:
cursors[INVALID] = createCursor(ISharedImages.IMG_OBJS_DND_INVALID_SOURCE,

Check warning on line 1635 in org.eclipse.gef/src/org/eclipse/gef/ui/palette/FlyoutPaletteComposite.java

View check run for this annotation

Jenkins - Eclipse GEF / Java Compiler

tycho-compiler:compile

NORMAL:
ISharedImages.IMG_OBJS_DND_INVALID_MASK);

Check warning on line 1636 in org.eclipse.gef/src/org/eclipse/gef/ui/palette/FlyoutPaletteComposite.java

View check run for this annotation

Jenkins - Eclipse GEF / Java Compiler

tycho-compiler:compile

NORMAL:
break;
}
}
Expand Down
Loading