mirror of
https://github.com/trudnai/Steve2.git
synced 2025-08-09 07:25:07 +00:00
Better structured DebugView / DisassView
This commit is contained in:
@@ -8,51 +8,10 @@
|
|||||||
|
|
||||||
import Cocoa
|
import Cocoa
|
||||||
|
|
||||||
class DisassView: NSTextView {
|
class DisassView: DisplayView {
|
||||||
|
|
||||||
override var acceptsFirstResponder: Bool {
|
|
||||||
get {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var trackingArea: NSTrackingArea?
|
|
||||||
|
|
||||||
func debugDisplayContraints() {
|
|
||||||
print( "debugDisplayContraints ----------------------------------" )
|
|
||||||
if let view = window?.contentView {
|
|
||||||
for constraint in view.constraints {
|
|
||||||
print( "debugDisplayContraints:", constraint.identifier ?? "{Constaint has no identifier}", constraint.constant )
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Install tracking area if window is set, remove previous one if needed.
|
|
||||||
func installTrackingArea() {
|
|
||||||
guard let window = window else { return }
|
|
||||||
window.acceptsMouseMovedEvents = true
|
|
||||||
if trackingArea != nil { removeTrackingArea(trackingArea!) }
|
|
||||||
let trackingOptions : NSTrackingArea.Options = [.activeAlways, .mouseEnteredAndExited, .mouseMoved]
|
|
||||||
trackingArea = NSTrackingArea(rect: bounds,
|
|
||||||
options: trackingOptions,
|
|
||||||
owner: self, userInfo: nil)
|
|
||||||
self.addTrackingArea(trackingArea!)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Called when layout is modified
|
|
||||||
override func updateTrackingAreas() {
|
|
||||||
super.updateTrackingAreas()
|
|
||||||
installTrackingArea()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override func acceptsFirstMouse(for event: NSEvent?) -> Bool {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override func mouseDown(with event: NSEvent) {
|
override func mouseDown(with event: NSEvent) {
|
||||||
// print(#function + "DisassView")
|
// print(#function + "DisassView")
|
||||||
if let dbgVC = DebuggerViewController.shared {
|
if let dbgVC = DebuggerViewController.shared {
|
||||||
dbgVC.mouseDown(with: event)
|
dbgVC.mouseDown(with: event)
|
||||||
dbgVC.DisassBackground.backgroundColor = dbgVC.selectedBackground
|
dbgVC.DisassBackground.backgroundColor = dbgVC.selectedBackground
|
||||||
@@ -60,30 +19,5 @@ class DisassView: NSTextView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// override func mouseUp(with event: NSEvent) {
|
|
||||||
// // print(#function + "DisassView")
|
|
||||||
// DebuggerViewController.shared?.mouseUp(with: event)
|
|
||||||
// }
|
|
||||||
|
|
||||||
override func rightMouseDown(with event: NSEvent) {
|
|
||||||
// print(#function + "DisassView")
|
|
||||||
DebuggerViewController.shared?.rightMouseDown(with: event)
|
|
||||||
}
|
|
||||||
|
|
||||||
// override func rightMouseUp(with event: NSEvent) {
|
|
||||||
// // print(#function + "DisassView")
|
|
||||||
// DebuggerViewController.shared?.rightMouseUp(with: event)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// override func otherMouseDown(with event: NSEvent) {
|
|
||||||
// // print(#function + "DisassView")
|
|
||||||
// DebuggerViewController.shared?.otherMouseDown(with: event)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override func otherMouseUp(with event: NSEvent) {
|
|
||||||
// // print(#function + "DisassView")
|
|
||||||
// DebuggerViewController.shared?.otherMouseUp(with: event)
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,11 +10,11 @@ import Cocoa
|
|||||||
|
|
||||||
class DisplayView: NSTextView {
|
class DisplayView: NSTextView {
|
||||||
|
|
||||||
// override var acceptsFirstResponder: Bool {
|
override var acceptsFirstResponder: Bool {
|
||||||
// get {
|
get {
|
||||||
// return true
|
return true
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
var trackingArea: NSTrackingArea?
|
var trackingArea: NSTrackingArea?
|
||||||
|
|
||||||
@@ -53,142 +53,30 @@ class DisplayView: NSTextView {
|
|||||||
|
|
||||||
override func mouseDown(with event: NSEvent) {
|
override func mouseDown(with event: NSEvent) {
|
||||||
// print(#function + "DisplayView")
|
// print(#function + "DisplayView")
|
||||||
ViewController.shared?.mouseDown(with: event)
|
if let dbgVC = DebuggerViewController.shared {
|
||||||
|
dbgVC.mouseDown(with: event)
|
||||||
// debugDisplayContraints()
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override func mouseUp(with event: NSEvent) {
|
|
||||||
// print(#function + "DisplayView")
|
|
||||||
ViewController.shared?.mouseUp(with: event)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func rightMouseDown(with event: NSEvent) {
|
override func rightMouseDown(with event: NSEvent) {
|
||||||
// print(#function + "DisplayView")
|
// print(#function + "DisplayView")
|
||||||
ViewController.shared?.rightMouseDown(with: event)
|
DebuggerViewController.shared?.rightMouseDown(with: event)
|
||||||
}
|
|
||||||
|
|
||||||
override func rightMouseUp(with event: NSEvent) {
|
|
||||||
// print(#function + "DisplayView")
|
|
||||||
ViewController.shared?.rightMouseUp(with: event)
|
|
||||||
}
|
|
||||||
|
|
||||||
override func otherMouseDown(with event: NSEvent) {
|
|
||||||
// print(#function + "DisplayView")
|
|
||||||
ViewController.shared?.otherMouseDown(with: event)
|
|
||||||
}
|
|
||||||
|
|
||||||
override func otherMouseUp(with event: NSEvent) {
|
|
||||||
// print(#function + "DisplayView")
|
|
||||||
ViewController.shared?.otherMouseUp(with: event)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// override func rightMouseUp(with event: NSEvent) {
|
||||||
// static let overscan_h = CGFloat(25)
|
// // print(#function + "DisplayView")
|
||||||
// static let textViewBounds = NSSize(width: 280 * 4 + overscan_h, height: 192 * 4)
|
// DebuggerViewController.shared?.rightMouseUp(with: event)
|
||||||
// let textDisplay_frameSize = NSSize(width: 1120 + overscan_h, height: 768)
|
|
||||||
//
|
|
||||||
// var textDisplay_width_diff : CGFloat?
|
|
||||||
// var textDisplay_height_diff : CGFloat?
|
|
||||||
//
|
|
||||||
// var locked = false
|
|
||||||
//
|
|
||||||
// func adjustTextDisplaySize() {
|
|
||||||
// var textFrameSize = frame.size
|
|
||||||
//
|
|
||||||
// if locked
|
|
||||||
// || frame.size.width > 8192
|
|
||||||
// || frame.size.width < 200
|
|
||||||
// || frame.size.height > 8192
|
|
||||||
// || frame.size.height < 200 {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// locked = true
|
|
||||||
//
|
|
||||||
// if textDisplay_width_diff == nil {
|
|
||||||
// textDisplay_width_diff = textFrameSize.width - textDisplay_frameSize.width
|
|
||||||
// textDisplay_height_diff = textFrameSize.height - textDisplay_frameSize.height
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// textFrameSize.width -= textDisplay_width_diff!
|
|
||||||
// textFrameSize.height -= textDisplay_height_diff!
|
|
||||||
//
|
|
||||||
//// print( String(
|
|
||||||
//// format: "DisplayView fw:%.2f fh:%.2f bw:%.2f bh:%.2f to fw:%.2f fh:%.2f bw:%.2f bh:%.2f",
|
|
||||||
//// frame.size.width,
|
|
||||||
//// frame.size.height,
|
|
||||||
//// textFrameSize.width,
|
|
||||||
//// textFrameSize.height,
|
|
||||||
//// bounds.size.width,
|
|
||||||
//// bounds.size.height,
|
|
||||||
//// MonitorView.textViewBounds.width,
|
|
||||||
//// MonitorView.textViewBounds.height
|
|
||||||
//// ))
|
|
||||||
//
|
|
||||||
// // BUGFIX: I am not sure why but if I do not adjust the frame and bounds size
|
|
||||||
// // couple of times, Cocoa miscalculates them
|
|
||||||
//// for _ in 0...15 {
|
|
||||||
//// self.setFrameSize(textFrameSize)
|
|
||||||
// self.setFrameSize(textDisplay_frameSize)
|
|
||||||
// self.setBoundsSize(MonitorView.textViewBounds)
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
// locked = false
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// override func viewDidEndLiveResize() {
|
// override func otherMouseDown(with event: NSEvent) {
|
||||||
// NSLog("DisplayView:viewDidEndLiveResize")
|
// // print(#function + "DisplayView")
|
||||||
// print( String(
|
// DebuggerViewController.shared?.otherMouseDown(with: event)
|
||||||
// format: "DisplayView fw:%.2f fh:%.2f bw:%.2f bh:%.2f",
|
|
||||||
// frame.size.width,
|
|
||||||
// frame.size.height,
|
|
||||||
// bounds.size.width,
|
|
||||||
// bounds.size.height
|
|
||||||
// ))
|
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// @objc func frameDidChange(notification: NSNotification) {
|
// override func otherMouseUp(with event: NSEvent) {
|
||||||
// NSLog("DisplayView:frameDidChange")
|
// // print(#function + "DisplayView")
|
||||||
//// adjustTextDisplaySize()
|
// DebuggerViewController.shared?.otherMouseUp(with: event)
|
||||||
// print( String(
|
|
||||||
// format: "DisplayView fw:%.2f fh:%.2f bw:%.2f bh:%.2f",
|
|
||||||
// frame.size.width,
|
|
||||||
// frame.size.height,
|
|
||||||
// bounds.size.width,
|
|
||||||
// bounds.size.height
|
|
||||||
// ))
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @objc func globalFrameDidChange(notification: NSNotification) {
|
|
||||||
// NSLog("DisplayView:globalFrameDidChange")
|
|
||||||
// print( String(
|
|
||||||
// format: "DisplayView fw:%.2f fh:%.2f bw:%.2f bh:%.2f",
|
|
||||||
// self.frame.size.width,
|
|
||||||
// self.frame.size.height,
|
|
||||||
// self.bounds.size.width,
|
|
||||||
// self.bounds.size.height
|
|
||||||
// ))
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @objc func boundsDidChange(notification: NSNotification) {
|
|
||||||
// NSLog("DisplayView:boundsDidChange")
|
|
||||||
// print( String(
|
|
||||||
// format: "DisplayView fw:%.2f fh:%.2f bw:%.2f bh:%.2f",
|
|
||||||
// self.frame.size.width,
|
|
||||||
// self.frame.size.height,
|
|
||||||
// self.bounds.size.width,
|
|
||||||
// self.bounds.size.height
|
|
||||||
// ))
|
|
||||||
// }
|
|
||||||
|
|
||||||
// required init?(coder: NSCoder) {
|
|
||||||
// super.init(coder: coder)
|
|
||||||
//
|
|
||||||
// postsFrameChangedNotifications = true
|
|
||||||
// NotificationCenter.default.addObserver(self, selector: #selector(frameDidChange), name: NSView.frameDidChangeNotification, object: self)
|
|
||||||
// NotificationCenter.default.addObserver(self, selector: #selector(globalFrameDidChange), name: NSView.globalFrameDidChangeNotification, object: self)
|
|
||||||
// NotificationCenter.default.addObserver(self, selector: #selector(boundsDidChange), name: NSView.boundsDidChangeNotification, object: self)
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user