Skip to content

Allowing smaller images to show in the workbench window #3169

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Expand Up @@ -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;

Expand Down Expand Up @@ -791,6 +793,7 @@ private void setOnboardingControlSize(CTabFolder tabFolder, Composite onBoarding
|| onBoardingImage == null || onBoardingImage.isDisposed()) {
return;
}
int imgH = getImageHeight(onBoardingImage);
boolean showComposite = tabFolder.getItemCount() == 0;
boolean compositeVisible = onBoarding.isVisible();
boolean imageVisible = onBoardingImage.isVisible();
Expand All @@ -804,7 +807,15 @@ private void setOnboardingControlSize(CTabFolder tabFolder, Composite onBoarding
if (!new Point(width, height).equals(onBoarding.getSize())) {
onBoarding.setSize(width, height);

boolean showImage = height > ONBOARDING_SHOW_IMAGE_HEIGHT_THRESHOLD;
boolean showImage;
if (imgH > 0 && imgH <= ONBOARDING_SMALL_IMAGE_MAX_HEIGHT) {
// For small images, require a smaller total height (314 overall)
showImage = height >= ONBOARDING_SMALL_IMAGE_REQUIRED_TOTAL
- (ONBOARDING_TOP_SPACING + ONBOARDING_SPACING); // 314 - 32 = 282
} else {
// For larger images, fall back to the original (higher) threshold
showImage = height >= ONBOARDING_SHOW_IMAGE_HEIGHT_THRESHOLD; // e.g., 450 content height
}
if (imageVisible != showImage || showComposite != compositeVisible) {
onBoardingImage.setVisible(showImage);
((GridData) onBoardingImage.getLayoutData()).exclude = !showImage;
Expand All @@ -820,6 +831,23 @@ private void setOnboardingControlSize(CTabFolder tabFolder, Composite onBoarding
}
}

/**
* 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();
}
Expand Down