1 /*
2     SPDX-FileCopyrightText: 2017 Jean-Baptiste Mardelle <jb@kdenlive.org>
3     SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
4 */
5 
6 #ifndef GEOMETRYWIDGET2_H
7 #define GEOMETRYWIDGET2_H
8 
9 #include <QWidget>
10 #include <kselectaction.h>
11 
12 class QAction;
13 class DragValue;
14 class Monitor;
15 
16 /** @class GeometryWidget
17     @brief A widget for modifying numbers by dragging, using the mouse wheel or entering them with the keyboard.
18  */
19 class GeometryWidget : public QWidget
20 {
21     Q_OBJECT
22 
23 public:
24     /**
25      * @brief Default constructor.
26      * @param monitor The monitor attached to this stack
27      * @param range The in / out points of the clip, useful to deactivate monitor scene when out of bounds
28      * @param rect The default geometry value
29      * @param frameSize The frame size of the original source video
30      * @param useRatioLock When true, width/height will keep the profile's aspect ratio on resize
31      */
32     explicit GeometryWidget(Monitor *monitor, QPair<int, int> range, const QRect &rect, double opacity, const QSize frameSize, bool useRatioLock,
33                             bool useOpacity, QWidget *parent = nullptr);
34     void setValue(const QRect r, double opacity = 1);
35     void connectMonitor(bool activate);
36 
37 private:
38     int m_min;
39     int m_max;
40     bool m_active;
41     Monitor *m_monitor;
42     DragValue *m_spinX;
43     DragValue *m_spinY;
44     DragValue *m_spinWidth;
45     DragValue *m_spinHeight;
46     DragValue *m_spinSize;
47     DragValue *m_opacity;
48     double m_opacityFactor;
49     QSize m_defaultSize;
50     QSize m_sourceSize;
51     QAction *m_originalSize;
52     QAction *m_lockRatio;
53     const QString getValue() const;
54     void adjustSizeValue();
55 
56 public slots:
57     void slotUpdateGeometryRect(const QRect r);
58     void slotSetRange(QPair<int, int>);
59 
60 private slots:
61     void slotAdjustRectKeyframeValue();
62     void slotAdjustToSource();
63     void slotAdjustToFrameSize();
64     void slotFitToWidth();
65     void slotFitToHeight();
66     void slotResize(double value);
67     /** @brief Moves the rect to the left frame border (x position = 0). */
68     void slotMoveLeft();
69     /** @brief Centers the rect horizontally. */
70     void slotCenterH();
71     /** @brief Moves the rect to the right frame border (x position = frame width - rect width). */
72     void slotMoveRight();
73     /** @brief Moves the rect to the top frame border (y position = 0). */
74     void slotMoveTop();
75     /** @brief Centers the rect vertically. */
76     void slotCenterV();
77     /** @brief Moves the rect to the bottom frame border (y position = frame height - rect height). */
78     void slotMoveBottom();
79     /** @brief Un/Lock aspect ratio for size in effect parameter. */
80     void slotLockRatio();
81     void slotAdjustRectHeight();
82     void slotAdjustRectWidth();
83 
84 signals:
85     void valueChanged(const QString val);
86     void updateMonitorGeometry(const QRect r);
87 };
88 
89 #endif
90