Fix delete guide hard to reach from timeline ruler on low zoom

CCBUG: 366068
Change timline size policy
CCBUG: 366066
parent e3f2662b
......@@ -3159,7 +3159,7 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
}
if (chapters.childNodes().count() > 0) {
if (pCore->projectManager()->currentTimeline()->projectView()->hasGuide(out, 0) == -1) {
if (pCore->projectManager()->currentTimeline()->projectView()->hasGuide(out, true) == -1) {
// Always insert a guide in pos 0
QDomElement chapter = doc.createElement(QStringLiteral("chapter"));
chapters.insertBefore(chapter, QDomNode());
......
......@@ -73,7 +73,6 @@ CustomRuler::CustomRuler(const Timecode &tc, const QList<QAction *> &rulerAction
setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
QFontMetricsF fontMetrics(font());
// Define size variables
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
LABEL_SIZE = fontMetrics.ascent();
FONT_WIDTH = fontMetrics.averageCharWidth();
PREVIEW_SIZE = LABEL_SIZE / 3;
......@@ -163,7 +162,7 @@ void CustomRuler::mousePressEvent(QMouseEvent * event)
event->setAccepted(true);
int pos = (int)((event->x() + offset()));
if (event->button() == Qt::RightButton) {
m_clickedGuide = m_view->hasGuide((int)(pos / m_factor), (int)(5 / m_factor + 1));
m_clickedGuide = m_view->hasGuide(pos, false);
m_editGuide->setEnabled(m_clickedGuide > 0);
m_deleteGuide->setEnabled(m_clickedGuide > 0);
m_view->buildGuidesMenu(m_goMenu);
......
......@@ -133,7 +133,6 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, Timeline *timeline, CustomTra
//setCacheMode(QGraphicsView::CacheBackground);
setAutoFillBackground(false);
setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
setContentsMargins(0, 0, 0, 0);
KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
m_selectedTrackColor = scheme.background(KColorScheme::ActiveBackground ).color();
......@@ -5836,12 +5835,16 @@ void CustomTrackView::clipEnd()
}
}
int CustomTrackView::hasGuide(int pos, int offset)
int CustomTrackView::hasGuide(double pos, bool framePos)
{
for (int i = 0; i < m_guides.count(); ++i) {
int guidePos = m_guides.at(i)->position().frames(m_document->fps());
if (qAbs(guidePos - pos) <= offset) return guidePos;
else if (guidePos > pos) return -1;
double guidePos = m_guides.at(i)->position().frames(m_document->fps()) * (framePos ? 1 : matrix().m11());
if (framePos) {
if (guidePos == pos) return guidePos;
} else {
if (qAbs(guidePos - pos) <= QApplication::startDragDistance()) return guidePos;
}
if (guidePos > pos) return -1;
}
return -1;
}
......
......@@ -170,7 +170,11 @@ public:
/** @brief Sets the clip type (av, video only, audio only) of the current selection. */
void setClipType(PlaylistState::ClipState state);
void doChangeClipType(ItemInfo info, PlaylistState::ClipState state);
int hasGuide(int pos, int offset);
/** @brief Check if there is a guide at position.
* @param pos Position to check
* @param framePos If set to true, pos is an exact frame number, otherwise it's a mouse event pos
*/
int hasGuide(double pos, bool framePos);
void reloadTransitionLumas();
void updateProjectFps();
double fps() const;
......
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