OBSPreviewScalingComboBox.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /******************************************************************************
  2. Copyright (C) 2024 by Taylor Giampaolo <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #pragma once
  15. #include <QComboBox>
  16. class OBSPreviewScalingComboBox : public QComboBox {
  17. Q_OBJECT
  18. public:
  19. OBSPreviewScalingComboBox(QWidget *parent = nullptr) : QComboBox(parent) {}
  20. inline void SetCanvasSize(uint32_t width, uint32_t height)
  21. {
  22. canvas_width = width;
  23. canvas_height = height;
  24. };
  25. inline void SetOutputSize(uint32_t width, uint32_t height)
  26. {
  27. output_width = width;
  28. output_height = height;
  29. };
  30. void UpdateAllText();
  31. public slots:
  32. void PreviewScaleChanged(float scale);
  33. void PreviewFixedScalingChanged(bool fixed);
  34. void CanvasResized(uint32_t width, uint32_t height);
  35. void OutputResized(uint32_t width, uint32_t height);
  36. private:
  37. uint32_t canvas_width = 0;
  38. uint32_t canvas_height = 0;
  39. uint32_t output_width = 0;
  40. uint32_t output_height = 0;
  41. float previewScale = 0.0f;
  42. bool fixedScaling = false;
  43. bool scaleOutputEnabled = false;
  44. void SetScaleOutputEnabled(bool show);
  45. void UpdateCanvasText();
  46. void UpdateOutputText();
  47. void UpdateScaledText();
  48. void UpdateSelection();
  49. };