Exemplo n.º 1
0
void SliderThumbElement::dragFrom(const LayoutPoint& point)
{
    Ref<SliderThumbElement> protect(*this);
    setPositionFromPoint(point);
#if !PLATFORM(IOS)
    startDragging();
#endif
}
Exemplo n.º 2
0
void CursorManager::onCursorMove(const CL_Point& mousePos) {
    if (dragCandidate_ && !isDragging_) {
        int pixelDiffDrag = Client::getSingleton()->getConfig()["/fluo/input/mouse@drag-start-distance"].asInt();

        if (abs(mousePos.x - dragStartMouseX_) + abs(mousePos.y - dragStartMouseY_) >= pixelDiffDrag) {
            startDragging();
            dragCandidate_->onStartDrag(mousePos);
        }
    }
}
void GameplayLayer::_handleActionDiceDragStarted(EventCustom* event) {
  auto data = (ActionDiceDragData*) event->getUserData();
  auto sprite = data->getSprite();
  auto dice = sprite->getDice();
  
  sprite->startDragging();
  
  auto room = Game::getInstance()->getRoomForCharacterCoordinate();
  auto hasMonstersInRoom = room->getMonsters().size() > 0;
  
  auto handler = DiceDragHandlerFactory::getHandler(dice);
  handler->dragStarted(data, this, this->_getDockableContainer());
}
Exemplo n.º 4
0
void SliderThumbElement::handleTouchStart(TouchEvent* touchEvent)
{
    TouchList* targetTouches = touchEvent->targetTouches();
    if (targetTouches->length() != 1)
        return;

    // Ignore the touch if it is not really inside the thumb.
    Touch* touch = targetTouches->item(0);
    IntRect boundingBox = renderer()->absoluteBoundingBoxRect();
    if (!boundingBox.contains(touch->pageX(), touch->pageY()))
        return;

    setExclusiveTouchIdentifier(touch->identifier());

    startDragging();
    touchEvent->setDefaultHandled();
}
Exemplo n.º 5
0
void ComponentLayout::paste()
{
    XmlDocument clip (SystemClipboard::getTextFromClipboard());
    ScopedPointer<XmlElement> doc (clip.getDocumentElement());

    if (doc != nullptr && doc->hasTagName (clipboardXmlTag))
    {
        selected.deselectAll();

        forEachXmlChildElement (*doc, e)
            if (Component* newComp = addComponentFromXml (*e, true))
                selected.addToSelection (newComp);

        startDragging();
        dragSelectedComps (Random::getSystemRandom().nextInt (40),
                           Random::getSystemRandom().nextInt (40));
        endDragging();
    }
Exemplo n.º 6
0
void SelectTool::mousePress(const QPoint &pos)
{
  // Last point is used for undrawing at the last position and calculating the distance the mouse has moved
  m_lastPoint = view()->canvasWidget()->mapFromScreen(pos);
  m_origPoint = m_lastPoint;

  // Check if we nailed a custom drag point on a selected stencil
  if( startCustomDragging(pos, true) )
  {
    m_mode = stmCustomDragging;
    return;
  }

  // Check if we are resizing
  if( startResizing(pos) )
  {
    m_mode = stmResizing;
    return;
  }


  // Check if we nailed a custom drag point on any other stencil
  if( startCustomDragging(pos, false) )
  {
    m_mode = stmCustomDragging;
    return;
  }

  // Check if we can drag a stencil
  if( startDragging(pos, false) )
  {
    m_mode = stmDragging;
    return;
  }

  // This should always be the last 'start' call since it always returns true
  if( startRubberBanding(pos) )
  {
    m_mode = stmDrawRubber;
    return;
  }
}
Exemplo n.º 7
0
ClsFEGroupPlot::ClsFEGroupPlot(ClsFEDataManager *_clsFEDataManager, QMutex *_qmutexSysGUI, string _strDataClientID, ClsFEGroup* _clsFEGroup) : 
    ClsFEDataClient(_clsFEDataManager, _qmutexSysGUI, _strDataClientID) {
#ifdef DEBUG_CLSFEGROUPPLOT
    cout << "ClsFEGroupPlot::ClsFEGroupPlot(...) [new]" << endl;
#endif
    bSparseTopology = false;   
    setClientType(CLIENT_SPACEPLOT);
    setAcceptDrops(TRUE);
    this->setIcon(QPixmap(icon_groupplot));
/* set up the WSpacePlot */
    wSpacePlot = new WSpacePlot(QSize(0,0),FALSE,this, this);
    wSpacePlot->setColor(QColor(0,0,0));
    wSpacePlot->showGrid(true);
    wSpacePlot->setMinimumWidth(200);

    (wSpacePlot->yAxis())->setDirection(-1);


    QBoxLayout* boxlayoutPlot = new QHBoxLayout();
    boxlayoutPlot->addWidget(wSpacePlot,1);
    boxlayoutPlot->addWidget(wSpacePlot->getColorBar());

    boxlayoutBase->addLayout(boxlayoutPlot, 0, 0);

    connect( wSpacePlot, SIGNAL(mouseEvent(QEvent::Type, QPoint, int, int)), this,
	     SLOT(slotPlotMouseClick(QEvent::Type, QPoint, int, int)) );

    connect( wSpacePlot, SIGNAL(wouldDrag()), this, SLOT(startDragging()) );
/* ----------------------- */
    if(_clsFEGroup != NULL){

	string strOutputStateName = _clsFEGroup->getNeuronOutput()->getName(); //NEW
	list<string> lstSelectedStates; // NEW
	lstSelectedStates.push_back(strOutputStateName); // NEW
	
	addStateVariableDisplay(_clsFEGroup, lstSelectedStates, "");
    }

    QWidget::show();
};
Exemplo n.º 8
0
void SliderThumbElement::defaultEventHandler(Event* event) {
  if (!event->isMouseEvent()) {
    HTMLDivElement::defaultEventHandler(event);
    return;
  }

  // FIXME: Should handle this readonly/disabled check in more general way.
  // Missing this kind of check is likely to occur elsewhere if adding it in
  // each shadow element.
  HTMLInputElement* input = hostInput();
  if (!input || input->isDisabledOrReadOnly()) {
    stopDragging();
    HTMLDivElement::defaultEventHandler(event);
    return;
  }

  MouseEvent* mouseEvent = toMouseEvent(event);
  bool isLeftButton = mouseEvent->button() ==
                      static_cast<short>(WebPointerProperties::Button::Left);
  const AtomicString& eventType = event->type();

  // We intentionally do not call event->setDefaultHandled() here because
  // MediaControlTimelineElement::defaultEventHandler() wants to handle these
  // mouse events.
  if (eventType == EventTypeNames::mousedown && isLeftButton) {
    startDragging();
    return;
  }
  if (eventType == EventTypeNames::mouseup && isLeftButton) {
    stopDragging();
    return;
  }
  if (eventType == EventTypeNames::mousemove) {
    if (m_inDragMode)
      setPositionFromPoint(LayoutPoint(mouseEvent->absoluteLocation()));
    return;
  }

  HTMLDivElement::defaultEventHandler(event);
}
Exemplo n.º 9
0
bool MapEditorToolBase::mouseMoveEvent(QMouseEvent* event, MapCoordF map_coord, MapWidget* widget)
{
	auto old_constrained_pos     = constrained_pos;
	auto old_constrained_pos_map = constrained_pos_map;
	
	active_modifiers = Qt::KeyboardModifiers(event->modifiers() | (key_button_bar ? key_button_bar->activeModifiers() : 0));
	cur_pos = event->pos();
	cur_pos_map = map_coord;
	calcConstrainedPositions(widget);
	
	if (event->buttons().testFlag(Qt::LeftButton))
	{
		if (dragging)
		{
			updateDragging();
		}
		else if (dragging_canceled)
		{
			click_pos = cur_pos;
			click_pos_map = cur_pos_map;
			dragging_canceled = false;
		}
		else if ((cur_pos - click_pos).manhattanLength() >= start_drag_distance)
		{
			// Use the actual click and current position to detect dragging, but
			// use the constrained variant of the click position as start of the
			// dragging operation.
			click_pos     = old_constrained_pos;
			click_pos_map = old_constrained_pos_map;
			startDragging();
		}
		return true;
	}
	else
	{
		mouseMove();
		return false;
	}
}
Exemplo n.º 10
0
void SliderThumbElement::defaultEventHandler(Event* event)
{
    if (!is<MouseEvent>(*event)) {
        HTMLDivElement::defaultEventHandler(event);
        return;
    }

    // FIXME: Should handle this readonly/disabled check in more general way.
    // Missing this kind of check is likely to occur elsewhere if adding it in each shadow element.
    HTMLInputElement* input = hostInput();
    if (!input || input->isDisabledOrReadOnly()) {
        stopDragging();
        HTMLDivElement::defaultEventHandler(event);
        return;
    }

    MouseEvent& mouseEvent = downcast<MouseEvent>(*event);
    bool isLeftButton = mouseEvent.button() == LeftButton;
    const AtomicString& eventType = mouseEvent.type();

    // We intentionally do not call event->setDefaultHandled() here because
    // MediaControlTimelineElement::defaultEventHandler() wants to handle these
    // mouse events.
    if (eventType == eventNames().mousedownEvent && isLeftButton) {
        startDragging();
        return;
    } else if (eventType == eventNames().mouseupEvent && isLeftButton) {
        stopDragging();
        return;
    } else if (eventType == eventNames().mousemoveEvent) {
        if (m_inDragMode)
            setPositionFromPoint(mouseEvent.absoluteLocation());
        return;
    }

    HTMLDivElement::defaultEventHandler(&mouseEvent);
}
Exemplo n.º 11
0
void EditPointTool::clickPress()
{
	Q_ASSERT(!hover_state.testFlag(OverObjectNode) ||
	         !hover_state.testFlag(OverPathEdge) ||
	         hover_object);
	
	if (hover_state.testFlag(OverPathEdge) &&
	    active_modifiers & Qt::ControlModifier)
	{
		// Add new point to path
		PathObject* path = hover_object->asPath();
		
		float distance_sq;
		PathCoord path_coord;
		path->calcClosestPointOnPath(cur_pos_map, distance_sq, path_coord);
		
		float click_tolerance_map_sq = cur_map_widget->getMapView()->pixelToLength(clickTolerance());
		click_tolerance_map_sq = click_tolerance_map_sq * click_tolerance_map_sq;
		
		if (distance_sq <= click_tolerance_map_sq)
		{
			startEditing();
			QScopedValueRollback<bool> no_effect_rollback(no_more_effect_on_click);
			no_more_effect_on_click = true;
			startDragging();
			hover_state = OverObjectNode;
			hover_point = path->subdivide(path_coord);
			if (addDashPointDefault() ^ space_pressed)
			{
				MapCoord point = path->getCoordinate(hover_point);
				point.setDashPoint(true);
				path->setCoordinate(hover_point, point);
				map()->emitSelectionEdited();
			}
			startEditingSetup();
			updatePreviewObjects();
		}
	}
    else if (hover_state.testFlag(OverObjectNode) &&
	         hover_object->getType() == Object::Path)
	{
		PathObject* hover_object = this->hover_object->asPath();
		Q_ASSERT(hover_point < hover_object->getCoordinateCount());
		
		if (space_pressed &&
		    !hover_object->isCurveHandle(hover_point))
		{
			// Switch point between dash / normal point
			createReplaceUndoStep(hover_object);
			
			MapCoord& hover_coord = hover_object->getCoordinate(hover_point);
			hover_coord.setDashPoint(!hover_coord.isDashPoint());
			hover_object->update();
			updateDirtyRect();
			no_more_effect_on_click = true;
		}
		else if (active_modifiers & Qt::ControlModifier)
		{
			auto hover_point_part_index = hover_object->findPartIndexForIndex(hover_point);
			PathPart& hover_point_part = hover_object->parts()[hover_point_part_index];
			
			if (hover_object->isCurveHandle(hover_point))
			{
				// Convert the curve into a straight line
				createReplaceUndoStep(hover_object);
				hover_object->deleteCoordinate(hover_point, false);
				hover_object->update();
				map()->emitSelectionEdited();
				updateHoverState(cur_pos_map);
				updateDirtyRect();
				no_more_effect_on_click = true;
			}
			else
			{
				// Delete the point
				if (hover_point_part.countRegularNodes() <= 2 ||
				    ( !(hover_object->getSymbol()->getContainedTypes() & Symbol::Line) &&
				      hover_point_part.size() <= 3 ) )
				{
					// Not enough remaining points -> delete the part and maybe object
					if (hover_object->parts().size() == 1)
					{
						map()->removeObjectFromSelection(hover_object, false);
						auto undo_step = new AddObjectsUndoStep(map());
						auto part = map()->getCurrentPart();
						int index = part->findObjectIndex(hover_object);
						Q_ASSERT(index >= 0);
						undo_step->addObject(index, hover_object);
						map()->deleteObject(hover_object, true);
						map()->push(undo_step);
						map()->setObjectsDirty();
						map()->emitSelectionEdited();
						updateHoverState(cur_pos_map);
					}
					else
					{
						createReplaceUndoStep(hover_object);
						hover_object->deletePart(hover_point_part_index);
						hover_object->update();
						map()->emitSelectionEdited();
						updateHoverState(cur_pos_map);
						updateDirtyRect();
					}
					no_more_effect_on_click = true;
				}
				else
				{
					// Delete the point only
					createReplaceUndoStep(hover_object);
					int delete_bezier_spline_point_setting;
					if (active_modifiers & Qt::ShiftModifier)
						delete_bezier_spline_point_setting = Settings::EditTool_DeleteBezierPointActionAlternative;
					else
						delete_bezier_spline_point_setting = Settings::EditTool_DeleteBezierPointAction;
					hover_object->deleteCoordinate(hover_point, true, Settings::getInstance().getSettingCached((Settings::SettingsEnum)delete_bezier_spline_point_setting).toInt());
					hover_object->update();
					map()->emitSelectionEdited();
					updateHoverState(cur_pos_map);
					updateDirtyRect();
					no_more_effect_on_click = true;
				}
			}
		}
	}
	else if (hoveringOverSingleText())
	{
		TextObject* hover_object = map()->getFirstSelectedObject()->asText();
		startEditing();
		
		// Don't show the original text while editing
		map()->removeRenderablesOfObject(hover_object, true);
		
		// Make sure that the TextObjectEditorHelper remembers the correct standard cursor
		cur_map_widget->setCursor(getCursor());
		
		old_text = hover_object->getText();
		old_horz_alignment = (int)hover_object->getHorizontalAlignment();
		old_vert_alignment = (int)hover_object->getVerticalAlignment();
		text_editor = new TextObjectEditorHelper(hover_object, editor);
		connect(text_editor, SIGNAL(selectionChanged(bool)), this, SLOT(textSelectionChanged(bool)));
		
		// Select clicked position
		int pos = hover_object->calcTextPositionAt(cur_pos_map, false);
		text_editor->setSelection(pos, pos);
		
		updatePreviewObjects();
	}
	
	click_timer.restart();
}
void SliderThumbElement::defaultEventHandler(Event* event)
{
    if (!event->isMouseEvent()
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
        && !event->isTouchEvent()
#endif
        ) {
        HTMLDivElement::defaultEventHandler(event);
        return;
    }

#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
    bool isLeftButton = false;

    if (event->isMouseEvent()) {
        MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
        isLeftButton = mouseEvent->button() == LeftButton;
    }
#else
    MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
    bool isLeftButton = mouseEvent->button() == LeftButton;
#endif
    const AtomicString& eventType = event->type();

    if (eventType == eventNames().mousedownEvent && isLeftButton
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
            || eventType == eventNames().touchstartEvent
#endif
            ) {
        startDragging();
        return;
    } else if (eventType == eventNames().mouseupEvent && isLeftButton
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
            || eventType == eventNames().touchendEvent
            || eventType == eventNames().touchcancelEvent
#endif
            ) {
        stopDragging();
        return;
    } else if (eventType == eventNames().mousemoveEvent
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
            || eventType == eventNames().touchmoveEvent
#endif
            ) {
        if (m_inDragMode)
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
        {
            if (event->isMouseEvent()) {
                MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
#endif
            setPositionFromPoint(mouseEvent->absoluteLocation());
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
            } else if (event->isTouchEvent()) {
                TouchEvent* touchEvent = static_cast<TouchEvent*>(event);
                if (touchEvent->touches() && touchEvent->touches()->item(0)) {
                    IntPoint curPoint;
                    curPoint.setX(touchEvent->touches()->item(0)->pageX());
                    curPoint.setY(touchEvent->touches()->item(0)->pageY());
                    setPositionFromPoint(curPoint);
                    // Tell the webview that webkit will handle the following move events
                    event->setDefaultPrevented(true);
                }
            }

        }
#endif
        return;
    }

    HTMLDivElement::defaultEventHandler(event);
}
void SliderThumbElement::dragFrom(const IntPoint& point)
{
    setPositionFromPoint(point);
    startDragging();
}
Exemplo n.º 14
0
void SliderThumbElement::dragFrom(const LayoutPoint& point)
{
    RefPtrWillBeRawPtr<SliderThumbElement> protector(this);
    startDragging();
    setPositionFromPoint(point);
}
Exemplo n.º 15
0
void PanTool::clickPress()
{
	startDragging();
}
Exemplo n.º 16
0
void LineItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {

  if (view()->viewMode() == View::Data) {
    event->ignore();
    return;
  }

  if (!dragStartPosition.isNull() && event->buttons() & Qt::LeftButton) {
    if (view()->mouseMode() == View::Move) {
      startDragging(event->widget(), dragStartPosition.toPoint());
      return;
    }
  }

  if (view()->mouseMode() == View::Default) {
    if (gripMode() == ViewItem::Move || activeGrip() == NoGrip) {
      view()->setMouseMode(View::Move);
      view()->undoStack()->beginMacro(tr("Move"));
    } else if (gripMode() == ViewItem::Resize) {
      view()->setMouseMode(View::Resize);
      view()->undoStack()->beginMacro(tr("Resize"));
    }
  }

  if (activeGrip() == NoGrip)
    return QGraphicsRectItem::mouseMoveEvent(event);

  double width = 0;
  double height = 0;
  double theta = 0;
  QPointF centerP;
  QPointF P1, P2;

  if (gripMode() == ViewItem::Resize) {
    switch(activeGrip()) {
    case RightMidGrip:
      P1 = mapToParent(QPoint(rect().left(), rect().center().y()));
      P2 = mapToParent(event->pos());
      break;
    case LeftMidGrip:
      P1 = mapToParent(event->pos());
      P2 = mapToParent(QPoint(rect().right(), rect().center().y()));
      break;
    default:
      return;
    }
    centerP = (P1 + P2) * 0.5;
    theta = atan2(P2.y() - P1.y(), P2.x() - P1.x());
    height = rect().height();
    double dx = P1.x() - P2.x();
    double dy = P1.y() - P2.y();
    width = sqrt(dx*dx + dy*dy)+1.0;

    if (activeGrip() == RightMidGrip) {
      setPos(P1);
      setViewRect(0,-height*0.5,width,height);
    } else if (activeGrip() == LeftMidGrip) {
      setPos(P2);
      setViewRect(-width, -height*0.5, width, height);
    }
    //setPos(centerP.x(), centerP.y());
    //setViewRect(-width*0.5, -height*0.5, width, height);

    QTransform transform;
    transform.rotateRadians(theta);

    setTransform(transform);
    updateRelativeSize(true);
  }
}