From 964643faf3fce32e2a4633dff824c702f1ab6560 Mon Sep 17 00:00:00 2001 From: shima11 Date: Mon, 18 Mar 2024 18:37:30 +0900 Subject: [PATCH] update --- Dev/Sources/SwiftUIDemo/DemoMaskingView.swift | 25 ++++++++++++++++++- .../Drawing/BlurryMaskingView.swift | 13 ++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Dev/Sources/SwiftUIDemo/DemoMaskingView.swift b/Dev/Sources/SwiftUIDemo/DemoMaskingView.swift index 66ed9a6b..a4b3a04a 100644 --- a/Dev/Sources/SwiftUIDemo/DemoMaskingView.swift +++ b/Dev/Sources/SwiftUIDemo/DemoMaskingView.swift @@ -6,12 +6,35 @@ struct DemoMaskingView: View { @ObjectEdge var editingStack: EditingStack + @State var brushSize: CanvasView.BrushSize = .point(30) + init(editingStack: @escaping () -> EditingStack) { self._editingStack = .init(wrappedValue: editingStack()) } var body: some View { - SwiftUIBlurryMaskingView(editingStack: editingStack) + VStack { + SwiftUIBlurryMaskingView(editingStack: editingStack) + .blushSize(brushSize) + + HStack { + Button(action: { + brushSize = .point(10) + }, label: { + Text("10") + }) + Button(action: { + brushSize = .point(30) + }, label: { + Text("30") + }) + Button(action: { + brushSize = .point(50) + }, label: { + Text("50") + }) + } + } } } diff --git a/Sources/BrightroomUI/Shared/Components/Drawing/BlurryMaskingView.swift b/Sources/BrightroomUI/Shared/Components/Drawing/BlurryMaskingView.swift index a8f05899..3429a7e2 100644 --- a/Sources/BrightroomUI/Shared/Components/Drawing/BlurryMaskingView.swift +++ b/Sources/BrightroomUI/Shared/Components/Drawing/BlurryMaskingView.swift @@ -283,6 +283,8 @@ public struct SwiftUIBlurryMaskingView: UIViewControllerRepresentable { private let editingStack: EditingStack + private var _brushSize: CanvasView.BrushSize? + public init( editingStack: EditingStack ) { @@ -300,6 +302,17 @@ public struct SwiftUIBlurryMaskingView: UIViewControllerRepresentable { public func updateUIViewController(_ uiViewController: _PixelEditor_WrapperViewController, context: Context) { + if let _brushSize { + uiViewController.bodyView.setBrushSize(_brushSize) + } + } + + public func blushSize(_ brushSize: CanvasView.BrushSize?) -> Self { + + var modified = self + modified._brushSize = brushSize + return modified } + }