Skip to content
This repository was archived by the owner on Nov 7, 2026. It is now read-only.

Commit 9bf2f73

Browse files
committed
Merge branch 'simulation-controller' into palette-view
# Conflicts: # VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/ContentView.swift
2 parents fab9f8f + d9e4351 commit 9bf2f73

4 files changed

Lines changed: 95 additions & 84 deletions

File tree

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/ContentView.swift‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,21 @@ struct ContentView: View {
232232
printDiagram()
233233
#endif
234234
}
235+
.onReceive(NotificationCenter.default.publisher(for: DiagramMenuNotification.sharePNG)) { _ in
236+
guard !isSimulationMode else { return }
237+
exportPNG()
238+
}
239+
.onReceive(NotificationCenter.default.publisher(for: DiagramMenuNotification.shareDocument)) { _ in
240+
guard !isSimulationMode else { return }
241+
shareDocumentAsFile()
242+
}
243+
.onReceive(NotificationCenter.default.publisher(for: DiagramMenuNotification.exportPDF)) { _ in
244+
guard !isSimulationMode else { return }
245+
shareDiagramPDF()
246+
}
247+
.onReceive(NotificationCenter.default.publisher(for: DiagramMenuNotification.showAbout)) { _ in
248+
showInfo = true
249+
}
235250
.onReceive(NotificationCenter.default.publisher(for: DiagramMenuNotification.close)) { _ in
236251
guard !isSimulationMode else { return }
237252
requestCloseDiagramTab(id: tabsModel.selectedTabId)
@@ -497,11 +512,7 @@ struct ContentView: View {
497512
onInsertItem: insertPaletteItem,
498513
onDeleteSelection: deleteSelection,
499514
onToggleSimulation: toggleSimulationMode,
500-
onGenerateCode: openCodeGenerator,
501-
onSharePNG: exportPNG,
502-
onShareDocument: shareDocumentAsFile,
503-
onExportPDF: shareDiagramPDF,
504-
onShowAbout: { showInfo = true }
515+
onGenerateCode: openCodeGenerator
505516
)
506517
}
507518

