Skip to content

Commit d1bf363

Browse files
committed
Give the settings strip room for the tab the focus page brought
Developer: Seif Hashish Project: HashNotch Summary: Every tab takes an equal share of the strip, so one more tab makes every label narrower. Adding the focus page took "Appearance" from 58.9 points of room to 51.0, against the 52.1 it needs at the smallest it is allowed to shrink to — so it was truncated with an ellipsis, silently, which is how a tab strip fails. The window is 500 points wide rather than 460, and the strip's own measurements — its padding, its spacing, its label size and how far a label may shrink — are named next to the rule that uses them rather than written twice. Verification: - swift build: clean, no warnings. - swift run HashNotchChecks: 1058 checks, all passed. Three are new and two of them measure the real font at the real size: every tab label the app ships fits the share it is given at the width the window ships at, and it does so with at least three points to spare, so the next tab is a decision somebody makes rather than a surprise somebody finds. The third is the degenerate case — a strip with no room asks for none. - The first two were run against the old 460-point width and both failed. - Notchless Macs: the features added in this release touch no geometry at all, confirmed by search, so the island's measurements are unchanged. The fourteen checks covering a notchless island's height at every menu bar size real hardware reports still pass. - README badge and the "Verified, not asserted" line moved from 1055 to 1058.
1 parent a94bac6 commit d1bf363

5 files changed

Lines changed: 104 additions & 11 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to HashNotch are recorded here.
44

55
## Unreleased
66

7+
### Fixed
8+
9+
- **The settings window fits its tabs again.** Every tab takes an equal share of
10+
the strip, so the focus page's tab made all of them narrower — and "Appearance"
11+
ended up a point short of the smallest it is allowed to shrink to, which
12+
truncates it with an ellipsis and says nothing. The window is wider, and the
13+
rule is now measured against the real font rather than looked at.
14+
15+
716
### Added
817

918
- **A focus cycle, with a week behind it.** A stretch of work, a short rest, and

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ What's playing, how fast your internet is, what your battery is doing, how hot t
1717
<img src="https://img.shields.io/badge/Apple%20Silicon-M--series-408CFF?style=flat-square&labelColor=0B0C10" alt="Apple Silicon">
1818
<img src="https://img.shields.io/badge/network-artwork%20only-47D67A?style=flat-square&labelColor=0B0C10" alt="Network: artwork only">
1919
<img src="https://img.shields.io/badge/telemetry-none-47D67A?style=flat-square&labelColor=0B0C10" alt="No telemetry">
20-
<img src="https://img.shields.io/badge/checks-1055%20passing-8FBAFF?style=flat-square&labelColor=0B0C10" alt="1055 automated checks passing">
20+
<img src="https://img.shields.io/badge/checks-1058%20passing-8FBAFF?style=flat-square&labelColor=0B0C10" alt="1058 automated checks passing">
2121
<img src="https://img.shields.io/badge/license-GPL%20v3-AEB7C8?style=flat-square&labelColor=0B0C10" alt="GNU General Public License v3">
2222
</p>
2323

@@ -89,7 +89,7 @@ Switch any of them off, drag to reorder, restyle each one. The panel is yours
8989

9090
**One glance, then gone.** Something that just happened outranks something merely still true. A finished job takes the strip for a few seconds and hands it back to the music.
9191

92-
**Verified, not asserted.** 1055 automated checks run before every push — the parsers, the geometry, the privacy rules, and the arithmetic behind every readout. Every commit is signed.
92+
**Verified, not asserted.** 1058 automated checks run before every push — the parsers, the geometry, the privacy rules, and the arithmetic behind every readout. Every commit is signed.
9393

