File indexing completed on 2023-12-03 04:55:10
0001 /* 0002 SPDX-FileCopyrightText: 2017 Jean-Baptiste Mardelle <jb@kdenlive.org> 0003 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 #pragma once 0007 0008 #include <QWidget> 0009 #include <kselectaction.h> 0010 0011 class QAction; 0012 class DragValue; 0013 class Monitor; 0014 0015 /** @class GeometryWidget 0016 @brief A widget for modifying numbers by dragging, using the mouse wheel or entering them with the keyboard. 0017 */ 0018 class GeometryWidget : public QWidget 0019 { 0020 Q_OBJECT 0021 0022 public: 0023 /** 0024 * @brief Default constructor. 0025 * @param monitor The monitor attached to this stack 0026 * @param range The in / out points of the clip, useful to deactivate monitor scene when out of bounds 0027 * @param rect The default geometry value 0028 * @param frameSize The frame size of the original source video 0029 * @param useRatioLock When true, width/height will keep the profile's aspect ratio on resize 0030 */ 0031 explicit GeometryWidget(Monitor *monitor, QPair<int, int> range, const QRect &rect, double opacity, const QSize frameSize, bool useRatioLock, 0032 bool useOpacity, QWidget *parent = nullptr); 0033 void setValue(const QRect r, double opacity = 1); 0034 void connectMonitor(bool activate); 0035 0036 private: 0037 int m_min; 0038 int m_max; 0039 bool m_active; 0040 Monitor *m_monitor; 0041 DragValue *m_spinX; 0042 DragValue *m_spinY; 0043 DragValue *m_spinWidth; 0044 DragValue *m_spinHeight; 0045 DragValue *m_spinSize; 0046 DragValue *m_opacity; 0047 double m_opacityFactor; 0048 QSize m_defaultSize; 0049 QSize m_sourceSize; 0050 QAction *m_originalSize; 0051 QAction *m_lockRatio; 0052 const QString getValue() const; 0053 void adjustSizeValue(); 0054 0055 public Q_SLOTS: 0056 void slotUpdateGeometryRect(const QRect r); 0057 void slotSetRange(QPair<int, int>); 0058 0059 private Q_SLOTS: 0060 void slotAdjustRectKeyframeValue(); 0061 void slotAdjustToSource(); 0062 void slotAdjustToFrameSize(); 0063 void slotFitToWidth(); 0064 void slotFitToHeight(); 0065 void slotResize(double value); 0066 /** @brief Moves the rect to the left frame border (x position = 0). */ 0067 void slotMoveLeft(); 0068 /** @brief Centers the rect horizontally. */ 0069 void slotCenterH(); 0070 /** @brief Moves the rect to the right frame border (x position = frame width - rect width). */ 0071 void slotMoveRight(); 0072 /** @brief Moves the rect to the top frame border (y position = 0). */ 0073 void slotMoveTop(); 0074 /** @brief Centers the rect vertically. */ 0075 void slotCenterV(); 0076 /** @brief Moves the rect to the bottom frame border (y position = frame height - rect height). */ 0077 void slotMoveBottom(); 0078 /** @brief Un/Lock aspect ratio for size in effect parameter. */ 0079 void slotLockRatio(); 0080 void slotAdjustRectHeight(); 0081 void slotAdjustRectWidth(); 0082 0083 Q_SIGNALS: 0084 void valueChanged(const QString val); 0085 void updateMonitorGeometry(const QRect r); 0086 };