Skip to content
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

Scaling of ColorDialog not working properly after DPI change #141

Closed
ShahzaibIbrahim opened this issue Nov 5, 2024 · 0 comments · Fixed by eclipse-platform/eclipse.platform.swt#1593
Assignees
Labels
HiDPI A HiDPI-Related Issue or Feature SWT Issue for SWT
Milestone

Comments

@ShahzaibIbrahim
Copy link

ShahzaibIbrahim commented Nov 5, 2024

Scaling of ColorDialog breaks during dpi change. In this screenshot, it is 100 -> 150

Image

Image

Test Example:

public class ColorDialogTest {

    public static void main(String[] args) {
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setText("ColorDialog Example");
        shell.setSize(300, 200);
        GridData data = new GridData(GridData.FILL_BOTH);
		shell.setLayoutData(data);
        // Create a button to open the color dialog
        Button button = new Button(shell, SWT.PUSH);
        button.setText("Choose Color");
        button.setBounds(50, 50, 100, 30);

        // Add a listener to open the ColorDialog when button is clicked
        button.addListener(SWT.Selection, event -> {
            ColorDialog colorDialog = new ColorDialog(shell, SWT.APPLICATION_MODAL);
            colorDialog.setText("Select a Color");


            // Open the dialog and get the selected color
            RGB selectedColor = colorDialog.open();

            if (selectedColor != null) {
                // Apply the selected color as the shell background
                Color color = new Color(display, selectedColor);
                shell.setBackground(color);

                // Dispose of the color when done
                shell.addListener(SWT.Dispose, e -> color.dispose());
            }
        });

        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        display.dispose();
    }

Run the example with the following VM Arguments

-Dswt.autoScale=quarter
-Dswt.autoScale.updateOnRuntime=true
@ShahzaibIbrahim ShahzaibIbrahim self-assigned this Nov 5, 2024
@ShahzaibIbrahim ShahzaibIbrahim converted this from a draft issue Nov 5, 2024
@ShahzaibIbrahim ShahzaibIbrahim added SWT Issue for SWT HiDPI A HiDPI-Related Issue or Feature labels Nov 5, 2024
@ShahzaibIbrahim ShahzaibIbrahim added this to the 4.35 M1 milestone Nov 5, 2024
@github-project-automation github-project-automation bot moved this from 👀 In Review to ✅ Done in HiDPI Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HiDPI A HiDPI-Related Issue or Feature SWT Issue for SWT
Projects
Status: Done
1 participant