Commit 6861382d by Daniel Dahan

development: Updated Grid calculations

parent 35c09def
......@@ -215,7 +215,6 @@ public class Grid {
case .horizontal:
let c = child.grid.columns
let co = child.grid.offset.columns
let w = (parent.bounds.width - contentInset.left - contentInset.right - layoutInset.left - layoutInset.right + interimSpace) / CGFloat(gc)
child.x = CGFloat(i + n + co) * w + contentInset.left + layoutInset.left
......@@ -226,39 +225,29 @@ public class Grid {
n += c + co - 1
case .vertical:
let h = (parent.bounds.height - contentInset.top - contentInset.bottom - layoutInset.top - layoutInset.bottom + interimSpace) / CGFloat(gr)
let r = child.grid.rows
let ro = child.grid.offset.rows
let vw = parent.bounds.width - contentInset.left - contentInset.right - layoutInset.left - layoutInset.right
let vt = CGFloat(i + n + ro) * h + contentInset.top + layoutInset.top
let vh = h * CGFloat(r) - interimSpace
let h = (parent.bounds.height - contentInset.top - contentInset.bottom - layoutInset.top - layoutInset.bottom + interimSpace) / CGFloat(gr)
child.x = contentInset.left + layoutInset.left
child.y = vt
child.width = vw
child.height = vh
child.y = CGFloat(i + n + ro) * h + contentInset.top + layoutInset.top
child.width = parent.bounds.width - contentInset.left - contentInset.right - layoutInset.left - layoutInset.right
child.height = h * CGFloat(r) - interimSpace
n += r + ro - 1
case .none:
let c = child.grid.columns
let co = child.grid.offset.columns
var w = (parent.bounds.width - contentInset.left - contentInset.right - layoutInset.left - layoutInset.right + interimSpace) / CGFloat(gc)
var h = (parent.bounds.height - contentInset.top - contentInset.bottom - layoutInset.top - layoutInset.bottom + interimSpace) / CGFloat(gr)
let r = child.grid.rows
let ro = child.grid.offset.rows
let x = CGFloat(co) * w + contentInset.left + layoutInset.left
let y = CGFloat(ro) * h + contentInset.top + layoutInset.top
w = w * CGFloat(c) - interimSpace
h = h * CGFloat(r) - interimSpace
let c = child.grid.columns
let co = child.grid.offset.columns
let w = (parent.bounds.width - contentInset.left - contentInset.right - layoutInset.left - layoutInset.right + interimSpace) / CGFloat(gc)
let h = (parent.bounds.height - contentInset.top - contentInset.bottom - layoutInset.top - layoutInset.bottom + interimSpace) / CGFloat(gr)
child.x = x
child.y = y
child.width = w
child.height = h
child.x = CGFloat(co) * w + contentInset.left + layoutInset.left
child.y = CGFloat(ro) * h + contentInset.top + layoutInset.top
child.width = w * CGFloat(c) - interimSpace
child.height = h * CGFloat(r) - interimSpace
}
}
}
......
......@@ -42,6 +42,29 @@ public class MenuView : PulseView {
/// References the Menu instance.
public private(set) lazy var menu: Menu = Menu()
public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
/**
Since the subviews will be outside the bounds of this view,
we need to look at the subviews to see if we have a hit.
*/
guard !isHidden else {
return nil
}
for v in subviews {
let p = v.convert(point, from: self)
if v.bounds.contains(p) {
return v.hitTest(p, with: event)
}
}
if menu.isOpened {
(delegate as? MenuViewDelegate)?.menuViewDidTapOutside?(menuView: self)
}
return super.hitTest(point, with: event)
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
......@@ -89,27 +112,4 @@ public class MenuView : PulseView {
}
}
}
public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
/**
Since the subviews will be outside the bounds of this view,
we need to look at the subviews to see if we have a hit.
*/
guard !isHidden else {
return nil
}
for v in subviews {
let p = v.convert(point, from: self)
if v.bounds.contains(p) {
return v.hitTest(p, with: event)
}
}
if menu.isOpened {
(delegate as? MenuViewDelegate)?.menuViewDidTapOutside?(menuView: self)
}
return super.hitTest(point, with: event)
}
}
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