diff --git a/Chord Provider/ChordProParser/ChordPro.swift b/Chord Provider/ChordProParser/ChordPro.swift index 8b5c4ae..38b2692 100644 --- a/Chord Provider/ChordProParser/ChordPro.swift +++ b/Chord Provider/ChordProParser/ChordPro.swift @@ -44,18 +44,19 @@ enum ChordPro { } case "": /// Empty line; close the section if it has an 'automatic type', - /// else close the section and start a new one with the same label and type + /// else add an empty line in the section if !currentSection.lines.isEmpty { - if currentSection.autoType { + if currentSection.type == .none || currentSection.autoType { song.sections.append(currentSection) currentSection = Song.Section(id: song.sections.count + 1) } else { - song.sections.append(currentSection) - currentSection = Song.Section( - id: song.sections.count + 1, - label: currentSection.label, - type: currentSection.type - ) + /// Start with a fresh line: + var line = Song.Section.Line(id: currentSection.lines.count + 1) + /// Add an empty part + /// - Note: Use a 'space' as text + var part = Song.Section.Line.Part(id: 1, chord: nil, text: " ") + line.parts.append(part) + currentSection.lines.append(line) } } case "#": diff --git a/Chord Provider/Metronome/Low.aif b/Chord Provider/Metronome/Low.aif index ba4a4a4..2123c43 100644 Binary files a/Chord Provider/Metronome/Low.aif and b/Chord Provider/Metronome/Low.aif differ diff --git a/Chord Provider/Metronome/Metronome.swift b/Chord Provider/Metronome/Metronome.swift index ffe637c..35698d2 100644 --- a/Chord Provider/Metronome/Metronome.swift +++ b/Chord Provider/Metronome/Metronome.swift @@ -26,7 +26,7 @@ final class Metronome: ObservableObject { } } /// Bool for the high/low tick and animation - @Published var flip: Bool = false + @Published var flip: Bool = true /// Timing for the next 'tick' private var nextTick: DispatchTime = DispatchTime.distantFuture /// The ID of the 'low' sound diff --git a/Chord Provider/SongModel/Song+Render/Song+Render.swift b/Chord Provider/SongModel/Song+Render/Song+Render.swift index 201c3fa..c6010de 100644 --- a/Chord Provider/SongModel/Song+Render/Song+Render.swift +++ b/Chord Provider/SongModel/Song+Render/Song+Render.swift @@ -85,7 +85,7 @@ extension Song.Render { /// The display options let options: Song.DisplayOptions /// The optional label - var label: String? + var label: String = "" /// Bool if the section is prominent (chorus for example) var prominent: Bool = false @@ -96,7 +96,10 @@ extension Song.Render { switch options.label { case .inline: VStack(alignment: .leading) { - if let label { + if label.isEmpty { + content + .padding(.leading) + } else { switch prominent { case true: ProminentLabel(options: options, label: label) @@ -106,15 +109,12 @@ extension Song.Render { Divider() content .padding(.leading) - } else { - content - .padding(.leading) } } .padding(.top) case .grid: GridRow { - Text(label ?? " ") + Text(label) .padding(.all, prominent ? 10 : 0) .background(prominent ? Color.accentColor.opacity(0.3) : Color.clear, in: RoundedRectangle(cornerRadius: 4)) .frame(minWidth: 100, alignment: .trailing) @@ -125,7 +125,7 @@ extension Song.Render { Rectangle() .frame(width: 1, height: nil, alignment: .leading) .foregroundColor( - prominent || label != nil ? Color.secondary.opacity(0.3) : Color.clear), alignment: .leading + prominent || label.isEmpty ? Color.clear : Color.secondary.opacity(0.3)), alignment: .leading ) .gridColumnAlignment(.leading) } @@ -179,7 +179,13 @@ extension Song.Render { } } } - .modifier(SectionView(options: options, label: section.label ?? "Chorus", prominent: true)) + .modifier( + SectionView( + options: options, + label: section.label.isEmpty ? "Chorus" : section.label, + prominent: true + ) + ) } } @@ -191,8 +197,12 @@ extension Song.Render { let options: Song.DisplayOptions /// The body of the `View` var body: some View { - ProminentLabel(options: options, label: section.label ?? "Repeat Chorus", icon: "arrow.triangle.2.circlepath") - .modifier(SectionView(options: options)) + ProminentLabel( + options: options, + label: section.label.isEmpty ? "Repeat Chorus" : section.label, + icon: "arrow.triangle.2.circlepath" + ) + .modifier(SectionView(options: options)) } } @@ -335,6 +345,7 @@ extension Song.Render { } } } + .frame(maxWidth: 400 * options.scale, alignment: .leading) .modifier(SectionView(options: options, label: section.label)) } } diff --git a/Chord Provider/SongModel/Song+Section.swift b/Chord Provider/SongModel/Song+Section.swift index 3c6c993..79759cb 100644 --- a/Chord Provider/SongModel/Song+Section.swift +++ b/Chord Provider/SongModel/Song+Section.swift @@ -14,7 +14,7 @@ extension Song { /// The unique ID var id: Int /// The optional label of the section - var label: String? + var label: String = "" /// The `Environment type` of the section var type: ChordPro.Environment = .none /// Bool if the Environment is automatic set or not diff --git a/Chord Provider/Views/EditorView/EditorView+directiveMenus.swift b/Chord Provider/Views/EditorView/EditorView+directiveMenus.swift index a6a2a2c..02079e0 100644 --- a/Chord Provider/Views/EditorView/EditorView+directiveMenus.swift +++ b/Chord Provider/Views/EditorView/EditorView+directiveMenus.swift @@ -52,7 +52,9 @@ extension EditorView { } } .labelsHidden() +#if os(macOS) .frame(maxWidth: 75) +#endif } .menuStyle(.button) } diff --git a/Chord Provider/Views/HeaderView.swift b/Chord Provider/Views/HeaderView.swift index 838541b..31336fa 100644 --- a/Chord Provider/Views/HeaderView.swift +++ b/Chord Provider/Views/HeaderView.swift @@ -17,6 +17,10 @@ struct HeaderView: View { HStack(alignment: .center) { General(song: sceneState.song) Details(song: sceneState.song) + if let tempo = sceneState.song.tempo, let bpm = Float(tempo) { + MetronomeView(bpm: bpm) + .padding(.leading) + } ToolbarView.PlayerButtons() } .frame(maxWidth: .infinity) @@ -36,6 +40,10 @@ struct HeaderView: View { General(song: sceneState.song) Details(song: sceneState.song) .labelStyle(.titleAndIcon) + if let tempo = sceneState.song.tempo, let bpm = Float(tempo) { + MetronomeView(bpm: bpm) + .padding(.leading) + } #elseif os(visionOS) Details(song: sceneState.song) .labelStyle(.titleAndIcon) @@ -91,10 +99,6 @@ extension HeaderView { if let time = song.time { Label(time, systemImage: "timer").padding(.leading) } - if let tempo = song.tempo, let bpm = Float(tempo) { - MetronomeView(bpm: bpm) - .padding(.leading) - } } } }