ViewportSettingsWidgets.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Core/Widgets/ViewportSettingsWidgets.h>
  9. #include <EditorViewportSettings.h>
  10. ViewportFieldOfViewPropertyWidget::ViewportFieldOfViewPropertyWidget()
  11. {
  12. // Set label name.
  13. m_label->setText("Field of View");
  14. // Set suffix on SpinBox
  15. m_spinBox->setSuffix(" deg");
  16. // Set starting value.
  17. m_spinBox->setValue(SandboxEditor::CameraDefaultFovDegrees());
  18. // Set minimum and maximun.
  19. // These should be set after the starting value if the default (0.0) is outside the range.
  20. m_spinBox->setMinimum(30.0);
  21. m_spinBox->setMaximum(120.0);
  22. const int DefaultViewportId = 0;
  23. AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Handler::BusConnect(DefaultViewportId);
  24. }
  25. ViewportFieldOfViewPropertyWidget::~ViewportFieldOfViewPropertyWidget()
  26. {
  27. AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Handler::BusDisconnect();
  28. }
  29. void ViewportFieldOfViewPropertyWidget::OnSpinBoxValueChanged(double newValue)
  30. {
  31. SandboxEditor::SetCameraDefaultFovDegrees(aznumeric_cast<float>(newValue));
  32. }
  33. void ViewportFieldOfViewPropertyWidget::OnCameraFovChanged(float fovRadians)
  34. {
  35. const float fovDegrees = AZ::RadToDeg(fovRadians);
  36. // Prevent signaling to avoid infinite loop.
  37. m_spinBox->blockSignals(true);
  38. m_spinBox->setValue(fovDegrees);
  39. m_spinBox->blockSignals(false);
  40. }
  41. ViewportCameraSpeedScalePropertyWidget::ViewportCameraSpeedScalePropertyWidget()
  42. {
  43. // Set label name.
  44. m_label->setText("Camera Speed Scale");
  45. // Set starting value.
  46. m_spinBox->setValue(SandboxEditor::CameraSpeedScale());
  47. const int DefaultViewportId = 0;
  48. AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Handler::BusConnect(DefaultViewportId);
  49. }
  50. ViewportCameraSpeedScalePropertyWidget::~ViewportCameraSpeedScalePropertyWidget()
  51. {
  52. AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Handler::BusDisconnect();
  53. }
  54. void ViewportCameraSpeedScalePropertyWidget::OnSpinBoxValueChanged(double newValue)
  55. {
  56. SandboxEditor::SetCameraSpeedScale(aznumeric_cast<float>(newValue));
  57. }
  58. void ViewportCameraSpeedScalePropertyWidget::OnCameraSpeedScaleChanged(float value)
  59. {
  60. // Prevent signaling to avoid infinite loop.
  61. m_spinBox->blockSignals(true);
  62. m_spinBox->setValue(value);
  63. m_spinBox->blockSignals(false);
  64. }
  65. ViewportGridSnappingSizePropertyWidget::ViewportGridSnappingSizePropertyWidget()
  66. {
  67. // Set label name.
  68. m_label->setText("Grid Snapping Size");
  69. // Set suffix on SpinBox
  70. m_spinBox->setSuffix(" m");
  71. // Set starting value.
  72. m_spinBox->setValue(SandboxEditor::GridSnappingSize());
  73. }
  74. void ViewportGridSnappingSizePropertyWidget::OnSpinBoxValueChanged(double newValue)
  75. {
  76. SandboxEditor::SetGridSnappingSize(aznumeric_cast<float>(newValue));
  77. }
  78. ViewportAngleSnappingSizePropertyWidget::ViewportAngleSnappingSizePropertyWidget()
  79. {
  80. // Set label name.
  81. m_label->setText("Angle Snapping Size");
  82. // Set suffix on SpinBox
  83. m_spinBox->setSuffix(" deg");
  84. // Set starting value.
  85. m_spinBox->setValue(SandboxEditor::AngleSnappingSize());
  86. }
  87. void ViewportAngleSnappingSizePropertyWidget::OnSpinBoxValueChanged(double newValue)
  88. {
  89. SandboxEditor::SetAngleSnappingSize(aznumeric_cast<float>(newValue));
  90. }