9494
```
9595
$ swift run HashNotchChecks

‎Sources/HashNotchChecks/main.swift‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3636,6 +3636,54 @@ MainActor.assumeIsolated {
36363636
page: FeatureSettingsPage(title: "Focus", symbol: "target", view: AnyView(EmptyView()))),
36373637
]) == ["Agents", "Focus"]
36383638
)
3639+
// Every tab takes an equal share of the strip, so one more tab makes every
3640+
// label narrower. A label that will not fit is truncated with an ellipsis
3641+
// and nothing says so — which is what adding the focus page did to
3642+
// "Appearance". Measured against the real font at the real size.
3643+
check(
3644+
"every tab label fits the room it is given, at the width the window ships",
3645+
{
3646+
let titles = SettingsTabs.allTitles(features: [
3647+
FeatureDescriptor(id: "activities", title: "Agents", options: [],
3648+
page: FeatureSettingsPage(title: "Agents", symbol: "sparkles", view: AnyView(EmptyView()))),
3649+
FeatureDescriptor(id: "focus", title: "Focus", options: [],
3650+
page: FeatureSettingsPage(title: "Focus", symbol: "target", view: AnyView(EmptyView()))),
3651+
])
3652+
let share = SettingsTabs.share(forTabs: titles.count, windowWidth: SettingsWindowController.windowWidth)
3653+
let font = NSFont.systemFont(
3654+
ofSize: SettingsTabs.labelSize * SettingsTabs.minimumScale, weight: .semibold
3655+
)
3656+
return titles.allSatisfy { title in
3657+
(title as NSString).size(withAttributes: [.font: font]).width <= share
3658+
}
3659+
}()
3660+
)
3661+
check(
3662+
"and the width it ships at is not one point of luck",
3663+
{
3664+
// Two more points of label than the strip has room for is the same
3665+
// failure; this holds a margin so the next tab is a decision rather
3666+
// than a surprise.
3667+
let titles = SettingsTabs.allTitles(features: [
3668+
FeatureDescriptor(id: "a", title: "Agents", options: [],
3669+
page: FeatureSettingsPage(title: "Agents", symbol: "sparkles", view: AnyView(EmptyView()))),
3670+
FeatureDescriptor(id: "f", title: "Focus", options: [],
3671+
page: FeatureSettingsPage(title: "Focus", symbol: "target", view: AnyView(EmptyView()))),
3672+
])
3673+
let share = SettingsTabs.share(forTabs: titles.count, windowWidth: SettingsWindowController.windowWidth)
3674+
let font = NSFont.systemFont(
3675+
ofSize: SettingsTabs.labelSize * SettingsTabs.minimumScale, weight: .semibold
3676+
)
3677+
let widest = titles.map { (($0 as NSString).size(withAttributes: [.font: font]).width) }.max() ?? 0
3678+
return share - widest >= 3
3679+
}()
3680+
)
3681+
check(
3682+
"a strip with no room in it asks for none",
3683+
SettingsTabs.share(forTabs: 0, windowWidth: 500) == 0
3684+
&& SettingsTabs.share(forTabs: 8, windowWidth: 10) == 0
3685+
)
3686+
36393687
check(
36403688
"and a build where no feature brings one gets no tab at all",
36413689
SettingsTabs.suppliedTitles([

‎Sources/HashNotchKit/Settings/SettingsView.swift‎

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ public struct SettingsView: View {
6363
/// what matters is where the row is going, not where the pointer is.
6464
@State private var hoveredRow: String?
6565

66-
enum Section: String, CaseIterable, Identifiable {
66+
package enum Section: String, CaseIterable, Identifiable {
6767
case general, indicators, appearance, alerts, position, privacy
6868
/// A page a FEATURE supplies. Deliberately unnamed here: the tab's
6969
/// words and its symbol come from the feature, because the core does
7070
/// not know what any feature does and should not start now.
7171
case supplied
72-
var id: String { rawValue }
72+
package var id: String { rawValue }
7373

74-
var title: String {
74+
package var title: String {
7575
switch self {
7676
case .general: return "General"
7777
case .indicators: return "Indicators"
@@ -83,7 +83,7 @@ public struct SettingsView: View {
8383
}
8484
}
8585

86-
var symbol: String {
86+
package var symbol: String {
8787
switch self {
8888
case .general: return "gearshape.fill"
8989
case .indicators: return "square.stack.3d.up.fill"
@@ -300,12 +300,12 @@ public struct SettingsView: View {
300300
/// be pushed out. Stacked, each tab needs only as much width as its widest
301301
/// word.
302302
private var tabStrip: some View {
303-
HStack(spacing: 4) {
303+
HStack(spacing: SettingsTabs.spacing) {
304304
ForEach(tabs) { item in
305305
tab(item)
306306
}
307307
}
308-
.padding(.horizontal, 12)
308+
.padding(.horizontal, SettingsTabs.horizontalPadding)
309309
.padding(.top, 10)
310310
.padding(.bottom, 10)
311311
}
@@ -337,12 +337,12 @@ public struct SettingsView: View {
337337
.frame(height: 14)
338338
.foregroundStyle(selected ? settings.accent.color : Color.white.opacity(0.55))
339339
Text(title(for: item))
340-
.font(.system(size: 10, weight: selected ? .semibold : .regular))
340+
.font(.system(size: SettingsTabs.labelSize, weight: selected ? .semibold : .regular))
341341
.foregroundStyle(selected ? Color.white : Color.white.opacity(0.7))
342342
// One line, always. A tab that wraps is taller than its
343343
// neighbours and the whole strip grows to match it.
344344
.lineLimit(1)
345-
.minimumScaleFactor(0.85)
345+
.minimumScaleFactor(SettingsTabs.minimumScale)
346346
}
347347
// Equal shares of whatever width there is, so the strip stays even
348348
// on a display that has squeezed the window narrower.
@@ -1741,6 +1741,32 @@ public struct SettingGroupLabel: View {
17411741
/// vanished without a word — and nothing could have caught that, because the
17421742
/// rule lived inside a `View` where no check can reach it.
17431743
package enum SettingsTabs {
1744+
// The strip's own measurements, named here so the rule below is about the
1745+
// real numbers rather than about numbers that look like them.
1746+
package static let horizontalPadding: CGFloat = 12
1747+
package static let spacing: CGFloat = 4
1748+
package static let labelSize: CGFloat = 10
1749+
package static let minimumScale: CGFloat = 0.85
1750+
1751+
/// How wide each tab is when this many share the strip.
1752+
///
1753+
/// Every tab takes an equal share, so one more tab makes every label
1754+
/// narrower — and a label that will not fit its share is truncated with an
1755+
/// ellipsis rather than reported. Adding the focus page took "Appearance"
1756+
/// from 58.9 points of room to 51.0, against the 52.1 it needs at the
1757+
/// smallest it is allowed to shrink to. It was measured, not noticed.
1758+
package static func share(forTabs count: Int, windowWidth: CGFloat) -> CGFloat {
1759+
guard count > 0 else { return 0 }
1760+
let usable = windowWidth - horizontalPadding * 2 - spacing * CGFloat(count - 1)
1761+
return max(0, usable) / CGFloat(count)
1762+
}
1763+
1764+
/// Every tab title the window would show, fixed pages first.
1765+
package static func allTitles(features: [FeatureDescriptor]) -> [String] {
1766+
SettingsView.Section.allCases.filter { $0 != .supplied }.map(\.title)
1767+
+ suppliedTitles(features)
1768+
}
1769+
17441770
package static func supplied(by features: [FeatureDescriptor]) -> [FeatureSettingsPage] {
17451771
features.compactMap(\.page)
17461772
}

‎Sources/HashNotchKit/Settings/SettingsWindowController.swift‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,17 @@ public final class SettingsWindowController {
7171
/// Indicators 844, Appearance 748 — because three of them are pages of
7272
/// prose and one grows a row per feature. Those scroll, and no window that
7373
/// fits on a laptop screen was ever going to stop them.
74-
private static let size = CGSize(width: 460, height: 760)
74+
/// Wide enough for the tabs the app actually ships.
75+
///
76+
/// It was 460, which fitted seven. The focus page made eight, and eight
77+
/// shares of 460 leave "Appearance" a point short of the smallest it may
78+
/// shrink to — so it was quietly truncated. `SettingsTabs.share` is the rule
79+
/// and the checks hold this width against it.
80+
private static let size = CGSize(width: windowWidth, height: 760)
81+
82+
/// Package-visible so the checks can hold the tab strip against the real
83+
/// width rather than against a number copied next to it.
84+
package static let windowWidth: CGFloat = 500
7585
/// The gap between the island's edge and this one.
7686
private static let gap: CGFloat = 12
7787
/// How far it starts to the left of its resting place, so it reads as

0 commit comments

Comments
 (0)