recalc
This commit is contained in:
1 parent
0da8bfcfa2
commit
30476a880d
5 files changed
+69
-25
No files matched your search
@@ -121,38 +121,43 @@ func registerOneliners<T>(
|
||||
public struct F {
|
||||
public static let count = "count"
|
||||
public static let countText = "countText"
|
||||
public static let didChangeBacking = "didChangeBacking"
|
||||
public static let didClickIncrement = "didClickIncrement"
|
||||
public static let didLaunch = "didLaunch"
|
||||
public static let didReshape = "didReshape"
|
||||
public static let didSetup = "didSetup"
|
||||
public static let isReadyToRender = "isReadyToRender"
|
||||
public static let pixelHeight = "pixelHeight"
|
||||
public static let pixelWidth = "pixelWidth"
|
||||
public static let pixelSize = "pixelSize"
|
||||
|
||||
}
|
||||
public struct RenderContext: DialectContext {
|
||||
public var didChangeBacking = Bool()
|
||||
public var didLaunch = Bool()
|
||||
public var didReshape = Bool()
|
||||
public var didSetup = Bool()
|
||||
public var isReadyToRender = Bool()
|
||||
public var pixelHeight = Int()
|
||||
public var pixelWidth = Int()
|
||||
public var pixelSize = [Int32]()
|
||||
|
||||
public var recentField = ""
|
||||
|
||||
public func field<T>(_ name: String) -> T {
|
||||
if (name == "didLaunch") {
|
||||
if (name == "didChangeBacking") {
|
||||
return didChangeBacking as! T
|
||||
}
|
||||
else if (name == "didLaunch") {
|
||||
return didLaunch as! T
|
||||
}
|
||||
else if (name == "didReshape") {
|
||||
return didReshape as! T
|
||||
}
|
||||
else if (name == "didSetup") {
|
||||
return didSetup as! T
|
||||
}
|
||||
else if (name == "isReadyToRender") {
|
||||
return isReadyToRender as! T
|
||||
}
|
||||
else if (name == "pixelHeight") {
|
||||
return pixelHeight as! T
|
||||
}
|
||||
else if (name == "pixelWidth") {
|
||||
return pixelWidth as! T
|
||||
else if (name == "pixelSize") {
|
||||
return pixelSize as! T
|
||||
}
|
||||
|
||||
return "unknown-field-name" as! T
|
||||
@@ -162,20 +167,23 @@ public struct RenderContext: DialectContext {
|
||||
_ name: String,
|
||||
_ value: Any
|
||||
) {
|
||||
if (name == "didLaunch") {
|
||||
if (name == "didChangeBacking") {
|
||||
didChangeBacking = value as! Bool
|
||||
}
|
||||
else if (name == "didLaunch") {
|
||||
didLaunch = value as! Bool
|
||||
}
|
||||
else if (name == "didReshape") {
|
||||
didReshape = value as! Bool
|
||||
}
|
||||
else if (name == "didSetup") {
|
||||
didSetup = value as! Bool
|
||||
}
|
||||
else if (name == "isReadyToRender") {
|
||||
isReadyToRender = value as! Bool
|
||||
}
|
||||
else if (name == "pixelHeight") {
|
||||
pixelHeight = value as! Int
|
||||
}
|
||||
else if (name == "pixelWidth") {
|
||||
pixelWidth = value as! Int
|
||||
else if (name == "pixelSize") {
|
||||
pixelSize = value as! [Int32]
|
||||
}
|
||||
|
||||
}
|
||||
@@ -265,6 +273,23 @@ func renderShouldResetDidLaunch(_ c: RenderContext) -> RenderContext {
|
||||
return c
|
||||
}
|
||||
|
||||
func renderShouldResetPixelSize(_ c: RenderContext) -> RenderContext {
|
||||
var c = c
|
||||
|
||||
/* 1. Upon launch */
|
||||
if
|
||||
c.recentField == F.didLaunch
|
||||
{
|
||||
c.pixelSize = [1, 1]
|
||||
c.recentField = F.pixelSize
|
||||
return c
|
||||
}
|
||||
|
||||
|
||||
c.recentField = DIALECT_CONTEXT_RECENT_FIELD_NONE
|
||||
return c
|
||||
}
|
||||
|
||||
func rootShouldResetCount(_ c: RootContext) -> RootContext {
|
||||
var c = c
|
||||
|
||||
@@ -339,6 +364,7 @@ func rootShouldResetDidLaunch(_ c: RootContext) -> RootContext {
|
||||
func renderRegisterShoulds(_ ctrl: DialectController) {
|
||||
[
|
||||
renderShouldResetDidLaunch,
|
||||
renderShouldResetPixelSize,
|
||||
|
||||
].forEach { f in
|
||||
ctrl.registerFunction { c in f(c as! RenderContext) }
|
||||
|
||||
Reference in new issue
Block a user