ps
This commit is contained in:
1 parent
30476a880d
commit
7c8bbe6473
3 files changed
+50
-20
No files matched your search
@@ -80,16 +80,18 @@ final class RenderGLView: NSOpenGLView {
|
|||||||
|
|
||||||
override func reshape() {
|
override func reshape() {
|
||||||
super.reshape()
|
super.reshape()
|
||||||
otherPrintStderr("RenderGLView reshape bounds \(bounds) backing \(convertToBacking(bounds))")
|
|
||||||
needsDisplay = true
|
needsDisplay = true
|
||||||
renderSet(F.didReshape, true)
|
|
||||||
|
let ps = renderPixelSize(self)
|
||||||
|
renderSet(F.reshapePixelSize, ps)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewDidChangeBackingProperties() {
|
override func viewDidChangeBackingProperties() {
|
||||||
super.viewDidChangeBackingProperties()
|
super.viewDidChangeBackingProperties()
|
||||||
otherPrintStderr("RenderGLView viewDidChangeBackingProperties bounds \(bounds) backing \(convertToBacking(bounds))")
|
|
||||||
needsDisplay = true
|
needsDisplay = true
|
||||||
renderSet(F.didChangeBacking, true)
|
|
||||||
|
let ps = renderPixelSize(self)
|
||||||
|
renderSet(F.backingPixelSize, ps)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func draw(_ dirtyRect: NSRect) {
|
override func draw(_ dirtyRect: NSRect) {
|
||||||
|
|||||||
+12
-2
@@ -7,12 +7,12 @@ output:
|
|||||||
RenderContext:
|
RenderContext:
|
||||||
type: context
|
type: context
|
||||||
fields:
|
fields:
|
||||||
didChangeBacking: Bool
|
backingPixelSize: [Int32]
|
||||||
didLaunch: Bool
|
didLaunch: Bool
|
||||||
didReshape: Bool
|
|
||||||
didSetup: Bool
|
didSetup: Bool
|
||||||
isReadyToRender: Bool
|
isReadyToRender: Bool
|
||||||
pixelSize: [Int32]
|
pixelSize: [Int32]
|
||||||
|
reshapePixelSize: [Int32]
|
||||||
|
|
||||||
RenderComponent:
|
RenderComponent:
|
||||||
type: component
|
type: component
|
||||||
@@ -32,6 +32,16 @@ RenderComponent:
|
|||||||
c.recentField == F.didLaunch
|
c.recentField == F.didLaunch
|
||||||
then:
|
then:
|
||||||
c.pixelSize = [1, 1]
|
c.pixelSize = [1, 1]
|
||||||
|
2. Upon resize:
|
||||||
|
if:
|
||||||
|
c.recentField == F.reshapePixelSize
|
||||||
|
then:
|
||||||
|
c.pixelSize = c.reshapePixelSize
|
||||||
|
3. Upon DPI change:
|
||||||
|
if:
|
||||||
|
c.recentField == F.backingPixelSize
|
||||||
|
then:
|
||||||
|
c.pixelSize = c.backingPixelSize
|
||||||
|
|
||||||
RootComponent:
|
RootComponent:
|
||||||
type: component
|
type: component
|
||||||
|
|||||||
@@ -119,37 +119,34 @@ func registerOneliners<T>(
|
|||||||
|
|
||||||
// Context field names for static type check
|
// Context field names for static type check
|
||||||
public struct F {
|
public struct F {
|
||||||
|
public static let backingPixelSize = "backingPixelSize"
|
||||||
public static let count = "count"
|
public static let count = "count"
|
||||||
public static let countText = "countText"
|
public static let countText = "countText"
|
||||||
public static let didChangeBacking = "didChangeBacking"
|
|
||||||
public static let didClickIncrement = "didClickIncrement"
|
public static let didClickIncrement = "didClickIncrement"
|
||||||
public static let didLaunch = "didLaunch"
|
public static let didLaunch = "didLaunch"
|
||||||
public static let didReshape = "didReshape"
|
|
||||||
public static let didSetup = "didSetup"
|
public static let didSetup = "didSetup"
|
||||||
public static let isReadyToRender = "isReadyToRender"
|
public static let isReadyToRender = "isReadyToRender"
|
||||||
public static let pixelSize = "pixelSize"
|
public static let pixelSize = "pixelSize"
|
||||||
|
public static let reshapePixelSize = "reshapePixelSize"
|
||||||
|
|
||||||
}
|
}
|
||||||
public struct RenderContext: DialectContext {
|
public struct RenderContext: DialectContext {
|
||||||
public var didChangeBacking = Bool()
|
public var backingPixelSize = [Int32]()
|
||||||
public var didLaunch = Bool()
|
public var didLaunch = Bool()
|
||||||
public var didReshape = Bool()
|
|
||||||
public var didSetup = Bool()
|
public var didSetup = Bool()
|
||||||
public var isReadyToRender = Bool()
|
public var isReadyToRender = Bool()
|
||||||
public var pixelSize = [Int32]()
|
public var pixelSize = [Int32]()
|
||||||
|
public var reshapePixelSize = [Int32]()
|
||||||
|
|
||||||
public var recentField = ""
|
public var recentField = ""
|
||||||
|
|
||||||
public func field<T>(_ name: String) -> T {
|
public func field<T>(_ name: String) -> T {
|
||||||
if (name == "didChangeBacking") {
|
if (name == "backingPixelSize") {
|
||||||
return didChangeBacking as! T
|
return backingPixelSize as! T
|
||||||
}
|
}
|
||||||
else if (name == "didLaunch") {
|
else if (name == "didLaunch") {
|
||||||
return didLaunch as! T
|
return didLaunch as! T
|
||||||
}
|
}
|
||||||
else if (name == "didReshape") {
|
|
||||||
return didReshape as! T
|
|
||||||
}
|
|
||||||
else if (name == "didSetup") {
|
else if (name == "didSetup") {
|
||||||
return didSetup as! T
|
return didSetup as! T
|
||||||
}
|
}
|
||||||
@@ -159,6 +156,9 @@ public struct RenderContext: DialectContext {
|
|||||||
else if (name == "pixelSize") {
|
else if (name == "pixelSize") {
|
||||||
return pixelSize as! T
|
return pixelSize as! T
|
||||||
}
|
}
|
||||||
|
else if (name == "reshapePixelSize") {
|
||||||
|
return reshapePixelSize as! T
|
||||||
|
}
|
||||||
|
|
||||||
return "unknown-field-name" as! T
|
return "unknown-field-name" as! T
|
||||||
}
|
}
|
||||||
@@ -167,15 +167,12 @@ public struct RenderContext: DialectContext {
|
|||||||
_ name: String,
|
_ name: String,
|
||||||
_ value: Any
|
_ value: Any
|
||||||
) {
|
) {
|
||||||
if (name == "didChangeBacking") {
|
if (name == "backingPixelSize") {
|
||||||
didChangeBacking = value as! Bool
|
backingPixelSize = value as! [Int32]
|
||||||
}
|
}
|
||||||
else if (name == "didLaunch") {
|
else if (name == "didLaunch") {
|
||||||
didLaunch = value as! Bool
|
didLaunch = value as! Bool
|
||||||
}
|
}
|
||||||
else if (name == "didReshape") {
|
|
||||||
didReshape = value as! Bool
|
|
||||||
}
|
|
||||||
else if (name == "didSetup") {
|
else if (name == "didSetup") {
|
||||||
didSetup = value as! Bool
|
didSetup = value as! Bool
|
||||||
}
|
}
|
||||||
@@ -185,6 +182,9 @@ public struct RenderContext: DialectContext {
|
|||||||
else if (name == "pixelSize") {
|
else if (name == "pixelSize") {
|
||||||
pixelSize = value as! [Int32]
|
pixelSize = value as! [Int32]
|
||||||
}
|
}
|
||||||
|
else if (name == "reshapePixelSize") {
|
||||||
|
reshapePixelSize = value as! [Int32]
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -285,6 +285,24 @@ func renderShouldResetPixelSize(_ c: RenderContext) -> RenderContext {
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 2. Upon resize */
|
||||||
|
if
|
||||||
|
c.recentField == F.reshapePixelSize
|
||||||
|
{
|
||||||
|
c.pixelSize = c.reshapePixelSize
|
||||||
|
c.recentField = F.pixelSize
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 3. Upon DPI change */
|
||||||
|
if
|
||||||
|
c.recentField == F.backingPixelSize
|
||||||
|
{
|
||||||
|
c.pixelSize = c.backingPixelSize
|
||||||
|
c.recentField = F.pixelSize
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
c.recentField = DIALECT_CONTEXT_RECENT_FIELD_NONE
|
c.recentField = DIALECT_CONTEXT_RECENT_FIELD_NONE
|
||||||
return c
|
return c
|
||||||
|
|||||||
Reference in new issue
Block a user