/*!!!
void MatrixResizer::slotMatrixScrolled(int newX, int newY)
{
    QPoint newP1(newX, newY), oldP1(m_parentView->getCanvasView()->contentsX(),
                                    m_parentView->getCanvasView()->contentsY());

    QPoint p(newX, newY);

    if (newP1.x() > oldP1.x()) {
        p.setX(newX + m_parentView->getCanvasView()->visibleWidth());
    }

    p = m_mParentView->inverseMapPoint(p);
    int newTime = getSnapGrid()->snapX(p.x());
    handleMouseMove(newTime, 0, 0);
}
*/
void MatrixResizer::setBasicContextHelp()
{
    EventSelection *selection = m_scene->getSelection();
    if (selection && selection->getAddedEvents() > 1) {
        setContextHelp(tr("Click and drag to resize selected notes"));
    } else {
        setContextHelp(tr("Click and drag to resize a note"));
    }
}
//***************************************************************
void CToolCreateEntity::updateBeforeRender()
{
	//H_AUTO(R2_CToolCreateEntity_updateBeforeRender)
	if (_CreateState != DrawArray)
	{
		CToolChoosePos::updateBeforeRender();
		_AutoGroup.update(_CreatePosition, _PaletteId, _Valid && !isCtrlDown());
		setContextHelp(CI18N::get(_AutoGroup.getGroupingCandidate() ? "uiR2EDToolCreateEntityAutoGroup" : "uiR2EDToolCreateEntity"));
		return;
	}
	setContextHelp(CI18N::get("uiR2EDDrawArrayContextHelp"));
	// update for array mode
	bool valid = true;
	sint32 mouseX,  mouseY;
	getMousePos(mouseX,  mouseY);
	if (!isInScreen(mouseX,  mouseY) || (isMouseOnUI() && !isMouseOnWorldMap()))
	{
		valid = false;
		_ArrayEnd = _ArrayOrigin;
	}
	//
	CTool::CWorldViewRay worldViewRay;
	computeWorldViewRay(mouseX,  mouseY,  worldViewRay);
	//
	CVector entityPos; // the pos where the ghost will be shown
	CVector inter;     // intersection of view ray with landscape
	_ValidArray = true;
	TRayIntersectionType rayIntersectionType = computeLandscapeRayIntersection(worldViewRay,  inter);
	switch(rayIntersectionType)
	{
		case NoIntersection:
			_ValidArray  = false;
			_ArrayEnd = _ArrayOrigin;
		break;
		case ValidPacsPos:
		case InvalidPacsPos:
			_ArrayEnd = inter;
		break;
	}
	for (uint k = 0; valid && k < _ArrayElements.size(); ++k)
	{
		if (_ArrayElements[k])
		{
			if (_ArrayElements[k]->getDisplayFlag(CDisplayerVisual::FlagBadPos))
			{
				_ValidArray  = false;
			}
		}
	}
	CGroupMap *worldMap = getWorldMap();
	if (worldMap) worldMap->setSelectionAxis(_ValidArray);
	setMouseCursor(_ValidArray ? _CursValid.c_str() : _CursInvalid.c_str());
}
void ContextHelp::slotSave()
{
	if ( !saveDescription( m_currentLanguage ) )
		return;
	
	setContextHelp( m_pNameLabel->text(), itemLibrary()->description( m_lastItemType, KGlobal::locale()->language() ) );
	m_pWidgetStack->raiseWidget( 0 );
}
Exemple #4
0
void SegmentPencil::setContextHelpFor(QPoint p)
{
    int trackPosition = m_canvas->grid().getYBin(p.y());

    if (trackPosition < (int)m_doc->getComposition().getNbTracks()) {
        Track *t = m_doc->getComposition().getTrackByPosition(trackPosition);
        if (t) {
            InstrumentId id = t->getInstrument();
            if (id >= AudioInstrumentBase && id < MidiInstrumentBase) {
                setContextHelp(tr("Record or drop audio here"));
                return;
            }
        }
    }

    setContextHelp(tr("Click and drag to draw an empty segment.  Control+Alt click and drag to draw in overlap mode."));
}
MatrixResizer::FollowMode
MatrixResizer::handleMouseMove(const MatrixMouseEvent *e)
{
    if (!e) return NoFollow;

    setBasicContextHelp();

    if (!m_currentElement || !m_currentViewSegment) return NoFollow;

    if (getSnapGrid()->getSnapSetting() != SnapGrid::NoSnap) {
        setContextHelp(tr("Hold Shift to avoid snapping to beat grid"));
    } else {
        clearContextHelp();
    }

    // snap in the closest direction
    timeT snapTime = e->snappedLeftTime;
    if (e->snappedRightTime - e->time < e->time - e->snappedLeftTime) {
        snapTime = e->snappedRightTime;
    }

    timeT newDuration = snapTime - m_currentElement->getViewAbsoluteTime();
    timeT durationDiff = newDuration - m_currentElement->getViewDuration();

    EventSelection* selection = m_scene->getSelection();
    if (!selection || selection->getAddedEvents() == 0) return NoFollow;

    EventSelection::eventcontainer::iterator it =
        selection->getSegmentEvents().begin();

    for (; it != selection->getSegmentEvents().end(); ++it) {

        MatrixElement *element = 0;
        ViewElementList::iterator vi = m_currentViewSegment->findEvent(*it);
        if (vi != m_currentViewSegment->getViewElementList()->end()) {
            element = static_cast<MatrixElement *>(*vi);
        }
        if (!element) continue;

        timeT t = element->getViewAbsoluteTime();
        timeT d = element->getViewDuration();
        
        d = d + durationDiff;
        if (d < 0) {
            t = t + d;
            d = -d;
        } else if (d == 0) {
            d = getSnapGrid()->getSnapTime(t);
        }

        element->reconfigure(t, d);
//            m_currentStaff->positionElement(element);
//        }
    }

//    m_mParentView->canvas()->update();
    return FollowHorizontal;
}
void SegmentSelector::setContextHelpFor(QPoint pos,
                                        Qt::KeyboardModifiers modifiers)
{
    // If we are moving something
    if (m_selectionMoveStarted)
    {
        const bool shift = ((modifiers & Qt::ShiftModifier) != 0);

        // If shift isn't being held down
        if (!shift) {
            setContextHelp(tr("Hold Shift to avoid snapping to beat grid"));
        } else {
            clearContextHelp();
        }

        return;
    }

    ChangingSegmentPtr segment = m_canvas->getModel()->getSegmentAt(pos);

    // If the mouse is hovering over the background
    if (!segment) {
        setContextHelp(tr("Click and drag to select segments; middle-click and drag to draw an empty segment"));
        return;
    }

    // The mouse is hovering over a segment.

    const bool ctrl = ((modifiers & Qt::ControlModifier) != 0);

    // If clicking would resize
    if (m_canvas->getModel()->getSelectedSegments().size() <= 1  &&
        isNearEdge(segment->rect(), pos)) {

        if (!ctrl) {
            setContextHelp(tr("Click and drag to resize a segment; hold Ctrl as well to rescale its contents"));
        } else {
            setContextHelp(tr("Click and drag to rescale segment"));
        }
    } else {  // clicking would move
        if (m_canvas->getModel()->haveMultipleSelection()) {
            if (!ctrl) {
                setContextHelp(tr("Click and drag to move segments; hold Ctrl as well to copy them; Ctrl + Alt for linked copies"));
            } else {
                setContextHelp(tr("Click and drag to copy segments"));
            }
        } else {
            if (!ctrl) {
                setContextHelp(tr("Click and drag to move segment; hold Ctrl as well to copy it; Ctrl + Alt for a linked copy; double-click to edit"));
            } else {
                setContextHelp(tr("Click and drag to copy segment"));
            }
        }
    }
}
void ContextHelp::slotClear()
{
	setContextHelp( i18n("No Item Selected"), 0 );
	m_pEditButton->setEnabled( false );
	
	// Can we go hide the edit widget?
	if ( !isEditChanged() )
		m_pWidgetStack->raiseWidget( 0 );
}
Exemple #8
0
void SegmentMover::setContextHelp2(Qt::KeyboardModifiers modifiers)
{
    // If we're moving something
    if (getChangingSegment()) {
        bool shift = ((modifiers & Qt::ShiftModifier) != 0);

        // If shift isn't being held down
        if (!shift) {
            setContextHelp(tr("Hold Shift to avoid snapping to beat grid"));
        } else {
            clearContextHelp();
        }

        return;
    }

    setContextHelp(tr("Click and drag to move a segment"));
}
Exemple #9
0
int SegmentPencil::mouseMoveEvent(QMouseEvent *e)
{
    // No need to propagate.
    e->accept();

    QPoint pos = m_canvas->viewportToContents(e->pos());

    if (!m_newRect) {
        setContextHelpFor(pos);
        return RosegardenScrollView::NoFollow;
    }

    // If shift isn't being held down
    if ((e->modifiers() & Qt::ShiftModifier) == 0) {
        setContextHelp(tr("Hold Shift to avoid snapping to bar lines"));
    } else {
        clearContextHelp();
    }

    QRect tmpRect = m_canvas->getNewSegmentRect();

    SnapGrid &snapGrid = m_canvas->grid();

    setSnapTime(e, SnapGrid::SnapToBar);

    int mouseX = pos.x();
    
    // if mouse X is to the right of the original Press point
    if (mouseX >= m_pressX) {
        m_startTime = snapGrid.snapX(m_pressX, SnapGrid::SnapLeft);
        m_endTime = snapGrid.snapX(mouseX, SnapGrid::SnapRight);

        // Make sure the segment is never smaller than the smallest note.
        if (m_endTime - m_startTime < Note(Note::Shortest).getDuration())
            m_endTime = m_startTime + Note(Note::Shortest).getDuration();
    } else {  // we are to the left of the original Press point
        m_startTime = snapGrid.snapX(mouseX, SnapGrid::SnapLeft);
        m_endTime = snapGrid.snapX(m_pressX, SnapGrid::SnapRight);

        // Make sure the segment is never smaller than the smallest note.
        if (m_endTime - m_startTime < Note(Note::Shortest).getDuration())
            m_startTime = m_endTime - Note(Note::Shortest).getDuration();
    }

    int leftX = snapGrid.getRulerScale()->getXForTime(m_startTime);
    int rightX = snapGrid.getRulerScale()->getXForTime(m_endTime);

    // Adjust the rectangle to go from leftX to rightX
    tmpRect.setLeft(leftX);
    tmpRect.setRight(rightX);

    m_canvas->drawNewSegment(tmpRect);
    return RosegardenScrollView::FollowHorizontal;
}
void
MatrixSelector::setContextHelpFor(const MatrixMouseEvent *e, bool ctrlPressed)
{
    QSettings settings;
    settings.beginGroup( GeneralOptionsConfigGroup );

    if (! qStrToBool( settings.value("toolcontexthelp", "true" ) ) ) {
        settings.endGroup();
        return;
    }
    settings.endGroup();

    MatrixElement *element = e->element;

    if (!element) {
        
        setContextHelp
            (tr("Click and drag to select; middle-click and drag to draw new note"));

    } else {
        
        // same logic as in handleLeftButtonPress
        
        float x = element->getLayoutX();
        float width = element->getWidth();
        float resizeStart = int(double(width) * 0.85) + x;

        // max size of 10
        if ((x + width) - resizeStart > 10) resizeStart = x + width - 10;

        EventSelection *s = m_scene->getSelection();

        if (e->sceneX > resizeStart) {
            if (s && s->getAddedEvents() > 1) {
                setContextHelp(tr("Click and drag to resize selected notes"));
            } else {
                setContextHelp(tr("Click and drag to resize note"));
            }
        } else {
            if (s && s->getAddedEvents() > 1) {
                if (!ctrlPressed) {
                    setContextHelp(tr("Click and drag to move selected notes; hold Ctrl as well to copy"));
                } else {
                    setContextHelp(tr("Click and drag to copy selected notes"));
                }
            } else {
                if (!ctrlPressed) {
                    setContextHelp(tr("Click and drag to move note; hold Ctrl as well to copy"));
                } else {
                    setContextHelp(tr("Click and drag to copy note"));
                }
            }                
        }
    }
}
void
MatrixSelector::ready()
{
    if (m_widget) m_widget->setCanvasCursor(Qt::ArrowCursor);


/*!!!
    connect(m_widget->getCanvasView(), SIGNAL(contentsMoving (int, int)),
            this, SLOT(slotMatrixScrolled(int, int)));
*/
    setContextHelp
        (tr("Click and drag to select; middle-click and drag to draw new note"));
}
KoContextHelpWidget::KoContextHelpWidget( QWidget* parent, const char* /*name*/ )
		: QWidget( parent )
{
	setWindowTitle( i18n( "Context Help" ) );
	QGridLayout* layout = new QGridLayout( this );
	layout->addWidget( m_helpIcon = new QLabel( this ), 0, 0 );
	layout->addWidget( m_helpTitle = new KoVerticalLabel( this ), 1, 0 );
	layout->addWidget( m_helpViewer = new KoHelpWidget( "", this ), 0, 1, 2, 1 );
	layout->setMargin( 2 );
	layout->setSpacing( 1 );
	layout->setRowStretch( 1, 1 );
	this->setMinimumSize( 180, 120 );
	this->show();
	setContextHelp( i18n( "Context Help" ), i18n( "Here will be shown help according to your actions" ), 0 );
	connect( m_helpViewer, SIGNAL( linkClicked( const QString& ) ), this, SIGNAL( linkClicked( const QString& ) ) );
} // KoContextHelpWidget::KoContextHelpWidget
Exemple #13
0
void ContextHelp::slotUpdate( Item * item )
{
	if ( isEditChanged() )
		return;
	
	m_lastItemType = item ? item->type() : QString::null;
	m_pEditButton->setEnabled( item );
	
	if ( !item )
	{
		slotClear();
		return;
	}
	
	m_pWidgetStack->raiseWidget( 0 );
	setContextHelp( item->name(), itemLibrary()->description( m_lastItemType, KGlobal::locale()->language() ) );
}
Exemple #14
0
void ContextHelp::setBrowserItem( const QString & type )
{
	if ( isEditChanged() )
		return;
	
	QString description = itemLibrary()->description( type, KGlobal::locale()->language() );
	if ( description.isEmpty() )
		return;
	
	QString name;
	LibraryItem * li = itemLibrary()->libraryItem( type );
	if ( li )
		name = li->name();
	else
		name = type;
	
	m_lastItemType = type;
	setContextHelp( name, description );
	m_pEditButton->setEnabled( true );
}
Exemple #15
0
//***************************************************************
void CToolCreateEntity::commit(const NLMISC::CVector &createPosition, float createAngle)
{
	//H_AUTO(R2_CToolCreateEntity_commit)
	if (_CreateState == ChooseArrayOrigin)
	{
		if (!getEditor().verifyRoomLeft(0, 1))
		{

			getUI().executeLuaScript("r2:checkStaticQuota(1)");
			return;
		}
		setContextHelp(CI18N::get("uiR2EDDrawArrayContextHelp"));
		_CreateState = DrawArray;
		_ArrayDefaultAngle = createAngle;
		_ArrayOrigin = createPosition;
		_ArrayEnd = createPosition;
		updateArray(getGhost());
		removeGhostSlot();
		return;
	}

	CEntityCL *ghost = getGhost();
	if (!ghost) return;

	cloneEntityIntoScenario(ghost,
							createPosition,
							createAngle,
							true, /* new action */
							false /* create ghost */);

	if (isMultiPos() && isShiftDown())
	{
		// prevent newly created ghost to be removed twice ...
		removeGhostSlot();
		// re set this tool to generate a new entity look
		getUI().runActionHandler("r2ed_create_entity", NULL, "PaletteId=" + _PaletteId);
	}
}
Exemple #16
0
void SegmentEraser::ready()
{
    m_canvas->viewport()->setCursor(Qt::PointingHandCursor);
    setContextHelp(tr("Click on a segment to delete it"));
}
Exemple #17
0
void MatrixEraser::setBasicContextHelp()
{
    setContextHelp(tr("Click on a note to delete it"));
}
Exemple #18
0
void ContextHelp::slotMultipleSelected()
{
	setContextHelp( i18n("Multiple Items"), 0 );
}
Exemple #19
0
void SegmentMover::setBasicContextHelp()
{
    setContextHelp(tr("Click and drag to move a segment"));
}
Exemple #20
0
int SegmentMover::mouseMoveEvent(QMouseEvent *e)
{
    // No need to propagate.
    e->accept();

    // If we aren't moving anything, bail.
    if (!getChangingSegment())
        return RosegardenScrollView::NoFollow;

    QPoint pos = m_canvas->viewportToContents(e->pos());

    setSnapTime(e, SnapGrid::SnapToBeat);

    // If shift isn't being held down
    if ((e->modifiers() & Qt::ShiftModifier) == 0) {
        setContextHelp(tr("Hold Shift to avoid snapping to beat grid"));
    } else {
        clearContextHelp();
    }

    const SnapGrid &grid = m_canvas->grid();

    // Compute how far we've moved vertically.
    const int startTrackPos = grid.getYBin(m_clickPoint.y());
    const int currentTrackPos = grid.getYBin(pos.y());
    const int deltaTrack = currentTrackPos - startTrackPos;

    const int dx = pos.x() - m_clickPoint.x();

    Composition &comp = m_doc->getComposition();

    CompositionModelImpl::ChangingSegmentSet &changingSegments =
            m_canvas->getModel()->getChangingSegments();

    // For each changing segment, move it
    for (CompositionModelImpl::ChangingSegmentSet::iterator it =
             changingSegments.begin();
         it != changingSegments.end();
         ++it) {

        ChangingSegmentPtr changingSegment = *it;

        const timeT newStartTime = grid.snapX(changingSegment->savedRect().x() + dx);
        const int newX = int(grid.getRulerScale()->getXForTime(newStartTime));

        int trackPos = grid.getYBin(changingSegment->savedRect().y()) + deltaTrack;
        if (trackPos < 0)
            trackPos = 0;
        if (trackPos >= (int)comp.getNbTracks())
            trackPos = comp.getNbTracks() - 1;
        const int newY = grid.getYBinCoordinate(trackPos);

        changingSegment->moveTo(newX, newY);
        m_changeMade = true;
    }

    if (m_changeMade) {
        // Make sure the segments are redrawn.
        m_canvas->slotUpdateAll();
    }

    // Draw the guides

    int guideX = getChangingSegment()->rect().x();
    int guideY = getChangingSegment()->rect().y();

    m_canvas->drawGuides(guideX, guideY);

    // Format and draw the text float

    timeT guideTime = grid.snapX(guideX);

    RealTime time = comp.getElapsedRealTime(guideTime);

    int bar, beat, fraction, remainder;
    comp.getMusicalTimeForAbsoluteTime(guideTime, bar, beat, fraction, remainder);

    QString timeString = QString("%1.%2s (%3, %4, %5)")
        .arg(time.sec).arg(time.msec(), 3, 10, QChar('0'))
        .arg(bar + 1).arg(beat).arg(fraction);

    m_canvas->drawTextFloat(guideX + 10, guideY - 30, timeString);

	m_canvas->update();

    return RosegardenScrollView::FollowHorizontal |
           RosegardenScrollView::FollowVertical;
}
Exemple #21
0
//***************************************************************
void CToolCreateEntity::onActivate()
{
	//H_AUTO(R2_CToolCreateEntity_onActivate)
	setContextHelp(CI18N::get("uiR2EDToolCreateEntity"));
}
Exemple #22
0
void SegmentEraser::setBasicContextHelp()
{
    setContextHelp(tr("Click on a segment to delete it"));
}