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

Add non-uniform segment sizing switch #47

Closed
wants to merge 14 commits into from

Conversation

DivineDominion
Copy link
Collaborator

This changes PreferencesStyle.segmentedControl to get an associated value:

public enum PreferencesStyle {
	public enum SegmentSize {
		case fit, uniform
	}
	
	case toolbarItems
	case segmentedControl(size: SegmentSize)
}

With that, you can opt in to not use the widest segmented control size for all segments. I still think the uniform sizing looks best for 2 or 3 segments. But when you have more than 4 panes, the names and large insets become a problem and require very wide windows.

Uniform (old) Fitting (new)
Screenshot 2020-02-20 at 18 59 28 Screenshot 2020-02-20 at 18 59 58

@sindresorhus
Copy link
Owner

Good idea. Can you update the readme too? Maybe include the above comparison table and mention when you would use each style.

@@ -1,6 +1,11 @@
import Cocoa

public enum PreferencesStyle {
public enum SegmentSize {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc comment?

case toolbarItems
case segmentedControl
case segmentedControl(size: SegmentSize)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it technically only the width that changes? Maybe it should be:

Suggested change
case segmentedControl(size: SegmentSize)
case segmentedControl(width: SegmentWidth)

?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, if we decide to go for shrinking the text too, as mentioned in #47 (comment), size does make sense.

@@ -1,6 +1,11 @@
import Cocoa

public enum PreferencesStyle {
public enum SegmentSize {
case fit
case uniform
Copy link
Owner

@sindresorhus sindresorhus Feb 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered a default auto size? Which would switch to fit if uniform causes overflow.

I don't think users ever want this:

Screenshot 2020-02-22 at 14 11 03

So it kinda makes sense to do the right behavior by default.

Copy link
Owner

@sindresorhus sindresorhus Feb 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fit mode, I could fit 5 segmented controls.

Screenshot 2020-02-22 at 14 13 22

What if the user needs more? Have you considered a mode that shrinks the text?

Kinda like the system about dialog:

Screenshot 2020-02-22 at 14 13 48

Like a fitSmall mode.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the .fitSmall idea!

Recently, I've been thinking that we maybe should drop the .uniform size completely. I don't know if anyone actually prefers uniform sizes. 🤔

But if someone really cares about uniform sizes, I'd like to think that they won't like the segment to change style to .fit for some of the tabs, and .uniform for others. The "right thing" here, in my opinion, would be to not encourage sloppy preference windows where the segments jiggle around when you switch the active page.

@sindresorhus WDYT?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recently, I've been thinking that we maybe should drop the .uniform size completely. I don't know if anyone actually prefers uniform sizes. 🤔

I like the uniform style and I don't think we should get rid of it. It looks better than "fit" when there are just a few buttons. For example, in one of my apps, I use uniform style:

Screenshot 2020-06-05 at 23 03 26

But if someone really cares about uniform sizes, I'd like to think that they won't like the segment to change style to .fit for some of the tabs, and .uniform for others. The "right thing" here, in my opinion, would be to not encourage sloppy preference windows where the segments jiggle around when you switch the active page.

Good point. Forgot about my idea about "auto". I didn't consider panes having different size.

@sindresorhus
Copy link
Owner

@DivineDominion Friendly bump. In case you missed my comments :)

@DivineDominion
Copy link
Collaborator Author

I wanted to jump in and implement .fitSmall, but cannot help out with this repo for a while until I get a device with Catalina. That's unfortunate :)

image

@sindresorhus
Copy link
Owner

but cannot help out with this repo for a while until I get a device with Catalina. That's unfortunate :)

I increased the required Xcode version as I thought that Xcode version was required to compile the latest Swift syntax. I've tried decreasing it here: c79a490 Not sure you'll be able to compile though.

@sindresorhus sindresorhus deleted the DivineDominion/segment-sizing-switch branch September 16, 2020 22:31
@DivineDominion
Copy link
Collaborator Author

I won't have time to work on app components until much later this year. What's your plan with this going forward?

@sindresorhus
Copy link
Owner

I moved it to an issue in case anyone else wants to work on it sooner: #62

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.

2 participants