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; }
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_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_10700) { effectiveOffset = -10700000000; } // 10.7GHz 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_10700) { effectiveOffset = -10700000000; } // 10.7GHz Down-conversion
else { effectiveOffset = 0; }
sigpath::sourceManager.setTuningOffset(effectiveOffset);
}

Wyświetl plik

@ -1,6 +1,7 @@
#include <gui/widgets/menu.h>
#include <imgui/imgui.h>
#include <imgui/imgui_internal.h>
#include <gui/style.h>
Menu::Menu() {
@ -26,19 +27,61 @@ void Menu::removeEntry(std::string name) {
bool Menu::draw(bool updateStates) {
bool changed = false;
headerTops.clear();
displayedNames.clear();
float menuWidth = ImGui::GetContentRegionAvailWidth();
ImGuiWindow* window = ImGui::GetCurrentWindow();
int id = 0;
ImU32 textColor = ImGui::GetColorU32(ImGuiCol_Text);
for (MenuOption_t& opt : order) {
if (items.find(opt.name) == items.end()) {
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];
ImRect orginalRect = window->WorkRect;
if (item.inst != NULL) {
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 (ImGui::CollapsingHeader((opt.name + "##sdrpp_main_menu").c_str())) {
if (item.inst != NULL) {
@ -83,6 +126,69 @@ bool Menu::draw(bool updateStates) {
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;
}

Wyświetl plik

@ -28,5 +28,13 @@ public:
private:
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;
};

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)
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)
* [Discord Server](https://discord.gg/aFgWjyD)
## Features
* 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
# Installing
## Windows
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.
@ -25,9 +26,11 @@ To create a desktop shortcut, rightclick the exe and select `Send to -> Desktop
## Linux
### 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.
Then, run:
```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 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`.
### Arch-based
Install the latest release from the [sdrpp-git](https://aur.archlinux.org/packages/sdrpp-git/) AUR package
### 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).
## MacOS
TODO
## 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.
# 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.
## Install dependencies
* [cmake](https://cmake.org)
* [vcpkg](https://vcpkg.io)
* [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/`)
After this, install the following dependencies using vcpkg:
* fftw3
* glfw3
* 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`
## Building using the command line
**IMPORTANT:** Replace `<vcpkg install directory>` with vcpkg's install directory.
```
mkdir build
cd build
@ -73,10 +85,13 @@ cmake --build . --config Release
```
## Running for development
### Create a new configuration root directory
```
```bat
./create_root.bat
```
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.
@ -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
From the top directory, you can simply run:
```
```bat
./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:
```
```bat
./sdrpp.exe -r ../../root_dev -s
```
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.
@ -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:
```json
...
"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.
## Installing SDR++
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`.
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):
* `build/radio/Release/`
* `build/recorder/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/audio_sink/Release/`
# Building on Linux / BSD
## Select which modules you wish to build
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),
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
## Install dependencies
* cmake
* fftw3
* 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.
## Building
replace `<N>` with the number of threads you wish to use to build
```sh
mkdir build
cd build
@ -172,14 +194,17 @@ make -j<N>
```
## Create a new root directory
```sh
sh ./create_root.sh
```
## Running for development
If you wish to install SDR++, skip to the next step
First run SDR++ from the build directory to generate a default config file
```
./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.
You also need to change the location of the resource and module directories, for development, I recommend:
```json
...
"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.
Next, from the top directory, you can simply run:
```
./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:
```
./sdrpp -r ../root_dev
```
## Installing SDR++
To install SDR++, run the following command in your ``build`` folder:
```sh
sudo make install
```
@ -311,6 +341,7 @@ I will soon publish a contributing.md listing the code style to use.
# Credits
## Patrons
* [Croccydile](https://example.com/)
* [Daniele D'Agnelli](https://linkedin.com/in/dagnelli)
* [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/)
* [SignalsEverywhere](https://signalseverywhere.com/)
## Contributors
* [Aang23](https://github.com/Aang23)
* [Alexsey Shestacov](https://github.com/wingrime)
* [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)
* [Zimm](https://github.com/invader-zimm)
## Libraries used
* [SoapySDR (PothosWare)](https://github.com/pothosware/SoapySDR)
* [Dear ImGui (ocornut)](https://github.com/ocornut/imgui)
* [spdlog (gabime)](https://github.com/gabime/spdlog)