Skip to content

Commit

Permalink
(partially) fixed the full size image view in fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
DrabWeb committed Feb 3, 2017
1 parent eb532c4 commit eaf8d2f
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions Booru-chan/Booru-chan/BCViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ class BCViewController: NSViewController, NSWindowDelegate {
updateTitle();
}

private func createImageViewScrollViewConstraints(relativeTo : NSView, attribute : NSLayoutAttribute) {
private func createImageViewScrollViewConstraints(relativeTo : NSView, attribute : NSLayoutAttribute, constant : CGFloat = 0) {
if(imageViewScrollViewTopConstraint != nil) {
window.contentView?.superview?.removeConstraint(imageViewScrollViewTopConstraint!);
}

imageViewScrollViewTopConstraint = NSLayoutConstraint(item: gridStyleController.imageViewScrollView, attribute: .top, relatedBy: .equal, toItem: relativeTo, attribute: attribute, multiplier: 1, constant: 0)
imageViewScrollViewTopConstraint = NSLayoutConstraint(item: gridStyleController.imageViewScrollView, attribute: .top, relatedBy: .equal, toItem: relativeTo, attribute: attribute, multiplier: 1, constant: constant);
window.contentView?.superview?.addConstraint(imageViewScrollViewTopConstraint!);
}

Expand All @@ -130,6 +130,20 @@ class BCViewController: NSViewController, NSWindowDelegate {
UserDefaults.standard.synchronize();
}

func windowWillEnterFullScreen(_ notification: Notification) {
if(!titlebarVisible) {
showTitlebar();
}
}

func windowDidEnterFullScreen(_ notification: Notification) {
createImageViewScrollViewConstraints(relativeTo: view, attribute: .top, constant: 37);
}

func windowDidExitFullScreen(_ notification: Notification) {
createImageViewScrollViewConstraints(relativeTo: window.standardWindowButton(.closeButton)!.superview!.superview!, attribute: .bottom);
}

/// Called when the tokens from toolbarSearchField change
func searchTokensChanged() {
// Update the tag display list
Expand Down Expand Up @@ -586,6 +600,8 @@ class BCViewController: NSViewController, NSWindowDelegate {
createImageViewScrollViewConstraints(relativeTo: window.contentView!, attribute: .top);

window.contentView?.needsDisplay = true;

titlebarVisible = false;
}

func showTitlebar() {
Expand All @@ -594,6 +610,8 @@ class BCViewController: NSViewController, NSWindowDelegate {
createImageViewScrollViewConstraints(relativeTo: window.standardWindowButton(.closeButton)!.superview!.superview!, attribute: .bottom);

window.contentView?.needsDisplay = true;

titlebarVisible = true;
}

func selectPostBrowser() {
Expand Down

0 comments on commit eaf8d2f

Please sign in to comment.