Cache source measurements and propagate native viewport inputs
Verify Tessera GUI / verify (push) Failing after 7m29s
Verify Tessera GUI / verify (push) Failing after 7m29s
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
class WidthModel {
|
||||
width: Number
|
||||
function expand(self: WidthModel, event: Event): Unit {
|
||||
self.width = 260
|
||||
}
|
||||
}
|
||||
class Tint {
|
||||
color: String
|
||||
function blue(self: Tint, event: Event): Unit {
|
||||
self.color = "#526AC7"
|
||||
}
|
||||
}
|
||||
class CachedRect: RectBlock {
|
||||
dimensions: WidthModel
|
||||
tint: Tint
|
||||
function measure(self: CachedRect, mount: Mount, constraints: Constraints): MeasureResult {
|
||||
return MeasureResult(self.dimensions.width, 60)
|
||||
}
|
||||
function paint(self: CachedRect, mount: Mount, geometry: Bounds): DisplayList {
|
||||
drawing = RectBlock.paint(self, mount, geometry)
|
||||
drawing.commands.at(0).color = self.tint.color
|
||||
return drawing
|
||||
}
|
||||
}
|
||||
class ViewportBand: RectBlock {
|
||||
function measure(self: ViewportBand, mount: Mount, constraints: Constraints): MeasureResult {
|
||||
return MeasureResult(ui.viewport().width, 24)
|
||||
}
|
||||
}
|
||||
dimensions = WidthModel(200)
|
||||
tint = Tint("#ED6A5A")
|
||||
rect = CachedRect(80, 20, 0, "#ED6A5A", dimensions, tint)
|
||||
band = ViewportBand(80, 24, 0, "#237A45")
|
||||
blue = Button("只改绘制颜色")
|
||||
expand = Button("修改测量依赖")
|
||||
blueConnection = blue.on("click", tint.blue)
|
||||
expandConnection = expand.on("click", dimensions.expand)
|
||||
root = Column(24, 16, TextBlock("改变颜色保留测量缓存;改变宽度重新测量"), band, rect, blue, expand)
|
||||
page = Page()
|
||||
page.render(root)
|
||||
Reference in New Issue
Block a user