Commit 6861382d by Daniel Dahan

development: Updated Grid calculations

parent 35c09def
...@@ -215,7 +215,6 @@ public class Grid { ...@@ -215,7 +215,6 @@ public class Grid {
case .horizontal: case .horizontal:
let c = child.grid.columns let c = child.grid.columns
let co = child.grid.offset.columns let co = child.grid.offset.columns
let w = (parent.bounds.width - contentInset.left - contentInset.right - layoutInset.left - layoutInset.right + interimSpace) / CGFloat(gc) 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 child.x = CGFloat(i + n + co) * w + contentInset.left + layoutInset.left
...@@ -226,39 +225,29 @@ public class Grid { ...@@ -226,39 +225,29 @@ public class Grid {
n += c + co - 1 n += c + co - 1
case .vertical: case .vertical:
let h = (parent.bounds.height - contentInset.top - contentInset.bottom - layoutInset.top - layoutInset.bottom + interimSpace) / CGFloat(gr)
let r = child.grid.rows let r = child.grid.rows
let ro = child.grid.offset.rows let ro = child.grid.offset.rows
let vw = parent.bounds.width - contentInset.left - contentInset.right - layoutInset.left - layoutInset.right let h = (parent.bounds.height - contentInset.top - contentInset.bottom - layoutInset.top - layoutInset.bottom + interimSpace) / CGFloat(gr)
let vt = CGFloat(i + n + ro) * h + contentInset.top + layoutInset.top
let vh = h * CGFloat(r) - interimSpace
child.x = contentInset.left + layoutInset.left child.x = contentInset.left + layoutInset.left
child.y = vt child.y = CGFloat(i + n + ro) * h + contentInset.top + layoutInset.top
child.width = vw child.width = parent.bounds.width - contentInset.left - contentInset.right - layoutInset.left - layoutInset.right
child.height = vh child.height = h * CGFloat(r) - interimSpace
n += r + ro - 1 n += r + ro - 1
case .none: 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 r = child.grid.rows
let ro = child.grid.offset.rows let ro = child.grid.offset.rows
let x = CGFloat(co) * w + contentInset.left + layoutInset.left let c = child.grid.columns
let y = CGFloat(ro) * h + contentInset.top + layoutInset.top let co = child.grid.offset.columns
let w = (parent.bounds.width - contentInset.left - contentInset.right - layoutInset.left - layoutInset.right + interimSpace) / CGFloat(gc)
w = w * CGFloat(c) - interimSpace let h = (parent.bounds.height - contentInset.top - contentInset.bottom - layoutInset.top - layoutInset.bottom + interimSpace) / CGFloat(gr)
h = h * CGFloat(r) - interimSpace
child.x = x child.x = CGFloat(co) * w + contentInset.left + layoutInset.left
child.y = y child.y = CGFloat(ro) * h + contentInset.top + layoutInset.top
child.width = w child.width = w * CGFloat(c) - interimSpace
child.height = h child.height = h * CGFloat(r) - interimSpace
} }
} }
} }
......
...@@ -42,6 +42,29 @@ public class MenuView : PulseView { ...@@ -42,6 +42,29 @@ public class MenuView : PulseView {
/// References the Menu instance. /// References the Menu instance.
public private(set) lazy var menu: Menu = Menu() 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, Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method it is recommended to override the prepareView method
...@@ -89,27 +112,4 @@ public class MenuView : PulseView { ...@@ -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