BOOL LLToolCompGun::handleHover(S32 x, S32 y, MASK mask) { // *NOTE: This hack is here to make mouselook kick in again after // item selected from context menu. if ( mCur == mNull && !gPopupMenuView->getVisible() ) { LLSelectMgr::getInstance()->deselectAll(); setCurrentTool( (LLTool*) mGrab ); } // Note: if the tool changed, we can't delegate the current mouse event // after the change because tools can modify the mouse during selection and deselection. // Instead we let the current tool handle the event and then make the change. // The new tool will take effect on the next frame. mCur->handleHover( x, y, mask ); // If mouse button not down... if( !gViewerWindow->getLeftMouseDown()) { // let ALT switch from gun to grab if ( mCur == mGun && (mask & MASK_ALT) ) { setCurrentTool( (LLTool*) mGrab ); } else if ( mCur == mGrab && !(mask & MASK_ALT) ) { setCurrentTool( (LLTool*) mGun ); setMouseCapture(TRUE); } } return TRUE; }
MainWindow2::MainWindow2( QWidget *parent ) : QMainWindow( parent ), ui( new Ui::MainWindow2 ) { ui->setupUi( this ); m_object = new Object(); m_object->defaultInitialisation(); editor = new Editor( this ); m_pScribbleArea = editor->getScribbleArea(); m_pTimeLine = new TimeLine( this, editor ); makeTimeLineConnections(); arrangePalettes(); createMenus(); loadAllShortcuts(); // must run after 'arragePalettes' editor->setObject( m_object ); editor->resetUI(); readSettings(); makeColorPaletteConnections(); makeColorWheelConnections(); connect(editor, SIGNAL(needSave()), this, SLOT(saveDocument())); connect(m_pToolSet, SIGNAL(clearButtonClicked()), editor, SLOT(clearCurrentFrame())); connect(editor, SIGNAL(changeTool(ToolType)), m_pToolSet, SLOT(setCurrentTool(ToolType))); editor->setCurrentLayer( this->editor->m_pObject->getLayerCount() - 1 ); }
LLToolMgr::LLToolMgr() : mBaseTool(NULL), mSavedTool(NULL), mTransientTool( NULL ), mOverrideTool( NULL ), mSelectedTool( NULL ), mCurrentToolset( NULL ) { // Not a panel, register these callbacks globally. LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Build.Active", boost::bind(&LLToolMgr::inEdit, this)); // LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Build.Enabled", boost::bind(&LLToolMgr::canEdit, this)); // [RLVa:KB] - Checked: 2010-09-11 (RLVa-1.2.1d) | Added: RLVa-1.2.1d | Ansa: Changed because of FIRE-5552 LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Build.Enabled", boost::bind(&RlvUIEnabler::isBuildEnabled)); // [/RLVa:KB] LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Build.Toggle", boost::bind(&LLToolMgr::toggleBuildMode, this, _2)); gToolNull = new LLTool(LLStringUtil::null); // Does nothing setCurrentTool(gToolNull); gBasicToolset = new LLToolset(); gCameraToolset = new LLToolset(); // gLandToolset = new LLToolset(); gMouselookToolset = new LLToolset(); gFaceEditToolset = new LLToolset(); gMouselookToolset->setShowFloaterTools(false); gFaceEditToolset->setShowFloaterTools(false); }
QDeclarativeViewInspector::QDeclarativeViewInspector(QDeclarativeView *view, QObject *parent) : AbstractViewInspector(parent), data(new QDeclarativeViewInspectorPrivate(this)) { data->view = view; data->manipulatorLayer = new LiveLayerItem(view->scene()); data->selectionTool = new LiveSelectionTool(this); data->zoomTool = new ZoomTool(this); data->colorPickerTool = new ColorPickerTool(this); data->boundingRectHighlighter = new BoundingRectHighlighter(this); setCurrentTool(data->selectionTool); // to capture ChildRemoved event when viewport changes data->view->installEventFilter(this); data->setViewport(data->view->viewport()); connect(data->view, SIGNAL(statusChanged(QDeclarativeView::Status)), data.data(), SLOT(_q_onStatusChanged(QDeclarativeView::Status))); connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)), SIGNAL(selectedColorChanged(QColor))); connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)), this, SLOT(sendColorChanged(QColor))); changeTool(InspectorProtocol::SelectTool); }
BOOL LLToolCompRotate::handleHover(S32 x, S32 y, MASK mask) { if( !mCur->hasMouseCapture() ) { setCurrentTool( mManip ); } return mCur->handleHover( x, y, mask ); }
void LLToolCompInspect::keyUp(KEY key, MASK mask) { if (KEY_ALT == key && mCur == LLToolCamera::getInstance()) { setCurrentTool(mDefault); mIsToolCameraActive = FALSE; } }
// Returns to the default tool BOOL LLToolComposite::handleMouseUp(S32 x, S32 y, MASK mask) { BOOL handled = mCur->handleMouseUp( x, y, mask ); if( handled ) { setCurrentTool( mDefault ); } return handled; }
LLToolCompGun::LLToolCompGun() : LLToolComposite(std::string("Mouselook")) { mGun = new LLToolGun(this); mGrab = new LLToolGrab(this); mNull = sNullTool; setCurrentTool(mGun); mDefault = mGun; }
void LLToolCompGun::onMouseCaptureLost() { if (mComposite) { mComposite->onMouseCaptureLost(); return; } mCur->onMouseCaptureLost(); // JC - I don't know if this is necessary. Maybe we could lose capture // if someone ALT-Tab's out when in mouselook. setCurrentTool( (LLTool*) mGun ); }
LLToolCompGun::LLToolCompGun() : LLToolComposite(std::string("Mouselook")) , mMenuShown(false), mTimerFOV(), mOriginalFOV(), mStartFOV(), mTargetFOV() { mGun = new LLToolGun(this); mGrab = new LLToolGrab(this); mNull = sNullTool; setCurrentTool(mGun); mDefault = mGun; mTimerFOV.stop(); }
void QgsComposerView::keyReleaseEvent( QKeyEvent * e ) { if ( e->key() == Qt::Key_Space && !e->isAutoRepeat() && mPanning ) { //end of panning with space key mPanning = false; //reset cursor if ( mCurrentTool == Pan ) { viewport()->setCursor( Qt::OpenHandCursor ); } else { if ( composition() ) { //allow cursor changes again composition()->setPreventCursorChange( false ); } viewport()->setCursor( Qt::ArrowCursor ); } return; } else if ( e->key() == Qt::Key_Space && !e->isAutoRepeat() && mTemporaryZoomStatus != QgsComposerView::Inactive ) { //temporary keyboard-based zoom tool is active and space key has been released if ( mMarqueeZoom ) { //currently in the middle of a marquee operation, so don't switch tool back immediately //instead, wait until mouse button has been released before switching tool back mTemporaryZoomStatus = QgsComposerView::ActiveUntilMouseRelease; } else { //switch tool back mTemporaryZoomStatus = QgsComposerView::Inactive; setCurrentTool( mPreviousTool ); } } else if ( mCurrentTool == QgsComposerView::Zoom ) { //if zoom tool is active, respond to changes in the shift key status and update cursor accordingly if ( ! e->isAutoRepeat() ) { QPixmap myZoomQPixmap = QPixmap(( const char ** )( e->modifiers() & Qt::ShiftModifier ? zoom_out : zoom_in ) ); QCursor zoomCursor = QCursor( myZoomQPixmap, 7, 7 ); viewport()->setCursor( zoomCursor ); } return; } }
BOOL LLToolCompInspect::handleKey(KEY key, MASK mask) { BOOL handled = FALSE; if(KEY_ALT == key) { setCurrentTool(LLToolCamera::getInstance()); mIsToolCameraActive = TRUE; handled = TRUE; } else { handled = LLToolComposite::handleKey(key, mask); } return handled; }
LLToolMgr::LLToolMgr() : mBaseTool(NULL), mSavedTool(NULL), mTransientTool( NULL ), mOverrideTool( NULL ), mSelectedTool( NULL ), mCurrentToolset( NULL ) { gToolNull = new LLTool(LLStringUtil::null); // Does nothing setCurrentTool(gToolNull); gBasicToolset = new LLToolset(); gCameraToolset = new LLToolset(); // gLandToolset = new LLToolset(); gMouselookToolset = new LLToolset(); gFaceEditToolset = new LLToolset(); }
void LLToolMgr::setCurrentToolset(LLToolset* current) { if (!current) return; // switching toolsets? if (current != mCurrentToolset) { // deselect current tool if (mSelectedTool) { mSelectedTool->handleDeselect(); } mCurrentToolset = current; // select first tool of new toolset only if toolset changed mCurrentToolset->selectFirstTool(); } // update current tool based on new toolset setCurrentTool( mCurrentToolset->getSelectedTool() ); }
LLToolMgr::LLToolMgr() : mBaseTool(NULL), mSavedTool(NULL), mTransientTool( NULL ), mOverrideTool( NULL ), mSelectedTool( NULL ), mCurrentToolset( NULL ) { gToolNull = new LLTool(LLStringUtil::null); // Does nothing setCurrentTool(gToolNull); gBasicToolset = new LLToolset("Basic"); gCameraToolset = new LLToolset("Camera"); // gLandToolset = new LLToolset("Land"); gMouselookToolset = new LLToolset("MouseLook"); gFaceEditToolset = new LLToolset("FaceEdit"); gMouselookToolset->setShowFloaterTools(false); gFaceEditToolset->setShowFloaterTools(false); }
BOOL LLToolCompCreate::handleMouseUp(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; if ( mMouseDown && !mObjectPlacedOnMouseDown && !(mask == MASK_SHIFT) && !(mask == MASK_CONTROL) ) { setCurrentTool( mPlacer ); handled = mPlacer->placeObject( x, y, mask ); } mObjectPlacedOnMouseDown = FALSE; mMouseDown = FALSE; if (!handled) { handled = LLToolComposite::handleMouseUp(x, y, mask); } return handled; }
BOOL LLToolCompCreate::handleMouseDown(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; mMouseDown = TRUE; if ( (mask == MASK_SHIFT) || (mask == MASK_CONTROL) ) { gViewerWindow->pickAsync(x, y, mask, pickCallback); handled = TRUE; } else { setCurrentTool( mPlacer ); handled = mPlacer->placeObject( x, y, mask ); } mObjectPlacedOnMouseDown = TRUE; return TRUE; }
void SGViewInspector::changeTool(InspectorProtocol::Tool tool) { switch (tool) { case InspectorProtocol::ColorPickerTool: // TODO emit colorPickerActivated(); break; case InspectorProtocol::SelectMarqueeTool: // TODO emit marqueeSelectToolActivated(); break; case InspectorProtocol::SelectTool: setCurrentTool(m_selectionTool); emit selectToolActivated(); break; case InspectorProtocol::ZoomTool: // TODO emit zoomToolActivated(); break; } }
void QgsComposerView::endMarqueeZoom( QMouseEvent* e ) { mMarqueeZoom = false; QRectF boundsRect; if ( !mRubberBandItem || ( mRubberBandItem->rect().width() < 0.1 && mRubberBandItem->rect().height() < 0.1 ) ) { //just a click, so zoom to clicked point and recenter double scaleFactor = 0.5; //get current visible part of scene QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() ); QgsRectangle visibleRect = QgsRectangle( mapToScene( viewportRect ).boundingRect() ); //transform the mouse pos to scene coordinates QPointF scenePoint = mapToScene( e->pos() ); visibleRect.scale( scaleFactor, scenePoint.x(), scenePoint.y() ); boundsRect = visibleRect.toRectF(); } else { //marquee zoom //zoom bounds are size marquee object boundsRect = QRectF( mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(), mRubberBandItem->rect().height() ); } removeRubberBand(); //zoom view to fit desired bounds fitInView( boundsRect, Qt::KeepAspectRatio ); if ( mTemporaryZoomStatus == QgsComposerView::ActiveUntilMouseRelease ) { //user was using the temporary keyboard activated zoom tool //and the control or space key was released before mouse button, so end temporary zoom mTemporaryZoomStatus = QgsComposerView::Inactive; setCurrentTool( mPreviousTool ); } }
LLToolMgr::LLToolMgr() : mBaseTool(NULL), mSavedTool(NULL), mTransientTool( NULL ), mOverrideTool( NULL ), mSelectedTool( NULL ), mCurrentToolset( NULL ) { // Not a panel, register these callbacks globally. LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Build.Active", boost::bind(&LLToolMgr::inEdit, this)); LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Build.Enabled", boost::bind(&LLToolMgr::canEdit, this)); LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Build.Toggle", boost::bind(&LLToolMgr::toggleBuildMode, this)); gToolNull = new LLTool(LLStringUtil::null); // Does nothing setCurrentTool(gToolNull); gBasicToolset = new LLToolset(); gCameraToolset = new LLToolset(); // gLandToolset = new LLToolset(); gMouselookToolset = new LLToolset(); gFaceEditToolset = new LLToolset(); }
void QgsComposerView::pasteItems( PasteMode mode ) { if ( !composition() ) { return; } QDomDocument doc; QClipboard *clipboard = QApplication::clipboard(); if ( doc.setContent( clipboard->mimeData()->data( "text/xml" ) ) ) { QDomElement docElem = doc.documentElement(); if ( docElem.tagName() == "ComposerItemClipboard" ) { if ( composition() ) { QPointF pt; if ( mode == QgsComposerView::PasteModeCursor || mode == QgsComposerView::PasteModeInPlace ) { // place items at cursor position pt = mapToScene( mapFromGlobal( QCursor::pos() ) ); } else { // place items in center of viewport pt = mapToScene( viewport()->rect().center() ); } bool pasteInPlace = ( mode == PasteModeInPlace ); composition()->addItemsFromXML( docElem, doc, 0, true, &pt, pasteInPlace ); } } } //switch back to select tool so that pasted items can be moved/resized (#8958) setCurrentTool( QgsComposerView::Select ); }
BOOL LLToolCompGun::handleMouseUp(S32 x, S32 y, MASK mask) { gAgent.setControlFlags(AGENT_CONTROL_ML_LBUTTON_UP); setCurrentTool( (LLTool*) mGun ); return TRUE; }
void ToolManager::onActionTriggered(QAction *action) { setCurrentTool(_actionHash[action]); }
void LLToolComposite::onMouseCaptureLost() { mCur->onMouseCaptureLost(); setCurrentTool( mDefault ); }
void QgsComposerView::keyPressEvent( QKeyEvent * e ) { if ( !composition() ) { return; } if ( mPanning ) return; if ( mTemporaryZoomStatus != QgsComposerView::Inactive ) { //temporary keyboard based zoom is active if ( e->isAutoRepeat() ) { return; } //respond to changes in ctrl key status if ( !( e->modifiers() & Qt::ControlModifier ) && !mMarqueeZoom ) { //space pressed, but control key was released, end of temporary zoom tool mTemporaryZoomStatus = QgsComposerView::Inactive; setCurrentTool( mPreviousTool ); } else if ( !( e->modifiers() & Qt::ControlModifier ) && mMarqueeZoom ) { //control key released, but user is mid-way through a marquee zoom //so end temporary zoom when user releases the mouse button mTemporaryZoomStatus = QgsComposerView::ActiveUntilMouseRelease; } else { //both control and space pressed //set cursor to zoom in/out depending on shift key status QPixmap myZoomQPixmap = QPixmap(( const char ** )( e->modifiers() & Qt::ShiftModifier ? zoom_out : zoom_in ) ); QCursor zoomCursor = QCursor( myZoomQPixmap, 7, 7 ); viewport()->setCursor( zoomCursor ); } return; } if ( e->key() == Qt::Key_Space && ! e->isAutoRepeat() ) { if ( !( e->modifiers() & Qt::ControlModifier ) ) { // Pan composer with space bar mPanning = true; mMouseLastXY = mMouseCurrentXY; if ( composition() ) { //prevent cursor changes while panning composition()->setPreventCursorChange( true ); } viewport()->setCursor( Qt::ClosedHandCursor ); return; } else { //ctrl+space pressed, so switch to temporary keyboard based zoom tool mTemporaryZoomStatus = QgsComposerView::Active; mPreviousTool = mCurrentTool; setCurrentTool( Zoom ); //set cursor to zoom in/out depending on shift key status QPixmap myZoomQPixmap = QPixmap(( const char ** )( e->modifiers() & Qt::ShiftModifier ? zoom_out : zoom_in ) ); QCursor zoomCursor = QCursor( myZoomQPixmap, 7, 7 ); viewport()->setCursor( zoomCursor ); return; } } if ( mCurrentTool == QgsComposerView::Zoom ) { //using the zoom tool, respond to changes in shift key status and update mouse cursor accordingly if ( ! e->isAutoRepeat() ) { QPixmap myZoomQPixmap = QPixmap(( const char ** )( e->modifiers() & Qt::ShiftModifier ? zoom_out : zoom_in ) ); QCursor zoomCursor = QCursor( myZoomQPixmap, 7, 7 ); viewport()->setCursor( zoomCursor ); } return; } QList<QgsComposerItem*> composerItemList = composition()->selectedComposerItems(); QList<QgsComposerItem*>::iterator itemIt = composerItemList.begin(); // increment used for cursor key item movement double increment = 1.0; if ( e->modifiers() & Qt::ShiftModifier ) { //holding shift while pressing cursor keys results in a big step increment = 10.0; } if ( e->key() == Qt::Key_Left ) { for ( ; itemIt != composerItemList.end(); ++itemIt ) { ( *itemIt )->beginCommand( tr( "Item moved" ), QgsComposerMergeCommand::ItemMove ); ( *itemIt )->move( -1 * increment, 0.0 ); ( *itemIt )->endCommand(); } } else if ( e->key() == Qt::Key_Right ) { for ( ; itemIt != composerItemList.end(); ++itemIt ) { ( *itemIt )->beginCommand( tr( "Item moved" ), QgsComposerMergeCommand::ItemMove ); ( *itemIt )->move( increment, 0.0 ); ( *itemIt )->endCommand(); } } else if ( e->key() == Qt::Key_Down ) { for ( ; itemIt != composerItemList.end(); ++itemIt ) { ( *itemIt )->beginCommand( tr( "Item moved" ), QgsComposerMergeCommand::ItemMove ); ( *itemIt )->move( 0.0, increment ); ( *itemIt )->endCommand(); } } else if ( e->key() == Qt::Key_Up ) { for ( ; itemIt != composerItemList.end(); ++itemIt ) { ( *itemIt )->beginCommand( tr( "Item moved" ), QgsComposerMergeCommand::ItemMove ); ( *itemIt )->move( 0.0, -1 * increment ); ( *itemIt )->endCommand(); } } }