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

WiP Widget: spinner #150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

WiP Widget: spinner #150

wants to merge 1 commit into from

Conversation

fedejeanne
Copy link

@fedejeanne fedejeanne commented Mar 7, 2025

Initial implementation of the Spinner. I am testing it with Snippet184:

Linux (WSL)
image

Windows
image

FIXME

  • The arrow buttons are too big and can't be resized
  • The text looks different (and odd) in different OSes (tested in Linux and Windows)
  • It is still not possible to validate the input (no line breaks, spaces, characters) since the method Text::addVerifyListener is not properly hooked right now. --> Added to Limitations of custom widget implementations #128

Any hints are appreciated!

@fedejeanne fedejeanne mentioned this pull request Mar 7, 2025
37 tasks
Copy link

github-actions bot commented Mar 7, 2025

Test Results

   338 files  ±0     338 suites  ±0   2m 47s ⏱️ +9s
 3 954 tests ±0   3 670 ✅ ±0  284 💤 ±0  0 ❌ ±0 
11 690 runs  ±0  10 805 ✅ ±0  885 💤 ±0  0 ❌ ±0 

Results for commit 7221725. ± Comparison against base commit 00ae69b.

♻️ This comment has been updated with latest results.

@fedejeanne fedejeanne marked this pull request as ready for review March 11, 2025 12:21
@HeikoKlare
Copy link

  • The arrow buttons are too big and can't be resized

May this just be a limitation in the button implementation? Button is custom-implemented, so it might be easy to change how it behaves for SWT.UP / SWT.DOWN flags.

  • The text looks different (and odd) in different OSes (tested in Linux and Windows)

It looks as if the text widget on Linux is not initialized with proper default values (insufficient height), so it might be a limitation of the custom-imlemented Text widget. In any case, the Text widget should probably be defined to vertically fill the overall layout.

The question is how the proper size for a Spinner should be defined: Do the defaults of the Text widget define the size so that the buttons have to adapt? Do the Button defaults define the size and the Text has to adapt? Or does it define its own defaults and both contained widgets have to fit into it? I have no answer to it, so take this as a pointer. Probably taking a look at how the native widgets behave could give some reasonable indication.

@fedejeanne
Copy link
Author

May this just be a limitation in the button implementation? Button is custom-implemented, so it might be easy to change how it behaves for SWT.UP / SWT.DOWN flags.

Hm, don't think so. They look fine to me here:
image

In any case, the Text widget should probably be defined to vertically fill the overall layout.

Good idea. Done 👍 . It looks better
image

@HeikoKlare
Copy link

Maybe it's because of the used GridLayout, which is not configured and thus mostly uses default values (which, if I am not mistakes, includes several margins).

Initial implementation
@fedejeanne
Copy link
Author

Maybe it's because of the used GridLayout, which is not configured and thus mostly uses default values (which, if I am not mistakes, includes several margins).

I added some more layout/layout data to it and it looks better now. I am using this modified version of Snippet184 to automatically grab the whole space of the shell and this is how it looks like:

public class Snippet184 {

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setText("Snippet 184");
		Spinner spinner = new Spinner (shell, SWT.BORDER);
		spinner.setMinimum(0);
		spinner.setMaximum(1000);
		spinner.setSelection(500);
		spinner.setIncrement(1);
		spinner.setPageIncrement(100);

		shell.setLayout(new GridLayout(1, false));
		spinner.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
		shell.setSize(300, 300);

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

image

image

@tmssngr
Copy link

tmssngr commented Mar 17, 2025

BTW, on Linux the spinner looks like [500 | - | + ]. Sometimes it also supports a unit, e.g. [250ms | - | + ].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants