From 685cf785153e7cfea5cd2c41a1a3e5f410947541 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sun, 30 May 2021 11:52:13 -0700 Subject: [PATCH] Added option to choose the axis icon location. Closes #638. --- common/lc_application.cpp | 2 ++ common/lc_application.h | 9 +++++++++ common/lc_profile.cpp | 1 + common/lc_profile.h | 1 + common/lc_view.cpp | 22 +++++++++++++++++++++- qt/lc_qpreferencesdialog.cpp | 3 +++ qt/lc_qpreferencesdialog.ui | 32 ++++++++++++++++++++++++++++++++ 7 files changed, 69 insertions(+), 1 deletion(-) diff --git a/common/lc_application.cpp b/common/lc_application.cpp index 575ea77f..ff595100 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -24,6 +24,7 @@ void lcPreferences::LoadDefaults() mBackgroundGradientColorTop = lcGetProfileInt(LC_PROFILE_GRADIENT_COLOR_TOP); mBackgroundGradientColorBottom = lcGetProfileInt(LC_PROFILE_GRADIENT_COLOR_BOTTOM); mDrawAxes = lcGetProfileInt(LC_PROFILE_DRAW_AXES); + mAxisIconLocation = static_cast(lcGetProfileInt(LC_PROFILE_DRAW_AXES_LOCATION)); mAxesColor = lcGetProfileInt(LC_PROFILE_AXES_COLOR); mTextColor = lcGetProfileInt(LC_PROFILE_TEXT_COLOR); mMarqueeBorderColor = lcGetProfileInt(LC_PROFILE_MARQUEE_BORDER_COLOR); @@ -74,6 +75,7 @@ void lcPreferences::SaveDefaults() lcSetProfileInt(LC_PROFILE_MOUSE_SENSITIVITY, mMouseSensitivity); lcSetProfileInt(LC_PROFILE_SHADING_MODE, static_cast(mShadingMode)); lcSetProfileInt(LC_PROFILE_DRAW_AXES, mDrawAxes); + lcSetProfileInt(LC_PROFILE_DRAW_AXES_LOCATION, static_cast(mAxisIconLocation)); lcSetProfileInt(LC_PROFILE_AXES_COLOR, mAxesColor); lcSetProfileInt(LC_PROFILE_TEXT_COLOR, mTextColor); lcSetProfileInt(LC_PROFILE_BACKGROUND_GRADIENT, mBackgroundGradient); diff --git a/common/lc_application.h b/common/lc_application.h index 4eef1997..a22f46a9 100644 --- a/common/lc_application.h +++ b/common/lc_application.h @@ -21,6 +21,14 @@ enum class lcColorTheme System }; +enum class lcAxisIconLocation +{ + TopLeft, + TopRight, + BottomLeft, + BottomRight +}; + class lcPreferences { public: @@ -35,6 +43,7 @@ public: quint32 mBackgroundGradientColorTop; quint32 mBackgroundGradientColorBottom; bool mDrawAxes; + lcAxisIconLocation mAxisIconLocation; quint32 mAxesColor; quint32 mTextColor; quint32 mMarqueeBorderColor; diff --git a/common/lc_profile.cpp b/common/lc_profile.cpp index c7511a8a..1975b586 100644 --- a/common/lc_profile.cpp +++ b/common/lc_profile.cpp @@ -70,6 +70,7 @@ static lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] = lcProfileEntry("Settings", "GradientColorTop", LC_RGB(54, 72, 95)), // LC_PROFILE_GRADIENT_COLOR_TOP lcProfileEntry("Settings", "GradientColorBottom", LC_RGB(49, 52, 55)), // LC_PROFILE_GRADIENT_COLOR_BOTTOM lcProfileEntry("Settings", "DrawAxes", 0), // LC_PROFILE_DRAW_AXES + lcProfileEntry("Settings", "DrawAxesLocation", static_cast(lcAxisIconLocation::BottomLeft)), // LC_PROFILE_DRAW_AXES_LOCATION lcProfileEntry("Settings", "AxesColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_AXES_COLOR lcProfileEntry("Settings", "TextColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_TEXT_COLOR lcProfileEntry("Settings", "MarqueeBorderColor", LC_RGBA(64, 64, 255, 255)), // LC_PROFILE_MARQUEE_BORDER_COLOR diff --git a/common/lc_profile.h b/common/lc_profile.h index a6992869..abfef7e5 100644 --- a/common/lc_profile.h +++ b/common/lc_profile.h @@ -17,6 +17,7 @@ enum LC_PROFILE_KEY LC_PROFILE_GRADIENT_COLOR_TOP, LC_PROFILE_GRADIENT_COLOR_BOTTOM, LC_PROFILE_DRAW_AXES, + LC_PROFILE_DRAW_AXES_LOCATION, LC_PROFILE_AXES_COLOR, LC_PROFILE_TEXT_COLOR, LC_PROFILE_MARQUEE_BORDER_COLOR, diff --git a/common/lc_view.cpp b/common/lc_view.cpp index 133939f9..13f17bb8 100644 --- a/common/lc_view.cpp +++ b/common/lc_view.cpp @@ -1239,7 +1239,27 @@ void lcView::DrawAxes() const 21, 22, 23, 21, 23, 24, 21, 24, 25, 21, 25, 26, 21, 26, 27, 21, 27, 28, 21, 28, 29, 21, 29, 22 }; - lcMatrix44 TranslationMatrix = lcMatrix44Translation(lcVector3(30.375f, 30.375f, 0.0f)); + lcMatrix44 TranslationMatrix; + + switch (Preferences.mAxisIconLocation) + { + default: + case lcAxisIconLocation::BottomLeft: + TranslationMatrix = lcMatrix44Translation(lcVector3(32, 32, 0.0f)); + break; + + case lcAxisIconLocation::BottomRight: + TranslationMatrix = lcMatrix44Translation(lcVector3(mWidth - 36, 32, 0.0f)); + break; + + case lcAxisIconLocation::TopLeft: + TranslationMatrix = lcMatrix44Translation(lcVector3(32, mHeight - 36, 0.0f)); + break; + + case lcAxisIconLocation::TopRight: + TranslationMatrix = lcMatrix44Translation(lcVector3(mWidth - 36, mHeight - 36, 0.0f)); + break; + } lcMatrix44 WorldViewMatrix = mCamera->mWorldView; WorldViewMatrix.SetTranslation(lcVector3(0, 0, 0)); diff --git a/qt/lc_qpreferencesdialog.cpp b/qt/lc_qpreferencesdialog.cpp index e8998588..89f86aad 100644 --- a/qt/lc_qpreferencesdialog.cpp +++ b/qt/lc_qpreferencesdialog.cpp @@ -121,6 +121,8 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO ui->GridOriginCheckBox->setChecked(mOptions->Preferences.mDrawGridOrigin); ui->AxisIconCheckBox->setChecked(mOptions->Preferences.mDrawAxes); + ui->AxisIconLocationCombo->setCurrentIndex((int)mOptions->Preferences.mAxisIconLocation); + if (!mOptions->Preferences.mBackgroundGradient) ui->BackgroundSolidRadio->setChecked(true); else @@ -294,6 +296,7 @@ void lcQPreferencesDialog::accept() mOptions->Preferences.mBackgroundGradient = ui->BackgroundGradientRadio->isChecked(); mOptions->Preferences.mDrawAxes = ui->AxisIconCheckBox->isChecked(); + mOptions->Preferences.mAxisIconLocation = (lcAxisIconLocation)ui->AxisIconLocationCombo->currentIndex(); mOptions->Preferences.mViewSphereEnabled = ui->ViewSphereSizeCombo->currentIndex() > 0; mOptions->Preferences.mViewSphereLocation = (lcViewSphereLocation)ui->ViewSphereLocationCombo->currentIndex(); diff --git a/qt/lc_qpreferencesdialog.ui b/qt/lc_qpreferencesdialog.ui index bd50f81d..3acb423c 100644 --- a/qt/lc_qpreferencesdialog.ui +++ b/qt/lc_qpreferencesdialog.ui @@ -705,6 +705,37 @@ + + + + Location: + + + + + + + + Top Left + + + + + Top Right + + + + + Bottom Left + + + + + Bottom Right + + + + @@ -1782,6 +1813,7 @@ ViewSphereSizeCombo ViewSphereLocationCombo AxisIconCheckBox + AxisIconLocationCombo gridStuds gridLines gridLineSpacing