Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Multimedia
Kdenlive
Commits
243dff06
Commit
243dff06
authored
Mar 22, 2017
by
Jean-Baptiste Mardelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to lock aspect ratio in geometry effects/transitions
parent
3d53f186
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
287 additions
and
63 deletions
+287
-63
data/kdenlivemonitoreffectscene.qml
data/kdenlivemonitoreffectscene.qml
+53
-16
src/effectstack/widgets/animationwidget.cpp
src/effectstack/widgets/animationwidget.cpp
+110
-23
src/effectstack/widgets/animationwidget.h
src/effectstack/widgets/animationwidget.h
+5
-0
src/effectstack/widgets/geometrywidget.cpp
src/effectstack/widgets/geometrywidget.cpp
+97
-23
src/effectstack/widgets/geometrywidget.h
src/effectstack/widgets/geometrywidget.h
+5
-1
src/kdenlivesettings.kcfg
src/kdenlivesettings.kcfg
+6
-0
src/monitor/monitor.cpp
src/monitor/monitor.cpp
+9
-0
src/monitor/monitor.h
src/monitor/monitor.h
+2
-0
No files found.
data/kdenlivemonitoreffectscene.qml
View file @
243dff06
...
...
@@ -16,6 +16,7 @@ Item {
property
double
scaley
property
double
offsetx
:
0
property
double
offsety
:
0
property
double
lockratio
:
-
1
onScalexChanged
:
canvas
.
requestPaint
()
onScaleyChanged
:
canvas
.
requestPaint
()
onOffsetxChanged
:
canvas
.
requestPaint
()
...
...
@@ -224,7 +225,7 @@ Item {
color
:
"
transparent
"
border.color
:
"
#ffff0000
"
Rectangle
{
id
:
"
tlhandle
"
id
:
tlhandle
anchors
{
top
:
parent
.
top
left
:
parent
.
left
...
...
@@ -249,10 +250,20 @@ Item {
}
onPositionChanged
:
{
if
(
pressed
)
{
framesize
.
x
=
(
framerect
.
x
+
(
mouseX
-
oldMouseX
)
-
frame
.
x
)
/
root
.
scalex
;
framesize
.
width
=
(
framerect
.
width
-
(
mouseX
-
oldMouseX
))
/
root
.
scalex
;
framesize
.
y
=
(
framerect
.
y
+
(
mouseY
-
oldMouseY
)
-
frame
.
y
)
/
root
.
scaley
;
framesize
.
height
=
(
framerect
.
height
-
(
mouseY
-
oldMouseY
))
/
root
.
scaley
;
if
(
root
.
lockratio
>
0
)
{
var
delta
=
Math
.
max
(
mouseX
-
oldMouseX
,
mouseY
-
oldMouseY
)
var
newwidth
=
framerect
.
width
-
delta
var
newheight
=
newwidth
/
root
.
lockratio
framesize
.
x
=
(
framerect
.
x
+
(
framerect
.
width
-
newwidth
)
-
frame
.
x
)
/
root
.
scalex
;
framesize
.
width
=
newwidth
/
root
.
scalex
;
framesize
.
y
=
(
framerect
.
y
+
(
framerect
.
height
-
newheight
)
-
frame
.
y
)
/
root
.
scaley
;
framesize
.
height
=
newheight
/
root
.
scaley
;
}
else
{
framesize
.
x
=
(
framerect
.
x
+
(
mouseX
-
oldMouseX
)
-
frame
.
x
)
/
root
.
scalex
;
framesize
.
width
=
(
framerect
.
width
-
(
mouseX
-
oldMouseX
))
/
root
.
scalex
;
framesize
.
y
=
(
framerect
.
y
+
(
mouseY
-
oldMouseY
)
-
frame
.
y
)
/
root
.
scaley
;
framesize
.
height
=
(
framerect
.
height
-
(
mouseY
-
oldMouseY
))
/
root
.
scaley
;
}
root
.
effectChanged
()
}
}
...
...
@@ -273,7 +284,7 @@ Item {
}
}
Rectangle
{
id
:
"
trhandle
"
id
:
trhandle
anchors
{
top
:
parent
.
top
right
:
parent
.
right
...
...
@@ -298,9 +309,18 @@ Item {
}
onPositionChanged
:
{
if
(
pressed
)
{
framesize
.
width
=
(
framerect
.
width
+
(
mouseX
-
oldMouseX
))
/
root
.
scalex
;
framesize
.
y
=
(
framerect
.
y
+
(
mouseY
-
oldMouseY
)
-
frame
.
y
)
/
root
.
scaley
;
framesize
.
height
=
(
framerect
.
height
-
(
mouseY
-
oldMouseY
))
/
root
.
scaley
;
if
(
root
.
lockratio
>
0
)
{
var
delta
=
Math
.
max
(
oldMouseX
-
mouseX
,
mouseY
-
oldMouseY
)
var
newheight
=
framerect
.
height
-
delta
var
newwidth
=
newheight
*
root
.
lockratio
framesize
.
y
=
(
framerect
.
y
+
(
framerect
.
height
-
newheight
)
-
frame
.
y
)
/
root
.
scaley
;
framesize
.
width
=
newwidth
/
root
.
scalex
;
framesize
.
height
=
newheight
/
root
.
scaley
;
}
else
{
framesize
.
width
=
(
framerect
.
width
+
(
mouseX
-
oldMouseX
))
/
root
.
scalex
;
framesize
.
y
=
(
framerect
.
y
+
(
mouseY
-
oldMouseY
)
-
frame
.
y
)
/
root
.
scaley
;
framesize
.
height
=
(
framerect
.
height
-
(
mouseY
-
oldMouseY
))
/
root
.
scaley
;
}
root
.
effectChanged
()
}
}
...
...
@@ -310,7 +330,7 @@ Item {
}
}
Rectangle
{
id
:
"
blhandle
"
id
:
blhandle
anchors
{
bottom
:
parent
.
bottom
left
:
parent
.
left
...
...
@@ -335,9 +355,18 @@ Item {
}
onPositionChanged
:
{
if
(
pressed
)
{
framesize
.
x
=
(
framerect
.
x
+
(
mouseX
-
oldMouseX
)
-
frame
.
x
)
/
root
.
scalex
;
framesize
.
width
=
(
framerect
.
width
-
(
mouseX
-
oldMouseX
))
/
root
.
scalex
;
framesize
.
height
=
(
framerect
.
height
+
(
mouseY
-
oldMouseY
))
/
root
.
scaley
;
if
(
root
.
lockratio
>
0
)
{
var
delta
=
Math
.
max
(
mouseX
-
oldMouseX
,
oldMouseY
-
mouseY
)
var
newwidth
=
framerect
.
width
-
delta
var
newheight
=
newwidth
/
root
.
lockratio
framesize
.
x
=
(
framerect
.
x
+
(
framerect
.
width
-
newwidth
)
-
frame
.
x
)
/
root
.
scalex
;
framesize
.
width
=
newwidth
/
root
.
scalex
;
framesize
.
height
=
newheight
/
root
.
scaley
;
}
else
{
framesize
.
x
=
(
framerect
.
x
+
(
mouseX
-
oldMouseX
)
-
frame
.
x
)
/
root
.
scalex
;
framesize
.
width
=
(
framerect
.
width
-
(
mouseX
-
oldMouseX
))
/
root
.
scalex
;
framesize
.
height
=
(
framerect
.
height
+
(
mouseY
-
oldMouseY
))
/
root
.
scaley
;
}
root
.
effectChanged
()
}
}
...
...
@@ -347,7 +376,7 @@ Item {
}
}
Rectangle
{
id
:
"
brhandle
"
id
:
brhandle
anchors
{
bottom
:
parent
.
bottom
right
:
parent
.
right
...
...
@@ -372,8 +401,16 @@ Item {
}
onPositionChanged
:
{
if
(
pressed
)
{
framesize
.
width
=
(
framerect
.
width
+
(
mouseX
-
oldMouseX
))
/
root
.
scalex
;
framesize
.
height
=
(
framerect
.
height
+
(
mouseY
-
oldMouseY
))
/
root
.
scaley
;
if
(
root
.
lockratio
>
0
)
{
var
delta
=
Math
.
max
(
oldMouseX
-
mouseX
,
oldMouseY
-
mouseY
)
var
newwidth
=
framerect
.
width
-
delta
var
newheight
=
newwidth
/
root
.
lockratio
framesize
.
width
=
newwidth
/
root
.
scalex
;
framesize
.
height
=
newheight
/
root
.
scaley
;
}
else
{
framesize
.
width
=
(
framerect
.
width
+
(
mouseX
-
oldMouseX
))
/
root
.
scalex
;
framesize
.
height
=
(
framerect
.
height
+
(
mouseY
-
oldMouseY
))
/
root
.
scaley
;
}
root
.
effectChanged
()
}
}
...
...
src/effectstack/widgets/animationwidget.cpp
View file @
243dff06
...
...
@@ -90,6 +90,10 @@ AnimationWidget::AnimationWidget(EffectMetaInfo *info, int clipPos, int min, int
connect
(
m_ruler
,
&
AnimKeyframeRuler
::
moveKeyframe
,
this
,
&
AnimationWidget
::
moveKeyframe
);
connect
(
m_timePos
,
SIGNAL
(
timeCodeEditingFinished
()),
this
,
SLOT
(
slotPositionChanged
()));
if
(
m_frameSize
==
QPoint
()
||
m_frameSize
.
x
()
==
0
||
m_frameSize
.
y
()
==
0
)
{
m_frameSize
=
QPoint
(
m_monitor
->
render
->
frameRenderWidth
(),
m_monitor
->
render
->
renderHeight
());
}
// seek to previous
m_previous
=
tb
->
addAction
(
KoIconUtils
::
themedIcon
(
QStringLiteral
(
"media-skip-backward"
)),
i18n
(
"Previous keyframe"
),
this
,
SLOT
(
slotPrevious
()));
...
...
@@ -591,8 +595,22 @@ void AnimationWidget::updateRect(int pos)
m_spinY
->
setValue
(
rect
.
y
);
m_spinWidth
->
setValue
(
rect
.
w
);
m_spinHeight
->
setValue
(
rect
.
h
);
double
scale
=
qMin
(
rect
.
w
/
m_monitor
->
render
->
frameRenderWidth
(),
rect
.
h
/
m_monitor
->
render
->
renderHeight
());
m_spinSize
->
setValue
(
100.0
*
scale
);
double
size
;
if
(
rect
.
w
/
m_monitor
->
render
->
dar
()
>
rect
.
h
)
{
if
(
m_originalSize
->
isChecked
())
{
size
=
rect
.
w
*
100.0
/
m_frameSize
.
x
();
}
else
{
size
=
rect
.
w
*
100.0
/
m_monitor
->
render
->
frameRenderWidth
();
}
}
else
{
if
(
m_originalSize
->
isChecked
())
{
size
=
rect
.
h
*
100.0
/
m_frameSize
.
y
();
}
else
{
size
=
rect
.
h
*
100.0
/
m_monitor
->
render
->
renderHeight
();
}
}
m_spinSize
->
setValue
(
size
);
if
(
m_spinOpacity
)
{
m_spinOpacity
->
blockSignals
(
true
);
m_spinOpacity
->
setValue
(
100.0
*
rect
.
o
);
...
...
@@ -772,11 +790,20 @@ void AnimationWidget::buildRectWidget(const QString ¶mTag, const QDomElement
horLayout
->
addWidget
(
m_spinY
);
m_spinWidth
=
new
DragValue
(
i18nc
(
"Frame width"
,
"W"
),
m_monitor
->
render
->
frameRenderWidth
(),
0
,
1
,
99000
,
-
1
,
QString
(),
false
,
this
);
connect
(
m_spinWidth
,
&
DragValue
::
valueChanged
,
this
,
&
AnimationWidget
::
slotAdjustRect
KeyframeValue
);
connect
(
m_spinWidth
,
&
DragValue
::
valueChanged
,
this
,
&
AnimationWidget
::
slotAdjustRect
Width
);
horLayout
->
addWidget
(
m_spinWidth
);
// Lock ratio stuff
QAction
*
lockRatio
=
new
QAction
(
KoIconUtils
::
themedIcon
(
QStringLiteral
(
"link"
)),
i18n
(
"Lock aspect ratio"
),
this
);
lockRatio
->
setCheckable
(
true
);
lockRatio
->
setChecked
(
KdenliveSettings
::
lock_ratio
());
connect
(
lockRatio
,
&
QAction
::
triggered
,
this
,
&
AnimationWidget
::
slotLockRatio
);
QToolButton
*
ratioButton
=
new
QToolButton
;
ratioButton
->
setDefaultAction
(
lockRatio
);
horLayout
->
addWidget
(
ratioButton
);
m_spinHeight
=
new
DragValue
(
i18nc
(
"Frame height"
,
"H"
),
m_monitor
->
render
->
renderHeight
(),
0
,
1
,
99000
,
-
1
,
QString
(),
false
,
this
);
connect
(
m_spinHeight
,
&
DragValue
::
valueChanged
,
this
,
&
AnimationWidget
::
slotAdjustRect
KeyframeValue
);
connect
(
m_spinHeight
,
&
DragValue
::
valueChanged
,
this
,
&
AnimationWidget
::
slotAdjustRect
Height
);
horLayout
->
addWidget
(
m_spinHeight
);
horLayout
->
addStretch
(
10
);
...
...
@@ -792,8 +819,9 @@ void AnimationWidget::buildRectWidget(const QString ¶mTag, const QDomElement
}
// Build buttons
QAction
*
originalSize
=
new
QAction
(
KoIconUtils
::
themedIcon
(
QStringLiteral
(
"zoom-original"
)),
i18n
(
"Adjust to original size"
),
this
);
connect
(
originalSize
,
&
QAction
::
triggered
,
this
,
&
AnimationWidget
::
slotAdjustToSource
);
m_originalSize
=
new
QAction
(
KoIconUtils
::
themedIcon
(
QStringLiteral
(
"zoom-original"
)),
i18n
(
"Adjust to original size"
),
this
);
connect
(
m_originalSize
,
&
QAction
::
triggered
,
this
,
&
AnimationWidget
::
slotAdjustToSource
);
m_originalSize
->
setCheckable
(
true
);
QAction
*
adjustSize
=
new
QAction
(
KoIconUtils
::
themedIcon
(
QStringLiteral
(
"zoom-fit-best"
)),
i18n
(
"Adjust and center in frame"
),
this
);
connect
(
adjustSize
,
&
QAction
::
triggered
,
this
,
&
AnimationWidget
::
slotAdjustToFrameSize
);
QAction
*
fitToWidth
=
new
QAction
(
KoIconUtils
::
themedIcon
(
QStringLiteral
(
"zoom-fit-width"
)),
i18n
(
"Fit to width"
),
this
);
...
...
@@ -847,7 +875,7 @@ void AnimationWidget::buildRectWidget(const QString ¶mTag, const QDomElement
alignLayout
->
addWidget
(
alignButton
);
alignButton
=
new
QToolButton
;
alignButton
->
setDefaultAction
(
originalSize
);
alignButton
->
setDefaultAction
(
m_
originalSize
);
alignButton
->
setAutoRaise
(
true
);
alignLayout
->
addWidget
(
alignButton
);
...
...
@@ -932,9 +960,23 @@ void AnimationWidget::slotAdjustRectKeyframeValue()
rect
.
w
=
m_spinWidth
->
value
();
rect
.
h
=
m_spinHeight
->
value
();
rect
.
o
=
m_spinOpacity
?
m_spinOpacity
->
value
()
/
100.0
:
1
;
double
scale
=
qMin
(
m_spinWidth
->
value
()
/
m_monitor
->
render
->
frameRenderWidth
(),
m_spinHeight
->
value
()
/
m_monitor
->
render
->
renderHeight
());
double
size
;
if
(
m_spinWidth
->
value
()
/
m_monitor
->
render
->
dar
()
>
m_spinHeight
->
value
())
{
if
(
m_originalSize
->
isChecked
())
{
size
=
m_spinWidth
->
value
()
*
100.0
/
m_frameSize
.
x
();
}
else
{
size
=
m_spinWidth
->
value
()
*
100.0
/
m_monitor
->
render
->
frameRenderWidth
();
}
}
else
{
if
(
m_originalSize
->
isChecked
())
{
size
=
m_spinHeight
->
value
()
*
100.0
/
m_frameSize
.
y
();
}
else
{
size
=
m_spinHeight
->
value
()
*
100.0
/
m_monitor
->
render
->
renderHeight
();
}
}
m_spinSize
->
blockSignals
(
true
);
m_spinSize
->
setValue
(
100.0
*
scal
e
);
m_spinSize
->
setValue
(
siz
e
);
m_spinSize
->
blockSignals
(
false
);
if
(
m_animController
.
is_key
(
pos
))
{
// This is a keyframe
...
...
@@ -955,8 +997,10 @@ void AnimationWidget::slotResize(double value)
{
m_spinWidth
->
blockSignals
(
true
);
m_spinHeight
->
blockSignals
(
true
);
m_spinWidth
->
setValue
(
m_monitor
->
render
->
frameRenderWidth
()
*
value
/
100.0
);
m_spinHeight
->
setValue
(
m_monitor
->
render
->
renderHeight
()
*
value
/
100.0
);
int
w
=
m_originalSize
->
isChecked
()
?
m_frameSize
.
x
()
:
m_monitor
->
render
->
frameRenderWidth
();
int
h
=
m_originalSize
->
isChecked
()
?
m_frameSize
.
y
()
:
m_monitor
->
render
->
renderHeight
();
m_spinWidth
->
setValue
(
w
*
value
/
100.0
);
m_spinHeight
->
setValue
(
h
*
value
/
100.0
);
m_spinWidth
->
blockSignals
(
false
);
m_spinHeight
->
blockSignals
(
false
);
slotAdjustRectKeyframeValue
();
...
...
@@ -1259,6 +1303,19 @@ void AnimationWidget::connectMonitor(bool activate)
connect
(
m_monitor
,
SIGNAL
(
deleteKeyframe
()),
this
,
SLOT
(
slotDeleteKeyframe
()),
Qt
::
UniqueConnection
);
int
framePos
=
qBound
<
int
>
(
0
,
m_monitor
->
render
->
seekFramePosition
()
-
m_clipPos
,
m_timePos
->
maximum
());
slotPositionChanged
(
framePos
,
false
);
double
ratio
=
(
double
)
m_spinWidth
->
value
()
/
m_spinHeight
->
value
();
if
(
m_frameSize
.
x
()
!=
m_monitor
->
render
->
frameRenderWidth
()
||
m_frameSize
.
y
()
!=
m_monitor
->
render
->
renderHeight
())
{
// Source frame size different than project frame size, enable original size option accordingly
bool
isOriginalSize
=
qAbs
((
double
)
m_frameSize
.
x
()
/
m_frameSize
.
y
()
-
ratio
)
<
qAbs
((
double
)
m_monitor
->
render
->
frameRenderWidth
()
/
m_monitor
->
render
->
renderHeight
()
-
ratio
);
if
(
isOriginalSize
)
{
m_originalSize
->
blockSignals
(
true
);
m_originalSize
->
setChecked
(
true
);
m_originalSize
->
blockSignals
(
false
);
}
}
if
(
KdenliveSettings
::
lock_ratio
())
{
m_monitor
->
setEffectSceneProperty
(
QStringLiteral
(
"lockratio"
),
m_originalSize
->
isChecked
()
?
(
double
)
m_frameSize
.
x
()
/
m_frameSize
.
y
()
:
(
double
)
m_monitor
->
render
->
frameRenderWidth
()
/
m_monitor
->
render
->
renderHeight
());
}
}
else
{
disconnect
(
m_monitor
,
&
Monitor
::
effectChanged
,
this
,
&
AnimationWidget
::
slotUpdateGeometryRect
);
disconnect
(
m_monitor
,
&
Monitor
::
effectPointsChanged
,
this
,
&
AnimationWidget
::
slotUpdateCenters
);
...
...
@@ -1383,9 +1440,6 @@ QString AnimationWidget::defaultValue(const QString ¶mName)
void
AnimationWidget
::
slotAdjustToSource
()
{
if
(
m_frameSize
==
QPoint
()
||
m_frameSize
.
x
()
==
0
||
m_frameSize
.
y
()
==
0
)
{
m_frameSize
=
QPoint
(
m_monitor
->
render
->
frameRenderWidth
(),
m_monitor
->
render
->
renderHeight
());
}
m_spinWidth
->
blockSignals
(
true
);
m_spinHeight
->
blockSignals
(
true
);
m_spinWidth
->
setValue
((
int
)(
m_frameSize
.
x
()
/
m_monitor
->
render
->
sar
()
+
0.5
),
false
);
...
...
@@ -1393,13 +1447,13 @@ void AnimationWidget::slotAdjustToSource()
m_spinWidth
->
blockSignals
(
false
);
m_spinHeight
->
blockSignals
(
false
);
slotAdjustRectKeyframeValue
();
if
(
KdenliveSettings
::
lock_ratio
())
{
m_monitor
->
setEffectSceneProperty
(
QStringLiteral
(
"lockratio"
),
m_originalSize
->
isChecked
()
?
(
double
)
m_frameSize
.
x
()
/
m_frameSize
.
y
()
:
(
double
)
m_monitor
->
render
->
frameRenderWidth
()
/
m_monitor
->
render
->
renderHeight
());
}
}
void
AnimationWidget
::
slotAdjustToFrameSize
()
{
if
(
m_frameSize
==
QPoint
()
||
m_frameSize
.
x
()
==
0
||
m_frameSize
.
y
()
==
0
)
{
m_frameSize
=
QPoint
(
m_monitor
->
render
->
frameRenderWidth
(),
m_monitor
->
render
->
renderHeight
());
}
double
monitorDar
=
m_monitor
->
render
->
frameRenderWidth
()
/
m_monitor
->
render
->
renderHeight
();
double
sourceDar
=
m_frameSize
.
x
()
/
m_frameSize
.
y
();
m_spinWidth
->
blockSignals
(
true
);
...
...
@@ -1430,9 +1484,6 @@ void AnimationWidget::slotAdjustToFrameSize()
void
AnimationWidget
::
slotFitToWidth
()
{
if
(
m_frameSize
==
QPoint
()
||
m_frameSize
.
x
()
==
0
||
m_frameSize
.
y
()
==
0
)
{
m_frameSize
=
QPoint
(
m_monitor
->
render
->
frameRenderWidth
(),
m_monitor
->
render
->
renderHeight
());
}
double
factor
=
(
double
)
m_monitor
->
render
->
frameRenderWidth
()
/
m_frameSize
.
x
()
*
m_monitor
->
render
->
sar
();
m_spinWidth
->
blockSignals
(
true
);
m_spinHeight
->
blockSignals
(
true
);
...
...
@@ -1445,9 +1496,6 @@ void AnimationWidget::slotFitToWidth()
void
AnimationWidget
::
slotFitToHeight
()
{
if
(
m_frameSize
==
QPoint
()
||
m_frameSize
.
x
()
==
0
||
m_frameSize
.
y
()
==
0
)
{
m_frameSize
=
QPoint
(
m_monitor
->
render
->
frameRenderWidth
(),
m_monitor
->
render
->
renderHeight
());
}
double
factor
=
(
double
)
m_monitor
->
render
->
renderHeight
()
/
m_frameSize
.
y
();
m_spinWidth
->
blockSignals
(
true
);
m_spinHeight
->
blockSignals
(
true
);
...
...
@@ -1510,3 +1558,42 @@ void AnimationWidget::slotImportKeyframes()
QString
values
=
clipboard
->
text
();
emit
setKeyframes
(
values
);
}
void
AnimationWidget
::
slotLockRatio
()
{
QAction
*
lockRatio
=
qobject_cast
<
QAction
*>
(
QObject
::
sender
());
KdenliveSettings
::
setLock_ratio
(
lockRatio
->
isChecked
());
if
(
lockRatio
->
isChecked
())
{
m_monitor
->
setEffectSceneProperty
(
QStringLiteral
(
"lockratio"
),
m_originalSize
->
isChecked
()
?
(
double
)
m_frameSize
.
x
()
/
m_frameSize
.
y
()
:
(
double
)
m_monitor
->
render
->
frameRenderWidth
()
/
m_monitor
->
render
->
renderHeight
());
}
else
{
m_monitor
->
setEffectSceneProperty
(
QStringLiteral
(
"lockratio"
),
-
1
);
}
}
void
AnimationWidget
::
slotAdjustRectWidth
()
{
if
(
KdenliveSettings
::
lock_ratio
())
{
m_spinHeight
->
blockSignals
(
true
);
if
(
m_originalSize
->
isChecked
())
{
m_spinHeight
->
setValue
((
int
)
(
m_spinWidth
->
value
()
*
m_frameSize
.
y
()
/
m_frameSize
.
x
()
+
0.5
));
}
else
{
m_spinHeight
->
setValue
((
int
)
(
m_spinWidth
->
value
()
*
m_monitor
->
render
->
renderHeight
()
/
m_monitor
->
render
->
frameRenderWidth
()
+
0.5
));
}
m_spinHeight
->
blockSignals
(
false
);
}
slotAdjustRectKeyframeValue
();
}
void
AnimationWidget
::
slotAdjustRectHeight
()
{
if
(
KdenliveSettings
::
lock_ratio
())
{
m_spinWidth
->
blockSignals
(
true
);
if
(
m_originalSize
->
isChecked
())
{
m_spinWidth
->
setValue
((
int
)
(
m_spinHeight
->
value
()
*
m_frameSize
.
x
()
/
m_frameSize
.
y
()
+
0.5
));
}
else
{
m_spinWidth
->
setValue
((
int
)
(
m_spinHeight
->
value
()
*
m_monitor
->
render
->
frameRenderWidth
()
/
m_monitor
->
render
->
renderHeight
()
+
0.5
));
}
m_spinWidth
->
blockSignals
(
false
);
}
slotAdjustRectKeyframeValue
();
}
src/effectstack/widgets/animationwidget.h
View file @
243dff06
...
...
@@ -96,6 +96,7 @@ private:
DragValue
*
m_spinHeight
;
DragValue
*
m_spinSize
;
DragValue
*
m_spinOpacity
;
QAction
*
m_originalSize
;
int
m_offset
;
void
parseKeyframes
();
void
rebuildKeyframes
();
...
...
@@ -160,6 +161,10 @@ private slots:
void
slotCenterV
();
/** @brief Moves the rect to the bottom frame border (y position = frame height - rect height). */
void
slotMoveBottom
();
/** @brief Un/Lock aspect ratio for size in effect parameter. */
void
slotLockRatio
();
void
slotAdjustRectHeight
();
void
slotAdjustRectWidth
();
signals:
void
seekToPos
(
int
);
...
...
src/effectstack/widgets/geometrywidget.cpp
View file @
243dff06
...
...
@@ -55,7 +55,10 @@ GeometryWidget::GeometryWidget(EffectMetaInfo *info, int clipPos, bool showRotat
/*
Setup of timeline and keyframe controls
*/
if
(
m_frameSize
==
QPoint
()
||
m_frameSize
.
x
()
==
0
||
m_frameSize
.
y
()
==
0
)
{
m_originalSize
->
setEnabled
(
false
);
m_frameSize
=
QPoint
(
m_monitor
->
render
->
frameRenderWidth
(),
m_monitor
->
render
->
renderHeight
());
}
((
QGridLayout
*
)(
m_ui
.
widgetTimeWrapper
->
layout
()))
->
addWidget
(
m_timePos
,
1
,
5
);
QVBoxLayout
*
layout
=
new
QVBoxLayout
(
m_ui
.
frameTimeline
);
...
...
@@ -94,14 +97,24 @@ GeometryWidget::GeometryWidget(EffectMetaInfo *info, int clipPos, bool showRotat
m_spinWidth
=
new
DragValue
(
i18nc
(
"Frame width"
,
"W"
),
m_monitor
->
render
->
frameRenderWidth
(),
0
,
1
,
99000
,
-
1
,
QString
(),
false
,
this
);
m_ui
.
horizontalLayout
->
addWidget
(
m_spinWidth
,
0
,
2
);
// Lock ratio stuff
QAction
*
lockRatio
=
new
QAction
(
KoIconUtils
::
themedIcon
(
QStringLiteral
(
"link"
)),
i18n
(
"Lock aspect ratio"
),
this
);
lockRatio
->
setCheckable
(
true
);
lockRatio
->
setChecked
(
KdenliveSettings
::
lock_ratio
());
connect
(
lockRatio
,
&
QAction
::
triggered
,
this
,
&
GeometryWidget
::
slotLockRatio
);
QToolButton
*
ratioButton
=
new
QToolButton
;
ratioButton
->
setDefaultAction
(
lockRatio
);
m_ui
.
horizontalLayout
->
addWidget
(
ratioButton
,
0
,
3
);
m_spinHeight
=
new
DragValue
(
i18nc
(
"Frame height"
,
"H"
),
m_monitor
->
render
->
renderHeight
(),
0
,
1
,
99000
,
-
1
,
QString
(),
false
,
this
);
m_ui
.
horizontalLayout
->
addWidget
(
m_spinHeight
,
0
,
3
);
m_ui
.
horizontalLayout
->
addWidget
(
m_spinHeight
,
0
,
4
);
m_ui
.
horizontalLayout
->
setColumnStretch
(
4
,
10
);
m_ui
.
horizontalLayout
->
setColumnStretch
(
5
,
10
);
QMenu
*
menu
=
new
QMenu
(
this
);
QAction
*
originalSize
=
new
QAction
(
KoIconUtils
::
themedIcon
(
QStringLiteral
(
"zoom-original"
)),
i18n
(
"Adjust to original size"
),
this
);
connect
(
originalSize
,
&
QAction
::
triggered
,
this
,
&
GeometryWidget
::
slotAdjustToSource
);
m_originalSize
=
new
QAction
(
KoIconUtils
::
themedIcon
(
QStringLiteral
(
"zoom-original"
)),
i18n
(
"Adjust to original size"
),
this
);
connect
(
m_originalSize
,
&
QAction
::
triggered
,
this
,
&
GeometryWidget
::
slotAdjustToSource
);
m_originalSize
->
setCheckable
(
true
);
QAction
*
adjustSize
=
new
QAction
(
KoIconUtils
::
themedIcon
(
QStringLiteral
(
"zoom-fit-best"
)),
i18n
(
"Adjust and center in frame"
),
this
);
connect
(
adjustSize
,
&
QAction
::
triggered
,
this
,
&
GeometryWidget
::
slotAdjustToFrameSize
);
QAction
*
fitToWidth
=
new
QAction
(
KoIconUtils
::
themedIcon
(
QStringLiteral
(
"zoom-fit-width"
)),
i18n
(
"Fit to width"
),
this
);
...
...
@@ -181,7 +194,7 @@ GeometryWidget::GeometryWidget(EffectMetaInfo *info, int clipPos, bool showRotat
alignLayout
->
addWidget
(
alignButton
);
alignButton
=
new
QToolButton
;
alignButton
->
setDefaultAction
(
originalSize
);
alignButton
->
setDefaultAction
(
m_
originalSize
);
alignButton
->
setAutoRaise
(
true
);
alignLayout
->
addWidget
(
alignButton
);
...
...
@@ -496,6 +509,20 @@ void GeometryWidget::slotPositionChanged(int pos, bool seek)
void
GeometryWidget
::
slotInitScene
(
int
pos
)
{
slotPositionChanged
(
pos
,
false
);
double
ratio
=
(
double
)
m_spinWidth
->
value
()
/
m_spinHeight
->
value
();
if
(
m_frameSize
.
x
()
!=
m_monitor
->
render
->
frameRenderWidth
()
||
m_frameSize
.
y
()
!=
m_monitor
->
render
->
renderHeight
())
{
// Source frame size different than project frame size, enable original size option accordingly
bool
isOriginalSize
=
qAbs
((
double
)
m_frameSize
.
x
()
/
m_frameSize
.
y
()
-
ratio
)
<
qAbs
((
double
)
m_monitor
->
render
->
frameRenderWidth
()
/
m_monitor
->
render
->
renderHeight
()
-
ratio
);
if
(
isOriginalSize
)
{
m_originalSize
->
blockSignals
(
true
);
m_originalSize
->
setChecked
(
true
);
m_originalSize
->
blockSignals
(
false
);
}
}
// scene ratio lock
if
(
KdenliveSettings
::
lock_ratio
())
{
m_monitor
->
setEffectSceneProperty
(
QStringLiteral
(
"lockratio"
),
m_originalSize
->
isChecked
()
?
(
double
)
m_frameSize
.
x
()
/
m_frameSize
.
y
()
:
(
double
)
m_monitor
->
render
->
frameRenderWidth
()
/
m_monitor
->
render
->
renderHeight
());
}
}
void
GeometryWidget
::
slotKeyframeMoved
(
int
pos
)
...
...
@@ -744,9 +771,17 @@ void GeometryWidget::slotUpdateProperties(QRect rect)
}
double
size
;
if
(
rect
.
width
()
/
m_monitor
->
render
->
dar
()
>
rect
.
height
())
{
size
=
rect
.
width
()
*
100.0
/
m_monitor
->
render
->
frameRenderWidth
();
if
(
m_originalSize
->
isChecked
())
{
size
=
rect
.
width
()
*
100.0
/
m_frameSize
.
x
();
}
else
{
size
=
rect
.
width
()
*
100.0
/
m_monitor
->
render
->
frameRenderWidth
();
}
}
else
{
size
=
rect
.
height
()
*
100.0
/
m_monitor
->
render
->
renderHeight
();
if
(
m_originalSize
->
isChecked
())
{
size
=
rect
.
height
()
*
100.0
/
m_frameSize
.
y
();
}
else
{
size
=
rect
.
height
()
*
100.0
/
m_monitor
->
render
->
renderHeight
();
}
}
m_spinX
->
blockSignals
(
true
);
...
...
@@ -797,6 +832,15 @@ void GeometryWidget::slotSetY(double value)
void
GeometryWidget
::
slotSetWidth
(
double
value
)
{
if
(
KdenliveSettings
::
lock_ratio
())
{
m_spinHeight
->
blockSignals
(
true
);
if
(
m_originalSize
->
isChecked
())
{
m_spinHeight
->
setValue
((
int
)
(
value
*
m_frameSize
.
y
()
/
m_frameSize
.
x
()
+
0.5
));
}
else
{
m_spinHeight
->
setValue
((
int
)
(
value
*
m_monitor
->
render
->
renderHeight
()
/
m_monitor
->
render
->
frameRenderWidth
()
+
0.5
));
}
m_spinHeight
->
blockSignals
(
false
);
}
m_monitor
->
setUpEffectGeometry
(
QRect
(
m_spinX
->
value
(),
m_spinY
->
value
(),
value
,
m_spinHeight
->
value
()));
slotUpdateGeometry
();
m_monitor
->
setUpEffectGeometry
(
QRect
(),
calculateCenters
());
...
...
@@ -804,6 +848,15 @@ void GeometryWidget::slotSetWidth(double value)
void
GeometryWidget
::
slotSetHeight
(
double
value
)
{
if
(
KdenliveSettings
::
lock_ratio
())
{
m_spinWidth
->
blockSignals
(
true
);
if
(
m_originalSize
->
isChecked
())
{
m_spinWidth
->
setValue
((
int
)
(
value
*
m_frameSize
.
x
()
/
m_frameSize
.
y
()
+
0.5
));
}
else
{
m_spinWidth
->
setValue
((
int
)
(
value
*
m_monitor
->
render
->
frameRenderWidth
()
/
m_monitor
->
render
->
renderHeight
()
+
0.5
));
}
m_spinWidth
->
blockSignals
(
false
);
}
m_monitor
->
setUpEffectGeometry
(
QRect
(
m_spinX
->
value
(),
m_spinY
->
value
(),
m_spinWidth
->
value
(),
value
));
slotUpdateGeometry
();
m_monitor
->
setUpEffectGeometry
(
QRect
(),
calculateCenters
());
...
...
@@ -818,7 +871,9 @@ void GeometryWidget::updateMonitorGeometry()
void
GeometryWidget
::
slotResize
(
double
value
)
{
m_monitor
->
setUpEffectGeometry
(
QRect
(
m_spinX
->
value
(),
m_spinY
->
value
(),
(
int
)((
m_monitor
->
render
->
frameRenderWidth
()
*
value
/
100.0
)
+
0.5
),
(
int
)((
m_monitor
->
render
->
renderHeight
()
*
value
/
100.0
)
+
0.5
)));
int
w
=
m_originalSize
->
isChecked
()
?
m_frameSize
.
x
()
:
m_monitor
->
render
->
frameRenderWidth
();
int
h
=
m_originalSize
->
isChecked
()
?
m_frameSize
.
y
()
:
m_monitor
->
render
->
renderHeight
();
m_monitor
->
setUpEffectGeometry
(
QRect
(
m_spinX
->
value
(),
m_spinY
->
value
(),
(
int
)((
w
*
value
/
100.0
)
+
0.5
),
(
int
)((
h
*
value
/
100.0
)
+
0.5
)));
slotUpdateGeometry
();
m_monitor
->
setUpEffectGeometry
(
QRect
(),
calculateCenters
());
}
...
...
@@ -882,27 +937,42 @@ void GeometryWidget::slotSetSynchronize(bool sync)
void
GeometryWidget
::
setFrameSize
(
const
QPoint
&
size
)
{
m_frameSize
=
size
;
if
(
m_frameSize
==
QPoint
()
||
m_frameSize
.
x
()
==
0
||
m_frameSize
.
y
()
==
0
)
{
m_originalSize
->
setEnabled
(
false
);
m_frameSize
=
QPoint
(
m_monitor
->
render
->
frameRenderWidth
(),
m_monitor
->
render
->
renderHeight
());
}
else
{
m_originalSize
->
setEnabled
(
true
);
}
if
(
KdenliveSettings
::
lock_ratio
())
{
m_monitor
->
setEffectSceneProperty
(
QStringLiteral
(
"lockratio"
),
m_originalSize
->
isChecked
()
?
(
double
)
m_frameSize
.
x
()
/
m_frameSize
.
y
()
:
(
double
)
m_monitor
->
render
->
frameRenderWidth
()
/
m_monitor
->
render
->
renderHeight
());
}
else
{
m_monitor
->
setEffectSceneProperty
(
QStringLiteral
(
"lockratio"
),
-
1
);
}
}
void
GeometryWidget
::
slotAdjustToSource
()
{
if
(
m_frameSize
==
QPoint
()
||
m_frameSize
.
x
()
==
0
||
m_frameSize
.
y
()
==
0
)
{
m_frameSize
=
QPoint
(
m_monitor
->
render
->
frameRenderWidth
(),
m_monitor
->
render
->
renderHeight
());
}
m_spinWidth
->
blockSignals
(
true
);
m_spinHeight
->
blockSignals
(
true
);
m_spinWidth
->
setValue
((
int
)(
m_frameSize
.
x
()
/
m_monitor
->
render
->
sar
()
+
0.5
));
m_spinHeight
->
setValue
(
m_frameSize
.
y
());
if
(
m_originalSize
->
isChecked
())
{
// Adjust to source size
m_spinWidth
->
setValue
((
int
)(
m_frameSize
.
x
()
/
m_monitor
->
render
->
sar
()
+
0.5
));
m_spinHeight
->
setValue
(
m_frameSize
.
y
());
}
else
{
// Adjust to profile size
m_spinWidth
->
setValue
((
int
)(
m_monitor
->
render
->
frameRenderWidth
()
/
m_monitor
->
render
->
sar
()
+
0.5
));
m_spinHeight
->
setValue
(
m_monitor
->
render
->
renderHeight
());
}
m_spinWidth
->
blockSignals
(
false
);
m_spinHeight
->
blockSignals
(
false
);
updateMonitorGeometry
();
if
(
KdenliveSettings
::
lock_ratio
())
{
m_monitor
->
setEffectSceneProperty
(
QStringLiteral
(
"lockratio"
),
m_originalSize
->
isChecked
()
?
(
double
)
m_frameSize
.
x
()
/
m_frameSize
.
y
()
:
(
double
)
m_monitor
->
render
->
frameRenderWidth
()
/
m_monitor
->
render
->
renderHeight
());
}
}
void
GeometryWidget
::
slotAdjustToFrameSize
()
{
if
(
m_frameSize
==
QPoint
()
||
m_frameSize
.
x
()
==
0
||
m_frameSize
.
y
()
==
0
)
{
m_frameSize
=
QPoint
(
m_monitor
->
render
->
frameRenderWidth
(),
m_monitor
->
render
->
renderHeight
());
}
double
monitorDar
=
m_monitor
->
render
->
frameRenderWidth
()
/
m_monitor
->
render
->
renderHeight
();
double
sourceDar
=
m_frameSize
.
x
()
/
m_frameSize
.
y
();
m_spinWidth
->
blockSignals
(
true
);
...
...
@@ -933,9 +1003,6 @@ void GeometryWidget::slotAdjustToFrameSize()
void
GeometryWidget
::
slotFitToWidth
()
{
if
(
m_frameSize
==
QPoint
()
||
m_frameSize
.
x
()
==
0
||
m_frameSize
.
y
()
==
0
)
{
m_frameSize
=
QPoint
(
m_monitor
->
render
->
frameRenderWidth
(),
m_monitor
->
render
->
renderHeight
());
}
double
factor
=
(
double
)
m_monitor
->
render
->
frameRenderWidth
()
/
m_frameSize
.
x
()
*
m_monitor
->
render
->
sar
();
m_spinWidth
->
blockSignals
(
true
);
m_spinHeight
->
blockSignals
(
true
);
...
...
@@ -948,9 +1015,6 @@ void GeometryWidget::slotFitToWidth()
void
GeometryWidget
::
slotFitToHeight
()
{
if
(
m_frameSize
==
QPoint
()
||
m_frameSize
.
x
()
==
0
||
m_frameSize
.
y
()
==
0
)
{
m_frameSize
=
QPoint
(
m_monitor
->
render
->
frameRenderWidth
(),
m_monitor
->
render
->
renderHeight
());
}
double
factor
=
(
double
)
m_monitor
->
render
->
renderHeight
()
/
m_frameSize
.
y
();
m_spinWidth
->
blockSignals
(
true
);
m_spinHeight
->
blockSignals
(
true
);
...
...
@@ -1125,3 +1189,13 @@ void GeometryWidget::slotUpdateRange(int inPoint, int outPoint)