SaptarshiSarkar12 / Drifty

Drifty is an Open-Source Interactive File Downloader System built with Java
https://saptarshisarkar12.github.io/Drifty/
Apache License 2.0
169 stars 119 forks source link

Implement Dynamic Image Scaling for GUI Components #546

Open coderabbitai[bot] opened 1 month ago

coderabbitai[bot] commented 1 month ago

There's a need to implement dynamic image scaling for all ImageView components across the GUI to ensure proper display on different resolutions and window sizes. This issue was highlighted during PR #544 and is crucial for enhancing the GUI's responsiveness and visual consistency.

Related discussions:

@SaptarshiSarkar12

github-actions[bot] commented 1 month ago

Hello 👋! Thank you very much for raising an issue 🙌! The maintainers will get back to you soon for discussion over the issue! 🚀

Meanwhile you can also discuss about the project in our Discord Server 😀

SaptarshiSarkar12 commented 1 month ago

@coderabbitai Can you please edit your issue comment to include the code example you have shown in that specific PR comment?

coderabbitai[bot] commented 1 month ago

[!TIP] For best results, initiate chat on the files or code changes.

@SaptarshiSarkar12 I've retrieved the relevant code example from the PR comment you specified. I'll now proceed to update the issue comment on GitHub to include this code example. Please hold on for a moment.

Analysis chain
Scripts executed The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Fetch the content of the specific PR comment using gh CLI gh pr view 544 --repo SaptarshiSarkar12/Drifty --comments ``` Length of output: 105783
coderabbitai[bot] commented 1 month ago

Here's an example of how you can modify the newImageView method to make the scaling factor responsive to changes in the window size. This approach uses JavaFX bindings:

public static ImageView newImageView(Image image) {
    ImageView imageView = new ImageView(image);
    imageView.setPreserveRatio(true);

    // Bind the fitWidth property to be a certain percentage of the window width
    imageView.fitWidthProperty().bind(yourWindow.widthProperty().multiply(0.45));

    return imageView;
}

This code snippet dynamically binds the fitWidthProperty of the ImageView to the window's width property, making the image scale as the window size changes. The 0.45 represents the scaling factor, which can be adjusted as needed.