Skip to content

Commit

Permalink
moved debug content to an overlay view
Browse files Browse the repository at this point in the history
updated help text for presentation mode and debug options
added presentation as an option to `--style`
  • Loading branch information
bartreardon committed May 29, 2024
1 parent 2c67586 commit 3c34188
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 46 deletions.
4 changes: 4 additions & 0 deletions dialog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
CCB35CB42BCFF4460041A701 /* SystemInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCB35CB32BCFF4460041A701 /* SystemInfo.swift */; };
CCD8ACEC2A011C9500D98695 /* RadioView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCD8ACEB2A011C9500D98695 /* RadioView.swift */; };
CCE934AD2ACC29F60094BD06 /* TextFileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCE934AC2ACC29F60094BD06 /* TextFileView.swift */; };
CCF4305A2C07562D004DFB4D /* DebugOverlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCF430592C07562D004DFB4D /* DebugOverlay.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -185,6 +186,7 @@
CCB35CB32BCFF4460041A701 /* SystemInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemInfo.swift; sourceTree = "<group>"; };
CCD8ACEB2A011C9500D98695 /* RadioView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioView.swift; sourceTree = "<group>"; };
CCE934AC2ACC29F60094BD06 /* TextFileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFileView.swift; sourceTree = "<group>"; };
CCF430592C07562D004DFB4D /* DebugOverlay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugOverlay.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -401,6 +403,7 @@
CCE934AC2ACC29F60094BD06 /* TextFileView.swift */,
CCB3346F2B2320F20079FB83 /* SolidColourView.swift */,
CC7D43CE2B972976004B9E65 /* PresentationView.swift */,
CCF430592C07562D004DFB4D /* DebugOverlay.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -695,6 +698,7 @@
CC2190572A7BCDA800269525 /* String+Additions.swift in Sources */,
417BD43827992EDB009AE34A /* TaskProgressView.swift in Sources */,
41D81E5725F7929800D1F7E1 /* DialogView.swift in Sources */,
CCF4305A2C07562D004DFB4D /* DebugOverlay.swift in Sources */,
4154C2E025F76BDB00A3D373 /* ContentView.swift in Sources */,
CC7D43CF2B972976004B9E65 /* PresentationView.swift in Sources */,
41D81E5C25F817BF00D1F7E1 /* ButtonView.swift in Sources */,
Expand Down
19 changes: 17 additions & 2 deletions dialog/Command Line/HelpText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,17 @@ struct SDHelp {
"""

argument.dialogStyle.helpShort = "Configure a pre-set window style"
argument.dialogStyle.helpUsage = "mini | centered | alert | caution | warning"
argument.dialogStyle.helpUsage = "presentation | mini | centered | alert | caution | warning"
argument.dialogStyle.helpLong = """
Displays the dialog in one of the defined styles by adjusting window defaults
"presentation" is functionally equavelent to --\(argument.presentationMode.long)
"mini" is functionally equavelent to --\(argument.miniMode.long)
"centered" will set all the options for centered content
"alert" sets a pre-configured dialog window 300x300 and centered content
"caution" and "warning" are the same as "alert" with the icon configured
Style defaults (other than mini) can be overridden. e.g:
Style defaults other than mini and presentation can be overridden. e.g:
--\(argument.dialogStyle.long) alert --\(argument.windowWidth.long) 400
will use the alert style with 400 width instead of the default 300
"""
Expand Down Expand Up @@ -547,6 +548,7 @@ struct SDHelp {
regexerror - Specify a custom error to display if regex conditions are not met
fileselect - Adds a "Select" button and presents a file picker
filetype - Limits fileselect to the named file extensions. Presented in space seperated values
confirm - Adds a secondary textfield whose contents need to match the primary one for validation to succeed
modifiers can be combined e.g. --\(appArguments.textField.long) <text>,secure,required
--\(appArguments.textField.long) <text>,required,prompt="<text>"
Expand Down Expand Up @@ -946,6 +948,19 @@ struct SDHelp {
This property is implied when using --\(argument.forceOnTop.long)
"""

argument.debug.helpShort = "Enable debug mode"
argument.debug.helpUsage = "(<colour>)"
argument.debug.helpLong = """
Enables debug mode. This increases the level of log output on stdout and
displays additional window properties along the title bar area for reference.
Optionally supply a <colour> argument as either a named colour or hex value.
This will enable content area boundry highlights.
Used in conjunction with \(argument.windowResizable.long) this is a good way to evaluate dialog
look and feel.
"""

argument.getVersion.helpShort = "Print version string"
argument.getVersion.helpUsage = ""
argument.getVersion.helpLong = ""
Expand Down
2 changes: 2 additions & 0 deletions dialog/Command Line/ProcessCLOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ func processCLOptions(json: JSON = getJSON()) {
appvars.messageAlignment = .center
case "mini":
appArguments.miniMode.present = true
case "presentation":
appArguments.presentationMode.present = true
default: ()
}
}
Expand Down
2 changes: 1 addition & 1 deletion dialog/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>4758</string>
<string>4762</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
26 changes: 0 additions & 26 deletions dialog/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ struct ContentView: View {
var titlePadding = CGFloat(10)

@ObservedObject var observedData: DialogUpdatableContent
@State private var windowFrame: CGSize = CGSize(width: 0, height: 0)

init (observedDialogContent: DialogUpdatableContent) {
self.observedData = observedDialogContent
Expand Down Expand Up @@ -84,33 +83,8 @@ struct ContentView: View {
Spacer()
}
}
if observedData.args.debug.present {
// Display window information in the title bar and keep it updated
VStack {
HStack {
Text("DEBUG - Window height: \(Int(windowFrame.width)) width: \(Int(windowFrame.height)) - Icon width: \(Int(observedData.iconSize)) alpha: \(observedData.iconAlpha)")
Spacer()
Text("quitkey: cmd+\(observedData.args.quitKey.value.uppercased() == observedData.args.quitKey.value ? "shift+" : "")\(observedData.args.quitKey.value.lowercased())")
}
.foregroundColor(observedData.appProperties.titleFontColour.opacity(0.7))
.padding(.top, 5)
.padding(.leading, observedData.args.windowButtonsEnabled.present ? 70 : 5)
.padding(.trailing, 5)
Spacer()
}
}
}
.edgesIgnoringSafeArea(.all)
.background(GeometryReader {child -> Color in
if observedData.args.debug.present {
DispatchQueue.main.async {
// update on next cycle with calculated height
self.windowFrame = child.size
}
}
return Color.clear
})

}


