SPB Git

Repository Public

TypographyControls.swift 26.0 KB 390 lines swift

1// ORIX Docs2// File: App/Sources/Inspector/TypographyControls.swift3// Description: The character and paragraph control groups of the Typography Studio. They edit a "format target" (the selection or4//              a named style) so the Styles tab reuses exactly the same controls.5//6// Author: Simon-Pierre Boucher7// Contact: contact@spboucher.ai8import SwiftUI9import DocModel10import DocLayout1112/// What a group of character controls edits.13struct CharacterTarget {14    /// The effective values shown by the controls.15    var resolved: ResolvedChar16    /// Properties set at this level (direct formatting, or the style's own properties).17    var direct: CharProps18    /// Properties inherited by this level.19    var base: CharProps20    /// Applies a change as one undoable step: action name, coalescing key, mutation.21    var apply: (String, String?, (inout CharProps) -> Void) -> Void22}2324/// What a group of paragraph controls edits.25struct ParagraphTarget {26    var resolved: ResolvedPara27    var direct: ParaProps28    var base: ParaProps29    var apply: (String, String?, (inout ParaProps) -> Void) -> Void30}3132// MARK: - Character3334struct CharacterGroups: View {35    let target: CharacterTarget36    /// Prefix of the groups' identifiers ("format" or "style").37    let scopeID: String38    @State private var customLanguage = false3940    private var r: ResolvedChar { target.resolved }41    private var d: CharProps { target.direct }4243    private func set(_ name: String, key: String? = nil, _ change: (inout CharProps) -> Void) { target.apply(name, key.map { "\(scopeID)-\($0)" }, change) }44    private func reset(_ set: Bool, _ name: String, _ change: @escaping (inout CharProps) -> Void) -> (() -> Void)? {45        set ? { target.apply(name, nil, change) } : nil46    }4748    static let languages = ["en", "en-CA", "en-US", "en-GB", "fr", "fr-CA", "fr-FR", "es", "de", "it", "pt"]49    static func languageName(_ tag: String) -> String {50        guard !tag.isEmpty else { return String(localized: "Document language") }51        return (Locale.current.localizedString(forIdentifier: tag)?.capitalized(with: .current)).map { "\($0) (\(tag))" } ?? tag52    }5354    var body: some View {55        InspectorGroup("Font", id: "\(scopeID).font") {56            PropertyRow("Family", onReset: reset(d.fontFamily != nil, String(localized: "Font")) { $0.fontFamily = nil }) {57                FontFamilyPicker(current: r.fontFamily, identifier: "\(scopeID)-font-family") { f in set(String(localized: "Font")) { $0.fontFamily = f } }58            }59            PropertyRow("Weight", onReset: reset(d.weight != nil || d.bold != nil, String(localized: "Font Weight")) { $0.weight = nil; $0.bold = nil }) {60                let weights = Array(Set(FontCatalog.shared.weights(for: r.fontFamily) + [r.weight])).sorted()61                ChoicePopup(selection: r.weight, options: weights.map { ($0, FontCatalog.weightName($0)) }, width: 118, label: "Font weight", identifier: "\(scopeID)-font-weight") { w in62                    set(String(localized: "Font Weight")) { p in63                        // Regular and bold stay expressed with `bold` (what Word understands); other weights use the numeric weight, which overrides it.64                        if w == 400 { p.weight = nil; p.bold = false } else if w == 700 { p.weight = nil; p.bold = true } else { p.weight = w }65                    }66                }67            }68            PropertyRow("Size", onReset: reset(d.fontSize != nil, String(localized: "Font Size")) { $0.fontSize = nil }) {69                ValueField(value: r.fontSize, range: 4...400, step: 1, decimals: 1, suffix: "pt", width: 76, label: "Font size", identifier: "\(scopeID)-font-size") { v in70                    set(String(localized: "Font Size"), key: "size") { $0.fontSize = v }71                }72            }73            HStack(spacing: 0) {74                BarButton(symbol: "bold", help: "Bold", isOn: r.isBold) { set(String(localized: "Bold")) { $0.bold = !r.isBold; $0.weight = nil } }75                    .accessibilityIdentifier("\(scopeID)-bold")76                BarButton(symbol: "italic", help: "Italic", isOn: r.italic) { set(String(localized: "Italic")) { $0.italic = !r.italic } }77                    .accessibilityIdentifier("\(scopeID)-italic")78                BarButton(symbol: "underline", help: "Underline", isOn: r.underline) { set(String(localized: "Underline")) { $0.underline = !r.underline } }79                BarButton(symbol: "strikethrough", help: "Strikethrough", isOn: r.strikethrough) { set(String(localized: "Strikethrough")) { $0.strikethrough = !r.strikethrough } }80                Spacer(minLength: 2)81                BarButton(symbol: "textformat.superscript", help: "Superscript", isOn: r.vertical == .superscript) {82                    set(String(localized: "Superscript")) { $0.vertical = r.vertical == .superscript ? .baseline : .superscript }83                }84                BarButton(symbol: "textformat.subscript", help: "Subscript", isOn: r.vertical == .subscript) {85                    set(String(localized: "Subscript")) { $0.vertical = r.vertical == .subscript ? .baseline : .subscript }86                }87                Spacer(minLength: 2)88                GlyphButton(glyph: "Tᴛ", help: "Small capitals", isOn: r.smallCaps) { set(String(localized: "Small Capitals")) { $0.smallCaps = !r.smallCaps; if !r.smallCaps { $0.allCaps = nil } } }89                GlyphButton(glyph: "TT", help: "All capitals", isOn: r.allCaps) { set(String(localized: "All Capitals")) { $0.allCaps = !r.allCaps; if !r.allCaps { $0.smallCaps = nil } } }90                    .accessibilityIdentifier("\(scopeID)-allcaps")91            }92            PropertyRow("Text colour", onReset: reset(d.color != nil, String(localized: "Text Colour")) { $0.color = nil }) {93                SwatchMenu(help: "Text colour", current: r.color, identifier: "\(scopeID)-color") { c in set(String(localized: "Text Colour"), key: "color") { $0.color = c } }94            }95            PropertyRow("Highlight", onReset: reset(d.highlight != nil, String(localized: "Highlight")) { $0.highlight = nil }) {96                SwatchMenu(help: "Highlight", current: r.highlight, allowsNone: true, palette: ColorMenu.highlights, identifier: "\(scopeID)-highlight") { c in97                    // "None" over an inherited highlight needs an explicit transparent value: nil only means "inherit".98                    let inherited = (target.base.highlight?.a ?? 0) > 099                    set(String(localized: "Highlight"), key: "highlight") { $0.highlight = c ?? (inherited ? RGBA(r: 1, g: 1, b: 1, a: 0) : nil) }100                }101            }102        }103        InspectorGroup("Spacing and Features", id: "\(scopeID).features") {104            PropertyRow("Tracking", onReset: reset(d.tracking != nil, String(localized: "Tracking")) { $0.tracking = nil }) {105                ValueField(value: r.tracking, range: -5...40, step: 0.1, decimals: 2, suffix: "pt", width: 76, label: "Character spacing", identifier: "\(scopeID)-tracking") { v in106                    set(String(localized: "Tracking"), key: "tracking") { $0.tracking = v }107                }108            }109            PropertyRow("Baseline shift", onReset: reset(d.baselineShift != nil, String(localized: "Baseline Shift")) { $0.baselineShift = nil }) {110                ValueField(value: r.baselineShift, range: -100...100, step: 0.5, decimals: 1, suffix: "pt", width: 76, label: "Baseline shift, positive is up") { v in111                    set(String(localized: "Baseline Shift"), key: "baseline") { $0.baselineShift = v }112                }113            }114            SwitchRow("Kerning", isOn: r.kerning, onReset: reset(d.kerning != nil, String(localized: "Kerning")) { $0.kerning = nil }) { on in115                set(String(localized: "Kerning")) { $0.kerning = on }116            }117            SwitchRow("Ligatures", isOn: r.ligatures, onReset: reset(d.ligatures != nil, String(localized: "Ligatures")) { $0.ligatures = nil }, identifier: "\(scopeID)-ligatures") { on in118                set(String(localized: "Ligatures")) { $0.ligatures = on }119            }120            let lang = r.language ?? ""121            PropertyRow("Language", onReset: reset(d.language != nil, String(localized: "Language")) { $0.language = nil }) {122                InspectorPopup(CharacterGroups.languageName(lang), width: 150, label: "Language for spelling and hyphenation", identifier: "\(scopeID)-language") {123                    ForEach(CharacterGroups.languages, id: \.self) { tag in124                        Button { customLanguage = false; set(String(localized: "Language")) { $0.language = tag } } label: {125                            if tag == lang { Label(CharacterGroups.languageName(tag), systemImage: "checkmark") } else { Text(CharacterGroups.languageName(tag)) }126                        }127                    }128                    Divider()129                    Button("Other…") { customLanguage = true }130                }131            }132            if customLanguage || !(lang.isEmpty || CharacterGroups.languages.contains(lang)) {133                PropertyRow("Language tag") {134                    InspectorTextField(text: lang, placeholder: "pt-BR", monospaced: true, label: "BCP 47 language tag") { tag in135                        let t = tag.trimmingCharacters(in: .whitespaces)136                        guard !t.isEmpty, t.count <= 35, t.allSatisfy({ $0.isLetter || $0.isNumber || $0 == "-" }) else { return }137                        set(String(localized: "Language")) { $0.language = t }138                    }139                    .frame(width: 110)140                }141            }142        }143    }144}145146// MARK: - Paragraph147148private enum LineMode: Hashable { case multiple, exact, atLeast }149private enum FirstLineMode: Hashable { case none, firstLine, hanging }150151struct ParagraphGroups: View {152    let target: ParagraphTarget153    let scopeID: String154    /// Font size at the target, used to seed fixed line heights.155    let fontSize: Double156157    private var r: ResolvedPara { target.resolved }158    private var d: ParaProps { target.direct }159160    private func set(_ name: String, key: String? = nil, _ change: (inout ParaProps) -> Void) { target.apply(name, key.map { "\(scopeID)-\($0)" }, change) }161    private func reset(_ set: Bool, _ name: String, _ change: @escaping (inout ParaProps) -> Void) -> (() -> Void)? {162        set ? { target.apply(name, nil, change) } : nil163    }164165    private var lineMode: LineMode {166        switch r.lineSpacing { case .multiple: return .multiple; case .exact: return .exact; case .atLeast: return .atLeast }167    }168    private var lineValue: Double {169        switch r.lineSpacing { case .multiple(let v), .exact(let v), .atLeast(let v): return v }170    }171172    var body: some View {173        InspectorGroup("Paragraph", id: "\(scopeID).paragraph") {174            PropertyRow("Alignment", onReset: reset(d.alignment != nil, String(localized: "Alignment")) { $0.alignment = nil }) {175                IconSegments(items: [.init(value: TextAlignment.left, symbol: "text.alignleft", title: String(localized: "Align Left")),176                                     .init(value: .center, symbol: "text.aligncenter", title: String(localized: "Centre")),177                                     .init(value: .right, symbol: "text.alignright", title: String(localized: "Align Right")),178                                     .init(value: .justified, symbol: "text.justify", title: String(localized: "Justify"))],179                             selection: r.alignment, identifier: "\(scopeID)-align") { a in set(String(localized: "Alignment")) { $0.alignment = a } }180            }181            PropertyRow("Line spacing", onReset: reset(d.lineSpacing != nil, String(localized: "Line Spacing")) { $0.lineSpacing = nil }) {182                ChoicePopup(selection: lineMode, options: [(.multiple, String(localized: "Multiple")), (.exact, String(localized: "Exactly")), (.atLeast, String(localized: "At least"))],183                            width: 78, label: "Line spacing rule", identifier: "\(scopeID)-line-mode") { mode in184                    guard mode != lineMode else { return }185                    let natural = (fontSize * 1.2).rounded()186                    let points = lineMode == .multiple ? (natural * lineValue).rounded() : lineValue187                    set(String(localized: "Line Spacing")) { p in188                        switch mode {189                        case .multiple: p.lineSpacing = .multiple(lineMode == .multiple ? lineValue : max(0.5, ((lineValue / natural) * 20).rounded() / 20))190                        case .exact: p.lineSpacing = .exact(points)191                        case .atLeast: p.lineSpacing = .atLeast(points)192                        }193                    }194                }195                if lineMode == .multiple {196                    ValueField(value: lineValue, range: 0.5...5, step: 0.05, decimals: 2, suffix: "×", width: 64, label: "Line spacing multiple", identifier: "\(scopeID)-line-value") { v in197                        set(String(localized: "Line Spacing"), key: "line") { $0.lineSpacing = .multiple(v) }198                    }199                } else {200                    ValueField(value: lineValue, range: 4...400, step: 1, decimals: 1, suffix: "pt", width: 64, label: "Line height", identifier: "\(scopeID)-line-value") { v in201                        set(String(localized: "Line Spacing"), key: "line") { $0.lineSpacing = lineMode == .exact ? .exact(v) : .atLeast(v) }202                    }203                }204            }205            PropertyRow("Space before", onReset: reset(d.spaceBefore != nil, String(localized: "Space Before")) { $0.spaceBefore = nil }) {206                ValueField(value: r.spaceBefore, range: 0...400, step: 1, decimals: 1, suffix: "pt", width: 76, label: "Space before the paragraph", identifier: "\(scopeID)-space-before") { v in207                    set(String(localized: "Space Before"), key: "before") { $0.spaceBefore = v }208                }209            }210            PropertyRow("Space after", onReset: reset(d.spaceAfter != nil, String(localized: "Space After")) { $0.spaceAfter = nil }) {211                ValueField(value: r.spaceAfter, range: 0...400, step: 1, decimals: 1, suffix: "pt", width: 76, label: "Space after the paragraph", identifier: "\(scopeID)-space-after") { v in212                    set(String(localized: "Space After"), key: "after") { $0.spaceAfter = v }213                }214            }215        }216        InspectorGroup("Indents", id: "\(scopeID).indents") {217            PropertyRow("Left", onReset: reset(d.indentLeft != nil, String(localized: "Left Indent")) { $0.indentLeft = nil }) {218                ValueField(value: r.indentLeft, range: 0...720, step: 3, decimals: 1, suffix: "pt", width: 76, label: "Left indent", identifier: "\(scopeID)-indent-left") { v in219                    set(String(localized: "Left Indent"), key: "indent-left") { $0.indentLeft = v }220                }221            }222            PropertyRow("Right", onReset: reset(d.indentRight != nil, String(localized: "Right Indent")) { $0.indentRight = nil }) {223                ValueField(value: r.indentRight, range: 0...720, step: 3, decimals: 1, suffix: "pt", width: 76, label: "Right indent") { v in224                    set(String(localized: "Right Indent"), key: "indent-right") { $0.indentRight = v }225                }226            }227            let mode: FirstLineMode = r.firstLineIndent > 0 ? .firstLine : (r.firstLineIndent < 0 ? .hanging : .none)228            PropertyRow("First line", onReset: reset(d.firstLineIndent != nil, String(localized: "First Line Indent")) { $0.firstLineIndent = nil }) {229                ChoicePopup(selection: mode, options: [(.none, String(localized: "None")), (.firstLine, String(localized: "Indent")), (.hanging, String(localized: "Hanging"))],230                            width: 78, label: "First line", identifier: "\(scopeID)-first-line-mode") { m in231                    let magnitude = abs(r.firstLineIndent) > 0 ? abs(r.firstLineIndent) : 18232                    set(String(localized: "First Line Indent")) { p in233                        switch m {234                        case .none: p.firstLineIndent = 0235                        case .firstLine: p.firstLineIndent = magnitude236                        case .hanging:237                            p.firstLineIndent = -magnitude238                            // A hanging first line needs room on its left.239                            if r.indentLeft < magnitude { p.indentLeft = magnitude }240                        }241                    }242                }243                ValueField(value: abs(r.firstLineIndent), range: 0...360, step: 3, decimals: 1, suffix: "pt", width: 64, label: "First line indent", isEnabled: mode != .none) { v in244                    set(String(localized: "First Line Indent"), key: "first-line") { p in245                        p.firstLineIndent = mode == .hanging ? -v : v246                        if mode == .hanging, r.indentLeft < v { p.indentLeft = v }247                    }248                }249            }250        }251        InspectorGroup("Layout and Flow", id: "\(scopeID).flow") {252            PropertyRow("Drop cap", onReset: reset(d.dropCapLines != nil, String(localized: "Drop Cap")) { $0.dropCapLines = nil }) {253                ChoicePopup(selection: r.dropCapLines < 2 ? 0 : min(5, r.dropCapLines),254                            options: [(0, String(localized: "Off"))] + (2...5).map { ($0, String(localized: "\($0) lines")) },255                            width: 96, label: "Drop cap", identifier: "\(scopeID)-dropcap") { n in set(String(localized: "Drop Cap")) { $0.dropCapLines = n } }256            }257            SwitchRow("Hyphenation", isOn: r.hyphenate, onReset: reset(d.hyphenate != nil, String(localized: "Hyphenation")) { $0.hyphenate = nil }, identifier: "\(scopeID)-hyphenate") { on in258                set(String(localized: "Hyphenation")) { $0.hyphenate = on }259            }260            SwitchRow("Keep with next", isOn: r.keepWithNext, onReset: reset(d.keepWithNext != nil, String(localized: "Keep with Next")) { $0.keepWithNext = nil }) { on in261                set(String(localized: "Keep with Next")) { $0.keepWithNext = on }262            }263            SwitchRow("Keep lines together", isOn: r.keepLinesTogether, onReset: reset(d.keepLinesTogether != nil, String(localized: "Keep Lines Together")) { $0.keepLinesTogether = nil }) { on in264                set(String(localized: "Keep Lines Together")) { $0.keepLinesTogether = on }265            }266            SwitchRow("Page break before", isOn: r.pageBreakBefore, onReset: reset(d.pageBreakBefore != nil, String(localized: "Page Break Before")) { $0.pageBreakBefore = nil }) { on in267                set(String(localized: "Page Break Before")) { $0.pageBreakBefore = on }268            }269            SwitchRow("Widow and orphan control", isOn: r.widowControl, onReset: reset(d.widowControl != nil, String(localized: "Widow and Orphan Control")) { $0.widowControl = nil }) { on in270                set(String(localized: "Widow and Orphan Control")) { $0.widowControl = on }271            }272            SwitchRow("Right-to-left", isOn: r.rightToLeft, onReset: reset(d.rightToLeft != nil, String(localized: "Text Direction")) { $0.rightToLeft = nil }) { on in273                set(String(localized: "Text Direction")) { $0.rightToLeft = on }274            }275        }276        InspectorGroup("Shading and Borders", id: "\(scopeID).borders") {277            PropertyRow("Shading", onReset: reset(d.shading != nil, String(localized: "Paragraph Shading")) { $0.shading = nil }) {278                SwatchMenu(help: "Paragraph shading", current: r.shading, allowsNone: true, palette: ColorMenu.highlights, identifier: "\(scopeID)-shading") { c in279                    let inherited = (target.base.shading?.a ?? 0) > 0280                    set(String(localized: "Paragraph Shading"), key: "shading") { $0.shading = c ?? (inherited ? RGBA(r: 1, g: 1, b: 1, a: 0) : nil) }281                }282            }283            borderRow("Top border", \.borderTop, name: String(localized: "Top Border"), key: "border-top")284            borderRow("Bottom border", \.borderBottom, name: String(localized: "Bottom Border"), key: "border-bottom")285            borderRow("Left border", \.borderLeft, name: String(localized: "Left Border"), key: "border-left")286        }287        InspectorGroup("Tab Stops", id: "\(scopeID).tabs") {288            TabStopsEditor(tabs: r.tabs, isOverride: d.tabs != nil, scopeID: scopeID) { name, key, tabs in289                set(name, key: key) { $0.tabs = tabs }290            }291        }292    }293294    private func resolvedBorder(_ path: KeyPath<ResolvedPara, BorderLine?>) -> BorderLine? { r[keyPath: path].flatMap { $0.width > 0 ? $0 : nil } }295296    /// One paragraph border: switch, width and colour. (The engine draws paragraph rules solid.)297    private func borderRow(_ label: LocalizedStringKey, _ path: WritableKeyPath<ParaProps, BorderLine?>, name: String, key: String) -> some View {298        let resolvedPath: KeyPath<ResolvedPara, BorderLine?> = path == \ParaProps.borderTop ? \.borderTop : (path == \ParaProps.borderBottom ? \.borderBottom : \.borderLeft)299        let line = resolvedBorder(resolvedPath)300        let inherited = (target.base[keyPath: path]?.width ?? 0) > 0301        return PropertyRow(label, onReset: reset(d[keyPath: path] != nil, name) { $0[keyPath: path] = nil }) {302            if let line {303                ValueField(value: line.width, range: 0.25...12, step: 0.25, decimals: 2, suffix: "pt", width: 66, label: "Border width") { v in304                    set(name, key: key) { $0[keyPath: path] = BorderLine(width: v, color: line.color, style: line.style) }305                }306                SwatchMenu(help: "Border colour", current: line.color) { c in307                    set(name, key: key + "-color") { $0[keyPath: path] = BorderLine(width: line.width, color: c ?? line.color, style: line.style) }308                }309            }310            Toggle(isOn: Binding(get: { line != nil }, set: { on in311                set(name) { p in312                    if on { p[keyPath: path] = BorderLine(width: path == \ParaProps.borderLeft ? 2 : 0.75, color: RGBA(hex: 0x4B5160)) }313                    // Switching off an inherited border needs an explicit zero-width line: nil only means "inherit".314                    else { p[keyPath: path] = inherited ? BorderLine(width: 0) : nil }315                }316            })) { Text(label) }317                .labelsHidden().toggleStyle(.switch).controlSize(.mini)318        }319    }320}321322// MARK: - Tab stops323324struct TabStopsEditor: View {325    let tabs: [TabStop]326    let isOverride: Bool327    let scopeID: String328    /// Action name, coalescing key, new tab list (nil = inherit).329    let commit: (String, String?, [TabStop]?) -> Void330331    private static var kinds: [(TabStop.Kind, String)] {332        [(.left, String(localized: "Left")), (.center, String(localized: "Centre")), (.right, String(localized: "Right")), (.decimal, String(localized: "Decimal"))]333    }334    private static var leaders: [(TabStop.Leader, String)] {335        [(.none, String(localized: "No leader")), (.dots, String(localized: "Dots ····")), (.dashes, String(localized: "Dashes - - -")), (.line, String(localized: "Line ___"))]336    }337    private static func leaderShort(_ l: TabStop.Leader) -> String {338        switch l { case .none: return String(localized: "None"); case .dots: return "····"; case .dashes: return "- - -"; case .line: return "___" }339    }340341    var body: some View {342        if tabs.isEmpty {343            InspectorNote("No custom tab stops. The Tab key moves to the next default position.")344        } else {345            HStack(spacing: 4) {346                Text("Position").frame(width: 66, alignment: .leading)347                Text("Alignment").frame(width: 74, alignment: .leading)348                Text("Leader")349                Spacer(minLength: 0)350            }351            .font(.system(size: 10)).foregroundStyle(ORIX.Palette.textTertiary).accessibilityHidden(true)352            ForEach(Array(tabs.enumerated()), id: \.offset) { index, tab in353                HStack(spacing: 4) {354                    ValueField(value: tab.position, range: 0...1584, step: 6, decimals: 1, suffix: "pt", width: 66, label: "Tab position", identifier: "\(scopeID)-tab-\(index)") { v in355                        var t = tabs; t[index].position = v356                        commit(String(localized: "Tab Stop"), "tab-\(index)", t.sorted { $0.position < $1.position })357                    }358                    ChoicePopup(selection: tab.kind, options: TabStopsEditor.kinds.map { (value: $0.0, title: $0.1) }, width: 74, label: "Tab alignment") { k in359                        var t = tabs; t[index].kind = k360                        commit(String(localized: "Tab Stop"), nil, t)361                    }362                    InspectorPopup(TabStopsEditor.leaderShort(tab.leader), width: 62, label: "Tab leader") {363                        ForEach(TabStopsEditor.leaders, id: \.0) { leader, title in364                            Button { var t = tabs; t[index].leader = leader; commit(String(localized: "Tab Stop"), nil, t) } label: {365                                if leader == tab.leader { Label(title, systemImage: "checkmark") } else { Text(title) }366                            }367                        }368                    }369                    Spacer(minLength: 0)370                    Button { var t = tabs; t.remove(at: index); commit(String(localized: "Remove Tab Stop"), nil, t) } label: {371                        Image(systemName: "minus.circle").font(.system(size: 12)).foregroundStyle(ORIX.Palette.textSecondary).frame(width: 20, height: 22).contentShape(Rectangle())372                    }373                    .buttonStyle(.plain).help("Remove this tab stop").accessibilityLabel(Text("Remove tab stop at \(Int(tab.position)) points"))374                }375            }376        }377        HStack(spacing: ORIX.Space.s) {378            InspectorButton("Add Tab Stop", symbol: "plus", identifier: "\(scopeID)-tab-add") {379                // Half an inch after the last stop.380                let next = ((tabs.map(\.position).max() ?? 0) / 36).rounded(.down) * 36 + 36381                commit(String(localized: "Add Tab Stop"), nil, tabs + [TabStop(position: min(1584, next))])382            }383            if isOverride {384                InspectorButton("Use Inherited", fill: false) { commit(String(localized: "Tab Stops"), nil, nil) }385                    .help("Remove these tab stops and use the ones the style defines")386            }387        }388    }389}390
Files main
Menu

Theme