Skip to content

Commit

Permalink
Rearchitected
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyome22 committed Jan 24, 2023
1 parent 44f1d5d commit 3c54882
Show file tree
Hide file tree
Showing 52 changed files with 1,377 additions and 889 deletions.
247 changes: 78 additions & 169 deletions ShiftWindow.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Kyome22/SpiceKey.git",
"state" : {
"revision" : "59954c585f7851b2f1917352d7f56428b62d70b8",
"version" : "4.3.0"
"revision" : "297c37fbdb415bfed9bd8ac0e6a17029d6c304da",
"version" : "4.5.0"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1330"
LastUpgradeVersion = "1420"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -34,7 +34,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = "en"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
11 changes: 0 additions & 11 deletions ShiftWindow/Assets.xcassets/AccentColor.colorset/Contents.json

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
6 changes: 0 additions & 6 deletions ShiftWindow/Assets.xcassets/Preferences/Contents.json

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
25 changes: 25 additions & 0 deletions ShiftWindow/Entity/SettingsTabType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// SettingsTabType.swift
// ShiftWindow
//
// Created by Takuto Nakamura on 2023/01/24.
//
// Copyright 2023 Takuto Nakamura (Kyome22)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

enum SettingsTabType {
case general
case shortcuts
}
89 changes: 89 additions & 0 deletions ShiftWindow/Entity/ShiftPattern.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//
// ShiftPattern.swift
// ShiftWindow
//
// Created by Takuto Nakamura on 2021/07/31.
//
// Copyright 2021 Takuto Nakamura (Kyome22)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import AppKit
import SwiftUI
import SpiceKey

final class ShiftPattern: Codable {
enum CodingKeys: String, CodingKey {
case shiftType
case spiceKeyData
}

let shiftType: ShiftType
var spiceKeyData: SpiceKeyData?

var titleKey: LocalizedStringKey {
return shiftType.titleKey
}
var title: String {
return shiftType.id.localized
}
var imageTitle: String {
return shiftType.imageTitle
}
var image: NSImage {
return shiftType.image
}
var keyString: String? {
return spiceKeyData?.key?.string
}
var modifierMask: NSEvent.ModifierFlags? {
return spiceKeyData?.modifierFlags?.flags
}
var keyCombination: KeyCombination? {
return spiceKeyData?.keyCombination
}
var description: String {
let str = spiceKeyData?.keyCombination?.string ?? "nil"
return "type: \(titleKey), spiceKeyData: \(str)"
}

init(shiftType: ShiftType) {
self.shiftType = shiftType
}

init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
shiftType = try container.decode(ShiftType.self, forKey: .shiftType)
spiceKeyData = try container.decodeIfPresent(SpiceKeyData.self, forKey: .spiceKeyData)
}

func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(shiftType, forKey: .shiftType)
try container.encodeIfPresent(spiceKeyData, forKey: .spiceKeyData)
}

static let `defaults`: [ShiftPattern] = [
ShiftPattern(shiftType: .topHalf),
ShiftPattern(shiftType: .bottomHalf),
ShiftPattern(shiftType: .leftHalf),
ShiftPattern(shiftType: .rightHalf),
ShiftPattern(shiftType: .leftThird),
ShiftPattern(shiftType: .leftTwoThirds),
ShiftPattern(shiftType: .middleThird),
ShiftPattern(shiftType: .rightTwoThirds),
ShiftPattern(shiftType: .rightThird),
ShiftPattern(shiftType: .maximize)
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
// limitations under the License.
//

import Cocoa
import AppKit
import SwiftUI

enum ShiftType: Int, CaseIterable {
enum ShiftType: Int, Codable, CaseIterable {
case topHalf
case bottomHalf
case leftHalf
Expand Down Expand Up @@ -50,7 +50,7 @@ enum ShiftType: Int, CaseIterable {
}

var titleKey: LocalizedStringKey {
return LocalizedStringKey(self.id)
return LocalizedStringKey(id)
}

var imageTitle: String {
Expand All @@ -69,6 +69,6 @@ enum ShiftType: Int, CaseIterable {
}

var image: NSImage {
return NSImage(imageLiteralResourceName: self.imageTitle)
return NSImage(imageLiteralResourceName: imageTitle)
}
}
25 changes: 25 additions & 0 deletions ShiftWindow/Entity/WindowType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// WindowType.swift
// ShiftWindow
//
// Created by Takuto Nakamura on 2023/01/24.
//
// Copyright 2023 Takuto Nakamura (Kyome22)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

enum WindowType {
case preferences
case about
}
51 changes: 39 additions & 12 deletions ShiftWindow/Extensions/AppKit+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
//
// Created by Takuto Nakamura on 2022/06/27.
//
// Copyright 2022 Takuto Nakamura (Kyome22)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import AppKit

Expand All @@ -13,9 +27,33 @@ extension NSStatusItem {
}
}

extension NSMenu {
func addItem(title: String, action: Selector, target: AnyObject) {
self.addItem(NSMenuItem(title: title, action: action, target: target))
}

func addSeparator() {
self.addItem(NSMenuItem.separator())
}
}

extension NSMenuItem {
convenience init(title: String, action: Selector) {
convenience init(title: String, action: Selector, target: AnyObject) {
self.init(title: title, action: action, keyEquivalent: "")
self.target = target
}

func setValues(title: String, action: Selector, target: AnyObject) {
self.title = title
self.action = action
self.target = target
}
}

extension NSScreen {
var displayID: CGDirectDisplayID {
let key = NSDeviceDescriptionKey("NSScreenNumber")
return self.deviceDescription[key] as! CGDirectDisplayID
}
}

Expand All @@ -30,14 +68,3 @@ extension NSControl.StateValue {
return self == .on
}
}

extension NSImage {
static let statusIcon = NSImage(imageLiteralResourceName: "StatusIcon")
}

extension NSScreen {
var displayID: CGDirectDisplayID {
let key = NSDeviceDescriptionKey("NSScreenNumber")
return self.deviceDescription[key] as! CGDirectDisplayID
}
}
14 changes: 14 additions & 0 deletions ShiftWindow/Extensions/CoreGraphics+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
//
// Created by Takuto Nakamura on 2022/06/27.
//
// Copyright 2022 Takuto Nakamura (Kyome22)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import CoreGraphics

Expand Down
Loading

0 comments on commit 3c54882

Please sign in to comment.