@@ -295,13 +295,6 @@ extension GraphLayout {
295295}
296296
297297// Drawing.
298- fileprivate var debuggingEnabled = false
299- extension Renderer {
300- var debug : Renderer ? {
301- guard debuggingEnabled else { _onFastPath ( ) ; return nil }
302- return self
303- }
304- }
305298
306299extension GraphLayout {
307300
@@ -345,7 +338,7 @@ extension GraphLayout {
345338 let rect = Rect ( origin: Point ( plotExternalRect. minX, plotExternalRect. maxY + t_height) ,
346339 size: Size ( width: plotExternalRect. width, height: itemSize. height) )
347340 t_height += itemSize. height
348- renderer. debug ? . drawSolidRect ( rect, fillColor: Color . random ( ) . withAlpha ( 1 ) , hatchPattern: . none)
341+ renderer. debugLayoutComponents ? . drawSolidRect ( rect, fillColor: Color . random ( ) . withAlpha ( 1 ) , hatchPattern: . none)
349342 item. draw ( rect, measuredSize: itemSize, edge: . top, renderer: renderer)
350343 }
351344 // Bottom components.
@@ -355,7 +348,7 @@ extension GraphLayout {
355348 let rect = Rect ( origin: Point ( plotExternalRect. minX, plotExternalRect. minY - b_height - itemSize. height) ,
356349 size: Size ( width: plotExternalRect. width, height: itemSize. height) )
357350 b_height += itemSize. height
358- renderer. debug ? . drawSolidRect ( rect, fillColor: Color . random ( ) . withAlpha ( 1 ) , hatchPattern: . none)
351+ renderer. debugLayoutComponents ? . drawSolidRect ( rect, fillColor: Color . random ( ) . withAlpha ( 1 ) , hatchPattern: . none)
359352 item. draw ( rect, measuredSize: itemSize, edge: . bottom, renderer: renderer)
360353 }
361354 // Right components.
@@ -365,7 +358,7 @@ extension GraphLayout {
365358 let rect = Rect ( origin: Point ( plotExternalRect. maxX + r_width, plotExternalRect. minY) ,
366359 size: Size ( width: itemSize. width, height: plotExternalRect. height) )
367360 r_width += itemSize. width
368- renderer. debug ? . drawSolidRect ( rect, fillColor: Color . random ( ) . withAlpha ( 1 ) , hatchPattern: . none)
361+ renderer. debugLayoutComponents ? . drawSolidRect ( rect, fillColor: Color . random ( ) . withAlpha ( 1 ) , hatchPattern: . none)
369362 item. draw ( rect, measuredSize: itemSize, edge: . right, renderer: renderer)
370363 }
371364 // Left components.
@@ -375,7 +368,7 @@ extension GraphLayout {
375368 let rect = Rect ( origin: Point ( plotExternalRect. minX - l_width - itemSize. width, plotExternalRect. minY) ,
376369 size: Size ( width: itemSize. width, height: plotExternalRect. height) )
377370 l_width += itemSize. width
378- renderer. debug ? . drawSolidRect ( rect, fillColor: Color . random ( ) . withAlpha ( 1 ) , hatchPattern: . none)
371+ renderer. debugLayoutComponents ? . drawSolidRect ( rect, fillColor: Color . random ( ) . withAlpha ( 1 ) , hatchPattern: . none)
379372 item. draw ( rect, measuredSize: itemSize, edge: . left, renderer: renderer)
380373 }
381374 }
@@ -528,9 +521,31 @@ extension GraphLayout {
528521 }
529522}
530523
524+ // Debugging.
525+
526+ extension GraphLayout {
527+
528+ public struct DebugFlags {
529+ /// Draws a different background color behind each `LayoutComponent`.
530+ public var debugLayoutComponents = false
531+ }
532+
533+ /// Debugging flags for `Plot` developers.
534+ ///
535+ public static var _debugFlags = DebugFlags ( )
536+ }
537+
538+ extension Renderer {
539+ var debugLayoutComponents : Renderer ? {
540+ guard GraphLayout . _debugFlags. debugLayoutComponents else { _onFastPath ( ) ; return nil }
541+ return self
542+ }
543+ }
544+
531545protocol AdjustsPlotSize {
532546 var desiredPlotSize : Size { get }
533547}
548+
534549public protocol HasGraphLayout {
535550
536551 var layout : GraphLayout { get set }
0 commit comments