本文整理汇总了C++中SparseSet::addRange方法的典型用法代码示例。如果您正苦于以下问题:C++ SparseSet::addRange方法的具体用法?C++ SparseSet::addRange怎么用?C++ SparseSet::addRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SparseSet
的用法示例。
在下文中一共展示了SparseSet::addRange方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createSolidAreaMask
void Image::createSolidAreaMask (RectangleList& result, const float alphaThreshold) const
{
if (hasAlphaChannel())
{
const uint8 threshold = (uint8) jlimit (0, 255, roundToInt (alphaThreshold * 255.0f));
SparseSet<int> pixelsOnRow;
const BitmapData srcData (*this, 0, 0, getWidth(), getHeight());
for (int y = 0; y < srcData.height; ++y)
{
pixelsOnRow.clear();
const uint8* lineData = srcData.getLinePointer (y);
if (isARGB())
{
for (int x = 0; x < srcData.width; ++x)
{
if (((const PixelARGB*) lineData)->getAlpha() >= threshold)
pixelsOnRow.addRange (Range<int> (x, x + 1));
lineData += srcData.pixelStride;
}
}
else
{
for (int x = 0; x < srcData.width; ++x)
{
if (*lineData >= threshold)
pixelsOnRow.addRange (Range<int> (x, x + 1));
lineData += srcData.pixelStride;
}
}
for (int i = 0; i < pixelsOnRow.getNumRanges(); ++i)
{
const Range<int> range (pixelsOnRow.getRange (i));
result.add (Rectangle<int> (range.getStart(), y, range.getLength(), 1));
}
result.consolidate();
}
}
else
{
result.add (0, 0, getWidth(), getHeight());
}
}
示例2: mouseDrag
void mouseDrag (const MouseEvent& e) override
{
if (auto* m = owner.getModel())
{
if (isEnabled() && e.mouseWasDraggedSinceMouseDown() && ! isDragging)
{
SparseSet<int> rowsToDrag;
if (owner.selectOnMouseDown || owner.isRowSelected (row))
rowsToDrag = owner.getSelectedRows();
else
rowsToDrag.addRange (Range<int>::withStartAndLength (row, 1));
if (rowsToDrag.size() > 0)
{
auto dragDescription = m->getDragSourceDescription (rowsToDrag);
if (! (dragDescription.isVoid() || (dragDescription.isString() && dragDescription.toString().isEmpty())))
{
isDragging = true;
owner.startDragAndDrop (e, rowsToDrag, dragDescription, true);
}
}
}
}
if (! isDraggingToScroll)
if (auto* vp = owner.getViewport())
isDraggingToScroll = vp->isCurrentlyScrollingOnDrag();
}
示例3: syncSelectedItemsWithDeviceList
//==============================================================================
void syncSelectedItemsWithDeviceList (const ReferenceCountedArray<MidiDeviceListEntry>& midiDevices)
{
SparseSet<int> selectedRows;
for (int i = 0; i < midiDevices.size(); ++i)
if (midiDevices[i]->inDevice != nullptr || midiDevices[i]->outDevice != nullptr)
selectedRows.addRange (Range<int> (i, i+1));
lastSelectedItems = selectedRows;
updateContent();
setSelectedRows (selectedRows, dontSendNotification);
}
示例4: mouseDrag
void mouseDrag (const MouseEvent& e) override
{
if (isEnabled() && owner.getModel() != nullptr && ! (e.mouseWasClicked() || isDragging))
{
SparseSet<int> rowsToDrag;
if (owner.selectOnMouseDown || owner.isRowSelected (row))
rowsToDrag = owner.getSelectedRows();
else
rowsToDrag.addRange (Range<int>::withStartAndLength (row, 1));
if (rowsToDrag.size() > 0)
{
const var dragDescription (owner.getModel()->getDragSourceDescription (rowsToDrag));
if (! (dragDescription.isVoid() || (dragDescription.isString() && dragDescription.toString().isEmpty())))
{
isDragging = true;
owner.startDragAndDrop (e, rowsToDrag, dragDescription, true);
}
}
}
}
示例5: timerCallback
void CDPlayer::timerCallback()
{
m_digitalDisplay.setText(Utils::formatSeconds(m_transportSource.getCurrentPosition()), sendNotification);
int64 currentSample = m_source->getNextReadPosition();
const Array<int>& offsets = m_reader->getTrackOffsets();
// offsets[0] != 0 is possible, there might be a track before the first.
// offsets.getLast() is not the start of the last track but the end sample of the CD.
if (currentSample < offsets[0])
{
// We are before the first track.
m_slider.setEnabled(false);
m_slider.setValue(m_slider.getMinimum(), juce::dontSendNotification);
m_currentTrack = -1;
SparseSet<int> rows;
m_tracksTable.setSelectedRows(rows, juce::dontSendNotification);
return;
}
if (m_currentTrack == -1)
{
// We have now entered the first track.
m_slider.setEnabled(true);
m_slider.setRange(offsets[0], offsets[1]);
// Possible loss of precision is acceptable for very large values because user can't select specific value that precise.
m_slider.setValue(static_cast<double>(currentSample), juce::dontSendNotification);
m_currentTrack = 0;
m_pluginLoader.playlistEntrySelected(getName().toRawUTF8(), m_currentTrack);
SparseSet<int> rows;
rows.addRange(Range<int>(m_currentTrack, m_currentTrack + 1));
m_tracksTable.setSelectedRows(rows, juce::dontSendNotification);
return;
}
jassert(m_currentTrack + 1 < offsets.size());
if (currentSample >= offsets[m_currentTrack] && currentSample < offsets[m_currentTrack + 1])
{
// We are still within the current track (usual case).
// Possible loss of precision is acceptable for very large values because user can't select specific value that precise.
m_slider.setValue(static_cast<double>(currentSample), juce::dontSendNotification);
return;
}
// We are within another track.
int64 firstSample = -1;
int64 lastSample = -1;
if (currentSample < offsets[m_currentTrack])
{
// We are before the curren track. Search backward to find the track our sample position now lies within.
// Assume our current track is the immediately preceeding track.
jassert(m_currentTrack - 1 >= 0);
firstSample = -1;
lastSample = offsets[m_currentTrack];
for (int probeTrack = m_currentTrack - 1; probeTrack >= 0; --probeTrack)
{
if (currentSample >= offsets[probeTrack])
{
m_currentTrack = probeTrack;
firstSample = offsets[probeTrack];
break; // We are at the previous track.
}
lastSample = offsets[probeTrack];
}
m_pluginLoader.previousEntrySelected(getName().toRawUTF8());
m_pluginLoader.playlistEntrySelected(getName().toRawUTF8(), m_currentTrack);
}
if (currentSample >= offsets[m_currentTrack + 1])
{
// We are after the curren track. Search forward to find the track our sample position now lies within.
// Assume our current track is the immediately following track.
jassert(m_currentTrack + 2 < offsets.size());
firstSample = offsets[m_currentTrack + 1];
lastSample = -1;
for (int probeTrack = m_currentTrack + 2; probeTrack < offsets.size(); ++probeTrack)
{
if (offsets[probeTrack] > currentSample)
{
m_currentTrack = probeTrack - 1;
lastSample = offsets[probeTrack];
break; // We are at the next track.
}
firstSample = offsets[probeTrack];
}
m_pluginLoader.nextEntrySelected(getName().toRawUTF8());
m_pluginLoader.playlistEntrySelected(getName().toRawUTF8(), m_currentTrack);
}
//.........这里部分代码省略.........