MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / updatePosition

Method updatePosition

src/gui/VfoWidget.cpp:2958–3024  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2956}
2957
2958void VfoWidget::updatePosition(int vfoX, int specTop, FlagDir dir)
2959{
2960 const int w = width();
2961 const bool defaultOnLeft = !m_slice || defaultFlagOnLeftForMode(m_slice->mode());
2962 const int parentW = parentWidget() ? parentWidget()->width() : 0;
2963 const FlagPlacement placement = placementForMarker(
2964 vfoX, specTop, w, height(), parentW, dir, defaultOnLeft);
2965 const bool onLeft = placement.onLeft;
2966
2967 // Skip all moves if position unchanged — prevents repaint cascade on QRhiWidget
2968 const QPoint newPos = placement.rect.topLeft();
2969 if (pos() == newPos && m_lastOnLeft == onLeft)
2970 return;
2971 m_lastOnLeft = onLeft;
2972
2973 move(newPos);
2974
2975 // The value labels (drawn by the spectrum's above-flags layer) are anchored to
2976 // this flag — repaint them as it pans. Only when labels are actually shown.
2977 if (m_smartMtr && !m_collapsed
2978 && MeterViewController::instance().showValues()
2979 != DisplaySettings::MeterValues::None)
2980 emit smartMtrLabelsChanged();
2981
2982 // Position close/lock/record/play buttons stacked vertically on the side opposite the marker
2983 if (m_closeSliceBtn && m_lockVfoBtn) {
2984 const int btnSize = 20;
2985 const int gap = 2;
2986 int btnX;
2987 if (onLeft)
2988 btnX = newPos.x() - btnSize - gap; // left of VFO widget
2989 else
2990 btnX = newPos.x() + w + gap; // right of VFO widget
2991
2992 int btnY = newPos.y();
2993 if (!m_collapsed) {
2994 m_closeSliceBtn->move(btnX, btnY);
2995 btnY += btnSize + gap;
2996
2997 m_lockVfoBtn->move(btnX, btnY);
2998 btnY += btnSize + gap;
2999
3000 if (m_recordBtn) {
3001 m_recordBtn->move(btnX, btnY);
3002 btnY += btnSize + gap;
3003 }
3004 if (m_playBtn) {
3005 m_playBtn->move(btnX, btnY);
3006 }
3007 }
3008 }
3009
3010 // Position collapsed frequency label next to the collapsed widget
3011 if (m_collapsedFreqLabel && m_collapsed) {
3012 const int freqGap = 2;
3013 int freqX;
3014 int freqH = m_collapsedFreqLabel->sizeHint().height();
3015 int freqY = newPos.y() + (height() - freqH) / 2; // vertically centered

Callers 2

repositionVfoFlagsMethod · 0.80
paintEventMethod · 0.80

Calls 4

moveFunction · 0.85
modeMethod · 0.45
showValuesMethod · 0.45
sizeHintMethod · 0.45

Tested by 2

repositionVfoFlagsMethod · 0.64
paintEventMethod · 0.64