mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-01-24 08:44:44 +01:00
Added scroll controls
This commit is contained in:
parent
75568a7bf7
commit
dd5490cac6
@ -648,6 +648,19 @@ void drawWindow() {
|
|||||||
|
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
|
||||||
|
// Handle scrollwheel
|
||||||
|
int wheel = ImGui::GetIO().MouseWheel;
|
||||||
|
if (wheel != 0 && (gui::waterfall.mouseInFFT || gui::waterfall.mouseInWaterfall)) {
|
||||||
|
double nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset + (vfo->snapInterval * wheel);
|
||||||
|
nfreq = roundl(nfreq / vfo->snapInterval) * vfo->snapInterval;
|
||||||
|
setVFO(nfreq);
|
||||||
|
core::configManager.aquire();
|
||||||
|
core::configManager.conf["frequency"] = gui::waterfall.getCenterFrequency();
|
||||||
|
if (vfo != NULL) {
|
||||||
|
core::configManager.conf["vfoOffsets"][gui::waterfall.selectedVFO] = vfo->generalOffset;
|
||||||
|
}
|
||||||
|
core::configManager.release(true);
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
ImGui::BeginChild("WaterfallControls");
|
ImGui::BeginChild("WaterfallControls");
|
||||||
|
@ -256,9 +256,11 @@ namespace ImGui {
|
|||||||
ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_PressedOnClick);
|
ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_PressedOnClick);
|
||||||
|
|
||||||
bool draging = ImGui::IsMouseDragging(ImGuiMouseButton_Left) && ImGui::IsWindowFocused();
|
bool draging = ImGui::IsMouseDragging(ImGuiMouseButton_Left) && ImGui::IsWindowFocused();
|
||||||
bool mouseInFreq = IS_IN_AREA(dragOrigin, freqAreaMin, freqAreaMax);
|
mouseInFreq = IS_IN_AREA(dragOrigin, freqAreaMin, freqAreaMax);
|
||||||
bool mouseInFFT = IS_IN_AREA(dragOrigin, fftAreaMin, fftAreaMax);
|
mouseInFFT = IS_IN_AREA(dragOrigin, fftAreaMin, fftAreaMax);
|
||||||
bool mouseInWaterfall = IS_IN_AREA(dragOrigin, wfMin, wfMax);
|
mouseInWaterfall = IS_IN_AREA(dragOrigin, wfMin, wfMax);
|
||||||
|
|
||||||
|
int mouseWheel = ImGui::GetIO().MouseWheel;
|
||||||
|
|
||||||
// Deselect everything if the mouse is released
|
// Deselect everything if the mouse is released
|
||||||
if (!ImGui::IsMouseDown(ImGuiMouseButton_Left)) {
|
if (!ImGui::IsMouseDown(ImGuiMouseButton_Left)) {
|
||||||
@ -361,6 +363,33 @@ namespace ImGui {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the mouse wheel is moved on the frequency scale
|
||||||
|
if (mouseWheel != 0 && mouseInFreq) {
|
||||||
|
viewOffset -= (double)mouseWheel * viewBandwidth / 20.0;
|
||||||
|
|
||||||
|
if (viewOffset + (viewBandwidth / 2.0) > wholeBandwidth / 2.0) {
|
||||||
|
double freqOffset = (viewOffset + (viewBandwidth / 2.0)) - (wholeBandwidth / 2.0);
|
||||||
|
viewOffset = (wholeBandwidth / 2.0) - (viewBandwidth / 2.0);
|
||||||
|
centerFreq += freqOffset;
|
||||||
|
centerFreqMoved = true;
|
||||||
|
}
|
||||||
|
if (viewOffset - (viewBandwidth / 2.0) < -(wholeBandwidth / 2.0)) {
|
||||||
|
double freqOffset = (viewOffset - (viewBandwidth / 2.0)) + (wholeBandwidth / 2.0);
|
||||||
|
viewOffset = (viewBandwidth / 2.0) - (wholeBandwidth / 2.0);
|
||||||
|
centerFreq += freqOffset;
|
||||||
|
centerFreqMoved = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0);
|
||||||
|
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0);
|
||||||
|
|
||||||
|
if (viewBandwidth != wholeBandwidth) {
|
||||||
|
updateAllVFOs();
|
||||||
|
if (_fullUpdate) { updateWaterfallFb(); };
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Finally, if nothing else was selected, just move the VFO
|
// Finally, if nothing else was selected, just move the VFO
|
||||||
if (ImGui::IsMouseDown(ImGuiMouseButton_Left) && (mouseInFFT|mouseInWaterfall)) {
|
if (ImGui::IsMouseDown(ImGuiMouseButton_Left) && (mouseInFFT|mouseInWaterfall)) {
|
||||||
if (selVfo != NULL) {
|
if (selVfo != NULL) {
|
||||||
|
@ -129,6 +129,10 @@ namespace ImGui {
|
|||||||
bool bandplanEnabled = false;
|
bool bandplanEnabled = false;
|
||||||
bandplan::BandPlan_t* bandplan = NULL;
|
bandplan::BandPlan_t* bandplan = NULL;
|
||||||
|
|
||||||
|
bool mouseInFreq = false;
|
||||||
|
bool mouseInFFT = false;
|
||||||
|
bool mouseInWaterfall = false;
|
||||||
|
|
||||||
std::map<std::string, WaterfallVFO*> vfos;
|
std::map<std::string, WaterfallVFO*> vfos;
|
||||||
std::string selectedVFO = "";
|
std::string selectedVFO = "";
|
||||||
bool selectedVFOChanged = false;
|
bool selectedVFOChanged = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user