Skip to content

Commit

Permalink
Allowing for page only focus area
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Filetti committed Feb 22, 2016
1 parent 67602f3 commit 91b70b8
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions PeyeDF/Model/FocusAreas.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Quartz
/// Enum representing something we can focus on, such as a point on a document (to
/// refer to a heading or bookmark) or a rect (to refer to a block of text).
enum FocusAreaType {
case Page
case Rect(NSRect)
case Point(NSPoint)

Expand All @@ -29,8 +30,7 @@ enum FocusAreaType {
} else if let sp = params["point"]?.withoutChars(["(", ")"]), p = NSPoint(string: sp) {
self = .Point(p)
} else {
AppSingleton.log.warning("Could not parse string to rect or point: \(comps.string)")
return nil
self = .Page
}
}
}
Expand Down Expand Up @@ -99,6 +99,18 @@ extension MyPDFBase {
pointRect.origin.y += frame.size.height / 3
goToRect(pointRect, onPage: pdfpage)

case .Page:

// Get beginning of page (x: 0, y: top)
let pageRect = getPageRect(pdfpage)
var p = pageRect.origin
p.y = pageRect.origin.y + pageRect.height

// Get tiny rect for beginning of page
let pointRect = NSRect(origin: p, size: NSSize())

goToRect(pointRect, onPage: pdfpage)

}
}

Expand Down

0 comments on commit 91b70b8

Please sign in to comment.