void TextureEditor::keyPressed(ofKeyEventArgs& args) { int key = args.key; float moveStep; if (bShiftKeyDown) moveStep = 10.0f; else moveStep = 0.5f; switch (key) { case OF_KEY_LEFT: moveSelection(ofVec2f(-moveStep, 0.0f)); break; case OF_KEY_RIGHT: moveSelection(ofVec2f(moveStep, 0.0f)); break; case OF_KEY_UP: moveSelection(ofVec2f(0.0f, -moveStep)); break; case OF_KEY_DOWN: moveSelection(ofVec2f(0.0f, moveStep)); break; case OF_KEY_SHIFT: bShiftKeyDown = true; break; } }
bool PsiFilteredContactListView::handleKeyPressEvent(QKeyEvent* e) { updateKeyboardModifiers(e); switch (e->key()) { case Qt::Key_Enter: case Qt::Key_Return: { if (state() == EditingState) return false; QModelIndex currentIndex = this->currentIndex(); if (currentIndex.isValid()) { // TODO: probably should select the item from the filteredListView_ // in the contactListView_ as well activate(currentIndex); } return true; } case Qt::Key_Home: { selectIndex(0); return true; } case Qt::Key_End: { selectIndex(model()->rowCount()-1); return true; } case Qt::Key_Up: case Qt::Key_Down: { moveSelection(1, e->key() == Qt::Key_Up ? Backward : Forward); return true; } case Qt::Key_PageUp: case Qt::Key_PageDown: { int delta = 0; QModelIndex index = model()->index(0, 0, QModelIndex()); if (index.isValid()) { int itemHeight = itemDelegate()->sizeHint(QStyleOptionViewItem(), index).height(); if (itemHeight) delta = viewport()->height() / itemHeight; } moveSelection(delta, e->key() == Qt::Key_PageUp ? Backward : Forward); return true; } default: ; } return false; }
void motion(int x, int y) { float selx, sely; if (middle_mouse && !left_mouse) { if (mousex != x || mousey != y) { trackball(lastquat, (2.0*mousex - W) / W, (H - 2.0*mousey) / H, (2.0*x - W) / W, (H - 2.0*y) / H); spinning = 1; } else { spinning = 0; } changeState(); } else { computeCoords(sel_piece, x, y, &selx, &sely); moveSelection(selx, sely); } mousex = x; mousey = y; glutPostRedisplay(); }
void eListbox::entryReset(bool selectionHome) { m_content_changed = true; m_prev_scrollbar_page = -1; int oldsel; if (selectionHome) { if (m_content) m_content->cursorHome(); m_top = 0; m_selected = 0; } if (m_content && (m_selected >= m_content->size())) { if (m_content->size()) m_selected = m_content->size() - 1; else m_selected = 0; m_content->cursorSet(m_selected); } oldsel = m_selected; moveSelection(justCheck); /* if oldsel != m_selected, selectionChanged was already emitted in moveSelection. we want it in any case, so otherwise, emit it now. */ if (oldsel == m_selected) /* emit */ selectionChanged(); invalidate(); }
void eListbox::moveSelectionTo(int index) { if (m_content) { m_content->cursorSet(index); moveSelection(justCheck); } }
void eListbox::entryRemoved(int index) { if (m_content && !(m_content->size() % m_items_per_page)) m_content_changed=true; if (index == m_selected && m_content) m_selected = m_content->cursorGet(); if (m_content && m_content->cursorGet() >= m_content->size()) moveSelection(moveUp); else moveSelection(justCheck); if ((m_top <= index) && (index < (m_top + m_items_per_page))) { /* todo, calc exact invalidation... */ invalidate(); } }
int eListBoxBase::eventHandler(const eWidgetEvent &event) { switch (event.type) { case eWidgetEvent::changedSize: eWidget::eventHandler(event); recalcMaxEntries(); recalcScrollBar(); init(); return 1; break; case eWidgetEvent::evtAction: if ((flags & flagHasShortcuts) && eventHandlerShortcuts(event)) return 1; else if ((event.action == &i_listActions->pageup) && !(flags & flagNoPageMovement)) moveSelection(dirPageUp); else if ((event.action == &i_listActions->pagedown) && !(flags & flagNoPageMovement)) moveSelection(dirPageDown); else if ( entries && current->eventHandler(event) ) return 1; else if ((event.action == &i_cursorActions->up) && !(flags & flagNoUpDownMovement) && !(flags&flagLostFocusOnFirst && current == childs.begin()) ) moveSelection(dirUp); else if ((event.action == &i_cursorActions->down) && !(flags & flagNoUpDownMovement) && !(flags&flagLostFocusOnLast && current == --childs.end()) ) moveSelection(dirDown); else if (event.action == &i_cursorActions->ok) { if ( current == childs.end() ) /*emit*/ SendSelected(0); else /*emit*/ SendSelected(*current); } else if (event.action == &i_cursorActions->cancel && MaxEntries > 1 ) /*emit*/ SendSelected(0); else break; return 1; default: break; } return eWidget::eventHandler(event); }
void eListbox::recalcSize() { m_content_changed=true; m_prev_scrollbar_page=-1; if (m_content) m_content->setSize(eSize(size().width(), m_itemheight)); m_items_per_page = size().height() / m_itemheight; if (m_items_per_page < 0) /* TODO: whyever - our size could be invalid, or itemheigh could be wrongly specified. */ m_items_per_page = 0; moveSelection(justCheck); }
void ShapeMoveStrategy::handleCustomEvent(KoPointerEvent *event) { QPointF diff = tool()->canvas()->viewConverter()->viewToDocument(event->pos()); if (event->modifiers() & Qt::ShiftModifier) { // Limit change to one direction only diff = snapToClosestAxis(diff); } m_diff += 0.1 * diff; moveSelection(); }
void LibraryControl::slotSelectTrack(double v) { if (!m_pLibraryWidget) { return; } int i = (int)v; auto activeView = m_pLibraryWidget->getActiveView(); if (!activeView) { return; } activeView->moveSelection(i); }
void Ruler::createPlugin(QObject *parent, QString idParent,plugin::PluginsManager *manager) { if(idParent == "Main") { mainWin = MAINWINDOW(parent); if(mainWin!=0) { painter = PAINTWIDGETINTERFACE(mainWin->getPaintWidget()); realPainter = RPWINTEFACE(painter->getRealPaintWidget()); selection = GSRINTEFACE(realPainter->getSelection()); connect(selection,SIGNAL(moved(qreal,qreal)),this,SLOT(moveSelection(qreal,qreal))); // добавление линеек painter->mySetViewportMargins(RULER_BREADTH,RULER_BREADTH,0,0); QGridLayout* gridLayout = new QGridLayout(); gridLayout->setSpacing(0); gridLayout->setMargin(0); mHorzRuler = new QDRuler(QDRuler::Horizontal,this); mVertRuler = new QDRuler(QDRuler::Vertical,this); QWidget* fake = new QWidget(); fake->setBackgroundRole(QPalette::Window); fake->setFixedSize(RULER_BREADTH,RULER_BREADTH); gridLayout->addWidget(fake,0,0); gridLayout->addWidget(mHorzRuler,0,1); gridLayout->addWidget(mVertRuler,1,0); gridLayout->addWidget(painter->viewport(),1,1); painter->setLayout(gridLayout); for(int i=0; i<W_COUNT; i++) { WayLine *w = new WayLine(painter->viewport()); w->setVisible(false); waylines.append(w); } // сигналы из внешнего мира connect(painter,SIGNAL(mouseMoveEvent(QPoint,QPoint,qreal)),this,SLOT(mouseMoveCoords(QPoint,QPoint,qreal))); connect(painter,SIGNAL(paintEvent(QPoint)),this,SLOT(mouseMoveOrigin(QPoint))); connect(painter,SIGNAL(zoomEvent(qreal)),this,SLOT(zoomEvent(qreal))); // коннекты для направляющих connect(mHorzRuler,SIGNAL(rulerClick(QPoint)),this,SLOT(rulerClickedH(QPoint))); connect(mVertRuler,SIGNAL(rulerClick(QPoint)),this,SLOT(rulerClickedV(QPoint))); manager->addPlugins(this, "Scale"); } } }
void ShapeMoveStrategy::handleCustomEvent(KoPointerEvent *event) { QPointF diff = tool()->canvas()->viewConverter()->viewToDocument(event->pos()); if (event->modifiers() & (Qt::AltModifier | Qt::ControlModifier)) { // keep x or y position unchanged if(qAbs(diff.x()) < qAbs(diff.y())) diff.setX(0); else diff.setY(0); } m_diff += 0.1 * diff ; moveSelection(); }
void ShapeMoveStrategy::handleMouseMove(const QPointF &point, Qt::KeyboardModifiers modifiers) { if (m_selectedShapes.isEmpty()) { return; } QPointF diff = point - m_start; if (modifiers & Qt::ShiftModifier) { // Limit change to one direction only diff = snapToClosestAxis(diff); } else { QPointF positionToSnap = point + m_initialOffset; tool()->canvas()->updateCanvas(tool()->canvas()->snapGuide()->boundingRect()); QPointF snappedPosition = tool()->canvas()->snapGuide()->snap(positionToSnap, modifiers); tool()->canvas()->updateCanvas(tool()->canvas()->snapGuide()->boundingRect()); diff = snappedPosition - m_initialOffset - m_start; } m_diff = diff; moveSelection(); }
void eListbox::entryAdded(int index) { if (m_content && (m_content->size() % m_items_per_page) == 1) m_content_changed=true; /* manage our local pointers. when the entry was added before the current position, we have to advance. */ /* we need to check <= - when the new entry has the (old) index of the cursor, the cursor was just moved down. */ if (index <= m_selected) ++m_selected; if (index <= m_top) ++m_top; /* we have to check wether our current cursor is gone out of the screen. */ /* moveSelection will check for this case */ moveSelection(justCheck); /* now, check if the new index is visible. */ if ((m_top <= index) && (index < (m_top + m_items_per_page))) { /* todo, calc exact invalidation... */ invalidate(); } }
void ShapeMoveStrategy::handleMouseMove(const QPointF &point, Qt::KeyboardModifiers modifiers) { if(m_selectedShapes.isEmpty()) return; QPointF diff = point - m_start; if (modifiers & (Qt::AltModifier | Qt::ControlModifier)) { // keep x or y position unchanged if(qAbs(diff.x()) < qAbs(diff.y())) diff.setX(0); else diff.setY(0); } else { QPointF positionToSnap = point + m_initialOffset; tool()->canvas()->updateCanvas( tool()->canvas()->snapGuide()->boundingRect() ); QPointF snappedPosition = tool()->canvas()->snapGuide()->snap( positionToSnap, modifiers ); tool()->canvas()->updateCanvas( tool()->canvas()->snapGuide()->boundingRect() ); diff = snappedPosition - m_initialOffset - m_start; } m_diff = diff; moveSelection(); }
void DSMoveKeysAndNodesCommand::redo() { moveSelection(_dt); }
void KBBGraphic::slotDown() { if( curRow < numRows-1 ) { moveSelection( 1, 0 ); } }
void KBBGraphic::slotUp() { if( curRow > 0 ) { moveSelection( -1, 0 ); } }
int eListbox::event(int event, void *data, void *data2) { switch (event) { case evtPaint: { ePtr<eWindowStyle> style; if (!m_content) return eWidget::event(event, data, data2); ASSERT(m_content); getStyle(style); if (!m_content) return 0; gPainter &painter = *(gPainter*)data2; m_content->cursorSave(); m_content->cursorMove(m_top - m_selected); gRegion entryrect = eRect(0, 0, size().width(), m_itemheight); const gRegion &paint_region = *(gRegion*)data; for (int y = 0, i = 0; i <= m_items_per_page; y += m_itemheight, ++i) { gRegion entry_clip_rect = paint_region & entryrect; if (!entry_clip_rect.empty()) m_content->paint(painter, *style, ePoint(0, y), m_selected == m_content->cursorGet() && m_content->size() && m_selection_enabled); /* (we could clip with entry_clip_rect, but this shouldn't change the behavior of any well behaving content, so it would just degrade performance without any gain.) */ m_content->cursorMove(+1); entryrect.moveBy(ePoint(0, m_itemheight)); } // clear/repaint empty/unused space between scrollbar and listboxentrys if (m_scrollbar && m_scrollbar->isVisible()) { style->setStyle(painter, eWindowStyle::styleListboxNormal); painter.clip(eRect(m_scrollbar->position() - ePoint(5,0), eSize(5,m_scrollbar->size().height()))); painter.clear(); painter.clippop(); } m_content->cursorRestore(); return 0; } case evtChangedSize: recalcSize(); return eWidget::event(event, data, data2); case evtAction: if (isVisible()) { moveSelection((long)data2); return 1; } return 0; default: return eWidget::event(event, data, data2); } }
void KBBGraphic::slotLeft() { if( curCol > 0 ) { moveSelection( 0, -1 ); } }
eListBoxEntry* eListBoxBase::goPrev() { moveSelection(dirUp); return current!=childs.end() ? *current : 0; }
eListBoxEntry *eListBoxBase::goNext() { moveSelection(dirDown); return current!=childs.end() ? *current : 0; }
void KBBGraphic::slotRight() { if( curCol < numCols-1 ) { moveSelection( 0, 1 ); } }
int Puzzle_Window::handle(int event) { int x = Fl::event_x(); int y = Fl::event_y(); switch (event) { case FL_KEY: switch (Fl::event_key()) { case FL_Escape: case 'Q': case 'q': exit(0); break; case 'S': case 's': solve_cb(this,0); break; case 'D': case 'd': piece = selectPiece(x, y); delete_cb(this,0); break; case 'R': case 'r': reset_cb(this,0); break; case 'O': case 'o': reset_view_cb(this,0); break; default: break; } return 1; case FL_PUSH: mousex = curX = x; mousey = curY = y; switch (Fl::event_button()) { case 1: set_solving(0); left_mouse = true; sel_piece = selectPiece(mousex, mousey); if (!sel_piece) { left_mouse = false; middle_mouse = true; // let it rotate object } else { float selx, sely; if (computeCoords(sel_piece, mousex, mousey, &selx, &sely)) { grabPiece(sel_piece, selx, sely); } } redraw(); break; case 2: middle_mouse = true; redraw(); break; default: piece = selectPiece(x, y); if (piece) menu->child(2)->activate(); else menu->child(2)->deactivate(); menu->popup(x, y); return 1; } // fall through to drag handler: case FL_DRAG: if (middle_mouse && !left_mouse) { if (mousex != x || mousey != y) { trackball(lastquat, (2.0*mousex - W) / W, (H - 2.0*mousey) / H, (2.0*x - W) / W, (H - 2.0*y) / H); spinning = 1; } else { spinning = 0; } changeState(); } else { float selx, sely; computeCoords(sel_piece, x, y, &selx, &sely); moveSelection(selx, sely); } mousex = x; mousey = y; redraw(); return 1; case FL_RELEASE: if (left_mouse) { left_mouse = false; dropSelection(); redraw(); } else if (middle_mouse) { middle_mouse = GL_FALSE; redraw(); } return 1; } return Fl_Gl_Window::handle(event); }
void moveGroupNode(DopeSheetEditor* model, const NodePtr& node, double dt) { NodeGroupPtr group = node->isEffectNodeGroup(); assert(group); NodesList nodes; group->getNodes_recursive(nodes, true); for (NodesList::iterator it = nodes.begin(); it != nodes.end(); ++it) { NodeGuiPtr nodeGui = boost::dynamic_pointer_cast<NodeGui>( (*it)->getNodeGui() ); assert(nodeGui); std::string pluginID = (*it)->getPluginID(); NodeGroupPtr isChildGroup = (*it)->isEffectNodeGroup(); // Move readers #ifndef NATRON_ENABLE_IO_META_NODES if ( ReadNode::isBundledReader( pluginID, node->getApp()->wasProjectCreatedWithLowerCaseIDs() ) ) { #else if (pluginID == PLUGINID_NATRON_READ) { #endif moveReader(*it, dt); } else if (pluginID == PLUGINID_OFX_TIMEOFFSET) { moveTimeOffset(*it, dt); } else if (pluginID == PLUGINID_OFX_FRAMERANGE) { moveFrameRange(*it, dt); } else if (isChildGroup) { moveGroupNode(model, *it, dt); } // Move keyframes const KnobsVec &knobs = (*it)->getKnobs(); for (KnobsVec::const_iterator knobIt = knobs.begin(); knobIt != knobs.end(); ++knobIt) { const KnobIPtr& knob = *knobIt; if ( !knob->hasAnimation() ) { continue; } for (int dim = 0; dim < knob->getDimension(); ++dim) { if ( !knob->isAnimated( dim, ViewIdx(0) ) ) { continue; } KeyFrameSet keyframes = knob->getCurve(ViewIdx(0), dim)->getKeyFrames_mt_safe(); for (KeyFrameSet::iterator kfIt = keyframes.begin(); kfIt != keyframes.end(); ++kfIt) { KeyFrame kf = (*kfIt); KeyFrame fake; knob->moveValueAtTime(eCurveChangeReasonDopeSheet, kf.getTime(), ViewSpec::all(), dim, dt, 0, &fake); } } } } } // moveGroupNode NATRON_NAMESPACE_ANONYMOUS_EXIT ////////////////////////// DSMoveKeysCommand ////////////////////////// DSMoveKeysAndNodesCommand::DSMoveKeysAndNodesCommand(const DSKeyPtrList &keys, const std::vector<DSNodePtr >& nodes, double dt, DopeSheetEditor *model, QUndoCommand *parent) : QUndoCommand(parent), _keys(keys), _nodes(), _dt(dt), _model(model) { setText( tr("Move selected keys") ); std::set<NodePtr > nodesSet; for (std::vector<DSNodePtr >::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { DopeSheetItemType type = (*it)->getItemType(); if ( (type != eDopeSheetItemTypeReader) && ( type != eDopeSheetItemTypeGroup) && ( type != eDopeSheetItemTypeTimeOffset) && ( type != eDopeSheetItemTypeFrameRange) ) { //Note that Retime nodes cannot be moved continue; } _nodes.push_back(*it); nodesSet.insert( (*it)->getInternalNode() ); NodeGroupPtr isGroup = (*it)->getInternalNode()->isEffectNodeGroup(); if (isGroup) { NodesList recurseNodes; isGroup->getNodes_recursive(recurseNodes, true); for (NodesList::iterator it = recurseNodes.begin(); it != recurseNodes.end(); ++it) { nodesSet.insert(*it); } } } for (DSKeyPtrList::iterator it = _keys.begin(); it != _keys.end(); ++it) { KnobHolderPtr holder = (*it)->getContext()->getInternalKnob()->getHolder(); assert(holder); EffectInstancePtr isEffect = toEffectInstance(holder); if (isEffect) { nodesSet.insert( isEffect->getNode() ); } } for (std::set<NodePtr >::iterator it = nodesSet.begin(); it != nodesSet.end(); ++it) { _allDifferentNodes.push_back(*it); } } void DSMoveKeysAndNodesCommand::undo() { moveSelection(-_dt); }