void FrameDisplayGL ::resizeGL(int newWidth, int newHeight) { currWidth =visibleRegion().boundingRect().width(); currHeight=visibleRegion().boundingRect().height(); glViewport( 0,0,newWidth,newHeight ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( 0, newWidth, newHeight, 0, 0, 1 ); glMatrixMode(GL_MODELVIEW); }
void GenericPanel::mouseMoveEvent(QMouseEvent *e) { int row = getViewer()->yToRow(e->pos().y()); int col = getViewer()->xToColumn(e->pos().x()); if (e->buttons() != 0 && m_dragTool != 0) { if ((e->buttons() & Qt::LeftButton) != 0 && !visibleRegion().contains(e->pos())) { QRect bounds = visibleRegion().boundingRect(); m_viewer->setAutoPanSpeed(bounds, e->pos()); } else m_viewer->stopAutoPan(); m_dragTool->drag(row, col, e); } }
void RowArea::mouseMoveEvent(QMouseEvent *event) { m_viewer->setQtModifiers(event->modifiers()); QPoint pos = event->pos(); // pan by middle-drag if (m_isPanning) { QPoint delta = m_pos - pos; delta.setX(0); m_viewer->scroll(delta); return; } m_row = m_viewer->yToRow(pos.y()); int x = pos.x(); if ((event->buttons() & Qt::LeftButton) != 0 && !visibleRegion().contains(pos)) { QRect bounds = visibleRegion().boundingRect(); m_viewer->setAutoPanSpeed(bounds, QPoint(bounds.left(), pos.y())); } else m_viewer->stopAutoPan(); m_pos = pos; m_viewer->dragToolDrag(event); if (getDragTool()) { m_showOnionToSet = false; return; } int currentRow = TApp::instance()->getCurrentFrame()->getFrame(); int row = m_viewer->yToRow(m_pos.y()); if (row < 0) return; // "decide" se mostrare la possibilita' di settare l'onion skin if (7 <= x && x <= 13 && row != currentRow) m_showOnionToSet = true; else m_showOnionToSet = false; update(); if (m_xa <= x && x <= m_xa + 10 && row == m_r0) m_tooltip = tr("Playback Start Marker"); else if (m_xa <= x && x <= m_xa + 10 && row == m_r1) m_tooltip = tr("Playback End Marker"); else if (row == currentRow) m_tooltip = tr("Curren Frame"); else m_tooltip = tr(""); }
void ImageView::mousePressEvent(QMouseEvent *event) { switch (m_mouseMode) { case MM_ZOOM: m_rubberBand->setGeometry(0, 0, 0, 0); if (event->modifiers() & Qt::ControlModifier) { m_rubberBand->hide(); } else { m_rubberBandOrigin = event->pos(); m_rubberBand->show(); } break; case MM_MINMAX: m_minMaxLens->show(); //this->repaint(this->m_minMaxLens->geometry()); this->repaint(0, 0, -1, -1); this->m_minMaxLens->setGeometry(QRect()); m_minMaxLensOrigin = event->pos(); break; case MM_PICK: if (visibleRegion().contains(event->pos())) { int x = event->x(); int y = event->y(); this->canvasToImage(x, y); emit picked(x, y); } break; default: break; } }
void RowPanel::drawRows(QPainter &p, int r0, int r1) { #ifdef WIN32 static QFont font("Arial", 9, QFont::Bold); #else static QFont font("Helvetica", 9, QFont::Bold); #endif p.setFont(font); QRect visibleRect = visibleRegion().boundingRect(); int x0 = visibleRect.left(); int x1 = visibleRect.right(); int y0 = visibleRect.top(); int y1 = visibleRect.bottom(); int r; for (r = r0; r <= r1; r++) { int y = getViewer()->rowToY(r); //draw horizontal line QColor color = (getViewer()->isMarkRow(r)) ? getViewer()->getMarkerLineColor() : getViewer()->getLightLineColor(); p.setPen(color); p.drawLine(x0, y, x1, y); //draw numbers p.setPen(getViewer()->getTextColor()); QString number = QString::number(r + 1); p.drawText(QRect(x0, y + 1, width(), 18), Qt::AlignHCenter | Qt::AlignBottom, number); } // erase the marker interval at upper-end if (r0 == 0) { p.setPen(getViewer()->getLightLineColor()); p.drawLine(x0, getViewer()->rowToY(0), x1, getViewer()->rowToY(0)); } }
void StatusBar::onVolumeButtonsPressed() { QRegion region = visibleRegion(); if (region.isEmpty()) { return; } QRect visible_rect = region.boundingRect(); if (visible_rect.width() < height() && visible_rect.height() < height()) { return; } VolumeControlDialog * dialog = volumeDialog(true); if (!dialog->isVisible()) { dialog->ensureVisible(); onyx::screen::instance().updateWidget(0, onyx::screen::ScreenProxy::GU, false, onyx::screen::ScreenCommand::WAIT_COMMAND_FINISH); } else { dialog->resetTimer(); } }
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); sb->setValue(sbValue + dy); }
FrameDisplayGL ::FrameDisplayGL(QWidget *parent) { QGLFormat frmt; setFormat(frmt); currWidth =visibleRegion().boundingRect().width(); currHeight=visibleRegion().boundingRect().height(); QString msg = QString("Loading image into QImage"); Profiler timer(msg); timer.start(); ImageLoader i; QString x("/home/xmk/programming/capella/test/images/m51.jpg"); image = i.imageLoader( &x, 0 ); //i.loadImage("/home/xmk/programming/skeleton/test/images/m42.jpg", 1 ); timer.finish(); }
void RowArea::mousePressEvent(QMouseEvent *event) { m_viewer->setQtModifiers(event->modifiers()); if (event->button() == Qt::LeftButton) { bool playRangeModifierisClicked = false; TApp *app = TApp::instance(); TXsheet *xsh = app->getCurrentScene()->getScene()->getXsheet(); TPoint pos(event->pos().x(), event->pos().y()); int row = m_viewer->yToRow(pos.y); QRect visibleRect = visibleRegion().boundingRect(); int playR0, playR1, step; XsheetGUI::getPlayRange(playR0, playR1, step); bool playRangeEnabled = playR0 <= playR1; if (!playRangeEnabled) { TXsheet *xsh = m_viewer->getXsheet(); playR1 = xsh->getFrameCount() - 1; playR0 = 0; } if (playR1 == -1) { //getFrameCount = 0 i.e. xsheet is empty setDragTool(XsheetGUI::DragTool::makeCurrentFrameModifierTool(m_viewer)); } else if (m_xa <= pos.x && pos.x <= m_xa + 10 && (row == playR0 || row == playR1)) { if (!playRangeEnabled) XsheetGUI::setPlayRange(playR0, playR1, step); setDragTool(XsheetGUI::DragTool::makePlayRangeModifierTool(m_viewer)); playRangeModifierisClicked = true; } else setDragTool(XsheetGUI::DragTool::makeCurrentFrameModifierTool(m_viewer)); //when shift+click the row area, select a single row region in the cell area if (!playRangeModifierisClicked && 0 != (event->modifiers() & Qt::ShiftModifier)) { int filledCol; for (filledCol = xsh->getColumnCount() - 1; filledCol >= 0; filledCol--) { TXshColumn *currentColumn = xsh->getColumn(filledCol); if (!currentColumn) continue; if (!currentColumn->isEmpty()) break; } m_viewer->getCellSelection()->selectNone(); m_viewer->getCellSelection()->selectCells(row, 0, row, tmax(0, filledCol)); m_viewer->updateCellRowAree(); } m_viewer->dragToolClick(event); event->accept(); } // left-click // pan by middle-drag else if (event->button() == Qt::MidButton) { m_pos = event->pos(); m_isPanning = true; } }
void SimpleVisW::start( bool v ) { if ( v || dw->visibleRegion() != QRegion() || visibleRegion() != QRegion() ) { simpleVis.soundBuffer( true ); tim.start( interval ); timInterval.start(); } }
//----------------------------------------------------------------------------- void FilmstripFrames::updateContentHeight(int minimumHeight) { if (minimumHeight < 0) minimumHeight = visibleRegion().boundingRect().bottom(); int contentHeight = getFramesHeight(); if (contentHeight < minimumHeight) contentHeight = minimumHeight; int parentHeight = parentWidget()->height(); if (contentHeight < parentHeight) contentHeight = parentHeight; if (contentHeight != height()) setFixedHeight(contentHeight); }
void ScrollingContextualView::paintEvent(QPaintEvent *e) { Q_UNUSED(e); QPainter painter(this); QRect rect = visibleRegion().boundingRect(); QLinearGradient shadow; shadow.setFinalStop(0, 20); shadow.setColorAt(0, QColor(0x00, 0x00, 0x00, 48)); shadow.setColorAt(1, QColor(0x00, 0x00, 0x00, 0)); painter.fillRect(rect.x(), rect.y(), rect.width(), 20, QBrush(shadow)); }
void HistoryField::updateContentHeight(int minimumHeight) { if (minimumHeight < 0) minimumHeight = visibleRegion().boundingRect().bottom(); int contentHeight = TUndoManager::manager()->getHistoryCount() * HISTORY_ITEM_HEIGHT; if (contentHeight < minimumHeight) contentHeight = minimumHeight; int parentHeight = parentWidget()->height(); if (contentHeight < parentHeight) contentHeight = parentHeight; if (contentHeight != height()) setFixedHeight(contentHeight); }
void FilmstripFrames::keyPressEvent(QKeyEvent *event) { TFrameHandle *fh = TApp::instance()->getCurrentFrame(); TXshSimpleLevel *level = getLevel(); if (!level) return; std::vector<TFrameId> fids; level->getFids(fids); if (fids.empty()) return; fh->setFrameIds(fids); if (event->key() == Qt::Key_Up) fh->prevFrame(); else if (event->key() == Qt::Key_Down) fh->nextFrame(); else if (event->key() == Qt::Key_Home) fh->firstFrame(); else if (event->key() == Qt::Key_End) fh->lastFrame(); else if (event->key() == Qt::Key_PageDown) { int frameHeight = m_iconSize.height(); int visibleHeight = visibleRegion().rects()[0].height(); int visibleFrames = double(visibleHeight) / double(frameHeight); scroll(visibleFrames * frameHeight); return; } else if (event->key() == Qt::Key_PageUp) { int frameHeight = m_iconSize.height(); int visibleHeight = visibleRegion().rects()[0].height(); int visibleFrames = double(visibleHeight) / double(frameHeight); scroll(-visibleFrames * frameHeight); return; } else return; m_selection->selectNone(); if (getLevel()) m_selection->select(fh->getFid()); int index = fid2index(fh->getFid()); if (index >= 0) exponeFrame(index); }
void FilmstripFrames::mouseMoveEvent(QMouseEvent *e) { QPoint pos = e->pos(); int index = y2index(e->pos().y()); if (e->buttons() & Qt::LeftButton) { // navigator pan if (m_isNavigatorPanning) { execNavigatorPan(e->pos()); e->accept(); return; } if (m_dragDropArmed) { if ((m_pos - e->pos()).manhattanLength() > 10) { startDragDrop(); m_dragDropArmed = false; } } else if (m_selecting) { m_pos = e->globalPos(); select(index, DRAG_SELECT); } // autopan 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 m_scrollSpeed = 0; if (m_scrollSpeed != 0) startAutoPanning(); else stopAutoPanning(); update(); } else if (e->buttons() & Qt::MidButton) { // scroll con il tasto centrale pos = e->globalPos(); scroll(m_pos.y() - pos.y()); m_pos = pos; } }
void ImageView::mouseMoveEvent(QMouseEvent *event) { /* this is really ugly! But as far as I can see the only way to ensure that * the ImageView always has focus when the window is in the foreground */ if (m_pWorkspace->activeWindow() == parent()->parent()->parent()->parent()) { setFocus(Qt::MouseFocusReason); } if (visibleRegion().contains(event->pos())) { int x = event->x(); int y = event->y(); this->canvasToImage(x, y); emit mousePosChanged(x, y); } else { emit mousePosChanged(-1, -1); } switch (m_mouseMode) { case MM_ZOOM: if (event->modifiers() & Qt::ControlModifier) { m_rubberBand->hide(); } else if (m_rubberBand->isVisible()) { m_rubberBand->setGeometry(QRect(m_rubberBandOrigin, event->pos()).normalized()); } break; case MM_MINMAX: if ((event->buttons() & Qt::LeftButton) && m_minMaxLens->isVisible()) { m_minMaxLens->setGeometry(QRect(m_minMaxLensOrigin, event->pos()).normalized()); } break; default: break; } }
void MarkerRuler::paintEvent(QPaintEvent*) { QPainter painter(this); painter.setFont(*m_barFont); if (getHScaleFactor() != 1.0) painter.scale(getHScaleFactor(), 1.0); // See note elsewhere... QRect clipRect = visibleRegion().boundingRect(); // In a stylesheet world, we have to paint our our own background to rescue // it from the muddle of QWidget background style hacks QBrush bg = QBrush(GUIPalette::getColour(GUIPalette::RulerBackground)); painter.fillRect(clipRect, bg); // Now we set the pen dungle flungy to the newly defined foreground color in // GUIPalette to make the text all pretty like again. (Whew.) painter.setPen(GUIPalette::getColour(GUIPalette::RulerForeground)); int firstBar = m_rulerScale->getBarForX(clipRect.x() - m_currentXOffset - m_xorigin); int lastBar = m_rulerScale->getLastVisibleBar(); if (firstBar < m_rulerScale->getFirstVisibleBar()) { firstBar = m_rulerScale->getFirstVisibleBar(); } painter.drawLine(m_currentXOffset, 0, static_cast<int>(clipRect.width() / getHScaleFactor()), 0); float minimumWidth = 25.0; float testSize = ((float)(m_rulerScale->getBarPosition(firstBar + 1) - m_rulerScale->getBarPosition(firstBar))) / minimumWidth; int every = 0; int count = 0; if (testSize < 1.0) { every = (int(1.0 / testSize)); if (every % 2 == 0) every++; } for (int i = firstBar; i <= lastBar; ++i) { double x = m_rulerScale->getBarPosition(i) + m_xorigin + m_currentXOffset; if ((x * getHScaleFactor()) > clipRect.x() + clipRect.width()) break; // always the first bar number if (every && i != firstBar) { if (count < every) { count++; continue; } // reset count if we passed count = 0; } // adjust count for first bar line if (every == firstBar) count++; if (i != lastBar) { painter.drawLine(static_cast<int>(x), 0, static_cast<int>(x), m_barHeight); // disable worldXForm for text //QPoint textDrawPoint = painter.xForm(QPoint(static_cast<int>(x + 4), 12)); QPoint textDrawPoint = QPoint(static_cast<int>(x + 4), 12) * painter.combinedTransform(); bool enableXForm = painter.worldMatrixEnabled(); painter.setWorldMatrixEnabled(false); if (i >= 0) painter.drawText(textDrawPoint, QString("%1").arg(i + 1)); painter.setWorldMatrixEnabled(enableXForm); } else { const QPen normalPen = painter.pen(); ; QPen endPen(Qt::black, 2); painter.setPen(endPen); painter.drawLine(static_cast<int>(x), 0, static_cast<int>(x), m_barHeight); painter.setPen(normalPen); } } if (m_doc) { Composition &comp = m_doc->getComposition(); Composition::markercontainer markers = comp.getMarkers(); Composition::markerconstiterator it; timeT start = comp.getBarStart(firstBar); timeT end = comp.getBarEnd(lastBar); QFontMetrics metrics = painter.fontMetrics(); for (it = markers.begin(); it != markers.end(); ++it) { if ((*it)->getTime() >= start && (*it)->getTime() < end) { QString name(strtoqstr((*it)->getName())); double x = m_rulerScale->getXForTime((*it)->getTime()) + m_xorigin + m_currentXOffset; painter.fillRect(static_cast<int>(x), 1, static_cast<int>(metrics.width(name) + 5), m_barHeight - 2, QBrush(GUIPalette::getColour(GUIPalette::MarkerBackground))); painter.drawLine(int(x), 1, int(x), m_barHeight - 2); painter.drawLine(int(x) + 1, 1, int(x) + 1, m_barHeight - 2); // NO_QT3 NOTE: This next bit is a complete shot in the dark, // and is likely to be wrong. // was: // //QPoint textDrawPoint = painter.xForm // (QPoint(static_cast<int>(x + 3), m_barHeight - 4)); // QPoint textDrawPoint = QPoint(static_cast<int>(x + 3), m_barHeight - 4) * painter.combinedTransform(); // disable worldXForm for text bool enableXForm = painter.worldMatrixEnabled(); painter.setWorldMatrixEnabled(false); painter.drawText(textDrawPoint, name); painter.setWorldMatrixEnabled(enableXForm); } } } }
void SourceCodeTreeView::Repaint() { QRect dirtyRegionRect = visibleRegion().boundingRect(); setDirtyRegion(dirtyRegionRect); repaint(); }
void ImageViewer::contextMenuEvent(QContextMenuEvent *event) { if (!m_flipbook) return; QAction *action; if (m_isColorModel) { event->ignore(); return; } QMenu *menu = new QMenu(this); if (m_flipbook->getPreviewedFx()) { if (!(windowState() & Qt::WindowFullScreen)) { action = menu->addAction(tr("Clone Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_ClonePreview))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(clonePreview())); } if (m_flipbook->isFreezed()) { action = menu->addAction(tr("Unfreeze Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_FreezePreview))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(unfreezePreview())); } else { action = menu->addAction(tr("Freeze Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_FreezePreview))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(freezePreview())); } action = menu->addAction(tr("Regenerate Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_RegeneratePreview))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(regenerate())); action = menu->addAction(tr("Regenerate Frame Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_RegenerateFramePr))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(regenerateFrame())); menu->addSeparator(); } action = menu->addAction(tr("Load / Append Images")); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(loadImages())); // history of the loaded paths of flipbook action = CommandManager::instance()->getAction(MI_LoadRecentImage); menu->addAction(action); action->setParent(m_flipbook); if (m_flipbook->isSavable()) { action = menu->addAction(tr("Save Images")); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(saveImages())); } menu->addSeparator(); QAction *reset = menu->addAction(tr("Reset View")); reset->setShortcut( QKeySequence(CommandManager::instance()->getKeyFromId(V_ZoomReset))); connect(reset, SIGNAL(triggered()), SLOT(resetView())); QAction *fit = menu->addAction(tr("Fit To Window")); fit->setShortcut( QKeySequence(CommandManager::instance()->getKeyFromId(V_ZoomFit))); connect(fit, SIGNAL(triggered()), SLOT(fitView())); #ifdef _WIN32 if (ImageUtils::FullScreenWidget *fsWidget = dynamic_cast<ImageUtils::FullScreenWidget *>(parentWidget())) { bool isFullScreen = (fsWidget->windowState() & Qt::WindowFullScreen) != 0; action = menu->addAction(isFullScreen ? tr("Exit Full Screen Mode") : tr("Full Screen Mode")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(V_ShowHideFullScreen))); connect(action, SIGNAL(triggered()), fsWidget, SLOT(toggleFullScreen())); } #endif bool addedSep = false; if (m_isHistogramEnable && visibleRegion().contains(event->pos() * getDevPixRatio())) { menu->addSeparator(); addedSep = true; action = menu->addAction(tr("Show Histogram")); connect(action, SIGNAL(triggered()), SLOT(showHistogram())); } if (m_visualSettings.m_doCompare) { if (!addedSep) menu->addSeparator(); action = menu->addAction(tr("Swap Compared Images")); connect(action, SIGNAL(triggered()), SLOT(swapCompared())); } menu->exec(event->globalPos()); action = CommandManager::instance()->getAction(MI_LoadRecentImage); action->setParent(0); delete menu; update(); }
void ImageView::mouseReleaseEvent(QMouseEvent *event) { switch (m_mouseMode) { case MM_ZOOM: m_rubberBand->hide(); if (m_rubberBand->geometry().isNull()) { /* Zoom step. */ int newCenterX, newCenterY; int x = event->x(); int y = event->y(); if (event->modifiers() & Qt::ControlModifier) { this->zoomOut(); if (m_zoomLevel != 1) { newCenterX = (int)(x * (this->m_zoomLevel - 1.0) / this->m_zoomLevel); newCenterY = (int)(y * (this->m_zoomLevel - 1.0) / this->m_zoomLevel); emit viewCenterChanged(newCenterX, newCenterY); if (visibleRegion().contains(event->pos())) { this->canvasToImage(x, y); emit mousePosChanged(x, y); } else { emit mousePosChanged(-1, -1); } } } else if (event->modifiers() == Qt::ShiftModifier) { this->setZoomLevel(1.0f); } else { this->zoomIn(); newCenterX = (int)(x * (this->m_zoomLevel + 1.0) / this->m_zoomLevel); newCenterY = (int)(y * (this->m_zoomLevel + 1.0) / this->m_zoomLevel); emit viewCenterChanged(newCenterX, newCenterY); if (visibleRegion().contains(event->pos())) { this->canvasToImage(x, y); emit mousePosChanged(x, y); } else { emit mousePosChanged(-1, -1); } } } else { /* Lasso zoom. */ if (!(event->modifiers() & Qt::ControlModifier)) { zoomRegion(m_rubberBand->geometry()); } } break; case MM_MINMAX: { QRect selRect = this->m_minMaxLens->geometry(); //QRect visRect = this->visibleRegion().boundingRect(); selRect.moveLeft(selRect.left() / this->m_zoomLevel); selRect.moveTop(selRect.top() / this->m_zoomLevel); selRect.setWidth(::ceilf(static_cast<float>(selRect.width()) / this->m_zoomLevel)); selRect.setHeight(::ceilf(static_cast<float>(selRect.height()) / this->m_zoomLevel)); emit minMaxAreaChanged(selRect); this->m_minMaxLens->setVisible(false); if (event->modifiers() & Qt::ControlModifier) { emit setMappingBounds(); } } break; default: break; } }
void RowArea::drawRows(QPainter &p, int r0, int r1) { int playR0, playR1, step; XsheetGUI::getPlayRange(playR0, playR1, step); if (!XsheetGUI::isPlayRangeEnabled()) { TXsheet *xsh = m_viewer->getXsheet(); playR1 = xsh->getFrameCount() - 1; playR0 = 0; } #ifdef _WIN32 static QFont font("Arial", XSHEET_FONT_SIZE, QFont::Bold); #else static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal); #endif p.setFont(font); // marker interval int distance, offset; TApp::instance()->getCurrentScene()->getScene()->getProperties()->getMarkers(distance, offset); //default value if (distance == 0) distance = 6; QRect visibleRect = visibleRegion().boundingRect(); int x0 = visibleRect.left(); int x1 = visibleRect.right(); int y0 = visibleRect.top(); int y1 = visibleRect.bottom(); for (int r = r0; r <= r1; r++) { int y = m_viewer->rowToY(r); //--- draw horizontal line QColor color = ((r - offset) % distance != 0) ? m_viewer->getLightLineColor() : m_viewer->getMarkerLineColor(); p.setPen(color); p.drawLine(x0, y, x1, y); // draw frame text if (playR0 <= r && r <= playR1) { p.setPen(((r - m_r0) % step == 0) ? m_viewer->getPreviewFrameTextColor() : m_viewer->getTextColor()); } //not in preview range else p.setPen(m_viewer->getTextColor()); switch (m_viewer->getFrameDisplayStyle()) { case XsheetViewer::SecAndFrame: { int frameRate = TApp::instance()->getCurrentScene()->getScene()->getProperties()->getOutputProperties()->getFrameRate(); QString str; int koma = (r + 1) % frameRate; if (koma == 1) { int sec = (r + 1) / frameRate; str = QString("%1' %2\"").arg(QString::number(sec).rightJustified(2, '0')).arg(QString::number(koma).rightJustified(2, '0')); } else { if (koma == 0) koma = frameRate; str = QString("%1\"").arg(QString::number(koma).rightJustified(2, '0')); } p.drawText(QRect(width() / 2 - 15, y + 1, width() / 2 + 7, RowHeight - 2), Qt::AlignRight | Qt::AlignBottom, str); break; } case XsheetViewer::Frame: { QString number = QString::number(r + 1); p.drawText(QRect(width() / 2 - 2, y + 1, width() / 2, RowHeight - 2), Qt::AlignHCenter | Qt::AlignBottom, number); break; } //6 second sheet (144frames per page) case XsheetViewer::SixSecSheet: { int frameRate = TApp::instance()->getCurrentScene()->getScene()->getProperties()->getOutputProperties()->getFrameRate(); QString str; int koma = (r + 1) % (frameRate * 6); if ((r + 1) % frameRate == 1) { int page = (r + 1) / (frameRate * 6) + 1; str = QString("p%1 %2").arg(QString::number(page)).arg(QString::number(koma).rightJustified(3, '0')); } else { if (koma == 0) koma = frameRate * 6; str = QString("%1").arg(QString::number(koma).rightJustified(3, '0')); } p.drawText(QRect(width() / 2 - 21, y + 1, width() / 2 + 7, RowHeight - 2), Qt::AlignRight | Qt::AlignBottom, str); break; } //3 second sheet (72frames per page) case XsheetViewer::ThreeSecSheet: { int frameRate = TApp::instance()->getCurrentScene()->getScene()->getProperties()->getOutputProperties()->getFrameRate(); QString str; int koma = (r + 1) % (frameRate * 3); if ((r + 1) % frameRate == 1) { int page = (r + 1) / (frameRate * 3) + 1; str = QString("p%1 %2").arg(QString::number(page)).arg(QString::number(koma).rightJustified(2, '0')); } else { if (koma == 0) koma = frameRate * 3; str = QString("%1").arg(QString::number(koma).rightJustified(2, '0')); } p.drawText(QRect(width() / 2 - 21, y + 1, width() / 2 + 7, RowHeight - 2), Qt::AlignRight | Qt::AlignBottom, str); break; } } } // hide the top-most horizontal line if (r0 == 0) { p.setPen(m_viewer->getLightLineColor()); p.drawLine(x0, m_viewer->rowToY(0), x1, m_viewer->rowToY(0)); } }
Rosegarden::Marker* MarkerRuler::getMarkerAtClickPosition() { // NO_QT3 NOTE: // // Let's try this. We used to use QRect visibleRect() to get a rect for // further calculations. Now the equivalent method returns a region instead // of a rect. A region could be a complex shape, but our old code was // written with a rectangle in mind. Let's try getting the boundingRect for // the entire region, and using that for our subsequent calculations, // instead of refactoring everything to take a region into account (which // requires deeper understanding of what the old code did than I have at a // glance). This is a shot in the dark, and it's hard to predict how this // is going to behave until the code is running and testable. QRect clipRect = visibleRegion().boundingRect(); int firstBar = m_rulerScale->getBarForX(clipRect.x() - m_currentXOffset - m_xorigin); int lastBar = m_rulerScale->getLastVisibleBar(); if (firstBar < m_rulerScale->getFirstVisibleBar()) { firstBar = m_rulerScale->getFirstVisibleBar(); } Composition &comp = m_doc->getComposition(); Composition::markercontainer markers = comp.getMarkers(); timeT start = comp.getBarStart(firstBar); timeT end = comp.getBarEnd(lastBar); // need these to calculate the visible extents of a marker tag QFontMetrics metrics(*m_barFont); for (Composition::markerconstiterator i = markers.begin(); i != markers.end(); ++i) { if ((*i)->getTime() >= start && (*i)->getTime() < end) { QString name(strtoqstr((*i)->getName())); int x = m_rulerScale->getXForTime((*i)->getTime()) + m_xorigin + m_currentXOffset; int width = metrics.width(name) + 5; int nextX = -1; Composition::markerconstiterator j = i; ++j; if (j != markers.end()) { nextX = m_rulerScale->getXForTime((*j)->getTime()) + m_xorigin + m_currentXOffset; } if (m_clickX >= x && m_clickX <= x + width) { if (nextX < x || m_clickX <= nextX) { return *i; } } } } return 0L; }
void SystemTopologyDrawing::paintTopology( QPainter &painter, bool optimizeScreen ) { initScale(); int dimIndex[ 3 ]; dimIndex[ 0 ] = -1; dimIndex[ 1 ] = -1; dimIndex[ 2 ] = -1; plane.setFoldingSeparator( data->getFoldingSeparators() ); //if the right mouse is pressed, then we must find the topology item that is selected; //the position of the selected item will be stored in dimIndex; //similarly, if the left mouse was pressed and released at the same position, we //will select the corresponding tree item, and thus need its id int selectedPlane = -1; if ( rightMousePressed || toSelect ) { // get selected plane index Tetragon polygon; polygon.push_back( QPointF( plane.getPoint( 0 )->getX(), plane.getPoint( 0 )->getY() ) ); polygon.push_back( QPointF( plane.getPoint( 1 )->getX(), plane.getPoint( 1 )->getY() ) ); polygon.push_back( QPointF( plane.getPoint( 2 )->getX(), plane.getPoint( 2 )->getY() ) ); polygon.push_back( QPointF( plane.getPoint( 3 )->getX(), plane.getPoint( 3 )->getY() ) ); if ( plane.isRising() ) // check from top to bottom, if user has clicked inside plane { for ( selectedPlane = 0; selectedPlane < ( int )data->getDim( ZZ ); selectedPlane++ ) { //painter.setPen(QPen(Qt::red, 7, Qt::SolidLine)); painter.drawPolygon(polygon); if ( polygon.containsPoint( lastPoint ) ) { break; } polygon.translate( 0, transform->getPlaneDistance() ); } } else // check from bottom to top { polygon.translate( 0, ( ( int )data->getDim( ZZ ) - 1 ) * transform->getPlaneDistance() ); for ( selectedPlane = data->getDim( ZZ ) - 1; selectedPlane >= 0; selectedPlane-- ) { //painter.setPen(QPen(Qt::red, 7, Qt::SolidLine)); painter.drawPolygon(polygon); if ( polygon.containsPoint( lastPoint ) ) { break; } polygon.translate( 0, -transform->getPlaneDistance() ); } } } dimIndex[ ZZ ] = selectedPlane; //if the planes are rising, then we paint the lowest plane first, //otherwise we start with the plane on the top int dummy1 = -1; int dummy2 = -1; if ( plane.isRising() ) { // since the plane is rising, we paint the lowest plane first plane.yScroll( ( double )( data->getDim( ZZ ) - 1 ) * transform->getPlaneDistance() ); //compute which items on planes are visible if the plane is partly //covered by another plane plane.computeVisibles( data, -transform->getPlaneDistance() ); //paint all planes for ( int i = data->getDim( ZZ ) - 1; i >= 0; i-- ) { bool toPaint = true; if ( optimizeScreen ) { //this is the region of this widget which is not covered by other //widgets; only planes in this widget must be painted QRect rect = visibleRegion().boundingRect(); //don't paint if whole plane is below the visible rectangle if ( ( int )plane.getPoint( 0 )->getY() > rect.y() + rect.height() && ( int )plane.getPoint( 1 )->getY() > rect.y() + rect.height() && ( int )plane.getPoint( 2 )->getY() > rect.y() + rect.height() && ( int )plane.getPoint( 3 )->getY() > rect.y() + rect.height() ) { toPaint = false; } //also don't paint if plane is above the visible rectangle else if ( ( int )plane.getPoint( 0 )->getY() < rect.y() && ( int )plane.getPoint( 1 )->getY() < rect.y() && ( int )plane.getPoint( 2 )->getY() < rect.y() && ( int )plane.getPoint( 3 )->getY() < rect.y() ) { toPaint = false; } } // plane.paint method also calculated the index of the selected item if ( toPaint ) { plane.paint( data, i, painter, i > 0, ( i == selectedPlane && ( rightMousePressed || toSelect ) ? &lastPoint : NULL ), ( i == selectedPlane ? dimIndex[ XX ] : dummy1 ), ( i == selectedPlane ? dimIndex[ YY ] : dummy2 ) ); } //scroll the plane to represent the next plane above the //currently painted one if ( i > 0 ) { plane.yScroll( -transform->getPlaneDistance() ); } } } else { //compute which items on planes are visible if the plane is partly //covered by another plane plane.computeVisibles( data, transform->getPlaneDistance() ); //paint all planes; since the plane is not rising, we paint the //plane on the top first for ( unsigned i = 0; i < data->getDim( ZZ ); i++ ) { bool toPaint = true; if ( optimizeScreen ) { //this is the region of this widget which is not covered by other //widgets; only planes in this widget must be painted QRect rect = visibleRegion().boundingRect(); //don't paint if whole plane is below the visible rectangle if ( ( int )plane.getPoint( 0 )->getY() > rect.y() + rect.height() && ( int )plane.getPoint( 1 )->getY() > rect.y() + rect.height() && ( int )plane.getPoint( 2 )->getY() > rect.y() + rect.height() && ( int )plane.getPoint( 3 )->getY() > rect.y() + rect.height() ) { toPaint = false; } //also don't paint if plane is above the visible rectangle else if ( ( int )plane.getPoint( 0 )->getY() < rect.y() && ( int )plane.getPoint( 1 )->getY() < rect.y() && ( int )plane.getPoint( 2 )->getY() < rect.y() && ( int )plane.getPoint( 3 )->getY() < rect.y() ) { toPaint = false; } } if ( toPaint ) { plane.paint( data, i, painter, i < data->getDim( ZZ ) - 1, ( ( int )i == selectedPlane && ( rightMousePressed || toSelect ) ? &lastPoint : NULL ), ( ( int )i == selectedPlane ? dimIndex[ XX ] : dummy1 ), ( ( int )i == selectedPlane ? dimIndex[ YY ] : dummy2 ) ); } if ( i < data->getDim( ZZ ) - 1 ) { plane.yScroll( transform->getPlaneDistance() ); } } //scroll the plane to represent the next plane below the //currently painted one plane.yScroll( -( double )( data->getDim( ZZ ) - 1 ) * transform->getPlaneDistance() ); } QPen pen( Qt::black ); pen.setWidth( 0 ); painter.setPen( pen ); //if the left mouse button was pressed and released without moving //then we select the corresponding item if ( toSelect && dimIndex[ 0 ] != -1 && dimIndex[ 1 ] != -1 && dimIndex[ 2 ] != -1 ) { int systemId = data->getSystemId( dimIndex[ XX ], dimIndex[ YY ], dimIndex[ ZZ ] ); if ( systemId >= 0 ) { selectedSystemId = systemId; } else { selectedSystemId = -1; } } else { selectedSystemId = -1; } if ( rightMousePressed ) // show Tooltip { int x = dimIndex[ XX ]; int y = dimIndex[ YY ]; int z = dimIndex[ ZZ ]; QPoint pos = this->mapToGlobal( lastPoint ); pos.rx() += 5; pos.ry() += 5; info->showInfo( pos, data->getTooltipText( x, y, z ) ); } if ( data->hasInvalidDimensions() ) { painter.setOpacity( 0.7 ); painter.fillRect( this->rect(), Qt::gray ); } }
void RowArea::mouseMoveEvent(QMouseEvent *event) { m_viewer->setQtModifiers(event->modifiers()); QPoint pos = event->pos(); // pan by middle-drag if (m_isPanning) { QPoint delta = m_pos - pos; delta.setX(0); m_viewer->scroll(delta); return; } m_row = m_viewer->yToRow(pos.y()); int x = pos.x(); if ((event->buttons() & Qt::LeftButton) != 0 && !visibleRegion().contains(pos)) { QRect bounds = visibleRegion().boundingRect(); m_viewer->setAutoPanSpeed(bounds, QPoint(bounds.left(), pos.y())); } else m_viewer->stopAutoPan(); m_pos = pos; m_viewer->dragToolDrag(event); m_showOnionToSet = None; if (getDragTool()) return; int currentRow = TApp::instance()->getCurrentFrame()->getFrame(); int row = m_viewer->yToRow(m_pos.y()); if (row < 0) return; // "decide" se mostrare la possibilita' di settare l'onion skin if (Preferences::instance()->isOnionSkinEnabled()) { int onionDotDiam = 8; if (x <= onionDotDiam && row != currentRow) m_showOnionToSet = Fos; else if (x <= onionDotDiam * 2 && row != currentRow) m_showOnionToSet = Mos; } update(); if (m_xa <= x && x <= m_xa + 10 && row == m_r0) m_tooltip = tr("Playback Start Marker"); else if (m_xa <= x && x <= m_xa + 10 && row == m_r1) m_tooltip = tr("Playback End Marker"); else if (row == currentRow) { if (Preferences::instance()->isOnionSkinEnabled() && x < RowHeight + 2) m_tooltip = tr("Double Click to Toggle Onion Skin"); else m_tooltip = tr("Curren Frame"); } else if (m_showOnionToSet == Fos) m_tooltip = tr("Fixed Onion Skin Toggle"); else if (m_showOnionToSet == Mos) m_tooltip = tr("Relative Onion Skin Toggle"); else m_tooltip = tr(""); }