-
-
Notifications
You must be signed in to change notification settings - Fork 125
Expand file tree
/
Copy pathmatrixstate.cpp
More file actions
43 lines (36 loc) · 913 Bytes
/
matrixstate.cpp
File metadata and controls
43 lines (36 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2023 Kushview, LLC <info@kushview.net>
// SPDX-License-Identifier: GPL-3.0-or-later
#include "matrixstate.hpp"
namespace element {
using namespace juce;
void MatrixState::setFrom (const MatrixState& o)
{
for (int row = jmin (getNumRows(), o.getNumRows()); --row >= 0;)
for (int col = jmin (getNumColumns(), o.getNumColumns()); --col >= 0;)
set (row, col, o.connected (row, col));
}
void MatrixState::resize (int r, int c, bool retain)
{
if (r < 0)
r = 0;
if (c < 0)
c = 0;
BigInteger bits;
bits.setRange (0, r * c, false);
// TODO: retain set bits
if (retain)
{
const auto old = *this;
numRows = r;
numColumns = c;
toggled.swapWith (bits);
setFrom (old);
}
else
{
numRows = r;
numColumns = c;
toggled.swapWith (bits);
}
}
} // namespace element