Added a way to move menus around

pull/162/head
Ryzerth 2021-07-09 04:29:16 +02:00
rodzic 29ec14d3f0
commit cf3c976651
4 zmienionych plików z 160 dodań i 15 usunięć

Wyświetl plik

@ -35,9 +35,9 @@ namespace sourecmenu {
if (offsetMode == OFFSET_MODE_CUSTOM) { effectiveOffset = customOffset; } if (offsetMode == OFFSET_MODE_CUSTOM) { effectiveOffset = customOffset; }
else if (offsetMode == OFFSET_MODE_SPYVERTER) { effectiveOffset = 120000000; } // 120MHz Up-conversion else if (offsetMode == OFFSET_MODE_SPYVERTER) { effectiveOffset = 120000000; } // 120MHz Up-conversion
else if (offsetMode == OFFSET_MODE_HAM_IT_UP) { effectiveOffset = 125000000; } // 125MHz Up-conversion else if (offsetMode == OFFSET_MODE_HAM_IT_UP) { effectiveOffset = 125000000; } // 125MHz Up-conversion
else if (offsetMode == OFFSET_MODE_DK5AV_XB) { effectiveOffset = -6800000000; } // 6.8GHz Down-conversion else if (offsetMode == OFFSET_MODE_DK5AV_XB) { effectiveOffset = -6800000000; } // 6.8GHz Down-conversion
else if (offsetMode == OFFSET_MODE_KU_LNB_9750) { effectiveOffset = -9750000000; } // 9.750GHz Down-conversion else if (offsetMode == OFFSET_MODE_KU_LNB_9750) { effectiveOffset = -9750000000; } // 9.750GHz Down-conversion
else if (offsetMode == OFFSET_MODE_KU_LNB_10700) { effectiveOffset = -10700000000; } // 10.7GHz Down-conversion else if (offsetMode == OFFSET_MODE_KU_LNB_10700) { effectiveOffset = -10700000000; } // 10.7GHz Down-conversion
else { effectiveOffset = 0; } else { effectiveOffset = 0; }
sigpath::sourceManager.setTuningOffset(effectiveOffset); sigpath::sourceManager.setTuningOffset(effectiveOffset);
} }

Wyświetl plik

