Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Zoom on mouse

parent 137b11fd
......@@ -83,7 +83,7 @@ Rectangle {
}
function getMousePos() {
return (scrollView.flickableItem.contentX + tracksArea.mouseX) / timeline.scaleFactor;
return (scrollView.flickableItem.contentX + tracksArea.mouseX) / timeline.scaleFactor
}
function getMouseTrack() {
......@@ -122,10 +122,17 @@ Rectangle {
property int trackHeight
property int copiedClip: -1
property var dragList: []
property int zoomOnMouse: -1
//onCurrentTrackChanged: timeline.selection = []
onTimeScaleChanged: {
scrollView.flickableItem.contentX = Math.max(0, (timeline.seekPosition > -1 ? timeline.seekPosition : timeline.position) * timeline.scaleFactor - (scrollView.width / 2))
if (root.zoomOnMouse >= 0) {
var mouseFraction =
scrollView.flickableItem.contentX = Math.max(0, root.zoomOnMouse * timeline.scaleFactor - tracksArea.mouseX)
root.zoomOnMouse = -1
} else {
scrollView.flickableItem.contentX = Math.max(0, (timeline.seekPosition > -1 ? timeline.seekPosition : timeline.position) * timeline.scaleFactor - (scrollView.width / 2))
}
root.snapping = timeline.snap ? 10 / Math.sqrt(root.timeScale) : -1
ruler.adjustStepSize()
}
......
......@@ -191,6 +191,17 @@ QMap<int, QString> TimelineController::getTrackNames(bool videoOnly)
return names;
}
void TimelineController::setScaleFactorOnMouse(double scale, bool zoomOnMouse)
{
/*if (m_duration * scale < width() - 160) {
// Don't allow scaling less than full project's width
scale = (width() - 160.0) / m_duration;
}*/
m_root->setProperty("zoomOnMouse", zoomOnMouse ? getMousePos() : -1);
m_scale = scale;
emit scaleFactorChanged();
}
void TimelineController::setScaleFactor(double scale)
{
/*if (m_duration * scale < width() - 160) {
......
......@@ -79,6 +79,7 @@ public:
Q_INVOKABLE double scaleFactor() const;
/* @brief set current timeline's zoom factor
*/
void setScaleFactorOnMouse(double scale, bool zoomOnMouse);
Q_INVOKABLE void setScaleFactor(double scale);
/* @brief Returns the project's duration (tractor)
*/
......
......@@ -104,8 +104,7 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event)
void TimelineWidget::slotChangeZoom(int value, bool zoomOnMouse)
{
Q_UNUSED(zoomOnMouse)
m_proxy->setScaleFactor(100.0 / comboScale[value]);
m_proxy->setScaleFactorOnMouse(100.0 / comboScale[value], zoomOnMouse);
}
void TimelineWidget::wheelEvent(QWheelEvent *event)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment