|
|
|
@ -112,6 +112,7 @@ FilmstripFrames::FilmstripFrames(QScrollArea *parent, Qt::WFlags flags)
|
|
|
|
|
, m_dragSelectionStartIndex(-1)
|
|
|
|
|
, m_dragSelectionEndIndex(-1)
|
|
|
|
|
, m_timerId(0)
|
|
|
|
|
, m_isGhibli(false)
|
|
|
|
|
, m_selecting(false)
|
|
|
|
|
, m_dragDropArmed(false)
|
|
|
|
|
, m_readOnly(false) {
|
|
|
|
@ -130,6 +131,11 @@ FilmstripFrames::FilmstripFrames(QScrollArea *parent, Qt::WFlags flags)
|
|
|
|
|
|
|
|
|
|
m_selection->setView(this);
|
|
|
|
|
setMouseTracking(true);
|
|
|
|
|
|
|
|
|
|
std::string room =
|
|
|
|
|
Preferences::instance()->getCurrentRoomChoice().toStdString();
|
|
|
|
|
m_isGhibli = room == "StudioGhibli";
|
|
|
|
|
m_viewer = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
@ -208,12 +214,14 @@ void FilmstripFrames::updateContentHeight(int minimumHeight) {
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
void FilmstripFrames::exponeFrame(int index) {
|
|
|
|
|
void FilmstripFrames::showFrame(int index) {
|
|
|
|
|
TXshSimpleLevel *level = getLevel();
|
|
|
|
|
|
|
|
|
|
if (!level->isFid(index2fid(index))) return;
|
|
|
|
|
int y0 = index2y(index);
|
|
|
|
|
int y1 = y0 + m_iconSize.height() + fs_frameSpacing + fs_iconMarginTop +
|
|
|
|
|
fs_iconMarginBottom;
|
|
|
|
|
if (y1 > height()) setFixedHeight(y1);
|
|
|
|
|
// else if(height()-y1>=m_iconSize.height()) updateContentHeight();
|
|
|
|
|
m_scrollArea->ensureVisible(0, (y0 + y1) / 2, 50, (y1 - y0) / 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -222,9 +230,12 @@ void FilmstripFrames::exponeFrame(int index) {
|
|
|
|
|
void FilmstripFrames::scroll(int dy) {
|
|
|
|
|
QScrollBar *sb = m_scrollArea->verticalScrollBar();
|
|
|
|
|
int sbValue = sb->value();
|
|
|
|
|
int y = visibleRegion().boundingRect().bottom() + dy + 1;
|
|
|
|
|
if (y < 0) y = 0;
|
|
|
|
|
updateContentHeight(y);
|
|
|
|
|
|
|
|
|
|
updateContentHeight(getFramesHeight());
|
|
|
|
|
if (sbValue + dy > getFramesHeight()) {
|
|
|
|
|
sb->setValue(getFramesHeight());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
sb->setValue(sbValue + dy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -239,7 +250,6 @@ void FilmstripFrames::mouseDoubleClickEvent(QMouseEvent *event) {
|
|
|
|
|
|
|
|
|
|
void FilmstripFrames::select(int index, SelectionMode mode) {
|
|
|
|
|
TXshSimpleLevel *sl = getLevel();
|
|
|
|
|
|
|
|
|
|
bool outOfRange = !sl || index < 0 || index >= sl->getFrameCount();
|
|
|
|
|
|
|
|
|
|
TFrameId fid;
|
|
|
|
@ -367,15 +377,7 @@ void FilmstripFrames::showEvent(QShowEvent *) {
|
|
|
|
|
connect(app->getCurrentOnionSkin(), SIGNAL(onionSkinMaskChanged()), this,
|
|
|
|
|
SLOT(update()));
|
|
|
|
|
|
|
|
|
|
// enable navigator link with the Viewer in the InknPaint page
|
|
|
|
|
ComboViewerPanel *inknPaintViewerPanel = app->getInknPaintViewerPanel();
|
|
|
|
|
if (inknPaintViewerPanel) {
|
|
|
|
|
SceneViewer *viewer = inknPaintViewerPanel->getSceneViewer();
|
|
|
|
|
if (viewer) {
|
|
|
|
|
connect(viewer, SIGNAL(onZoomChanged()), this, SLOT(update()));
|
|
|
|
|
connect(viewer, SIGNAL(refreshNavi()), this, SLOT(update()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
getViewer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
@ -400,13 +402,33 @@ void FilmstripFrames::hideEvent(QHideEvent *) {
|
|
|
|
|
disconnect(app->getCurrentOnionSkin(), SIGNAL(onionSkinMaskChanged()), this,
|
|
|
|
|
SLOT(update()));
|
|
|
|
|
|
|
|
|
|
ComboViewerPanel *inknPaintViewerPanel = app->getInknPaintViewerPanel();
|
|
|
|
|
if (inknPaintViewerPanel) {
|
|
|
|
|
SceneViewer *viewer = inknPaintViewerPanel->getSceneViewer();
|
|
|
|
|
if (viewer) {
|
|
|
|
|
disconnect(viewer, SIGNAL(onZoomChanged()), this, SLOT(update()));
|
|
|
|
|
disconnect(viewer, SIGNAL(refreshNavi()), this, SLOT(update()));
|
|
|
|
|
if (m_viewer) {
|
|
|
|
|
disconnect(m_viewer, SIGNAL(onZoomChanged()), this, SLOT(update()));
|
|
|
|
|
disconnect(m_viewer, SIGNAL(refreshNavi()), this, SLOT(update()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
void FilmstripFrames::getViewer() {
|
|
|
|
|
bool viewerChanged = false;
|
|
|
|
|
if (m_viewer != TApp::instance()->getActiveViewer()) {
|
|
|
|
|
if (m_viewer) {
|
|
|
|
|
disconnect(m_viewer, SIGNAL(onZoomChanged()), this, SLOT(update()));
|
|
|
|
|
disconnect(m_viewer, SIGNAL(refreshNavi()), this, SLOT(update()));
|
|
|
|
|
}
|
|
|
|
|
viewerChanged = true;
|
|
|
|
|
}
|
|
|
|
|
ComboViewerPanel *inknPaintViewerPanel =
|
|
|
|
|
TApp::instance()->getInknPaintViewerPanel();
|
|
|
|
|
if (m_isGhibli && inknPaintViewerPanel) {
|
|
|
|
|
m_viewer = inknPaintViewerPanel->getSceneViewer();
|
|
|
|
|
} else {
|
|
|
|
|
m_viewer = TApp::instance()->getActiveViewer();
|
|
|
|
|
}
|
|
|
|
|
if (m_viewer && viewerChanged) {
|
|
|
|
|
connect(m_viewer, SIGNAL(onZoomChanged()), this, SLOT(update()));
|
|
|
|
|
connect(m_viewer, SIGNAL(refreshNavi()), this, SLOT(update()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -456,18 +478,14 @@ void FilmstripFrames::paintEvent(QPaintEvent *evt) {
|
|
|
|
|
//--- compute navigator rect ---
|
|
|
|
|
|
|
|
|
|
QRect naviRect;
|
|
|
|
|
ComboViewerPanel *inknPaintViewerPanel =
|
|
|
|
|
TApp::instance()->getInknPaintViewerPanel();
|
|
|
|
|
if (sl->getType() == TZP_XSHLEVEL && inknPaintViewerPanel) {
|
|
|
|
|
// show navigator only if the inknpaint viewer is visible
|
|
|
|
|
if (inknPaintViewerPanel->isVisible()) {
|
|
|
|
|
SceneViewer *viewer = inknPaintViewerPanel->getSceneViewer();
|
|
|
|
|
|
|
|
|
|
if ((sl->getType() == TZP_XSHLEVEL || sl->getType() == OVL_XSHLEVEL) &&
|
|
|
|
|
m_viewer && m_viewer->isVisible()) {
|
|
|
|
|
// imgSize: image's pixel size
|
|
|
|
|
QSize imgSize(sl->getProperties()->getImageRes().lx,
|
|
|
|
|
sl->getProperties()->getImageRes().ly);
|
|
|
|
|
// Viewer affine
|
|
|
|
|
TAffine viewerAff =
|
|
|
|
|
inknPaintViewerPanel->getSceneViewer()->getViewMatrix();
|
|
|
|
|
TAffine viewerAff = m_viewer->getViewMatrix();
|
|
|
|
|
// pixel size which will be displayed with 100% scale in Viewer Stage
|
|
|
|
|
TFrameId currentId = TApp::instance()->getCurrentFrame()->getFid();
|
|
|
|
|
double imgPixelWidth =
|
|
|
|
@ -488,13 +506,13 @@ void FilmstripFrames::paintEvent(QPaintEvent *evt) {
|
|
|
|
|
|
|
|
|
|
// ratio of the Viewer frame's position and size
|
|
|
|
|
QRectF naviRatio(
|
|
|
|
|
(-(float)viewer->width() * 0.5f - (float)imgBottomLeft.x) /
|
|
|
|
|
(-(float)m_viewer->width() * 0.5f - (float)imgBottomLeft.x) /
|
|
|
|
|
imgSizeInViewer.width(),
|
|
|
|
|
1.0f -
|
|
|
|
|
((float)viewer->height() * 0.5f - (float)imgBottomLeft.y) /
|
|
|
|
|
((float)m_viewer->height() * 0.5f - (float)imgBottomLeft.y) /
|
|
|
|
|
imgSizeInViewer.height(),
|
|
|
|
|
(float)viewer->width() / imgSizeInViewer.width(),
|
|
|
|
|
(float)viewer->height() / imgSizeInViewer.height());
|
|
|
|
|
(float)m_viewer->width() / imgSizeInViewer.width(),
|
|
|
|
|
(float)m_viewer->height() / imgSizeInViewer.height());
|
|
|
|
|
|
|
|
|
|
naviRect = QRect(iconImgRect.left() +
|
|
|
|
|
(int)(naviRatio.left() * (float)iconImgRect.width()),
|
|
|
|
@ -512,7 +530,6 @@ void FilmstripFrames::paintEvent(QPaintEvent *evt) {
|
|
|
|
|
m_icon2ViewerRatio.setY(imgSizeInViewer.height() /
|
|
|
|
|
(float)iconImgRect.height());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--- compute navigator rect end ---
|
|
|
|
|
|
|
|
|
@ -545,15 +562,13 @@ void FilmstripFrames::paintEvent(QPaintEvent *evt) {
|
|
|
|
|
QRect tmp_iconImgRect =
|
|
|
|
|
iconImgRect.translated(QPoint(0, oneFrameHeight * i));
|
|
|
|
|
QRect tmp_frameRect = frameRect.translated(QPoint(0, oneFrameHeight * i));
|
|
|
|
|
|
|
|
|
|
bool isCurrentFrame =
|
|
|
|
|
(i == sl->fid2index(TApp::instance()->getCurrentFrame()->getFid()));
|
|
|
|
|
bool isSelected =
|
|
|
|
|
(0 <= i && i < frameCount && m_selection->isSelected(fids[i]));
|
|
|
|
|
|
|
|
|
|
TFrameId fid;
|
|
|
|
|
if (0 <= i && i < frameCount) {
|
|
|
|
|
TFrameId fid = fids[i];
|
|
|
|
|
|
|
|
|
|
fid = fids[i];
|
|
|
|
|
// normal or inbetween (for vector levels)
|
|
|
|
|
int flags = (sl->getType() == PLI_XSHLEVEL && range.first < fid &&
|
|
|
|
|
fid < range.second)
|
|
|
|
@ -608,7 +623,7 @@ void FilmstripFrames::paintEvent(QPaintEvent *evt) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// navigator rect
|
|
|
|
|
if (naviRect.isValid() && isCurrentFrame) {
|
|
|
|
|
if (naviRect.isValid() && fid >= 0 && fid == getCurrentFrameId()) {
|
|
|
|
|
p.setPen(QPen(Qt::red, 1));
|
|
|
|
|
p.drawRect(naviRect.translated(0, oneFrameHeight * i));
|
|
|
|
|
p.setPen(Qt::NoPen);
|
|
|
|
@ -671,6 +686,28 @@ void FilmstripFrames::drawFrameIcon(QPainter &p, const QRect &r, int index,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FilmstripFrames::enterEvent(QEvent *event) { getViewer(); }
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
TFrameId FilmstripFrames::getCurrentFrameId() {
|
|
|
|
|
TApp *app = TApp::instance();
|
|
|
|
|
TFrameHandle *fh = app->getCurrentFrame();
|
|
|
|
|
TFrameId currFid;
|
|
|
|
|
if (fh->isEditingLevel())
|
|
|
|
|
currFid = fh->getFid();
|
|
|
|
|
else {
|
|
|
|
|
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
|
|
|
int col = app->getCurrentColumn()->getColumnIndex();
|
|
|
|
|
int row = fh->getFrame();
|
|
|
|
|
if (row < 0 || col < 0) return TFrameId();
|
|
|
|
|
TXshCell cell = xsh->getCell(row, col);
|
|
|
|
|
// if (cell.isEmpty()) return;
|
|
|
|
|
currFid = cell.getFrameId();
|
|
|
|
|
}
|
|
|
|
|
return currFid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
void FilmstripFrames::mousePressEvent(QMouseEvent *event) {
|
|
|
|
@ -683,40 +720,49 @@ void FilmstripFrames::mousePressEvent(QMouseEvent *event) {
|
|
|
|
|
int frameHeight = m_iconSize.height() + fs_frameSpacing + fs_iconMarginTop +
|
|
|
|
|
fs_iconMarginBottom;
|
|
|
|
|
QPoint clickedPos = event->pos() - QPoint(0, (index - i0) * frameHeight);
|
|
|
|
|
|
|
|
|
|
if (event->button() == Qt::LeftButton) {
|
|
|
|
|
if (fid == TFrameId()) return;
|
|
|
|
|
|
|
|
|
|
ComboViewerPanel *inknPaintViewerPanel =
|
|
|
|
|
TApp::instance()->getInknPaintViewerPanel();
|
|
|
|
|
|
|
|
|
|
// navigator pan
|
|
|
|
|
if (fid == TApp::instance()->getCurrentFrame()->getFid() &&
|
|
|
|
|
sl->getType() == TZP_XSHLEVEL && inknPaintViewerPanel &&
|
|
|
|
|
inknPaintViewerPanel->isVisible() &&
|
|
|
|
|
bool actualIconClicked =
|
|
|
|
|
QRect(QPoint(fs_leftMargin + fs_iconMarginLR,
|
|
|
|
|
fs_frameSpacing / 2 +
|
|
|
|
|
fs_iconMarginTop) //<- top-left position of the icon
|
|
|
|
|
,
|
|
|
|
|
m_iconSize)
|
|
|
|
|
.contains(clickedPos)) {
|
|
|
|
|
.contains(clickedPos);
|
|
|
|
|
|
|
|
|
|
if (event->button() == Qt::LeftButton ||
|
|
|
|
|
event->button() == Qt::MiddleButton) {
|
|
|
|
|
// navigator pan
|
|
|
|
|
// make sure the viewer is visible and that a toonz raster or raster level
|
|
|
|
|
// is current
|
|
|
|
|
if (fid.getNumber() >= 0 && fid == getCurrentFrameId() &&
|
|
|
|
|
(sl->getType() == TZP_XSHLEVEL || sl->getType() == OVL_XSHLEVEL) &&
|
|
|
|
|
m_viewer && m_viewer->isVisible() && actualIconClicked &&
|
|
|
|
|
(m_isGhibli != (event->button() == Qt::MiddleButton))) {
|
|
|
|
|
m_isNavigatorPanning = true;
|
|
|
|
|
execNavigatorPan(event->pos());
|
|
|
|
|
QApplication::setOverrideCursor(Qt::ClosedHandCursor);
|
|
|
|
|
} else
|
|
|
|
|
m_isNavigatorPanning = false;
|
|
|
|
|
// end of navigator section
|
|
|
|
|
|
|
|
|
|
// return if frame empty or middle button pressed
|
|
|
|
|
if (fid == TFrameId() || event->button() == Qt::MiddleButton) {
|
|
|
|
|
m_justStartedSelection = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// with shift or control
|
|
|
|
|
if (event->modifiers() & Qt::ShiftModifier) {
|
|
|
|
|
select(index, SHIFT_SELECT);
|
|
|
|
|
if (m_selection->isSelected(fid)) {
|
|
|
|
|
// click su di un frame gia' selezionato. Puo' essere l'inizio di un
|
|
|
|
|
// If the frame is already selected enable
|
|
|
|
|
// drag'n'drop
|
|
|
|
|
m_dragDropArmed = true;
|
|
|
|
|
m_pos = event->pos();
|
|
|
|
|
}
|
|
|
|
|
} else if (event->modifiers() & Qt::ControlModifier)
|
|
|
|
|
select(index, CTRL_SELECT);
|
|
|
|
|
// inbetween
|
|
|
|
|
|
|
|
|
|
// was the inbetween button clicked?
|
|
|
|
|
else if (sl->getType() == PLI_XSHLEVEL &&
|
|
|
|
|
m_selection->isInInbetweenRange(fid) &&
|
|
|
|
|
event->pos().x() > width() - 20 - fs_rightMargin) {
|
|
|
|
@ -731,25 +777,31 @@ void FilmstripFrames::mousePressEvent(QMouseEvent *event) {
|
|
|
|
|
tapp->getCurrentFrame()->setFrameIds(fids);
|
|
|
|
|
tapp->getCurrentFrame()->setFid(fid);
|
|
|
|
|
|
|
|
|
|
if (!m_selection->isSelected(fid)) // selezione semplice
|
|
|
|
|
{
|
|
|
|
|
// click su un frame non selezionato
|
|
|
|
|
m_selecting = true; // posso estendere la selezione con il drag
|
|
|
|
|
if (actualIconClicked &&
|
|
|
|
|
(!m_selection->isSelected(fid) || m_justStartedSelection)) {
|
|
|
|
|
// click on a non-selected frame
|
|
|
|
|
m_selecting = true; // allow drag-select
|
|
|
|
|
select(index, START_DRAG_SELECT);
|
|
|
|
|
} else if (m_selection->isSelected(fid)) {
|
|
|
|
|
// click su di un frame gia' selezionato. Puo' essere l'inizio di un
|
|
|
|
|
// drag'n'drop
|
|
|
|
|
// if it's already selected - it can be drag and dropped
|
|
|
|
|
m_dragDropArmed = true;
|
|
|
|
|
m_pos = event->pos();
|
|
|
|
|
// allow a the frame to be reselected if the mouse isn't moved far
|
|
|
|
|
// this is to enable a group selection to become a single selection
|
|
|
|
|
m_allowResetSelection = true;
|
|
|
|
|
m_indexForResetSelection = index;
|
|
|
|
|
} else if (!actualIconClicked) {
|
|
|
|
|
// this allows clicking the frame number to trigger an instant drag
|
|
|
|
|
select(index, ONLY_SELECT);
|
|
|
|
|
m_dragDropArmed = true;
|
|
|
|
|
m_pos = event->pos();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
update();
|
|
|
|
|
} else if (event->button() == Qt::MidButton) {
|
|
|
|
|
m_pos = event->globalPos();
|
|
|
|
|
return;
|
|
|
|
|
} else if (event->button() == Qt::RightButton) {
|
|
|
|
|
select(index);
|
|
|
|
|
}
|
|
|
|
|
m_justStartedSelection = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
@ -763,7 +815,7 @@ void FilmstripFrames::execNavigatorPan(const QPoint &point) {
|
|
|
|
|
fs_iconMarginBottom;
|
|
|
|
|
QPoint clickedPos = point - QPoint(0, (index - i0) * frameHeight);
|
|
|
|
|
|
|
|
|
|
if (fid != TApp::instance()->getCurrentFrame()->getFid()) return;
|
|
|
|
|
if (fid != getCurrentFrameId()) return;
|
|
|
|
|
|
|
|
|
|
QRect iconRect =
|
|
|
|
|
QRect(QPoint(fs_leftMargin + fs_iconMarginLR,
|
|
|
|
@ -783,21 +835,22 @@ void FilmstripFrames::execNavigatorPan(const QPoint &point) {
|
|
|
|
|
delta.setX(delta.x() * m_icon2ViewerRatio.x());
|
|
|
|
|
delta.setY(delta.y() * m_icon2ViewerRatio.y());
|
|
|
|
|
|
|
|
|
|
if (TApp::instance()->getInknPaintViewerPanel()) {
|
|
|
|
|
SceneViewer *viewer =
|
|
|
|
|
TApp::instance()->getInknPaintViewerPanel()->getSceneViewer();
|
|
|
|
|
if (viewer) viewer->navigatorPan(delta.toPoint());
|
|
|
|
|
}
|
|
|
|
|
if (m_viewer) m_viewer->navigatorPan(delta.toPoint());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
void FilmstripFrames::mouseReleaseEvent(QMouseEvent *) {
|
|
|
|
|
void FilmstripFrames::mouseReleaseEvent(QMouseEvent *e) {
|
|
|
|
|
stopAutoPanning();
|
|
|
|
|
m_selecting = false;
|
|
|
|
|
m_dragDropArmed = false;
|
|
|
|
|
m_isNavigatorPanning = false;
|
|
|
|
|
|
|
|
|
|
if (m_allowResetSelection) {
|
|
|
|
|
select(m_indexForResetSelection, ONLY_SELECT);
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
m_allowResetSelection = false;
|
|
|
|
|
m_indexForResetSelection = -1;
|
|
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -806,18 +859,19 @@ void FilmstripFrames::mouseReleaseEvent(QMouseEvent *) {
|
|
|
|
|
void FilmstripFrames::mouseMoveEvent(QMouseEvent *e) {
|
|
|
|
|
QPoint pos = e->pos();
|
|
|
|
|
int index = y2index(e->pos().y());
|
|
|
|
|
if (e->buttons() & Qt::LeftButton) {
|
|
|
|
|
if (e->buttons() & Qt::LeftButton || e->buttons() & Qt::MiddleButton) {
|
|
|
|
|
// navigator pan
|
|
|
|
|
if (m_isNavigatorPanning) {
|
|
|
|
|
execNavigatorPan(e->pos());
|
|
|
|
|
e->accept();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e->buttons() & Qt::MiddleButton) return;
|
|
|
|
|
if (m_dragDropArmed) {
|
|
|
|
|
if ((m_pos - e->pos()).manhattanLength() > 10) {
|
|
|
|
|
startDragDrop();
|
|
|
|
|
m_dragDropArmed = false;
|
|
|
|
|
m_allowResetSelection = false;
|
|
|
|
|
}
|
|
|
|
|
} else if (m_selecting) {
|
|
|
|
|
m_pos = e->globalPos();
|
|
|
|
@ -825,22 +879,40 @@ void FilmstripFrames::mouseMoveEvent(QMouseEvent *e) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// autopan
|
|
|
|
|
int speed = getOneFrameHeight() / 64;
|
|
|
|
|
|
|
|
|
|
QRect visibleRect = visibleRegion().boundingRect();
|
|
|
|
|
if (pos.y() < visibleRect.top())
|
|
|
|
|
m_scrollSpeed = -(5 + (visibleRect.top() - pos.y()) / 4);
|
|
|
|
|
else if (pos.y() > visibleRect.bottom())
|
|
|
|
|
m_scrollSpeed = (5 + (pos.y() - visibleRect.bottom()) / 4);
|
|
|
|
|
else
|
|
|
|
|
int visibleTop = visibleRect.top();
|
|
|
|
|
int visibleBottom = visibleRect.bottom();
|
|
|
|
|
if (pos.y() < visibleRect.top()) {
|
|
|
|
|
m_scrollSpeed = -speed;
|
|
|
|
|
if (visibleRect.top() - pos.y() > 30) {
|
|
|
|
|
m_timerInterval = 50;
|
|
|
|
|
} else if (visibleRect.top() - pos.y() > 15) {
|
|
|
|
|
m_timerInterval = 150;
|
|
|
|
|
} else {
|
|
|
|
|
m_timerInterval = 300;
|
|
|
|
|
}
|
|
|
|
|
} else if (pos.y() > visibleRect.bottom()) {
|
|
|
|
|
m_scrollSpeed = speed;
|
|
|
|
|
if (pos.y() - visibleRect.bottom() > 30) {
|
|
|
|
|
m_timerInterval = 50;
|
|
|
|
|
} else if (pos.y() - visibleRect.bottom() > 15) {
|
|
|
|
|
m_timerInterval = 150;
|
|
|
|
|
} else {
|
|
|
|
|
m_timerInterval = 300;
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
m_scrollSpeed = 0;
|
|
|
|
|
if (m_scrollSpeed != 0)
|
|
|
|
|
if (m_scrollSpeed != 0) {
|
|
|
|
|
startAutoPanning();
|
|
|
|
|
else
|
|
|
|
|
} else
|
|
|
|
|
stopAutoPanning();
|
|
|
|
|
update();
|
|
|
|
|
} else if (e->buttons() & Qt::MidButton) {
|
|
|
|
|
// scroll con il tasto centrale
|
|
|
|
|
pos = e->globalPos();
|
|
|
|
|
scroll(m_pos.y() - pos.y());
|
|
|
|
|
scroll((m_pos.y() - pos.y()) * 10);
|
|
|
|
|
m_pos = pos;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -882,7 +954,7 @@ void FilmstripFrames::keyPressEvent(QKeyEvent *event) {
|
|
|
|
|
m_selection->selectNone();
|
|
|
|
|
if (getLevel()) m_selection->select(fh->getFid());
|
|
|
|
|
int index = fid2index(fh->getFid());
|
|
|
|
|
if (index >= 0) exponeFrame(index);
|
|
|
|
|
if (index >= 0) showFrame(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
@ -894,7 +966,7 @@ void FilmstripFrames::wheelEvent(QWheelEvent *event) {
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
void FilmstripFrames::startAutoPanning() {
|
|
|
|
|
if (m_timerId == 0) m_timerId = startTimer(40);
|
|
|
|
|
if (m_timerId == 0) m_timerId = startTimer(m_timerInterval);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
@ -911,11 +983,15 @@ void FilmstripFrames::stopAutoPanning() {
|
|
|
|
|
|
|
|
|
|
void FilmstripFrames::timerEvent(QTimerEvent *) {
|
|
|
|
|
scroll(m_scrollSpeed);
|
|
|
|
|
|
|
|
|
|
// reset the timer in case m_scroll speed has changed
|
|
|
|
|
killTimer(m_timerId);
|
|
|
|
|
m_timerId = 0;
|
|
|
|
|
m_timerId = startTimer(m_timerInterval);
|
|
|
|
|
if (m_selecting) {
|
|
|
|
|
QPoint pos = mapFromGlobal(m_pos);
|
|
|
|
|
int index = y2index(pos.y());
|
|
|
|
|
select(index, DRAG_SELECT);
|
|
|
|
|
showFrame(index);
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -991,25 +1067,20 @@ void FilmstripFrames::onFrameSwitched() {
|
|
|
|
|
// m_selection->selectNone();
|
|
|
|
|
TApp *app = TApp::instance();
|
|
|
|
|
TFrameHandle *fh = app->getCurrentFrame();
|
|
|
|
|
TFrameId fid;
|
|
|
|
|
if (fh->isEditingLevel())
|
|
|
|
|
fid = fh->getFid();
|
|
|
|
|
else {
|
|
|
|
|
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
|
|
|
int col = app->getCurrentColumn()->getColumnIndex();
|
|
|
|
|
int row = fh->getFrame();
|
|
|
|
|
if (row < 0 || col < 0) return;
|
|
|
|
|
TXshCell cell = xsh->getCell(row, col);
|
|
|
|
|
if (cell.isEmpty()) return;
|
|
|
|
|
fid = cell.getFrameId();
|
|
|
|
|
}
|
|
|
|
|
TFrameId fid = getCurrentFrameId();
|
|
|
|
|
|
|
|
|
|
int index = fid2index(fid);
|
|
|
|
|
if (index >= 0) {
|
|
|
|
|
exponeFrame(index);
|
|
|
|
|
// clear selection and select only the destination frame
|
|
|
|
|
showFrame(index);
|
|
|
|
|
|
|
|
|
|
TFilmstripSelection *fsSelection =
|
|
|
|
|
dynamic_cast<TFilmstripSelection *>(TSelection::getCurrent());
|
|
|
|
|
if (fsSelection) select(index, ONLY_SELECT);
|
|
|
|
|
|
|
|
|
|
// don't select if already selected - may be part of a group selection
|
|
|
|
|
if (!m_selection->isSelected(index2fid(index)) && fsSelection) {
|
|
|
|
|
select(index, ONLY_SELECT);
|
|
|
|
|
m_justStartedSelection = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|