Skip to content

Commit

Permalink
fix: skip resizing window when opening file in full screen mode
Browse files Browse the repository at this point in the history
  • Loading branch information
godly-devotion committed Apr 23, 2024
1 parent 2978cdf commit b35faa4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions Front Row/Support/PlayEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ import SwiftUI
.sink { [weak self] size in
guard let self else { return }
videoSize = size
fitToVideoSize()
fitToVideoSize(skipResize: WindowController.shared.isFullscreen)
}
.store(in: &currentItemSubs)

Expand Down Expand Up @@ -331,7 +331,7 @@ import SwiftUI
item.step(byCount: byCount)
}

func fitToVideoSize() {
func fitToVideoSize(skipResize: Bool = false) {
guard let window = NSApp.windows.first else { return }
guard videoSize != CGSize.zero else {
/// reset aspect ratio setting
Expand All @@ -356,7 +356,9 @@ import SwiftUI
)
newFrame = NSRect(origin: newOrigin, size: newSize)
}
window.setFrame(newFrame, display: true, animate: true)
if !skipResize {
window.setFrame(newFrame, display: true, animate: true)
}
window.aspectRatio = videoSize
}

Expand Down
6 changes: 3 additions & 3 deletions Front Row/Views/SeekSliderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct SeekSliderView: NSViewRepresentable {
let barRect = rect
let path = NSBezierPath(roundedRect: barRect, xRadius: barRadius, yRadius: barRadius)

// draw left
/// draw left
let pathLeftRect: NSRect = NSMakeRect(
barRect.origin.x, barRect.origin.y, progress, barRect.height)
NSBezierPath(rect: pathLeftRect).addClip()
Expand All @@ -63,7 +63,7 @@ struct SeekSliderView: NSViewRepresentable {
path.fill()
NSGraphicsContext.restoreGraphicsState()

// draw right
/// draw right
NSGraphicsContext.saveGraphicsState()
let pathRight = NSMakeRect(
barRect.origin.x + progress, barRect.origin.y, barRect.width - progress,
Expand Down Expand Up @@ -93,7 +93,7 @@ struct SeekSliderView: NSViewRepresentable {
if percentage.isNaN {
percentage = 0.0
}
// The usable width of the bar is reduced by the width of the knob.
/// The usable width of the bar is reduced by the width of the knob.
let effectiveBarWidth = barRect.width - knobWidth
let pos = barRect.origin.x + CGFloat(percentage) * effectiveBarWidth
let rect = super.knobRect(flipped: flipped)
Expand Down

0 comments on commit b35faa4

Please sign in to comment.