Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Rectangle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
6490B39F27BF98840056C220 /* BottomCenterRightEighthCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6490B39E27BF98840056C220 /* BottomCenterRightEighthCalculation.swift */; };
6490B3A127BF98C70056C220 /* BottomRightEighthCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6490B3A027BF98C70056C220 /* BottomRightEighthCalculation.swift */; };
729E0A982AFF76B1006E2F48 /* CenterProminentlyCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 729E0A972AFF76B1006E2F48 /* CenterProminentlyCalculation.swift */; };
74804F0B2E25521C009F1F7D /* CenterTwoThirdsCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74804F0A2E25521C009F1F7D /* CenterTwoThirdsCalculation.swift */; };
7BE578EF2C5BF4EE0083DAE3 /* CycleSize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BE578EE2C5BF4ED0083DAE3 /* CycleSize.swift */; };
866661F2257D248A00A9CD2D /* RepeatedExecutionsInThirdsCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 866661F1257D248A00A9CD2D /* RepeatedExecutionsInThirdsCalculation.swift */; };
944F25CD2CE5A144004B2FD2 /* PrefsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944F25CC2CE5A144004B2FD2 /* PrefsViewController.swift */; };
Expand Down Expand Up @@ -187,6 +188,7 @@
6490B39E27BF98840056C220 /* BottomCenterRightEighthCalculation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomCenterRightEighthCalculation.swift; sourceTree = "<group>"; };
6490B3A027BF98C70056C220 /* BottomRightEighthCalculation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomRightEighthCalculation.swift; sourceTree = "<group>"; };
729E0A972AFF76B1006E2F48 /* CenterProminentlyCalculation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CenterProminentlyCalculation.swift; sourceTree = "<group>"; };
74804F0A2E25521C009F1F7D /* CenterTwoThirdsCalculation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CenterTwoThirdsCalculation.swift; sourceTree = "<group>"; };
7BE578EE2C5BF4ED0083DAE3 /* CycleSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CycleSize.swift; sourceTree = "<group>"; };
866661F1257D248A00A9CD2D /* RepeatedExecutionsInThirdsCalculation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RepeatedExecutionsInThirdsCalculation.swift; sourceTree = "<group>"; };
944F25CC2CE5A144004B2FD2 /* PrefsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrefsViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -400,6 +402,7 @@
982140E922B7DA3100ABFB3F /* WindowCalculation */ = {
isa = PBXGroup;
children = (
74804F0A2E25521C009F1F7D /* CenterTwoThirdsCalculation.swift */,
98A009AA2512491300CFBF0C /* CenterHalfCalculation.swift */,
98A009AC2512498000CFBF0C /* FirstFourthCalculation.swift */,
98FD7C5E2687BC14009E9DAF /* FirstThreeFourthsCalculation.swift */,
Expand Down Expand Up @@ -865,6 +868,7 @@
985B9BF522B93EEC00A2E8F0 /* ApplicationToggle.swift in Sources */,
AA0AC002291C1B9100D125D2 /* AXExtension.swift in Sources */,
98D16A442592AD55005228CB /* MASShortcutMigration.swift in Sources */,
74804F0B2E25521C009F1F7D /* CenterTwoThirdsCalculation.swift in Sources */,
988D066522EB4CB6004EABD7 /* CenterThirdCalculation.swift in Sources */,
D04CE30827817A9200BD47B3 /* MiddleCenterNinthCalculation.swift in Sources */,
98A009BD251253A000CFBF0C /* BottomCenterSixthCalculation.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "centerTwoThirdsTemplate.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
119 changes: 86 additions & 33 deletions Rectangle/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Rectangle/PrefsWindow/PrefsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class PrefsViewController: NSViewController {
@IBOutlet weak var firstThirdShortcutView: MASShortcutView!
@IBOutlet weak var firstTwoThirdsShortcutView: MASShortcutView!
@IBOutlet weak var centerThirdShortcutView: MASShortcutView!
@IBOutlet weak var centerTwoThirdsShortcutView: MASShortcutView!
@IBOutlet weak var lastTwoThirdsShortcutView: MASShortcutView!
@IBOutlet weak var lastThirdShortcutView: MASShortcutView!

Expand Down Expand Up @@ -92,6 +93,7 @@ class PrefsViewController: NSViewController {
.firstThird: firstThirdShortcutView,
.firstTwoThirds: firstTwoThirdsShortcutView,
.centerThird: centerThirdShortcutView,
.centerTwoThirds: centerTwoThirdsShortcutView,
.lastTwoThirds: lastTwoThirdsShortcutView,
.lastThird: lastThirdShortcutView,
.moveLeft: moveLeftShortcutView,
Expand Down
135 changes: 71 additions & 64 deletions Rectangle/WindowAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,72 +36,73 @@ enum WindowAction: Int, Codable {
firstThird = 20,
firstTwoThirds = 21,
centerThird = 22,
lastTwoThirds = 23,
lastThird = 24,
moveLeft = 25,
moveRight = 26,
moveUp = 27,
moveDown = 28,
almostMaximize = 29,
centerHalf = 30,
firstFourth = 31,
secondFourth = 32,
thirdFourth = 33,
lastFourth = 34,
firstThreeFourths = 35,
lastThreeFourths = 36,
topLeftSixth = 37,
topCenterSixth = 38,
topRightSixth = 39,
bottomLeftSixth = 40,
bottomCenterSixth = 41,
bottomRightSixth = 42,
specified = 43,
reverseAll = 44,
topLeftNinth = 45,
topCenterNinth = 46,
topRightNinth = 47,
middleLeftNinth = 48,
middleCenterNinth = 49,
middleRightNinth = 50,
bottomLeftNinth = 51,
bottomCenterNinth = 52,
bottomRightNinth = 53,
topLeftThird = 54,
topRightThird = 55,
bottomLeftThird = 56,
bottomRightThird = 57,
topLeftEighth = 58,
topCenterLeftEighth = 59,
topCenterRightEighth = 60,
topRightEighth = 61,
bottomLeftEighth = 62,
bottomCenterLeftEighth = 63,
bottomCenterRightEighth = 64,
bottomRightEighth = 65,
tileAll = 66,
cascadeAll = 67,
leftTodo = 68,
rightTodo = 69,
cascadeActiveApp = 70,
centerProminently = 71,
doubleHeightUp = 72,
doubleHeightDown = 73,
doubleWidthLeft = 74,
doubleWidthRight = 75,
halveHeightUp = 76,
halveHeightDown = 77,
halveWidthLeft = 78,
halveWidthRight = 79,
largerWidth = 80,
smallerWidth = 81,
largerHeight = 82,
smallerHeight = 83
centerTwoThirds = 23,
lastTwoThirds = 24,
lastThird = 25,
moveLeft = 26,
moveRight = 27,
moveUp = 28,
moveDown = 29,
almostMaximize = 30,
centerHalf = 31,
firstFourth = 32,
secondFourth = 33,
thirdFourth = 34,
lastFourth = 35,
firstThreeFourths = 36,
lastThreeFourths = 37,
topLeftSixth = 38,
topCenterSixth = 39,
topRightSixth = 40,
bottomLeftSixth = 41,
bottomCenterSixth = 42,
bottomRightSixth = 43,
specified = 44,
reverseAll = 45,
topLeftNinth = 46,
topCenterNinth = 47,
topRightNinth = 48,
middleLeftNinth = 49,
middleCenterNinth = 50,
middleRightNinth = 51,
bottomLeftNinth = 52,
bottomCenterNinth = 53,
bottomRightNinth = 54,
topLeftThird = 55,
topRightThird = 56,
bottomLeftThird = 57,
bottomRightThird = 58,
topLeftEighth = 59,
topCenterLeftEighth = 60,
topCenterRightEighth = 61,
topRightEighth = 62,
bottomLeftEighth = 63,
bottomCenterLeftEighth = 64,
bottomCenterRightEighth = 65,
bottomRightEighth = 66,
tileAll = 67,
cascadeAll = 68,
leftTodo = 69,
rightTodo = 70,
cascadeActiveApp = 71,
centerProminently = 72,
doubleHeightUp = 73,
doubleHeightDown = 74,
doubleWidthLeft = 75,
doubleWidthRight = 76,
halveHeightUp = 77,
halveHeightDown = 78,
halveWidthLeft = 79,
halveWidthRight = 80,
largerWidth = 81,
smallerWidth = 82,
largerHeight = 83,
smallerHeight = 84

// Order matters here - it's used in the menu
static let active = [leftHalf, rightHalf, centerHalf, topHalf, bottomHalf,
topLeft, topRight, bottomLeft, bottomRight,
firstThird, centerThird, lastThird, firstTwoThirds, lastTwoThirds,
firstThird, centerThird, lastThird, firstTwoThirds, centerTwoThirds, lastTwoThirds,
maximize, almostMaximize, maximizeHeight, larger, smaller, largerWidth, smallerWidth, largerHeight, smallerHeight,
center, centerProminently, restore,
nextDisplay, previousDisplay,
Expand Down Expand Up @@ -173,6 +174,7 @@ enum WindowAction: Int, Codable {
case .firstThird: return "firstThird"
case .firstTwoThirds: return "firstTwoThirds"
case .centerThird: return "centerThird"
case .centerTwoThirds: return "centerTwoThirds"
case .lastTwoThirds: return "lastTwoThirds"
case .lastThird: return "lastThird"
case .moveLeft: return "moveLeft"
Expand Down Expand Up @@ -299,6 +301,9 @@ enum WindowAction: Int, Codable {
case .centerThird:
key = "7YK-9Z-lzw.title"
value = "Center Third"
case .centerTwoThirds:
key = "oSu-n4-8Yu.title"
value = "Center Two Thirds"
case .lastTwoThirds:
key = "08q-Ce-1QL.title"
value = "Last Two Thirds"
Expand Down Expand Up @@ -463,6 +468,7 @@ enum WindowAction: Int, Codable {
case .firstThird: return Shortcut( ctrl|alt, kVK_ANSI_D )
case .firstTwoThirds: return Shortcut( ctrl|alt, kVK_ANSI_E )
case .centerThird: return Shortcut( ctrl|alt, kVK_ANSI_F )
case .centerTwoThirds: return Shortcut( ctrl|alt, kVK_ANSI_R )
case .lastTwoThirds: return Shortcut( ctrl|alt, kVK_ANSI_T )
case .lastThird: return Shortcut( ctrl|alt, kVK_ANSI_G )
default: return nil
Expand Down Expand Up @@ -490,6 +496,7 @@ enum WindowAction: Int, Codable {
case .firstThird: return NSImage(imageLiteralResourceName: "firstThirdTemplate")
case .firstTwoThirds: return NSImage(imageLiteralResourceName: "firstTwoThirdsTemplate")
case .centerThird: return NSImage(imageLiteralResourceName: "centerThirdTemplate")
case .centerTwoThirds: return NSImage(imageLiteralResourceName: "centerTwoThirdsTemplate")
case .lastTwoThirds: return NSImage(imageLiteralResourceName: "lastTwoThirdsTemplate")
case .lastThird: return NSImage(imageLiteralResourceName: "lastThirdTemplate")
case .moveLeft: return NSImage(imageLiteralResourceName: "moveLeftTemplate")
Expand Down Expand Up @@ -574,7 +581,7 @@ enum WindowAction: Int, Codable {

var gapsApplicable: Dimension {
switch self {
case .leftHalf, .rightHalf, .bottomHalf, .topHalf, .centerHalf, .bottomLeft, .bottomRight, .topLeft, .topRight, .firstThird, .firstTwoThirds, .centerThird, .lastTwoThirds, .lastThird,
case .leftHalf, .rightHalf, .bottomHalf, .topHalf, .centerHalf, .bottomLeft, .bottomRight, .topLeft, .topRight, .firstThird, .firstTwoThirds, .centerThird, .centerTwoThirds, .lastTwoThirds, .lastThird,
.firstFourth, .secondFourth, .thirdFourth, .lastFourth, .firstThreeFourths, .lastThreeFourths, .topLeftSixth, .topCenterSixth, .topRightSixth, .bottomLeftSixth, .bottomCenterSixth, .bottomRightSixth,
.topLeftNinth, .topCenterNinth, .topRightNinth, .middleLeftNinth, .middleCenterNinth, .middleRightNinth, .bottomLeftNinth, .bottomCenterNinth, .bottomRightNinth,
.topLeftThird, .topRightThird, .bottomLeftThird, .bottomRightThird,
Expand Down Expand Up @@ -608,7 +615,7 @@ enum WindowAction: Int, Codable {

var classification: WindowActionCategory? {
switch self {
case .firstThird, .firstTwoThirds, .centerThird, .lastTwoThirds, .lastThird: return .thirds
case .firstThird, .firstTwoThirds, .centerThird, .centerTwoThirds, .lastTwoThirds, .lastThird: return .thirds
default: return nil
}
}
Expand Down
36 changes: 36 additions & 0 deletions Rectangle/WindowCalculation/CenterTwoThirdsCalculation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// CenterTwoThirdsCalculation.swift
// Rectangle
//
// Created by Mikhail Savin on 7/14/25.
// Copyright © 2025 Mikhail Savin. All rights reserved.
//

import Foundation

class CenterTwoThirdsCalculation: WindowCalculation, OrientationAware {

override func calculateRect(_ params: RectCalculationParameters) -> RectResult {
let visibleFrameOfScreen = params.visibleFrameOfScreen
return orientationBasedRect(visibleFrameOfScreen)
}

func landscapeRect(_ visibleFrameOfScreen: CGRect) -> RectResult {
var rect = visibleFrameOfScreen
rect.origin.x = visibleFrameOfScreen.minX + floor(visibleFrameOfScreen.width / 3.0) / 2
rect.origin.y = visibleFrameOfScreen.minY
rect.size.width = visibleFrameOfScreen.width / 3.0 * 2
rect.size.height = visibleFrameOfScreen.height
return RectResult(rect, subAction: .centerVerticalThird)
}

func portraitRect(_ visibleFrameOfScreen: CGRect) -> RectResult {
var rect = visibleFrameOfScreen
rect.origin.x = visibleFrameOfScreen.minX
rect.origin.y = visibleFrameOfScreen.minY + floor(visibleFrameOfScreen.height / 3.0) / 2
rect.size.width = visibleFrameOfScreen.width
rect.size.height = visibleFrameOfScreen.height / 3.0 * 2
return RectResult(rect, subAction: .centerHorizontalThird)
}
}

2 changes: 2 additions & 0 deletions Rectangle/WindowCalculation/WindowCalculation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class WindowCalculationFactory {
static let firstThirdCalculation = FirstThirdCalculation()
static let firstTwoThirdsCalculation = FirstTwoThirdsCalculation()
static let centerThirdCalculation = CenterThirdCalculation()
static let centerTwoThirdsCalculation = CenterTwoThirdsCalculation()
static let lastTwoThirdsCalculation = LastTwoThirdsCalculation()
static let lastThirdCalculation = LastThirdCalculation()
static let moveLeftRightCalculation = MoveLeftRightCalculation()
Expand Down Expand Up @@ -208,6 +209,7 @@ class WindowCalculationFactory {
.firstThird: firstThirdCalculation,
.firstTwoThirds: firstTwoThirdsCalculation,
.centerThird: centerThirdCalculation,
.centerTwoThirds: centerTwoThirdsCalculation,
.lastTwoThirds: lastTwoThirdsCalculation,
.lastThird: lastThirdCalculation,
.moveLeft: moveLeftRightCalculation,
Expand Down
24 changes: 24 additions & 0 deletions Rectangle/mul.lproj/Main.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -33298,6 +33298,30 @@
}
}
},
"oSu-n4-8Yu.title" : {
"comment" : "Class = \"NSTextFieldCell\"; title = \"Center Two Thirds\"; ObjectID = \"oSu-n4-8Yu\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Center Two Thirds"
}
},
"en-GB" : {
"stringUnit" : {
"state" : "translated",
"value" : "Centre Two Thirds"
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Центральные две трети"
}
},
}
},
"Other" : {
"localizations" : {
"ar" : {
Expand Down
Loading