Skip to content

Commit

Permalink
Added option to lock the menu order
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreRouma committed Mar 30, 2022
1 parent 03f173a commit 8d78eb3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions core/src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ int sdrpp_main(int argc, char* argv[]) {

defConfig["vfoColors"]["Radio"] = "#FFFFFF";

#ifdef __ANDROID__
defConfig["lockMenuOrder"] = true;
#else
defConfig["lockMenuOrder"] = false;
#endif

#if defined(_WIN32)
defConfig["modulesDirectory"] = "./modules";
defConfig["resourcesDirectory"] = "./res";
Expand Down
1 change: 1 addition & 0 deletions core/src/gui/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ void MainWindow::draw() {
}

ImGui::Checkbox("WF Single Click", &gui::waterfall.VFOMoveSingleClick);
ImGui::Checkbox("Lock Menu Order", &gui::menu.locked);

ImGui::Spacing();
}
Expand Down
8 changes: 8 additions & 0 deletions core/src/gui/menus/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ namespace displaymenu {
selectedWindow = std::clamp<int>((int)core::configManager.conf["fftWindow"], 0, _FFT_WINDOW_COUNT - 1);
gui::mainWindow.setFFTWindow(selectedWindow);

gui::menu.locked = core::configManager.conf["lockMenuOrder"];

// Define and load UI scales
uiScales.define(1.0f, "100%", 1.0f);
uiScales.define(2.0f, "200%", 2.0f);
Expand Down Expand Up @@ -124,6 +126,12 @@ namespace displaymenu {
core::configManager.release(true);
}

if (ImGui::Checkbox("Lock Menu Order##_sdrpp", &gui::menu.locked)) {
core::configManager.acquire();
core::configManager.conf["lockMenuOrder"] = gui::menu.locked;
core::configManager.release(true);
}

ImGui::LeftLabel("High-DPI Scaling");
ImGui::FillWidth();
if (ImGui::Combo("##sdrpp_ui_scale", &uiScaleId, uiScales.txt)) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/gui/widgets/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ bool Menu::draw(bool updateStates) {
clickedMenuName = opt.name;
}

if (menuClicked && ImGui::IsMouseDragging(ImGuiMouseButton_Left) && draggedMenuName.empty() && clickedMenuName == opt.name) {
if (menuClicked && ImGui::IsMouseDragging(ImGuiMouseButton_Left) && draggedMenuName.empty() && clickedMenuName == opt.name && !locked) {
draggedMenuName = opt.name;
draggedId = rawId - 1;
draggedOpt = opt;
Expand Down
3 changes: 3 additions & 0 deletions core/src/gui/widgets/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ class Menu {

std::vector<MenuOption_t> order;

bool locked = false;

private:
bool isInOrderList(std::string name);


bool menuClicked = false;
std::string clickedMenuName = "";
std::string draggedMenuName = "";
Expand Down

0 comments on commit 8d78eb3

Please sign in to comment.