Esempio n. 1
0
int InteractionTool::processMouseEvent( ViewportMouseEvent& event )
{
  int flags = 0;

  if ( event.panel->contextMenuVisible() )
  {
    return flags;
  }

  // make sure we let the vis. manager render at least one frame between selection updates
  bool need_selection_update = context_->getFrameCount() > last_selection_frame_count_;

  // we are only dragging if exactly one mouse button is down
  bool dragging = ( event.type == QEvent::MouseMove && event.buttons_down != Qt::NoButton );

  // unless we're dragging, check if there's a new object under the mouse
  if( need_selection_update &&
      !dragging &&
      event.type != QEvent::MouseButtonRelease )
  {
    updateFocus( event );
    flags = Render;
  }

  {
    InteractiveObjectPtr focused_object = focused_object_.lock();
    if( focused_object )
    {
      focused_object->handleMouseEvent( event );
      setCursor( focused_object->getCursor() );
      // this will disable everything but the current interactive object
      if ( hide_inactive_property_->getBool() )
      {
        context_->getSelectionManager()->enableInteraction(!dragging);
      }
    }
    else if( event.panel->getViewController() )
    {
      move_tool_.processMouseEvent( event );
      setCursor( move_tool_.getCursor() );
      if ( hide_inactive_property_->getBool() )
      {
        context_->getSelectionManager()->enableInteraction(true);
      }
    }
  }

  if( event.type == QEvent::MouseButtonRelease )
  {
    updateFocus( event );
  }

  return flags;
}
Esempio n. 2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    splw = new SerialPortListWidget(this);
    ui->communicationVBoxLayout->addWidget(splw);

    //Connect browse button
    QFileDialog* fileDialog = new QFileDialog();
    connect(fileDialog,SIGNAL(fileSelected(QString)),ui->calibrationFileLineEdit,SLOT(setText(QString)));
    connect(ui->calibrationFilePushButton,SIGNAL(clicked()),fileDialog,SLOT(open()));

    //Connect apply settings button
    connect(ui->applySettingsPushButton,SIGNAL(clicked()),this,SLOT(applySettings()));

    //Frame rate timer
    frameRateTimer = new QTimer(this);
    fillDefaultSettings();
    connect(frameRateTimer,SIGNAL(timeout()),this,SLOT(update()));

    //Initialize marker detector
    markerDetector.setMinMaxSize(0.0001,0.5);

    //Camera view
    updateAutoFocus(false);
    updateFocus(ui->cameraFocusSlider->value());
    updateBrightness(ui->cameraBrightnessSlider->value());
    updateSharpness(ui->cameraSharpnessSlider->value());
    connect(ui->cameraFocusSlider,SIGNAL(valueChanged(int)),this,SLOT(updateFocus(int)));
    connect(ui->cameraBrightnessSlider,SIGNAL(valueChanged(int)),this,SLOT(updateBrightness(int)));
    connect(ui->cameraSharpnessSlider,SIGNAL(valueChanged(int)),this,SLOT(updateSharpness(int)));
}
Esempio n. 3
0
void Editor::updateCaret()
{
  placeCaret();

  POINT pt = toPoint(caret);
  caretX = pt.x;
  SCROLLINFO si;
  memset(&si, 0, sizeof si);
  si.cbSize = sizeof si;
  si.fMask = SIF_RANGE | SIF_PAGE;

  int xto = scrollPos.x;
  GetScrollInfo(hWnd, SB_HORZ, &si);
  if (pt.x < scrollPos.x)
    xto = (pt.x > 2 ? pt.x - 2 : 0);
  else if (pt.x >= scrollPos.x + si.nPage)
    xto = (pt.x - si.nPage + 10 < si.nMax ? pt.x - si.nPage + 10 : si.nMax);

  int yto = scrollPos.y;
  GetScrollInfo(hWnd, SB_VERT, &si);
  if (pt.y < scrollPos.y)
    yto = (pt.y > 2 ? pt.y - 2 : 0);
  else if (pt.y >= scrollPos.y + si.nPage)
    yto = (pt.y - si.nPage + 10 < si.nMax ? pt.y - si.nPage + 10 : si.nMax);

  doScroll(xto, yto);
  updateFocus();
  invalidate();
}
void KexiComboBoxTableEdit::showFocus(const QRect& r, bool readOnly)
{
// d->button->move( pos().x()+ width(), pos().y() );
    updateFocus(r);
    d->button->setEnabled(!readOnly);
    if (readOnly)
        d->button->hide();
    else
        d->button->show();
}
Esempio n. 5
0
void KexiBlobTableEdit::showFocus(const QRect& r, bool readOnly)
{
    d->readOnly = readOnly; //cache for slotUpdateActionsAvailabilityRequested()
// d->button->move( pos().x()+ width(), pos().y() );
    updateFocus(r);
// d->button->setEnabled(!readOnly);
    if (d->readOnly)
        d->button->hide();
    else
        d->button->show();
}
Esempio n. 6
0
bool Screen::mouseButtonCallbackEvent(int button, int action, int modifiers) {
    mModifiers = modifiers;
    mLastInteraction = glfwGetTime();
    try {
        if (mFocusPath.size() > 1) {
            const Window *window =
                dynamic_cast<Window *>(mFocusPath[mFocusPath.size() - 2]);
            if (window && window->modal()) {
                if (!window->contains(mMousePos))
                    return false;
            }
        }

        if (action == GLFW_PRESS)
            mMouseState |= 1 << button;
        else
            mMouseState &= ~(1 << button);

        auto dropWidget = findWidget(mMousePos);
        if (mDragActive && action == GLFW_RELEASE &&
            dropWidget != mDragWidget)
            mDragWidget->mouseButtonEvent(
                mMousePos - mDragWidget->parent()->absolutePosition(), button,
                false, mModifiers);

        if (dropWidget != nullptr && dropWidget->cursor() != mCursor) {
            mCursor = dropWidget->cursor();
            glfwSetCursor(mGLFWWindow, mCursors[(int) mCursor]);
        }

        if (action == GLFW_PRESS && button == GLFW_MOUSE_BUTTON_1) {
            mDragWidget = findWidget(mMousePos);
            if (mDragWidget == this)
                mDragWidget = nullptr;
            mDragActive = mDragWidget != nullptr;
            if (!mDragActive)
                updateFocus(nullptr);
        } else {
            mDragActive = false;
            mDragWidget = nullptr;
        }

        return mouseButtonEvent(mMousePos, button, action == GLFW_PRESS,
                                mModifiers);
    } catch (const std::exception &e) {
        std::cerr << "Caught exception in event handler: " << e.what() << std::endl;
        abort();
    }

    return false;
}
Esempio n. 7
0
void KexiBlobTableEdit::resize(int w, int h)
{
    d->totalSize = QSize(w, h);
    const int addWidth = d->readOnly ? 0 : d->button->width();
    QWidget::resize(w - addWidth, h);
    if (!d->readOnly)
        d->button->resize(h, h);
    m_rightMarginWhenFocused = m_rightMargin + addWidth;
    QRect r(pos().x(), pos().y(), w + 1, h + 1);
    r.translate(m_scrollView->contentsX(), m_scrollView->contentsY());
    updateFocus(r);
//todo if (d->menu) {
//todo  d->menu->updateSize();
//todo }
}
void KexiComboBoxTableEdit::resize(int w, int h)
{
    d->totalSize = QSize(w, h);
    if (!column()->isReadOnly()) {
        d->button->resize(h, h);
        QWidget::resize(w - d->button->width(), h);
    }
    m_rightMarginWhenFocused = m_rightMargin + (column()->isReadOnly() ? 0 : d->button->width());
    QRect r(pos().x(), pos().y(), w + 1, h + 1);
    if (m_scrollView)
        r.translate(m_scrollView->contentsX(), m_scrollView->contentsY());
    updateFocus(r);
    if (popup()) {
        popup()->updateSize();
    }
}
Esempio n. 9
0
bool KstTopLevelView::handlePress(const QPoint& pos, bool shift) {
  if (_activeHandler) {
    _activeHandler->handlePress(this, pos, shift);
    return true;
  }
  
  _mouseMoved = false;
  
  //kstdDebug() << "HANDLE PRESS" << endl;
  _pressDirection = -1;

  if (_mode != LayoutMode) {
    _pressTarget = 0L;
    return false;
  }  
  
  _pressTarget = findDeepestChild(pos, false);
  if (_pressTarget) {
    KstViewObjectPtr p = _pressTarget;
    while (p->_parent && (p->_parent->_container || kst_cast<KstPlotGroup>((KstViewObjectPtr)p->_parent)) && !kst_cast<KstTopLevelView>((KstViewObjectPtr)p->_parent)) {
      p = p->_parent;
    }
    if (p->_parent && !p->_parent->_container && !kst_cast<KstTopLevelView>((KstViewObjectPtr)p->_parent)) {
      _pressTarget = p->_parent;
    } else if (p && !p->_container) {
      _pressTarget = p;
    }
  }

  if (!_pressTarget) {
    _moveOffset = pos;
    return false;
  }

  _prevBand = QRect(-1, -1, 0, 0);
  _moveOffset = QPoint(-1, -1);
  _moveOffsetSticky = QPoint(0, 0);

  if (!_focusOn) {
    _pressTarget = 0L;
    _cursor.setShape(Qt::ArrowCursor);
    _w->setCursor(_cursor);
    _moveOffset = pos; // use _moveOffset to store our start point
    return true;
  }

  assert(_pressTarget);
  
  _pressDirection = _pressTarget->directionFor(pos);
  
  if (shift && _pressDirection < 1) {
    KstViewObjectList::Iterator it = _selectionList.find(_pressTarget);

    if (_pressTarget->isSelected()) {
      _pressTarget->setSelected(false);
      if (it != _selectionList.end()) {
        _selectionList.remove(it);
      }
    } else {
      _pressTarget->setSelected(true);
      if (it == _selectionList.end()) {
        _selectionList.append(_pressTarget);
      }
    }
    _pressTarget = 0L;
    _pressDirection = -1;
    _moveOffset = QPoint(-1, -1);
    _moveOffsetSticky = QPoint(0, 0);
    updateFocus(pos);
    paint(KstPainter::P_PAINT);
    return true;
  }

  if (_pressDirection == 0) {
    _moveOffset = pos - _pressTarget->position();
    _selectionList.clear();
    if (_pressTarget->isSelected()) {
      recursivelyQuery(&KstViewObject::isSelected, _selectionList, false);
    } else {
      recursively<bool>(&KstViewObject::setSelected, false);
    }
  } else {
    _selectionList.clear();
    recursively<bool>(&KstViewObject::setSelected, false);
  }
  
  // single click selects a single object if it is not part of the current list
  if (!_selectionList.contains(_pressTarget)) {
    _selectionList.clear();
    recursively<bool>(&KstViewObject::setSelected, false);
    _selectionList.append(_pressTarget);
  }
  _pressTarget->setSelected(true);

  _pressTarget->setFocus(false);
  paint(KstPainter::P_PAINT);
  return true;
}
Esempio n. 10
0
void TracksView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
      {
      updateFocus(current.row(), current.column());
      keepVisible(previous, current);
      }
Esempio n. 11
0
void KexiComboBoxTableEdit::showFocus(const QRect& r, bool readOnly)
{
    updateFocus(r);
    d->button->setEnabled(!readOnly);
    d->button->setVisible(!readOnly);
}