Commit 09fdc471 by Daniel Dahan

development: added begin and commit methods to Grid for transactional calculations

parent 77eee758
......@@ -171,7 +171,7 @@ open class ControlView: View {
let p = width - l - r - contentEdgeInsets.left - contentEdgeInsets.right
let columns = Int(p / gridFactor)
grid.deferred = true
grid.begin()
grid.views.removeAll()
grid.axis.columns = columns
......@@ -209,8 +209,7 @@ open class ControlView: View {
contentView.grid.columns = columns - lc - rc
}
grid.deferred = false
grid.reload()
grid.commit()
}
}
......
......@@ -197,6 +197,17 @@ public class Grid {
axis = GridAxis(grid: self)
}
/// Begins a deferred block.
public func begin() {
deferred = true
}
/// Completes a deferred block.
public func commit() {
deferred = false
reload()
}
/// Reload the button layout.
public func reload() {
guard !deferred else {
......
......@@ -204,7 +204,7 @@ open class NavigationBar: UINavigationBar {
let p = width - l - r - contentEdgeInsets.left - contentEdgeInsets.right
let columns = Int(p / gridFactor)
item.titleView!.grid.deferred = true
item.titleView!.grid.begin()
item.titleView!.grid.views.removeAll()
item.titleView!.grid.axis.columns = columns
......@@ -244,8 +244,7 @@ open class NavigationBar: UINavigationBar {
item.titleView!.grid.interimSpace = interimSpace
item.titleView!.grid.contentEdgeInsets = contentEdgeInsets
item.titleView!.grid.deferred = false
item.titleView!.grid.reload()
item.titleView!.grid.commit()
// contentView alignment.
if nil != item.title && "" != item.title {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment