MCPcopy Create free account
hub / github.com/HertzDevil/0CC-FamiTracker / ModifyItems

Method ModifyItems

Source/GraphEditorComponentImpl.cpp:37–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35
36
37void CGraphBase::ModifyItems(bool redraw) {
38 int count = parent_.GetItemCount();
39
40 if (auto pSeq = parent_.GetSequence()) {
41 m_iHighlightedItem = -1;
42 m_iHighlightedValue = 0;
43
44 int index1 = GetItemIndex(m_ptLineStart);
45 int index2 = GetItemIndex(m_ptLineEnd);
46 int value1 = GetItemValue(m_ptLineStart);
47 int value2 = GetItemValue(m_ptLineEnd);
48
49 if (index1 == index2) {
50 if (index1 >= 0 && index1 < count)
51 pSeq->SetItem(index1, GetSequenceItemValue(index1, std::clamp(value1, GetMinItemValue(), GetMaxItemValue())));
52 }
53 else {
54 if (index1 > index2) {
55 std::swap(index1, index2);
56 std::swap(value1, value2);
57 }
58 if (value1 <= value2) {
59 int offs = 0;
60 for (int i = index1; i <= index2; ++i) {
61 auto delta = static_cast<int>(.5 + static_cast<double>(offs) / (index2 - index1));
62 if (i >= 0 && i < count)
63 pSeq->SetItem(i, GetSequenceItemValue(i, std::clamp(value1 + delta, GetMinItemValue(), GetMaxItemValue())));
64 offs += value2 - value1;
65 }
66 }
67 else {
68 int offs = 0;
69 for (int i = index2; i >= index1; --i) {
70 auto delta = static_cast<int>(.5 + static_cast<double>(offs) / (index2 - index1));
71 if (i >= 0 && i < count)
72 pSeq->SetItem(i, GetSequenceItemValue(i, std::clamp(value2 + delta, GetMinItemValue(), GetMaxItemValue())));
73 offs += value1 - value2;
74 }
75 }
76 }
77
78 if (redraw)
79 parent_.ItemModified(); // // //
80 }
81}
82
83int CGraphBase::GetSequenceItemValue(int idx, int val) const {
84 return val;

Callers

nothing calls this directly

Calls 6

clampFunction · 0.85
swapFunction · 0.85
SetItemMethod · 0.80
ItemModifiedMethod · 0.80
GetItemCountMethod · 0.45
GetSequenceMethod · 0.45

Tested by

no test coverage detected