mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-28 21:37:50 +02:00
Updated to ImGui 1.87 to cleanup UI code
This commit is contained in:
@ -28,7 +28,6 @@
|
||||
#include <gui/colormaps.h>
|
||||
#include <gui/widgets/snr_meter.h>
|
||||
#include <gui/tuner.h>
|
||||
#include <keybinds.h>
|
||||
|
||||
void MainWindow::init() {
|
||||
LoadingScreen::show("Initializing UI");
|
||||
@ -358,7 +357,7 @@ void MainWindow::draw() {
|
||||
// To Bar
|
||||
ImVec2 btnSize(30 * style::uiScale, 30 * style::uiScale);
|
||||
ImGui::PushID(ImGui::GetID("sdrpp_menu_btn"));
|
||||
if (ImGui::ImageButton(icons::MENU, btnSize, ImVec2(0, 0), ImVec2(1, 1), 5) || ImGui::IsKeyPressed(KB_KEY_MENU, false)) {
|
||||
if (ImGui::ImageButton(icons::MENU, btnSize, ImVec2(0, 0), ImVec2(1, 1), 5) || ImGui::IsKeyPressed(ImGuiKey_Menu, false)) {
|
||||
showMenu = !showMenu;
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["showMenu"] = showMenu;
|
||||
@ -372,14 +371,14 @@ void MainWindow::draw() {
|
||||
if (playButtonLocked && !tmpPlaySate) { style::beginDisabled(); }
|
||||
if (playing) {
|
||||
ImGui::PushID(ImGui::GetID("sdrpp_stop_btn"));
|
||||
if (ImGui::ImageButton(icons::STOP, btnSize, ImVec2(0, 0), ImVec2(1, 1), 5) || ImGui::IsKeyPressed(KB_KEY_END, false)) {
|
||||
if (ImGui::ImageButton(icons::STOP, btnSize, ImVec2(0, 0), ImVec2(1, 1), 5) || ImGui::IsKeyPressed(ImGuiKey_End, false)) {
|
||||
setPlayState(false);
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
else { // TODO: Might need to check if there even is a device
|
||||
ImGui::PushID(ImGui::GetID("sdrpp_play_btn"));
|
||||
if (ImGui::ImageButton(icons::PLAY, btnSize, ImVec2(0, 0), ImVec2(1, 1), 5) || ImGui::IsKeyPressed(KB_KEY_END, false)) {
|
||||
if (ImGui::ImageButton(icons::PLAY, btnSize, ImVec2(0, 0), ImVec2(1, 1), 5) || ImGui::IsKeyPressed(ImGuiKey_End, false)) {
|
||||
setPlayState(true);
|
||||
}
|
||||
ImGui::PopID();
|
||||
@ -444,7 +443,7 @@ void MainWindow::draw() {
|
||||
if (ImGui::IsMouseDown(ImGuiMouseButton_Left)) {
|
||||
showCredits = false;
|
||||
}
|
||||
if (ImGui::IsKeyPressed(KB_KEY_ESC)) {
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||
showCredits = false;
|
||||
}
|
||||
|
||||
@ -562,12 +561,12 @@ void MainWindow::draw() {
|
||||
if (!lockWaterfallControls) {
|
||||
// Handle arrow keys
|
||||
if (vfo != NULL && (gui::waterfall.mouseInFFT || gui::waterfall.mouseInWaterfall)) {
|
||||
if (ImGui::IsKeyPressed(KB_KEY_LEFT) && !gui::freqSelect.digitHovered) {
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_LeftArrow) && !gui::freqSelect.digitHovered) {
|
||||
double nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset - vfo->snapInterval;
|
||||
nfreq = roundl(nfreq / vfo->snapInterval) * vfo->snapInterval;
|
||||
tuner::tune(tuningMode, gui::waterfall.selectedVFO, nfreq);
|
||||
}
|
||||
if (ImGui::IsKeyPressed(KB_KEY_RIGHT) && !gui::freqSelect.digitHovered) {
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_RightArrow) && !gui::freqSelect.digitHovered) {
|
||||
double nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset + vfo->snapInterval;
|
||||
nfreq = roundl(nfreq / vfo->snapInterval) * vfo->snapInterval;
|
||||
tuner::tune(tuningMode, gui::waterfall.selectedVFO, nfreq);
|
||||
|
@ -35,7 +35,7 @@ namespace bandplanmenu {
|
||||
}
|
||||
|
||||
void draw(void* ctx) {
|
||||
float menuColumnWidth = ImGui::GetContentRegionAvailWidth();
|
||||
float menuColumnWidth = ImGui::GetContentRegionAvail().x;
|
||||
ImGui::PushItemWidth(menuColumnWidth);
|
||||
if (ImGui::Combo("##_bandplan_name_", &bandplanId, bandplan::bandplanNameTxt.c_str())) {
|
||||
gui::waterfall.bandplan = &bandplan::bandplans[bandplan::bandplanNames[bandplanId]];
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include <gui/main_window.h>
|
||||
#include <signal_path/signal_path.h>
|
||||
#include <gui/style.h>
|
||||
#include <keybinds.h>
|
||||
|
||||
namespace displaymenu {
|
||||
bool showWaterfall;
|
||||
@ -89,8 +88,8 @@ namespace displaymenu {
|
||||
}
|
||||
|
||||
void draw(void* ctx) {
|
||||
float menuWidth = ImGui::GetContentRegionAvailWidth();
|
||||
bool homePressed = ImGui::IsKeyPressed(KB_KEY_HOME, false);
|
||||
float menuWidth = ImGui::GetContentRegionAvail().x;
|
||||
bool homePressed = ImGui::IsKeyPressed(ImGuiKey_Home, false);
|
||||
if (ImGui::Checkbox("Show Waterfall##_sdrpp", &showWaterfall) || homePressed) {
|
||||
if (homePressed) { showWaterfall = !showWaterfall; }
|
||||
showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall();
|
||||
|
@ -80,11 +80,11 @@ namespace module_manager_menu {
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth());
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||
ImGui::InputText("##module_mod_name", modName, 1000);
|
||||
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth());
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||
ImGui::Combo("##module_mgr_type", &modTypeId, modTypesTxt.c_str());
|
||||
|
||||
ImGui::TableSetColumnIndex(2);
|
||||
|
@ -156,7 +156,7 @@ namespace sourcemenu {
|
||||
}
|
||||
|
||||
void draw(void* ctx) {
|
||||
float itemWidth = ImGui::GetContentRegionAvailWidth();
|
||||
float itemWidth = ImGui::GetContentRegionAvail().x;
|
||||
bool running = gui::mainWindow.sdrIsRunning();
|
||||
|
||||
if (running) { style::beginDisabled(); }
|
||||
|
@ -41,7 +41,7 @@ namespace thememenu {
|
||||
}
|
||||
|
||||
void draw(void* ctx) {
|
||||
float menuWidth = ImGui::GetContentRegionAvailWidth();
|
||||
float menuWidth = ImGui::GetContentRegionAvail().x;
|
||||
ImGui::LeftLabel("Theme");
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::Combo("##theme_select_combo", &themeId, themeNamesTxt.c_str())) {
|
||||
|
@ -81,7 +81,7 @@ namespace vfo_color_menu {
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
if (ImGui::Button("Auto Color##vfo_color", ImVec2(ImGui::GetContentRegionAvailWidth(), 0))) {
|
||||
if (ImGui::Button("Auto Color##vfo_color", ImVec2(ImGui::GetContentRegionAvail().x, 0))) {
|
||||
float delta = 1.0f / (float)gui::waterfall.vfos.size();
|
||||
float hue = 0;
|
||||
for (auto& [name, vfo] : gui::waterfall.vfos) {
|
||||
@ -99,7 +99,7 @@ namespace vfo_color_menu {
|
||||
}
|
||||
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
if (ImGui::Button("Clear All##vfo_color", ImVec2(ImGui::GetContentRegionAvailWidth(), 0))) {
|
||||
if (ImGui::Button("Clear All##vfo_color", ImVec2(ImGui::GetContentRegionAvail().x, 0))) {
|
||||
for (auto& [name, vfo] : gui::waterfall.vfos) {
|
||||
vfoColors[name] = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
vfo->color = IM_COL32(255, 255, 255, 50);
|
||||
|
@ -459,7 +459,7 @@ namespace SmGui {
|
||||
void FillWidth() {
|
||||
if (!options::opts.serverMode) {
|
||||
nextItemFillWidth = true;
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth());
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||
return;
|
||||
}
|
||||
if (rdl) { rdl->pushStep(DRAW_STEP_FILL_WIDTH, false); }
|
||||
@ -504,7 +504,7 @@ namespace SmGui {
|
||||
if (!options::opts.serverMode) {
|
||||
if (nextItemFillWidth) {
|
||||
nextItemFillWidth = false;
|
||||
size.x = ImGui::GetContentRegionAvailWidth();
|
||||
size.x = ImGui::GetContentRegionAvail().x;
|
||||
}
|
||||
return ImGui::Button(label, size);
|
||||
}
|
||||
|
@ -70,6 +70,6 @@ namespace ImGui {
|
||||
}
|
||||
|
||||
void FillWidth() {
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth());
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ FileSelect::FileSelect(std::string defaultPath, std::vector<std::string> filter)
|
||||
|
||||
bool FileSelect::render(std::string id) {
|
||||
bool _pathChanged = false;
|
||||
float menuColumnWidth = ImGui::GetContentRegionAvailWidth();
|
||||
float menuColumnWidth = ImGui::GetContentRegionAvail().x;
|
||||
|
||||
float buttonWidth = ImGui::CalcTextSize("...").x + 20.0f;
|
||||
bool lastPathValid = pathValid;
|
||||
|
@ -10,7 +10,7 @@ FolderSelect::FolderSelect(std::string defaultPath) {
|
||||
|
||||
bool FolderSelect::render(std::string id) {
|
||||
bool _pathChanged = false;
|
||||
float menuColumnWidth = ImGui::GetContentRegionAvailWidth();
|
||||
float menuColumnWidth = ImGui::GetContentRegionAvail().x;
|
||||
|
||||
float buttonWidth = ImGui::CalcTextSize("...").x + 20.0f;
|
||||
bool lastPathValid = pathValid;
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include <gui/style.h>
|
||||
#include <gui/gui.h>
|
||||
#include <backend.h>
|
||||
#include <keybinds.h>
|
||||
|
||||
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
@ -155,23 +154,23 @@ void FrequencySelect::draw() {
|
||||
}
|
||||
if (onDigit) {
|
||||
hovered = true;
|
||||
if (rightClick || (ImGui::IsKeyPressed(KB_KEY_DEL) || ImGui::IsKeyPressed(KB_KEY_ENTER) || ImGui::IsKeyPressed(KB_KEY_KP_ENTER))) {
|
||||
if (rightClick || (ImGui::IsKeyPressed(ImGuiKey_Delete) || ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::IsKeyPressed(ImGuiKey_KeypadEnter))) {
|
||||
for (int j = i; j < 12; j++) {
|
||||
digits[j] = 0;
|
||||
}
|
||||
|
||||
frequencyChanged = true;
|
||||
}
|
||||
if (ImGui::IsKeyPressed(KB_KEY_UP)) {
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_UpArrow)) {
|
||||
incrementDigit(i);
|
||||
}
|
||||
if (ImGui::IsKeyPressed(KB_KEY_DOWN)) {
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_DownArrow)) {
|
||||
decrementDigit(i);
|
||||
}
|
||||
if ((ImGui::IsKeyPressed(KB_KEY_LEFT) || ImGui::IsKeyPressed(KB_KEY_BACKSPACE)) && i > 0) {
|
||||
if ((ImGui::IsKeyPressed(ImGuiKey_LeftArrow) || ImGui::IsKeyPressed(ImGuiKey_Backspace)) && i > 0) {
|
||||
moveCursorToDigit(i - 1);
|
||||
}
|
||||
if (ImGui::IsKeyPressed(KB_KEY_RIGHT) && i < 11) {
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_RightArrow) && i < 11) {
|
||||
moveCursorToDigit(i + 1);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ void Menu::removeEntry(std::string name) {
|
||||
|
||||
bool Menu::draw(bool updateStates) {
|
||||
bool changed = false;
|
||||
float menuWidth = ImGui::GetContentRegionAvailWidth();
|
||||
float menuWidth = ImGui::GetContentRegionAvail().x;
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||
ImVec2 checkboxOffset = ImVec2(menuWidth - ImGui::GetTextLineHeight() - (6.0f * style::uiScale), - ImGui::GetTextLineHeight() - (10.0f * style::uiScale));
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <gui/gui.h>
|
||||
#include <gui/style.h>
|
||||
#include <keybinds.h>
|
||||
|
||||
float DEFAULT_COLOR_MAP[][3] = {
|
||||
{ 0x00, 0x00, 0x20 },
|
||||
@ -390,8 +389,8 @@ namespace ImGui {
|
||||
}
|
||||
|
||||
// If the left and right keys are pressed while hovering the freq scale, move it too
|
||||
bool leftKeyPressed = ImGui::IsKeyPressed(KB_KEY_LEFT);
|
||||
if ((leftKeyPressed || ImGui::IsKeyPressed(KB_KEY_RIGHT)) && mouseInFreq) {
|
||||
bool leftKeyPressed = ImGui::IsKeyPressed(ImGuiKey_LeftArrow);
|
||||
if ((leftKeyPressed || ImGui::IsKeyPressed(ImGuiKey_RightArrow)) && mouseInFreq) {
|
||||
viewOffset += leftKeyPressed ? (viewBandwidth / 20.0) : (-viewBandwidth / 20.0);
|
||||
|
||||
if (viewOffset + (viewBandwidth / 2.0) > wholeBandwidth / 2.0) {
|
||||
@ -438,7 +437,7 @@ namespace ImGui {
|
||||
|
||||
ImGui::TextUnformatted(name.c_str());
|
||||
|
||||
if (ImGui::IsKeyDown(KB_KEY_LCTRL) || ImGui::IsKeyDown(KB_KEY_RCTRL)) {
|
||||
if (ImGui::GetIO().KeyCtrl) {
|
||||
ImGui::Separator();
|
||||
printAndScale(_vfo->generalOffset + centerFreq, buf);
|
||||
ImGui::Text("Frequency: %sHz", buf);
|
||||
@ -464,7 +463,7 @@ namespace ImGui {
|
||||
}
|
||||
|
||||
// Handle Page Up to cycle through VFOs
|
||||
if (ImGui::IsKeyPressed(KB_KEY_PG_UP) && selVfo != NULL) {
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_PageUp) && selVfo != NULL) {
|
||||
std::string next = (--vfos.end())->first;
|
||||
std::string lowest = "";
|
||||
double lowestOffset = INFINITY;
|
||||
@ -487,7 +486,7 @@ namespace ImGui {
|
||||
}
|
||||
|
||||
// Handle Page Down to cycle through VFOs
|
||||
if (ImGui::IsKeyPressed(KB_KEY_PG_DOWN) && selVfo != NULL) {
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_PageDown) && selVfo != NULL) {
|
||||
std::string next = (--vfos.end())->first;
|
||||
std::string highest = "";
|
||||
double highestOffset = -INFINITY;
|
||||
|
Reference in New Issue
Block a user