Skip to content

Commit

Permalink
Fix eclipse-platform#1173 - bad UI on MacOS merge viewer (eclipse-pla…
Browse files Browse the repository at this point in the history
…tform#732)

Implement ContentMergeViewer.computeSize and run toolbar updated async
  • Loading branch information
zulus committed Oct 10, 2023
1 parent e64f742 commit cfba199
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Sash;
import org.eclipse.swt.widgets.Shell;
Expand Down Expand Up @@ -126,8 +127,15 @@ public abstract class ContentMergeViewer extends ContentViewer

private class ContentMergeViewerLayout extends Layout {
@Override
public Point computeSize(Composite c, int w, int h, boolean force) {
return new Point(100, 100);
public Point computeSize(Composite composite, int wHint, int hHint, boolean force) {
if (hHint > SWT.DEFAULT && wHint > SWT.DEFAULT) {
return new Point(wHint, hHint);
}

Rectangle r = composite.getClientArea();


return new Point(r.width, r.height);
}

@Override
Expand Down Expand Up @@ -797,8 +805,12 @@ private void internalRefresh(Object input) {
ToolBarManager tbm = (ToolBarManager) getToolBarManager(fComposite.getParent());
if (tbm != null ) {
updateToolItems();
tbm.update(true);
tbm.getControl().getParent().layout(true);
Display.getDefault().asyncExec(() -> {
// relayout in next tick
tbm.update(true);
tbm.getControl().getParent().setRedraw(true);
});

}
}
}
Expand Down

0 comments on commit cfba199

Please sign in to comment.