@ -1,6 +1,7 @@
#include <gui/widgets/menu.h> #include <gui/widgets/menu.h>
#include <imgui/imgui.h> #include <imgui/imgui.h>
#include <imgui/imgui_internal.h> #include <imgui/imgui_internal.h>
#include <gui/style.h>
Menu::Menu() { Menu::Menu() {
@ -26,19 +27,61 @@ void Menu::removeEntry(std::string name) {
bool Menu::draw(bool updateStates) { bool Menu::draw(bool updateStates) {
bool changed = false; bool changed = false;
headerTops.clear();
displayedNames.clear();
float menuWidth = ImGui::GetContentRegionAvailWidth(); float menuWidth = ImGui::GetContentRegionAvailWidth();
ImGuiWindow* window = ImGui::GetCurrentWindow(); ImGuiWindow* window = ImGui::GetCurrentWindow();
int id = 0;
ImU32 textColor = ImGui::GetColorU32(ImGuiCol_Text);
for (MenuOption_t& opt : order) { for (MenuOption_t& opt : order) {
if (items.find(opt.name) == items.end()) { if (items.find(opt.name) == items.end()) {
continue; continue;
} }
if (opt.name == draggedMenuName) {
ImGui::BeginTooltip();
ImGui::Text("%s", draggedMenuName.c_str());
ImGui::EndTooltip();
continue;
}
if (id == insertBefore && draggedMenuName != "") {
if (updateStates) { ImGui::SetNextItemOpen(false); }
ImVec2 posMin = ImGui::GetCursorScreenPos();
ImVec2 posMax = ImVec2(posMin.x + menuWidth, posMin.y + ImGui::GetFrameHeight());
style::beginDisabled();
ImGui::CollapsingHeader((draggedMenuName + "##sdrpp_main_menu_dragging").c_str());
style::endDisabled();
window->DrawList->AddRect(posMin, posMax, textColor);
}
id++;
MenuItem_t& item = items[opt.name]; MenuItem_t& item = items[opt.name];
ImRect orginalRect = window->WorkRect; ImRect orginalRect = window->WorkRect;
if (item.inst != NULL) { if (item.inst != NULL) {
window->WorkRect = ImRect(orginalRect.Min, ImVec2(orginalRect.Max.x - ImGui::GetTextLineHeight() - 6, orginalRect.Max.y)); window->WorkRect = ImRect(orginalRect.Min, ImVec2(orginalRect.Max.x - ImGui::GetTextLineHeight() - 6, orginalRect.Max.y));
} }
ImVec2 posMin = ImGui::GetCursorScreenPos();
ImVec2 posMax = ImVec2(posMin.x + menuWidth, posMin.y + ImGui::GetFrameHeight());
headerTops.push_back(posMin.y);
displayedNames.push_back(opt.name);
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left) && ImGui::IsMouseHoveringRect(posMin, posMax)) {
menuClicked = true;
clickedMenuName = opt.name;
}
if (menuClicked && ImGui::IsMouseDragging(ImGuiMouseButton_Left) && draggedMenuName == "" && clickedMenuName == opt.name) {
draggedMenuName = opt.name;
continue;
}
if (updateStates) { ImGui::SetNextItemOpen(opt.open); } if (updateStates) { ImGui::SetNextItemOpen(opt.open); }
if (ImGui::CollapsingHeader((opt.name + "##sdrpp_main_menu").c_str())) { if (ImGui::CollapsingHeader((opt.name + "##sdrpp_main_menu").c_str())) {
if (item.inst != NULL) { if (item.inst != NULL) {
@ -83,6 +126,69 @@ bool Menu::draw(bool updateStates) {
changed = true; changed = true;
} }
} }
if (!ImGui::IsMouseDown(ImGuiMouseButton_Left) && menuClicked) {
if (draggedMenuName != "") {
// Move menu
int movedId = 0;
MenuOption_t movedOpt;
for (int i = 0; i < order.size(); i++) {
if (order[i].name == draggedMenuName) {
movedId = i;
movedOpt = order[i];
break;
}
}
order.erase(order.begin() + movedId);
if (insertBefore == headerTops.size()) {
order.push_back(movedOpt);
}
else if (insertBeforeName != "") {
int beforeId = 0;
for (int i = 0; i < order.size(); i++) {
if (order[i].name == insertBeforeName) {
beforeId = i;
break;
}
}
order.insert(order.begin() + beforeId, movedOpt);
}
changed = true;
}
menuClicked = false;
draggedMenuName = "";
insertBeforeName = "";
insertBefore = -1;
}
if (insertBefore == headerTops.size() && draggedMenuName != "") {
if (updateStates) { ImGui::SetNextItemOpen(false); }
ImVec2 posMin = ImGui::GetCursorScreenPos();
ImVec2 posMax = ImVec2(posMin.x + menuWidth, posMin.y + ImGui::GetFrameHeight());
style::beginDisabled();
ImGui::CollapsingHeader((draggedMenuName + "##sdrpp_main_menu_dragging").c_str());
style::endDisabled();
window->DrawList->AddRect(posMin, posMax, textColor);
}
if (draggedMenuName != "") {
insertBefore = headerTops.size();
ImVec2 mPos = ImGui::GetMousePos();
for (int i = 0; i < headerTops.size(); i++) {
if (headerTops[i] > mPos.y) {
insertBefore = i;
insertBeforeName = displayedNames[i];
break;
}
}
}
return changed; return changed;
} }

Wyświetl plik

@ -28,5 +28,13 @@ public:
private: private:
bool isInOrderList(std::string name); bool isInOrderList(std::string name);
bool menuClicked = false;
std::string clickedMenuName = "";
std::string draggedMenuName = "";
std::vector<float> headerTops;
int insertBefore = -1;
std::string insertBeforeName = "";
std::vector<std::string> displayedNames;
std::map<std::string, MenuItem_t> items; std::map<std::string, MenuItem_t> items;
}; };

Wyświetl plik

@ -1,4 +1,4 @@
# SDR++, The bloat-free SDR software # SDR++, The bloat-free SDR software<br>
![Screenshot](https://i.imgur.com/Ter2MQJ.png) ![Screenshot](https://i.imgur.com/Ter2MQJ.png)
SDR++ is a cross-platform and open source SDR software with the aim of being bloat free and simple to use. SDR++ is a cross-platform and open source SDR software with the aim of being bloat free and simple to use.
@ -8,7 +8,6 @@ SDR++ is a cross-platform and open source SDR software with the aim of being blo
* [Patreon](https://patreon.com/ryzerth) * [Patreon](https://patreon.com/ryzerth)
* [Discord Server](https://discord.gg/aFgWjyD) * [Discord Server](https://discord.gg/aFgWjyD)
## Features ## Features
* Wide hardware support (both through SoapySDR and dedicated modules) * Wide hardware support (both through SoapySDR and dedicated modules)
@ -17,7 +16,9 @@ SDR++ is a cross-platform and open source SDR software with the aim of being blo
* Full waterfall update when possible. Makes browsing signals easier and more pleasant * Full waterfall update when possible. Makes browsing signals easier and more pleasant
# Installing # Installing
## Windows ## Windows
Download the latest release from [the Releases page](https://github.com/AlexandreRouma/SDRPlusPlus/releases) and extract to the directory of your choice. Download the latest release from [the Releases page](https://github.com/AlexandreRouma/SDRPlusPlus/releases) and extract to the directory of your choice.
To create a desktop shortcut, rightclick the exe and select `Send to -> Desktop (create shortcut)`, then, rename the shortcut on the desktop to whatever you want. To create a desktop shortcut, rightclick the exe and select `Send to -> Desktop (create shortcut)`, then, rename the shortcut on the desktop to whatever you want.
@ -25,9 +26,11 @@ To create a desktop shortcut, rightclick the exe and select `Send to -> Desktop
## Linux ## Linux
### Debian-based (Ubuntu, Mint, etc) ### Debian-based (Ubuntu, Mint, etc)
Download the latest release from [the Releases page](https://github.com/AlexandreRouma/SDRPlusPlus/releases) and extract to the directory of your choice. Download the latest release from [the Releases page](https://github.com/AlexandreRouma/SDRPlusPlus/releases) and extract to the directory of your choice.
Then, run: Then, run:
```sh ```sh
sudo apt install libfftw3-dev libglfw3-dev libglew-dev libvolk2-dev libsoapysdr-dev libairspyhf-dev libiio-dev libad9361-dev librtaudio-dev libhackrf-dev sudo apt install libfftw3-dev libglfw3-dev libglew-dev libvolk2-dev libsoapysdr-dev libairspyhf-dev libiio-dev libad9361-dev librtaudio-dev libhackrf-dev
sudo dpkg -i sdrpp_debian_amd64.deb sudo dpkg -i sdrpp_debian_amd64.deb
@ -36,35 +39,44 @@ sudo dpkg -i sdrpp_debian_amd64.deb
If `libvolk2-dev` is not available, use `libvolk1-dev`. If `libvolk2-dev` is not available, use `libvolk1-dev`.
### Arch-based ### Arch-based
Install the latest release from the [sdrpp-git](https://aur.archlinux.org/packages/sdrpp-git/) AUR package Install the latest release from the [sdrpp-git](https://aur.archlinux.org/packages/sdrpp-git/) AUR package
### Other ### Other
There are currently no existing packages for other distributions, for these systems you'll have to [build from source](https://github.com/AlexandreRouma/SDRPlusPlus#building-on-linux--bsd). There are currently no existing packages for other distributions, for these systems you'll have to [build from source](https://github.com/AlexandreRouma/SDRPlusPlus#building-on-linux--bsd).
## MacOS ## MacOS
TODO TODO
## BSD ## BSD
There are currently no BSD packages, refer to [Building on Linux / BSD](https://github.com/AlexandreRouma/SDRPlusPlus#building-on-linux--bsd) for instructions on building from source. There are currently no BSD packages, refer to [Building on Linux / BSD](https://github.com/AlexandreRouma/SDRPlusPlus#building-on-linux--bsd) for instructions on building from source.
# Building on Windows # Building on Windows
The prefered IDE is [VS Code](https://code.visualstudio.com/) in order to have similar development experience across platforms and to build with CMake using the command line. The prefered IDE is [VS Code](https://code.visualstudio.com/) in order to have similar development experience across platforms and to build with CMake using the command line.
## Install dependencies ## Install dependencies
* [cmake](https://cmake.org) * [cmake](https://cmake.org)
* [vcpkg](https://vcpkg.io) * [vcpkg](https://vcpkg.io)
* [PothosSDR](https://github.com/pothosware/PothosSDR) (This will install libraries for most SDRs) * [PothosSDR](https://github.com/pothosware/PothosSDR) (This will install libraries for most SDRs)
* [RtAudio](https://www.music.mcgill.ca/~gary/rtaudio/) (You have to build and install it in `C:/Program Files (x86)/RtAudio/`) * [RtAudio](https://www.music.mcgill.ca/~gary/rtaudio/) (You have to build and install it in `C:/Program Files (x86)/RtAudio/`)
After this, install the following dependencies using vcpkg: After this, install the following dependencies using vcpkg:
* fftw3 * fftw3
* glfw3 * glfw3
* glew * glew
You are probably going to build in 64 bit so make sure vcpkg installs the correct versions using `.\vcpkg.exe install <package>:x64-windows` You are probably going to build in 64 bit so make sure vcpkg installs the correct versions using `.\vcpkg.exe install <package>:x64-windows`
## Building using the command line ## Building using the command line
**IMPORTANT:** Replace `<vcpkg install directory>` with vcpkg's install directory. **IMPORTANT:** Replace `<vcpkg install directory>` with vcpkg's install directory.
``` ```
mkdir build mkdir build
cd build cd build
@ -73,10 +85,13 @@ cmake --build . --config Release
``` ```
## Running for development ## Running for development
### Create a new configuration root directory ### Create a new configuration root directory
```
```bat
./create_root.bat ./create_root.bat
``` ```
This will create the `root_dev` directory that will be used to save the configs of sdrpp and the modules. This will create the `root_dev` directory that will be used to save the configs of sdrpp and the modules.
You will next need to edit the `root_dev/config.json` file to point to the modules that were built. If the file is missing in your folder run the application once and it will create one with default value -- see later on how to run the application. You will next need to edit the `root_dev/config.json` file to point to the modules that were built. If the file is missing in your folder run the application once and it will create one with default value -- see later on how to run the application.
@ -84,14 +99,17 @@ You will next need to edit the `root_dev/config.json` file to point to the modul
### Run SDR++ from the command line ### Run SDR++ from the command line
From the top directory, you can simply run: From the top directory, you can simply run:
```
```bat
./build/Release/sdrpp.exe -r root_dev -s ./build/Release/sdrpp.exe -r root_dev -s
``` ```
Or, if you wish to run from the build directory e.g. `build/Release` and adapt the relative path to the `root_dev` folder: Or, if you wish to run from the build directory e.g. `build/Release` and adapt the relative path to the `root_dev` folder:
```
```bat
./sdrpp.exe -r ../../root_dev -s ./sdrpp.exe -r ../../root_dev -s
``` ```
The optional `-s` argument is for keeping the console active in order to see the error messages. The optional `-s` argument is for keeping the console active in order to see the error messages.
Because all the paths are relative, for the rest of the command line instructions we are going to assume you are running from the top directory using the former command. Because all the paths are relative, for the rest of the command line instructions we are going to assume you are running from the top directory using the former command.
@ -110,6 +128,7 @@ As mentioned previously you need to edit `root_dev/config.json` to add the modul
``` ```
You also need to change the location of the resource and module directories, for development, I recommend: You also need to change the location of the resource and module directories, for development, I recommend:
```json ```json
... ...
"modulesDirectory": "root_dev/modules", "modulesDirectory": "root_dev/modules",
@ -120,14 +139,15 @@ You also need to change the location of the resource and module directories, for
Remember that these paths will be relative to the run directory. Remember that these paths will be relative to the run directory.
## Installing SDR++ ## Installing SDR++
If you choose to run SDR++ for development, you do not need this step. If you choose to run SDR++ for development, you do not need this step.
First, copy over the exe and DLLs from `build/Release/` to `root_dev`. First, copy over the exe and DLLs from `build/Release/` to `root_dev`.
Next you need to copy over all the modules that were compiled. To do so, copy the DLL file of the module (located in its build folder given below) to the `root_dev/modules` directory and other DLLs (that do not have the exact name of the modue) to the `root_dev` directory. Next you need to copy over all the modules that were compiled. To do so, copy the DLL file of the module (located in its build folder given below) to the `root_dev/modules` directory and other DLLs (that do not have the exact name of the modue) to the `root_dev` directory.
The modules built will be some of the following (Repeat the instructions above for all you wish to use): The modules built will be some of the following (Repeat the instructions above for all you wish to use):
* `build/radio/Release/` * `build/radio/Release/`
* `build/recorder/Release/` * `build/recorder/Release/`
* `build/rtl_tcp_source/Release/` * `build/rtl_tcp_source/Release/`
@ -137,11 +157,10 @@ The modules built will be some of the following (Repeat the instructions above f
* `build/plutosdr_source/Release/` * `build/plutosdr_source/Release/`
* `build/audio_sink/Release/` * `build/audio_sink/Release/`
# Building on Linux / BSD # Building on Linux / BSD
## Select which modules you wish to build ## Select which modules you wish to build
Depending on which module you want to build, you will need to install some additional dependencies. Depending on which module you want to build, you will need to install some additional dependencies.
Here are listed every module that requires addition dependencies. If a module enabled by default and you do not wish to install a perticular dependency (or can't, eg. the BladeRF module on Debian Buster), Here are listed every module that requires addition dependencies. If a module enabled by default and you do not wish to install a perticular dependency (or can't, eg. the BladeRF module on Debian Buster),
you can disable it using the module parameter listed in the table below you can disable it using the module parameter listed in the table below
@ -152,6 +171,7 @@ you can disable it using the module parameter listed in the table below
* audio_sink: librtaudio-dev * audio_sink: librtaudio-dev
## Install dependencies ## Install dependencies
* cmake * cmake
* fftw3 * fftw3
* glfw * glfw
@ -163,7 +183,9 @@ Next install dependencies based on the modules you wish to build (See previous s
Note: make sure you're using GCC 8 or later as older versions do not have `std::filesystem` built-in. Note: make sure you're using GCC 8 or later as older versions do not have `std::filesystem` built-in.
## Building ## Building
replace `<N>` with the number of threads you wish to use to build replace `<N>` with the number of threads you wish to use to build
```sh ```sh
mkdir build mkdir build
cd build cd build
@ -172,14 +194,17 @@ make -j<N>
``` ```
## Create a new root directory ## Create a new root directory
```sh ```sh
sh ./create_root.sh sh ./create_root.sh
``` ```
## Running for development ## Running for development
If you wish to install SDR++, skip to the next step If you wish to install SDR++, skip to the next step
First run SDR++ from the build directory to generate a default config file First run SDR++ from the build directory to generate a default config file
``` ```
./sdrpp -r ../root_dev/ ./sdrpp -r ../root_dev/
``` ```
@ -201,6 +226,7 @@ Then, you will need to edit the `root_dev/config.json` file to point to the modu
Note: You can generate this list automatically by running `find . | grep '\.so' | sed 's/^/"/' | sed 's/$/",/' | sed '/sdrpp_core.so/d'` in the build directory. Note: You can generate this list automatically by running `find . | grep '\.so' | sed 's/^/"/' | sed 's/$/",/' | sed '/sdrpp_core.so/d'` in the build directory.
You also need to change the location of the resource and module directories, for development, I recommend: You also need to change the location of the resource and module directories, for development, I recommend:
```json ```json
... ...
"modulesDirectory": "./root_dev/modules", "modulesDirectory": "./root_dev/modules",
@ -214,17 +240,21 @@ Remember that these paths will be relative to the run directory.
Of course, remember to add entries for all modules that were built and that you wish to use. Of course, remember to add entries for all modules that were built and that you wish to use.
Next, from the top directory, you can simply run: Next, from the top directory, you can simply run:
``` ```
./build/sdrpp -r root_dev ./build/sdrpp -r root_dev
``` ```
Or, if you wish to run from the build directory, you will need to correct the directories in the config.json file, and then run: Or, if you wish to run from the build directory, you will need to correct the directories in the config.json file, and then run:
``` ```
./sdrpp -r ../root_dev ./sdrpp -r ../root_dev
``` ```
## Installing SDR++ ## Installing SDR++
To install SDR++, run the following command in your ``build`` folder: To install SDR++, run the following command in your ``build`` folder:
```sh ```sh
sudo make install sudo make install
``` ```
@ -311,6 +341,7 @@ I will soon publish a contributing.md listing the code style to use.
# Credits # Credits
## Patrons ## Patrons
* [Croccydile](https://example.com/) * [Croccydile](https://example.com/)
* [Daniele D'Agnelli](https://linkedin.com/in/dagnelli) * [Daniele D'Agnelli](https://linkedin.com/in/dagnelli)
* [W4IPA](https://twitter.com/W4IPAstroke5) * [W4IPA](https://twitter.com/W4IPAstroke5)
@ -320,8 +351,8 @@ I will soon publish a contributing.md listing the code style to use.
* [Scanner School](https://scannerschool.com/) * [Scanner School](https://scannerschool.com/)
* [SignalsEverywhere](https://signalseverywhere.com/) * [SignalsEverywhere](https://signalseverywhere.com/)
## Contributors ## Contributors
* [Aang23](https://github.com/Aang23) * [Aang23](https://github.com/Aang23)
* [Alexsey Shestacov](https://github.com/wingrime) * [Alexsey Shestacov](https://github.com/wingrime)
* [Aosync](https://github.com/aosync) * [Aosync](https://github.com/aosync)
@ -342,8 +373,8 @@ I will soon publish a contributing.md listing the code style to use.
* [Tobias Mädel](https://github.com/Manawyrm) * [Tobias Mädel](https://github.com/Manawyrm)
* [Zimm](https://github.com/invader-zimm) * [Zimm](https://github.com/invader-zimm)
## Libraries used ## Libraries used
* [SoapySDR (PothosWare)](https://github.com/pothosware/SoapySDR) * [SoapySDR (PothosWare)](https://github.com/pothosware/SoapySDR)
* [Dear ImGui (ocornut)](https://github.com/ocornut/imgui) * [Dear ImGui (ocornut)](https://github.com/ocornut/imgui)
* [spdlog (gabime)](https://github.com/gabime/spdlog) * [spdlog (gabime)](https://github.com/gabime/spdlog)