d
This commit is contained in:
Binary file not shown.
@@ -9,15 +9,16 @@ protocol MainSectionGrid { }
|
||||
extension Main {
|
||||
enum SectionGrid {
|
||||
static func setupCore(_ core: Main.Core) {
|
||||
let side = 50
|
||||
let space = 20
|
||||
let gap = side + space
|
||||
|
||||
// Расставляем кнопки в сетке 4x4.
|
||||
for btn in core.buttons {
|
||||
let id = btn.tag
|
||||
let row = Int(id / 4)
|
||||
btn.frame = CGRect(x: gap + (id - row * 4) * gap, y: gap + row * gap, width: side, height: side)
|
||||
for (id, p) in memoryItemPositions(M()).enumerated() {
|
||||
let btn = core.buttons[id]
|
||||
btn.frame =
|
||||
CGRect(
|
||||
x: p.0,
|
||||
y: p.1,
|
||||
width: memorySide(),
|
||||
height: memorySide()
|
||||
)
|
||||
btn.backgroundColor = .blue
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Foundation
|
||||
|
||||
protocol MItemsCount {
|
||||
var itemsCount: Int { get }
|
||||
struct M {
|
||||
var itemsCount: Int = 16
|
||||
}
|
||||
|
||||
func memorySide() -> CGFloat {
|
||||
@@ -16,7 +16,7 @@ func memoryGap() -> CGFloat {
|
||||
return memorySide() + memorySpace()
|
||||
}
|
||||
|
||||
func memoryItemPositions(M: MItemsCount) -> [(CGFloat, CGFloat)] {
|
||||
func memoryItemPositions(_ M: M) -> [(CGFloat, CGFloat)] {
|
||||
var pos = [(CGFloat, CGFloat)]()
|
||||
for i in stride(from: 0, to: M.itemsCount, by: 1) {
|
||||
let row = floor(Double(i) / 4)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
|
||||
function memoryItemPositions(M) {
|
||||
var pos = [];
|
||||
var pos = []
|
||||
for (var i = 0; i < M.itemsCount; i++) {
|
||||
let row = Math.floor(i / 4)
|
||||
let x = memoryGap() + (i - row * 4) * memoryGap()
|
||||
|
||||
Reference in New Issue
Block a user