Updated to ImGui 1.87 to cleanup UI code

This commit is contained in:
AlexandreRouma
2022-02-14 23:33:52 +01:00
parent 04e54a2d57
commit 51c940acd4
47 changed files with 2018 additions and 1069 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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));

View File

@ -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;