Skip to content

Commit

Permalink
Merge pull request #27 from FrancisCrickInstitute/hotfix/resizing_and…
Browse files Browse the repository at this point in the history
…_x11_pt2

Allowed for dimension differences on X11 RDs
  • Loading branch information
JonathanCSmith authored Feb 6, 2025
2 parents c95aa1c + 25c1e62 commit d61b8ab
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,14 @@ public TWOMBLIWindow(TWOMBLIConfigurator plugin, ImagePlus previewImage, ImagePl
sidePanelConstraints.weighty = 1;
this.sidePanel.add(Box.createVerticalBox(), sidePanelConstraints);

// X11 RD Dimensions
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int width = (int) (screenSize.width * 0.4);
int height = (int) (screenSize.height * 0.6);

// Scroll bar
JScrollPane sidePanelScroll = new JScrollPane(sidePanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
sidePanelScroll.setMinimumSize(new Dimension(350, 400));
JScrollPane sidePanelScroll = new JScrollPane(this.sidePanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
sidePanelScroll.setMinimumSize(new Dimension(width / 4, height));
sidePanelScroll.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);

// Content panel
Expand All @@ -482,7 +487,7 @@ public TWOMBLIWindow(TWOMBLIConfigurator plugin, ImagePlus previewImage, ImagePl
contentPanelConstraints.gridheight = 1;
contentPanelConstraints.gridx = 0;
contentPanelConstraints.gridy = 0;
contentPanelConstraints.weightx = 1;
contentPanelConstraints.weightx = 0.5;
contentPanelConstraints.weighty = 1;

// Image display
Expand All @@ -494,7 +499,7 @@ public TWOMBLIWindow(TWOMBLIConfigurator plugin, ImagePlus previewImage, ImagePl
// Side panel for controls
contentPanelConstraints.gridx++;
contentPanelConstraints.weightx = 0.3;
contentPanelConstraints.weighty = 0;
contentPanelConstraints.weighty = 1;
contentPanel.add(sidePanelScroll, contentPanelConstraints);

// Core window layout properties
Expand All @@ -516,8 +521,12 @@ public TWOMBLIWindow(TWOMBLIConfigurator plugin, ImagePlus previewImage, ImagePl
this.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
super.componentResized(e);
canvas.fitToWindow();
SwingUtilities.invokeLater(() -> {
super.componentResized(e);
canvas.fitToWindow();
sidePanel.revalidate();
sidePanel.repaint();
});
}
});
}
Expand Down

0 comments on commit d61b8ab

Please sign in to comment.