diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java index bc20b90c816c..395c688b48db 100644 --- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java +++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java @@ -201,6 +201,8 @@ public class StackRenderer extends LazyStackRenderer { * this threshold, the image is hidden. */ public static final int ONBOARDING_SHOW_IMAGE_HEIGHT_THRESHOLD = 450; + public static final int ONBOARDING_SMALL_IMAGE_MAX_HEIGHT = 250; // "small" cutoff + public static final int ONBOARDING_SMALL_IMAGE_REQUIRED_TOTAL = 314; // 256 + 32(top/bot) + 32(extra) private MPerspective currentPerspectiveForOnboarding; @@ -790,6 +792,7 @@ private void setOnboardingControlSize(CTabFolder tabFolder, Composite onBoarding || onBoardingImage == null || onBoardingImage.isDisposed()) { return; } + int imgHeight = getImageHeight(onBoardingImage); boolean showComposite = tabFolder.getItemCount() == 0; boolean compositeVisible = onBoarding.isVisible(); boolean imageVisible = onBoardingImage.isVisible(); @@ -802,14 +805,12 @@ private void setOnboardingControlSize(CTabFolder tabFolder, Composite onBoarding int height = folderBounds.height - ONBOARDING_TOP_SPACING - ONBOARDING_SPACING; if (!new Point(width, height).equals(onBoarding.getSize())) { onBoarding.setSize(width, height); - - boolean showImage = height > ONBOARDING_SHOW_IMAGE_HEIGHT_THRESHOLD; + boolean showImage = shouldShowOnboardingImage(height, imgHeight); if (imageVisible != showImage || showComposite != compositeVisible) { onBoardingImage.setVisible(showImage); ((GridData) onBoardingImage.getLayoutData()).exclude = !showImage; onboardingComposite.getParent().layout(true); } - } } else { if (compositeVisible) { @@ -819,6 +820,46 @@ private void setOnboardingControlSize(CTabFolder tabFolder, Composite onBoarding } } + /** + * Checks if the onboarding image should be shown, based on how much vertical + * space is available and the image size. + *

+ *

+ * + * @param contentHeight available space in pixels + * @param imageHeight image height in pixels (0 if none) + * @return true if the image should be shown; false otherwise + */ + private static boolean shouldShowOnboardingImage(int contentHeight, int imageHeight) { + if (imageHeight > 0 && imageHeight <= ONBOARDING_SMALL_IMAGE_MAX_HEIGHT) { + // 314 total minus (top + bottom) = 314 - (30 + 2) = 282 + int required = ONBOARDING_SMALL_IMAGE_REQUIRED_TOTAL - (ONBOARDING_TOP_SPACING + ONBOARDING_SPACING); + return contentHeight >= required; + } + // Larger images fall back to the original (higher) threshold + return contentHeight >= ONBOARDING_SHOW_IMAGE_HEIGHT_THRESHOLD; + } + + /** + * Returns the height of the image assigned to the given label. + * + * @param label the Label widget holding the image + * @return the height in pixels, or 0 if the label has no valid image + */ + private static int getImageHeight(Label label) { + if (label == null || label.isDisposed()) { + return 0; + } + Image img = label.getImage(); + if (img == null || img.isDisposed()) { + return 0; + } + return img.getBounds().height; + } + private boolean getMRUValue() { return getMRUValueFromPreferences(); }