diff --git a/.gitattributes b/.gitattributes
index 7bbb636b..433e97d6 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,3 +1,4 @@
-*.swift text eol=lf
+*.html text eol=lf
*.md text eol=lf
-.gitmodules text eol=lf
+*.yml text eol=lf
+Gemfile text eol=lf
diff --git a/.github/codecov.yml b/.github/codecov.yml
deleted file mode 100644
index cb5a48a3..00000000
--- a/.github/codecov.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-comment:
- layout: "diff,files"
- behavior: new
-coverage:
- status:
- project: true
- patch: true
- changes: true
-ignore:
- - "Examples/**/*"
- - "Tests/**/*"
- - "Packages/**/*"
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
deleted file mode 100644
index c52b2b3d..00000000
--- a/.github/workflows/build.yml
+++ /dev/null
@@ -1,62 +0,0 @@
-name: build
-
-on:
- pull_request:
- branches:
- - main
- paths:
- - '**/*.swift'
- - '.github/workflows/build.yml'
- workflow_dispatch:
-
-jobs:
- build:
- runs-on: windows-latest
-
- strategy:
- fail-fast: false
- matrix:
- include:
- - branch: swift-5.4.3-release
- tag: 5.4.3-RELEASE
- options: '-Xmanifest -use-ld=link -Xswiftc -use-ld=link'
-
- - branch: swift-5.5.3-release
- tag: 5.5.3-RELEASE
- options: '-Xmanifest -use-ld=link -Xswiftc -use-ld=link'
-
- - branch: swift-5.6.3-release
- tag: 5.6.3-RELEASE
- options: ''
-
- - branch: swift-5.7.3-release
- tag: 5.7.3-RELEASE
- options: ''
-
- - branch: swift-5.8.1-release
- tag: 5.8.1-RELEASE
- options: ''
-
- - branch: swift-5.9.1-release
- tag: 5.9.1-RELEASE
- options: ''
-
- - branch: development
- tag: DEVELOPMENT-SNAPSHOT-2023-08-12-a
- options: ''
-
- name: Swift ${{ matrix.tag }}
-
- steps:
- - uses: compnerd/gha-setup-swift@main
- with:
- tag: ${{ matrix.tag }}
- branch: ${{ matrix.branch }}
-
- - uses: actions/checkout@v3
-
- - name: Build
- run: swift build -v ${{ matrix.options }}
-
- - name: Run tests
- run: swift test -v -Xswiftc -DENABLE_TESTING ${{ matrix.options }}
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
deleted file mode 100644
index 7e5ff9eb..00000000
--- a/.github/workflows/coverage.yml
+++ /dev/null
@@ -1,51 +0,0 @@
-name: coverage
-
-on:
- push:
- branches:
- - main
- paths:
- - '**/*.swift'
- - '.github/workflows/coverage.yml'
- - '!Examples/**/*.swift'
- pull_request:
- branches:
- - main
- paths:
- - '**/*.swift'
- - '.github/workflows/coverage.yml'
- - '!Examples/**/*.swift'
- workflow_dispatch:
-
-jobs:
- coverage:
- runs-on: windows-latest
-
- strategy:
- matrix:
- include:
- - branch: swift-5.9-release
- tag: 5.9-RELEASE
-
- steps:
- - uses: actions/checkout@v2
- - uses: seanmiddleditch/gha-setup-vsdevenv@master
- - uses: compnerd/gha-setup-swift@main
- with:
- tag: ${{ matrix.tag }}
- branch: ${{ matrix.branch }}
-
- - name: Build
- run: swift build -v
-
- - name: Run tests
- run: swift test -v -Xswiftc -DENABLE_TESTING --enable-code-coverage
-
- - name: Process Coverage
- run: |
- llvm-cov export -format lcov -ignore-filename-regex ".build|Tests|Examples" -instr-profile .build\x86_64-unknown-windows-msvc\debug\codecov\default.profdata .build\x86_64-unknown-windows-msvc\debug\SwiftWin32PackageTests.xctest > coverage.lcov
-
- - uses: codecov/codecov-action@v3
- with:
- token: ${{ secrets.CODECOV_TOKEN }}
- files: coverage.lcov
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
deleted file mode 100644
index 41389425..00000000
--- a/.github/workflows/lint.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-name: lint
-
-on:
- pull_request:
- branches:
- - main
- paths:
- - '**/*.swift'
-
-jobs:
- lint:
- runs-on: windows-latest
-
- steps:
- - uses: compnerd/gha-setup-swift@main
- with:
- branch: swift-5.8-release
- tag: 5.8-RELEASE
- - name: Install swift-format
- run: |
- Install-Binary -Url "https://github.com/compnerd/swift-build/releases/download/swift-format-5.8-RELEASE/swift-format.msi" -Name "swift-format.msi" -ArgumentList ("-q")
-
- - uses: actions/checkout@v2
-
- - uses: compnerd/swift-format-linter-action@main
- with:
- github-token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.gitignore b/.gitignore
index de66424b..ba584468 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,15 +1,5 @@
-# git ls-files --others --exclude-from=.git/info/exclude
-# Lines that start with '#' are comments.
-# For a project mostly in C, the following would be a good set of
-# exclude patterns (uncomment them if you want to use them):
-
-.*.sw[nop]
-*~
-
-/build/
-
-/package.resolved
-/Packages/
-.build/
-
-.vscode/
+_site
+.sass-cache
+.jekyll-cache
+.jeykll-metadata
+vendor
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 23c85fc2..00000000
--- a/.gitmodules
+++ /dev/null
@@ -1,12 +0,0 @@
-[submodule "Packages/cassowary"]
- path = Packages/cassowary
- url = https://github.com/compnerd/cassowary
-[submodule "Packages/SwiftCOM"]
- path = Packages/SwiftCOM
- url = https://github.com/compnerd/swift-com
-[submodule "Packages/swift-log"]
- path = Packages/swift-log
- url = https://github.com/apple/swift-log
-[submodule "Packages/swift-collections"]
- path = Packages/swift-collections
- url = https://github.com/apple/swift-collections
diff --git a/.swift-format b/.swift-format
deleted file mode 100644
index 37c59f44..00000000
--- a/.swift-format
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "version": 1,
- "rules": {
- "AllPublicDeclarationsHaveDocumentation": true,
- "AlwaysUseLowerCamelCase": false,
- "UseShorthandTypeNames": false,
- "ValidateDocumentationComments": true
- }
-}
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
deleted file mode 100644
index 9ab73d1e..00000000
--- a/.vscode/extensions.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "recommendations": [
- "exodiusstudios.comment-anchors",
- "sswg.swift-lang"
- ]
-}
diff --git a/.vscode/settings.json b/.vscode/settings.json
deleted file mode 100644
index 9e3ec7e8..00000000
--- a/.vscode/settings.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- "cmake.configureOnOpen": false,
- "commentAnchors.tags.list": [
- {
- "tag": "MARK",
- "iconColor": "default",
- "highlightColor": "#A8C023",
- "scope": "file"
- },
- {
- "tag": "TODO",
- "iconColor": "blue",
- "highlightColor": "#3ea8ff",
- "scope": "workspace"
- },
- {
- "tag": "FIXME",
- "iconColor": "red",
- "highlightColor": "#F44336",
- "scope": "workspace"
- },
- {
- "tag": "NOTE",
- "iconColor": "orange",
- "highlightColor": "#FFB300",
- "scope": "file"
- },
- ],
- "files.exclude": {
- ".git": true,
- ".build": true,
- ".*.sw?": true,
- "**/.DS_Store": true
- }
-}
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
deleted file mode 100644
index 1d41a3a0..00000000
--- a/.vscode/tasks.json
+++ /dev/null
@@ -1,159 +0,0 @@
-// See https://go.microsoft.com/fwlink/?LinkId=733558
-// for the documentation about the tasks.json format
-{
- "version": "2.0.0",
- "problemMatcher": {
- "owner": "swift",
- "fileLocation": "autoDetect",
- "pattern": {
- "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
- "file": 1,
- "line": 2,
- "column": 3,
- "severity": 4,
- "message": 5
- }
- },
- "tasks": [
- {
- "label": "Build (Debug DWARF)",
- "type": "shell",
- "command": "swift",
- "args": [
- "build",
- "-c", "debug",
- "-Xlinker", "-debug:dwarf",
- ],
- "group": {
- "kind": "build",
- "isDefault": true
- },
- "windows": {
- "options": {
- "shell": {
- "executable": "C:\\WINDOWS\\System32\\cmd.exe",
- "args": [
- "/d",
- "/c",
- ]
- }
- }
- }
- },
- {
- "label": "Build (Debug PDB)",
- "type": "shell",
- "command": "swift",
- "args": [
- "build",
- "-c", "debug",
- "-Xswiftc", "-g",
- "-Xswiftc", "-debug-info-format=codeview",
- "-Xlinker", "-debug",
- ],
- "group": "build",
- "windows": {
- "options": {
- "shell": {
- "executable": "C:\\WINDOWS\\System32\\cmd.exe",
- "args": [
- "/d",
- "/c",
- ]
- }
- }
- }
- },
- {
- "label": "Build (Release)",
- "type": "shell",
- "command": "swift",
- "args": [
- "build",
- "-c", "release",
- ],
- "group": "build",
- "windows": {
- "options": {
- "shell": {
- "executable": "C:\\WINDOWS\\System32\\cmd.exe",
- "args": [
- "/d",
- "/c",
- ]
- }
- }
- }
- },
- {
- "label": "Test (Debug)",
- "type": "shell",
- "command": "swift",
- "args": [
- "test",
- "-c", "debug",
- "-Xswiftc", "-DENABLE_TESTING",
- ],
- "group": {
- "kind": "test",
- "isDefault": true
- },
- "windows": {
- "options": {
- "shell": {
- "executable": "C:\\WINDOWS\\System32\\cmd.exe",
- "args": [
- "/d",
- "/c",
- ]
- }
- }
- },
- },
- {
- "label": "Test (Coverage)",
- "command": "swift",
- "type": "shell",
- "args": [
- "test",
- "-c", "debug",
- "-Xswiftc", "-DENABLE_TESTING",
- "--enable-code-coverage",
- ],
- "group": "test",
- "windows": {
- "options": {
- "shell": {
- "executable": "C:\\WINDOWS\\System32\\cmd.exe",
- "args": [
- "/d",
- "/c",
- ]
- }
- }
- }
- },
- {
- "label": "Test (Release)",
- "command": "swift",
- "type": "shell",
- "args": [
- "test",
- "-c", "release",
- "-Xswiftc", "-DENABLE_TESTING",
- ],
- "group": "test",
- "windows": {
- "options": {
- "shell": {
- "executable": "C:\\WINDOWS\\System32\\cmd.exe",
- "args": [
- "/d",
- "/c",
- ]
- }
- }
- }
- }
- ]
-}
diff --git a/404.html b/404.html
new file mode 100644
index 00000000..086a5c9e
--- /dev/null
+++ b/404.html
@@ -0,0 +1,25 @@
+---
+permalink: /404.html
+layout: default
+---
+
+
+
+
+
404
+
+
Page not found :(
+
The requested page could not be found.
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index f16e0b69..00000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,71 +0,0 @@
-#[[
-Copyright © 2019 Saleem Abdulrasool
-All rights reserved.
-
-SPDX-License-Identifier: BSD-3-Clause
-#]]
-
-cmake_minimum_required(VERSION 3.16.0)
-
-project(SwiftWin32
- LANGUAGES C Swift)
-
-list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
-
-set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
-set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
-
-find_package(dispatch CONFIG QUIET)
-find_package(Foundation CONFIG QUIET)
-
-find_package(Git REQUIRED)
-execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- RESULT_VARIABLE GIT_SUBMODULE_UPDATE_RESULT)
-if(NOT GIT_SUBMODULE_UPDATE_RESULT EQUAL "0")
- message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMODULE_UPDATE_RESULT}, please checkout submodules")
-endif()
-
-execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Packages/Cassowary"
- OUTPUT_VARIABLE CASSOWARY_GIT_REVISION
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Packages/SwiftCOM"
- OUTPUT_VARIABLE SWIFT_COM_GIT_REVISION
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Packages/swift-log"
- OUTPUT_VARIABLE SWIFT_LOG_GIT_REVISION
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Packages/swift-collections"
- OUTPUT_VARIABLE COLLECTIONS_GIT_REVISION
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-
-include(SwiftSupport)
-
-add_subdirectory(Packages/swift-collections)
-
-add_subdirectory(Sources)
-add_subdirectory(Examples)
-
-message("-- Building with sub-modules:")
-message("-- Cassowary rG${CASSOWARY_GIT_REVISION}")
-message("-- Swift/COM rG${SWIFT_COM_GIT_REVISION}")
-message("-- swift-log rG${SWIFT_LOG_GIT_REVISION}")
-message("-- Collections rG${COLLECTIONS_GIT_REVISION}")
-
-if(Swift_COMPILER_VERSION VERSION_LESS 5.5)
- export(TARGETS Logging SwiftCOM SwiftWin32
- FILE SwiftWin32Config.cmake)
-else()
- export(TARGETS SwiftCOM SwiftWin32
- FILE SwiftWin32Config.cmake)
-endif()
diff --git a/CMakePresets.json b/CMakePresets.json
deleted file mode 100644
index d97c8b4c..00000000
--- a/CMakePresets.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "version": 3,
- "cmakeMinimumRequired": {
- "major": 3,
- "minor": 21,
- "patch": 0
- },
- "configurePresets": [
- {
- "name": "Default",
- "displayName": "Release Build (Ninja)",
- "description": "Defaults",
- "generator": "Ninja",
- "binaryDir": "${sourceDir}/.build/x86_64-unknown-windows-msvc/Release",
- "cacheVariables": {
- "BUILD_SHARED_LIBS": "YES",
- "CMAKE_BUILD_TYPE": "Release",
- "CMAKE_Swift_FLAGS": "-sdk $env{SDKROOT}"
- }
- }
- ],
- "buildPresets": [
- {
- "name": "Default",
- "configurePreset": "Default"
- }
- ]
-}
diff --git a/CoreGraphics/index.md b/CoreGraphics/index.md
new file mode 100644
index 00000000..95148925
--- /dev/null
+++ b/CoreGraphics/index.md
@@ -0,0 +1,9 @@
+---
+layout: default
+title: CoreGraphics
+nav_order: 2
+has_children: true
+---
+
+CoreGraphics provides lightweight 2D rendering utilities. This is primarily
+used for the basic graphics primitives required to interact with SwiftWin32.
diff --git a/Documentation/BundleLayout.md b/Documentation/BundleLayout.md
deleted file mode 100644
index 3e9c5d09..00000000
--- a/Documentation/BundleLayout.md
+++ /dev/null
@@ -1,48 +0,0 @@
-## Bundle Layout
-
-### What Files Go Into an Application Bundle?
-
-The following table summarises the types of files that need to be included in an application distribution.
-
-| File | Description |
-| ---- | ----------- |
-| Info.plist | **(Optional)** The *information property list* file is a structured file that contains configuration information for the application. |
-| Executable | The application's main entry point and any statically linked code. |
-| Libraries | Any additional dependent libraries needed by the main executable. |
-| Application Manifest | The Windows application manifest which is used to enable features for modern Windows APIs. |
-| Swift Runtime | **(Optional)** The runtime libraries for the Swift runtime. |
-
-### Anatomy of a Windows Application Bundle
-
-#### The Windows Application Bundle Structure
-
-The Windows application bundle contains the application executable and any resources required for the application. The following listing shows the structure of a simple application called `Application`.
-
-```
-Application.app
- Application.exe
- Application.exe.manifest
- Resources
- Image.png
-```
-
-| File | Description |
-| ---- | ----------- |
-| Application.exe | (Required) The executable file containing the application code. |
-| Application.exe.manifest | (Required) The executable manifest. This must be named the same as the executable with an additional `.manifest` suffix. |
-| Info.plist | (Recommended) The file contains confituration information for the application. |
-| Custom resource files | Any additional resources, including but not limited to images, sound files, and custom data files needed for the application. |
-
-### The Information Property List File
-
-Applications should provide an information property list (`Info.plist`) file
-containing the application's configuration information. If one is not provided,
-the framework wil attempt to subsitute defaults. The following table lists some
-of the keys which are commonly used. Although the file nor the keys are
-required, they provide a way to adjust the configuration of the application at
-launch time. Providing the configuration helps ensure te proper presentation of
-the application to the user.
-
-| Key | Description |
-| --- | ----------- |
-| `PrincipalClass` (Principal class) | The entry point for for the application. This is either the default `Application` or a subclass. |
diff --git a/Documentation/PrincipalClass.md b/Documentation/PrincipalClass.md
deleted file mode 100644
index 11638539..00000000
--- a/Documentation/PrincipalClass.md
+++ /dev/null
@@ -1,29 +0,0 @@
-## Principal Class
-
-Defining a PrincipalClass allows to use a subclass of the `Application` class.
-
-### How to use an Application subclass ?
-
-- Define a class that inherits from `SwiftWin32.Application`. Here is an example:
-
-```swift
-import SwiftWin32
-
-public class MyApplication: Application {
- let message = "This is a message from MyApplication subclass"
-}
-```
-
-- In `Info.plist`, define a `PrincipalClass` entry with a String value of `{Module}.{CustomClassName}`. For example, if the product module name is `CustomPrincipalClass`, then we can register `MyApplication` (defined above) as follows:
-
-```xml
-
-
-
-
- PrincipalClass
- CustomPrincipalClass.MyApplication
-
-
-
-```
diff --git a/Examples/CMakeLists.txt b/Examples/CMakeLists.txt
deleted file mode 100644
index ec143d00..00000000
--- a/Examples/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-add_subdirectory(Calculator)
-add_subdirectory(UICatalog)
diff --git a/Examples/Calculator/CMakeLists.txt b/Examples/Calculator/CMakeLists.txt
deleted file mode 100644
index 13f16c52..00000000
--- a/Examples/Calculator/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-add_executable(Calculator
- Calculator.swift)
-add_custom_command(TARGET Calculator POST_BUILD
- COMMAND
- mt -nologo -manifest ${CMAKE_CURRENT_SOURCE_DIR}/Calculator.exe.manifest -outputresource:$
- COMMAND
- ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist $)
-# FIXME(SR-12683) `@main` requires `-parse-as-library`
-target_compile_options(Calculator PRIVATE
- -parse-as-library)
-target_link_libraries(Calculator PRIVATE
- SwiftWin32)
diff --git a/Examples/Calculator/Calculator.exe.manifest b/Examples/Calculator/Calculator.exe.manifest
deleted file mode 100644
index eee17d38..00000000
--- a/Examples/Calculator/Calculator.exe.manifest
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
- PerMonitorV2
- true
-
-
-
- Calculator
-
-
-
-
-
-
-
-
diff --git a/Examples/Calculator/Calculator.swift b/Examples/Calculator/Calculator.swift
deleted file mode 100644
index 2a2962b1..00000000
--- a/Examples/Calculator/Calculator.swift
+++ /dev/null
@@ -1,187 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import SwiftWin32
-import Foundation
-
-#if swift(>=5.7)
-import CoreGraphics
-#endif
-
-private extension View {
- func addSubviews(_ views: [View]) {
- _ = views.map { self.addSubview($0) }
- }
-}
-
-private extension Button {
- convenience init(frame: Rect = .zero, title: String) {
- self.init(frame: frame)
- setTitle(title, forState: .normal)
- }
-}
-
-private enum CalculatorOperation {
-case undefined
-case addition
-case substraction
-case multiplication
-case division
-}
-
-private struct CalculatorState {
- var lhs: NSDecimalNumber = .zero
- var rhs: NSDecimalNumber = .zero
- var operand: WritableKeyPath = \.lhs
- var operation: CalculatorOperation = .undefined {
- willSet { self.operand = (newValue == .undefined) ? \.lhs : \.rhs }
- }
-
- mutating func evaluate() -> NSDecimalNumber {
- switch self.operation {
- case .undefined: break
- case .addition: lhs = lhs.adding(rhs)
- case .substraction: lhs = lhs.subtracting(rhs)
- case .multiplication: lhs = lhs.multiplying(by: rhs)
- case .division: lhs = lhs.dividing(by: rhs)
- }
-
- rhs = .zero
- operation = .undefined
-
- return lhs
- }
-}
-
-private class Calculator {
- private var state: CalculatorState = CalculatorState()
-
- private var window: Window
-
- private var txtResult: TextField = {
- let txtResult = TextField(frame: Rect(x: 34, y: 32, width: 128, height: 24))
- txtResult.font = Font(name: "Consolas", size: Font.systemFontSize)
- txtResult.textAlignment = .right
- txtResult.text = "0"
- return txtResult
- }()
-
- private var btnDigits: [Button] = [
- Button(frame: Rect(x: 32, y: 192, width: 64, height: 32), title: "0"),
- Button(frame: Rect(x: 32, y: 160, width: 32, height: 32), title: "1"),
- Button(frame: Rect(x: 64, y: 160, width: 32, height: 32), title: "2"),
- Button(frame: Rect(x: 96, y: 160, width: 32, height: 32), title: "3"),
- Button(frame: Rect(x: 32, y: 128, width: 32, height: 32), title: "4"),
- Button(frame: Rect(x: 64, y: 128, width: 32, height: 32), title: "5"),
- Button(frame: Rect(x: 96, y: 128, width: 32, height: 32), title: "6"),
- Button(frame: Rect(x: 32, y: 96, width: 32, height: 32), title: "7"),
- Button(frame: Rect(x: 64, y: 96, width: 32, height: 32), title: "8"),
- Button(frame: Rect(x: 96, y: 96, width: 32, height: 32), title: "9"),
- ]
-
- private var btnDecimal: Button =
- Button(frame: Rect(x: 96, y: 192, width: 32, height: 32), title: ".")
-
- private var btnOperations: [Button] = [
- Button(frame: Rect(x: 32, y: 64, width: 32, height: 32), title: "AC"),
- Button(frame: Rect(x: 64, y: 64, width: 32, height: 32), title: "⁺∕₋"),
- Button(frame: Rect(x: 96, y: 64, width: 32, height: 32), title: "%"),
- Button(frame: Rect(x: 128, y: 64, width: 32, height: 32), title: "÷"),
- Button(frame: Rect(x: 128, y: 96, width: 32, height: 32), title: "x"),
- Button(frame: Rect(x: 128, y: 128, width: 32, height: 32), title: "-"),
- Button(frame: Rect(x: 128, y: 160, width: 32, height: 32), title: "+"),
- Button(frame: Rect(x: 128, y: 192, width: 32, height: 32), title: "="),
- ]
-
- public init(windowScene: WindowScene) {
- self.window = Window(windowScene: windowScene)
-
- self.window.rootViewController = ViewController()
- self.window.rootViewController?.title = "Calculator"
-
- self.window.addSubview(self.txtResult)
- self.txtResult.font = Font(name: "Consolas", size: Font.systemFontSize)
- self.txtResult.textAlignment = .right
- self.txtResult.text =
- self.state.evaluate().description(withLocale: Locale.current)
-
- self.window.addSubviews(self.btnDigits)
- self.btnDigits.forEach {
- $0.addTarget(self, action: Calculator.onDigitPress(_:_:),
- for: .primaryActionTriggered)
- }
- self.window.addSubviews(self.btnOperations)
- self.btnOperations.forEach {
- $0.addTarget(self, action: Calculator.onOperationPress(_:_:),
- for: .primaryActionTriggered)
- }
- self.window.addSubview(self.btnDecimal)
- self.btnDecimal.addTarget(self, action: Calculator.onDecimalPress(_:_:),
- for: .primaryActionTriggered)
-
- self.window.makeKeyAndVisible()
- }
-
- private func onDigitPress(_ sender: Button, _: Control.Event) {
- guard let input = self.btnDigits.firstIndex(of: sender) else {
- fatalError("invalid target: \(self) for sender: \(sender)")
- }
-
- var operand = self.state[keyPath: self.state.operand] as Decimal
- operand *= 10
- operand += Decimal(input)
- self.state[keyPath: self.state.operand] = operand as NSDecimalNumber
-
- self.txtResult.text = operand.description
- }
-
- private func onOperationPress(_ sender: Button, _: Control.Event) {
- switch self.btnOperations.firstIndex(of: sender)! {
- case 0: /* AC */
- self.state = CalculatorState()
- self.txtResult.text = Decimal.zero.description
- case 1: /* +/- */
- var operand = self.state[keyPath: self.state.operand] as Decimal
- operand.negate()
- case 3: /* ÷ */
- self.state.operation = .division
- case 4: /* x */
- self.state.operation = .multiplication
- case 5: /* - */
- self.state.operation = .substraction
- case 6: /* + */
- self.state.operation = .addition
- case 2: /* % */
- if (self.state.lhs as Decimal).isZero { break }
- self.state.operation = .division
- self.state.rhs = NSDecimalNumber(string: "100")
- fallthrough
- case 7: /* = */
- self.txtResult.text =
- self.state.evaluate().description(withLocale: Locale.current)
- default:
- fatalError("unknown operation \(self.btnOperations.firstIndex(of: sender)!)")
- }
- }
-
- private func onDecimalPress(_ sender: Button, _: Control.Event) {
- self.txtResult.text =
- (self.state[keyPath: self.state.operand] as Decimal).description
- }
-}
-
-@main
-final class CalculatorDelegate: ApplicationDelegate, SceneDelegate {
- private var calculator: Calculator?
-
- func scene(_ scene: Scene, willConnectTo session: SceneSession,
- options: Scene.ConnectionOptions) {
- guard let windowScene = scene as? WindowScene else { return }
-
- let size: Size = Size(width: 192, height: 264)
- windowScene.sizeRestrictions?.minimumSize = size
- windowScene.sizeRestrictions?.maximumSize = size
-
- self.calculator = Calculator(windowScene: windowScene)
- }
-}
diff --git a/Examples/Calculator/Info.plist b/Examples/Calculator/Info.plist
deleted file mode 100644
index 34cb62ef..00000000
--- a/Examples/Calculator/Info.plist
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
- ApplicationSceneManifest
-
- ApplicationSupportsMultipleScenes
-
- SceneConfigurations
-
- UIWindowSceneSessionRoleApplication
-
-
- SceneConfigurationName
- Default Configuration
- SceneDelegateClassName
- Calculator.CalculatorDelegate
-
-
-
-
-
-
diff --git a/Examples/UICatalog/Assets/CoffeeCup.jpg b/Examples/UICatalog/Assets/CoffeeCup.jpg
deleted file mode 100644
index df3016cb..00000000
Binary files a/Examples/UICatalog/Assets/CoffeeCup.jpg and /dev/null differ
diff --git a/Examples/UICatalog/CMakeLists.txt b/Examples/UICatalog/CMakeLists.txt
deleted file mode 100644
index df5dc638..00000000
--- a/Examples/UICatalog/CMakeLists.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-add_executable(UICatalog
- UICatalog.swift)
-add_custom_command(TARGET UICatalog POST_BUILD
- COMMAND
- mt -nologo -manifest ${CMAKE_CURRENT_SOURCE_DIR}/UICatalog.exe.manifest -outputresource:$
- COMMAND
- ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist $
- COMMAND
- ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/Assets/CoffeeCup.jpg $)
-# FIXME(SR-12683) `@main` requires `-parse-as-library`
-target_compile_options(UICatalog PRIVATE
- -parse-as-library)
-target_link_libraries(UICatalog PRIVATE
- SwiftWin32)
diff --git a/Examples/UICatalog/Info.plist b/Examples/UICatalog/Info.plist
deleted file mode 100644
index 1fda46a0..00000000
--- a/Examples/UICatalog/Info.plist
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
- ApplicationSceneManifest
-
- ApplicationSupportsMultipleScenes
-
- SceneConfigurations
-
- UIWindowSceneSessionRoleApplication
-
-
- SceneConfigurationName
- Default Configuration
- SceneDelegateClassName
- UICatalog.UICatalog
-
-
-
-
-
-
diff --git a/Examples/UICatalog/UICatalog.exe.manifest b/Examples/UICatalog/UICatalog.exe.manifest
deleted file mode 100644
index 704609af..00000000
--- a/Examples/UICatalog/UICatalog.exe.manifest
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
- PerMonitorV2
- true
-
-
-
- UICatalog
-
-
-
-
-
-
-
-
diff --git a/Examples/UICatalog/UICatalog.swift b/Examples/UICatalog/UICatalog.swift
deleted file mode 100644
index 8282b7ad..00000000
--- a/Examples/UICatalog/UICatalog.swift
+++ /dev/null
@@ -1,215 +0,0 @@
-// Copyright © 2019 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import SwiftWin32
-import Foundation
-
-import func WinSDK.MessageBoxW
-import let WinSDK.MB_OK
-import struct WinSDK.UINT
-
-#if swift(>=5.7)
-import CoreGraphics
-#endif
-
-private extension Label {
- convenience init(frame: Rect, title: String) {
- self.init(frame: frame)
- self.text = title
- }
-}
-
-@main
-final class UICatalog: ApplicationDelegate, SceneDelegate {
- var window: Window!
-
- lazy var label: Label =
- Label(frame: Rect(x: 4.0, y: 12.0, width: 64.0, height: 16.0),
- title: "Read Me:")
-
- lazy var button: Button =
- Button(frame: Rect(x: 72.0, y: 4.0, width: 96.0, height: 32.0),
- primaryAction: Action(title: "Press Me!") { _ in
- MessageBoxW(nil, "Swift/Win32 Demo!".wide,
- "Swift/Win32 MessageBox!".wide, UINT(MB_OK))
- })
-
- lazy var checkbox: Switch =
- Switch(frame: Rect(x: 4.0, y: 40.0, width: 256.0, height: 24.0))
-
- lazy var progress: ProgressView =
- ProgressView(frame: Rect(x: 4.0, y: 68.0, width: 256.0, height: 20.0))
-
- lazy var textfield: TextField =
- TextField(frame: Rect(x: 4.0, y: 92.0, width: 254.0, height: 17.0))
-
- lazy var password: TextField =
- TextField(frame: Rect(x: 4.0, y: 113.0, width: 254.0, height: 17.0))
-
- lazy var textview: TextView =
- TextView(frame: Rect(x: 4.0, y: 134.0, width: 254.0, height: 72.0))
-
- lazy var slider: Slider =
- Slider(frame: Rect(x: 4.0, y: 210.0, width: 256.0, height: 24.0))
-
- lazy var picker: DatePicker =
- DatePicker(frame: Rect(x: 4.0, y: 238.0, width: 256.0, height: 32.0))
-
- lazy var stepperLabel: Label =
- Label(frame: Rect(x: 4.0, y: 274.0, width: 128.0, height: 32.0))
- lazy var stepper: Stepper =
- Stepper(frame: Rect(x: 197.0, y: 274.0, width: 64.0, height: 32.0))
-
- lazy var tableview: TableView =
- TableView(frame: Rect(x: 4.0, y: 310.0, width: 254.0, height: 48.0),
- style: .plain)
-
- lazy var pickerview: PickerView =
- PickerView(frame: Rect(x: 4.0, y: 362.0, width: 256.0, height: 24.0))
-
- lazy var imageview: ImageView = {
-#if SWIFT_PACKAGE
- let bundle: Bundle = Bundle.module
-#else
- let bundle: Bundle = Bundle.main
-#endif
- guard let resource: URL =
- bundle.url(forResource: "CoffeeCup", withExtension: "jpg") else {
- fatalError("Unable to load resource `CoffeeCup.jpg`")
- }
- let image: Image? = Image(contentsOfFile: resource.path)
- let view = ImageView(image: image)
- view.frame = Rect(x: 64.0, y: 394.0, width: 128.0, height: 128.0)
- return view
- }()
-
- func scene(_ scene: Scene, willConnectTo session: SceneSession,
- options: Scene.ConnectionOptions) {
- guard let windowScene = scene as? WindowScene else { return }
-
- // Set the preferred window size and restrict resizing by setting the
- // minimum and maximum to the same value.
- let size: Size = Size(width: 265, height: 530)
- windowScene.sizeRestrictions?.minimumSize = size
- windowScene.sizeRestrictions?.maximumSize = size
-
- self.window = Window(windowScene: windowScene)
-
- window.rootViewController = ViewController()
- window.rootViewController?.title = "UICatalog"
-
- window.addSubview(self.label)
- window.addSubview(self.button)
- window.addSubview(self.checkbox)
- window.addSubview(self.progress)
- window.addSubview(self.textfield)
- window.addSubview(self.password)
- window.addSubview(self.textview)
- window.addSubview(self.slider)
- window.addSubview(self.picker)
- window.addSubview(self.stepperLabel)
- window.addSubview(self.stepper)
- window.addSubview(self.tableview)
- window.addSubview(self.pickerview)
- window.addSubview(self.imageview)
-
- self.label.font = Font(name: "Consolas", size: 10)!
-
- self.checkbox.title = "Check me out"
-
- self.textfield.text = "Introducing Swift/Win32"
- self.textfield.font = Font(name: "Cascadia Code", size: 10)
-
- self.password.isSecureTextEntry = true
- self.password.font = Font(name: "Cascadia Code", size: 10)
- self.password.placeholder = "Password"
-
- self.textview.text = """
-Lorem ipsum dolor sit amet, consectetur adipiscicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
-Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
-"""
- self.textview.font = Font(name: "MS Comic Sans", size: 10)
-
- self.progress.setProgress(0.5, animated: false)
-
- self.slider.minimumValue = 0.0
- self.slider.maximumValue = 100.0
- self.slider.value = 48.0
-
- self.stepper.value = 2
- self.stepperLabel.text = String(Int(self.stepper.value))
- self.stepper.addTarget(self, action: UICatalog.stepperValueDidChange(_:),
- for: .valueChanged)
-
- self.tableview.dataSource = self
-
- self.pickerview.dataSource = self
- self.pickerview.delegate = self
- self.pickerview.reloadAllComponents()
-
- window.makeKeyAndVisible()
- }
-
- func sceneDidBecomeActive(_: Scene) {
- print("Good morning!")
- }
-
- func sceneWillResignActive(_: Scene) {
- print("Good night!")
- }
-
- func applicationWillTerminate(_: Application) {
- print("Goodbye cruel world!")
- }
-
- private func stepperValueDidChange(_ stepper: Stepper) {
- self.stepperLabel.text = String(Int(stepper.value))
- self.tableview.reloadData()
- }
-}
-
-extension UICatalog: TableViewDataSource {
- public func tableView(_ tableView: TableView,
- numberOfRowsInSection section: Int) -> Int {
- return Int(stepper.value)
- }
-
- public func tableView(_ tableView: TableView,
- cellForRowAt indexPath: IndexPath) -> TableViewCell {
- let cell = TableViewCell(style: .default, reuseIdentifier: nil)
-
- let button: Button = Button(frame: Rect(x: 0, y: 0, width: 80, height: 32))
- button.setTitle("Button \(indexPath.row)", forState: .normal)
- cell.addSubview(button)
-
- return cell
- }
-}
-
-extension UICatalog: PickerViewDataSource {
- public func numberOfComponents(in pickerView: PickerView) -> Int {
- return 1
- }
-
- public func pickerView(_ pickerView: PickerView,
- numberOfRowsInComponent component: Int) -> Int {
- return 7
- }
-}
-
-extension UICatalog: PickerViewDelegate {
- public func pickerView(_ pickerView: PickerView, titleForRow row: Int,
- forComponent component: Int) -> String? {
- return [
- "Sunday",
- "Monday",
- "Tuesday",
- "Wednesday",
- "Thursday",
- "Friday",
- "Saturday",
- ][row]
- }
-}
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 00000000..20b1b828
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,17 @@
+source "https://rubygems.org"
+
+gem "github-pages", group: :jekyll_plugins
+gem "just-the-docs"
+group :jekyll_plugins do
+ gem "jekyll-feed", "~> 0.12"
+end
+
+# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
+# and associated library.
+platforms :mingw, :x64_mingw, :mswin, :jruby do
+ gem "tzinfo", "~> 1.2"
+ gem "tzinfo-data"
+end
+
+# Performance-booster for watching directories on Windows
+gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
diff --git a/LICENSE.txt b/LICENSE.txt
deleted file mode 100644
index 19d2c536..00000000
--- a/LICENSE.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-BSD 3-Clause License
-
-Copyright (c) 2019, Saleem Abdulrasool
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Package.swift b/Package.swift
deleted file mode 100644
index ceec4a26..00000000
--- a/Package.swift
+++ /dev/null
@@ -1,90 +0,0 @@
-// swift-tools-version:5.9
-
-import PackageDescription
-
-let SwiftWin32: Package =
- Package(name: "SwiftWin32",
- products: [
- .library(name: "SwiftWin32",
- type: .dynamic,
- targets: ["SwiftWin32"]),
- .library(name: "SwiftWin32UI",
- type: .dynamic,
- targets: ["SwiftWin32UI"]),
- .executable(name: "UICatalog", targets: ["UICatalog"]),
- .executable(name: "Calculator", targets: ["Calculator"]),
- ],
- dependencies: [
- .package(url: "https://github.com/apple/swift-log.git",
- .upToNextMajor(from: "1.4.3")),
- .package(url: "https://github.com/apple/swift-collections.git",
- .upToNextMinor(from: "1.0.0")),
- .package(url: "https://github.com/compnerd/cassowary.git",
- branch: "main"),
- .package(url: "https://github.com/compnerd/swift-com.git",
- revision: "ebbc617d3b7ba3a2023988a74bebd118deea4cc5"),
- ],
- targets: [
- .target(name: "CoreAnimation",
- path: "Sources/SwiftWin32/CoreAnimation"),
- .target(name: "CoreGraphics",
- path: "Sources/SwiftWin32/CoreGraphics"),
- .target(name: "SwiftWin32",
- dependencies: [
- "CoreAnimation",
- "CoreGraphics",
- .product(name: "Logging", package: "swift-log"),
- .product(name: "OrderedCollections",
- package: "swift-collections"),
- .product(name: "cassowary", package: "cassowary"),
- .product(name: "SwiftCOM", package: "swift-com"),
- ],
- path: "Sources/SwiftWin32",
- exclude: [
- "CoreAnimation",
- "CoreGraphics",
- "CMakeLists.txt"
- ],
- swiftSettings: [
- .enableExperimentalFeature("AccessLevelOnImport"),
- ],
- linkerSettings: [
- .linkedLibrary("User32"),
- .linkedLibrary("ComCtl32"),
- ]),
- .target(name: "SwiftWin32UI",
- dependencies: ["SwiftWin32"],
- path: "Sources/SwiftWin32UI",
- exclude: ["CMakeLists.txt"]),
- .executableTarget(name: "Calculator",
- dependencies: ["SwiftWin32"],
- path: "Examples/Calculator",
- exclude: [
- "CMakeLists.txt",
- "Calculator.exe.manifest",
- "Info.plist",
- ],
- swiftSettings: [
- .unsafeFlags(["-parse-as-library"])
- ]),
- .executableTarget(name: "UICatalog",
- dependencies: ["SwiftWin32"],
- path: "Examples/UICatalog",
- exclude: [
- "CMakeLists.txt",
- "Info.plist",
- "UICatalog.exe.manifest",
- ],
- resources: [
- .copy("Assets/CoffeeCup.jpg")
- ],
- swiftSettings: [
- .unsafeFlags(["-parse-as-library"])
- ]),
- .target(name: "TestUtilities", path: "Tests/Utilities"),
- .testTarget(name: "AutoLayoutTests", dependencies: ["SwiftWin32"]),
- .testTarget(name: "CoreGraphicsTests", dependencies: ["CoreGraphics"]),
- .testTarget(name: "SupportTests", dependencies: ["SwiftWin32"]),
- .testTarget(name: "UICoreTests",
- dependencies: ["SwiftWin32", "TestUtilities"])
- ])
diff --git a/Package@swift-5.4.swift b/Package@swift-5.4.swift
deleted file mode 100644
index 5ff5f6d1..00000000
--- a/Package@swift-5.4.swift
+++ /dev/null
@@ -1,76 +0,0 @@
-// swift-tools-version:5.4
-
-import PackageDescription
-
-let SwiftWin32 = Package(
- name: "SwiftWin32",
- products: [
- .library(name: "SwiftWin32", type: .dynamic, targets: ["SwiftWin32"]),
- .library(name: "SwiftWin32UI", type: .dynamic, targets: ["SwiftWin32UI"]),
- .executable(name: "UICatalog", targets: ["UICatalog"]),
- .executable(name: "Calculator", targets: ["Calculator"]),
- ],
- dependencies: [
- .package(url: "https://github.com/apple/swift-log.git",
- .upToNextMajor(from: "1.4.3")),
- .package(url: "https://github.com/apple/swift-collections.git",
- .upToNextMinor(from: "1.0.0")),
- .package(url: "https://github.com/compnerd/cassowary.git", .branch("main")),
- .package(name: "SwiftCOM", url: "https://github.com/compnerd/swift-com.git",
- .revision("ebbc617d3b7ba3a2023988a74bebd118deea4cc5")),
- ],
- targets: [
- .target(
- name: "SwiftWin32",
- dependencies: [
- .product(name: "Logging", package: "swift-log"),
- .product(name: "OrderedCollections", package: "swift-collections"),
- .product(name: "cassowary", package: "cassowary"),
- .product(name: "SwiftCOM", package: "SwiftCOM"),
- ],
- path: "Sources/SwiftWin32",
- exclude: ["CMakeLists.txt"],
- linkerSettings: [
- .linkedLibrary("User32"),
- .linkedLibrary("ComCtl32"),
- ]
- ),
- .target(
- name: "SwiftWin32UI",
- dependencies: ["SwiftWin32"],
- path: "Sources/SwiftWin32UI",
- exclude: ["CMakeLists.txt"]
- ),
- .executableTarget(
- name: "Calculator",
- dependencies: ["SwiftWin32"],
- path: "Examples/Calculator",
- exclude: [
- "CMakeLists.txt",
- "Calculator.exe.manifest",
- "Info.plist",
- ],
- swiftSettings: [.unsafeFlags(["-parse-as-library"])]
- ),
- .executableTarget(
- name: "UICatalog",
- dependencies: ["SwiftWin32"],
- path: "Examples/UICatalog",
- exclude: [
- "CMakeLists.txt",
- "Info.plist",
- "UICatalog.exe.manifest",
- ],
- resources: [.copy("Assets/CoffeeCup.jpg")],
- swiftSettings: [.unsafeFlags(["-parse-as-library"])]
- ),
- .target(name: "TestUtilities", path: "Tests/Utilities"),
- .testTarget(name: "AutoLayoutTests", dependencies: ["SwiftWin32"]),
- .testTarget(name: "CoreGraphicsTests", dependencies: ["SwiftWin32"]),
- .testTarget(name: "SupportTests", dependencies: ["SwiftWin32"]),
- .testTarget(
- name: "UICoreTests",
- dependencies: ["SwiftWin32", "TestUtilities"]
- )
- ]
-)
diff --git a/Package@swift-5.5.swift b/Package@swift-5.5.swift
deleted file mode 120000
index bd1da396..00000000
--- a/Package@swift-5.5.swift
+++ /dev/null
@@ -1 +0,0 @@
-Package@swift-5.4.swift
\ No newline at end of file
diff --git a/Package@swift-5.6.swift b/Package@swift-5.6.swift
deleted file mode 120000
index bd1da396..00000000
--- a/Package@swift-5.6.swift
+++ /dev/null
@@ -1 +0,0 @@
-Package@swift-5.4.swift
\ No newline at end of file
diff --git a/Package@swift-5.7.swift b/Package@swift-5.7.swift
deleted file mode 100644
index e699cc56..00000000
--- a/Package@swift-5.7.swift
+++ /dev/null
@@ -1,87 +0,0 @@
-// swift-tools-version:5.7
-
-import PackageDescription
-
-let SwiftWin32: Package =
- Package(name: "SwiftWin32",
- products: [
- .library(name: "SwiftWin32",
- type: .dynamic,
- targets: ["SwiftWin32"]),
- .library(name: "SwiftWin32UI",
- type: .dynamic,
- targets: ["SwiftWin32UI"]),
- .executable(name: "UICatalog", targets: ["UICatalog"]),
- .executable(name: "Calculator", targets: ["Calculator"]),
- ],
- dependencies: [
- .package(url: "https://github.com/apple/swift-log.git",
- .upToNextMajor(from: "1.4.3")),
- .package(url: "https://github.com/apple/swift-collections.git",
- .upToNextMinor(from: "1.0.0")),
- .package(url: "https://github.com/compnerd/cassowary.git",
- branch: "main"),
- .package(url: "https://github.com/compnerd/swift-com.git",
- revision: "ebbc617d3b7ba3a2023988a74bebd118deea4cc5"),
- ],
- targets: [
- .target(name: "CoreAnimation",
- path: "Sources/SwiftWin32/CoreAnimation"),
- .target(name: "CoreGraphics",
- path: "Sources/SwiftWin32/CoreGraphics"),
- .target(name: "SwiftWin32",
- dependencies: [
- "CoreAnimation",
- "CoreGraphics",
- .product(name: "Logging", package: "swift-log"),
- .product(name: "OrderedCollections",
- package: "swift-collections"),
- .product(name: "cassowary", package: "cassowary"),
- .product(name: "SwiftCOM", package: "swift-com"),
- ],
- path: "Sources/SwiftWin32",
- exclude: [
- "CoreAnimation",
- "CoreGraphics",
- "CMakeLists.txt",
- ],
- linkerSettings: [
- .linkedLibrary("User32"),
- .linkedLibrary("ComCtl32"),
- ]),
- .target(name: "SwiftWin32UI",
- dependencies: ["SwiftWin32"],
- path: "Sources/SwiftWin32UI",
- exclude: ["CMakeLists.txt"]),
- .executableTarget(name: "Calculator",
- dependencies: ["SwiftWin32"],
- path: "Examples/Calculator",
- exclude: [
- "CMakeLists.txt",
- "Calculator.exe.manifest",
- "Info.plist",
- ],
- swiftSettings: [
- .unsafeFlags(["-parse-as-library"])
- ]),
- .executableTarget(name: "UICatalog",
- dependencies: ["SwiftWin32"],
- path: "Examples/UICatalog",
- exclude: [
- "CMakeLists.txt",
- "Info.plist",
- "UICatalog.exe.manifest",
- ],
- resources: [
- .copy("Assets/CoffeeCup.jpg")
- ],
- swiftSettings: [
- .unsafeFlags(["-parse-as-library"])
- ]),
- .target(name: "TestUtilities", path: "Tests/Utilities"),
- .testTarget(name: "AutoLayoutTests", dependencies: ["SwiftWin32"]),
- .testTarget(name: "CoreGraphicsTests", dependencies: ["CoreGraphics"]),
- .testTarget(name: "SupportTests", dependencies: ["SwiftWin32"]),
- .testTarget(name: "UICoreTests",
- dependencies: ["SwiftWin32", "TestUtilities"])
- ])
diff --git a/Package@swift-5.8.swift b/Package@swift-5.8.swift
deleted file mode 120000
index 731795f1..00000000
--- a/Package@swift-5.8.swift
+++ /dev/null
@@ -1 +0,0 @@
-Package@swift-5.7.swift
\ No newline at end of file
diff --git a/Packages/SwiftCOM b/Packages/SwiftCOM
deleted file mode 160000
index ebbc617d..00000000
--- a/Packages/SwiftCOM
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit ebbc617d3b7ba3a2023988a74bebd118deea4cc5
diff --git a/Packages/cassowary b/Packages/cassowary
deleted file mode 160000
index a4386112..00000000
--- a/Packages/cassowary
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit a438611231901f9f350da27857d786f7979d578b
diff --git a/Packages/swift-collections b/Packages/swift-collections
deleted file mode 160000
index c0549b62..00000000
--- a/Packages/swift-collections
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit c0549b6284aadd5fd13156316f43fcb43c7fca77
diff --git a/Packages/swift-log b/Packages/swift-log
deleted file mode 160000
index d8af258a..00000000
--- a/Packages/swift-log
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit d8af258aecd93cd8604e74ade3c0fe438bac13f8
diff --git a/README.md b/README.md
deleted file mode 100644
index ad5d1888..00000000
--- a/README.md
+++ /dev/null
@@ -1,65 +0,0 @@
-Swift/Win32 - A Swift Application Framework for Windows
--------------------------------------------------------
-
-
-
-
-
-Swift/Win32 aims to provide a [MVC](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller) model for writing applications on Windows. It provides Swift friendly wrapping of the Win32 APIs much like [MFC](https://en.wikipedia.org/wiki/Microsoft_Foundation_Class_Library) did for C++.
-
-## Build Requirements
-
-- Swift 5.4 or newer
-- Windows SDK 10.0.107763 or newer
-- CMake 3.16 or newer
-
-## Building
-
-This project requires Swift 5.4 or newer. You can use the the snapshot binaries from [swift.org](https://swift.org/download/), download the nightly build from [Azure](https://dev.azure.com/compnerd/swift-build), or build the Swift compiler from source.
-
-### Recommended (CMake)
-
-The following example session shows how to build with CMake 3.16 or newer.
-
-```cmd
-cmake -B build -D BUILD_SHARED_LIBS=YES -D CMAKE_BUILD_TYPE=Release -D CMAKE_Swift_FLAGS="-sdk %SDKROOT%" -G Ninja -S .
-ninja -C build SwiftWin32 UICatalog
-
-%CD%\build\bin\UICatalog.exe
-```
-
-
- Required Environment Variables
-
- The CMake build will automatically perform the application manifest merging via the `mt` tool, which is part of the Visual Studio build tools. Ensure that you run the build under the `x64 Native Tools Command Prompt for VS2019` (or the appropriate shell for the version of Visual Studio).
-
- The Swift installer will also add environment variables, ensure that you have restarted the terminal emulator after installing the toolchain to pick up the required environment variables.
-
-
-### Swift Package Manager
-
-Building this project with swift-package-manager is supported although CMake is recommended for ease. The Swift Package Manager based build is required for code completion via SourceKit-LSP. It also allows for the use of Swift/Win32 in other applications using SPM. In order to use SPM to build this project additional post-build steps are required to use the demo applications.
-
-The following known limitations are known:
-
-1. It is not possible to deploy auxiliary files which are required for Swift/Win32 based applications to function to the correct location.
-2. It is not possible to build and run multiple demo projects as the auxiliary files collide.
-
-```cmd
-swift build --product UICatalog
-mt -nologo -manifest Examples\UICatalog\UICatalog.exe.manifest -outputresource:.build\x86_64-unknown-windows-msvc\debug\UICatalog.exe
-copy Examples\UICatalog\Info.plist .build\x86_64-unknown-windows-msvc\debug\
-.build\x86_64-unknown-windows-msvc\debug\UICatalog.exe
-```
-
-In order to get access to the manifest tool (`mt`), the build and testing should occur in a [x64 Native Tools Command Prompt for VS2019](https://docs.microsoft.com/en-us/cpp/build/how-to-enable-a-64-bit-visual-cpp-toolset-on-the-command-line?view=msvc-160)
-
-## Testing
-
-The current implementation is still under flux and many of the interfaces we expect to be present are not yet implemented. Because clearly indicating the missing surface makes it easier to focus on what needs to be accomplished, there are many instances of interfaces being declared but not implemented. Most of these sites will abort if they are reached. In order to enable testing for scenarios which may interct with these cases, a special condition has been added as `ENABLE_TESTING` to allow us to bypass the missing functionality.
-
-You can run tests by adding that as a flag when invoking the SPM test command as:
-
-```cmd
-swift test -Xswiftc -DENABLE_TESTING
-```
diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt
deleted file mode 100644
index 2a9385bb..00000000
--- a/Sources/CMakeLists.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-#[[
-Copyright © 2019 Saleem Abdulrasool
-All rights reserved.
-
-SPDX-License-Identifier: BSD-3-Clause
-#]]
-
-# NOTE(compnerd) because these modules are meant to be static and pristine,
-# there can be no changes to the sources here. As such, these modules are safe
-# to glob because they cannot impact the build.
-
-file(GLOB CASSOWARY_SOURCES
- ${PROJECT_SOURCE_DIR}/Packages/cassowary/Sources/Cassowary/*.swift)
-add_library(Cassowary SHARED
- ${CASSOWARY_SOURCES})
-set_target_properties(Cassowary PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
-_install_target(Cassowary)
-
-file(GLOB_RECURSE COM_SOURCES
- ${PROJECT_SOURCE_DIR}/Packages/SwiftCOM/Sources/SwiftCOM/*.swift
- ${PROJECT_SOURCE_DIR}/Packages/SwiftCOM/Sources/SwiftCOM/**/*.swift)
-add_library(SwiftCOM SHARED
- ${COM_SOURCES})
-target_link_libraries(SwiftCOM PUBLIC
- Ole32
- PortableDeviceGUIDs)
-set_target_properties(SwiftCOM PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
-_install_target(SwiftCOM)
-
-file(GLOB LOGGING_SOURCES
- ${PROJECT_SOURCE_DIR}/Packages/swift-log/Sources/Logging/*.swift)
-# FIXME(compnerd) 5.5 does not officially support static libraries on Windows
-# either. The support requires a version strictly greater than 5.5. Once the
-# branch is introduced, adjust this accordingly.
-if(Swift_COMPILER_VERSION VERSION_LESS 5.5)
- add_library(Logging SHARED
- ${LOGGING_SOURCES})
- _install_target(Logging)
-else()
- add_library(Logging STATIC
- ${LOGGING_SOURCES})
-endif()
-
-add_subdirectory(SwiftWin32)
-add_subdirectory(SwiftWin32UI)
diff --git a/Sources/SwiftWin32/Animation and Haptics/Property-Based Animations/CubicTimingParameters.swift b/Sources/SwiftWin32/Animation and Haptics/Property-Based Animations/CubicTimingParameters.swift
deleted file mode 100644
index 94b48be6..00000000
--- a/Sources/SwiftWin32/Animation and Haptics/Property-Based Animations/CubicTimingParameters.swift
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright © 2021 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-#if swift(>=5.7)
-import CoreGraphics
-#endif
-
-/// The timing information for animations in the form of a cubic Bézier curve.
-public class CubicTimingParameters {
- // MARK - Initializing a Cubic Timing Parameters Object
-
- /// Initializes the object with the system’s default timing curve.
- public init() {
- self.animationCurve = .linear
- self.controlPoint1 = .zero
- self.controlPoint2 = Point(x: 1, y: 1)
- }
-
- /// Initializes the object with the specified builtin timing curve.
- public init(animationCurve curve: View.AnimationCurve) {
- self.animationCurve = curve
- self.controlPoint1 = .zero
- self.controlPoint2 = .zero
- }
-
- /// Initializes the object with the specified control points for a cubic
- /// Bézier curve.
- public init(controlPoint1 point1: Point, controlPoint2 point2: Point) {
- self.animationCurve = .linear
- self.controlPoint1 = point1
- self.controlPoint2 = point2
- }
-
- // MARK - Getting the Timing Parameters
-
- /// The standard builtin animation curve to use for timing.
- public private(set) var animationCurve: View.AnimationCurve
-
- /// The first control point for the cubic Bézier curve.
- public private(set) var controlPoint1: Point
-
- /// The second control point of the cubic Bézier curve.
- public private(set) var controlPoint2: Point
-}
diff --git a/Sources/SwiftWin32/Animation and Haptics/Property-Based Animations/SpringTimingParameters.swift b/Sources/SwiftWin32/Animation and Haptics/Property-Based Animations/SpringTimingParameters.swift
deleted file mode 100644
index 5cadc584..00000000
--- a/Sources/SwiftWin32/Animation and Haptics/Property-Based Animations/SpringTimingParameters.swift
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright © 2021 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-#if swift(>=5.7)
-import CoreGraphics
-#endif
-
-/// The timing information for animations that mimics the behavior of a spring.
-public class SpringTimingParameters {
- // MARK - Initializing a Spring Timing Parameters Object
-
- /// Creates a default timing parameters object.
- ///
- /// This method sets the initial velocity of any animated properties to 0.0
- /// and sets the damping ratio to 4.56.
- public init() {
- self.initialVelocity = .zero
- }
-
- /// Creates a timing parameters object with the specified damping ratio.
- ///
- /// This method sets the initial velocity of any animated properties to 0.0.
- public convenience init(dampingRatio ratio: Double) {
- self.init(dampingRatio: ratio, initialVelocity: .zero)
- }
-
- /// Creates a timing parameters object with the specified damping ratio and
- /// initial velocity.
- public init(dampingRatio ratio: Double, initialVelocity velocity: Vector) {
- self.initialVelocity = velocity
- }
-
- /// Creates a timing parameters object with the specified spring stiffness,
- /// mass, damping coefficient, and initial velocity.
- ///
- /// The damping ratio for the spring is computed from the formula:
- /// `damping / (2 * sqrt (stiffness * mass))`.
- public init(mass: Double, stiffness: Double, damping: Double,
- initialVelocity velocity: Vector) {
- self.initialVelocity = velocity
- }
-
- // MARK - Getting the Initial Velocity
-
- /// The target property’s rate of change at the start of a spring animation,
- /// enabling a smooth transition into the animation.
- public private(set) var initialVelocity: Vector
-}
diff --git a/Sources/SwiftWin32/Animation and Haptics/Property-Based Animations/TimingCurveProvider.swift b/Sources/SwiftWin32/Animation and Haptics/Property-Based Animations/TimingCurveProvider.swift
deleted file mode 100644
index 80bd4975..00000000
--- a/Sources/SwiftWin32/Animation and Haptics/Property-Based Animations/TimingCurveProvider.swift
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright © 2021 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// Constants indicating the type of timing information to use.
-public enum TimingCurveType: Int {
- /// Use the built-in timing curves. Specify this value when you want to use
- /// one of the constants in the `View.AnimationCurve` type. Specify the
- /// desired curve using the `cubicTimingParameters` property.
- case builtin
-
- /// Use a custom cubic Bézier curve. Specify the curve information using the
- /// `cubicTimingParameters` property.
- case cubic
-
- /// Use a custom spring animation. Specify the desired curve using the
- /// `springTimingParameters` property.
- case spring
-
- /// Use a combination of timing parameters. This type of curve starts with the
- /// curve defined by the `cubicTimingParameters` property and modifies it
- /// using the spring information in the `springTimingParameters` property.
- case composed
-}
-
-/// An interface for providing the timing information needed to perform
-/// animations.
-public protocol TimingCurveProvider {
- // MARK - Getting the Timing Information
-
- /// The type of timing information to use.
- var timingCurveType: TimingCurveType { get }
-
- /// The cubic timing parameters to use.
- var cubicTimingParameters: CubicTimingParameters? { get }
-
- /// The spring-based timing parameters to use.
- var springTimingParameters: SpringTimingParameters? { get }
-}
diff --git a/Sources/SwiftWin32/Animation and Haptics/Property-Based Animations/ViewAnimating.swift b/Sources/SwiftWin32/Animation and Haptics/Property-Based Animations/ViewAnimating.swift
deleted file mode 100644
index 376e54d9..00000000
--- a/Sources/SwiftWin32/Animation and Haptics/Property-Based Animations/ViewAnimating.swift
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright © 2021 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import struct Foundation.TimeInterval
-
-/// Constants indicating positions within the animation.
-public enum ViewAnimatingPosition: Int {
- /// The end point of the animation. Use this constant when you want the final
- /// values for any animatable properties — that is, you want to refer to the
- /// values you specified in your animation blocks.
- case end
-
- /// The beginning of the animation. Use this constant when you want the
- /// starting values for any animatable properties—that is, the values of the
- /// properties before you applied any animations.
- case start
-
- /// The current position. Use this constant when you want the most recent
- /// value set by an animator object.
- case current
-}
-
-/// Constants indicating the current state of the animation.
-public enum ViewAnimatingState: Int {
- /// The animations have not yet started executing. This is the initial state
- /// of the animator object.
- case inactive
-
- /// The animator object is active and animations are either running or paused.
- /// An animator moves to this state after the first call to `startAnimation()`
- /// or `pauseAnimation()`. It stays in the active state until the animations
- /// finish naturally or until you call the `stopAnimation(_:)` method.
- case active
-
- /// The animation is stopped. Putting an animation into this state ends the
- /// animation and leaves any animatable properties at their current values,
- /// instead of updating them to their intended final values. An animation
- /// cannot be started while in this state.
- case stopped
-}
-
-/// An interface for implementing custom animator objects.
-public protocol ViewAnimating {
- // MARK - Starting and Stopping the Animations
-
- /// Starts the animation from its current position.
- func startAnimation()
-
- /// Starts the animation after the specified delay.
- func startAnimation(afterDelay delay: TimeInterval)
-
- /// Pauses a running animation at its current position.
- func pauseAnimation()
-
- /// Stops the animations at their current positions.
- func stopAnimation(_ withoutFinishing: Bool)
-
- /// Finishes the animations and returns the animator to the inactive state.
- func finishAnimation(at finalPositiong: ViewAnimatingPosition)
-
- // MARK - Getting the Animator's State
-
- /// The completion percentage of the animation.
- var fractionComplete: Double { get set }
-
- /// A boolean value indicating whether the animation is running in the reverse
- /// direction.
- var isReversed: Bool { get set }
-
- /// The current state of the animation.
- var state: ViewAnimatingState { get }
-
- /// A boolean value indicating whether the animation is currently running.
- var isRunning: Bool { get }
-}
diff --git a/Sources/SwiftWin32/Animation and Haptics/Property-Based Animations/ViewImplicitlyAnimating.swift b/Sources/SwiftWin32/Animation and Haptics/Property-Based Animations/ViewImplicitlyAnimating.swift
deleted file mode 100644
index 9dec6851..00000000
--- a/Sources/SwiftWin32/Animation and Haptics/Property-Based Animations/ViewImplicitlyAnimating.swift
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright © 2021 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// An interface for modifying an animation while it is running.
-public protocol ViewImplicitlyAnimating: ViewAnimating {
- // MARK - Modifying Animations
-
- /// Adds the specified animation block to the animator.
- func addAnimations(_ animation: @escaping () -> Void)
-
- /// Adds the specified animation block to the animator with a delay.
- func addAnimations(_ animation: @escaping () -> Void, delayFactor: Double)
-
- /// Adds the specified completion block to the animator.
- func addCompletion(_ completion: @escaping (ViewAnimatingPosition) -> Void)
-
- /// Adjusts the final timing and duration of a paused animation.
- func continueAnimation(withTimingParameters paramters: TimingCurveProvider?,
- durationFactor: Double)
-}
-
-extension ViewImplicitlyAnimating {
- public func addAnimations(_ animation: @escaping () -> Void) {
- self.addAnimations(animation, delayFactor: 0.0)
- }
-
- public func addAnimations(_ animation: @escaping () -> Void,
- delayFactor: Double) {
- }
-
- public func addCompletion(_ completion: @escaping (ViewAnimatingPosition) -> Void) {
- }
-
- public func continueAnimation(withTimingParameters paramters: TimingCurveProvider?,
- durationFactor: Double) {
- }
-}
diff --git a/Sources/SwiftWin32/Animation and Haptics/View Controller Transitions/ViewControllerAnimatedTransitioning.swift b/Sources/SwiftWin32/Animation and Haptics/View Controller Transitions/ViewControllerAnimatedTransitioning.swift
deleted file mode 100644
index 67fca20c..00000000
--- a/Sources/SwiftWin32/Animation and Haptics/View Controller Transitions/ViewControllerAnimatedTransitioning.swift
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright © 2021 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import struct Foundation.TimeInterval
-
-/// A set of methods for implementing the animations for a custom view controller
-/// transition.
-public protocol ViewControllerAnimatedTransitioning {
- // MARK - Performing a Transition
-
- /// Tells your animator object to perform the transition animations.
- func animateTransition(using transitionContext: ViewControllerContextTransitioning)
-
- /// Tells your animator object that the transition animations have finished.
- func animationEnded(_ transitionCompleted: Bool)
-
- // MARK - Reporting Transition Duration
-
- /// Asks your animator object for the duration (in seconds) of the transition
- /// animation.
- func transitionDuration(using transitionContext: ViewControllerContextTransitioning?)
- -> TimeInterval
-
- // MARK - Returning an Interruptible Animator
-
- /// Returns the interruptible animator to use during the transition.
- func interruptibleAnimator(using transitionContext: ViewControllerContextTransitioning)
- -> ViewImplicitlyAnimating
-}
-
-extension ViewControllerAnimatedTransitioning {
- public func animationEnded(_ transitionCompleted: Bool) {
- }
-}
-
-extension ViewControllerAnimatedTransitioning {
- func interruptibleAnimator(using transitionContext: ViewControllerContextTransitioning)
- -> ViewImplicitlyAnimating {
- fatalError("\(#function) not yet implemented")
- }
-}
diff --git a/Sources/SwiftWin32/Animation and Haptics/View Controller Transitions/ViewControllerInteractiveTransitioning.swift b/Sources/SwiftWin32/Animation and Haptics/View Controller Transitions/ViewControllerInteractiveTransitioning.swift
deleted file mode 100644
index eaaf1e61..00000000
--- a/Sources/SwiftWin32/Animation and Haptics/View Controller Transitions/ViewControllerInteractiveTransitioning.swift
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright © 2021 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A set of methods that enable an object (such as a navigation controller) to
-/// drive a view controller transition.
-public protocol ViewControllerInteractiveTransitioning {
- // MARK - Starting an Interactive Transition
-
- /// Called when the system needs to set up the interactive portions of a view
- /// controller transition and start the animations.
- func startInteractiveTransition(_ transitionContext: ViewControllerContextTransitioning)
-
- /// A boolean value indicating whether the transition is interactive when it
- /// starts.
- ///
- /// The value of this property is `true` when the transition is interactive
- /// from the moment it starts. The property is `false` when the transition
- /// starts off as noninteractive. However, even a transition that starts off
- /// as noninteractive may become interactive later if it implements the
- /// `interruptibleAnimator(using:)` method of the
- /// `ViewControllerAnimatedTransitioning` protocol.
- var wantsInteractiveStart: Bool { get }
-
- // MARK - Providing a Transition's Completion Characteristics
-
- /// Called when the system needs the animation completion curve for an
- /// interactive view controller transition.
- var completionCurve: View.AnimationCurve { get }
-
- /// Called when the system needs the speed at which to complete an interactive
- /// transition, after the interactive portion is finished.
- var completionSpeed: Double { get }
-}
-
-extension ViewControllerInteractiveTransitioning {
- public var wantsInteractiveStart: Bool { true }
-}
-
-extension ViewControllerInteractiveTransitioning {
- public var completionCurve: View.AnimationCurve { .easeInOut }
-
- public var completionSpeed: Double { 1.0 }
-}
diff --git a/Sources/SwiftWin32/Animation and Haptics/View Controller Transitions/ViewControllerTransitionCoordinator.swift b/Sources/SwiftWin32/Animation and Haptics/View Controller Transitions/ViewControllerTransitionCoordinator.swift
deleted file mode 100644
index 001dd72c..00000000
--- a/Sources/SwiftWin32/Animation and Haptics/View Controller Transitions/ViewControllerTransitionCoordinator.swift
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-public protocol ViewControllerTransitionCoordinator: ViewControllerTransitionCoordinatorContext {
- /// Responding to View Controller Transition Progress
- func animate(alongsideTransition animation: ((ViewControllerTransitionCoordinatorContext) -> Void)?,
- completion: ((ViewControllerTransitionCoordinatorContext) -> Void)?)
- -> Bool
- func animateAlongsideTransition(in view: View?,
- animation: ((ViewControllerTransitionCoordinatorContext) -> Void)?,
- completion: ((ViewControllerTransitionCoordinatorContext) -> Void)?)
- -> Bool
- func notifyWhenInteractionChanges(_ handler: @escaping (ViewControllerTransitionCoordinatorContext) -> Void)
-}
diff --git a/Sources/SwiftWin32/Animation and Haptics/View Controller Transitions/ViewControllerTransitionCoordinatorContext.swift b/Sources/SwiftWin32/Animation and Haptics/View Controller Transitions/ViewControllerTransitionCoordinatorContext.swift
deleted file mode 100644
index 43e3554a..00000000
--- a/Sources/SwiftWin32/Animation and Haptics/View Controller Transitions/ViewControllerTransitionCoordinatorContext.swift
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import struct Foundation.TimeInterval
-
-#if swift(>=5.7)
-import CoreGraphics
-#endif
-
-/// Modal presentation styles available when presenting view controllers.
-public enum ModalPresentationStyle: Int {
- /// The default presentation style chosen by the system.
- case automatic
-
- /// A presentation style that indicates no adaptations should be made.
- case none
-
- /// A presentation style in which the presented view covers the screen.
- case fullScreen
-
- /// A presentation style that partially covers the underlying content.
- case pageSheet
-
- /// A presentation style that displays the content centered in the screen.
- case formSheet
-
- /// A presentation style where the content is displayed over another view
- /// controller's content.
- case currentContext
-
- /// A custom view presentation style that is managed by a custom presentation
- /// controller and one or more custom animator objects.
- case custom
-
- /// A view presentation style in which the presented view covers the screen.
- case overFullScreen
-
- /// A presentation style where the content is displayed over another view
- /// controller's content.
- case overCurrentContext
-
- /// A presentation style where the content is displayed in a popover view.
- case popover
-
- /// A presentation style that blurs the underlying content before displaying new
- /// content in a full-screen presentation.
- case blurOverFullScreen
-}
-
-/// A set of methods that provides information about an in-progress view
-/// controller transition.
-public protocol ViewControllerTransitionCoordinatorContext {
- // MARK - Getting the Views and the View Controllers
-
- /// Returns the view controllers involved in the transition.
- func viewController(forKey key: TransitionContextViewControllerKey)
- -> ViewController?
-
- /// Returns the specified view involved in the transition.
- func view(forKey key: TransitionContextViewKey) -> View?
-
- /// Returns the view in which the transition takes place.
- var containerView: View { get }
-
- // MARK - Getting the Behaviour Attributes
-
- /// Returns the presentation style being used for the transition.
- var presentationStyle: ModalPresentationStyle { get }
-
- /// Returns the noninteractive duration of a transition.
- var transitionDuration: TimeInterval { get }
-
- /// Returns the completion curve associated with the transition.
- var completionCurve: View.AnimationCurve { get }
-
- /// Returns the starting velocity to use for any final animations.
- var completionVelocity: Double { get }
-
- /// Returns the percentage of completion for an interactive transition when it
- /// moves to its noninteractive phase.
- var percentComplete: Double { get }
-
- // MARK - Getting the Transition State
-
- /// A Boolean value indicating whether the transition started as an
- /// interactive transition.
- var initiallyInteractive: Bool { get }
-
- /// A Boolean value indicating whether the transition is currently interactive.
- var isInteractive: Bool { get }
-
- /// A Boolean value indicating whether the transition is explicitly animated.
- var isAnimated: Bool { get }
-
- /// A Boolean value indicating whether an interactive transition was cancelled.
- var isCancelled: Bool { get }
-
- /// A Boolean value indicating whether the transition animations can be
- /// interrupted.
- var isInterruptible: Bool { get }
-
- // MARK - Getting the Rotation Factor
-
- /// Returns a transform indicating the amount of rotation being applied during
- /// the transition.
- var targetTransform: AffineTransform { get }
-}
diff --git a/Sources/SwiftWin32/Animation and Haptics/View Controller Transitions/ViewControllerTransitioningDelegate.swift b/Sources/SwiftWin32/Animation and Haptics/View Controller Transitions/ViewControllerTransitioningDelegate.swift
deleted file mode 100644
index edfb208b..00000000
--- a/Sources/SwiftWin32/Animation and Haptics/View Controller Transitions/ViewControllerTransitioningDelegate.swift
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright © 2021 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A set of methods that vend objects used to manage a fixed-length or
-/// interactive transition between view controllers.
-public protocol ViewControllerTransitioningDelegate: AnyObject {
- // MARK - Getting the Transition Animator Objects
-
- /// Asks your delegate for the transition animator object to use when
- /// presenting a view controller.
- func animationController(forPresented presented: ViewController,
- presenting: ViewController, source: ViewController)
- -> ViewControllerAnimatedTransitioning?
-
- /// Asks your delegate for the transition animator object to use when
- /// dismissing a view controller.
- func animationController(forDismissed dismissed: ViewController)
- -> ViewControllerAnimatedTransitioning?
-
- // MARK - Getting the Interactive Animator Objects
-
- /// Asks your delegate for the interactive animator object to use when
- /// presenting a view controller.
- func interactionControllerForPresentation(using animator: ViewControllerAnimatedTransitioning)
- -> ViewControllerInteractiveTransitioning?
-
- /// Asks your delegate for the interactive animator object to use when
- /// dismissing a view controller.
- func interactionControllerForDismissal(using animator: ViewControllerAnimatedTransitioning)
- -> ViewControllerInteractiveTransitioning?
-
- // MARK - Getting the Custom Presentation Controller
-
- /// Asks your delegate for the custom presentation controller to use for
- /// managing the view hierarchy when presenting a view controller.
- func presentationController(forPresented presented: ViewController,
- presenting: ViewController?,
- source: ViewController)
- -> PresentationController?
-}
-
-extension ViewControllerTransitioningDelegate {
- public func animationController(forPresented presented: ViewController,
- presenting: ViewController, source: ViewController)
- -> ViewControllerAnimatedTransitioning? {
- return nil
- }
-
- public func animationController(forDismissed dismissed: ViewController)
- -> ViewControllerAnimatedTransitioning? {
- return nil
- }
-}
-
-extension ViewControllerTransitioningDelegate {
- public func interactionControllerForPresentation(using animator: ViewControllerAnimatedTransitioning)
- -> ViewControllerInteractiveTransitioning? {
- return nil
- }
-
- public func interactionControllerForDismissal(using animator: ViewControllerAnimatedTransitioning)
- -> ViewControllerInteractiveTransitioning? {
- return nil
- }
-}
-
-extension ViewControllerTransitioningDelegate {
- public func presentationController(forPresented presented: ViewController,
- presenting: ViewController?,
- source: ViewController)
- -> PresentationController? {
- return nil
- }
-}
diff --git a/Sources/SwiftWin32/Animation and Haptics/ViewControllerContextTransitioning.swift b/Sources/SwiftWin32/Animation and Haptics/ViewControllerContextTransitioning.swift
deleted file mode 100644
index c3b151c5..00000000
--- a/Sources/SwiftWin32/Animation and Haptics/ViewControllerContextTransitioning.swift
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright © 2021 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-#if swift(>=5.7)
-import CoreGraphics
-#endif
-
-/// The keys you use to identify the view controllers involved in a transition.
-public struct TransitionContextViewControllerKey: Equatable, Hashable, RawRepresentable {
- public typealias RawValue = String
-
- public let rawValue: RawValue
-
- public init(rawValue: RawValue) {
- self.rawValue = rawValue
- }
-}
-
-extension TransitionContextViewControllerKey {
- /// A key that identifies the view controller that is visible at the beginning
- /// of the transition, or at the end of a canceled transition.
- public static var from: TransitionContextViewControllerKey {
- TransitionContextViewControllerKey(rawValue: "UITransitionContextFromViewController")
- }
-
- /// A key that identifies the view controller that is visible at the end of a
- /// completed transition.
- public static var to: TransitionContextViewControllerKey {
- TransitionContextViewControllerKey(rawValue: "UITransitionContextToViewController")
- }
-}
-
-/// The keys you use to identify the views involved in a transition.
-public struct TransitionContextViewKey: Equatable, Hashable, RawRepresentable {
- public typealias RawValue = String
-
- public let rawValue: RawValue
-
- public init(rawValue: RawValue) {
- self.rawValue = rawValue
- }
-}
-
-extension TransitionContextViewKey {
- /// A key that identifies the view shown at the beginning of the transition,
- /// or at the end of a canceled transition.
- public static var from: TransitionContextViewKey {
- TransitionContextViewKey(rawValue: "UITransitionContextFromView")
- }
-
- /// A key that identifies the view shown at the end of a completed transition.
- public static var to: TransitionContextViewKey {
- TransitionContextViewKey(rawValue: "UITransitionContextToView")
- }
-}
-
-/// A set of methods that provide contextual information for transition
-/// animations between view controllers.
-public protocol ViewControllerContextTransitioning {
- // MARK - Accessing the Transition Objects
-
- /// The view that acts as the superview for the views involved in the
- /// transition.
- var containerView: View { get }
-
- /// Returns a view controller involved in the transition.
- func viewController(forKey key: TransitionContextViewControllerKey)
- -> ViewController?
-
- /// Returns the specified view involved in the transition.
- func view(forKey key: TransitionContextViewKey) -> View?
-
- // MARK - Getting the Transition Frame Rectangles
-
- /// Returns the starting frame rectangle for the specified view controller's
- /// view.
- func initialFrame(for viewController: ViewController) -> Rect
-
- /// Returns the ending frame rectangle for the specified view controller's
- /// view.
- func finalFrame(for viewController: ViewController) -> Rect
-
- // MARK - Getting the Transition Behaviors
-
- /// A boolean value indicating whether the transition should be animated.
- var isAnimated: Bool { get }
-
- /// A boolean value indicating whether the transition is currently
- /// interactive.
- var isInteractive: Bool { get }
-
- /// Returns the presentation style for the view controller transition.
- var presentationStyle: ModalPresentationStyle { get }
-
- // MARK - Reporting the Transition Progress
-
- /// Notifies the system that the transition animation is done.
- func completeTransition(_ didComplete: Bool)
-
- /// Updates the completion percentage of the transition.
- func updateInteractiveTransition(_ percentComplete: Double)
-
- /// Tells the system to pause the animations.
- func pauseInteractiveTransition()
-
- /// Notifies the system that user interactions signaled the completion of the
- /// transition.
- func finishInteractiveTransition()
-
- /// Notifies the system that user interactions canceled the transition.
- func cancelInteractiveTransition()
-
- /// Returns a boolean value indicating whether the transition was canceled.
- var transitionWasCancelled: Bool { get }
-
- // MARK - Getting the Rotation Factor
-
- /// Returns a transform indicating the amount of rotation being applied during
- /// the transition.
- var targetTransform: AffineTransform { get }
-}
diff --git a/Sources/SwiftWin32/App Extensions/InputViewController.swift b/Sources/SwiftWin32/App Extensions/InputViewController.swift
deleted file mode 100644
index d84de6d5..00000000
--- a/Sources/SwiftWin32/App Extensions/InputViewController.swift
+++ /dev/null
@@ -1,5 +0,0 @@
-// Copyright © 2021 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-public class InputViewController: ViewController {
-}
diff --git a/Sources/SwiftWin32/App and Environment/AdaptivePresentationControllerDelegate.swift b/Sources/SwiftWin32/App and Environment/AdaptivePresentationControllerDelegate.swift
deleted file mode 100644
index 1cd99d38..00000000
--- a/Sources/SwiftWin32/App and Environment/AdaptivePresentationControllerDelegate.swift
+++ /dev/null
@@ -1,168 +0,0 @@
-// Copyright © 2021 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A set of methods that, in conjunction with a presentation controller,
-/// determine how to respond to trait changes in your application.
-public protocol AdaptivePresentationControllerDelegate: AnyObject {
- // MARK - Adapting the Presentation Style
-
- /// Asks the delegate for the presentation style to use when the specified set
- /// of traits are active.
- ///
- /// The presentation controller calls this method when the traits of the
- /// current environment are about to change. Your implementation of this
- /// method can return the preferred presentation style to use for the
- /// specified traits. If you do not return one of the allowed styles, the
- /// presentation controller uses its preferred default style.
- ///
- /// If you do not implement this method in your delegate, the framework calls
- /// the `adaptivePresentationStyle(for:)` method instead.
- func adaptivePresentationStyle(for controller: PresentationController,
- traitCollection: TraitCollection)
- -> ModalPresentationStyle
-
- /// Asks the delegate for the new presentation style to use.
- ///
- /// Use the `adaptivePresentationStyle(for:traitCollection:)` method to handle
- /// all trait changes instead of this method. If you do not implement that
- /// method, you can use this method to change the presentation style when
- /// transitioning to a horizontally compact environment.
- ///
- /// If you do not implement this method or if you return an invalid style, the
- /// current presentation controller returns its preferred default style.
- func adaptivePresentationStyle(for controller: PresentationController)
- -> ModalPresentationStyle
-
- // MARK - Adapting the View Controller
-
- /// Asks the delegate for the view controller to display when adapting to the
- /// specified presentation style.
- ///
- /// When a size class change causes a change to the underlying presentation
- /// style, the presentation controller calls this method to ask for the view
- /// controller to display in that new style. This method is your opportunity
- /// to replace the current view controller with one that is better suited for
- /// the new presentation style. For example, you might use this method to
- /// insert a navigation controller into your view hierarchy to facilitate
- /// pushing new view controllers more easily in the compact environment. In
- /// that instance, you would return a navigation controller whose root view
- /// controller is the currently presented view controller. You could also
- /// return an entirely different view controller if you prefer.
- ///
- /// If you do not implement this method or your implementation returns `nil`,
- /// the presentation controller uses its existing presented view controller.
- func presentationController(_ controller: PresentationController,
- viewControllerForAdaptivePresentationStyle style: ModalPresentationStyle)
- -> ViewController?
-
- // MARK - Responding to Adaptive Transitions
-
- /// Notifies the delegate that an adaptivity-related transition is about to
- /// occur.
- ///
- /// When a size class change occurs, the framework calls this method to let
- /// you know how the presentation controller will adapt. Use this method to
- /// make any additional changes. For example, you might use the transition
- /// coordinator object to create additional animations for the transition.
- func presentationController(_ presentationController: PresentationController,
- willPresentWithAdaptiveStyle style: ModalPresentationStyle,
- transitionCoordinator: ViewControllerTransitionCoordinator?)
-
- /// Notifies the delegate that a user-initiated attempt to dismiss a view was
- /// prevented.
- ///
- /// The framework supports refusing to dismiss a presentation when the
- /// `presentationController.isModalInPresentation` returns `true` or
- /// `presentationControllerShouldDismiss(_:)` returns `false`.
- ///
- /// Use this method to inform the user why the presentation can't be
- /// dismissed, for example, by presenting an instance of `AlertController`.
- func presentationControllerDidAttemptToDismiss(_ presentationController: PresentationController)
-
- /// Asks the delegate for permission to dismiss the presentation.
- ///
- /// The system may call this method at any time. This method isn't guaranteed
- /// to be followed by a call to `presentationControllerWillDismiss(_:)` or
- /// `presentationControllerDidDismiss(_:)`. Make sure that your implementation
- /// of this method returns quickly.
- func presentationControllerShouldDismiss(_ presentationController: PresentationController)
- -> Bool
-
- /// Notifies the delegate after a presentation is dismissed.
- ///
- /// This method is not called if the presentation is dismissed
- /// programmatically.
- func presentationControllerDidDismiss(_ presentationController: PresentationController)
-
- /// Notifies the delegate before a presentation is dismissed.
- ///
- /// You can use this method to set up animations or interaction notifications
- /// with the `presentationController`'s `transitionCoordinator`.
- ///
- /// This method is not called if the presentation is dismissed
- /// programmatically.
- func presentationControllerWillDismiss(_ presentationController: PresentationController)
-
- // MARK - Preparing the Adaptive Presentation Controller
-
- /// Provides an opportunity to configure the adaptive presentation controller
- /// after an adaptivity change.
- ///
- /// The system calls this method during adaptation so the delegate can
- /// configure properties of the adaptive presentation controller before it
- /// presents.
- ///
- /// For example, the system automatically adapts a view controller that
- /// presents as a popover in standard size classes to a sheet in compact size
- /// classes. You can implement this method to customize the sheet's
- /// properties before it presents.
- func presentationController(_ presentationController: PresentationController,
- prepare adaptivePresentationController: PresentationController)
-}
-
-extension AdaptivePresentationControllerDelegate {
- public func adaptivePresentationStyle(for controller: PresentationController,
- traitCollection: TraitCollection)
- -> ModalPresentationStyle {
- return self.adaptivePresentationStyle(for: controller)
- }
-
- public func adaptivePresentationStyle(for controller: PresentationController)
- -> ModalPresentationStyle {
- return controller.presentationStyle
- }
-}
-
-extension AdaptivePresentationControllerDelegate {
- public func presentationController(controller: PresentationController,
- viewControllerForAdaptivePresentationStyle style: ModalPresentationStyle)
- -> ViewController? {
- return controller.presentedViewController
- }
-}
-
-extension AdaptivePresentationControllerDelegate {
- public func presentationController(_ controller: PresentationController,
- willPresentWithAdaptiveStyle style: ModalPresentationStyle,
- transitionCoordinator: ViewControllerTransitionCoordinator?) {
- }
-
- public func presentationControllerDidAttemptToDismiss(_ presentationController: PresentationController) {
- }
-
- public func presentationControllerShouldDismiss(_ presentationController: PresentationController) -> Bool {
- return true
- }
-
- public func presentationControllerDidDismiss(_ presentationController: PresentationController) {
- }
-
- public func presentationControllerWillDismiss(_ presentationController: PresentationController) {
- }
-}
-
-extension AdaptivePresentationControllerDelegate {
- public func presentationController(_ presentationController: PresentationController,
- prepare adaptivePresentationController: PresentationController) {
- }
-}
diff --git a/Sources/SwiftWin32/App and Environment/Application.swift b/Sources/SwiftWin32/App and Environment/Application.swift
deleted file mode 100644
index ca6d3f55..00000000
--- a/Sources/SwiftWin32/App and Environment/Application.swift
+++ /dev/null
@@ -1,186 +0,0 @@
-// Copyright © 2019 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import class Foundation.NSNotification
-
-/// Constants that indicate the preferred size of your content.
-public struct ContentSizeCategory: Equatable, Hashable, RawRepresentable {
- public typealias RawValue = String
-
- public var rawValue: RawValue
-
- public init(rawValue: RawValue) {
- self.rawValue = rawValue
- }
-}
-
-extension ContentSizeCategory {
- // MARK - Font Sizes
-
- /// An unspecified font size.
- public static var unspecified: ContentSizeCategory {
- ContentSizeCategory(rawValue: "_UICTContentSizeCategoryUnspecified")
- }
-
- /// An extra-small font.
- public static var extraSmall: ContentSizeCategory {
- ContentSizeCategory(rawValue: "UICTContentSizeCategoryXS")
- }
-
- /// A small font.
- public static var small: ContentSizeCategory {
- ContentSizeCategory(rawValue: "UICTContentSizeCategoryS")
- }
-
- /// A medium-sized font.
- public static var medium: ContentSizeCategory {
- ContentSizeCategory(rawValue: "UICTContentSizeCategoryM")
- }
-
- /// A large font.
- public static var large: ContentSizeCategory {
- ContentSizeCategory(rawValue: "UICTContentSizeCategoryL")
- }
-
- /// An extra-large font.
- public static var extraLarge: ContentSizeCategory {
- ContentSizeCategory(rawValue: "UICTContentSizeCategoryXL")
- }
-
- /// A font that is larger than the extra-large font but smaller than the
- /// largest font size available.
- public static var extraExtraLarge: ContentSizeCategory {
- ContentSizeCategory(rawValue: "UICTContentSizeCategoryXXL")
- }
-
- /// The largest font size.
- public static var extraExtraExtraLarge: ContentSizeCategory {
- ContentSizeCategory(rawValue: "UICTContentSizeCategoryXXXL")
- }
-
- // MARK - Accessibility Sizes
-
- /// A medium font size that reflects the current accessibility settings.
- public static var accessibilityMedium: ContentSizeCategory {
- ContentSizeCategory(rawValue: "UICTContentSizeCategoryAccessibilityM")
- }
-
- /// A large font size that reflects the current accessibility settings.
- public static var accessibilityLarge: ContentSizeCategory {
- ContentSizeCategory(rawValue: "UICTContentSizeCategoryAccessibilityL")
- }
-
- /// An extra-large font size that reflects the current accessibility settings.
- public static var accessibilityExtraLarge: ContentSizeCategory {
- ContentSizeCategory(rawValue: "UICTContentSizeCategoryAccessibilityXL")
- }
-
- /// A font that is larger than the extra-large font but not the largest
- /// available, reflecting the current accessibility settings.
- public static var accessibilityExtraExtraLarge: ContentSizeCategory {
- ContentSizeCategory(rawValue: "UICTContentSizeCategoryAccessibilityXXL")
- }
-
- /// The largest font size that reflects the current accessibility settings.
- public static var accessibilityExtraExtraExtraLarge: ContentSizeCategory {
- ContentSizeCategory(rawValue: "UICTContentSizeCategoryAccessibilityXXXL")
- }
-
- // MARK - Font Size Change Notifications
-
- /// A notification that posts when the user changes the preferred content size
- /// setting.
- ///
- /// This notification is sent when the value in the
- /// `preferredContentSizeCategory` property changes. The `userInfo` dictionary
- /// of the notification contains the `newValueUserInfoKey` key, which reflects
- /// the new setting.
- public static var didChangeNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIContentSizeCategoryDidChangeNotification")
- }
-
- /// A key that reflects the new preferred content size.
- ///
- /// This key's value is an `NSString` object that reflects the new value of
- /// the `preferredContentSizeCategory` property.
- public static var newValueUserInfoKey: String {
- "UIContentSizeCategoryNewValueUserInfoKey"
- }
-}
-
-/// The centralised point of control and coordination for running applications.
-open class Application: Responder {
- internal var information: Information?
-
- // MARK - Getting the Application Instance
-
- /// Returns the singleton application instance.
- public static var shared: Application = Application()
-
- // MARK - Managing the Application's Behaviour
-
- /// The delegate of the application object.
- public var delegate: ApplicationDelegate?
-
- // MARK - Getting the Application State
-
- /// The applications current state or that of its most active scene.
- public internal(set) var state: Application.State
-
- // MARK - Getting Scene Information
-
- /// A boolean indicating whether the application may display multiple scenes.
- public var supportsMultipleScenes: Bool {
- information?.scene?.supportsMultipleScenes ?? false
- }
-
- /// The application's currently connected scenes.
- public internal(set) var connectedScenes: Set = []
-
- /// The sessions whose scenes are either currently active or archived by the
- /// system.
- public internal(set) var openSessions: Set = []
-
- // MARK - Getting Application Windows
-
- /// The application’s visible and hidden windows.
- public internal(set) var windows: [Window]
-
- /// The application's key window.
- public internal(set) var keyWindow: Window?
-
- override public required init() {
- self.state = .active
- self.windows = []
- super.init()
- }
-
- // MARK - Responder Chain Overrides
-
- override public var next: Responder? {
- // The next responder is the application delegate, but only if the
- // application delegate is an instance of `Responder` and is not a `View`,
- // `ViewController`, or the `Application` object itself.
- if let responder = self.delegate as? Responder,
- !(self.delegate is View), !(self.delegate is ViewController),
- !(self.delegate === self) {
- return responder
- }
- return nil
- }
-}
-
-extension Application {
- /// The running states of the application
- public enum State: Int {
- /// The application is running in the foreground and currently receiving
- /// events.
- case active
-
- /// The application is running in the foreground but is not receiving events.
- case inactive
-
- /// The application is running in the background.
- case background
- }
-}
diff --git a/Sources/SwiftWin32/App and Environment/ApplicationDelegate.swift b/Sources/SwiftWin32/App and Environment/ApplicationDelegate.swift
deleted file mode 100644
index 499152f6..00000000
--- a/Sources/SwiftWin32/App and Environment/ApplicationDelegate.swift
+++ /dev/null
@@ -1,271 +0,0 @@
-// Copyright © 2019 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import class Foundation.NSNotification
-
-/// The orientation of the application's user interface
-public enum InterfaceOrientation: Int {
- /// The orientation of the device is unknown.
- case unknown
-
- /// The device is in portrait mode, with the device upright.
- case portrait
-
- /// The device is in portrait mode, with the device upside down.
- case portraitUpsideDown
-
- /// The device is in landscape mode, with the device upright.
- case landscapeLeft
-
- /// The device is in landscape mode, with the device upright.
- case landscapeRight
-}
-
-extension InterfaceOrientation {
- public var isLandscape: Bool {
- switch self {
- case .landscapeLeft, .landscapeRight:
- return true
- default: return false
- }
- }
-
- public var isPortrait: Bool {
- switch self {
- case .portrait, .portraitUpsideDown:
- return true
- default: return false
- }
- }
-}
-
-/// These constants are mask bits for specifying a view controller's supported
-/// interface orientations.
-public struct InterfaceOrientationMask: OptionSet {
- public typealias RawValue = UInt
-
- public let rawValue: RawValue
-
- public init(rawValue: RawValue) {
- self.rawValue = rawValue
- }
-}
-
-extension InterfaceOrientationMask {
- /// The view controller supports a portrait interface orientation.
- public static var portrait: InterfaceOrientationMask {
- InterfaceOrientationMask(rawValue: 1 << InterfaceOrientation.portrait.rawValue)
- }
-
- /// The view controller supports a landscape-left interface orientation.
- public static var landscapeLeft: InterfaceOrientationMask {
- InterfaceOrientationMask(rawValue: 1 << InterfaceOrientation.landscapeLeft.rawValue)
- }
-
- /// The view controller supports a landscape-right interface orientation.
- public static var landscapeRight: InterfaceOrientationMask {
- InterfaceOrientationMask(rawValue: 1 << InterfaceOrientation.landscapeRight.rawValue)
- }
-
- /// The view controller supports an upside-down portrait interface
- /// orientation.
- public static var portraitUpsideDown: InterfaceOrientationMask {
- InterfaceOrientationMask(rawValue: 1 << InterfaceOrientation.portraitUpsideDown.rawValue)
- }
-
- /// The view controller supports both landscape-left and landscape-right
- /// interface orientation.
- public static var landscape: InterfaceOrientationMask {
- InterfaceOrientationMask(rawValue: self.landscapeLeft.rawValue | self.landscapeRight.rawValue)
- }
-
- /// The view controller supports all interface orientations.
- public static var all: InterfaceOrientationMask {
- InterfaceOrientationMask(rawValue: self.portrait.rawValue | self.landscapeLeft.rawValue | self.landscapeRight.rawValue | self.portraitUpsideDown.rawValue)
- }
-
- /// The view controller supports all but the upside-down portrait interface
- /// orientation.
- public static var allButUpsideDown: InterfaceOrientationMask {
- InterfaceOrientationMask(rawValue: self.portrait.rawValue | self.landscapeLeft.rawValue | self.landscapeRight.rawValue)
- }
-}
-
-/// A set of methods used to manage shared behaviours for the application.
-public protocol ApplicationDelegate: AnyObject, _TriviallyConstructible {
- // MARK - Initializing the App
-
- /// Informs the delegate that the application launch process has begun.
- func application(_ application: Application,
- willFinishLaunchingWithOptions options: [Application.LaunchOptionsKey:Any]?)
- -> Bool
-
- /// Informs the delegate that the application launch process has ended and
- /// the application is almost ready to run.
- func application(_ application: Application,
- didFinishLaunchingWithOptions options: [Application.LaunchOptionsKey:Any]?)
- -> Bool
-
- // MARK - Responding to App Life-Cycle Events
-
- /// Informs the delegate that the application has become active.
- func applicationDidBecomeActive(_ application: Application)
-
- /// Informs the delegate that the application is about to become inactive.
- func applicationWillResignActive(_ application: Application)
-
- /// Informs the delegate that the application is now in the background.
- func applicationDidEnterBackground(_ application: Application)
-
- /// Informs the delegate that the application is about to enter the foreground.
- func applicationWillEnterForeground(_ application: Application)
-
- /// Informs the delegate that the application is about to terminate.
- func applicationWillTerminate(_ application: Application)
-
- // MARK - Responding to Environment Changes
-
- /// Tells the delegate that protected files are available now.
- func applicationProtectedDataDidBecomeAvailable(_ application: Application)
-
- /// Tells the delegate that the protected files are about to become
- /// unavailable.
- func applicationProtectedDataWillBecomeUnavailable(_ application: Application)
-
- /// Tells the delegate when the app receives a memory warning from the system.
- func applicationDidReceiveMemoryWarning(_ application: Application)
-
- /// Tells the delegate when there is a significant change in the time.
- func applicationSignificantTimeChange(_ application: Application)
-
- // MARK - Configuring and Discarding Scenes
-
- /// Returns the configuration data to use when creating a new scene.
- func application(_ application: Application,
- configurationForConnecting connectingSceneSession: SceneSession,
- options: Scene.ConnectionOptions) -> SceneConfiguration
-
- /// Informs the delegate that the user closed one or more of the application's
- /// scenes.
- func application(_ application: Application,
- didDiscardSceneSessions sceneSessions: Set)
-}
-
-extension ApplicationDelegate {
- public func application(_ application: Application,
- willFinishLaunchingWithOptions options: [Application.LaunchOptionsKey:Any]?)
- -> Bool {
- return true
- }
-
- public func application(_ application: Application,
- didFinishLaunchingWithOptions options: [Application.LaunchOptionsKey:Any]?)
- -> Bool {
- return true
- }
-
- /// A notification that posts immediately after the app finishes launching.
- public static var didFinishLaunchingNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIApplicationDidFinishLaunchingNotification")
- }
-}
-
-extension ApplicationDelegate {
- public func applicationDidBecomeActive(_: Application) {
- }
-
- public func applicationWillResignActive(_: Application) {
- }
-
- public func applicationDidEnterBackground(_: Application) {
- }
-
- public func applicationWillEnterForeground(_: Application) {
- }
-
- public func applicationWillTerminate(_: Application) {
- }
-
- /// A notification that posts when the app becomes active.
- public static var didBecomeActiveNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIApplicationDidBecomeActiveNotification")
- }
-
- /// A notification that posts when the app is no longer active and loses
- /// focus.
- public static var willResignActiveNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIApplicationWillResignActiveNotification")
- }
-
- /// A notification that posts when the app enters the background.
- public static var didEnterBackgroundNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIApplicationDidEnterBackgroundNotification")
- }
-
- /// A notification that posts shortly before an app leaves the background
- /// state on its way to becoming the active app.
- public static var willEnterForegroundNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIApplicationWillEnterForegroundNotification")
- }
-
- /// A notification that posts when the app is about to terminate.
- public static var willTerminateNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIApplicationWillTerminateNotification")
- }
-}
-
-extension ApplicationDelegate {
- public func applicationProtectedDataDidBecomeAvailable(_ application: Application) {
- }
-
- public func applicationProtectedDataWillBecomeUnavailable(_ application: Application) {
- }
-
- public func applicationDidReceiveMemoryWarning(_ application: Application) {
- }
-
- public func applicationSignificantTimeChange(_ application: Application) {
- }
-
- /// A notification that posts when the protected files become available for
- /// your code to access.
- public static var protectedDataDidBecomeAvailableNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIApplicationProtectedDataDidBecomeAvailableNotification")
- }
-
- /// A notification that posts shortly before protected files are locked down
- /// and become inaccessible.
- public static var protectedDataWillBecomeUnavailableNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIApplicationProtectedDataWillBecomeUnavailableNotification")
- }
-
- /// A notification that posts when the app receives a warning from the
- /// operating system about low memory availability.
- public static var didReceiveMemoryWarningNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIApplicationDidReceiveMemoryWarningNotification")
- }
-
- /// A notification that posts when there is a significant change in time, for
- /// example, change to a new day (midnight), carrier time update, and change
- /// to or from daylight savings time.
- public static var significantTimeChangeNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIApplicationSignificantTimeChangeNotification")
- }
-}
-
-extension ApplicationDelegate {
- public func application(_ application: Application,
- configurationForConnecting connectingSceneSession: SceneSession,
- options: Scene.ConnectionOptions) -> SceneConfiguration {
- return connectingSceneSession.configuration
- }
-
- public func application(_ application: Application,
- didDiscardSceneSessions sceneSessions: Set) {
- sceneSessions.forEach {
- if let scene = $0.scene {
- scene.delegate?.sceneDidDisconnect(scene)
- }
- }
- }
-}
diff --git a/Sources/SwiftWin32/App and Environment/ApplicationMain.swift b/Sources/SwiftWin32/App and Environment/ApplicationMain.swift
deleted file mode 100644
index ca05b892..00000000
--- a/Sources/SwiftWin32/App and Environment/ApplicationMain.swift
+++ /dev/null
@@ -1,226 +0,0 @@
-// Copyright © 2019 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import WinSDK
-import SwiftCOM
-import Foundation
-
-internal final class Delegate: ApplicationDelegate {}
-
-private let pApplicationStateChangeRoutine: PAPPSTATE_CHANGE_ROUTINE = { (quiesced: UInt8, context: PVOID?) in
- let foregrounding: Bool = quiesced == 0
- if foregrounding {
- Application.shared.delegate?
- .applicationWillEnterForeground(Application.shared)
-
- // Post ApplicationDelegate.willEnterForegroundNotification
- NotificationCenter.default
- .post(name: Delegate.willEnterForegroundNotification,
- object: Application.shared)
- } else {
- Application.shared.delegate?
- .applicationDidEnterBackground(Application.shared)
-
- // Post ApplicationDelegate.willEnterBackgroundNotification
- NotificationCenter.default
- .post(name: Delegate.didEnterBackgroundNotification,
- object: Application.shared)
- }
-}
-
-@discardableResult
-public func ApplicationMain(_ argc: Int32,
- _ argv: UnsafeMutablePointer?>,
- _ application: String?,
- _ delegate: String?) -> Int32 {
- let hRichEdit: HMODULE? = LoadLibraryW("msftedit.dll".wide)
- if hRichEdit == nil {
- log.error("unable to load `msftedit.dll`: \(Error(win32: GetLastError()))")
- }
-
- var information: Application.Information?
- if let path = Bundle.main.path(forResource: "Info", ofType: "plist"),
- let contents = FileManager.default.contents(atPath: path) {
- information = try? PropertyListDecoder().decode(Application.Information.self,
- from: contents)
- }
-
- // Setup the main application class. The following order describes how the
- // user may actually configure the selected class:
- //
- // 1. `application`: the parameter passd to `ApplicationMain(_:_:_:_:)`
- // 2. `PrincipalClass`: the value configured in `Info.plist`
- // 3. `Application`: the default application class provided by Swift/Win32
- //
- // We must have an application class to instantiate as this is the main entry
- // point which is executed by this framework.
- let application = application ?? (information?.principalClass ?? NSStringFromClass(Application.self))
- guard let instance = NSClassFromString(application) else {
- log.error("unable to find application class \(application)")
- exit(EXIT_FAILURE)
- }
- Application.shared = (instance as! Application.Type).init()
-
- // Setup the application's information which was loaded. Because the
- // configuration can indicate the principal class it is loaded prior to the
- // construction of the shared application's construction. Now that the
- // application has been construted, we can instill the configuration.
- Application.shared.information = information
-
- // Setup the application's delegate.
- if let delegate = delegate {
- guard let instance = NSClassFromString(delegate) else {
- fatalError("unable to find delegate class: \(delegate)")
- }
- if instance as? Application.Type == nil {
- Application.shared.delegate = (instance as! ApplicationDelegate.Type).init()
- } else {
- Application.shared.delegate = Application.shared as? ApplicationDelegate
- }
- }
-
- // Initialize COM
- do {
- try CoInitializeEx(COINIT_MULTITHREADED)
- } catch {
- log.error("CoInitializeEx: \(error)")
- return EXIT_FAILURE
- }
-
- // Enable Per Monitor DPI Awareness
- if !SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) {
- log.error("SetProcessDpiAwarenessContext: \(Error(win32: GetLastError()))")
- }
-
- let dwICC: DWORD = DWORD(ICC_BAR_CLASSES)
- | DWORD(ICC_DATE_CLASSES)
- | DWORD(ICC_LISTVIEW_CLASSES)
- | DWORD(ICC_NATIVEFNTCTL_CLASS)
- | DWORD(ICC_PROGRESS_CLASS)
- | DWORD(ICC_STANDARD_CLASSES)
- | DWORD(ICC_TAB_CLASSES)
- var ICCE: INITCOMMONCONTROLSEX =
- INITCOMMONCONTROLSEX(dwSize: DWORD(MemoryLayout.size),
- dwICC: dwICC)
- if !InitCommonControlsEx(&ICCE) {
- log.error("InitCommonControlsEx: \(Error(win32: GetLastError()))")
- }
-
- if Application.shared.delegate?
- .application(Application.shared,
- willFinishLaunchingWithOptions: nil) == false {
- return EXIT_FAILURE
- }
-
- var pAppRegistration: PAPPSTATE_REGISTRATION?
- let ulStatus =
- RegisterAppStateChangeNotification(pApplicationStateChangeRoutine, nil,
- &pAppRegistration)
- if ulStatus != ERROR_SUCCESS {
- log.error("RegisterAppStateChangeNotification: \(Error(win32: GetLastError()))")
- }
- defer { UnregisterAppStateChangeNotification(pAppRegistration) }
-
- if Application.shared.delegate?
- .application(Application.shared,
- didFinishLaunchingWithOptions: nil) == false {
- return EXIT_FAILURE
- }
-
- // Post ApplicationDelegate.didFinishLaunchingNotification
- NotificationCenter.default
- .post(name: Delegate.didFinishLaunchingNotification,
- object: nil, userInfo: nil)
-
- Application.shared.delegate?
- .applicationDidBecomeActive(Application.shared)
-
- // TODO(compnerd) populate these based on the application instantiation
- let options: Scene.ConnectionOptions = Scene.ConnectionOptions()
-
- // Setup the scene session.
- let (_, session) =
- Application.shared.openSessions
- .insert(SceneSession(identifier: UUID().uuidString,
- role: .windowApplication))
-
- // Update the scene configuration based on the delegate's response.
- if let configuration = Application.shared.delegate?
- .application(Application.shared, configurationForConnecting: session,
- options: options) {
- session.configuration = configuration
- }
-
- // Create the scene.
- let SceneType =
- (session.configuration.sceneClass as? Scene.Type) ?? WindowScene.self
-
- let (_, scene) =
- Application.shared.connectedScenes
- .insert(SceneType.init(session: session, connectionOptions: options))
-
- if let DelegateType =
- session.configuration.delegateClass as? SceneDelegate.Type {
- // Only instantiate the scene delegate if the scene delegate is not the
- // Application class or the ApplicationDelegate class.
- if DelegateType as? Application.Type == nil {
- if DelegateType as? ApplicationDelegate.Type == nil {
- scene.delegate = DelegateType.init()
- } else {
- scene.delegate = Application.shared.delegate as? SceneDelegate
- }
- } else {
- scene.delegate = Application.shared as? SceneDelegate
- }
- }
-
- scene.delegate?.scene(scene, willConnectTo: session, options: options)
- session.scene = scene
-
- var msg: MSG = MSG()
- var nExitCode: Int32 = EXIT_SUCCESS
-
- mainLoop: while true {
- // Process all messages in thread's message queue; for GUI applications UI
- // events must have high priority.
- while PeekMessageW(&msg, nil, 0, 0, UINT(PM_REMOVE)) {
- if msg.message == UINT(WM_QUIT) {
- nExitCode = Int32(msg.wParam)
- break mainLoop
- }
-
- TranslateMessage(&msg)
- DispatchMessageW(&msg)
- }
-
- var time: Date? = nil
- repeat {
- // Execute Foundation.RunLoop once and determine the next time the timer
- // fires. At this point handle all Foundation.RunLoop timers, sources and
- // Dispatch.DispatchQueue.main tasks
- time = RunLoop.main.limitDate(forMode: .default)
-
- // If Foundation.RunLoop doesn't contain any timers or the timers should
- // not be running right now, we interrupt the current loop or otherwise
- // continue to the next iteration.
- } while (time?.timeIntervalSinceNow ?? -1) <= 0
-
- // Yield control to the system until the earlier of a requisite timer
- // expiration or a message is posted to the runloop.
- _ = MsgWaitForMultipleObjects(0, nil, false,
- DWORD(exactly: time?.timeIntervalSinceNow ?? -1)
- ?? INFINITE,
- QS_ALLINPUT | DWORD(QS_KEY) | QS_MOUSE | DWORD(QS_RAWINPUT))
- }
-
- Application.shared.delegate?.applicationWillTerminate(Application.shared)
-
- return nExitCode
-}
-
-extension ApplicationDelegate {
- public static func main() {
- ApplicationMain(CommandLine.argc, CommandLine.unsafeArgv, nil,
- String(describing: String(reflecting: Self.self)))
- }
-}
diff --git a/Sources/SwiftWin32/App and Environment/Device.swift b/Sources/SwiftWin32/App and Environment/Device.swift
deleted file mode 100644
index 65d715ae..00000000
--- a/Sources/SwiftWin32/App and Environment/Device.swift
+++ /dev/null
@@ -1,250 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import WinSDK
-import class Foundation.NSNotification
-
-public struct Device {
- public static let current: Device = Device()
-
- /// Is multitasking supported on the current device
- public internal(set) var isMultitaskingSupported: Bool = true
-
- /// The name identifyying the device
- public var name: String {
- let value: [WCHAR] =
- Array(unsafeUninitializedCapacity: Int(MAX_COMPUTERNAME_LENGTH) + 1) {
- var nSize: DWORD = DWORD($0.count)
- $1 = GetComputerNameW($0.baseAddress!, &nSize) ? Int(nSize) + 1 : 0
- }
- return String(decodingCString: value, as: UTF16.self)
- }
-
- /// The name of the operating system running on the device represented by the
- // receiver.
- public var systemName: String {
- var szBuffer: [WCHAR] = Array(repeating: 0, count: 64)
- while true {
- var cbData: DWORD = DWORD(szBuffer.count * MemoryLayout.size)
- let lStatus: LSTATUS =
- RegGetValueW(HKEY_LOCAL_MACHINE,
- "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion".wide,
- "ProductName".wide,
- DWORD(RRF_RT_REG_SZ | RRF_ZEROONFAILURE),
- nil, &szBuffer, &cbData)
- if lStatus == ERROR_MORE_DATA {
- szBuffer = Array(repeating: 0, count: szBuffer.count * 2)
- continue
- }
- guard lStatus == 0 else {
- log.warning("RegGetValueW: \(lStatus)")
- return ""
- }
- return String(decodingCString: szBuffer, as: UTF16.self)
- }
- }
-
- /// The current version of the operating system.
- public var systemVersion: String {
- var szBuffer: [WCHAR] = Array(repeating: 0, count: 64)
- while true {
- var cbData: DWORD = DWORD(szBuffer.count * MemoryLayout.size)
- let lStatus: LSTATUS =
- RegGetValueW(HKEY_LOCAL_MACHINE,
- "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion".wide,
- "CurrentBuildNumber".wide,
- DWORD(RRF_RT_REG_SZ | RRF_ZEROONFAILURE),
- nil, &szBuffer, &cbData)
- if lStatus == ERROR_MORE_DATA {
- szBuffer = Array(repeating: 0, count: szBuffer.count * 2)
- continue
- }
- guard lStatus == 0 else {
- log.warning("RegGetValueW: \(lStatus)")
- return ""
- }
- return String(decodingCString: szBuffer, as: UTF16.self)
- }
- }
-
- /// The model of the device.
- public var model: String {
- fatalError("\(#function) not implemented")
- }
-
- public var localizedModel: String {
- fatalError("\(#function) not implemented")
- }
-
- /// The style of interface to use on the current device.
- public var userInterfaceIdiom: UserInterfaceIdiom {
- return .unspecified
- }
-
- /// An alphanumeric string that uniquely identifies a device to the
- /// application vendor.
- public var identifierForVendor: UUID? {
- // TODO(compnerd) should be Windows.System.Profile.GetSystemIdForPublisher()
- return nil
- }
-
- /// Tracking the Device Orientation
- public var orientation: Device.Orientation {
- var dmDeviceMode: DEVMODEW = DEVMODEW()
- dmDeviceMode.dmSize = WORD(MemoryLayout.size)
- dmDeviceMode.dmDriverExtra = 0
- if !EnumDisplaySettingsExW(nil, ENUM_CURRENT_SETTINGS, &dmDeviceMode, 0) {
- log.warning("EnumDisplaySettingsExW: \(Error(win32: GetLastError()))")
- return .unknown
- }
-
- let dwRequiredFields: DWORD =
- DWORD(DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYORIENTATION)
- guard dmDeviceMode.dmFields & dwRequiredFields == dwRequiredFields else {
- return .unknown
- }
-
- switch dmDeviceMode.dmDisplayOrientation {
- case DWORD(DMDO_90), DWORD(DMDO_270):
- swap(&dmDeviceMode.dmPelsHeight, &dmDeviceMode.dmPelsWidth)
- case DWORD(DMDO_DEFAULT), DWORD(DMDO_180):
- break
- default:
- log.error("unknown display orientation: \(dmDeviceMode.dmDisplayOrientation)")
- return .unknown
- }
-
- let bPortrait: Bool = dmDeviceMode.dmPelsWidth < dmDeviceMode.dmPelsHeight
- switch dmDeviceMode.dmDisplayOrientation {
- case DWORD(DMDO_DEFAULT):
- return bPortrait ? .portrait : .landscapeLeft
- case DWORD(DMDO_90):
- return bPortrait ? .landscapeRight : .portrait
- case DWORD(DMDO_180):
- return bPortrait ? .portraitUpsideDown : .landscapeRight
- case DWORD(DMDO_270):
- return bPortrait ? .landscapeLeft : .portraitUpsideDown
- default:
- return .unknown
- }
- }
-
- public private(set) var isGeneratingDeviceOrientationNotifications: Bool =
- false
-
- public func beginGeneratingDeviceOrientationNotifications() {
- // TODO(compnerd) implement this
- }
-
- public func endGeneratingDeviceOrientationNotifications() {
- // TODO(compnerd) implement this
- }
-
- /// Determining the Current Orientation
- public var isPortrait: Bool {
- switch self.orientation {
- case .portrait, .portraitUpsideDown: return true
- default: return false
- }
- }
-
- public var isLandscape: Bool {
- switch self.orientation {
- case .landscapeLeft, .landscapeRight: return true
- default: return false
- }
- }
-
- public var isValidIntefaceOrientation: Bool {
- true
- }
-
- /// Getting the Device Battery State
- public var batteryLevel: Float {
- guard Device.current.isBatteryMonitoringEnabled else { return -1.0 }
-
- var status: SYSTEM_POWER_STATUS = SYSTEM_POWER_STATUS()
- guard GetSystemPowerStatus(&status) else {
- log.warning("GetSystemPowerStatus: \(Error(win32: GetLastError()))")
- return -1.0
- }
-
- if status.BatteryLifePercent == 255 { return -1.0 }
- return Float(status.BatteryLifePercent) / 100.0
- }
-
- private var batteryMonitor: BatteryMonitor?
- public var isBatteryMonitoringEnabled: Bool = false {
- didSet {
- self.batteryMonitor =
- self.isBatteryMonitoringEnabled
- ? (self.batteryMonitor ?? BatteryMonitor())
- : nil
- }
- }
-
- public var batteryState: Device.BatteryState {
- guard Device.current.isBatteryMonitoringEnabled else { return .unknown }
-
- var status: SYSTEM_POWER_STATUS = SYSTEM_POWER_STATUS()
- guard GetSystemPowerStatus(&status) else {
- log.warning("GetSystemPowerStatus: \(Error(win32: GetLastError()))")
- return .unknown
- }
-
- // If the system does not have a battery (e.g. desktop system), present as
- // `unknown`.
- guard status.BatteryFlag & BYTE(BATTERY_FLAG_NO_BATTERY) == 0 else {
- return .unknown
- }
-
- // If AC power is offline, we are unplugged.
- if status.ACLineStatus & BYTE(AC_LINE_OFFLINE) == BYTE(AC_LINE_OFFLINE) {
- return .unplugged
- }
-
- // Either we are `charging` or the battery is `full`.
- return status.BatteryFlag & BYTE(BATTERY_FLAG_CHARGING) == BYTE(BATTERY_FLAG_CHARGING)
- ? .charging
- : .full
- }
-}
-
-extension Device {
- public enum BatteryState: Int {
- case unknown
- case unplugged
- case charging
- case full
- }
-}
-
-extension Device {
- public enum Orientation: Int {
- case unknown
- case portrait
- case portraitUpsideDown
- case landscapeLeft
- case landscapeRight
- case faceUp
- case faceDown
- }
-}
-
-extension Device {
- public static var batteryLevelDidChangeNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIDeviceBatteryLevelDidChangeNotification")
- }
-
- public static var batteryStateDidChangeNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIDeviceBatteryStateDidChangeNotification")
- }
-
- public static var orientationDidChangeNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIDeviceOrientationDidChangeNotification")
- }
-
- public static var proximityStateDidChangeNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIDeviceProximityStateDidChangeNotification")
- }
-}
diff --git a/Sources/SwiftWin32/App and Environment/Scenes/Scene.swift b/Sources/SwiftWin32/App and Environment/Scenes/Scene.swift
deleted file mode 100644
index 05259171..00000000
--- a/Sources/SwiftWin32/App and Environment/Scenes/Scene.swift
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import WinSDK
-import class Foundation.NSNotification
-
-extension Scene {
- public class ConnectionOptions {
- }
-}
-
-public class Scene: Responder {
- /// Creating a Scene Object
-
- /// Creates a scene object using the specified session and connection
- /// information.
- public required init(session: SceneSession,
- connectionOptions: Scene.ConnectionOptions) {
- self.session = session
- }
-
- /// Managing the Life Cycle of a Scene
-
- /// The object you use to recieve life-cycle events associated with the scene.
- public var delegate: SceneDelegate?
-
- /// Getting the Scene's Session
-
- /// The session associated with the scene.
- public let session: SceneSession
-}
-
-extension Scene {
- /// A notification indicating that a scene was added to the application.
- public class var willConnectNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UISceneWillConnectNotification")
- }
-
- /// A notification indicating that a scene was removed from the application.
- public class var didDisconnectNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UISceneDidDisconnectNotification")
- }
-
- /// A notification indicating that a scene is about to begin running in the
- /// foreground and become visible to the user.
- public class var willEnterForegroundNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UISceneWillEnterForegroundNotification")
- }
-
- /// A notification indicating that the scene is now onscreen and reponding to
- /// user events.
- public class var didActivateNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UISceneDidActivateNotification")
- }
-
- /// A notification indicating that the scene is about to resign the active
- /// state and stop responding to user events.
- public class var willDeactivateNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UISceneWillDeactivateNotification")
- }
-
- /// A notification indicating that the scene is running in the background and
- /// is no longer onscreen.
- public class var didEnterBackgroundNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UISceneDidEnterBackgroundNotification")
- }
-}
-
-extension Scene: Hashable {
- public static func == (lhs: Scene, rhs: Scene) -> Bool {
- // TODO(compnerd) figure out the proper equality check for Scene
- return lhs === rhs
- }
-
- public func hash(into hasher: inout Hasher) {
- // TODO(compnerd) figure out the proper hashing for Scene
- }
-}
diff --git a/Sources/SwiftWin32/App and Environment/Scenes/SceneConfiguration.swift b/Sources/SwiftWin32/App and Environment/Scenes/SceneConfiguration.swift
deleted file mode 100644
index 29ab34a0..00000000
--- a/Sources/SwiftWin32/App and Environment/Scenes/SceneConfiguration.swift
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import func Foundation.NSClassFromString
-
-public class SceneConfiguration {
- /// Creating a Configuration Object
-
- /// Creates a scene-configuration object with the specified role and
- /// application-specific name.
- public init(name: String?, sessionRole: SceneSession.Role) {
- self.name = name
- self.role = sessionRole
-
- // Try to load the configuration from the Info.plist ...
-
- // ... which requires that we have an Info.plist
- guard let info = Application.shared.information else {
- return
- }
-
- // ... which requires that the Info.plist contains scene configuration
- guard let configurations =
- info.scene?.configurations?[sessionRole.rawValue] else {
- return
- }
-
- // ... taking the configuration which matches the name or the first entry
- guard let scene = name == nil
- ? configurations.first
- : configurations.filter({ $0.name == name }).first else {
- return
- }
- // ... overwriting the scene name to the current configuration's scene name
- self.name = scene.name
-
- // ... deserialising the scene class if one was provided
- if let sceneClass = scene.class {
- self.sceneClass = NSClassFromString(sceneClass)
- }
-
- // .. deserialising the delegate class if one was provided
- if let delegateClass = scene.delegate {
- self.delegateClass = NSClassFromString(delegateClass)
- }
- }
-
- /// Specifying the Scene Creation Details
-
- /// The class of the scene object you want to create.
- public var sceneClass: AnyClass?
-
- /// The class of the delegate object you want to create.
- public var delegateClass: AnyClass?
-
- /// Getting the Configuration Attributes
-
- /// The application-specific name assigned to the scene configuration.
- public private(set) var name: String?
-
- /// The role assigned to the scene configuration.
- public let role: SceneSession.Role
-}
-
-extension SceneConfiguration: Hashable {
- public static func == (lhs: SceneConfiguration, rhs: SceneConfiguration)
- -> Bool {
- return lhs.name == rhs.name && lhs.role == rhs.role
- }
-
- public func hash(into hasher: inout Hasher) {
- hasher.combine(self.name)
- hasher.combine(self.role)
- }
-}
diff --git a/Sources/SwiftWin32/App and Environment/Scenes/SceneDelegate.swift b/Sources/SwiftWin32/App and Environment/Scenes/SceneDelegate.swift
deleted file mode 100644
index 018055b1..00000000
--- a/Sources/SwiftWin32/App and Environment/Scenes/SceneDelegate.swift
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import WinSDK
-
-public protocol SceneDelegate: _TriviallyConstructible {
- // MARK - Connecting and Disconnecting the Scene
-
- /// Informs the delegate about the addition of a scene to the application.
- func scene(_ scene: Scene, willConnectTo: SceneSession,
- options: Scene.ConnectionOptions)
-
- /// Informs the delegate that a scene was removed from the application.
- func sceneDidDisconnect(_ scene: Scene)
-
- // MARK - Transitioning to the Foreground
-
- /// Informs the delegate that the scene is about to begin running in the
- /// foreground and become visible to the user.
- func sceneWillEnterForeground(_ scene: Scene)
-
- /// Informs the delegate that the scene became active and is now responding to
- /// user events.
- func sceneDidBecomeActive(_ scene: Scene)
-
- // MARK - Transitioning to the Background
-
- /// Informs the delegate that the scene is about to resign the active state
- /// and stop responding to user events.
- func sceneWillResignActive(_ scene: Scene)
-
- /// Informs the delegate that the scene is running in the background and is no
- /// longer onscreen.
- func sceneDidEnterBackground(_ scene: Scene)
-}
-
-extension SceneDelegate {
- public func scene(_ scene: Scene, willConnectTo: SceneSession,
- options: Scene.ConnectionOptions) {
- }
-
- public func sceneDidDisconnect(_ scene: Scene) {
- }
-}
-
-extension SceneDelegate {
- public func sceneWillEnterForeground(_ scene: Scene) {
- }
-
- public func sceneDidBecomeActive(_ scene: Scene) {
- }
-}
-
-extension SceneDelegate {
- public func sceneWillResignActive(_ scene: Scene) {
- }
-
- public func sceneDidEnterBackground(_ scene: Scene) {
- }
-}
diff --git a/Sources/SwiftWin32/App and Environment/Scenes/SceneSession.swift b/Sources/SwiftWin32/App and Environment/Scenes/SceneSession.swift
deleted file mode 100644
index bd9a1cef..00000000
--- a/Sources/SwiftWin32/App and Environment/Scenes/SceneSession.swift
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-extension SceneSession {
- /// Constants that indicate the possible roles for a scene.
- public struct Role: Equatable, Hashable, RawRepresentable {
- public typealias RawValue = String
-
- public let rawValue: RawValue
-
- public init(rawValue: RawValue) {
- self.rawValue = rawValue
- }
- }
-}
-
-extension SceneSession.Role {
- /// The scene displays noninteractive windows on an externally connected
- /// screen.
- public static var windowApplication: SceneSession.Role {
- SceneSession.Role(rawValue: "UIWindowSceneSessionRoleApplication")
- }
-
- /// The scene displays interactive content on the device's main screen.
- public static var windowExternalDisplay: SceneSession.Role {
- SceneSession.Role(rawValue: "UIWindowSceneSessionRoleExternalDisplay")
- }
-}
-
-public class SceneSession {
- // MARK - Getting the Scene Information
-
- /// The scene associated with the current session.
- public internal(set) weak var scene: Scene?
-
- /// The role played by the scene's content.
- public let role: SceneSession.Role
-
- // MARK - Getting the Scene Configuration Details
-
- /// The configuration data for creating the secene.
- // This is mutable as the configuration is only finalized after the deleate
- // has formed the final configuration.
- public internal(set) var configuration: SceneConfiguration
-
- // MARK - Identifying the Scene
-
- /// A unique identifier that persists for the lifetime of the session
- public let persistentIdentifier: String
-
- internal init(identifier: String, role: SceneSession.Role,
- configuration name: String? = nil) {
- self.persistentIdentifier = identifier
- self.role = role
- self.configuration = SceneConfiguration(name: name, sessionRole: role)
- }
-}
-
-extension SceneSession: Hashable {
- public static func == (lhs: SceneSession, rhs: SceneSession) -> Bool {
- return lhs.persistentIdentifier == rhs.persistentIdentifier
- }
-
- public func hash(into hasher: inout Hasher) {
- hasher.combine(self.persistentIdentifier)
- }
-}
diff --git a/Sources/SwiftWin32/App and Environment/Scenes/WindowScene.swift b/Sources/SwiftWin32/App and Environment/Scenes/WindowScene.swift
deleted file mode 100644
index 63884cd0..00000000
--- a/Sources/SwiftWin32/App and Environment/Scenes/WindowScene.swift
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-public class WindowScene: Scene {
- public required init(session: SceneSession,
- connectionOptions: Scene.ConnectionOptions) {
- // TODO(compnerd) we really should base this on the device properties.
- // Windows Phone should have set the sizeRestrictions to nil. Similarly,
- // Surface Neo and Surface Duo Devices will not permit the window resizing.
- self.sizeRestrictions = SceneSizeRestrictions()
-
- // FIXME(compnerd) how do you attach a different screen to the window scene?
- self.screen = Screen.main
-
- super.init(session: session, connectionOptions: connectionOptions)
- }
-
- /// Getting the Active Windows
-
- /// The windows associated with the scene.
- public internal(set) var windows: [Window] = []
-
- /// The screen that displays the content of the scene.
- public private(set) var screen: Screen
-
- /// Getting the Interface Attributes
-
- /// The minimum and maximum size of the application's windows.
- public private(set) var sizeRestrictions: SceneSizeRestrictions?
-}
diff --git a/Sources/SwiftWin32/App and Environment/Scenes/WindowSceneDelegate.swift b/Sources/SwiftWin32/App and Environment/Scenes/WindowSceneDelegate.swift
deleted file mode 100644
index 36c8420b..00000000
--- a/Sources/SwiftWin32/App and Environment/Scenes/WindowSceneDelegate.swift
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// Additional methods that you can use to manage application specific tasks
-/// occurring in a scene.
-public protocol WindowSceneDelegate: SceneDelegate {
- // MARK - Managing the Scene's Main Window
-
- /// The main window associated with the scene.
- var window: Window? { get set }
-
- // MARK - Responding to Scene Changes
-
- /// Notifies you when the size, orientation, or traits of a scene change.
- func windowScene(_ windowScene: WindowScene,
- didUpdate previousCoordinateSpace: CoordinateSpace,
- interfaceOrientation previousInterfaceOrientation: InterfaceOrientation,
- traitCollection previousTraitCollection: TraitCollection)
-}
-
-extension WindowSceneDelegate {
- public var window: Window? {
- get { return nil }
- set { }
- }
-}
-
-extension WindowSceneDelegate {
- public func windowScene(_ windowScene: WindowScene,
- didUpdate previousCoordinateSpace: CoordinateSpace,
- interfaceOrientation previousInterfaceOrientation: InterfaceOrientation,
- traitCollection previousTraitCollection: TraitCollection) {
- }
-}
diff --git a/Sources/SwiftWin32/App and Environment/TraitCollection.swift b/Sources/SwiftWin32/App and Environment/TraitCollection.swift
deleted file mode 100644
index e5af045d..00000000
--- a/Sources/SwiftWin32/App and Environment/TraitCollection.swift
+++ /dev/null
@@ -1,549 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import WinSDK
-
-/// Constants that indicate the size class of a view.
-public enum UserInterfaceSizeClass: Int {
- /// Indicates the size class has not been specified.
- case unspecified
-
- /// Indicates a compact size class.
- case compact
-
- /// Indicates a regular size class.
- case regular
-}
-
-/// Constants that indicate the gamut of the current display.
-public enum DisplayGamut: Int {
- /// An unspecified gamut value.
- case unspecified
-
- /// The sRGB display gamut.
- case SRGB
-
- /// The P3 display gamut.
- case P3
-}
-
-/// Constants that indicate the interface style for the application.
-public enum UserInterfaceStyle: Int {
- /// An unspecified interface style.
- case unspecified
-
- /// The light interface style.
- case light
-
- /// The dark interface style.
- case dark
-}
-
-/// Constants that indicate whether the user interface has an active appearance.
-public enum UserInterfaceActiveAppearance: Int {
- /// The interface has an unspecified appearance.
- case unspecified = -1
-
- /// The interface has an inactive appearance.
- case inactive
-
- /// The interface has an active appearance.
- case active
-}
-
-/// Constants that indicate the interface type for the device or an object that
-/// has a trait environment, such as a view and view controller.
-public enum UserInterfaceIdiom: Int {
- /// An unspecified idiom.
- case unspecified = -1
-
- /// An interface designed for a phone.
- case phone
-
- @available(*, deprecated, renamed: "UserInterfaceIdiom.tablet")
- case pad
-
- /// An interface designed for a TV.
- case tv
-
- @available(*, deprecated, message: "Use UserInterfaceIdiom.car")
- case carPlay
-
- @available(*, deprecated, renamed: "UserInterfaceIdiom.desktop")
- case mac
-
- /// An interface designed for a tablet.
- case tablet
-
- /// An interface designed for a car display.
- case car
-
- /// An interface designed for a desktop or laptop.
- case desktop
-
- /// An interface designed for a AR/VR device.
- case headset
-}
-
-/// Constants that indicate the visual level for content in the window.
-public enum UserInterfaceLevel: Int {
- /// An unspecified interface level.
- ///
- /// Choose this option when you want to follow the inherited level.
- case unspecified = -1
-
- /// The level for your window's main content.
- case base
-
- /// The level for content visually above your window's main content.
- case elevated
-}
-
-/// Constants that indicate the layout direction associated with the current
-/// environment.
-public enum TraitEnvironmentLayoutDirection: Int {
- /// An unknown layout direction.
- case unspecified = -1
-
- /// A left-to-right layout direction.
- case leftToRight
-
- /// A right-to-left layout direction.
- case rightToLeft
-}
-
-/// Constants that indicate the accessibility contrast setting.
-public enum AccessibilityContrast: Int {
- /// An unspecified contrast.
- case unspecified = -1
-
- /// A normal contrast level.
- case normal
-
- /// A high contrast level.
- case high
-}
-
-/// The font weight to apply to text.
-///
-/// The legibility weight reflects the value of the Bold Text display setting.
-public enum LegibilityWeight: Int {
- /// An unspecified text weight.
- case unspecified = -1
-
- /// A regular font weight.
- case regular
-
- /// A bold font weight.
- case bold
-}
-
-/// Keys that indicate the availability of 3D Touch on a device.
-public enum ForceTouchCapability: Int {
- /// The availability of 3D Touch is unknown.
- ///
- /// A view has this trait after you create it but before you add it your
- /// application's view hierarchy.
- case unspecified
-
- /// 3D Touch is available on the device.
- case available
-
- /// 3D Touch is not available on the device.
- case unavailable
-}
-
-private func GetCurrentColorScheme() -> UserInterfaceStyle {
- var dwAppsUseLightTheme: DWORD = 1
- var cbAppsUseLightTheme: DWORD =
- DWORD(MemoryLayout.size(ofValue: dwAppsUseLightTheme))
-
- // TODO: query the `RequestedTheme` property of the `Application` from the
- // manifest
-
- let lStatus: LSTATUS =
- RegGetValueW(HKEY_CURRENT_USER,
- "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize".wide,
- "AppsUseLightTheme".wide,
- DWORD(RRF_RT_REG_DWORD), nil,
- &dwAppsUseLightTheme, &cbAppsUseLightTheme)
- guard lStatus == S_OK else {
- log.error("RegGetValueW: \(lStatus)")
- return .unspecified
- }
- return dwAppsUseLightTheme == 0 ? .dark : .light
-}
-
-private func GetCurrentDeviceFamily() -> UserInterfaceIdiom {
- return GetSystemMetrics(SM_TABLETPC) == 0 ? .unspecified : .tablet
-}
-
-private func GetCurrentAccessibilityContrast() -> AccessibilityContrast {
- var hcContrast: HIGHCONTRASTW = HIGHCONTRASTW()
- hcContrast.cbSize = UINT(MemoryLayout.size)
- if !SystemParametersInfoW(UINT(SPI_GETHIGHCONTRAST), 0, &hcContrast, 0) {
- log.error("SystemParametersInfoW: \(Error(win32: GetLastError()))")
- return .unspecified
- }
- return Int32(hcContrast.dwFlags) & HCF_HIGHCONTRASTON == HCF_HIGHCONTRASTON
- ? .high : .normal
-}
-
-private func GetCurrentLayoutDirection() -> TraitEnvironmentLayoutDirection {
- var dwDefaultLayout: DWORD = 0
- if !GetProcessDefaultLayout(&dwDefaultLayout) {
- log.error("GetProcessDefaultLayout: \(Error(win32: GetLastError()))")
- return .unspecified
- }
- return dwDefaultLayout == LAYOUT_RTL ? .rightToLeft : .leftToRight
-}
-
-private func GetCurrentDisplayScale() -> Double {
- let hMonitor: HMONITOR =
- MonitorFromWindow(GetDesktopWindow(), DWORD(MONITOR_DEFAULTTOPRIMARY))
- var dsfDeviceScaleFactor: DEVICE_SCALE_FACTOR = SCALE_100_PERCENT
- let hr: HRESULT = GetScaleFactorForMonitor(hMonitor, &dsfDeviceScaleFactor)
- guard hr == S_OK else {
- log.warning("GetScaleFactorFromMonitor: \(String(hr, radix: 16))")
- return 0.0
- }
- return dsfDeviceScaleFactor.factor
-}
-
-private func GetCurrentDisplayGamut() -> DisplayGamut {
- // TODO(compnerd) identify the actual display gamut in use for the primary
- // display. sRGB is still far more common than DCI-P3, so assume that for
- // now. Note that in reality, its more likely that the display is using
- // wsRGB, which is a Windows "optimized" sRGB color gamut.
- return .SRGB
-}
-
-public class TraitCollection {
- /// Creates an empty trait collection.
- internal init() {
- }
-
- // MARK - Creating a Trait Collection
-
- /// Creates a trait collection that consists of traits merged from a specified
- /// array of trait collections.
- ///
- /// This method takes an array of one or more trait collections and merges
- /// them to create a new trait collection. If the array contains more than one
- /// element, the highest-indexed element that contains a given trait is used
- /// for that trait. For example, the following code snippet creates a trait
- /// collection with a compact horizontal size class, because the second
- /// element in the array overrides the first for that trait:
- ///
- /// ```swift
- /// let collection1: TraitCollection = TraitCollection(horizontalSizeClass: .regular)
- /// let collection2: TraitCollection = TraitCollection(horizontalSizeClass: .compact)
- /// let collection3: TraitCollection = TraitCollection(traitsFrom: [collection1, collection2])
- /// ```
- public init(traitsFrom traits: [TraitCollection]) {
- _ = traits.map {
- if $0.horizontalSizeClass != .unspecified {
- self.horizontalSizeClass = $0.horizontalSizeClass
- }
- if $0.verticalSizeClass != .unspecified {
- self.verticalSizeClass = $0.verticalSizeClass
- }
- if $0.displayScale != 0.0 {
- self.displayScale = $0.displayScale
- }
- if $0.displayGamut != .unspecified {
- self.displayGamut = $0.displayGamut
- }
- if $0.userInterfaceStyle != .unspecified {
- self.userInterfaceStyle = $0.userInterfaceStyle
- }
- if $0.userInterfaceIdiom != .unspecified {
- self.userInterfaceIdiom = $0.userInterfaceIdiom
- }
- if $0.userInterfaceLevel != .unspecified {
- self.userInterfaceLevel = $0.userInterfaceLevel
- }
- if $0.layoutDirection != .unspecified {
- self.layoutDirection = $0.layoutDirection
- }
- if $0.accessibilityContrast != .unspecified {
- self.accessibilityContrast = $0.accessibilityContrast
- }
- if $0.legibilityWeight != .unspecified {
- self.legibilityWeight = $0.legibilityWeight
- }
- if $0.activeAppearance != .unspecified {
- self.activeAppearance = $0.activeAppearance
- }
- if $0.forceTouchCapability != .unspecified {
- self.forceTouchCapability = $0.forceTouchCapability
- }
- if $0.preferredContentSizeCategory != .unspecified {
- self.preferredContentSizeCategory = $0.preferredContentSizeCategory
- }
- }
- }
-
- /// Creates a trait collection that contains only a specified interface idiom.
- public init(userInterfaceIdiom: UserInterfaceIdiom) {
- self.userInterfaceIdiom = userInterfaceIdiom
- }
-
- /// Creates a trait collection that contains only a specified horizontal size
- /// class.
- public init(horizontalSizeClass: UserInterfaceSizeClass) {
- self.horizontalSizeClass = horizontalSizeClass
- }
-
- /// Creates a trait collection that contains only a specified vertical size
- /// class.
- public init(verticalSizeClass: UserInterfaceSizeClass) {
- self.verticalSizeClass = verticalSizeClass
- }
-
- /// Creates a trait collection that contains only the specified user interface
- /// style trait.
- public init(userInterfaceStyle: UserInterfaceStyle) {
- self.userInterfaceStyle = userInterfaceStyle
- }
-
- /// Creates a trait collection that contains only the specified accessibility
- /// contrast trait.
- public init(accessibilityContrast: AccessibilityContrast) {
- self.accessibilityContrast = accessibilityContrast
- }
-
- /// Creates a trait collection that contains only the specified user interface
- /// level trait.
- public init(userInterfaceLevel: UserInterfaceLevel) {
- self.userInterfaceLevel = userInterfaceLevel
- }
-
- /// Creates a trait collection that contains only the specified legibility
- /// weight trait.
- public init(legibilityWeight: LegibilityWeight) {
- self.legibilityWeight = legibilityWeight
- }
-
- /// Creates a trait collection that contains only a specified force touch
- /// capability trait.
- public init(forceTouchCapability: ForceTouchCapability) {
- self.forceTouchCapability = forceTouchCapability
- }
-
- /// Creates a trait collection that contains only a specified display scale.
- public init(displayScale: Double) {
- self.displayScale = displayScale
- }
-
- /// Creates a trait collection that contains only the specified display gamut
- /// trait.
- public init(displayGamut: DisplayGamut) {
- self.displayGamut = displayGamut
- }
-
- /// Creates a trait collection that contains only the specified layout
- /// direction trait.
- public init(layoutDirection: TraitEnvironmentLayoutDirection) {
- self.layoutDirection = layoutDirection
- }
-
- /// Creates a trait collection that contains only the specified content size
- /// category trait.
- public init(preferredContentSizeCategory: ContentSizeCategory) {
- self.preferredContentSizeCategory = preferredContentSizeCategory
- }
-
- /// Creates a trait collection that contains only the specified active
- /// appearance trait.
- public init(activeAppearance: UserInterfaceActiveAppearance) {
- self.activeAppearance = activeAppearance
- }
-
- // MARK - Getting the Current Traits
-
- // TODO(compnerd) The framework stores the value for this property as a
- // thread-local variable, so access to it is fast.
-
- /// The complete set of traits for the current environment.
- ///
- /// The framework updates the value of this property before calling several
- /// well-known methods of `View`, `ViewController`, and
- /// `PresentationController`. The trait collection contains a complete set of
- /// trait values describing the current environment, and does not include
- /// unspecified or unknown values.
- ///
- /// Changing the traits on a nonmain thread does not affect the current traits
- /// on your applications's main thread.
- public private(set) static var current: TraitCollection =
- TraitCollection(traitsFrom: [
- TraitCollection(accessibilityContrast: GetCurrentAccessibilityContrast()),
- TraitCollection(displayGamut: GetCurrentDisplayGamut()),
- TraitCollection(displayScale: GetCurrentDisplayScale()),
- TraitCollection(layoutDirection: GetCurrentLayoutDirection()),
- TraitCollection(preferredContentSizeCategory: .large),
- TraitCollection(userInterfaceIdiom: GetCurrentDeviceFamily()),
- TraitCollection(userInterfaceLevel: .base),
- TraitCollection(userInterfaceStyle: GetCurrentColorScheme()),
-
- TraitCollection(horizontalSizeClass: Device.current.isPortrait
- ? .compact
- : .regular),
- TraitCollection(verticalSizeClass: Device.current.isPortrait
- ? .regular
- : .compact),
- ])
-
- // MARK - Retriving Size Class Traits
-
- /// The horizontal size class of the trait collection.
- public private(set) var horizontalSizeClass: UserInterfaceSizeClass =
- .unspecified
-
- /// The vertical size class of the trait collection.
- public private(set) var verticalSizeClass: UserInterfaceSizeClass =
- .unspecified
-
- // MARK -Retriving Display-Related Traits
-
- /// The display scale of the trait collection.
- ///
- /// A value of 1.0 indicates a non-Retina display and a value of 2.0 indicates
- /// a Retina display. The default display scale for a trait collection is 0.0
- /// (indicating unspecified).
- public private(set) var displayScale: Double = 0.0
-
- /// The gamut of the current display.
- public private(set) var displayGamut: DisplayGamut = .unspecified
-
- // MARK - Retriving Interface-Related Traits
-
- /// The style associated with the user interface.
- ///
- /// Use this trait to determine whether your interface should be configured
- /// with a dark or light appearance. The default value of this trait is set to
- /// the corresponding appearance setting on the user's device.
- public private(set) var userInterfaceStyle: UserInterfaceStyle = .unspecified
-
- /// The user interface idiom of the trait collection.
- ///
- /// The default user interface idiom for a trait collection is
- /// `UserInterfaceIdiom.unspecified`.
- public private(set) var userInterfaceIdiom: UserInterfaceIdiom = .unspecified
-
- /// The elevation level of the interface.
- ///
- /// Levels create a visual separation between different parts of your UI.
- /// `Window` content typically appears at the `UserInterfaceLevel.base` level.
- /// When you want parts of your UI to stand out from the underlying
- /// background, assign the `UserInterfaceLevel.elevated` level to them. For
- /// example, the system assigns the `UserInterfaceLevel.elevated` level to
- /// alerts and popovers.
- public private(set) var userInterfaceLevel: UserInterfaceLevel = .unspecified
-
- /// The layout direction associated with the current environment.
- ///
- /// Use this trait to determine whether the underlying environment uses a
- /// left-to-right or right-to-left orientation.
- public private(set) var layoutDirection: TraitEnvironmentLayoutDirection =
- .unspecified
-
- /// The accessibility contrast associated with the current environment.
- ///
- /// Use this trait to determine whether the user requested a high contrast
- /// between foreground and background content. The user sets the contrast
- /// level in Accessibility Settings.
- public private(set) var accessibilityContrast: AccessibilityContrast =
- .unspecified
-
- /// The font weight to apply to text.
- ///
- /// The legibility weight reflects the value of the Bold Text display setting.
- public private(set) var legibilityWeight: LegibilityWeight = .unspecified
-
- /// A property that indicates whether the user interface has an active
- /// appearance.
- ///
- /// The active appearance varies according to window activation state.
- public private(set) var activeAppearance: UserInterfaceActiveAppearance =
- .unspecified
-
- // MARK - Retriving the Force Touch Capability
-
- /// The force touch capability value of the trait collection.
- ///
- /// Force Touch is available only on certain devices. On those devices,
- /// availability is determined by the user's associated accessibility setting
- /// in Settings. Check this property's value on app launch, and in your
- /// implementation of the `traitCollectionDidChange(_:)` method.
- ///
- /// If this property does not contain a value, the meaning is equivalent to
- /// the value `ForceTouchCapability.unknown`.
- public private(set) var forceTouchCapability: ForceTouchCapability =
- .unspecified
-
- // MARK - Retriving Content Size Category Information
-
- /// The font sizing option preferred by the user.
- ///
- /// With dynamic text sizing, users can ask that apps display text using fonts
- /// that are larger or smaller than the normal font size defined by the
- /// system. For example, a user with a visual impairment might request a
- /// larger default font size to make it easier to read text. Use the value of
- /// this property to request a `Font` object that matches the user's requested
- /// size.
- public private(set) var preferredContentSizeCategory: ContentSizeCategory =
- .unspecified
-
- // MARK - Comparing Trait Collections
-
- /// Queries whether a trait collection contains all of another trait
- /// collection's values.
- ///
- /// Use this method to compare two standalone trait collections, or to compare
- /// the interface environment's trait collection to a standalone trait
- /// collection.
- public func containsTraits(in trait: TraitCollection?) -> Bool {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Queries whether changing between the specified and current trait
- /// collections would affect color values.
- ///
- /// Use this method to determine whether changing the traits of the current
- /// environment would also change the colors in your interface. For example,
- /// changing the `userInterfaceStyle` or `accessibilityContrast` property
- /// usually changes the colors of your interface.
- public func hasDifferentColorAppearance(comparedTo traitCollection: TraitCollection?)
- -> Bool {
- fatalError("\(#function) not yet implemented")
- }
-
-
- // MARK - Getting an Image Configuration Object
-
- /// An image configuration object compatible with this trait collection.
- ///
- /// The `Image.Configuration` object in this property contains the same traits
- /// as the current trait collection.
- public var imageConfiguration: Image.Configuration {
- fatalError("\(#function) not yet implemented")
- }
-
- // MARK - Performing Actions with the Current Traits
-
- /// Executes custom code using the traits of the current trait collection.
- ///
- /// Use this method when you want to execute code using a set of traits that
- /// differ from those in the current trait environment. For example, you might
- /// use this method to draw part of a view's content with a different set of
- /// traits. This method temporarily replaces the traits of the current
- /// environment with the ones found in the current `TraitCollection`. After
- /// the actions block finishes, the method restores the original traits to the
- /// environment.
- ///
- /// You can call this method from any thread of your application.
- public func performAsCurrent(_ actions: () -> Void) {
- fatalError("\(#function) not yet implemented")
- }
-}
diff --git a/Sources/SwiftWin32/App and Environment/TraitEnvironment.swift b/Sources/SwiftWin32/App and Environment/TraitEnvironment.swift
deleted file mode 100644
index a259e493..00000000
--- a/Sources/SwiftWin32/App and Environment/TraitEnvironment.swift
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A set of methods that makes the interface environment available to your
-/// application.
-public protocol TraitEnvironment {
- // MARK - Accessing a Trait Collection
-
- /// The traits, such as the size class and scale factor, that describe the
- /// current environment of the object.
- var traitCollection: TraitCollection { get }
-
- // MARK - Responding to a Change in the Interface Environment
-
- /// Called when the interface environment changes.
- func traitCollectionDidChange(_ previousTraitCollection: TraitCollection?)
-}
diff --git a/Sources/SwiftWin32/Appearance Customization/Appearance.swift b/Sources/SwiftWin32/Appearance Customization/Appearance.swift
deleted file mode 100644
index e6ba4e01..00000000
--- a/Sources/SwiftWin32/Appearance Customization/Appearance.swift
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A collection of methods that gives you access to the appearance proxy for a
-/// class.
-public protocol Appearance {
- // MARK - Appearance Methods
-
- /// Returns the appearance proxy for the receiver.
- static func appearance() -> Self
-
- /// Returns the appearance proxy for the receiver that has the passed trait
- /// collection.
- static func appearance(for trait: TraitCollection) -> Self
-
- /// Returns the appearance proxy for the object when it is contained in the
- /// hierarchy the specified classes describe.
- static func appearance(whenContainedInInstancesOf containerTypes: [AppearanceContainer.Type])
- -> Self
-
- /// Returns the appearance proxy for the object when it is contained in the
- /// hierarchy the specified classes describe and has the specified trait
- /// collection.
- static func appearance(for trait: TraitCollection,
- whenContainedInInstancesOf containerTypes: [AppearanceContainer.Type]) -> Self
-}
diff --git a/Sources/SwiftWin32/Appearance Customization/AppearanceContainer.swift b/Sources/SwiftWin32/Appearance Customization/AppearanceContainer.swift
deleted file mode 100644
index 602a5c09..00000000
--- a/Sources/SwiftWin32/Appearance Customization/AppearanceContainer.swift
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A protocol that a class must adopt to allow appearance customization using
-/// the `Appearance` API.
-public protocol AppearanceContainer {
-}
diff --git a/Sources/SwiftWin32/Appearance Customization/Configurations/BackgroundConfiguration.swift b/Sources/SwiftWin32/Appearance Customization/Configurations/BackgroundConfiguration.swift
deleted file mode 100644
index c8f035d6..00000000
--- a/Sources/SwiftWin32/Appearance Customization/Configurations/BackgroundConfiguration.swift
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A configuration that describes a specific background appearance.
-public struct BackgroundConfiguration {
- // MARK - Creating Cell Background Configurations
-
- /// Creates a default configuration for a plain list cell.
- public static func listPlainCell() -> BackgroundConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates a default configuration for a grouped list cell.
- public static func listGroupedCell() -> BackgroundConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates a default configuration for a sidebar list cell.
- public static func listSidebarCell() -> BackgroundConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates a default configuration for an accompanied sidebar list cell.
- public static func listAccompaniedSidebarCell() -> BackgroundConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- // MARK - Creating Header and Footer Background Configurations
-
- /// Creates a default configuration for a plain list header or footer.
- public static func listPlainHeaderFooter() -> BackgroundConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates a default configuration for a grouped list header or footer.
- public static func listGroupedHeaderFooter() -> BackgroundConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates a default configuration for a sidebar list header.
- public static func listSidebarHeader() -> BackgroundConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- // MARK - Creating an Empty Background Configuration
-
- /// Creates an empty background configuration with a transparent background
- /// and no default styling.
- public static func clear() -> BackgroundConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- // MARK - Customizing the Background
-
- /// A custom view for the background.
- public var customView: View?
-
- /// The preferred corner radius, using a continuous corner curve, for the
- /// background and stroke.
- public var cornerRadius: Double = 0.0
-
- /// The insets (or outsets, if negative) for the background and stroke,
- /// relative to the edges of the containing view.
- public var backgroundInsets: DirectionalEdgeInsets = .zero
-
- /// The edges on which the configuration adds the containing view’s layout
- /// margins to the background insets.
- public var edgesAddingLayoutMarginsToBackgroundInsets: DirectionalRectEdge =
- .none
-
- /// The color of the background.
- ///
- /// If the value is `nil`, the background color is the view's tint color. Use
- /// `clear` for a transparent background with no color.
- public var backgroundColor: Color?
-
- /// The color transformer for resolving the background color.
- ///
- /// If the value is `nil`, the configuration uses `backgroundColor` without
- /// any transformations.
- public var backgroundColorTransformer: ConfigurationColorTransformer?
-
- /// Generates the resolved background color for the specified tint color,
- /// using the background color and color transformer.
- public func resolvedBackgroundColor(for tintColor: Color) -> Color {
- fatalError("\(#function) not yet implemented")
- }
-
- /// The visual effect that the configuration applies to the background.
- public var visualEffect: VisualEffect?
-
- /// The color of the stroke.
- ///
- /// If the value is `nil`, the stroke color is the view's tint color. Use
- /// `clear` for a transparent stroke with no color.
- public var strokeColor: Color?
-
- /// The color transformer for resolving the stroke color.
- ///
- /// If the value is `nil`, the configuration uses `strokeColor` without any
- /// transformations.
- public var strokeColorTransformer: ConfigurationColorTransformer?
-
- /// Generates the resolved stroke color for the specified tint color, using
- /// the stroke color and color transformer.
- public func resolvedStrokeColor(for tintColor: Color) -> Color {
- fatalError("\(#function) not yet implemented")
- }
-
- /// The width of the stroke.
- public var strokeWidth: Double = 0.0
-
- /// The outset (or inset, if negative) for the stroke.
- public var strokeOutset: Double = 0.0
-
- // MARK - Updating Background Configurations
-
- /// Generates a configuration for the specified state by applying the
- /// configuration's default values for that state to any properties that you
- /// haven't customized.
- public func updated(for state: ConfigurationState) -> BackgroundConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-// MARK - Comparing Background Configurations
-
-extension BackgroundConfiguration: Hashable {
- public static func ==(_ lhs: BackgroundConfiguration,
- _ rhs: BackgroundConfiguration) -> Bool {
- fatalError("\(#function) not yet implemented")
- }
-
- public func hash(into hasher: inout Hasher) {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-// MARK - Describing a Background Configuration
-
-extension BackgroundConfiguration: CustomStringConvertible {
- public var description: String {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-extension BackgroundConfiguration: CustomDebugStringConvertible {
- public var debugDescription: String {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-extension BackgroundConfiguration: CustomReflectable {
- public var customMirror: Mirror {
- fatalError("\(#function) not yet implemented")
- }
-}
diff --git a/Sources/SwiftWin32/Appearance Customization/Configurations/CellConfigurationState.swift b/Sources/SwiftWin32/Appearance Customization/Configurations/CellConfigurationState.swift
deleted file mode 100644
index dc74db6d..00000000
--- a/Sources/SwiftWin32/Appearance Customization/Configurations/CellConfigurationState.swift
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A structure that encapsulates a cell's state.
-public struct CellConfigurationState: ConfigurationState {
- // MARK - Managing View Configuration States
-
- /// The traits that describe the current layout environment of the view, such
- /// as the user interface style and layout direction.
- public var traitCollection: TraitCollection
-
- /// A boolean value that indicates whether the cell is in a selected state.
- public var isSelected: Bool = false
-
- /// A boolean value that indicates whether the cell is in a highlighted state.
- public var isHighlighted: Bool = false
-
- /// A boolean value that indicates whether the cell is in a focused state.
- public var isFocused: Bool = false
-
- /// A boolean value that indicates whether the cell is in a disabled state.
- public var isDisabled: Bool = false
-
- /// Accesses custom states by key.
- public subscript(key: ConfigurationStateCustomKey) -> AnyHashable? {
- get { return nil }
- set { }
- }
-
- // MARK - Creating a Configuration State Manually
-
- /// Creates a cell configuration state with the specified trait collection.
- public init(traitCollection: TraitCollection) {
- self.traitCollection = traitCollection
- }
-}
diff --git a/Sources/SwiftWin32/Appearance Customization/Configurations/ConfigurationColorTransformer.swift b/Sources/SwiftWin32/Appearance Customization/Configurations/ConfigurationColorTransformer.swift
deleted file mode 100644
index b7e9d127..00000000
--- a/Sources/SwiftWin32/Appearance Customization/Configurations/ConfigurationColorTransformer.swift
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A transformer that generates a modified output color from an input color.
-public struct ConfigurationColorTransformer {
- // MARK - Creating a Color Transformer
-
- /// Creates a color transformer with the specified closure.
- public init(_ transform: @escaping (Color) -> Color) {
- self.transform = transform
- }
-
- /// Creates a color transformer that generates a grayscale version of the
- /// color.
- public static var grayscale: ConfigurationColorTransformer {
- fatalError("\(#function) not yet implemented")
- }
-
- /// A color transformer that returns the preferred system accent color.
- public static var preferredTint: ConfigurationColorTransformer {
- fatalError("\(#function) not yet implemented")
- }
-
- /// A color transformer that returns the color with a monochrome tint.
- public static var monochromeTint: ConfigurationColorTransformer {
- fatalError("\(#function) not yet implemented")
- }
-
- // MARK - Calling the Color Transformer
-
- /// The transform closure of the color transformer.
- public private(set) var transform: (Color) -> Color
-
- /// Calls the transform closure of the color transformer.
- public func callAsFunction(_ input: Color) -> Color {
- return self.transform(input)
- }
-}
diff --git a/Sources/SwiftWin32/Appearance Customization/Configurations/ConfigurationState.swift b/Sources/SwiftWin32/Appearance Customization/Configurations/ConfigurationState.swift
deleted file mode 100644
index b92447df..00000000
--- a/Sources/SwiftWin32/Appearance Customization/Configurations/ConfigurationState.swift
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// The requirements for an object that encapsulate a view's state.
-public protocol ConfigurationState {
- // MARK - Managing Configuration States
-
- /// The traits that describe the current layout environment of the view, such
- /// as the user interface style and layout direction.
- var traitCollection: TraitCollection { get set }
-
- /// Accesses custom states by key.
- subscript(key: ConfigurationStateCustomKey) -> AnyHashable? { get set }
-
- // MARK - Creating a Configuration State Manually
-
- /// Creates a View configuration state with the specified trait collection.
- init(traitCollection: TraitCollection)
-}
diff --git a/Sources/SwiftWin32/Appearance Customization/Configurations/ConfigurationStateCustomKey.swift b/Sources/SwiftWin32/Appearance Customization/Configurations/ConfigurationStateCustomKey.swift
deleted file mode 100644
index 1a613a62..00000000
--- a/Sources/SwiftWin32/Appearance Customization/Configurations/ConfigurationStateCustomKey.swift
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A key that defines a custom state for a view.
-public struct ConfigurationStateCustomKey: Equatable, Hashable, RawRepresentable {
- public typealias RawValue = String
-
- public let rawValue: RawValue
-
- public init(rawValue: RawValue) {
- self.rawValue = rawValue
- }
-}
-
-extension ConfigurationStateCustomKey {
- public init(_ rawValue: String) {
- self.rawValue = rawValue
- }
-}
diff --git a/Sources/SwiftWin32/Appearance Customization/Configurations/ContentConfiguration.swift b/Sources/SwiftWin32/Appearance Customization/Configurations/ContentConfiguration.swift
deleted file mode 100644
index 5a926121..00000000
--- a/Sources/SwiftWin32/Appearance Customization/Configurations/ContentConfiguration.swift
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// The requirements for an object that provides the configuration for a content
-/// view.
-public protocol ContentConfiguration {
- // MARK - Creating a Content Configuration
-
- /// Creates a new instance of the content view using this configuration.
- func makeContentView() -> View & ContentView
-
- // MARK - Updating a Content Configuration
-
- /// Generates a configuration for the specified state by applying the
- /// configuration's default values for that state to any properties that you
- /// haven't customized.
- func updated(for state: ConfigurationState) -> Self
-}
diff --git a/Sources/SwiftWin32/Appearance Customization/Configurations/ContentView.swift b/Sources/SwiftWin32/Appearance Customization/Configurations/ContentView.swift
deleted file mode 100644
index cf02ff36..00000000
--- a/Sources/SwiftWin32/Appearance Customization/Configurations/ContentView.swift
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// The requirements for a content view that you create using a configuration.
-public protocol ContentView {
- // MARK - Managing the Content Configuration
-
- /// The current configuration of the view.
- var configuration: ContentConfiguration { get set }
-}
diff --git a/Sources/SwiftWin32/Appearance Customization/Configurations/ListContentConfiguration.swift b/Sources/SwiftWin32/Appearance Customization/Configurations/ListContentConfiguration.swift
deleted file mode 100644
index 424b5fe9..00000000
--- a/Sources/SwiftWin32/Appearance Customization/Configurations/ListContentConfiguration.swift
+++ /dev/null
@@ -1,374 +0,0 @@
-// Copyright © 2019 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import class Foundation.NSAttributedString
-
-#if swift(>=5.7)
-import CoreGraphics
-#endif
-
-extension ListContentConfiguration {
- /// Properties that affect the list content configuration's image.
- public struct ImageProperties {
- internal init() {
- // FIXME how do we intialize the value of `cornerRadius`?
- self.cornerRadius = 0.0
- }
-
- // MARK - Configuring Image Properties
-
- /// The symbol configuration to use.
- public var preferredSymbolConfiguration: Image.SymbolConfiguration?
-
- /// The tint color to apply to the image view.
- public var tintColor: Color?
-
- /// The color transformer for resolving the tint color.
- public var tintColorTransformer: ConfigurationColorTransformer?
-
- /// Generates the resolved tint color for the specified tint color, using
- /// the tint color and color transformer.
- public func resolvedTintColor(for tintColor: Color) -> Color {
- fatalError("\(#function) not yet implemented")
- }
-
- /// The preferred corner radius, using a continuous corner curve, for the
- /// image.
- public var cornerRadius: Double
-
- /// The maximum size for the image.
- public var maximumSize: Size = .zero
-
- /// The layout size that the system reserves for the image, and then centers
- /// the image within.
- public var reservedLayoutSize: Size = .zero
-
- /// The system standard layout dimension for reserved layout size.
- public static var standardDimension: Double {
- .greatestFiniteMagnitude
- }
-
- /// A boolean value that determines whether the image inverts its colors
- /// when the user turns on the Invert Colors accessibility setting.
- public var accessibilityIgnoresInvertColors: Bool = false
- }
-}
-
-// MARK - Comparing Image Properties
-
-extension ListContentConfiguration.ImageProperties: Hashable {
- public static func ==(_ lhs: ListContentConfiguration.ImageProperties,
- _ rhs: ListContentConfiguration.ImageProperties)
- -> Bool {
- fatalError("\(#function) not yet implemented")
- }
-
- public func hash(into hasher: inout Hasher) {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-// MARK - Describing Image Properties
-
-extension ListContentConfiguration.ImageProperties: CustomStringConvertible {
- public var description: String {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-extension ListContentConfiguration.ImageProperties: CustomDebugStringConvertible {
- public var debugDescription: String {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-extension ListContentConfiguration.ImageProperties: CustomReflectable {
- public var customMirror: Mirror {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-extension ListContentConfiguration.TextProperties {
- /// Constants that specify the visual alignment of the text.
- public enum TextAlignment {
- // MARK - Text Alignment
-
- /// The text has centered alignment.
- case center
-
- /// The text has justified alignment.
- case justified
-
- /// The text uses the default alignment that the system associates with the
- /// current localization of the app.
- case natural
- }
-}
-
-// MARK - Comparing Text Alignment
-
-extension ListContentConfiguration.TextProperties.TextAlignment: Hashable {
- public static func ==(_ lhs: ListContentConfiguration.TextProperties.TextAlignment,
- _ rhs: ListContentConfiguration.TextProperties.TextAlignment)
- -> Bool {
- fatalError("\(#function) not yet implemented")
- }
-
- public func hash(into hasher: inout Hasher) {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-extension ListContentConfiguration.TextProperties {
- public enum TextTransform {
- // MARK - Text Transforms
-
- /// The text doesn't have a transform.
- case none
-
- /// Displays the text with the first character capitalized.
- case capitalized
-
- /// Displays the text in all lowercase characters.
- case lowercase
-
- /// Displays the text in all uppercase characters.
- case uppercase
- }
-}
-
-// MARK - Comparing Text Transforms
-
-extension ListContentConfiguration.TextProperties.TextTransform: Hashable {
- public static func ==(_ lhs: ListContentConfiguration.TextProperties.TextTransform,
- _ rhs: ListContentConfiguration.TextProperties.TextTransform)
- -> Bool {
- fatalError("\(#function) not yet implemented")
- }
-
- public func hash(into hasher: inout Hasher) {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-extension ListContentConfiguration {
- /// Properties that affect the list content configuration's text.
- public struct TextProperties {
- // MARK - Configuring Text Properties
-
- /// The font for the text.
- public var font: Font
-
- /// The color of the text.
- public var color: Color
-
- /// The color transformer for resolving the text color.
- public var colorTransformer: ConfigurationColorTransformer?
-
- /// Generates the resolved color for the specified color, using the text
- /// color and color transformer.
- public func resolvedColor() -> Color {
- fatalError("\(#function) not yet implemented")
- }
-
- /// The alignment for the text.
- public var alignment: TextProperties.TextAlignment
-
- /// The line break mode to use for the text.
- public var lineBreakMode: LineBreakMode
-
- /// The maximum number of lines for the text.
- public var numberOfLines: Int
-
- /// A boolean value that detemines whether the configuration automatically
- /// adjusts the font size of the text when necessary to fit in the available
- /// width.
- public var adjustsFontSizeToFitWidth: Bool
-
- /// The smallest multiplier for the font size that the configuration uses to
- /// make the text fit.
- public var minimumScaleFactor: Double
-
- /// A boolean value that detemines whether the configuration tightens the
- /// text before truncating.
- public var allowsDefaultTighteningForTruncation: Bool
-
- /// A boolean value that detemines whether the configuration automatically
- /// updates the font when the content size category changes.
- public var adjustsFontForContentSizeCategory: Bool
-
- /// The transform to apply to the text.
- public var transform: TextProperties.TextTransform
- }
-}
-
-/// A content configuration for a list-based content view.
-public struct ListContentConfiguration {
- // MARK - Creating Default Configurations
-
- /// Creates the default configuration for a list cell.
- public static func cell() -> ListContentConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates the default configuration for a list cell with subtitle text.
- public static func subtitleCell() -> ListContentConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates the default configuration for a list cell with side-by-side value
- /// text.
- public static func valueCell() -> ListContentConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates the default configuration for a plain list header.
- public static func plainHeader() -> ListContentConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates the default configuration for a plain list footer.
- public static func plainFooter() -> ListContentConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates the default configuration for a grouped list header.
- public static func groupedHeader() -> ListContentConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates the default configuration for a grouped list footer.
- public static func groupedFooter() -> ListContentConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates the default configuration for a sidebar list cell.
- public static func sidebarCell() -> ListContentConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates the default configuration for a sidebar list cell with subtitle
- /// text.
- public static func sidebarSubtitleCell() -> ListContentConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates the default configuration for a sidebar list header.
- public static func sidebarHeader() -> ListContentConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates the default configuration for an accompanied sidebar list cell.
- public static func accompaniedSidebarCell() -> ListContentConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates the default configuration for an accompanied sidebar list cell
- /// with subtitle text.
- public static func accompaniedSidebarSubtitleCell()
- -> ListContentConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- // MARK - Customizing Content
-
- /// The image to display.
- public var image: Image?
-
- /// The primary text.
- public var text: String?
-
- /// An attributed variant of the primary text.
- public var attributedText: NSAttributedString?
-
- /// The secondary text.
- public var secondaryText: String?
-
- /// An attributed variant of the secondary text.
- public var secondaryAttributedText: NSAttributedString?
-
- // MARK - Customizing Appearance
-
- /// Properties for configuring the image.
- public var imageProperties: ListContentConfiguration.ImageProperties
-
- /// Properties for configuring the primary text.
- public var textProperties: ListContentConfiguration.TextProperties
-
- /// Properties for configuring the secondary text.
- public var secondaryTextProperties: ListContentConfiguration.TextProperties
-
- // MARK - Customizing Layout
-
- /// A boolean value that detemines whether the content view preserves the
- /// layout margins that it inherits from its superview on the horizontal or
- /// vertical axes.
- public var axesPreservingSuperviewLayoutMargins: Axis = .both
-
- /// The margins between the content and the edges of the content view.
- public var directionalLayoutMargins: DirectionalEdgeInsets
-
- /// A boolean value that detemines whether the configuration positions the
- /// text and secondary text side by side.
- public var prefersSideBySideTextAndSecondaryText: Bool
-
- /// The padding between the image and text.
- public var imageToTextPadding: Double
-
- /// The minimum horizontal padding between the text and secondary text.
- public var textToSecondaryTextHorizontalPadding: Double
-
- /// The vertical padding between the text and secondary text.
- public var textToSecondaryTextVerticalPadding: Double
-}
-
-extension ListContentConfiguration: ContentConfiguration {
- // MARK - Creating a Content View
-
- /// Creates a new instance of the content view using this configuration.
- public func makeContentView() -> View & ContentView {
- fatalError("\(#function) not yet implemented")
- }
-
- // MARK - Updating the Configuration
-
- /// Generates a configuration for the specified state by applying the
- /// configuration's default values for that state to any properties that you
- /// haven't customized.
- public func updated(for state: ConfigurationState) -> ListContentConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-// MARK - Comparing List Content Configurations
-
-extension ListContentConfiguration: Hashable {
- public static func ==(_ lhs: ListContentConfiguration,
- _ rhs: ListContentConfiguration) -> Bool {
- fatalError("\(#function) not yet implemented")
- }
-
- public func hash(into hasher: inout Hasher) {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-// MARK - Describing a List Content Configuration
-
-extension ListContentConfiguration: CustomStringConvertible {
- public var description: String {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-extension ListContentConfiguration: CustomDebugStringConvertible {
- public var debugDescription: String {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-extension ListContentConfiguration: CustomReflectable {
- public var customMirror: Mirror {
- fatalError("\(#function) not yet implemented")
- }
-}
diff --git a/Sources/SwiftWin32/Appearance Customization/Configurations/ViewConfigurationState.swift b/Sources/SwiftWin32/Appearance Customization/Configurations/ViewConfigurationState.swift
deleted file mode 100644
index 7e9c70a5..00000000
--- a/Sources/SwiftWin32/Appearance Customization/Configurations/ViewConfigurationState.swift
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A structure that encapsulates a view's state.
-public struct ViewConfigurationState: ConfigurationState {
- // MARK - Managing View Configuration States
-
- /// The traits that describe the current layout environment of the view, such
- /// as the user interface style and layout direction.
- public var traitCollection: TraitCollection
-
- /// A boolean value that indicates whether the view is in a selected state.
- public var isSelected: Bool
-
- /// A boolean value that indicates whether the view is in a highlighted state.
- public var isHighlighted: Bool
-
- /// A boolean value that indicates whether the view is in a focused state.
- public var isFocused: Bool
-
- /// A boolean value that indicates whether the view is in a disabled state.
- public var isDisabled: Bool
-
- /// Accesses custom states by key.
- public subscript(key: ConfigurationStateCustomKey) -> AnyHashable? {
- get { fatalError("\(#function) not yet implemented") }
- set { fatalError("\(#function) not yet implemented") }
- }
-
- // MARK - Creating a Configuration State Manually
-
- public init(traitCollection: TraitCollection) {
- self.traitCollection = traitCollection
-
- self.isSelected = false
- self.isHighlighted = false
- self.isFocused = false
- self.isDisabled = false
- }
-}
-
-extension ViewConfigurationState: Hashable {
- public static func ==(_ lhs: ViewConfigurationState,
- _ rhs: ViewConfigurationState) -> Bool {
- fatalError("\(#function) not yet implemented")
- }
-
- public func hash(into hasher: inout Hasher) {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-extension ViewConfigurationState: CustomStringConvertible {
- public var description: String {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-extension ViewConfigurationState: CustomDebugStringConvertible {
- public var debugDescription: String {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-extension ViewConfigurationState: CustomReflectable {
- public var customMirror: Mirror {
- fatalError("\(#function) not yet implemented")
- }
-}
diff --git a/Sources/SwiftWin32/Application/Information.swift b/Sources/SwiftWin32/Application/Information.swift
deleted file mode 100644
index 45bcca8c..00000000
--- a/Sources/SwiftWin32/Application/Information.swift
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-extension Application {
- internal struct SceneConfiguration {
- let name: String?
- let `class`: String?
- let delegate: String?
- }
-}
-
-extension Application.SceneConfiguration: Decodable {
- enum CodingKeys: String, CodingKey {
- case name = "SceneConfigurationName"
- case `class` = "SceneClassName"
- case delegate = "SceneDelegateClassName"
- }
-}
-
-extension Application {
- internal struct SceneManifest {
- // Enable Multiple Windows
- let supportsMultipleScenes: Bool?
- // Scene Configuration
- let configurations: [String:[Application.SceneConfiguration]]?
- }
-}
-
-extension Application.SceneManifest: Decodable {
- enum CodingKeys: String, CodingKey {
- case supportsMultipleScenes = "ApplicationSupportsMultipleScenes"
- case configurations = "SceneConfigurations"
- }
-}
-
-extension Application {
- internal struct Information {
- let scene: Application.SceneManifest?
- let principalClass: String?
- }
-}
-
-extension Application.Information: Decodable {
- enum CodingKeys: String, CodingKey {
- case scene = "ApplicationSceneManifest"
- case principalClass = "PrincipalClass"
- }
-}
diff --git a/Sources/SwiftWin32/Application/LaunchKeyOptions.swift b/Sources/SwiftWin32/Application/LaunchKeyOptions.swift
deleted file mode 100644
index 13cd2eec..00000000
--- a/Sources/SwiftWin32/Application/LaunchKeyOptions.swift
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright © 2019 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-extension Application {
- /// Keys used to access values in the launch options dictionary passed to your
- /// application at initialization time.
- public struct LaunchOptionsKey: Equatable, Hashable, RawRepresentable {
- public typealias RawValue = String
-
- public var rawValue: RawValue
-
- public init(rawValue: RawValue) {
- self.rawValue = rawValue
- }
- }
-}
-
-extension Application.LaunchOptionsKey {
- /// A key indicating that the URL passed to your application contains custom
- /// annotation data from the source application.
- public static var annotation: Application.LaunchOptionsKey {
- Application.LaunchOptionsKey(rawValue: "Application.Annotation")
- }
-
- /// A key indicating that the application was relaunched to handle
- /// bluetooth-related events.
- public static var bluetoothCentrals: Application.LaunchOptionsKey {
- Application.LaunchOptionsKey(rawValue: "Application.BluetoothCentrals")
- }
-
- /// A key indicating that the application should continue actions associated
- /// with it's bluetooth peripheral objects.
- public static var bluetoothPeripherals: Application.LaunchOptionsKey {
- Application.LaunchOptionsKey(rawValue: "Application.BluetoothPeripherals")
- }
-
- /// A key indicating that the application was launched to handle an incoming
- /// location event.
- public static var location: Application.LaunchOptionsKey {
- Application.LaunchOptionsKey(rawValue: "Application.Location")
- }
-
- /// A key indicating that a remove notification is available for the
- /// application to process.
- public static var remoteNotification: Application.LaunchOptionsKey {
- Application.LaunchOptionsKey(rawValue: "Application.RemoteNotification")
- }
-
- /// A key indicating that the application was launched in response to the user
- /// selecting a quick action.
- public static var shortcutItem: Application.LaunchOptionsKey {
- Application.LaunchOptionsKey(rawValue: "Application.ShortCutItem")
- }
-
- /// A key indicating that another application rrequested the launch of your
- /// application.
- public static var sourceApplication: Application.LaunchOptionsKey {
- Application.LaunchOptionsKey(rawValue: "Application.SourceApplication")
- }
-
- /// A key indicating that the application was launched so it could open the
- /// specified URL.
- public static var url: Application.LaunchOptionsKey {
- Application.LaunchOptionsKey(rawValue: "Application.URL")
- }
-
- /// A key indicating a dictionary associated with an activity that the user
- /// wants to continue.
- public static var userActivityDictionary: Application.LaunchOptionsKey {
- Application.LaunchOptionsKey(rawValue: "Application.UserActivityDictionary")
- }
-
- /// A key indicating the type of user activity that the user wants to
- /// continue.
- public static var userActivityType: Application.LaunchOptionsKey {
- Application.LaunchOptionsKey(rawValue: "Application.UserActivityType")
- }
-}
diff --git a/Sources/SwiftWin32/Application/_TriviallyConstructible.swift b/Sources/SwiftWin32/Application/_TriviallyConstructible.swift
deleted file mode 100644
index 6c1aa172..00000000
--- a/Sources/SwiftWin32/Application/_TriviallyConstructible.swift
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-// TODO(compnerd) determine if there is a way to avoid this conformance. It is
-// required to initialize the class from `ApplicationMain` which takes class
-// names.
-public protocol _TriviallyConstructible {
- init()
-}
diff --git a/Sources/SwiftWin32/AutoLayout/LayoutAnchor.swift b/Sources/SwiftWin32/AutoLayout/LayoutAnchor.swift
deleted file mode 100644
index 802e0294..00000000
--- a/Sources/SwiftWin32/AutoLayout/LayoutAnchor.swift
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool .
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A factory class for creating layout constraint objects using a fluent API.
-public class LayoutAnchor {
- internal unowned var item: AnyObject
- internal var attribute: LayoutConstraint.Attribute
-
- internal init(item: AnyObject, attribute: LayoutConstraint.Attribute) {
- self.item = item
- self.attribute = attribute
- }
-
- // MARK - Building Constraints
-
- /// Returns a constraint that defines one item's attribute as equal to
- /// another.
- public func constraint(equalTo anchor: LayoutAnchor)
- -> LayoutConstraint {
- return constraint(equalTo: anchor, constant: 0.0)
- }
-
- /// Returns a constraint that defines one item's attribute as equal to another
- /// item's attribute plus a constant offset.
- public func constraint(equalTo anchor: LayoutAnchor,
- constant offset: Double) -> LayoutConstraint {
- return LayoutConstraint(item: self.item, attribute: self.attribute,
- relatedBy: .equal,
- toItem: anchor.item, attribute: anchor.attribute,
- multiplier: 1.0, constant: offset)
- }
-
- /// Returns a constraint that defines one item's attribute as greater than or
- /// equal to another.
- public func constraint(greaterThanOrEqualTo anchor: LayoutAnchor)
- -> LayoutConstraint {
- return constraint(greaterThanOrEqualTo: anchor, constant: 0.0)
- }
-
- /// Returns a constraint that defines one item's attribute as greater than or
- /// equal to another item's attribute plus a constant offset.
- public func constraint(greaterThanOrEqualTo anchor: LayoutAnchor,
- constant offset: Double) -> LayoutConstraint {
- return LayoutConstraint(item: self.item, attribute: self.attribute,
- relatedBy: .greaterThanOrEqual,
- toItem: anchor.item, attribute: anchor.attribute,
- multiplier: 1.0, constant: offset)
- }
-
- /// Returns a constraint that defines one item's attribute as less than or
- /// equal to another.
- public func constraint(lessThanOrEqualTo anchor: LayoutAnchor)
- -> LayoutConstraint {
- return constraint(lessThanOrEqualTo: anchor, constant: 0.0)
- }
-
- /// Returns a constraint that defines one item's attribute as less than or
- /// equal to another item's attribute plus a constant offset.
- public func constraint(lessThanOrEqualTo anchor: LayoutAnchor,
- constant offset: Double) -> LayoutConstraint {
- return LayoutConstraint(item: self.item, attribute: self.attribute,
- relatedBy: .lessThanOrEqual,
- toItem: anchor.item, attribute: self.attribute,
- multiplier: 1.0, constant: offset)
- }
-}
diff --git a/Sources/SwiftWin32/AutoLayout/LayoutConstraint+Cassowary.swift b/Sources/SwiftWin32/AutoLayout/LayoutConstraint+Cassowary.swift
deleted file mode 100644
index 4ee98b63..00000000
--- a/Sources/SwiftWin32/AutoLayout/LayoutConstraint+Cassowary.swift
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool .
-// SPDX-License-Identifier: BSD-3-Clause
-
-import Cassowary
-
-extension LayoutConstraint.Attribute {
- internal var name: String {
- switch self {
- case .left: return "Left"
- case .right: return "Right"
- case .top: return "Top"
- case .bottom: return "Bottom"
- case .leading: return "Leading"
- case .trailing: return "Trailing"
- case .width: return "Width"
- case .height: return "Height"
- case .centerX: return "CenterX"
- case .centerY: return "CenterY"
- case .lastBaseline: return "lastBaseline"
- case .firstBaseline: return "FirstBaseline"
- case .leftMargin: return "LeftMargin"
- case .rightMargin: return "RightMargin"
- case .topMargin: return "TopMargin"
- case .bottomMargin: return "BottomMargin"
- case .leadingMargin: return "LeadingMargin"
- case .trailingMargin: return "TrailingMargin"
- case .centerXWithinMargins: return "CenterXWithinMargins"
- case .centerYWithinMargins: return "CenterYWithinMargins"
- case .notAnAttribute: return "NotAnAttribute"
- }
- }
-}
-
-extension LayoutAnchor {
- internal var variable: Variable {
- Variable("\(type(of: self.item)):0x\(String(UInt(bitPattern: ObjectIdentifier(self.item)), radix: 16)).\(self.attribute.name)")
- }
-}
-
-extension LayoutConstraint {
- internal var constraint: Constraint {
- let lhs = firstAnchor.variable
- let rhs: Cassowary.Variable? = secondAnchor?.variable
-
- switch self.relation {
- case .lessThanOrEqual:
- if let rhs = rhs {
- return Constraint(lhs <= rhs * self.multiplier + self.constant, .required)
- }
- return Constraint(lhs <= self.constant, .required)
-
- case .equal:
- if let rhs = rhs {
- return Constraint(lhs * self.multiplier + self.constant == rhs, .required)
- }
- return Constraint(lhs * self.multiplier == self.constant, .required)
-
- case .greaterThanOrEqual:
- if let rhs = rhs {
- return Constraint(lhs * self.multiplier + self.constant >= rhs, .required)
- }
- return Constraint(lhs * self.multiplier >= self.constant, .required)
- }
- }
-}
diff --git a/Sources/SwiftWin32/AutoLayout/LayoutConstraint.swift b/Sources/SwiftWin32/AutoLayout/LayoutConstraint.swift
deleted file mode 100644
index 6dd46bee..00000000
--- a/Sources/SwiftWin32/AutoLayout/LayoutConstraint.swift
+++ /dev/null
@@ -1,209 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool .
-// SPDX-License-Identifier: BSD-3-Clause
-
-extension LayoutConstraint {
- /// The relation between the first attribute and the modified second attribute
- /// in a constraint.
- public enum Relation: Int {
- /// The constraint requires the first attribute to be less than or equal to
- /// the modified second attribute.
- case lessThanOrEqual
-
- /// The constraint requires the first attribute to be exactly equal to the
- /// modified second attribute.
- case equal
-
- /// The constraint requires the first attribute to be greater than or equal to
- /// the modified second attribute.
- case greaterThanOrEqual
- }
-}
-
-extension LayoutConstraint {
- /// The part of the object's visual representation that should be used to get
- /// the value for the constraint.
- public enum Attribute: Int {
- /// The left side of the object's alignment rectangle.
- case left
-
- /// The right side of the object's alignment rectangle.
- case right
-
- /// The top of the object's alignment rectangle.
- case top
-
- /// The bottom of the object's alignment rectangle.
- case bottom
-
- /// The leading edge of the object's alignment rectangle.
- case leading
-
- /// The trailing edge of the object's alignment rectangle.
- case trailing
-
- /// The width of the object's alignment rectangle.
- case width
-
- /// The height of the object's alignment rectangle.
- case height
-
- /// Tne center along the x-axis of the object's alignment rectangle.
- case centerX
-
- /// The center along the y-axis of the object's alignment rectangle.
- case centerY
-
- /// The object's baseline. For objects with more than one line of text, this
- /// is the baseline for the bottom-most line of text.
- case lastBaseline
-
- /// The object's baseline. For objects with more than one line of text, this
- /// is the baseline for the top-most line of text.
- case firstBaseline
-
- /// The object's left margin. For `View` objects, the margins are defined by
- /// their `layoutMargins` property.
- case leftMargin
-
- /// The object's right margin. For `View` objects, the margins are defined by
- /// their `layoutMargins` property.
- case rightMargin
-
- /// The object's top margin. For `View` objects, the margins are defined by
- /// their `layoutMargins` property.
- case topMargin
-
- /// The object's bottom margin. For `View` objects, the margins are defined
- /// by their `layoutMargins` property.
- case bottomMargin
-
- /// The object's leading margin. For `View` objects, the margins are defined
- /// by their `layoutMargins` property.
- case leadingMargin
-
- /// The object's trailing margin. For `View` objects, the margins are defined
- /// by thier `layoutMargins` property.
- case trailingMargin
-
- /// The center along the x-axis between the object's left and right margin.
- /// For `View` objects, the margins are defined by their `layoutMargins`
- /// property.
- case centerXWithinMargins
-
- /// The center along the y-axis between the object's top and bottom margin.
- /// For `View` objects, the margins are defined by thier `layoutMargins`
- /// property.
- case centerYWithinMargins
-
- /// A placeholder value that is used to indicate taht the constraint's second
- /// item and second attribute are not used in any calculations.
- case notAnAttribute
- }
-}
-
-public class LayoutConstraint {
- // MARK - Creating Constraints
-
- /// Creates a constraint that defines the relationship between the specified
- /// attributes of the given views.
- public /*convenience*/ init(item firstItem: AnyObject,
- attribute firstAttribute: LayoutConstraint.Attribute,
- relatedBy relation: LayoutConstraint.Relation,
- toItem secondItem: AnyObject?,
- attribute secondAttribute: LayoutConstraint.Attribute,
- multiplier: Double, constant: Double) {
- self.firstAnchor =
- LayoutAnchor(item: firstItem, attribute: firstAttribute)
-
- if let item = secondItem {
- self.secondAnchor =
- LayoutAnchor(item: item, attribute: secondAttribute)
- }
-
- self.relation = relation
- self.multiplier = multiplier
- self.constant = constant
- }
-
- // MARK - Activating and Deactivating Constraints
-
- /// The active state of the constraint.
- public var isActive: Bool = false {
- didSet {
- var ancestor: View? = self.firstAnchor.item as? View
- if let other = self.secondAnchor?.item as? View {
- // TODO(compnerd) this has performance implications - O(n²) for the
- // check for the common ancestor search.
- while let parent = ancestor, !other.isDescendant(of: parent) {
- ancestor = parent.superview
- }
- }
-
- switch isActive {
- case true:
- ancestor?.addConstraint(self)
- case false:
- ancestor?.removeConstraint(self)
- }
- }
- }
-
- /// Activates each constraint in the specified array.
- public class func activate(_ constraints: [LayoutConstraint]) {
- constraints.forEach { $0.isActive = true }
- }
-
- /// Deactivates each constraint in the specified array.
- public class func deactivate(_ constraints: [LayoutConstraint]) {
- constraints.forEach { $0.isActive = false }
- }
-
- // MARK - Accessing Constraint Data
-
- /// The first object participating in the constraint.
- public unowned(unsafe) var firstItem: AnyObject? {
- firstAnchor.item
- }
-
- /// The attribute of the first object participating in the constraint.
- public var firstAttribute: LayoutConstraint.Attribute {
- firstAnchor.attribute
- }
-
- /// The relationship between the two attributes in the constraint.
- public private(set) var relation: LayoutConstraint.Relation
-
- /// The second object participating in the constraint.
- public unowned(unsafe) var secondItem: AnyObject? {
- secondAnchor?.item
- }
-
- /// The attribute of the second object participating in the constraint.
- public var secondAttribute: LayoutConstraint.Attribute {
- secondAnchor?.attribute ?? .notAnAttribute
- }
-
- /// The multiplier applied to the second attribute participating in the
- /// constraint.
- public private(set) var multiplier: Double
-
- /// The constant added to the multiplied second attribute participating in the
- /// constraint.
- public private(set) var constant: Double
-
- /// The first anchor that defines the constraint.
- public private(set) var firstAnchor: LayoutAnchor
-
- /// The second anchor that defines the constraint.
- public private(set) var secondAnchor: LayoutAnchor?
-
- // MARK - Getting the Layout Priority
-
- /// The priority of the constraint.
- public var priority: LayoutPriority = .required
-
- // MARK - Identifying a Constraint
-
- /// The name that identifies the constraint.
- public var identifier: String?
-}
diff --git a/Sources/SwiftWin32/AutoLayout/LayoutDimension.swift b/Sources/SwiftWin32/AutoLayout/LayoutDimension.swift
deleted file mode 100644
index 576d381f..00000000
--- a/Sources/SwiftWin32/AutoLayout/LayoutDimension.swift
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool .
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A factory class for creating size-based layout constraint objects using a
-/// fluent API.
-public class LayoutDimension: LayoutAnchor {
- // MARK - Building Constraints
-
- /// Returns a constraint that defines the anchor's size attribute as equal to
- /// the specified anchor multiplied by the constant.
- public func constraint(equalTo anchor: LayoutDimension, multiplier: Double)
- -> LayoutConstraint {
- return constraint(equalTo: anchor, multiplier: multiplier, constant: 0.0)
- }
-
- /// Returns a constraint that defines the anchor's size attribute as equal to
- /// the specified size attribute multiplied by a constant plus an offset.
- public func constraint(equalTo anchor: LayoutDimension, multiplier: Double,
- constant offset: Double) -> LayoutConstraint {
- return LayoutConstraint(item: self.item, attribute: self.attribute,
- relatedBy: .equal,
- toItem: anchor.item, attribute: anchor.attribute,
- multiplier: multiplier, constant: offset)
- }
-
- /// Returns a constraint that defines a constant size for the anchor's size
- /// attribute.
- public func constraint(equalToConstant constant: Double) -> LayoutConstraint {
- return LayoutConstraint(item: self.item, attribute: self.attribute,
- relatedBy: .equal,
- toItem: nil, attribute: .notAnAttribute,
- multiplier: 1.0, constant: constant)
- }
-
- /// Returns a constraint that defines the anchor's size attribute as greater
- /// than or equal to the specified anchor multiplied by the constant.
- public func constraint(greaterThanOrEqualTo anchor: LayoutDimension,
- multiplier: Double) -> LayoutConstraint {
- return constraint(greaterThanOrEqualTo: anchor, multiplier: multiplier,
- constant: 0.0)
- }
-
- /// Returns a constraint that defines teh anchor's size attribute greater than
- /// or equal to the specified anchor multiplied by the constant plus an
- /// offset.
- public func constraint(greaterThanOrEqualTo anchor: LayoutDimension,
- multiplier: Double, constant offset: Double)
- -> LayoutConstraint {
- return LayoutConstraint(item: self.item, attribute: self.attribute,
- relatedBy: .greaterThanOrEqual,
- toItem: anchor.item, attribute: anchor.attribute,
- multiplier: multiplier, constant: offset)
- }
-
- /// Returns a constraint that defines the minimum size for the anchor's size
- /// attribute.
- public func constraint(greaterThanOrEqualToConstant constant: Double)
- -> LayoutConstraint {
- return LayoutConstraint(item: self.item, attribute: self.attribute,
- relatedBy: .greaterThanOrEqual,
- toItem: nil, attribute: .notAnAttribute,
- multiplier: 1.0, constant: constant)
- }
-
- /// Returns a constraint that defines the anchor's size attribute as less than
- /// or requal to the specified anchor multiplied by the constant.
- public func constraint(lessThanOrEqualTo anchor: LayoutDimension,
- multiplier: Double) -> LayoutConstraint {
- return constraint(lessThanOrEqualTo: anchor, multiplier: multiplier,
- constant: 0.0)
- }
-
- /// Returns a constraint that defines the anchor's size attribute as greater
- /// than or equal to the specified anchor multiplied by the constant plus an
- /// offset.
- public func constraint(lessThanOrEqualTo anchor: LayoutDimension,
- multiplier: Double, constant offset: Double)
- -> LayoutConstraint {
- return LayoutConstraint(item: self.item, attribute: self.attribute,
- relatedBy: .lessThanOrEqual,
- toItem: anchor.item, attribute: anchor.attribute,
- multiplier: multiplier, constant: offset)
- }
-
- /// Returns a constraint that defines the maximum size for teh anchor's size
- /// attribute.
- public func constraint(lessThanOrEqualToConstant constant: Double)
- -> LayoutConstraint {
- return LayoutConstraint(item: self.item, attribute: self.attribute,
- relatedBy: .lessThanOrEqual,
- toItem: nil, attribute: .notAnAttribute,
- multiplier: 1.0, constant: constant)
- }
-}
diff --git a/Sources/SwiftWin32/AutoLayout/LayoutGuide.swift b/Sources/SwiftWin32/AutoLayout/LayoutGuide.swift
deleted file mode 100644
index 953ff580..00000000
--- a/Sources/SwiftWin32/AutoLayout/LayoutGuide.swift
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool .
-// SPDX-License-Identifier: BSD-3-Clause
-
-#if swift(>=5.7)
-import CoreGraphics
-#endif
-
-public class LayoutGuide {
- // MARK - Working with Layout Guides
-
- /// A string used to identify the layout guide.
- public var identifier: String = ""
-
- /// The layout guide's frame in its owning view's coordinate system.
- public private(set) var layoutFrame: Rect = .zero
-
- /// The view that owns the layout guide.
- public weak var owningView: View?
-
- // MARK - Creating Constraints Using Layout Anchors
-
- /// A layout anchor representing the bottom edge of the layout guide's frame.
- public var bottomAnchor: LayoutYAxisAnchor {
- LayoutYAxisAnchor(item: owningView!, attribute: .bottom)
- }
-
- /// A layout anchor representing the horizontal center of the layout guide's
- /// frame.
- public var centerXAnchor: LayoutXAxisAnchor {
- LayoutXAxisAnchor(item: owningView!, attribute: .centerX)
- }
-
- /// A layout anchor representing the vertical center of the layout guide's
- /// frame.
- public var centerYAnchor: LayoutYAxisAnchor {
- LayoutYAxisAnchor(item: owningView!, attribute: .centerY)
- }
-
- /// A layout anchor representing the height of the layout guide's frame.
- public var heightAnchor: LayoutDimension {
- LayoutDimension(item: owningView!, attribute: .height)
- }
-
- /// A layout anchor representing the leading edge of the layout guide's frame.
- public var leadingAnchor: LayoutXAxisAnchor {
- LayoutXAxisAnchor(item: owningView!, attribute: .leading)
- }
-
- /// A layout anchor representing the left edge of the layout guide's frame.
- public var leftAnchor: LayoutXAxisAnchor {
- LayoutXAxisAnchor(item: owningView!, attribute: .left)
- }
-
- /// A layout anchor representing the right edge of the layout guide's frame.
- public var rightAnchor: LayoutXAxisAnchor {
- LayoutXAxisAnchor(item: owningView!, attribute: .right)
- }
-
- /// A layout anchor representing the top edge of teh layout guide's frame.
- public var topAnchor: LayoutYAxisAnchor {
- LayoutYAxisAnchor(item: owningView!, attribute: .top)
- }
-
- /// A layout anchor representing the trailing edge of teh layout guide's
- /// frame.
- public var trailingAnchor: LayoutXAxisAnchor {
- LayoutXAxisAnchor(item: owningView!, attribute: .trailing)
- }
-
- /// A layout anchor representing the width of the layout guide's frame.
- public var widthAnchor: LayoutDimension {
- LayoutDimension(item: owningView!, attribute: .width)
- }
-}
diff --git a/Sources/SwiftWin32/AutoLayout/LayoutPriority.swift b/Sources/SwiftWin32/AutoLayout/LayoutPriority.swift
deleted file mode 100644
index 9041d681..00000000
--- a/Sources/SwiftWin32/AutoLayout/LayoutPriority.swift
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool .
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// The layout priority is used to indicate to the constraint-based layout
-/// system which constraints are more important, allowing the system to make
-/// appropriate tradeoffs when satisfying the constraints of the system as a
-/// whole.
-public struct LayoutPriority: Equatable, Hashable, RawRepresentable {
- public typealias RawValue = Float
-
- public let rawValue: RawValue
-
- public init(rawValue: RawValue) {
- self.rawValue = rawValue
- }
-}
-
-extension LayoutPriority {
- public init(_ rawValue: RawValue) {
- self.rawValue = rawValue
- }
-}
-
-extension LayoutPriority {
- /// A required constraint.
- public static var required: LayoutPriority {
- LayoutPriority(rawValue: 1000.0)
- }
-
- /// The priority level with which a button resists compressing its content.
- public static var defaultHigh: LayoutPriority {
- LayoutPriority(rawValue: 750.0)
- }
-
- /// The priority level with which a button hugs its contents horizontally.
- public static var defaultLow: LayoutPriority {
- LayoutPriority(rawValue: 250.0)
- }
-
- /// The priority level with which the view wants to conform to the target size
- /// in that computation.
- public static var fittingSizeLevel: LayoutPriority {
- LayoutPriority(rawValue: 50.0)
- }
-
- /// The priority with which a drag may end up resizing the window's scene.
- public static var dragThatCanResizeScene: LayoutPriority {
- LayoutPriority(rawValue: 510.0)
- }
-
- /// The priority with which the a split view divider is dragged.
- public static var dragThatCannotResizeScene: LayoutPriority {
- LayoutPriority(rawValue: 490.0)
- }
-
- /// The priority with which the window's scene prefers to stay the same size.
- public static var sceneSizeStayPut: LayoutPriority {
- LayoutPriority(rawValue: 500.0)
- }
-}
diff --git a/Sources/SwiftWin32/AutoLayout/LayoutSupport.swift b/Sources/SwiftWin32/AutoLayout/LayoutSupport.swift
deleted file mode 100644
index 5898e96a..00000000
--- a/Sources/SwiftWin32/AutoLayout/LayoutSupport.swift
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool .
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A set of methods that provide layout support and access to layout anchors.
-public protocol LayoutSupport {
- // MARK - Layout Support
-
- /// Provides the length, in points, of the portion of the view controller's
- /// view that is overlaid by translucent or transparent bars.
- var length: Double { get }
-
- // MARK - Creating Constraints Using Layout Anchors
-
- /// A layout anchor representing the guide's bottom edge.
- var bottomAnchor: LayoutYAxisAnchor { get }
-
- /// A layout anchor repreenting the guide's height.
- var heightAnchor: LayoutDimension { get }
-
- /// A layout anchor representing the guide's top edge.
- var topAnchor: LayoutYAxisAnchor { get }
-}
diff --git a/Sources/SwiftWin32/AutoLayout/LayoutXAxisAnchor.swift b/Sources/SwiftWin32/AutoLayout/LayoutXAxisAnchor.swift
deleted file mode 100644
index bef89b80..00000000
--- a/Sources/SwiftWin32/AutoLayout/LayoutXAxisAnchor.swift
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool .
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A factory class for creating horizontal layout constraint objects using a
-/// fluent API.
-public class LayoutXAxisAnchor: LayoutAnchor {
- // MARK - Building System Spacing Constraints
-
- /// Returns a constraint that defines by how much the current anchor trails
- /// the specified anchor.
- public func constraint(equalToSystemSpacingBelow anchor: LayoutXAxisAnchor,
- multiplier: Double) -> LayoutConstraint {
- return LayoutConstraint(item: self.item, attribute: self.attribute,
- relatedBy: .equal,
- toItem: anchor.item, attribute: anchor.attribute,
- multiplier: multiplier, constant: 8.0)
- }
-
- /// Returns a constraint that defines by how much the current anchor trails
- /// the specified anchor.
- public func constraint(greaterThanOrEqualToSystemSpacingBelow anchor: LayoutXAxisAnchor,
- multiplier: Double) -> LayoutConstraint {
- return LayoutConstraint(item: self.item, attribute: self.attribute,
- relatedBy: .greaterThanOrEqual,
- toItem: anchor.item, attribute: anchor.attribute,
- multiplier: multiplier, constant: 8.0)
- }
-
- /// Returns a constraint that defines the minimum distance by which the
- /// current anchor is positioned below the specified anchor.
- public func constraint(lessThanOrEqualToSystemSpacingBelow anchor: LayoutXAxisAnchor,
- multiplier: Double) -> LayoutConstraint {
- return LayoutConstraint(item: self.item, attribute: self.attribute,
- relatedBy: .lessThanOrEqual,
- toItem: anchor.item, attribute: anchor.attribute,
- multiplier: multiplier, constant: 8.0)
- }
-
- // MARK - Creating a Layout Dimension
-
- /// Creates a layout dimension object from two anchors.
- public func anchorWithOffset(to anchor: LayoutXAxisAnchor) -> LayoutDimension {
- fatalError("\(#function) not yet implemented")
- }
-}
diff --git a/Sources/SwiftWin32/AutoLayout/LayoutYAxisAnchor.swift b/Sources/SwiftWin32/AutoLayout/LayoutYAxisAnchor.swift
deleted file mode 100644
index fd319309..00000000
--- a/Sources/SwiftWin32/AutoLayout/LayoutYAxisAnchor.swift
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool .
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A factory class for creating vertical layout constraint objects using a
-/// fluent API.
-public class LayoutYAxisAnchor: LayoutAnchor {
- // MARK - Building System Spacing Constraints
-
- /// Returns a constraint that defines the specific distance at which the
- /// current anchor is positioned below the specified anchor.
- public func constraint(equalToSystemSpacingBelow anchor: LayoutYAxisAnchor,
- multiplier: Double) -> LayoutConstraint {
- return LayoutConstraint(item: self.item, attribute: self.attribute,
- relatedBy: .equal,
- toItem: anchor.item, attribute: anchor.attribute,
- multiplier: multiplier, constant: 8.0)
- }
-
- /// Returns a constraint that defines the minimum distance by which the
- /// current anchor is positioned below the specified anchor.
- public func constraint(greaterThanOrEqualToSystemSpacingBelow anchor: LayoutYAxisAnchor,
- multiplier: Double) -> LayoutConstraint {
- return LayoutConstraint(item: self.item, attribute: self.attribute,
- relatedBy: .greaterThanOrEqual,
- toItem: anchor.item, attribute: anchor.attribute,
- multiplier: multiplier, constant: 8.0)
- }
-
- /// Returns a constraint that defines the maximum distance by which the
- /// current anchor is positioned below the specified anchor.
- public func constraint(lessThanOrEqualToSystemSpacingBelow anchor: LayoutYAxisAnchor,
- multiplier: Double) -> LayoutConstraint {
- return LayoutConstraint(item: self.item, attribute: self.attribute,
- relatedBy: .lessThanOrEqual,
- toItem: anchor.item, attribute: anchor.attribute,
- multiplier: multiplier, constant: 8.0)
- }
-
- // MARK - Creating a Layout Dimension
-
- /// Creates a layout dimension object from two anchors.
- public func anchorWithOffset(to anchor: LayoutYAxisAnchor) -> LayoutDimension {
- fatalError("\(#function) not yet implemented")
- }
-}
diff --git a/Sources/SwiftWin32/CMakeLists.txt b/Sources/SwiftWin32/CMakeLists.txt
deleted file mode 100644
index 61f666f5..00000000
--- a/Sources/SwiftWin32/CMakeLists.txt
+++ /dev/null
@@ -1,202 +0,0 @@
-#[[
-Copyright © 2019 Saleem Abdulrasool
-All rights reserved.
-
-SPDX-License-Identifier: BSD-3-Clause
-#]]
-
-add_library(SwiftWin32 SHARED
- Application/_TriviallyConstructible.swift
- Application/Information.swift
- Application/LaunchKeyOptions.swift)
-target_sources(SwiftWin32 PRIVATE
- AutoLayout/LayoutAnchor.swift
- AutoLayout/LayoutConstraint.swift
- AutoLayout/LayoutDimension.swift
- AutoLayout/LayoutGuide.swift
- AutoLayout/LayoutPriority.swift
- AutoLayout/LayoutSupport.swift
- AutoLayout/LayoutXAxisAnchor.swift
- AutoLayout/LayoutYAxisAnchor.swift)
-target_sources(SwiftWin32 PRIVATE
- UI/ContentSizeCategoryAdjusting.swift
- UI/ContentSizeCategoryImageAdjusting.swift
- UI/Interaction.swift
- UI/SceneSizeRestrictions.swift)
-target_sources(SwiftWin32 PRIVATE
- "App Extensions/InputViewController.swift"
- "Animation and Haptics/ViewControllerContextTransitioning.swift"
- "Animation and Haptics/Property-Based Animations/CubicTimingParameters.swift"
- "Animation and Haptics/Property-Based Animations/SpringTimingParameters.swift"
- "Animation and Haptics/Property-Based Animations/TimingCurveProvider.swift"
- "Animation and Haptics/Property-Based Animations/ViewAnimating.swift"
- "Animation and Haptics/Property-Based Animations/ViewImplicitlyAnimating.swift"
- "Animation and Haptics/View Controller Transitions/ViewControllerAnimatedTransitioning.swift"
- "Animation and Haptics/View Controller Transitions/ViewControllerInteractiveTransitioning.swift"
- "Animation and Haptics/View Controller Transitions/ViewControllerTransitionCoordinator.swift"
- "Animation and Haptics/View Controller Transitions/ViewControllerTransitionCoordinatorContext.swift"
- "Animation and Haptics/View Controller Transitions/ViewControllerTransitioningDelegate.swift"
- "App and Environment/AdaptivePresentationControllerDelegate.swift"
- "App and Environment/Application.swift"
- "App and Environment/ApplicationDelegate.swift"
- "App and Environment/ApplicationMain.swift"
- "App and Environment/Device.swift"
- "App and Environment/TraitCollection.swift"
- "App and Environment/TraitEnvironment.swift"
- "App and Environment/Scenes/Scene.swift"
- "App and Environment/Scenes/SceneConfiguration.swift"
- "App and Environment/Scenes/SceneDelegate.swift"
- "App and Environment/Scenes/SceneSession.swift"
- "App and Environment/Scenes/WindowScene.swift"
- "App and Environment/Scenes/WindowSceneDelegate.swift"
- "Appearance Customization/Configurations/BackgroundConfiguration.swift"
- "Appearance Customization/Configurations/CellConfigurationState.swift"
- "Appearance Customization/Configurations/ConfigurationColorTransformer.swift"
- "Appearance Customization/Configurations/ConfigurationState.swift"
- "Appearance Customization/Configurations/ConfigurationStateCustomKey.swift"
- "Drag and Drop/SpringLoadedInteractionContext.swift"
- "Drawing/BezierPath.swift"
- "Drawing/Color.swift"
- "Focus-Based Navigation/FocusAnimationCoordinator.swift"
- "Focus-Based Navigation/FocusEnvironment.swift"
- "Focus-Based Navigation/FocusItem.swift"
- "Focus-Based Navigation/FocusItemContainer.swift"
- "Focus-Based Navigation/FocusMovementHint.swift"
- "Focus-Based Navigation/FocusUpdateContext.swift"
- "Images and PDF/Image.swift"
- "Keyboards and Input/TextInputTraits.swift"
- "Menus and Shortcuts/Action.swift"
- "Menus and Shortcuts/Command.swift"
- "Menus and Shortcuts/ContextMenuConfiguration.swift"
- "Menus and Shortcuts/ContextMenuInteractionAnimating.swift"
- "Menus and Shortcuts/ContextMenuInteractionCommitAnimating.swift"
- "Menus and Shortcuts/ContextMenuInteraction.swift"
- "Menus and Shortcuts/ContextMenuInteractionDelegate.swift"
- "Menus and Shortcuts/Menu.swift"
- "Menus and Shortcuts/MenuBuilder.swift"
- "Menus and Shortcuts/MenuElement.swift"
- "Menus and Shortcuts/MenuSystem.swift"
- "Menus and Shortcuts/PreviewParameters.swift"
- "Menus and Shortcuts/PreviewTarget.swift"
- "Menus and Shortcuts/TargetedPreview.swift"
- "Pointer Interactions/PointerInteraction.swift"
- "Pointer Interactions/PointerInteractionAnimating.swift"
- "Pointer Interactions/PointerInteractionDelegate.swift"
- "Pointer Interactions/PointerRegion.swift"
- "Pointer Interactions/PointerRegionRequest.swift"
- "Pointer Interactions/PointerStyle.swift"
- "Text Display and Fonts/Font.swift"
- "Text Display and Fonts/FontDescriptor.swift"
- "Text Display and Fonts/FontMetrics.swift"
- "Touches, Presses, and Gestures/Event.swift"
- "Touches, Presses, and Gestures/GestureRecognizer.swift"
- "Touches, Presses, and Gestures/GestureRecognizerDelegate.swift"
- "Touches, Presses, and Gestures/Responder.swift"
- "Touches, Presses, and Gestures/Touch.swift"
- "Touches, Presses, and Gestures/Press.swift"
- "Touches, Presses, and Gestures/PressesEvent.swift"
- "View Controllers/ContentContainer.swift"
- "View Controllers/PresentationController.swift"
- "View Controllers/ViewController.swift"
- "Views and Controls/Axis.swift"
- "Views and Controls/BarItem.swift"
- "Views and Controls/BarButtonItem.swift"
- "Views and Controls/BarButtonItemGroup.swift"
- "Views and Controls/BarPositioning.swift"
- "Views and Controls/Button.swift"
- "Views and Controls/Control.swift"
- "Views and Controls/DatePicker.swift"
- "Views and Controls/DirectionalEdgeInsets.swift"
- "Views and Controls/DirectionalRectEdge.swift"
- "Views and Controls/EdgeInsets.swift"
- "Views and Controls/ImageView.swift"
- "Views and Controls/Label.swift"
- "Views and Controls/Offset.swift"
- "Views and Controls/PickerView.swift"
- "Views and Controls/ProgressView.swift"
- "Views and Controls/Slider.swift"
- "Views and Controls/Stepper.swift"
- "Views and Controls/Switch.swift"
- "Views and Controls/TextAlignment.swift"
- "Views and Controls/TextField.swift"
- "Views and Controls/TextView.swift"
- "Views and Controls/View.swift"
- "Views and Controls/VisualEffect.swift"
- "Views and Controls/Table Views/ContextualAction.swift"
- "Views and Controls/Table Views/SwipeActionsConfiguration.swift"
- "Views and Controls/Table Views/TableView.swift"
- "Views and Controls/Table Views/TableViewCell.swift"
- "Views and Controls/Table Views/TableViewDataSource.swift"
- "Views and Controls/Table Views/TableViewDelegate.swift"
- "Views and Controls/Table Views/TableViewFocusUpdateContext.swift"
- "Windows and Screens/AlertAction.swift"
- "Windows and Screens/AlertController.swift"
- "Windows and Screens/CoordinateSpace.swift"
- "Windows and Screens/Screen.swift"
- "Windows and Screens/Window.swift")
-target_sources(SwiftWin32 PRIVATE
- Platform/BatteryMonitor.swift
- Platform/Error.swift
- Platform/Win32+Menu.swift
- Platform/Win32+PropertyWrappers.swift
- Platform/WindowClass.swift
- Platform/WindowsHandle.swift)
-target_sources(SwiftWin32 PRIVATE
- Support/Array+Extensions.swift
- Support/Date+Extensions.swift
- Support/IndexPath+UIExtensions.swift
- Support/Logging.swift
- Support/Rect+UIExtensions.swift
- Support/Point+UIExtensions.swift
- Support/Size+UIExtensions.swift
- Support/String+UIExtensions.swift
- Support/WindowsHandle+UIExtensions.swift
- Support/WinSDK+Extensions.swift
- Support/WinSDK+UIExtensions.swift)
-target_sources(SwiftWin32 PRIVATE
- Support/WindowMessage.swift)
-if(CMAKE_Swift_COMPILER_VERSION VERSION_LESS 5.7.0)
- target_sources(SwiftWin32 PRIVATE
- CoreAnimation/Transform3D.swift)
- target_sources(SwiftWin32 PRIVATE
- CoreGraphics/AffineTransform.swift
- CoreGraphics/Point.swift
- CoreGraphics/Rect.swift
- CoreGraphics/Size.swift
- CoreGraphics/Vector.swift)
-else()
- add_library(CoreAnimation STATIC
- CoreAnimation/Transform3D.swift)
- target_link_libraries(SwiftWin32 PRIVATE
- CoreAnimation)
-
- add_library(CoreGraphics STATIC
- CoreGraphics/AffineTransform.swift
- CoreGraphics/Point.swift
- CoreGraphics/Rect.swift
- CoreGraphics/Size.swift
- CoreGraphics/Vector.swift)
- target_link_libraries(SwiftWin32 PRIVATE
- CoreGraphics)
-endif()
-target_link_libraries(SwiftWin32 PUBLIC
- ComCtl32
- User32)
-target_link_libraries(SwiftWin32 PUBLIC
- SwiftCOM)
-target_link_libraries(SwiftWin32 PUBLIC
- $<$>:dispatch>
- $<$>:Foundation>)
-target_link_libraries(SwiftWin32 PRIVATE
- Logging
- OrderedCollections)
-set_target_properties(SwiftWin32 PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}
- INTERFACE_LINK_DIRECTORIES $)
-
-
-if(CMAKE_Swift_COMPILER_VERSION VERSION_GREATER_EQUAL 5.7.0)
- _install_target(CoreAnimation)
- _install_target(CoreGraphics)
-endif()
-_install_target(SwiftWin32)
diff --git a/Sources/SwiftWin32/CoreAnimation/Transform3D.swift b/Sources/SwiftWin32/CoreAnimation/Transform3D.swift
deleted file mode 100644
index c8cae9f3..00000000
--- a/Sources/SwiftWin32/CoreAnimation/Transform3D.swift
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// The standard transform matrix.
-public struct Transform3D {
- // MARK - Initializers
-
- public init() {
- self.m11 = 0
- self.m12 = 0
- self.m13 = 0
- self.m14 = 0
- self.m21 = 0
- self.m22 = 0
- self.m23 = 0
- self.m24 = 0
- self.m31 = 0
- self.m32 = 0
- self.m33 = 0
- self.m34 = 0
- self.m41 = 0
- self.m42 = 0
- self.m43 = 0
- self.m44 = 0
- }
-
- public init(m11: Double, m12: Double, m13: Double, m14: Double,
- m21: Double, m22: Double, m23: Double, m24: Double,
- m31: Double, m32: Double, m33: Double, m34: Double,
- m41: Double, m42: Double, m43: Double, m44: Double) {
- self.m11 = m11
- self.m12 = m12
- self.m13 = m13
- self.m14 = m14
- self.m21 = m21
- self.m22 = m22
- self.m23 = m23
- self.m24 = m24
- self.m31 = m31
- self.m32 = m32
- self.m33 = m33
- self.m34 = m34
- self.m41 = m41
- self.m42 = m42
- self.m43 = m43
- self.m44 = m44
- }
-
- // public init(_ m: float4x4) { }
-
- // public init(_ m: double4x4) { }
-
- // MARK - Instance Properties
-
- /// The entry at position 1,1 in the matrix.
- var m11: Double
-
- /// The entry at position 1,2 in the matrix.
- var m12: Double
-
- /// The entry at position 1,3 in the matrix.
- var m13: Double
-
- /// The entry at position 1,4 in the matrix.
- var m14: Double
-
- /// The entry at position 2,1 in the matrix.
- var m21: Double
-
- /// The entry at position 2,2 in the matrix.
- var m22: Double
-
- /// The entry at position 2,3 in the matrix.
- var m23: Double
-
- /// The entry at position 2,4 in the matrix.
- var m24: Double
-
- /// The entry at position 3,1 in the matrix.
- var m31: Double
-
- /// The entry at position 3,2 in the matrix.
- var m32: Double
-
- /// The entry at position 3,3 in the matrix.
- var m33: Double
-
- /// The entry at position 3,4 in the matrix.
- var m34: Double
-
- /// The entry at position 4,1 in the matrix.
- var m41: Double
-
- /// The entry at position 4,2 in the matrix.
- var m42: Double
-
- /// The entry at position 4,3 in the matrix.
- var m43: Double
-
- /// The entry at position 4,4 in the matrix.
- var m44: Double
-}
-
-extension Transform3D {
- /// The identity transform.
- /// [1, 0, 0, 0]
- /// [0, 1, 0, 0]
- /// [0, 0, 1, 0]
- /// [0, 0, 0, 1]
- public static var identity: Transform3D {
- Transform3D(m11: 1, m12: 0, m13: 0, m14: 0,
- m21: 0, m22: 1, m23: 0, m24: 0,
- m31: 0, m32: 0, m33: 1, m34: 0,
- m41: 0, m42: 0, m43: 0, m44: 1)
- }
-}
diff --git a/Sources/SwiftWin32/CoreGraphics/AffineTransform.swift b/Sources/SwiftWin32/CoreGraphics/AffineTransform.swift
deleted file mode 100644
index 149c7bc6..00000000
--- a/Sources/SwiftWin32/CoreGraphics/AffineTransform.swift
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import func ucrt.sin
-import func ucrt.cos
-
-/// An affine transformation matrix for use in drawing 2D graphics.
-public struct AffineTransform {
- // MARK -
-
- /// The identity transform.
- public static var identity: AffineTransform {
- AffineTransform( a: 1.0, b: 0.0,
- c: 0.0, d: 1.0,
- tx: 0.0, ty: 0.0)
- }
-
- // MARK -
-
- /// The entry at position [1,1] in the matrix.
- public var a: Double
-
- /// The entry at position [1,2] in the matrix.
- public var b: Double
-
- /// The entry at position [2,1] in the matrix.
- public var c: Double
-
- /// The entry at position [2,2] in the matrix.
- public var d: Double
-
- /// The entry at position [3,1] in the matrix.
- public var tx: Double
-
- /// The entry at position [3,2] in the matrix.
- public var ty: Double
-
- /// Checks whether an affine transform is the identity transform.
- public var isIdentity: Bool {
- return self == .identity
- }
-
- // MARK - Initializers
-
- public init() {
- self.a = 0.0
- self.b = 0.0
- self.c = 0.0
- self.d = 0.0
- self.tx = 0.0
- self.ty = 0.0
- }
-
- public init( a: Double, b: Double,
- c: Double, d: Double,
- tx: Double, ty: Double) {
- self.a = a
- self.b = b
- self.c = c
- self.d = d
- self.tx = tx
- self.ty = ty
- }
-
- /// Returns an affine transformation matrix constructed from a rotation value
- /// you provide.
- public init(rotationAngle radians: Double) {
- let sine: Double = sin(radians)
- let cosine: Double = cos(radians)
-
- self.init( a: cosine, b: sine,
- c: -sine, d: cosine,
- tx: 0.0, ty: 0.0)
- }
-
- /// Returns an affine transformation matrix constructed from scaling values
- /// you provide.
- public init(scaleX sx: Double, y sy: Double) {
- self.init( a: sx, b: 0.0,
- c: 0.0, d: sy,
- tx: 0.0, ty: 0.0)
- }
-
- /// Returns an affine transformation matrix constructed from translation
- /// values you provide.
- public init(translationX tx: Double, y ty: Double) {
- self.init( a: 1.0, b: 0.0,
- c: 0.0, d: 1.0,
- tx: tx, ty: ty)
- }
-
- // MARK -
-
- /// Returns an affine transformation matrix constructed by combining two
- /// existing affine transforms.
- public func concatenating(_ transform: AffineTransform) -> AffineTransform {
- return AffineTransform(a: self.a * transform.a + self.b * transform.c,
- b: self.a * transform.b + self.b * transform.d,
- c: self.c * transform.a + self.d * transform.c,
- d: self.c * transform.b + self.d * transform.d,
- tx: self.tx * transform.a + self.ty * transform.c + transform.tx,
- ty: self.tx * transform.b + self.ty * transform.d + transform.ty)
- }
-
- /// Returns an affine transformation matrix constructed by inverting an
- /// existing affine transform.
- public func inverted() -> AffineTransform {
- let determinant = self.a * self.d - self.b * self.c
-
- // The matrix is in-invertible if the determinant is 0.
- if determinant == 0 { return self }
-
- let a = self.d / determinant
- let b = -self.b / determinant
- let c = -self.c / determinant
- let d = self.a / determinant
-
- return AffineTransform(a: a, b: b, c: c, d: d,
- tx: -a * self.tx - c * self.ty,
- ty: -b * self.tx - d * self.ty)
- }
-}
-
-extension AffineTransform: Equatable {
-}
diff --git a/Sources/SwiftWin32/CoreGraphics/Point.swift b/Sources/SwiftWin32/CoreGraphics/Point.swift
deleted file mode 100644
index 85b0a163..00000000
--- a/Sources/SwiftWin32/CoreGraphics/Point.swift
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright © 2019 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A structure that contains a point in a two-dimensional coordinate system.
-public struct Point {
- // MARK - Creating Point Values
-
- /// Creates a point with coordinates specified as floating-point values.
- public init(x: Double, y: Double) {
- self.x = x
- self.y = y
- }
-
- /// Creates a point with coordinates specified as integer values.
- public init(x: Int, y: Int) {
- self.init(x: Double(x), y: Double(y))
- }
-
- // MARK - Special Values
-
- /// The point with location (0,0).
- public static var zero: Point {
- Point(x: 0, y: 0)
- }
-
- /// Creates a point with location (0,0).
- public init() {
- self.x = 0.0
- self.y = 0.0
- }
-
- // MARK - Geometric Properties
-
- /// The x-coordinate of the point.
- public var x: Double
-
- /// The y-coordinate of the point.
- public var y: Double
-
- // MARK - Transforming Points
-
- /// Returns the point resulting from an affine transformation of an existing
- /// point.
- public func applying(_ transform: AffineTransform) -> Point {
- return Point(x: transform.a * self.x + transform.c * self.y + transform.tx,
- y: transform.b * self.x + transform.d * self.y + transform.ty)
- }
-}
-
-extension Point: Equatable {
-}
-
-extension Point: CustomDebugStringConvertible {
- public var debugDescription: String {
- return "Point(x: \(x), y: \(y))"
- }
-}
diff --git a/Sources/SwiftWin32/CoreGraphics/Rect.swift b/Sources/SwiftWin32/CoreGraphics/Rect.swift
deleted file mode 100644
index 225c3ade..00000000
--- a/Sources/SwiftWin32/CoreGraphics/Rect.swift
+++ /dev/null
@@ -1,277 +0,0 @@
-// Copyright © 2019 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import CRT
-import WinSDK
-
-@inline(__always)
-private func __equals(_ lhs: Rect, _ rhs: Rect) -> Bool {
- return lhs.origin == rhs.origin && lhs.size == rhs.size
-}
-
-extension Rect {
- /// Coordinates that establish the edges of a rectangle.
- @frozen
- public enum Edge: UInt32 {
- /// The minimum value for the x-coordinate of the rectangle. In the default
- /// coordinate space, this is the left edge of the rectangle.
- case minXEdge
-
- /// The minimum value for the y-coordinate of the rectangle. In the default
- /// coordinate space, this is the top edge of the rectangle.
- case minYEdge
-
- /// The maximum value for the x-coordinate of the rectangle. In the default
- /// coordinate space, this is the right edge of the rectangle.
- case maxXEdge
-
- /// The maximum value for the y-coordinate of the rectangle. In the default
- /// coordinate space, this is the bottom edge of the rectangle.
- case maxYEdge
- }
-}
-
-/// A structure that contains the location and dimensions of a rectangle.
-public struct Rect {
- // MARK - Creating Rectangle Values
-
- /// Creates a rectangle with the specified origin and size.
- public init(origin: Point, size: Size) {
- self.origin = origin
- self.size = size
- }
-
- /// Creates a rectangle with coordinates and dimensions specified as
- /// floating-point values.
- public init(x: Double, y: Double, width: Double, height: Double) {
- self.init(origin: Point(x: x, y: y),
- size: Size(width: width, height: height))
- }
-
- /// Creates a rectangle with coordinates and dimensions specified as integer
- /// values.
- public init(x: Int, y: Int, width: Int, height: Int) {
- self.init(origin: Point(x: x, y: y),
- size: Size(width: Double(width), height: Double(height)))
- }
-
- // MARK - Special Values
-
- /// A rectangle that has infinite extent.
- public static var infinite: Rect {
- Rect(x: -.leastNormalMagnitude, y: -.leastNormalMagnitude,
- width: .greatestFiniteMagnitude, height:.greatestFiniteMagnitude)
- }
-
- /// The null rectangle, representing an invalid value.
- public static var null: Rect {
- Rect(x: .infinity, y: .infinity, width: 0.0, height: 0.0)
- }
-
- /// The rectangle whose origin and size are both zero.
- public static var zero: Rect {
- Rect(x: 0, y: 0, width: 0, height: 0)
- }
-
- /// Creates a rectangle with origin (0,0) and size (0,0).
- public init() {
- self = .zero
- }
-
- // MARK - Basic Geometric Properties
-
- /// A point that specifies the coordinates of the rectangle’s origin.
- public var origin: Point
-
- /// A size that specifies the height and width of the rectangle.
- public var size: Size
-
- // MARK - Calculated Geometric Properties
-
- /// Returns the height of a rectangle.
- public var height: Double {
- return self.size.height
- }
-
- /// Returns the width of a rectangle.
- public var width: Double {
- return self.size.width
- }
-
- /// Returns the smallest value for the x-coordinate of the rectangle.
- public var minX: Double {
- return self.origin.x
- }
-
- /// Returns the x-coordinate that establishes the center of a rectangle.
- public var midX: Double {
- return self.origin.x + (self.size.width / 2)
- }
-
- /// Returns the largest value of the x-coordinate for the rectangle.
- public var maxX: Double {
- return self.origin.x + self.size.width
- }
-
- /// Returns the smallest value for the y-coordinate of the rectangle.
- public var minY: Double {
- return self.origin.y
- }
-
- /// Returns the y-coordinate that establishes the center of the rectangle.
- public var midY: Double {
- return self.origin.y + (self.size.height / 2)
- }
-
- /// Returns the largest value for the y-coordinate of the rectangle.
- public var maxY: Double {
- return self.origin.y + self.size.height
- }
-
- // MARK - Creating Derived Rectangles
-
- /// Returns a rectangle with a positive width and height.
- public var standardized: Rect {
- guard !self.isNull else { return .null }
-
- guard self.size.width < 0 || self.size.height < 0 else { return self }
- return Rect(x: self.origin.x + (self.width < 0 ? self.width : 0),
- y: self.origin.y + (self.height < 0 ? self.height : 0),
- width: abs(self.width), height: abs(self.height))
- }
-
- /// Returns the smallest rectangle that results from converting the source
- /// rectangle values to integers.
- public var integral: Rect {
- guard !self.isNull else { return .null }
-
- let standardized = self.standardized
- let origin: Point = Point(x: floor(standardized.minX),
- y: floor(standardized.minY))
- let size: Size = Size(width: ceil(standardized.maxX) - origin.x,
- height: ceil(standardized.maxY) - origin.y)
- return Rect(origin: origin, size: size)
- }
-
- /// Applies an affine transform to a rectangle.
- public func applying(_ transform: AffineTransform) -> Rect {
- guard !self.isNull else { return .null }
- if transform.isIdentity { return self.standardized }
-
- let points: [Point] = [
- Point(x: minX, y: minY), // top left
- Point(x: maxX, y: minY), // top right
- Point(x: minX, y: maxY), // bottom left
- Point(x: maxX, y: maxY), // bottom right
- ].map { $0.applying(transform) }
-
- let (minX, minY, maxX, maxY): (Double, Double, Double, Double) =
- points.map { ($0.x, $0.y) }
- .reduce((.infinity, .infinity, -.infinity, -.infinity), {
- (min($0.0, $1.0), min($0.1, $1.1), max($0.2, $1.0), max($0.3, $1.1))
- })
-
- return Rect(origin: Point(x: minX, y: minY),
- size: Size(width: maxX - minX, height: maxY - minY))
- }
-
- /// Returns a rectangle that is smaller or larger than the source rectangle,
- /// with the same center point.
- public func insetBy(dx: Double, dy: Double) -> Rect {
- let standardized = self.standardized
- let origin: Point =
- Point(x: standardized.minX + dx, y: standardized.minY + dy)
- let size: Size = Size(width: standardized.width - 2 * dx,
- height: standardized.height - 2 * dy)
- guard size.width > 0, size.height > 0 else { return .null }
- return Rect(origin: origin, size: size)
- }
-
- /// Returns a rectangle with an origin that is offset from that of the source
- /// rectangle.
- public func offsetBy(dx: Double, dy: Double) -> Rect {
- guard !self.isNull else { return self }
-
- let standardized = self.standardized
- return Rect(x: standardized.origin.x + dx,
- y: standardized.origin.y + dy,
- width: standardized.size.width,
- height: standardized.size.height)
- }
-
- /// Returns the smallest rectangle that contains the two source rectangles.
- public func union(_ rect: Rect) -> Rect {
- guard !self.isNull else { return rect }
- guard !rect.isNull else { return self }
- let lhs: Rect = self.standardized, rhs: Rect = rect.standardized
-
- let origin: Point = Point(x: min(lhs.minX, rhs.minX),
- y: min(lhs.minY, rhs.minY))
- let size: Size = Size(width: max(lhs.maxX, rhs.maxX) - origin.x,
- height: max(lhs.maxY, rhs.maxY) - origin.y)
- return Rect(origin: origin, size: size)
- }
-
- /// Returns the intersection of two rectangles.
- public func intersection(_ rect: Rect) -> Rect {
- guard !self.isNull, !rect.isNull else { return .null }
- let lhs: Rect = self.standardized, rhs: Rect = rect.standardized
-
- let origin: Point = Point(x: max(lhs.minX, rhs.minX),
- y: max(lhs.minY, rhs.minY))
- let size: Size = Size(width: min(lhs.maxX, rhs.maxX) - origin.x,
- height: min(lhs.maxY, rhs.maxY) - origin.y)
- guard size.width > 0, size.height > 0 else { return .null }
- return Rect(origin: origin, size: size)
- }
-
- // MARK - Checking Characteristics
-
- /// Returns whether two rectangles intersect.
- public func intersects(_ rect: Rect) -> Bool {
- return !intersection(rect).isEmpty
- }
-
- /// Returns whether a rectangle contains a specified point.
- public func contains(_ point: Point) -> Bool {
- guard !self.isNull else { return false }
- let standardized: Rect = self.standardized
- return standardized.minX...standardized.maxX ~= point.x
- && standardized.minY...standardized.maxY ~= point.y
- }
-
- /// Returns whether the first rectangle contains the second rectangle.
- public func contains(_ rect2: Rect) -> Bool {
- return self == self.union(rect2)
- }
-
- /// Returns whether a rectangle has zero width or height, or is a null
- /// rectangle.
- public var isEmpty: Bool {
- return self.size.height == 0 || self.size.width == 0 || self.isNull
- }
-
- /// Returns whether a rectangle is infinite.
- public var isInfinite: Bool {
- return self == .infinite
- }
-
- /// Returns whether the rectangle is equal to the null rectangle.
- public var isNull: Bool {
- return __equals(self, .null)
- }
-}
-
-extension Rect: Equatable {
- // MARK - Operator Functions
- public static func == (lhs: Rect, rhs: Rect) -> Bool {
- let lhs: Rect = lhs.standardized, rhs: Rect = rhs.standardized
- return __equals(lhs, rhs)
- }
-}
-
-extension Rect: CustomDebugStringConvertible {
- public var debugDescription: String {
- return "Rect(origin: \(origin), size: \(size))"
- }
-}
diff --git a/Sources/SwiftWin32/CoreGraphics/Size.swift b/Sources/SwiftWin32/CoreGraphics/Size.swift
deleted file mode 100644
index 5fcd1560..00000000
--- a/Sources/SwiftWin32/CoreGraphics/Size.swift
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright © 2019 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A structure that contains width and height values.
-public struct Size {
- // MARK - Geometric Properties
-
- /// A width value.
- public var width: Double
-
- /// A height value.
- public var height: Double
-
- // MARK - Special Values
-
- /// The size whose width and height are both zero.
- public static var zero: Size {
- Size(width: 0, height: 0)
- }
-
- /// Creates a size with zero width and height.
- public init() {
- self = .zero
- }
-
- // MARK - Transforming Sizes
-
- /// Returns the height and width resulting from a transformation of an
- /// existing height and width.
- func applying(_ transform: AffineTransform) -> Size {
- return Size(width: transform.a * self.width + transform.c * self.height,
- height: transform.b * self.width + transform.d * self.height)
- }
-
- // MARK - Initializers
-
- /// Creates a size with dimensions specified as floating-point values.
- public init(width: Double, height: Double) {
- self.height = height
- self.width = width
- }
-
- public init(width: Int, height: Int) {
- self.init(width: Double(width), height: Double(height))
- }
-}
-
-extension Size: Equatable {
-}
-
-extension Size: CustomDebugStringConvertible {
- public var debugDescription: String {
- return "Size(width: \(width), height: \(height))"
- }
-}
diff --git a/Sources/SwiftWin32/CoreGraphics/Vector.swift b/Sources/SwiftWin32/CoreGraphics/Vector.swift
deleted file mode 100644
index 2d471b48..00000000
--- a/Sources/SwiftWin32/CoreGraphics/Vector.swift
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// A structure that contains a two-dimensional vector.
-public struct Vector {
- // MARK - Special Values
-
- /// The vector whose components are both zero.
- public static var zero: Vector {
- Vector(dx: 0.0, dy: 0.0)
- }
-
- /// Creates a vector whose components are both zero.
- public init() {
- self.dx = 0.0
- self.dy = 0.0
- }
-
- // MARK - Geometric Properties
-
- /// The x component of the vector.
- public var dx: Double
-
- /// The y component of the vector.
- public var dy: Double
-
- // MARK - Initializers
-
- /// Creates a vector with components specified as floating-point values.
- public init(dx: Double, dy: Double) {
- self.dx = dx
- self.dy = dy
- }
-
- /// Creates a vector with components specified as floating-point values.
- public init(dx: Float, dy: Float) {
- self.dx = Double(dx)
- self.dy = Double(dy)
- }
-
- /// Creates a vector with components specified as integer values.
- public init(dx: Int, dy: Int) {
- self.dx = Double(dx)
- self.dy = Double(dy)
- }
-}
-
-extension Vector: CustomDebugStringConvertible {
- public var debugDescription: String {
- return "(\(dx), \(dy))"
- }
-}
-
-extension Vector: Decodable {
-}
-
-extension Vector: Encodable {
-}
-
-extension Vector: Equatable {
-}
diff --git a/Sources/SwiftWin32/Drag and Drop/SpringLoadedInteractionContext.swift b/Sources/SwiftWin32/Drag and Drop/SpringLoadedInteractionContext.swift
deleted file mode 100644
index 7f746675..00000000
--- a/Sources/SwiftWin32/Drag and Drop/SpringLoadedInteractionContext.swift
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// The spring-loaded interaction states that determine the style of the
-/// interaction view.
-public enum SpringLoadedInteractionEffectState: Int {
- /// An interaction state that indicates that the view was spring loaded.
- case activated
- /// An interaction state that indicates that spring loading is about to start.
- case activating
- /// An interaction state that indicates that spring loading is not engaged.
- case inactive
- /// An interaction state that indicates that spring loading is available.
- case possible
-}
-
-/// The interface an object implements to provide information about a
-/// spring-loaded interaction.
-public protocol SpringLoadedInteractionContext {
- /// The current view style for the string-loaded interaction.
- var state: SpringLoadedInteractionEffectState { get }
-
- /// The specific subview, or associated model object, of the target view to
- /// use for the spring-loaded interaction.
- var targetItem: Any? { get set }
-
- /// The view to which the current spring-loaded interaction view style is
- /// applied.
- var targetView: View? { get set }
-}
diff --git a/Sources/SwiftWin32/Drawing/BezierPath.swift b/Sources/SwiftWin32/Drawing/BezierPath.swift
deleted file mode 100644
index 49fa8e79..00000000
--- a/Sources/SwiftWin32/Drawing/BezierPath.swift
+++ /dev/null
@@ -1,5 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-public class BezierPath {
-}
diff --git a/Sources/SwiftWin32/Drawing/Color.swift b/Sources/SwiftWin32/Drawing/Color.swift
deleted file mode 100644
index 491186f3..00000000
--- a/Sources/SwiftWin32/Drawing/Color.swift
+++ /dev/null
@@ -1,1052 +0,0 @@
-// Copyright © 2019 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import WinSDK
-
-extension Color {
- fileprivate enum Representation {
- case rgba(Double, Double, Double, Double)
- case hsba(Double, Double, Double, Double)
- case gray(Double, Double)
- case `func`((TraitCollection) -> Color)
- }
-}
-
-extension Color.Representation: Equatable {
- internal static func ==(_ lhs: Color.Representation,
- _ rhs: Color.Representation) -> Bool {
- switch (lhs, rhs) {
- case let (.rgba(lr, lg, lb, la), .rgba(rr, rg, rb, ra)):
- return (lr, lg, lb, la) == (rr, rg, rb, ra)
- case let (.hsba(lh, ls, lb, la), .hsba(rh, rs, rb, ra)):
- return (lh, ls, lb, la) == (rh, rs, rb, ra)
- case let (.gray(lg, la), gray(rg, ra)):
- return (lg, la) == (rg, ra)
- case let (.func(lhs), .func(rhs)):
- return withUnsafePointer(to: lhs) { lhs in
- return withUnsafePointer(to: rhs) { rhs in
- lhs == rhs
- }
- }
- default: return false
- }
- }
-}
-
-extension Color.Representation: Hashable {
- public func hash(into hasher: inout Hasher) {
- switch self {
- case .rgba(let r, let g, let b, let a):
- hasher.combine(0) // colorspace
- hasher.combine(r)
- hasher.combine(g)
- hasher.combine(b)
- hasher.combine(a)
- case .hsba(let h, let s, let b, let a):
- hasher.combine(1) // colorspace
- hasher.combine(h)
- hasher.combine(s)
- hasher.combine(b)
- hasher.combine(a)
- case .gray(let white, let alpha):
- hasher.combine(2) // colorspace
- hasher.combine(white)
- hasher.combine(alpha)
- case .func(let body):
- withUnsafePointer(to: body) {
- hasher.combine($0)
- }
- }
- }
-}
-
-/// An object that stores color data and sometimes opacity.
-public struct Color {
- private let value: Representation
-
- // MARK - Creating a Color from Component Values
-
- /// Creates a color object using the specified opacity and grayscale values.
- public init(white: Double, alpha: Double) {
- self.value = .gray(white, alpha)
- }
-
- /// Creates a color object using the specified opacity and HSB color space
- /// component values.
- public init(hue: Double, saturation: Double, brightness: Double,
- alpha: Double) {
- self.value = .hsba(hue, saturation, brightness, alpha)
- }
-
- /// Creates a color object using the specified opacity and RGB component
- /// values.
- public init(red: Double, green: Double, blue: Double, alpha: Double) {
- self.value = .rgba(red, green, blue, alpha)
- }
-
- // MARK - Creating a Color Dynamically
-
- /// Creates a color object that uses the specified block to generate its color
- /// data dynamically.
- public init(dynamicProvider block: @escaping (TraitCollection) -> Color) {
- self.value = .func(block)
- }
-
- // MARK - Getting the Color Information
-
- /// Returns the components that form the color in the HSB color space.
- ///
- /// If the color is in a compatible color space, it converts into the HSB
- /// color space, and its components return to your application. If the color
- /// isn’t in a compatible color space, the parameters don’t change.
- public func getHue(_ hue: UnsafeMutablePointer?,
- saturation: UnsafeMutablePointer?,
- brightness: UnsafeMutablePointer?,
- alpha: UnsafeMutablePointer?) -> Bool {
- switch self.value {
- case .gray:
- fatalError("cannot convert Gray to HSBA")
- case .rgba(let r, let g, let b, let a):
- func rgb2hsb(_ r: Double, _ g: Double, _ b: Double)
- -> (Double, Double, Double) {
- let V = max(r, g, b)
- let m = min(r, g, b)
- let delta = V - m
-
- var hue: Double
- if V == 0.0 { hue = 0.0 }
- else if V == r { hue = (g - b) / delta }
- else if V == g { hue = 2.0 + (b - r) / delta }
- else if V == b { hue = 4.0 + (r - g) / delta }
- else { fatalError("maximum must be one of the values") }
-
- hue = ucrt.fmodl(hue + 6.0, 6.0)
- return (hue == 0.0 ? 1.0 : hue / 6.0, V, V == 0.0 ? 0.0 : delta / V)
- }
-
- let (h, s, b) = rgb2hsb(r, g, b)
-
- hue?.pointee = h
- brightness?.pointee = s
- saturation?.pointee = b
- alpha?.pointee = a
- return true
- case .hsba(let h, let s, let b, let a):
- hue?.pointee = h
- saturation?.pointee = s
- brightness?.pointee = b
- alpha?.pointee = a
- return true
- case .func:
- return resolvedColor(with: TraitCollection.current)
- .getHue(hue, saturation: saturation, brightness: brightness,
- alpha: alpha)
- }
- }
-
- /// Returns the components that form the color in the RGB color space.
- ///
- /// If the color is in a compatible color space, it converts into RGB format
- /// and its components return to your application. If the color isn’t in a
- /// compatible color space, the parameters don’t change.
- public func getRed(_ red: UnsafeMutablePointer?,
- green: UnsafeMutablePointer?,
- blue: UnsafeMutablePointer?,
- alpha: UnsafeMutablePointer?) -> Bool {
- switch self.value {
- case .gray:
- fatalError("cannot convert Gray to RGBA")
- case .rgba(let r, let g, let b, let a):
- red?.pointee = r
- green?.pointee = g
- blue?.pointee = b
- alpha?.pointee = a
- return true
- case .hsba(let h, let s, let b, let a):
- func f(_ n: Double) -> Double {
- let k = ucrt.fmod(n + (6.0 * h), 6.0)
- return b - b * s * max(0, min(k, 4 - k, 1))
- }
- red?.pointee = f(5.0)
- green?.pointee = f(3.0)
- blue?.pointee = f(1.0)
- alpha?.pointee = a
- return true
- case .func:
- return resolvedColor(with: TraitCollection.current)
- .getRed(red, green: green, blue: blue, alpha: alpha)
- }
- }
-
- /// Returns the grayscale components of the color.
- ///
- /// If the color is in a compatible color space, it converts into grayscale
- /// format and its returned to your application. If the color isn’t in a
- /// compatible color space, the parameters don’t change.
- public func getWhite(_ white: UnsafeMutablePointer?,
- alpha: UnsafeMutablePointer?) -> Bool {
- switch self.value {
- case .gray(let w, let a):
- white?.pointee = w
- alpha?.pointee = a
- return true
- case .rgba(let r, let g, let b, let a):
- // The weighted or luminosity method uses the weighted average of the
- // channels based on the wavelength of the channel.
- // The constants here are from ITU-R BT.601-7.
- white?.pointee = r * 0.299 + g * 0.587 + b * 0.114
- alpha?.pointee = a
- return true
- case .hsba(let h, let s, let b, let a):
- func f(_ n: Double) -> Double {
- let k = ucrt.fmod(n + (6.0 * h), 6.0)
- return b - b * s * max(0, min(k, 4 - k, 1))
- }
- white?.pointee = f(5.0) * 0.299 + f(3.0) * 0.587 + f(1.0) * 0.114
- alpha?.pointee = a
- return true
- case .func:
- return resolvedColor(with: TraitCollection.current)
- .getWhite(white, alpha: alpha)
- }
- }
-
- // MARK - Resolving a Dynamically Generated Color
-
- /// Returns the version of the current color that results from the specified
- /// traits.
- public func resolvedColor(with traitCollection: TraitCollection) -> Color {
- guard case let .func(body) = self.value else { return self }
- return body(traitCollection)
- }
-}
-
-extension COLORREF {
- fileprivate init(red r: Double, green g: Double, blue b: Double) {
- self = 0
- | (DWORD((b * 255.0).rounded(.toNearestOrAwayFromZero)) << 16)
- | (DWORD((g * 255.0).rounded(.toNearestOrAwayFromZero)) << 8)
- | (DWORD((r * 255.0).rounded(.toNearestOrAwayFromZero)) << 0)
- }
-}
-
-extension Color {
- internal var COLORREF: COLORREF {
- switch self.value {
- case .rgba(let r, let g, let b, _):
- return WinSDK.COLORREF(red: r, green: g, blue: b)
- case .hsba(let h, let s, let b, _):
- func f(_ n: Double) -> Double {
- let k = ucrt.fmod(n + (6.0 * h), 6.0)
- return b - b * s * max(0, min(k, 4 - k, 1))
- }
-
- return WinSDK.COLORREF(red: f(5.0), green: f(3.0), blue: f(1.0))
- case .gray(let w, _):
- return WinSDK.COLORREF(red: w * 255.0, green: w * 255.0, blue: w * 255.0)
- case .func:
- return self.resolvedColor(with: TraitCollection.current).COLORREF
- }
- }
-}
-
-extension Color: _ExpressibleByColorLiteral {
- public init(_colorLiteralRed red: Float, green: Float, blue: Float,
- alpha: Float) {
- self.init(red: Double(red), green: Double(green), blue: Double(blue),
- alpha: Double(alpha))
- }
-}
-
-extension Color: Equatable {
- public static func ==(lhs: Color, rhs: Color) -> Bool {
- // TODO(compnerd) make this more accurate
- return lhs.COLORREF == rhs.COLORREF
- }
-}
-
-extension Color: Hashable {
- public func hash(into hasher: inout Hasher) {
- hasher.combine(self.value)
- }
-}
-
-extension Color {
- internal init(color: COLORREF) {
- self.init(red: Int(GetRValue(color)), green: Int(GetGValue(color)),
- blue: Int(GetBValue(color)))
- }
-}
-
-extension Color {
- internal init(red: Int, green: Int, blue: Int, alpha: Double = 1.0) {
- self.init(red: Double(red) / 255.0, green: Double(green) / 255.0,
- blue: Double(blue) / 255.0, alpha: Double(alpha))
- }
-}
-
-// MARK - Standard Colors
-
-extension Color {
- // MARK - Adaptable Colors
-
- /// A blue color that automatically adapts to the current trait environment.
- public static var systemBlue: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 0, green: 122, blue: 255)
- case (.normal, .dark):
- return Color(red: 10, green: 132, blue: 255)
- case (.high, .light):
- return Color(red: 0, green: 64, blue: 221)
- case (.high, .dark):
- return Color(red: 64, green: 156, blue: 255)
- }
- })
- }
-
- /// A brown color that automatically adapts to the current trait environment.
- public static var systemBrown: Color {
- fatalError("\(#function) not yet implemented")
- }
-
- /// A green color that automatically adapts to the current trait environment.
- public static var systemGreen: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 52, green: 199, blue: 89)
- case (.normal, .dark):
- return Color(red: 48, green: 209, blue: 88)
- case (.high, .light):
- return Color(red: 36, green: 138, blue: 61)
- case (.high, .dark):
- return Color(red: 48, green: 219, blue: 91)
- }
- })
- }
-
- /// An indigo color that automatically adapts to the current trait
- /// environment.
- public static var systemIndigo: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 88, green: 86, blue: 214)
- case (.normal, .dark):
- return Color(red: 94, green: 92, blue: 230)
- case (.high, .light):
- return Color(red: 54, green: 52, blue: 163)
- case (.high, .dark):
- return Color(red: 125, green: 122, blue: 255)
- }
- })
- }
-
- /// An orange color that automatically adapts to the current trait
- /// environment.
- public static var systemOrange: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 255, green: 149, blue: 0)
- case (.normal, .dark):
- return Color(red: 255, green: 159, blue: 10)
- case (.high, .light):
- return Color(red: 201, green: 52, blue: 0)
- case (.high, .dark):
- return Color(red: 255, green: 179, blue: 64)
- }
- })
- }
-
- /// A pink color that automatically adapts to the current trait environment.
- public static var systemPink: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 255, green: 45, blue: 85)
- case (.normal, .dark):
- return Color(red: 255, green: 55, blue: 95)
- case (.high, .light):
- return Color(red: 211, green: 15, blue: 69)
- case (.high, .dark):
- return Color(red: 255, green: 100, blue: 130)
- }
- })
- }
-
- /// A purple color that automatically adapts to the current trait environment.
- public static var systemPurple: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 175, green: 82, blue: 222)
- case (.normal, .dark):
- return Color(red: 191, green: 90, blue: 242)
- case (.high, .light):
- return Color(red: 137, green: 68, blue: 171)
- case (.high, .dark):
- return Color(red: 218, green: 143, blue: 255)
- }
- })
- }
-
- /// A red color that automatically adapts to the current trait environment.
- public static var systemRed: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 255, green: 59, blue: 48)
- case (.normal, .dark):
- return Color(red: 255, green: 69, blue: 58)
- case (.high, .light):
- return Color(red: 215, green: 0, blue: 21)
- case (.high, .dark):
- return Color(red: 255, green: 105, blue: 97)
- }
- })
- }
-
- /// A teal color that automatically adapts to the current trait environment.
- public static var systemTeal: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 90, green: 200, blue: 250)
- case (.normal, .dark):
- return Color(red: 100, green: 210, blue: 255)
- case (.high, .light):
- return Color(red: 0, green: 113, blue: 164)
- case (.high, .dark):
- return Color(red: 112, green: 215, blue: 255)
- }
- })
- }
-
- /// A yellow color that automatically adapts to the current trait environment.
- public static var systemYellow: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 255, green: 204, blue: 0)
- case (.normal, .dark):
- return Color(red: 255, green: 214, blue: 10)
- case (.high, .light):
- return Color(red: 178, green: 80, blue: 0)
- case (.high, .dark):
- return Color(red: 255, green: 212, blue: 38)
- }
- })
- }
-
- // MARK - Adaptable Grey Colors
-
- /// The standard base gray color that adapts to the environment.
- public static var systemGray: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 142, green: 142, blue: 147)
- case (.normal, .dark):
- return Color(red: 142, green: 142, blue: 147)
- case (.high, .light):
- return Color(red: 108, green: 108, blue: 112)
- case (.high, .dark):
- return Color(red: 174, green: 174, blue: 178)
- }
- })
- }
-
- /// A second-level shade of grey that adapts to the environment.
- public static var systemGray2: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 174, green: 174, blue: 178)
- case (.normal, .dark):
- return Color(red: 99, green: 99, blue: 102)
- case (.high, .light):
- return Color(red: 142, green: 142, blue: 147)
- case (.high, .dark):
- return Color(red: 124, green: 124, blue: 128)
- }
- })
- }
-
- /// A third-level shade of grey that adapts to the environment.
- public static var systemGray3: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 199, green: 199, blue: 204)
- case (.normal, .dark):
- return Color(red: 72, green: 72, blue: 74)
- case (.high, .light):
- return Color(red: 174, green: 174, blue: 178)
- case (.high, .dark):
- return Color(red: 84, green: 84, blue: 86)
- }
- })
- }
-
- /// A fourth-level shade of grey that adapts to the environment.
- public static var systemGray4: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 209, green: 209, blue: 214)
- case (.normal, .dark):
- return Color(red: 58, green: 58, blue: 60)
- case (.high, .light):
- return Color(red: 188, green: 188, blue: 192)
- case (.high, .dark):
- return Color(red: 68, green: 68, blue: 70)
- }
- })
- }
-
- /// A fifth-level shade of grey that adapts to the environment.
- public static var systemGray5: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 229, green: 229, blue: 234)
- case (.normal, .dark):
- return Color(red: 44, green: 44, blue: 46)
- case (.high, .light):
- return Color(red: 216, green: 216, blue: 220)
- case (.high, .dark):
- return Color(red: 54, green: 54, blue: 56)
- }
- })
- }
-
- /// A sixth-level shade of grey that adapts to the environment.
- public static var systemGray6: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 242, green: 242, blue: 247)
- case (.normal, .dark):
- return Color(red: 28, green: 28, blue: 30)
- case (.high, .light):
- return Color(red: 235, green: 235, blue: 240)
- case (.high, .dark):
- return Color(red: 36, green: 36, blue: 38)
- }
- })
- }
-
- // MARK - Transparent Color
-
- /// A color object with grayscale and alpha values that are both 0.0.
- public static var clear: Color {
- Color(white: 0.0, alpha: 0.0)
- }
-
- // MARK - Fixed Colors
-
- /// A color object in the sRGB color space with a grayscale value of 0.0 and
- /// an alpha value of 1.0.
- public static var black: Color {
- Color(white: 0.0, alpha: 1.0)
- }
-
- /// A color object with RGB values of 0.0, 0.0, and 1.0, and an alpha value of
- /// 1.0.
- public static var blue: Color {
- Color(red: 0.0, green: 0.0, blue: 1.0, alpha: 1.0)
- }
-
- /// A color object with RGB values of 0.6, 0.4, and 0.2, and an alpha value of
- /// 1.0.
- public static var brown: Color {
- Color(red: 0.6, green: 0.4, blue: 0.2, alpha: 1.0)
- }
-
- /// A color object with RGB values of 0.0, 1.0, and 1.0, and an alpha value of
- /// 1.0.
- public static var cyan: Color {
- Color(red: 0.0, green: 1.0, blue: 1.0, alpha: 1.0)
- }
-
- /// A color object with a grayscale value of 1/3 and an alpha value of 1.0.
- public static var darkGray: Color {
- Color(white: 1.0 / 3.0, alpha: 1.0)
- }
-
- /// A color object with a grayscale value of 0.5 and an alpha value of 1.0.
- public static var gray: Color {
- Color(white: 0.5, alpha: 1.0)
- }
-
- /// A color object with RGB values of 0.0, 1.0, and 0.0, and an alpha value of
- /// 1.0.
- public static var green: Color {
- Color(red: 0.0, green: 1.0, blue: 0.0, alpha: 1.0)
- }
-
- /// A color object with a grayscale value of 2/3 and an alpha value of 1.0.
- public static var lightGray: Color {
- Color(white: 2.0 / 3.0, alpha: 1.0)
- }
-
- /// A color object with RGB values of 1.0, 0.0, and 1.0, and an alpha value of
- /// 1.0.
- public static var magenta: Color {
- Color(red: 1.0, green: 0.0, blue: 1.0, alpha: 1.0)
- }
-
- /// A color object with RGB values of 1.0, 0.5, and 0.0, and an alpha value of
- /// 1.0.
- public static var orange: Color {
- Color(red: 1.0, green: 0.5, blue: 0.0, alpha: 1.0)
- }
-
- /// A color object with RGB values of 0.5, 0.0, and 0.5, and an alpha value of
- /// 1.0.
- public static var purple: Color {
- Color(red: 0.5, green: 0.0, blue: 0.5, alpha: 1.0)
- }
-
- /// A color object with RGB values of 1.0, 0.0, and 0.0, and an alpha value of
- /// 1.0.
- public static var red: Color {
- Color(red: 1.0, green: 0.0, blue: 0.0, alpha: 1.0)
- }
-
- /// A color object with a grayscale value of 1.0 and an alpha value of 1.0.
- public static var white: Color {
- Color(white: 1.0, alpha: 1.0)
- }
-
- /// A color object with RGB values of 1.0, 1.0, and 0.0, and an alpha value of
- /// 1.0.
- public static var yellow: Color {
- Color(red: 1.0, green: 1.0, blue: 0.0, alpha: 1.0)
- }
-}
-
-// MARK - UI Element Colors
-
-extension Color {
- // MARK - Label Colors
-
- /// The Color for text labels that contain primary content.
- public static var label: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (_, .light):
- return Color(white: 0.0, alpha: 1.0)
- case (_, .dark):
- return Color(white: 1.0, alpha: 1.0)
- }
- })
- }
-
- /// The color for text labels that contain secondary content.
- public static var secondaryLabel: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 60, green: 60, blue: 67, alpha: 0.60)
- case (.high, .light):
- return Color(red: 60, green: 60, blue: 67, alpha: 0.68)
- case (.normal, .dark):
- return Color(red: 235, green: 235, blue: 245, alpha: 0.60)
- case (.high, .dark):
- return Color(red: 235, green: 235, blue: 245, alpha: 0.68)
- }
- })
- }
-
- /// The color for text labels that contain tertiary content.
- public static var tertiaryLabel: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 60.0, green: 60, blue: 67, alpha: 0.30)
- case (.high, .light):
- return Color(red: 60.0, green: 60, blue: 67, alpha: 0.38)
- case (.normal, .dark):
- return Color(red: 235, green: 235, blue: 245, alpha: 0.30)
- case (.high, .dark):
- return Color(red: 235, green: 235, blue: 245, alpha: 0.38)
- }
- })
- }
-
- /// The color for text labels that contain quatenary content.
- public static var quatenaryLabel: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 60, green: 60, blue: 67, alpha: 0.18)
- case (.high, .light):
- return Color(red: 60, green: 60, blue: 67, alpha: 0.26)
- case (.normal, .dark):
- return Color(red: 235, green: 235, blue: 245, alpha: 0.18)
- case (.high, .dark):
- return Color(red: 235, green: 235, blue: 245, alpha: 0.26)
- }
- })
- }
-
- // MARK - Fill Colors
-
- /// An overlay fill color for thin and small shapes.
- public static var systemFill: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 120, green: 120, blue: 128, alpha: 0.20)
- case (.high, .light):
- return Color(red: 120, green: 120, blue: 128, alpha: 0.28)
- case (.normal, .dark):
- return Color(red: 120, green: 120, blue: 128, alpha: 0.36)
- case (.high, .dark):
- return Color(red: 120, green: 120, blue: 128, alpha: 0.44)
- }
- })
- }
-
- /// An overlay fill color for medium-size shapes.
- public static var secondarySystemFill: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 120, green: 120, blue: 128, alpha: 0.16)
- case (.high, .light):
- return Color(red: 120, green: 120, blue: 128, alpha: 0.24)
- case (.normal, .dark):
- return Color(red: 120, green: 120, blue: 128, alpha: 0.32)
- case (.high, .dark):
- return Color(red: 120, green: 120, blue: 128, alpha: 0.40)
- }
- })
- }
-
- /// An overlay fill color for large shapes.
- public static var tertiarySystemFill: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 118, green: 118, blue: 128, alpha: 0.12)
- case (.high, .light):
- return Color(red: 118, green: 118, blue: 128, alpha: 0.20)
- case (.normal, .dark):
- return Color(red: 118, green: 118, blue: 128, alpha: 0.24)
- case (.high, .dark):
- return Color(red: 118, green: 118, blue: 128, alpha: 0.32)
- }
- })
- }
-
- /// An overlay fill color for large areas that contain complex content.
- public static var quaternarySystemFill: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 116, green: 116, blue: 128, alpha: 0.08)
- case (.high, .light):
- return Color(red: 116, green: 116, blue: 128, alpha: 0.16)
- case (.normal, .dark):
- return Color(red: 118, green: 118, blue: 128, alpha: 0.18)
- case (.high, .dark):
- return Color(red: 118, green: 118, blue: 128, alpha: 0.26)
- }
- })
- }
-
- // MARK - Text Colors
-
- /// The color for placeholder text in controls or text views.
- public static var placeholderText: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 60, green: 60, blue: 67, alpha: 0.30)
- case (.high, .light):
- return Color(red: 60, green: 60, blue: 67, alpha: 0.38)
- case (.normal, .dark):
- return Color(red: 235, green: 235, blue: 245, alpha: 0.30)
- case (.high, .dark):
- return Color(red: 235, green: 235, blue: 245, alpha: 0.38)
- }
- })
- }
-
- /// Standard Content Background Colors
- ///
- /// Use these colors for standard table views and designs that have a white
- /// primary background in a light environment.
-
- /// The color for the main background of your interface.
- public static var systemBackground: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(white: 1.0, alpha: 1.0)
- case (.high, .light):
- return Color(white: 1.0, alpha: 1.0)
- case (.normal, .dark):
- return Color(white: 0.0, alpha: 1.0)
- case (.high, .dark):
- return Color(white: 0.0, alpha: 1.0)
- }
- })
- }
-
- /// The color for content layered on top of the main background.
- public static var secondarySystemBackground: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 242, green: 242, blue: 247, alpha: 1.0)
- case (.high, .light):
- return Color(red: 235, green: 235, blue: 240, alpha: 1.0)
- case (.normal, .dark):
- return Color(red: 28, green: 28, blue: 30, alpha: 1.0)
- case (.high, .dark):
- return Color(red: 36, green: 36, blue: 38, alpha: 1.0)
- }
- })
- }
-
- /// The color for content layered on top of secondary backgrounds.
- public static var tertiarySystemBackground: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(white: 1.0, alpha: 1.0)
- case (.high, .light):
- return Color(white: 1.0, alpha: 1.0)
- case (.normal, .dark):
- return Color(red: 44, green: 44, blue: 46, alpha: 1.0)
- case (.high, .dark):
- return Color(red: 54, green: 54, blue: 56, alpha: 1.0)
- }
- })
- }
-
- /// Grouped Content Background Colors
- ///
- /// Use these colors for grouped content, including table views and
- /// platter-based designs.
-
- /// The color for the main background of your grouped interface.
- public static var systemGroupedBackground: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 242, green: 242, blue: 247, alpha: 1.0)
- case (.high, .light):
- return Color(red: 235, green: 235, blue: 240, alpha: 1.0)
- case (.normal, .dark):
- return Color(white: 0.0, alpha: 1.0)
- case (.high, .dark):
- return Color(white: 0.0, alpha: 1.0)
- }
- })
- }
-
- /// The color for content layered on top of the main background of your
- /// grouped interface.
- public static var secondarySystemGroupedBackground: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 242, green: 242, blue: 247, alpha: 1.0)
- case (.high, .light):
- return Color(white: 1.0, alpha: 1.0)
- case (.normal, .dark):
- return Color(red: 28, green: 28, blue: 30, alpha: 1.0)
- case (.high, .dark):
- return Color(red: 36, green: 36, blue: 38, alpha: 1.0)
- }
- })
- }
-
- /// The color for content layered on top of secondary backgrounds of your
- /// grouped interface.
- public static var tertiarySystemGroupedBackground: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 242, green: 242, blue: 247, alpha: 1.0)
- case (.high, .light):
- return Color(red: 235, green: 235, blue: 240, alpha: 1.0)
- case (.normal, .dark):
- return Color(red: 44, green: 44, blue: 46, alpha: 1.0)
- case (.high, .dark):
- return Color(red: 54, green: 54, blue: 56, alpha: 1.0)
- }
- })
- }
-
- // MARK - Separator Colors
-
- /// The color for thin borders or divider lines that allows some underlying
- /// content to be visible.
- public static var separator: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 60, green: 60, blue: 67, alpha: 0.29)
- case (.high, .light):
- return Color(red: 60, green: 60, blue: 67, alpha: 0.37)
- case (.normal, .dark):
- return Color(red: 84, green: 84, blue: 88, alpha: 0.60)
- case (.high, .dark):
- return Color(red: 84, green: 84, blue: 88, alpha: 0.70)
- }
- })
- }
-
- /// The color for borders or divider lines that hides any underlying content.
- public static var opaqueSeparator: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 198, green: 198, blue: 200, alpha: 1.0)
- case (.high, .light):
- return Color(red: 198, green: 198, blue: 200, alpha: 1.0)
- case (.normal, .dark):
- return Color(red: 56, green: 56, blue: 58, alpha: 1.0)
- case (.high, .dark):
- return Color(red: 56, green: 56, blue: 58, alpha: 1.0)
- }
- })
- }
-
- // MARK - Link Color
-
- /// The color for links.
- public static var link: Color {
- Color(dynamicProvider: {
- switch ($0.accessibilityContrast, $0.userInterfaceStyle) {
- case (.unspecified, _), (_, .unspecified):
- log.warning("unable to query contrast or color scheme")
- fallthrough
- case (.normal, .light):
- return Color(red: 0, green: 122, blue: 255, alpha: 1.0)
- case (.high, .light):
- return Color(red: 0, green: 122, blue: 255, alpha: 1.0)
- case (.normal, .dark):
- return Color(red: 9, green: 132, blue: 255, alpha: 1.0)
- case (.high, .dark):
- return Color(red: 9, green: 132, blue: 255, alpha: 1.0)
- }
- })
- }
-
- // MARK - Nonadaptable Colors
-
- /// The nonadaptable system color for text on a light background.
- public static var darkText: Color {
- return Color(white: 0.0, alpha: 1.0)
- }
-
- /// The nonadaptable system color for text on a dark background.
- public static var lightText: Color {
- return Color(white: 1.0, alpha: 0.6)
- }
-}
diff --git a/Sources/SwiftWin32/Focus-Based Navigation/FocusAnimationCoordinator.swift b/Sources/SwiftWin32/Focus-Based Navigation/FocusAnimationCoordinator.swift
deleted file mode 100644
index c8de4cfb..00000000
--- a/Sources/SwiftWin32/Focus-Based Navigation/FocusAnimationCoordinator.swift
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import struct Foundation.TimeInterval
-
-/// Information about focusing animations being performed by the system.
-public protocol FocusAnimationContext {
- // MARK - Getting the Animation Attributes
-
- /// The duration (measured in seconds) of the focus animation.
- var duration: TimeInterval { get }
-}
-
-/// A coordinator of focus-related animations during a focus update.
-public class FocusAnimationCoordinator {
- // MARK - Adding Animations to Focus Updates
-
- /// Runs the specified set of animations together with the system animations
- /// for adding focus to an item.
- public func addCoordinatedFocusingAnimations(_ animations: ((FocusAnimationContext) -> Void)?,
- completion: (() -> Void)? = nil) {
- }
-
- /// Runs the specified set of animations together with the system animations
- /// for removing focus from an item.
- public func addCoordinatedUnfocusingAnimations(_ animations: ((FocusAnimationContext) -> Void)?,
- completion: (() -> Void)? = nil) {
- }
-
- /// Specifies the animations to coordinate with the active focus animation.
- public func addCoordinatedAnimations(_ animations: (() -> Void)?,
- completion: (() -> Void)? = nil) {
- }
-}
diff --git a/Sources/SwiftWin32/Focus-Based Navigation/FocusEnvironment.swift b/Sources/SwiftWin32/Focus-Based Navigation/FocusEnvironment.swift
deleted file mode 100644
index fed6ceaf..00000000
--- a/Sources/SwiftWin32/Focus-Based Navigation/FocusEnvironment.swift
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// An identifier for a focus-related sound.
-public struct FocusSoundIdentifier: Equatable, Hashable, RawRepresentable {
- public typealias RawValue = String
-
- public let rawValue: RawValue
-
- public init(rawValue: RawValue) {
- self.rawValue = rawValue
- }
-}
-
-extension FocusSoundIdentifier {
- public init(_ rawValue: String) {
- self.rawValue = rawValue
- }
-}
-
-extension FocusSoundIdentifier {
- /// The identifier for the default system sound to play during focus updates.
- public static var `default`: FocusSoundIdentifier {
- FocusSoundIdentifier(rawValue: "UIFocusSoundIdentifierDefault")
- }
-
- /// The identifier for disabling sound during a focus update.
- public static var none: FocusSoundIdentifier {
- FocusSoundIdentifier(rawValue: "UIFocusSoundIdentifierNone")
- }
-}
-
-/// A set of methods that define the focus behavior for a branch of the view
-/// hierarchy.
-public protocol FocusEnvironment: AnyObject {
- // MARK - Requesting Focus Update
-
- /// Submits a request to the focus engine for a focus update in this
- /// environment.
- func setNeedsFocusUpdate()
-
- /// Tells the focus engine to force a focus update immediately.
- func updateFocusIfNeeded()
-
- // MARK - Validating Focus Movements
-
- /// Returns a boolean value indicating whether the focus engine should allow
- /// the focus update described by the specified context to occur.
- func shouldUpdateFocus(in context: FocusUpdateContext) -> Bool
-
- // MARK - Responding to Focus Updates
-
- /// Called immediately after the system updates the focus to a new view.
- func didUpdateFocus(in context: FocusUpdateContext,
- with coordinator: FocusAnimationCoordinator)
-
- // MARK - Controlling User Generated Focus Movements
-
- /// An array of focus environments, ordered by priority, to which this
- /// environment prefers focus to be directed during a focus update.
- var preferredFocusEnvironments: [FocusEnvironment] { get }
-
- // MARK - Getting the Sound to Play During Updates
-
- /// Asks the delegate for the identifier of the sound to play when the object
- /// gains focus.
- func soundIdentifierForFocusUpdate(in context: FocusUpdateContext)
- -> FocusSoundIdentifier?
-
- // MARK - Checking the Ancestry of the Environment
-
- /// Returns a boolean value indicating whether the focus environment contains
- /// the specified environment.
- func contains(_ environment: FocusEnvironment) -> Bool
-
- /// The parent focus environment for this environment.
- /* weak */ var parentFocusEnvironment: FocusEnvironment? { get }
-
- /// The container for the child focus items in this focus environment.
- var focusItemContainer: FocusItemContainer? { get }
-
- // MARK -
-
- var focusGroupIdentifier: String? { get }
-}
-
-extension FocusEnvironment {
- public func soundIdentifierForFocusUpdate(in context: FocusUpdateContext)
- -> FocusSoundIdentifier? {
- return nil
- }
-}
-
-extension FocusEnvironment {
- public var focusGroupIdentifier: String? { nil }
-}
diff --git a/Sources/SwiftWin32/Focus-Based Navigation/FocusItem.swift b/Sources/SwiftWin32/Focus-Based Navigation/FocusItem.swift
deleted file mode 100644
index 362cef67..00000000
--- a/Sources/SwiftWin32/Focus-Based Navigation/FocusItem.swift
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-#if swift(>=5.7)
-import CoreGraphics
-#endif
-
-/// An object that can become focused.
-public protocol FocusItem: FocusEnvironment {
- // MARK - Determining Focusability
-
- /// A boolean value that indicates whether the item can become focused.
- var canBecomeFocused: Bool { get }
-
- /// A boolean value indicating whether the item is currently focused.
- var isFocused: Bool { get }
-
- // MARK - Retrieving the Item Frame
-
- /// The geometric frame of the item.
- var frame: Rect { get }
-
- // MARK - Providing Movement Hints
-
- func didHintFocusMovement(_ hint: FocusMovementHint)
-}
-
-extension FocusItem {
- public var isFocused: Bool { false }
-}
-
-extension FocusItem {
- public func didHintFocusMovement(_ hint: FocusMovementHint) {
- }
-}
diff --git a/Sources/SwiftWin32/Focus-Based Navigation/FocusItemContainer.swift b/Sources/SwiftWin32/Focus-Based Navigation/FocusItemContainer.swift
deleted file mode 100644
index 1d8a025c..00000000
--- a/Sources/SwiftWin32/Focus-Based Navigation/FocusItemContainer.swift
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-#if swift(>=5.7)
-import CoreGraphics
-#endif
-
-/// The container responsible for providing geometric context to focus items
-/// within a given focus environment.
-public protocol FocusItemContainer {
- // MARK - Retrieving Focus Items
-
- /// Retrieves all of the focus items within this container that intersect with
- /// the provided rectangle.
- func focusItems(in rect: Rect) -> [FocusItem]
-
- /// The coordinate space of the focus items contained in the focus item
- /// container.
- var coordinateSpace: CoordinateSpace { get }
-}
diff --git a/Sources/SwiftWin32/Focus-Based Navigation/FocusMovementHint.swift b/Sources/SwiftWin32/Focus-Based Navigation/FocusMovementHint.swift
deleted file mode 100644
index b3c43dee..00000000
--- a/Sources/SwiftWin32/Focus-Based Navigation/FocusMovementHint.swift
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-#if swift(>=5.7)
-import CoreAnimation
-import CoreGraphics
-#endif
-
-/// Provides movement hint information for the focused item.
-public class FocusMovementHint {
- // MARK -
-
- internal init () {
- fatalError("\(#function) not yet implemented")
- }
-
- // MARK - Moving Focus
-
- /// A vector representing how close focus is to moving to another item in the
- /// swiped direction.
- public private(set) var movementDirection: Vector
-
- // MARK - Transforming a Hint
-
- /// A 3D transform that contains the combined transformations of perspective,
- /// rotation, and translation.
- public private(set) var interactionTransform: Transform3D
-
- /// A 3D transform that represents a perspective matrix to be applied to match
- /// the system interaction hinting.
- public private(set) var perspectiveTransform: Transform3D
-
- /// A vector to apply to a transform to match system interaction hinting.
- public private(set) var rotation: Vector
-
- /// A vector to apply to a transform to match system interaction hinting.
- public private(set) var translation: Vector
-}
diff --git a/Sources/SwiftWin32/Focus-Based Navigation/FocusUpdateContext.swift b/Sources/SwiftWin32/Focus-Based Navigation/FocusUpdateContext.swift
deleted file mode 100644
index fd2a0f7f..00000000
--- a/Sources/SwiftWin32/Focus-Based Navigation/FocusUpdateContext.swift
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import class Foundation.NSNotification
-
-/// The general type of an event.
-public struct FocusHeading: OptionSet {
- public typealias RawValue = UInt
-
- public let rawValue: RawValue
-
- public init(rawValue: RawValue) {
- self.rawValue = rawValue
- }
-}
-
-extension FocusHeading {
- internal static var none: FocusHeading {
- FocusHeading(rawValue: 0 << 0)
- }
-
- /// The focus update is heading in the up direction.
- public static var up: FocusHeading {
- FocusHeading(rawValue: 1 << 0)
- }
-
- /// The focus update is heading in the down direction.
- public static var down: FocusHeading {
- FocusHeading(rawValue: 1 << 1)
- }
-
- /// The focus update is heading in the left direction.
- public static var left: FocusHeading {
- FocusHeading(rawValue: 1 << 2)
- }
-
- /// The focus update is heading in the right direction.
- public static var right: FocusHeading {
- FocusHeading(rawValue: 1 << 3)
- }
-
- /// The focus update is heading to the next item.
- public static var next: FocusHeading {
- FocusHeading(rawValue: 1 << 4)
- }
-
- /// The focus update is heading to the previous item.
- public static var previous: FocusHeading {
- FocusHeading(rawValue: 1 << 5)
- }
-}
-
-/// An object that provides information relevant to a specific focus update from
-/// one view to another.
-public class FocusUpdateContext {
- // MARK - Locating Focus Direction
-
- /// The view that was focused before the focus update.
- public private(set) weak var previouslyFocusedView: View?
-
- /// The view that takes the focus after the focus update.
- public private(set) weak var nextFocusedView: View?
-
- /// The heading in which the focus update is occurring.
- public private(set) var focusHeading: FocusHeading = .none
-
- // MARK - Getting Related Focus Items
-
- /// The item that was focused before the update.
- public private(set) weak var previouslyFocusedItem: FocusItem?
-
- /// The item to be focused after the update.
- public private(set) weak var nextFocusedItem: FocusItem?
-
- // MARK - Responding to Focus-Related Keys and Notifications
-
- /// The focus for the UI has been updated.
- public static var didUpdateNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIFocusUpdateContextDidUpdateNotification")
- }
-
- /// The focus failed to move to another item.
- public static var movementDidFailNotification: NSNotification.Name {
- NSNotification.Name(rawValue: "UIFocusUpdateContextMovementDidFailNotification")
- }
-
- /// Updates the animation coordinator.
- public static var animationCoordinatorUserInfoKey: String {
- "UIFocusUpdateContextAnimationCoordinatorUserInfoKey"
- }
-
- /// Updates the context key.
- public static var focusUpdateContextUserInfoKey: String {
- "UIFocusUpdateContextFocusUpdateContextUserInfoKey"
- }
-}
diff --git a/Sources/SwiftWin32/Images and PDF/Image.swift b/Sources/SwiftWin32/Images and PDF/Image.swift
deleted file mode 100644
index d5945651..00000000
--- a/Sources/SwiftWin32/Images and PDF/Image.swift
+++ /dev/null
@@ -1,259 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import WinSDK
-import SwiftCOM
-
-#if swift(>=5.7)
-import CoreGraphics
-#endif
-
-private let WICImagingFactory: SwiftCOM.IWICImagingFactory? =
- try? IWICImagingFactory.CreateInstance(class: CLSID_WICImagingFactory)
-
-extension Image {
- /// A configuration object that contains the traits that the system uses when
- /// selecting the current image variant.
- public class Configuration {
- // MARK - Modifying a Configuration Object
-
- /// Returns a configuration object that applies the specified configuration
- /// values on top of the current object's values.
- public func applying(_ otherConfiguration: Image.Configuration?) -> Self {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Returns a new configuration object that merges the current traits with
- /// the traits from the specified trait collection.
- public func withTraitCollection(_ traitCollection: TraitCollection?) -> Self {
- fatalError("\(#function) not yet implemented")
- }
-
- // MARK - Getting the Configuration Traits
-
- /// The traits associated with the image configuration.
- public private(set) var traitCollection: TraitCollection?
- }
-}
-
-extension Image {
- /// Constants that indicate which weight variant of a symbol image to use.
- public enum SymbolWeight: Int {
- // MARK - Symbol Image Weights
-
- /// An unspecified symbol image weight.
- case unspecified
-
- /// An ultralight weight.
- case ultraLight
-
- /// A thin weight
- case thin
-
- /// A light weight.
- case light
-
- /// A regular weight.
- case regular
-
- /// A medium weight.
- case medium
-
- /// A semibold weight.
- case semibold
-
- /// A bold weight.
- case bold
-
- /// A heavy weight.
- case heavy
-
- /// An ultra-heavy weight.
- case black
- }
-}
-
-extension Image.SymbolWeight {
- // MARK - Getting the Font Weight
-
- /// The font weight for the specified symbol weight.
- public func fontWeight() -> Font.Weight {
- fatalError("\(#function) not yet implemented")
- }
-}
-
-extension Image {
- public enum SymbolScale: Int {
- // MARK - Symbol Image Scales
-
- /// The default scale variant that matches the system usage.
- case `default`
-
- /// An unspecified scale.
- case unspecified
-
- /// The small variant of the symbol image.
- case small
-
- /// The medium variant of the symbol image.
- case medium
-
- /// The large variant of the symbol image.
- case large
- }
-}
-
-extension Image {
- /// An object that contains the specific font, size, style, and weight
- /// attributes to apply to a symbol image.
- public class SymbolConfiguration: Image.Configuration {
- // MARK - Creating a Symbol Configuration Object
-
- /// Creates a configuration object with the specified point-size information.
- public convenience init(pointSize: Double) {
- self.init(pointSize: pointSize, weight: .regular)
- }
-
- /// Creates a configuration object with the specified point-size and weight
- /// information.
- public convenience init(pointSize: Double, weight: Image.SymbolWeight) {
- self.init(pointSize: pointSize, weight: .regular, scale: .default)
- }
-
- /// Creates a configuration object with the specified point-size, weight,
- /// and scale information.
- public convenience init(pointSize: Double, weight: Image.SymbolWeight,
- scale: Image.SymbolScale) {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates a configuration object with the specified scale information.
- public convenience init(scale: Image.SymbolScale) {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates a configuration object with the specified font text style
- /// information.
- public convenience init(textStyle: Font.TextStyle) {
- self.init(textStyle: textStyle, scale: .default)
- }
-
- /// Creates a configuration object with the specified font text style and
- /// scale information.
- public convenience init(textStyle: Font.TextStyle,
- scale: Image.SymbolScale) {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates a configuration object with the specified weight information.
- public convenience init(weight: Image.SymbolWeight) {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Creates a configuration object with the specified font information.
- public convenience init(font: Font) {
- self.init(font: font, scale: .default)
- }
-
- /// Creates a configuration object with the specified font and scale
- /// information.
- public convenience init(font: Font, scale: Image.SymbolScale) {
- fatalError("\(#function) not yet implemented")
- }
-
- // MARK - Getting an Unspecified Configuration
-
- /// A symbol configuration object that contains unspecified values for all
- /// attributes.
- public class var unspecified: Image.SymbolConfiguration {
- fatalError("\(#function) not yet implemented")
- }
-
- // MARK - Removing Configuration Attributes
-
- /// Returns a copy of the current symbol configuration object without
- /// point-size and weight information.
- public func configurationWithoutPointSizeAndWeight() -> Self {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Returns a copy of the current symbol configuration object without scale
- /// information.
- public func configurationWithoutScale() -> Self {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Returns a copy of the current symbol configuration object without font
- /// text style information.
- public func configurationWithoutTextStyle() -> Self {
- fatalError("\(#function) not yet implemented")
- }
-
- /// Returns a copy of the current symbol configuration object without weight
- /// information.
- public func configurationWithoutWeight() -> Self {
- fatalError("\(#function) not yet implemented")
- }
-
- // MARK - Comparing Symbol Image Configurations
-
- /// Returns a boolean value that indicates whether the configuration objects
- /// are equivalent.
- public func isEqual(to otherConfiguration: Image.SymbolConfiguration?)
- -> Bool {
- fatalError("\(#function) not yet implemented")
- }
- }
-}
-
-/// An object that manages image data in your app.
-public class Image {
- private var WICBitmapDecoder: SwiftCOM.IWICBitmapDecoder?
- private var WICBitmapFrame: SwiftCOM.IWICBitmapFrameDecode?
- private var WICFormatConverter: SwiftCOM.IWICFormatConverter?
-
- internal var bitmap: SwiftCOM.IWICBitmapSource? { WICFormatConverter }
-
- // MARK - Creating and Initializing Image Objects
-
- /// Initializes and returns the image object with the contents of the
- /// specified file.
- public init?(contentsOfFile path: String) {
- guard let WICImagingFactory = WICImagingFactory else { return nil }
-
- do {
- self.WICBitmapDecoder =
- try WICImagingFactory.CreateDecoderFromFilename(path, nil, GENERIC_READ,
- WICDecodeMetadataCacheOnDemand)
-
- // TODO(compnerd) figure out how to handle multi-frame images
- let frames = try self.WICBitmapDecoder?.GetFrameCount()
-
- self.WICBitmapFrame = try self.WICBitmapDecoder?.GetFrame(frames! - 1)
-
- self.WICFormatConverter = try WICImagingFactory.CreateFormatConverter()
- try self.WICFormatConverter?.Initialize(WICBitmapFrame!,
- GUID_WICPixelFormat32bppBGRA,
- WICBitmapDitherTypeNone, nil, 0.0,
- WICBitmapPaletteTypeCustom)
- } catch {
- log.error("\(#function): \(error)")
- return nil
- }
- }
-
- // MARK - Getting the Image Size and Scale
-
- /// The scale factor of the image.
- public var scale: Float {
- 1.0
- }
-
- /// The logical dimensions, in points, for the image.
- public var size: Size {
- guard let ImageSize: (UINT, UINT) = try? self.WICBitmapFrame?.GetSize() else {
- return .zero
- }
- return Size(width: Double(ImageSize.0), height: Double(ImageSize.1))
- }
-}
diff --git a/Sources/SwiftWin32/Keyboards and Input/TextInputTraits.swift b/Sources/SwiftWin32/Keyboards and Input/TextInputTraits.swift
deleted file mode 100644
index 98eb3e5e..00000000
--- a/Sources/SwiftWin32/Keyboards and Input/TextInputTraits.swift
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-public protocol TextInputTraits {
- /// Managing the Keyboard Behaviour
- var isSecureTextEntry: Bool { get set }
-}
-
-extension TextInputTraits {
- public var isSecureTextEntry: Bool {
- get { return false }
- set { }
- }
-}
diff --git a/Sources/SwiftWin32/Menus and Shortcuts/Action.swift b/Sources/SwiftWin32/Menus and Shortcuts/Action.swift
deleted file mode 100644
index d61515d0..00000000
--- a/Sources/SwiftWin32/Menus and Shortcuts/Action.swift
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-extension Action {
- /// A type that represents an action identifier.
- public struct Identifier: Equatable, Hashable, RawRepresentable {
- public typealias RawValue = String
-
- public let rawValue: RawValue
-
- public init(rawValue: RawValue) {
- self.rawValue = rawValue
- }
- }
-}
-
-extension Action.Identifier {
- public init(_ rawValue: String) {
- self.rawValue = rawValue
- }
-}
-
-/// A menu element that performs its action in a closure.
-open class Action: MenuElement {
- // MARK - Creating an Action
-
- /// Creates an action.
- public /*convenience*/ init(title: String = "", image: Image? = nil,
- identifier: Action.Identifier? = nil,
- discoverabilityTitle: String? = nil,
- attributes: MenuElement.Attributes = [],
- state: MenuElement.State = .off,
- handler: @escaping ActionHandler) {
- self.identifier = identifier ?? Action.Identifier("")
- self.discoverabilityTitle = discoverabilityTitle
- self.attributes = attributes
- self.state = state
- self.handler = handler
-
- super.init(title: title, image: image)
- }
-
- /// A type that defines the closure for an action handler.
- public typealias ActionHandler = (Action) -> Void
-
- // MARK - Getting Information About the Action
-
- /// The action's title.
- open override var title: String {
- get { super.title }
- set { super.title = newValue }
- }
-
- /// The action's image.
- open override var image: Image? {
- get { super.image }
- set { super.image = newValue }
- }
-
- /// The unique identifier for the action.
- open private(set) var identifier: Action.Identifier
-
- /// An elaborated title that explains the purpose of the action.
- open var discoverabilityTitle: String?
-
- /// The attributes indicating the style of the action.
- open var attributes: MenuElement.Attributes
-
- /// The state of the action.
- open var state: MenuElement.State
-
- /// The object responsible for the action handler.
- open internal(set) var sender: Any?
-
- internal private(set) var handler: ActionHandler
-}
diff --git a/Sources/SwiftWin32/Menus and Shortcuts/Command.swift b/Sources/SwiftWin32/Menus and Shortcuts/Command.swift
deleted file mode 100644
index c10d851d..00000000
--- a/Sources/SwiftWin32/Menus and Shortcuts/Command.swift
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// Constants that indicate which modifier keys are pressed.
-public struct KeyModifierFlags: OptionSet {
- public typealias RawValue = Int
-
- public let rawValue: RawValue
-
- public init(rawValue: RawValue) {
- self.rawValue = rawValue
- }
-}
-
-extension KeyModifierFlags {
- /// A modifier flag that indicates the user pressed the Caps Lock key.
- public static var alphaShift: KeyModifierFlags {
- KeyModifierFlags(rawValue: 1 << 16)
- }
-
- /// A modifier flag that indicates the user pressed the Shift key.
- public static var shift: KeyModifierFlags {
- KeyModifierFlags(rawValue: 1 << 17)
- }
-
- /// A modifier flag that indicates the user pressed the Control key.
- public static var control: KeyModifierFlags {
- KeyModifierFlags(rawValue: 1 << 18)
- }
-
- /// A modifier flag that indicates the user pressed the Option key.
- public static var alternate: KeyModifierFlags {
- KeyModifierFlags(rawValue: 1 << 19)
- }
-
- /// A modifier flag that indicates the user pressed the Command key.
- public static var command: KeyModifierFlags {
- KeyModifierFlags(rawValue: 1 << 20)
- }
-
- /// A modifier flag that indicates the user pressed a key located on the
- /// numeric keypad.
- public static var numericPad: KeyModifierFlags {
- KeyModifierFlags(rawValue: 1 << 21)
- }
-}
-
-/// An object representing an alternative action for a command.
-public class CommandAlternate {
- // MARK - Creating a Command Alternative
-
- /// Creates a command alternative with the specified title, action, and
- /// modifier flags.
- public /*convenience*/ init(title: String,
- action: @escaping (_: AnyObject?) -> Void,
- modifierFlags: KeyModifierFlags) {
- self.title = title
- self.action = action
- self.modifierFlags = modifierFlags
- }
-
- /// The command alternative's title.
- public private(set) var title: String
-
- /// The command alternative's action-method selector.
- public private(set) var action: (_: AnyObject?) -> Void
-
- /// The bit mask of modifier keys that the user must press to invoke the
- /// action for the alternative command.
- public private(set) var modifierFlags: KeyModifierFlags
-}
-
-/// A menu element that performs its action in a selector.
-public class Command: MenuElement {
- // MARK - Creating a Command
-
- /// Creates a command.
- public /*convenience*/ init(title: String = "", image: Image? = nil,
- action: @escaping (_: AnyObject?) -> Void,
- propertyList: Any? = nil,
- alternates: [CommandAlternate] = [],
- discoverabilityTitle: String? = nil,
- attributes: MenuElement.Attributes = [],
- state: MenuElement.State = .off) {
- self.action = action
- self.discoverabilityTitle = discoverabilityTitle
- self.attributes = attributes
- self.state = state
-
- self.alternates = alternates
-
- super.init(title: title, image: image)
- }
-
- // MARK - Getting Information About the Command
-
- /// The command's title.
- public override var title: String {
- get { super.title }
- set { super.title = newValue }
- }
-
- /// The command's image.
- public override var image: Image? {
- get { super.image }
- set { super.image = newValue }
- }
-
- /// The selector identifying the action method called after the user selects
- /// the command.
- public var action: (_: AnyObject?) -> Void
-
- /// An elaborated title that explains the purpose of the command.
- public var discoverabilityTitle: String?
-
- /// The attributes indicating the style of the command.
- public var attributes: MenuElement.Attributes
-
- /// The state of the command.
- public var state: MenuElement.State
-
- // MARK - Getting Command Alternatives
-
- /// An array of alternative actions to take for the command.
- public private(set) var alternates: [CommandAlternate]
-}
diff --git a/Sources/SwiftWin32/Menus and Shortcuts/ContextMenuConfiguration.swift b/Sources/SwiftWin32/Menus and Shortcuts/ContextMenuConfiguration.swift
deleted file mode 100644
index 5c8f3324..00000000
--- a/Sources/SwiftWin32/Menus and Shortcuts/ContextMenuConfiguration.swift
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import class Foundation.NSUUID
-import protocol Foundation.NSCopying
-
-/// Returns the configuration data to use when previewing the content.
-public class ContextMenuConfiguration {
- internal var previewProvider: ContextMenuContentPreviewProvider
-
- internal var actionProvider: ContextMenuActionProvider?
-
- // MARK - Creating the Menu Configuration Object
-
- /// Returns the custom view controller to use when previewing your content.
- public typealias ContextMenuContentPreviewProvider = () -> ViewController?
-
- /// Returns an action-based contextual menu, optionally incorporating the
- /// system-suggested actions.
- public typealias ContextMenuActionProvider = ([MenuElement]) -> Menu?
-
- /// Creates a menu configuration object with the specified action and preview
- /// providers.
- public convenience init(identifier: NSCopying?,
- previewProvider: ContextMenuContentPreviewProvider?,
- actionProvider: ContextMenuActionProvider? = nil) {
- // TODO(compnerd) fill out the default preview provider
- self.init(identifier: identifier ?? NSUUID(),
- previewProvider: previewProvider ?? { return nil },
- actionProvider: actionProvider)
- }
-
- private init(identifier: NSCopying,
- previewProvider: @escaping ContextMenuContentPreviewProvider,
- actionProvider: ContextMenuActionProvider?) {
- self.identifier = identifier
- self.previewProvider = previewProvider
- self.actionProvider = actionProvider
- }
-
- // MARK - Getting the Configuration Identifier
-
- /// The unique identifier for this configuration object.
- public let identifier: NSCopying
-}
diff --git a/Sources/SwiftWin32/Menus and Shortcuts/ContextMenuInteraction.swift b/Sources/SwiftWin32/Menus and Shortcuts/ContextMenuInteraction.swift
deleted file mode 100644
index 3c5c8aae..00000000
--- a/Sources/SwiftWin32/Menus and Shortcuts/ContextMenuInteraction.swift
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-#if swift(>=5.7)
-import CoreGraphics
-#endif
-
-extension ContextMenuInteraction {
- /// Constants that describe the appearance of the menu.
- public enum Appearance: Int {
- /// No menu appearance.
- case unknown
-
- /// A modal menu with an optional preview.
- case rich
-
- /// A nonmodal, compact menu with no preview.
- case compact
- }
-}
-
-/// An interaction object that you use to display relevant actions for your
-/// content.
-public class ContextMenuInteraction: Interaction {
- // MARK - Creating a Context Menu Interaction Object
-
- /// Creates a context menu interaction object with the specified delegate
- /// object.
- public init(delegate: ContextMenuInteractionDelegate) {
- self.delegate = delegate
- }
-
- // MARK - Previewing and Managing the Content
-
- /// The object that provides the preview and contextual menu for your content
- /// and responds to interaction-related events.
- public private(set) weak var delegate: ContextMenuInteractionDelegate?
-
- public private(set) weak var view: View?
-
- public func willMove(to view: View?) {
- }
-
- public func didMove(to view: View?) {
- self.view = view
- }
-
- // MARK - Getting the Interaction's Location
-
- /// Returns the location of the user interaction in the specified view's
- /// coordinate system.
- public func location(in view: View?) -> Point {
- fatalError("\(#function) not yet implemented")
- }
-
- // MARK - Getting the Menu Appearance
-
- /// The appearance of the context menu.
- public var appearance: ContextMenuInteraction.Appearance = .compact
-
- // MARK - Managing Menu Interactions
-
- /// Dismisses the context menu.
- public func dismissMenu() {
- }
-
- /// Updates the currently visible menu.
- public func updateVisibleMenu(_ block: (Menu) -> Menu) {
- }
-}
diff --git a/Sources/SwiftWin32/Menus and Shortcuts/ContextMenuInteractionAnimating.swift b/Sources/SwiftWin32/Menus and Shortcuts/ContextMenuInteractionAnimating.swift
deleted file mode 100644
index 3c9eec48..00000000
--- a/Sources/SwiftWin32/Menus and Shortcuts/ContextMenuInteractionAnimating.swift
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// Methods adopted by system-supplied animator objects when interacting with
-/// context menus.
-public protocol ContextMenuInteractionAnimating {
- /// Adding Custom Animations
-
- /// Adds the specified animation block to the animator.
- func addAnimations(_ animations: @escaping () -> Void)
-
- /// Adds the specified completion block to the animator.
- func addCompletion(_ completion: @escaping () -> Void)
-
- /// Previewing the Content
-
- /// The current preview controller.
- var previewViewController: ViewController? { get }
-}
diff --git a/Sources/SwiftWin32/Menus and Shortcuts/ContextMenuInteractionCommitAnimating.swift b/Sources/SwiftWin32/Menus and Shortcuts/ContextMenuInteractionCommitAnimating.swift
deleted file mode 100644
index b3bdebf5..00000000
--- a/Sources/SwiftWin32/Menus and Shortcuts/ContextMenuInteractionCommitAnimating.swift
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// Constants that control the interaction commit style.
-public enum ContextMenuInteractionCommitStyle: Int {
-/// An interaction with no animations.
-case dismiss
-/// An interaction that uses animations.
-case pop
-}
-
-/// Methods adopted by system-supplied animator objects when committing
-/// preview-related animations.
-public protocol ContextMenuInteractionCommitAnimating: ContextMenuInteractionAnimating {
- /// Specifying the Commit Style
- var preferredCommitStyle: ContextMenuInteractionCommitStyle { get set }
-}
diff --git a/Sources/SwiftWin32/Menus and Shortcuts/ContextMenuInteractionDelegate.swift b/Sources/SwiftWin32/Menus and Shortcuts/ContextMenuInteractionDelegate.swift
deleted file mode 100644
index b156d8fc..00000000
--- a/Sources/SwiftWin32/Menus and Shortcuts/ContextMenuInteractionDelegate.swift
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-#if swift(>=5.7)
-import CoreGraphics
-#endif
-
-/// The methods for providing the set of actions to perform on your content,
-/// and for customizing the preview of that content.
-public protocol ContextMenuInteractionDelegate: AnyObject {
- // MARK - Providing the Preview Configuration Data
-
- /// Returns the configuration data to use when previewing the content.
- func contextMenuInteraction(_ interaction: ContextMenuInteraction,
- configurationForMenuAtLocation location: Point)
- -> ContextMenuConfiguration?
-
- // MARK - Customizing the Preview Animations
-
- /// Returns the source view to use when animating the appearance of the
- /// preview interface.
- func contextMenuInteraction(_ interaction: ContextMenuInteraction,
- previewForHighlightingMenuWithConfiguration configuration: ContextMenuConfiguration)
- -> TargetedPreview?
-
- /// Returns the destination view to use when animating the appearance of the
- /// preview interface.
- func contextMenuInteraction(_ interaction: ContextMenuInteraction,
- previewForDismissingMenuWithConfiguration configuration: ContextMenuConfiguration)
- -> TargetedPreview?
-
- // MARK - Responding to the Menu's Appearance
-
- /// Informs the delegate when a preview action begins.
- func contextMenuInteraction(_ interaction: ContextMenuInteraction,
- willPerformPreviewActionForMenuWith configuration: ContextMenuConfiguration,
- animator: ContextMenuInteractionCommitAnimating)
-
- // MARK - Handling Animations
-
- /// Informs the delegate when a menu display begins.
- func contextMenuInteraction(_ interaction: ContextMenuInteraction,
- willDisplayMenuFor configuration: ContextMenuConfiguration,
- animator: ContextMenuInteractionAnimating?)
-
- /// Informs the delegate when a menu display ends.
- func contextMenuInteraction(_ interaction: ContextMenuInteraction,
- willEndFor configuration: ContextMenuConfiguration,
- animator: ContextMenuInteractionAnimating?)
-}
-
-extension ContextMenuInteractionDelegate {
- public func contextMenuInteraction(_ interaction: ContextMenuInteraction,
- previewForHighlightingMenuWithConfiguration configuration: ContextMenuConfiguration)
- -> TargetedPreview? {
- // TODO(compnerd) what should the default be?
- return nil
- }
-
- public func contextMenuInteraction(_ interaction: ContextMenuInteraction,
- previewForDismissingMenuWithConfiguration configuration: ContextMenuConfiguration)
- -> TargetedPreview? {
- // TODO(compnerd) what should the default be?
- return nil
- }
-}
-
-extension ContextMenuInteractionDelegate {
- public func contextMenuInteraction(_ interaction: ContextMenuInteraction,
- willPerformPreviewActionForMenuWith configuration: ContextMenuConfiguration,
- animator: ContextMenuInteractionCommitAnimating) {
- }
-}
-
-extension ContextMenuInteractionDelegate {
- public func contextMenuInteraction(_ interaction: ContextMenuInteraction,
- willDisplayMenuFor configuration: ContextMenuConfiguration,
- animator: ContextMenuInteractionAnimating?) {
- }
-
- public func contextMenuInteraction(_ interaction: ContextMenuInteraction,
- willEndFor configuration: ContextMenuConfiguration,
- animator: ContextMenuInteractionAnimating?) {
- }
-}
diff --git a/Sources/SwiftWin32/Menus and Shortcuts/Menu.swift b/Sources/SwiftWin32/Menus and Shortcuts/Menu.swift
deleted file mode 100644
index 4c23d3d5..00000000
--- a/Sources/SwiftWin32/Menus and Shortcuts/Menu.swift
+++ /dev/null
@@ -1,333 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import class Foundation.NSUUID
-
-extension Menu {
- /// Constants for identifying an application's standard menus.
- public struct Identifier: Equatable, Hashable, RawRepresentable {
- public typealias RawValue = String
-
- public let rawValue: RawValue
-
- public init(rawValue: String) {
- self.rawValue = rawValue
- }
- }
-}
-
-extension Menu.Identifier {
- // MARK - Root Menu
-
- /// The root menu.
- public static var root: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.root")
- }
-
- // MARK - Top-Level Menus
-
- /// The standard application menu.
- public static var application: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.application")
- }
-
- /// The standard File menu.
- public static var file: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.file")
- }
-
- /// The standard Edit menu.
- public static var edit: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.edit")
- }
-
- /// The standard View menu.
- public static var view: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.view")
- }
-
- /// The standard Window menu.
- public static var window: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.window")
- }
-
- /// The standard Help menu.
- public static var help: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.help")
- }
-
- // MARK - Application Menu Commands
-
- /// The About menu.
- public static var about: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.about")
- }
-
- /// The Preferences menu.
- public static var preferences: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.preferences")
- }
-
- /// The Services menu.
- public static var services: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.services")
- }
-
- /// The Hide menu.
- public static var hide: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.hide")
- }
-
- /// The Quit menu.
- public static var quit: Menu.Identifier{
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.quit")
- }
-
- // MARK - File Menus
-
- /// The New Scene menu.
- public static var newScene: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.new-scene")
- }
-
- /// The Close menu.
- public static var close: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.close")
- }
-
- /// The Print menu.
- public static var print: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.print")
- }
-
- // MARK - Edit Menus
-
- /// The Undo/Redo menu.
- public static var undoRedo: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.undo-redo")
- }
-
- /// The standard Edit menu.
- public static var standardEdit: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.standard-edit")
- }
-
- /// The Find menu.
- public static var find: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.find")
- }
-
- /// The Replace menu.
- public static var replace: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.replace")
- }
-
- /// The Share menu.
- public static var share: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.share")
- }
-
- /// The Text Style menu.
- public static var textStyle: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.text-style")
- }
-
- /// The Spelling menu.
- public static var spelling: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.spelling")
- }
-
- /// The Spelling Panel menu.
- public static var spellingPanel: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.spelling-panel")
- }
-
- /// The Spelling Options menu.
- public static var spellingOptions: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.spelling-options")
- }
-
- /// The Subsitutions menu.
- public static var subsitutions: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.subsitutions")
- }
-
- /// The Subsitutions Panel menu.
- public static var subsitutionsPanel: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.subsitutions-panel")
- }
-
- /// The Transformations menu.
- public static var transformations: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.transformations")
- }
-
- /// The Speech menu.
- public static var speech: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.speech")
- }
-
- /// The Lookup menu.
- public static var lookup: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.lookup")
- }
-
- /// The Learn menu.
- public static var learn: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.learn")
- }
-
- /// The Format menu.
- public static var format: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.format")
- }
-
- /// The Font menu.
- public static var font: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.font")
- }
-
- /// The Text Size menu.
- public static var textSize: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.text-size")
- }
-
- /// The Text Color menu.
- public static var textColor: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.text-color")
- }
-
- /// The Text Style Pasteboard menu.
- public static var textStylePasteboard: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.text-style-pasteboard")
- }
-
- /// The Text menu.
- public static var text: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.text")
- }
-
- /// The Writing Direction menu.
- public static var writingDirection: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.writing-direction")
- }
-
- /// The Alignment menu.
- public static var alignment: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.alignment")
- }
-
- // MARK - View Menus
-
- /// The Toolbar menu group.
- public static var toolbar: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.toolbar")
- }
-
- /// The Fullscreen menu.
- public static var fullscreen: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.fullscreen")
- }
-
- // MARK - Window Menus
-
- /// The Bring All to Front menu.
- public static var bringAllToFront: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.bring-all-to-front")
- }
-
- /// The Minimize and Zoom menu.
- public static var minimizeAndZoom: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.minimize-and-zoom")
- }
-}
-
-extension Menu.Identifier {
- fileprivate static var generated: Menu.Identifier {
- Menu.Identifier(rawValue: "org.compnerd.swift-win32.menu.generated.\(NSUUID())")
- }
-}
-
-
-// MARK - Options for configuring a menu's appearance.
-
-extension Menu {
- /// Options for configuring a menu's appearance.
- public struct Options: OptionSet {
- public typealias RawValue = UInt
-
- public let rawValue: RawValue
-
- public init(rawValue: RawValue) {
- self.rawValue = rawValue
- }
- }
-}
-
-extension Menu.Options: Hashable {
-}
-
-extension Menu.Options {
- /// An option indicating the menu displays inline with its parent menu instead
- /// of displaying as a submenu.
- public static var displayInline: Menu.Options {
- return Menu.Options(rawValue: 1 << 0)
- }
-
- /// An Option indicating the menu's appearance represents a destructive
- /// action.
- public static var destructive: Menu.Options {
- return Menu.Options(rawValue: 1 << 1)
- }
-}
-
-/// A container for grouping related menu elements in an application menu or
-/// contextual menu.
-open class Menu: MenuElement {
- // MARK - Creating a Menu Object
-
- /// Creates a new menu with the specified values.
- public /*convenience*/ init(title: String = "", image: Image? = nil,
- identifier: Menu.Identifier? = nil,
- options: Menu.Options = [],
- children: [MenuElement] = []) {
- self.children = children
- self.identifier = identifier ?? .generated
- self.options = options
- super.init(title: title, image: image)
- }
-
- // MARK - Accessing the Child Elements
-
- /// The contents of the menu.
- public internal(set) var children: [MenuElement]
-
- /// Creates a new menu with the same configuration as the current menu, but
- /// with a new set of child elements.
- open func replacingChildren(_ newChildren: [MenuElement]) -> Menu {
- fatalError("\(#function) not yet implemented")
- }
-
- // MARK - Getting the Menu Details
-
- /// The unique identifier for the current menu.
- open private(set) var identifier: Menu.Identifier
-
- /// The configuration options for the current menu.
- open private(set) var options: Menu.Options
-}
-
-extension Menu: Equatable {
- public static func ==(_ lhs: Menu, _ rhs: Menu) -> Bool {
- // FIXME(compnerd) is this the correct check for equality?
- return lhs === rhs
- }
-}
-extension Menu: Hashable {
- public func hash(into hasher: inout Hasher) {
- // FIXME(compnerd) is this the correct hashing?
- hasher.combine(self.children.count)
- hasher.combine(self.identifier)
- hasher.combine(self.options)
- }
-}
diff --git a/Sources/SwiftWin32/Menus and Shortcuts/MenuBuilder.swift b/Sources/SwiftWin32/Menus and Shortcuts/MenuBuilder.swift
deleted file mode 100644
index e8f58187..00000000
--- a/Sources/SwiftWin32/Menus and Shortcuts/MenuBuilder.swift
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// An interface for adding and removing menus from a menu system.
-public protocol MenuBuilder {
- // MARK - Getting Menu Systems and Elements
-
- /// The menu system that the menu builder modifies.
- var system: MenuSystem { get }
-
- /// Gets the menu for the specified menu identifier.
- func menu(for identifier: Menu.Identifier) -> Menu?
-
- /// Gets the action for the specified action identifier.
- func action(for identifier: Action.Identifier) -> Action?
-
- /// Gets the command for the specified selector and property list.
- func command(for action: @escaping (_: AnyObject?) -> Void,
- propertyList: Any?) -> Command?
-
- // MARK - Inserting Child Menus
-
- /// Adds a child menu as the first element of the specified parent menu.
- func insertChild(_ childMenu: Menu,
- atStartOfMenu parentIdentifier: Menu.Identifier)
-
- /// Adds a child menu as the last element of the specified parent menu.
- func insertChild(_ childMenu: Menu,
- atEndOfMenu parentIdentifier: Menu.Identifier)
-
- // MARK - Inserting Sibling Menus
-
- /// Inserts a sibling menu before the specified menu.
- func insertSibling(_ siblingMenu: Menu,
- beforeMenu siblingIdentifier: Menu.Identifier)
-
- /// Inserts a sibling menu after the specified menu.
- func insertSibling(_ siblingMenu: Menu,
- afterMenu siblingIdentifier: Menu.Identifier)
-
- // MARK - Replacing Menus and Child Menu Elements
-
- /// Replaces the specified menu with a new menu.
- func replace(menu replacedIdentifier: Menu.Identifier,
- with replacementMenu: Menu)
-
- /// Replaces the elements in a menu with the elements returned by the
- /// specified handler block.
- func replaceChildren(ofMenu parentIdentifier: Menu.Identifier,
- from childrenBlock: ([MenuElement]) -> [MenuElement])
-
- // MARK - Removing a Menu
-
- /// Removes a menu from the menu system.
- func remove(menu removedIdentifier: Menu.Identifier)
-}
-
-extension MenuBuilder {
- func command(for action: @escaping (_: AnyObject?) -> Void,
- propertyList: Any?) -> Command? {
- return nil
- }
-}
diff --git a/Sources/SwiftWin32/Menus and Shortcuts/MenuElement.swift b/Sources/SwiftWin32/Menus and Shortcuts/MenuElement.swift
deleted file mode 100644
index b1561ad6..00000000
--- a/Sources/SwiftWin32/Menus and Shortcuts/MenuElement.swift
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-extension MenuElement {
- /// Attributes that determine the style of the menu element.
- public struct Attributes: OptionSet {
- public typealias RawValue = Int
-
- public let rawValue: RawValue
-
- public init(rawValue: RawValue) {
- self.rawValue = rawValue
- }
- }
-}
-
-extension MenuElement.Attributes {
- /// An attribute indicating the destructive style.
- public static var destructive: MenuElement.Attributes {
- MenuElement.Attributes(rawValue: 1 << 1)
- }
-
- /// An attribute indicating the disabled style.
- public static var disabled: MenuElement.Attributes {
- MenuElement.Attributes(rawValue: 1 << 0)
- }
-
- /// An attribute indicating the hidden style.
- public static var hidden: MenuElement.Attributes {
- MenuElement.Attributes(rawValue: 1 << 2)
- }
-}
-
-extension MenuElement {
- /// Constants that indicate the state of an action-based or command-based
- /// menu element.
- public enum State: Int {
- /// A constant indicating the menu element is in the "off" state.
- case off
-
- /// A constant indicating the menu element is in the "on" state.
- case on
-
- /// A constant indicating the menu element is in the "mixed" state.
- case mixed
- }
-}
-
-/// An object representing a menu, action, or command.
-open class MenuElement {
- // MARK - Getting the Element Attributes
-
- /// The title of the menu element.
- open internal(set) var title: String
-
- /// The image to display alongside the menu element's title.
- open internal(set) var image: Image?
-
- // MARK - Creating a Menu Element
-
- /// Creates and returns a `MenuElement` initialized with the given title and
- /// image.
- public init(title: String, image: Image? = nil) {
- self.title = title
- self.image = image
- }
-}
diff --git a/Sources/SwiftWin32/Menus and Shortcuts/MenuSystem.swift b/Sources/SwiftWin32/Menus and Shortcuts/MenuSystem.swift
deleted file mode 100644
index de26c846..00000000
--- a/Sources/SwiftWin32/Menus and Shortcuts/MenuSystem.swift
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-/// An object representing a main or contextual menu system.
-open class MenuSystem {
- // MARK - Getting a Menu System
-
- /// The main menu system.
- open class var main: MenuSystem {
- fatalError("\(#function) not yet implemented")
- }
-
- /// The context menu system.
- open class var context: MenuSystem {
- fatalError("\(#function) not yet implemented")
- }
-
- // MARK - Rebuilding a Menu System
-
- /// Tells the menu system to rebuild all of its menus.
- open func setNeedsRebuild() {
- }
-
- // MARK - Revalidating a Menu System
-
- /// Tells the menu system to validate all of its menus.
- open func setNeedsRevalidate() {
- }
-}
diff --git a/Sources/SwiftWin32/Menus and Shortcuts/PreviewParameters.swift b/Sources/SwiftWin32/Menus and Shortcuts/PreviewParameters.swift
deleted file mode 100644
index 0b0c7f62..00000000
--- a/Sources/SwiftWin32/Menus and Shortcuts/PreviewParameters.swift
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import class Foundation.NSValue
-
-/// Additional parameters to use when animating a preview interface.
-public class PreviewParameters {
- /// Creating Preview Parameters
-
- /// Creates a default set of preview parameters.
- public init() {
- // TODO(compnerd) initialize the default parameters
- }
-
- /// Creates a preview paramters object with information about the text you
- /// want to preview.
- public init(textLineRects: [NSValue]) {
- // TODO(compnerd) store the rects
- }
-
- /// Configuring the Preview Attributes
-
- /// The background color to display behind the preview.
- public var backgroundColor: Color!
-
- /// The portion of the view to show in the preview.
- public var visiblePath: BezierPath?
-
- public var shadowPath: BezierPath?
-}
diff --git a/Sources/SwiftWin32/Menus and Shortcuts/PreviewTarget.swift b/Sources/SwiftWin32/Menus and Shortcuts/PreviewTarget.swift
deleted file mode 100644
index fcb7240a..00000000
--- a/Sources/SwiftWin32/Menus and Shortcuts/PreviewTarget.swift
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-#if swift(>=5.7)
-import CoreGraphics
-#endif
-
-/// An object that specifies the container view to use for animations.
-public class PreviewTarget {
- /// Creating a Preview Target Object
-
- /// Creates a preview target object using the specified container view and
- /// configuration details.
- public init(container: View, center: Point, transform: AffineTransform) {
- self.container = container
- self.center = center
- self.transform = transform
- }
-
- /// Creates a preview target object using the specified container view and
- /// center point.
- public convenience init(container: View, center: Point) {
- self.init(container: container, center: center, transform: .identity)
- }
-
- /// Getting the Target Attributes
-
- /// The container for the view being animated.
- public let container: View
-
- /// The point in the containing view at which to place the center of the view
- /// being animated.
- public let center: Point
-
- /// An affine transform to apply to the view being animated.
- public let transform: AffineTransform
-}
diff --git a/Sources/SwiftWin32/Menus and Shortcuts/TargetedPreview.swift b/Sources/SwiftWin32/Menus and Shortcuts/TargetedPreview.swift
deleted file mode 100644
index 7e7d891c..00000000
--- a/Sources/SwiftWin32/Menus and Shortcuts/TargetedPreview.swift
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-#if swift(>=5.7)
-import CoreGraphics
-#endif
-
-public class TargetedPreview {
- /// Creting a Targeted Preview Object
-
- /// Creates a targeted preview with the specified view, parameters, and target
- /// container.
- public init(view: View, parameters: PreviewParameters, target: PreviewTarget) {
- self.view = view
- // FIXME(compnerd) is this correct?
- self.size = view.frame.size
- self.target = target
- self.parameters = parameters
- }
-
- /// Creates a targeted preview for a view in the current window and including
- /// the specified parameters.
- public convenience init(view: View, parameters: PreviewParameters) {
- self.init(view: view, parameters: parameters,
- target: PreviewTarget(container: view, center: view.center))
- }
-
- /// Creates a targeted preview for a view in the current window.
- public convenience init(view: View) {
- self.init(view: view, parameters: PreviewParameters())
- }
-
- /// Getting the Preview Attributes
-
- /// The view that is the target of the animation
- public let view: View
-
- /// The view that is the container for the target view.
- public let target: PreviewTarget
-
- /// The size of the view.
- public let size: Size
-
- /// Additional parameters to use when configuring the animations.
- public let parameters: PreviewParameters
-
- /// Changing the Target's Container
-
- /// Returns a targeted preview object with the same view and parameters, but
- /// with a different target container.
- public func retargetedPreview(with newTarget: PreviewTarget)
- -> TargetedPreview {
- return TargetedPreview(view: self.view, parameters: self.parameters,
- target: newTarget)
- }
-}
diff --git a/Sources/SwiftWin32/Platform/BatteryMonitor.swift b/Sources/SwiftWin32/Platform/BatteryMonitor.swift
deleted file mode 100644
index e67c020d..00000000
--- a/Sources/SwiftWin32/Platform/BatteryMonitor.swift
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import WinSDK
-import class Foundation.NotificationCenter
-
-private let SwiftBatteryMonitorProc: SUBCLASSPROC = { (hWnd, uMsg, wParam, lParam, uIdSubclass, dwRefData) in
- let monitor: BatteryMonitor? =
- unsafeBitCast(dwRefData, to: AnyObject.self) as? BatteryMonitor
-
- switch uMsg {
- case UINT(WM_POWERBROADCAST):
- guard wParam == PBT_POWERSETTINGCHANGE else {
- log.info("\(#function): uMsg: \(uMsg), wParam: \(wParam), lParam: \(lParam)")
- break
- }
-
- let pSetting: UnsafeMutablePointer =
- UnsafeMutablePointer(bitPattern: UInt(lParam))!
- let dwDataLength: DWORD = pSetting.pointee.DataLength
-
- switch pSetting.pointee.PowerSetting {
- case GUID_BATTERY_PERCENTAGE_REMAINING:
- assert(dwDataLength == MemoryLayout.size)
- let dwBatteryLevel: DWORD =
- withUnsafePointer(to: &pSetting.pointee.Data) {
- $0.withMemoryRebound(to: DWORD.self, capacity: 1) { $0.pointee }
- }
-
- NotificationCenter.default
- .post(name: Device.batteryLevelDidChangeNotification, object: nil)
- default:
- break
- }
-
- default:
- break
- }
-
- return DefSubclassProc(hWnd, uMsg, wParam, lParam)
-}
-
-internal struct BatteryMonitor {
- private static let `class`: WindowClass =
- WindowClass(hInst: GetModuleHandleW(nil), name: "Swift.BatteryMonitor")
-
- private var hWnd: HWND?
- private var hBatteryStateNotification: HPOWERNOTIFY?
- private var hPowerSourceNotification: HPOWERNOTIFY?
-
- public init() {
- self.hWnd = CreateWindowExW(0, BatteryMonitor.class.name, nil, 0, 0, 0, 0, 0,
- HWND_MESSAGE, nil, GetModuleHandleW(nil), nil)
- guard let hWnd = self.hWnd else {
- log.warning("CreateWindowExW: \(Error(win32: GetLastError()))")
- return
- }
-
- SetWindowSubclass(hWnd, SwiftBatteryMonitorProc, UINT_PTR(0),
- unsafeBitCast(self as AnyObject, to: DWORD_PTR.self))
-
- var setting: GUID = GUID_BATTERY_PERCENTAGE_REMAINING
- self.hBatteryStateNotification =
- RegisterPowerSettingNotification(self.hWnd, &setting,
- DWORD(DEVICE_NOTIFY_WINDOW_HANDLE))
- if self.hBatteryStateNotification == nil {
- log.warning("RegisterPowerSettingNotification: \(Error(win32: GetLastError()))")
- }
- }
-}
diff --git a/Sources/SwiftWin32/Platform/Error.swift b/Sources/SwiftWin32/Platform/Error.swift
deleted file mode 100644
index 8259662c..00000000
--- a/Sources/SwiftWin32/Platform/Error.swift
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import ucrt
-import WinSDK
-
-internal struct Error: Swift.Error {
- private enum ErrorCode {
- case errno(errno_t)
- case win32(DWORD)
- case nt(DWORD)
- case hresult(DWORD)
- }
-
- private let code: ErrorCode
-
- public init(win32 error: DWORD) {
- self.code = .win32(error)
- }
-
- public init(nt error: DWORD) {
- self.code = .nt(error)
- }
-
- public init(hresult hr: DWORD) {
- self.code = .hresult(hr)
- }
-
- public init(errno: errno_t) {
- self.code = .errno(errno)
- }
-}
-
-extension Error: CustomStringConvertible {
- public var description: String {
- let dwFlags: DWORD = DWORD(FORMAT_MESSAGE_ALLOCATE_BUFFER)
- | DWORD(FORMAT_MESSAGE_FROM_SYSTEM)
- | DWORD(FORMAT_MESSAGE_IGNORE_INSERTS)
-
- let short: String
- let dwResult: DWORD
- var buffer: UnsafeMutablePointer?
-
- switch self.code {
- case .errno(let errno):
- short = "errno \(errno)"
-
- // MSDN indicates that the returned string can have a maximum of 94
- // characters, so allocate 95 characters.
-#if swift(>=5.7)
- return withUnsafeTemporaryAllocation(of: wchar_t.self, capacity: 95) {
- let result: errno_t = _wcserror_s($0.baseAddress, $0.count, errno)
- guard result == 0 else { return short }
- return "\(short) - \(String(decodingCString: $0.baseAddress!, as: UTF16.self))"
- }
-#else
- let buffer: UnsafeMutablePointer = .allocate(capacity: 95)
- defer { buffer.deallocate() }
-
- let result: errno_t = _wcserror_s(buffer, 95, errno)
- guard result == 0 else { return short }
- return "\(short) - \(String(decodingCString: buffer, as: UTF16.self))"
-#endif
-
- case .win32(let error):
- short = "Win32 Error \(error)"
-
- dwResult = withUnsafeMutablePointer(to: &buffer) {
- $0.withMemoryRebound(to: WCHAR.self, capacity: 2) {
- FormatMessageW(dwFlags, nil, error,
- MAKELANGID(WORD(LANG_NEUTRAL), WORD(SUBLANG_DEFAULT)),
- $0, 0, nil)
- }
- }
-
-
- case .nt(let status):
- short = "NTSTATUS 0x\(String(status, radix: 16))"
-
- dwResult = withUnsafeMutablePointer(to: &buffer) {
- $0.withMemoryRebound(to: WCHAR.self, capacity: 2) {
- FormatMessageW(dwFlags, nil, status,
- MAKELANGID(WORD(LANG_NEUTRAL), WORD(SUBLANG_DEFAULT)),
- $0, 0, nil)
- }
- }
-
- case .hresult(let hr):
- short = "HRESULT 0x\(String(hr, radix: 16))"
-
- dwResult = withUnsafeMutablePointer(to: &buffer) {
- $0.withMemoryRebound(to: WCHAR.self, capacity: 2) {
- FormatMessageW(dwFlags, nil, hr,
- MAKELANGID(WORD(LANG_NEUTRAL), WORD(SUBLANG_DEFAULT)),
- $0, 0, nil)
- }
- }
- }
-
- guard dwResult > 0, let message = buffer else { return short }
- defer { LocalFree(buffer) }
- return "\(short) - \(String(decodingCString: message, as: UTF16.self))"
- }
-}
diff --git a/Sources/SwiftWin32/Platform/OrientationSensor.swift b/Sources/SwiftWin32/Platform/OrientationSensor.swift
deleted file mode 100644
index 82a3bcb3..00000000
--- a/Sources/SwiftWin32/Platform/OrientationSensor.swift
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright © 2020 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import WinSDK
-import SwiftCOM
-
-internal class OrientationSensorEventListener: SwiftCOM.ISensorEvents {
- public func OnEvent(_ pSensor: SwiftCOM.ISensor, _ eventID: REFGUID,
- _ pEventData: SwiftCOM.IPortableDeviceValues) -> HRESULT {
- switch eventID.pointee {
- case SENSOR_EVENT_PROPERTY_CHANGED:
- break
- default:
- break
- }
- return S_OK
- }
-}
-
-internal class OrientationSensorManager {
- private var SensorManager: SwiftCOM.ISensorManager?
- private var OrientationSensor: SwiftCOM.ISensor?
- private var EventListener: SwiftWin32.OrientationSensorEventListener =
- OrientationSensorEventListener()
-
- public lazy var shared: OrientationSensorManager? = OrientationSensorManager()
-
- private init?() {
- do {
- self.SensorManager =
- try ISensorManager.CreateInstance(class: CLSID_SensorManager)
- } catch where (error as? COMError)?.hr == HRESULT_FROM_WIN32(DWORD(ERROR_ACCESS_DISABLED_BY_POLICY)) {
- // TODO(compnerd) unable to access SensorManager due to Group Policy
- // Settings, surface to the user
- return nil
- } catch {
- log.error("CoCreateInstance(CLSID_SensorManager, IID_ISensorManager): \(error)")
- return nil
- }
-
- guard let sensors =
- try? SensorManager?.GetSensorsByType(SENSOR_TYPE_AGGREGATED_DEVICE_ORIENTATION) else {
- return nil
- }
-
- // FIXME(compnerd) can we select a sensor in a better way?
- self.OrientationSensor = try? sensors.GetAt(0)
- if self.OrientationSensor == nil { return nil }
-
- // FIXME(compnerd) can we continue to an alternative sensor?
- switch try? self.OrientationSensor?.GetState() {
- case .some(SENSOR_STATE_ACCESS_DENIED):
- // Request Sensor Access
- do {
- try self.SensorManager?.RequestPermissions(nil, sensors, false)
- } catch where (error as? COMError)?.hr == HRESULT_FROM_WIN32(DWORD(ERROR_ACCESS_DENIED)) {
- // The user denied access to the sensor
- return nil
- } catch where (error as? COMError)?.hr == HRESULT_FROM_WIN32(DWORD(ERROR_CANCELLED)) {
- // The user cancelled the requested
- return nil
- } catch {
- log.error("ISensorManager::RequestPermissions: \(error)")
- return nil
- }
- case .none, .some(_):
- return nil
- }
-
- try? self.OrientationSensor?.SetEventSink(self.EventListener)
- }
-
- deinit {
- _ = try? self.OrientationSensor?.SetEventSink(nil)
- }
-}
diff --git a/Sources/SwiftWin32/Platform/Win32+Menu.swift b/Sources/SwiftWin32/Platform/Win32+Menu.swift
deleted file mode 100644
index a4cd19b3..00000000
--- a/Sources/SwiftWin32/Platform/Win32+Menu.swift
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright © 2021 Saleem Abdulrasool
-// SPDX-License-Identifier: BSD-3-Clause
-
-import WinSDK
-
-#if swift(>=5.9)
-internal import OrderedCollections
-#else
-@_implementationOnly
-import OrderedCollections
-#endif
-
-internal final class _MenuBuilder: MenuSystem {
- internal private(set) var hMenu: MenuHandle
- internal private(set) weak var view: View?
-
- private var menus: OrderedSet