@@ -618,6 +629,10 @@ struct ContentView: View {
618629
onSave: performPrimarySave,
619630
onSaveAs: { showExporter = true },
620631
onPrint: printAction,
632+
onSharePNG: exportPNG,
633+
onShareDocument: shareDocumentAsFile,
634+
onExportPDF: shareDiagramPDF,
635+
onShowAbout: { showInfo = true },
621636
onKeyboardDismiss: {
622637
focusedField = nil
623638
if isPhone { hideInspectorOnPhone = true }

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/Palette/PaletteActionList.swift‎

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import SwiftUI
22
import VisuStructCore
33

4-
/// Palette (Strukturelemente zum Einfügen/Ziehen) und Aktionen darunter: Löschen, Simulation, Code, Teilen, Export, Info.
4+
/// Palette (Strukturelemente zum Einfügen/Ziehen) und Aktionen darunter: Löschen, Simulation, Code. Teilen, Export und Info stehen im Ablage-Menü.
55
struct PaletteActionList: View {
66
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
77
@Environment(\.appLanguage) private var lang
@@ -13,10 +13,6 @@ struct PaletteActionList: View {
1313
let onDeleteSelection: () -> Void
1414
let onToggleSimulation: () -> Void
1515
let onGenerateCode: () -> Void
16-
let onSharePNG: () -> Void
17-
let onShareDocument: () -> Void
18-
let onExportPDF: () -> Void
19-
let onShowAbout: () -> Void
2016

2117
var body: some View {
2218
let isCompact = horizontalSizeClass != .regular
@@ -85,65 +81,6 @@ struct PaletteActionList: View {
8581
.accessibilityLabel(
8682
codeGeneratorAccessGranted ? lang.tr("a11y_generate_code") : lang.tr("a11y_generate_code_locked")
8783
)
88-
Button {
89-
onSharePNG()
90-
} label: {
91-
Label(lang.tr("action_share_png"), systemImage: "square.and.arrow.up")
92-
.foregroundStyle(isSimulationMode ? .tertiary : .primary)
93-
}
94-
.buttonStyle(PaletteListElementButtonStyle())
95-
.disabledAndDimmed(isSimulationMode)
96-
.listRowInsets(
97-
isCompact
98-
? EdgeInsets(top: 3, leading: 10, bottom: 3, trailing: 10)
99-
: EdgeInsets(top: 5, leading: 12, bottom: 5, trailing: 12)
100-
)
101-
.listRowSeparator(.hidden)
102-
.listRowBackground(Color.clear)
103-
Button {
104-
onShareDocument()
105-
} label: {
106-
Label(lang.tr("action_share_document"), systemImage: "square.and.arrow.up.on.square")
107-
.foregroundStyle(isSimulationMode ? .tertiary : .primary)
108-
}
109-
.buttonStyle(PaletteListElementButtonStyle())
110-
.disabledAndDimmed(isSimulationMode)
111-
.listRowInsets(
112-
isCompact
113-
? EdgeInsets(top: 3, leading: 10, bottom: 3, trailing: 10)
114-
: EdgeInsets(top: 5, leading: 12, bottom: 5, trailing: 12)
115-
)
116-
.listRowSeparator(.hidden)
117-
.listRowBackground(Color.clear)
118-
Button {
119-
onExportPDF()
120-
} label: {
121-
Label(lang.tr("action_export_pdf"), systemImage: "doc.text.magnifyingglass")
122-
.foregroundStyle(isSimulationMode ? .tertiary : .primary)
123-
}
124-
.buttonStyle(PaletteListElementButtonStyle())
125-
.disabledAndDimmed(isSimulationMode)
126-
.listRowInsets(
127-
isCompact
128-
? EdgeInsets(top: 3, leading: 10, bottom: 3, trailing: 10)
129-
: EdgeInsets(top: 5, leading: 12, bottom: 5, trailing: 12)
130-
)
131-
.listRowSeparator(.hidden)
132-
.listRowBackground(Color.clear)
133-
134-
Button {
135-
onShowAbout()
136-
} label: {
137-
Label(lang.tr("action_about"), systemImage: "info.circle")
138-
}
139-
.buttonStyle(PaletteListElementButtonStyle())
140-
.listRowInsets(
141-
isCompact
142-
? EdgeInsets(top: 3, leading: 10, bottom: 4, trailing: 10)
143-
: EdgeInsets(top: 5, leading: 12, bottom: 8, trailing: 12)
144-
)
145-
.listRowSeparator(.hidden)
146-
.listRowBackground(Color.clear)
14784
}
14885
}
14986
.listStyle(.insetGrouped)

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/Toolbar/DiagramMainEditorToolbar.swift‎

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import SwiftUI
22

3-
/// Hauptfenster-Toolbar: Titel, Undo/Redo, Datei-Menü, Palette (iPhone), Tastatur „Fertig“.
3+
/// Hauptfenster-Toolbar: Titel, Undo/Redo, Datei-Menü (inkl. Teilen/Export und Info), Palette (iPhone), Tastatur „Fertig“.
44
/// Diagramm-Reiter liegen in `DiagramTabStrip`.
55
struct DiagramMainEditorToolbar: ToolbarContent {
66
@Environment(\.appLanguage) private var lang
@@ -29,6 +29,11 @@ struct DiagramMainEditorToolbar: ToolbarContent {
2929
/// Nur unter UIKit (Druck); sonst `nil` und kein Eintrag.
3030
let onPrint: (() -> Void)?
3131

32+
let onSharePNG: () -> Void
33+
let onShareDocument: () -> Void
34+
let onExportPDF: () -> Void
35+
let onShowAbout: () -> Void
36+
3237
let onKeyboardDismiss: () -> Void
3338

3439
var body: some ToolbarContent {
@@ -76,8 +81,8 @@ struct DiagramMainEditorToolbar: ToolbarContent {
7681
Menu {
7782
Button(action: onOpenImporter) {
7883
Label(lang.tr("menu_open"), systemImage: "square.and.arrow.down")
79-
.foregroundStyle(isSimulationMode ? .tertiary : .primary)
8084
}
85+
.disabled(isSimulationMode)
8186
Menu {
8287
if recentFiles.isEmpty {
8388
Text(lang.tr("recent_files_empty"))
@@ -97,26 +102,43 @@ struct DiagramMainEditorToolbar: ToolbarContent {
97102
} label: {
98103
Label(lang.tr("recent_files_menu"), systemImage: "clock")
99104
}
105+
.disabled(isSimulationMode)
100106
Divider()
101-
Button(action: onSave) {
102-
Label(lang.tr("menu_save"), systemImage: "arrow.down.doc")
103-
}
104-
Button(action: onSaveAs) {
105-
Label(lang.tr("menu_save_as"), systemImage: "square.and.arrow.up")
107+
Group {
108+
Button(action: onSave) {
109+
Label(lang.tr("menu_save"), systemImage: "arrow.down.doc")
110+
}
111+
Button(action: onSaveAs) {
112+
Label(lang.tr("menu_save_as"), systemImage: "square.and.arrow.up")
113+
}
106114
}
107-
#if canImport(UIKit)
108-
if let onPrint {
109-
Divider()
110-
Button(action: onPrint) {
111-
Label(lang.tr("menu_print"), systemImage: "printer")
115+
.disabled(isSimulationMode)
116+
Section {
117+
Button(action: onShareDocument) {
118+
Label(lang.tr("action_share_document"), systemImage: "square.and.arrow.up.on.square")
119+
}
120+
Button(action: onSharePNG) {
121+
Label(lang.tr("action_share_png"), systemImage: "photo")
122+
}
123+
Button(action: onExportPDF) {
124+
Label(lang.tr("action_export_pdf"), systemImage: "doc.text.magnifyingglass")
112125
}
126+
#if canImport(UIKit)
127+
if let onPrint {
128+
Button(action: onPrint) {
129+
Label(lang.tr("menu_print"), systemImage: "printer")
130+
}
131+
}
132+
#endif
133+
}
134+
.disabled(isSimulationMode)
135+
Divider()
136+
Button(action: onShowAbout) {
137+
Label(lang.tr("action_about"), systemImage: "info.circle")
113138
}
114-
#endif
115139
} label: {
116140
Label(lang.tr("menu_file"), systemImage: "folder")
117-
.foregroundStyle(isSimulationMode ? .tertiary : .primary)
118141
}
119-
.disabledAndDimmed(isSimulationMode)
120142
}
121143
#if canImport(UIKit)
122144
ToolbarItemGroup(placement: .keyboard) {

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/VisuStructApp.swift‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ enum DiagramMenuNotification {
4747
static let printDocument = Notification.Name("visustruct.menu.print")
4848
static let close = Notification.Name("visustruct.menu.close")
4949
static let openRecent = Notification.Name("visustruct.menu.openRecent")
50+
static let sharePNG = Notification.Name("visustruct.menu.sharePNG")
51+
static let shareDocument = Notification.Name("visustruct.menu.shareDocument")
52+
static let exportPDF = Notification.Name("visustruct.menu.exportPDF")
53+
static let showAbout = Notification.Name("visustruct.menu.showAbout")
5054

5155
static let recentFileIDKey = "id"
5256
}
@@ -124,6 +128,22 @@ final class DiagramCommandCenter: ObservableObject {
124128
NotificationCenter.default.post(name: DiagramMenuNotification.close, object: nil)
125129
}
126130

131+
func sharePNG() {
132+
NotificationCenter.default.post(name: DiagramMenuNotification.sharePNG, object: nil)
133+
}
134+
135+
func shareDocument() {
136+
NotificationCenter.default.post(name: DiagramMenuNotification.shareDocument, object: nil)
137+
}
138+
139+
func exportPDF() {
140+
NotificationCenter.default.post(name: DiagramMenuNotification.exportPDF, object: nil)
141+
}
142+
143+
func showAbout() {
144+
NotificationCenter.default.post(name: DiagramMenuNotification.showAbout, object: nil)
145+
}
146+
127147
func openRecent(_ file: RecentVisuStructFile) {
128148
NotificationCenter.default.post(
129149
name: DiagramMenuNotification.openRecent,
@@ -297,6 +317,11 @@ private struct VisuStructCommands: Commands {
297317
}
298318

299319
var body: some Commands {
320+
CommandGroup(replacing: .appInfo) {
321+
Button(lang.tr("action_about")) {
322+
commandCenter.showAbout()
323+
}
324+
}
300325
CommandGroup(replacing: .newItem) {
301326
Button(lang.tr("menu_new")) {
302327
commandCenter.newDocument()
@@ -316,6 +341,18 @@ private struct VisuStructCommands: Commands {
316341
.keyboardShortcut("s", modifiers: [.command, .shift])
317342
.disabled(!commandCenter.canSaveAs)
318343
Divider()
344+
Button(lang.tr("action_share_document")) {
345+
commandCenter.shareDocument()
346+
}
347+
.disabled(!commandCenter.canPrint)
348+
Button(lang.tr("action_share_png")) {
349+
commandCenter.sharePNG()
350+
}
351+
.disabled(!commandCenter.canPrint)
352+
Button(lang.tr("action_export_pdf")) {
353+
commandCenter.exportPDF()
354+
}
355+
.disabled(!commandCenter.canPrint)
319356
Button(lang.tr("menu_print")) {
320357
commandCenter.printDocument()
321358
}

0 commit comments

Comments
 (0)