More UI bugfix

This commit is contained in:
Ryzerth 2021-07-10 21:15:20 +02:00
parent 6cca4c654f
commit eb48dd70fb
3 changed files with 21 additions and 3 deletions

View File

@ -196,6 +196,21 @@ void MainWindow::init() {
tuningMode = core::configManager.conf["centerTuning"] ? tuner::TUNER_MODE_CENTER : tuner::TUNER_MODE_NORMAL;
core::configManager.release();
// Correct the offset of all VFOs so that they fit on the screen
float finalBwHalf = gui::waterfall.getBandwidth() / 2.0;
for (auto& [_name, _vfo] : gui::waterfall.vfos) {
if (_vfo->lowerOffset < -finalBwHalf) {
sigpath::vfoManager.setCenterOffset(_name, (_vfo->bandwidth/2)-finalBwHalf);
continue;
}
if (_vfo->upperOffset > finalBwHalf) {
sigpath::vfoManager.setCenterOffset(_name, finalBwHalf-(_vfo->bandwidth/2));
continue;
}
}
initComplete = true;
}
void MainWindow::fftHandler(dsp::complex_t* samples, int count, void* ctx) {
@ -233,7 +248,8 @@ void MainWindow::vfoAddedHandler(VFOManager::VFO* vfo, void* ctx) {
}
double offset = core::configManager.conf["vfoOffsets"][name];
core::configManager.release();
sigpath::vfoManager.setOffset(name, std::clamp<double>(offset, -_this->bw/2.0, _this->bw/2.0));
sigpath::vfoManager.setOffset(name, _this->initComplete ? std::clamp<double>(offset, -_this->bw/2.0, _this->bw/2.0) : offset);
}
void MainWindow::draw() {

View File

@ -65,6 +65,8 @@ private:
bool demoWindow = false;
int selectedWindow = 0;
bool initComplete = false;
EventHandler<VFOManager::VFO*> vfoCreatedHandler;
};

View File

@ -1151,8 +1151,8 @@ namespace ImGui {
int _right = right;
left = std::clamp<int>(left, 0, dataWidth - 1);
right = std::clamp<int>(right, 0, dataWidth - 1);
if (left != _left) { leftClamped = true; }
if (right != _right) { rightClamped = true; }
leftClamped = (left != _left);
rightClamped = (right != _right);
rectMin = ImVec2(widgetPos.x + 50 + left, widgetPos.y + 10);
rectMax = ImVec2(widgetPos.x + 51 + right, widgetPos.y + fftHeight + 10);