Skip to content

Commit 1973dc0

Browse files
committed
Fix channel info display for very small channel heights when depth sorting is enabled
1 parent 41b6d18 commit 1973dc0

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

Plugins/LfpViewer/LfpChannelDisplayInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ constexpr int channelLabelHeight = 12;
4646
constexpr int channelButtonSize = 10;
4747
constexpr int singleChannelInfoOffset = 75;
4848

49-
bool shouldDrawDenseChannelLabel (const int channelHeight, const int drawableChannelNumber, bool isSingleChannel)
49+
bool shouldDrawDenseChannelLabel (const int channelHeight, const int channelIndex, bool isSingleChannel)
5050
{
5151
if (isSingleChannel || channelHeight >= 15)
5252
return true;
5353

54-
return (drawableChannelNumber + 1) % 10 == 0;
54+
return (channelIndex + 1) % 10 == 0;
5555
}
5656

5757
String getChannelLabelString (LfpChannelDisplay& channel, LfpDisplayOptions::ChannelLabelDisplayMode labelMode)
@@ -233,7 +233,7 @@ void LfpChannelDisplayInfo::paint (Graphics& g)
233233
{
234234
auto* channel = display->drawableChannels[i];
235235
const int center = getTrackCenterY (*channel);
236-
const bool drawChannelLabel = shouldDrawDenseChannelLabel (channelHeight, channel->getDrawableChannelNumber(), isSingleChannel);
236+
const bool drawChannelLabel = shouldDrawDenseChannelLabel (channelHeight, i, isSingleChannel);
237237
const bool showTypeString = isSingleChannel || channel->getChannelHeight() > 34;
238238

239239
g.setColour (channel->getRecorded() && recordingIsActive ? Colours::red : Colours::grey);

Plugins/LfpViewer/LfpDisplayCanvas.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,8 @@ LfpDisplaySplitter::LfpDisplaySplitter (LfpDisplayNode* node,
713713
screenBufferWidth (0),
714714
nChans (0),
715715
selectedStreamId (0),
716-
isSelected (false)
716+
isSelected (false),
717+
hasAnyDepthInfo (false)
717718
{
718719
viewport = std::make_unique<LfpViewport> (this);
719720
lfpDisplay = std::make_unique<LfpDisplay> (this, viewport.get());
@@ -766,9 +767,12 @@ void LfpDisplaySplitter::refreshLeftMargin()
766767

767768
if (options->getChannelLabelDisplayMode() == LfpDisplayOptions::ChannelLabelDisplayMode::Depth)
768769
{
769-
// If displaying depth, we want to ensure enough space for the largest possible depth label
770-
const float textWidth = labelFont.getStringWidthFloat ("99999 μm");
771-
newMargin = std::max (newMargin, static_cast<int> (std::ceil (textWidth)) + 10);
770+
if (hasAnyDepthInfo)
771+
{
772+
// If displaying depth, we want to ensure enough space for the largest possible depth label
773+
const float textWidth = labelFont.getStringWidthFloat ("99999 μm");
774+
newMargin = std::max (newMargin, static_cast<int> (std::ceil (textWidth)) + 10);
775+
}
772776
}
773777
else
774778
{
@@ -1008,6 +1012,10 @@ void LfpDisplaySplitter::updateSettings()
10081012
lfpDisplay->channels[i]->setName (displayBuffer->channelMetadata[i].name);
10091013
lfpDisplay->channels[i]->setGroup (displayBuffer->channelMetadata[i].group);
10101014
lfpDisplay->channels[i]->setDepth (displayBuffer->channelMetadata[i].ypos);
1015+
if (displayBuffer->channelMetadata[i].ypos != 0)
1016+
{
1017+
hasAnyDepthInfo = true;
1018+
}
10111019
lfpDisplay->channels[i]->setXpos (displayBuffer->channelMetadata[i].xpos);
10121020
lfpDisplay->channels[i]->setMetadataPresence (displayBuffer->channelMetadata[i].hasGroupMetadata,
10131021
displayBuffer->channelMetadata[i].hasYposMetadata,

Plugins/LfpViewer/LfpDisplayCanvas.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ class LfpDisplaySplitter : public Component,
399399

400400
int eventState;
401401

402+
bool hasAnyDepthInfo;
403+
402404
std::unique_ptr<AudioBuffer<float>> eventDisplayBuffer; // buffer for event data
403405

404406
/** Define buffers for min, mean, and max for better plotting of spikes */

0 commit comments

Comments
 (0)