Skip to content

Commit

Permalink
FindReplaceOverlay: avoid inconsistent borders eclipse-platform#2194
Browse files Browse the repository at this point in the history
When the replace toggle in the FindReplaceOverlay is not shown because
the target file is read-only or because the editor is too small to show
the toggle button, the right border of the overlay is larger than the
others. The reason is an inconsistent layout, as the container always
expects two columns of elements but when the replace toggle is hidden
only one column is present.

With this change, the number of columns of the container is adapted
according to whether the replace toggle is present or not.

Fixed eclipse-platform#2194
  • Loading branch information
HeikoKlare committed Nov 2, 2024
1 parent 462666b commit 6d57b4b
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
Expand Down Expand Up @@ -695,9 +696,10 @@ private void enableReplaceToggle(boolean enable) {
if (!okayToUse(replaceToggle)) {
return;
}
boolean visible = enable && findReplaceLogic.getTarget().isEditable();
((GridData) replaceToggleTools.getLayoutData()).exclude = !visible;
replaceToggleTools.setVisible(visible);
boolean shouldBeVisible = enable && findReplaceLogic.getTarget().isEditable();
((GridLayout) containerControl.getLayout()).numColumns = shouldBeVisible ? 2 : 1;
((GridData) replaceToggleTools.getLayoutData()).exclude = !shouldBeVisible;
replaceToggleTools.setVisible(shouldBeVisible);
}

private void enableReplaceTools(boolean enable) {
Expand Down

0 comments on commit 6d57b4b

Please sign in to comment.