Expand Down
43 changes: 43 additions & 0 deletions dialog/Views/DebugOverlay.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// DebugOverlay.swift
// Dialog
//
// Created by Bart E Reardon on 29/5/2024.
//

import SwiftUI

struct DebugOverlay: View {
@ObservedObject var observedData: DialogUpdatableContent
@State private var windowFrame: CGSize = CGSize(width: 0, height: 0)

var body: some View {
if observedData.args.debug.present {
// Display window information in the title bar and keep it updated
VStack {
HStack {
Text("DEBUG - Window height: \(Int(windowFrame.width)) width: \(Int(windowFrame.height)) - Icon width: \(Int(observedData.iconSize)) alpha: \(observedData.iconAlpha)")
Spacer()
Text("quitkey: cmd+\(observedData.args.quitKey.value.uppercased() == observedData.args.quitKey.value ? "shift+" : "")\(observedData.args.quitKey.value.lowercased())")
}
.foregroundColor(observedData.appProperties.titleFontColour.opacity(0.7))
.padding(.top, 5)
.padding(.leading, observedData.args.windowButtonsEnabled.present ? 70 : 5)
.padding(.trailing, 5)
Spacer()
}
.background(GeometryReader {child -> Color in
if observedData.args.debug.present {
DispatchQueue.main.async {
// update on next cycle with calculated height
self.windowFrame = child.size
}
}
return Color.clear
})
.ignoresSafeArea()
.frame(width: observedData.appProperties.windowWidth, height: observedData.appProperties.windowHeight)
}
}
}

37 changes: 20 additions & 17 deletions dialog/dialogApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -202,25 +202,28 @@ struct dialogApp: App {

WindowGroup {
if !appArguments.notification.present {
if appArguments.miniMode.present {
MiniView(observedDialogContent: observedData)
.frame(width: observedData.appProperties.windowWidth, height: observedData.appProperties.windowHeight)
} else if appArguments.presentationMode.present {
PresentationView(observedData: observedData)
.frame(width: observedData.appProperties.windowWidth, height: observedData.appProperties.windowHeight)
} else {
if appArguments.windowResizable.present {
ContentView(observedDialogContent: observedData)
.sheet(isPresented: $observedData.showSheet, content: {
ErrorView(observedContent: observedData)
})
} else {
ContentView(observedDialogContent: observedData)
ZStack {
if appArguments.miniMode.present {
MiniView(observedDialogContent: observedData)
.frame(width: observedData.appProperties.windowWidth, height: observedData.appProperties.windowHeight)
} else if appArguments.presentationMode.present {
PresentationView(observedData: observedData)
.frame(width: observedData.appProperties.windowWidth, height: observedData.appProperties.windowHeight)
.sheet(isPresented: $observedData.showSheet, content: {
ErrorView(observedContent: observedData)
})
} else {
if appArguments.windowResizable.present {
ContentView(observedDialogContent: observedData)
.sheet(isPresented: $observedData.showSheet, content: {
ErrorView(observedContent: observedData)
})
} else {
ContentView(observedDialogContent: observedData)
.frame(width: observedData.appProperties.windowWidth, height: observedData.appProperties.windowHeight)
.sheet(isPresented: $observedData.showSheet, content: {
ErrorView(observedContent: observedData)
})
}
}
DebugOverlay(observedData: observedData)
}
}
}
Expand Down

0 comments on commit 3c34188

Please sign in to comment.