Skip to content

Commit

Permalink
Fixes two problems of fullscreen views. Adds debug info.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisDrogoul committed May 22, 2022
1 parent a270112 commit bcb8bd4
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 7 deletions.
Expand Up @@ -316,7 +316,7 @@ public boolean step(final IScope scope) {
try {
Thread.sleep(5);
} catch (InterruptedException e) {
e.printStackTrace();
// e.printStackTrace();
}
}
}
Expand Down
Expand Up @@ -104,7 +104,7 @@ public void hideCanvas() {
@Override
public void showCanvas() {
getGLCanvas().setVisible(true);
getGLCanvas().reparentWindow();
// getGLCanvas().reparentWindow();
}

/**
Expand Down
Expand Up @@ -235,6 +235,7 @@ public void toggleFullScreen() {
normalParentOfFullScreenControl.requestLayout();
destroyFullScreenShell();
} else {
ViewsHelper.activate(view);
fullScreenShell = createFullScreenShell();
if (fullScreenShell == null) return;
fs.setImage(GamaIcons.create("display.fullscreen3").image());
Expand Down Expand Up @@ -420,6 +421,7 @@ private void destroyFullScreenShell() {
fullScreenShell.dispose();
fullScreenShell = null;
ViewsHelper.unregisterFullScreenView(view);
ViewsHelper.activate(view);
}

/**
Expand Down
Expand Up @@ -184,7 +184,6 @@ public CentralPanel(final Composite c) {
setLayout(emptyLayout());
setLayoutData(fullData());
setParentComposite(this);
// form.setMaximizedControl(this);
}

/**
Expand Down Expand Up @@ -352,7 +351,7 @@ protected IStatus run(final IProgressMonitor monitor) {
// synchronizer.waitForSurfaceToBeRealized();
// DEBUG.OUT("UPDATE THREAD: Surface has been realized");

if (!disposed && !surface.isDisposed()) {
if (surface != null && !disposed && !surface.isDisposed()) {
try {
// synchronizer.waitForViewUpdateAuthorisation();

Expand Down Expand Up @@ -482,14 +481,18 @@ public void close(final IScope scope) {
closing = true;
WorkbenchHelper.asyncRun(() -> {
try {
if (getDisplaySurface() != null) { getDisplaySurface().dispose(); }
IDisplaySurface surface = getDisplaySurface();
if (surface != null) { surface.dispose(); }
ViewsHelper.hideView(this);
} catch (final Exception e) {}
});

}

@Override
public boolean isVisible() { return getDisplaySurface().isVisible() || isFullScreen(); }
public boolean isVisible() {
IDisplaySurface surface = getDisplaySurface();
return surface != null && surface.isVisible() || isFullScreen();
}

}
10 changes: 10 additions & 0 deletions ummisco.gama.ui.shared/src/ummisco/gama/ui/utils/ViewsHelper.java
Expand Up @@ -296,4 +296,14 @@ public static void unregisterFullScreenView(final IGamaView.Display view) {
});
}

/**
* Activate.
*
* @param view
* the view
*/
public static void activate(final IWorkbenchPart view) {
WorkbenchHelper.getPage().activate(view);
}

}
Expand Up @@ -18,6 +18,9 @@

import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Point;
Expand Down Expand Up @@ -51,7 +54,7 @@
* @author drogoul
*/
public abstract class GamaViewPart extends ViewPart
implements DisposeListener, IGamaView, IToolbarDecoratedView, ITooltipDisplayer {
implements DisposeListener, IGamaView, IToolbarDecoratedView, ITooltipDisplayer, ControlListener {

static {
DEBUG.ON();
Expand Down Expand Up @@ -136,6 +139,17 @@ public GamaUIJob() {
@Override
public void reset() {}

/**
* Gets the top composite.
*
* @return the top composite
*/
public Composite getTopComposite() {
Composite c = rootComposite;
while (!(c.getParent() instanceof CTabFolder)) { c = c.getParent(); }
return c;
}

@Override
public void addStateListener(final StateListener listener) {
toolbarUpdater = listener;
Expand Down Expand Up @@ -242,7 +256,9 @@ public boolean containsPoint(final int x, final int y) {
@Override
public void createPartControl(final Composite composite) {
this.rootComposite = composite;
// DEBUG.OUT("Root Composite is " + composite.getClass().getSimpleName());
composite.addDisposeListener(this);
getTopComposite().addControlListener(this);
if (needsOutput() && getOutput() == null) return;
this.setParentComposite(GamaToolbarFactory.createToolbars(this, composite));
ownCreatePartControl(getParentComposite());
Expand Down Expand Up @@ -437,4 +453,14 @@ public void setName(final String name) {
@Override
public boolean isVisible() { return true; }

@Override
public void controlMoved(final ControlEvent e) {
DEBUG.OUT("View " + this.getTitle() + " moved to " + rootComposite.getParent().toDisplay(0, 0));
}

@Override
public void controlResized(final ControlEvent e) {
DEBUG.OUT("View " + this.getTitle() + " resized to " + rootComposite.getSize());
}

}

0 comments on commit bcb8bd4

Please sign in to comment.