Esempio n. 1
0
    void setScreenPos (Point<float> newScreenPos, Time time, const bool forceUpdate)
    {
        if (! isDragging())
            setComponentUnderMouse (findComponentAt (newScreenPos), newScreenPos, time);

        if (newScreenPos != lastScreenPos || forceUpdate)
        {
            cancelPendingUpdate();
            lastScreenPos = newScreenPos;

            if (Component* const current = getComponentUnderMouse())
            {
                if (isDragging())
                {
                    registerMouseDrag (newScreenPos);
                    sendMouseDrag (*current, newScreenPos + unboundedMouseOffset, time);

                    if (isUnboundedMouseModeOn)
                        handleUnboundedDrag (*current);
                }
                else
                {
                    sendMouseMove (*current, newScreenPos, time);
                }
            }

            revealCursor (false);
        }
    }
Esempio n. 2
0
bool DrawPointTool::keyPress(QKeyEvent* event)
{
	if (event->key() == Qt::Key_Tab)
		deactivate();
	else if (event->key() == Qt::Key_Control)
	{
		if (isDragging() && rotating)
		{
			angle_helper->setActive(true, preview_object->getCoordF());
			calcConstrainedPositions(cur_map_widget);
			dragMove();
		}
	}
	else if (event->key() == Qt::Key_Shift)
	{
		snap_helper->setFilter(SnappingToolHelper::AllTypes);
		calcConstrainedPositions(cur_map_widget);
		if (isDragging())
			dragMove();
		else
			mouseMove();
	}
	else
		return false;
	return true;
}
Esempio n. 3
0
void ComboBox::display(void) {
   static Kernel *kernel = Kernel::getInstance();
   
   if (_cTexture == NULL || _isVisible == false) return;

   Point currPosition = getAbsolutePosition();

   if (isDragging()) _comboBoxMenu->setPosition(currPosition + Point(0, getHeight()));

   _cTexture->enable();

   ColorScheme::getInstance()->applyColor(ColorScheme::TEXTFIELD);
   _cTexture->display(currPosition.x, currPosition.y, 1, getWidth(), getHeight());
   _cTexture->display(currPosition.x + 1, currPosition.y + 1, 0, getWidth() - 2, getHeight() - 2);

   ColorScheme::getInstance()->applyColor(ColorScheme::MAINCOMPONENTS);
   _cTexture->display(currPosition.x + getWidth() - 17, currPosition.y + getHeight() - 2, 2, 15, - 16);

   ColorScheme::getInstance()->applyColor(ColorScheme::TEXTFIELD);
   if (isHolded()) {
      _cTexture->display(currPosition.x + 1, currPosition.y + 1, 4, getWidth() - 2, getHeight() - 2);
   } else if (isOvered()) {
      _cTexture->display(currPosition.x + 1 , currPosition.y + 1, 3, getWidth() - 2, getHeight() - 2);
   }

   _cTexture->disable();

   Scissor::getInstance()->pushScissor(Scissor::Info(currPosition.x + 3, kernel->getHeight() - (getHeight() + currPosition.y), getWidth() - 22, getHeight()));

   StaticLabel::display(currPosition.x + 4, currPosition.y + getHeight() / 2 - 6, Label::getString());

   Scissor::getInstance()->popScissor();
}
Esempio n. 4
0
int EditPointTool::updateDirtyRectImpl(QRectF& rect)
{
	bool show_object_points = map()->selectedObjects().size() <= max_objects_for_handle_display;
	
	selection_extent = QRectF();
	map()->includeSelectionRect(selection_extent);
	
	rectInclude(rect, selection_extent);
	int pixel_border = show_object_points ? (scaleFactor() * 6) : 1;
	
	// Control points
	if (show_object_points)
	{
		for (Map::ObjectSelection::const_iterator it = map()->selectedObjectsBegin(), end = map()->selectedObjectsEnd(); it != end; ++it)
			(*it)->includeControlPointsRect(rect);
	}
	
	// Text selection
	if (text_editor)
		text_editor->includeDirtyRect(rect);
	
	// Box selection
	if (isDragging() && box_selection)
	{
		rectIncludeSafe(rect, click_pos_map);
		rectIncludeSafe(rect, cur_pos_map);
	}
	
	return pixel_border;
}
Esempio n. 5
0
    //==============================================================================
    void handleEvent (ComponentPeer* const newPeer, Point<int> positionWithinPeer, Time time, const ModifierKeys newMods)
    {
        jassert (newPeer != nullptr);
        lastTime = time;
        ++mouseEventCounter;
        const Point<int> screenPos (newPeer->localToGlobal (positionWithinPeer));

        if (isDragging() && newMods.isAnyMouseButtonDown())
        {
            setScreenPos (screenPos, time, false);
        }
        else
        {
            setPeer (newPeer, screenPos, time);

            if (ComponentPeer* peer = getPeer())
            {
                if (setButtons (screenPos, time, newMods))
                    return; // some modal events have been dispatched, so the current event is now out-of-date

                peer = getPeer();
                if (peer != nullptr)
                    setScreenPos (screenPos, time, false);
            }
        }
    }
Esempio n. 6
0
void DrawPointTool::drawImpl(QPainter* painter, MapWidget* widget)
{
	if (preview_object)
	{
		const MapView* map_view = widget->getMapView();
		painter->save();
		painter->translate(widget->width() / 2.0 + map_view->panOffset().x(),
						   widget->height() / 2.0 + map_view->panOffset().y());
		painter->setWorldTransform(map_view->worldTransform(), true);
		
		RenderConfig config = { *map(), map_view->calculateViewedRect(widget->viewportToView(widget->rect())), map_view->calculateFinalZoomFactor(), RenderConfig::Tool, 0.5 };
		renderables->draw(painter, config);
		
		painter->restore();
	}
	
	if (isDragging() && rotating)
	{
		painter->setRenderHint(QPainter::Antialiasing);
		
		QPen pen(qRgb(255, 255, 255));
		pen.setWidth(3);
		painter->setPen(pen);
		painter->drawLine(widget->mapToViewport(preview_object->getCoordF()), widget->mapToViewport(constrained_pos_map));
		painter->setPen(active_color);
		painter->drawLine(widget->mapToViewport(preview_object->getCoordF()), widget->mapToViewport(constrained_pos_map));
		
		angle_helper->draw(painter, widget);
	}
	
	if (active_modifiers & Qt::ShiftModifier)
		snap_helper->draw(painter, widget);
}
Esempio n. 7
0
    //==============================================================================
    void handleEvent (ComponentPeer& newPeer, Point<float> positionWithinPeer, Time time,
                      const ModifierKeys newMods, float newPressure)
    {
        lastTime = time;
        const bool pressureChanged = (pressure != newPressure);
        pressure = newPressure;
        ++mouseEventCounter;
        const Point<float> screenPos (newPeer.localToGlobal (positionWithinPeer));

        if (isDragging() && newMods.isAnyMouseButtonDown())
        {
            setScreenPos (screenPos, time, pressureChanged);
        }
        else
        {
            setPeer (newPeer, screenPos, time);

            if (ComponentPeer* peer = getPeer())
            {
                if (setButtons (screenPos, time, newMods))
                    return; // some modal events have been dispatched, so the current event is now out-of-date

                peer = getPeer();

                if (peer != nullptr)
                    setScreenPos (screenPos, time, pressureChanged);
            }
        }
    }
void DrawPointTool::updateStatusText()
{
	if (isDragging())
	{
		auto angle = qRadiansToDegrees(preview_object->getRotation());
		setStatusBarText( trUtf8("<b>Angle:</b> %1° ").arg(QLocale().toString(angle, 'f', 1)) + QLatin1String("| ") +
		                  tr("<b>%1</b>: Fixed angles. ").arg(ModifierKey::control()) );
	}
	else if (static_cast<const PointSymbol*>(preview_object->getSymbol())->isRotatable())
	{
		auto parts = QStringList {
		    tr("<b>Click</b>: Create a point object."),
		    tr("<b>Drag</b>: Create an object and set its orientation."),
		};
		auto angle = qRadiansToDegrees(preview_object->getRotation());
		if (!qIsNull(angle))
		{
			parts.push_front(trUtf8("<b>Angle:</b> %1° ").arg(QLocale().toString(angle, 'f', 1)) + QLatin1Char('|'));
			parts.push_back(tr("<b>%1, 0</b>: Reset rotation.").arg(ModifierKey::escape()));
		}
		setStatusBarText(parts.join(QLatin1Char(' ')));
	}
	else
	{
		// Same as click_text above.
		setStatusBarText(tr("<b>Click</b>: Create a point object."));
	}
}
Esempio n. 9
0
void DrawPointTool::mouseMove()
{
	PointSymbol* point = reinterpret_cast<PointSymbol*>(editor->activeSymbol());
	
	if (!isDragging())
	{
		// Show preview object at this position
		renderables->removeRenderablesOfObject(preview_object, false);
		if (preview_object->getSymbol() != point)
		{
			bool success = preview_object->setSymbol(point, true);
			Q_ASSERT(success);
			Q_UNUSED(success);
		}
		
		preview_object->setPosition(constrained_pos_map);
		if (point->isRotatable())
			preview_object->setRotation(0);
		preview_object->update();
		renderables->insertRenderablesOfObject(preview_object);
		updateDirtyRect();
		
		return;
	}
}
Esempio n. 10
0
void RotateTool::updateStatusText()
{
	QString text;
	if (isDragging())
	{
		auto display_rotation = qRadiansToDegrees(current_rotation);
		if (display_rotation <= -180)
			display_rotation += 360;
		else if (display_rotation > 180)
			display_rotation -= 360;
		else if (display_rotation > -0.05 && display_rotation < 0.0)
			display_rotation = +0.0;
		text = trUtf8("<b>Rotation:</b> %1° ").arg(QLocale().toString(display_rotation, 'f', 1));
		if (!angle_helper->isActive())
			text += QLatin1String("| ");
	}
	else
	{
		text = tr("<b>Click</b>: Set the center of rotation. ") +
		       tr("<b>Drag</b>: Rotate the selected objects. ");
	}
	
	if (!angle_helper->isActive())
	{
		text += tr("<b>%1</b>: Fixed angles. ").arg(ModifierKey::control());
	}
	
	setStatusBarText(text);
}
Esempio n. 11
0
void RotateTool::drawImpl(QPainter* painter, MapWidget* widget)
{
	const auto center = widget->mapToViewport(rotation_center);
	
	painter->save();
	if (isDragging())
	{
		painter->translate(center);
		painter->rotate(qRadiansToDegrees(current_rotation));
		painter->translate(-center);
	}
	map()->drawSelection(painter, true, widget);
	painter->restore();
	
	const auto saved_hints = painter->renderHints();
	painter->setRenderHint(QPainter::Antialiasing, true);
	
	painter->setPen(Qt::white);
	painter->setBrush(Qt::NoBrush);
	
	/// \todo Use dpi-scaled dimensions
	painter->drawEllipse(center, 3, 3);
	painter->setPen(Qt::black);
	painter->drawEllipse(center, 4, 4);
	
	painter->setRenderHints(saved_hints);
}
Esempio n. 12
0
float DrawPointTool::calculateRotation(QPointF mouse_pos, MapCoordF mouse_pos_map)
{
	QPoint preview_object_pos = cur_map_widget->mapToViewport(preview_object->getCoordF()).toPoint();
	if (isDragging() && (mouse_pos - preview_object_pos).manhattanLength() >= Settings::getInstance().getStartDragDistancePx())
		return -atan2(mouse_pos_map.x() - preview_object->getCoordF().x(), preview_object->getCoordF().y() - mouse_pos_map.y());
	else
		return 0;
}
Esempio n. 13
0
void TabbedPane::processMouse(const scv::MouseEvent &evt) {
   static Kernel *kernel = Kernel::getInstance();

   if (isDragging() || isResizing()) {
      Component::processMouse(evt);
      if (getCurrTabIndex() != -1 && isResizing()) {
         configPanel();
      }
   } else {

      if (getCurrTabIndex() == -1 || !_receivingCallbacks) {
         Component::processMouse(evt);
         return;
      } else if(getCurrTabIndex() != -1) {
         getChild(getCurrTabIndex())->setDraggable(false);
         getChild(getCurrTabIndex())->processMouse(evt);
      }

      Component::processMouse(evt);

      Point currPosition = getAbsolutePosition();
      Point relativeMouse = evt.getPosition();

      if (evt.getState() == MouseEvent::UP) configPanel();

      // open menu
      if (isInside(evt.getPosition())) {
         _currecOverTab = -1;
         if (kernel->requestMouseUse(this)) {
            // over menu
            for (int i = 0; i < _children.size(); i++) {
               if (relativeMouse.x > _index[i] + currPosition.x && relativeMouse.x < _index[i + 1] + currPosition.x - 1
                  && relativeMouse.y > currPosition.y && relativeMouse.y < currPosition.y + s_barHeight) {
                     if (getCurrTabIndex() != i) _currecOverTab = i;
                     break;
               }
            }
            if (isFocused()) {
               if (evt.getState() == MouseEvent::CLICK && evt.getButton() == MouseEvent::LEFT) {
                  for (int i = 0; i < _children.size(); i++) {
                     if (relativeMouse.x > _index[i] + currPosition.x && relativeMouse.x < _index[i + 1] + currPosition.x - 1
                        && relativeMouse.y > currPosition.y && relativeMouse.y < currPosition.y + s_barHeight) {
                           setCurrTabIndex(i);
                           _currecOverTab   = -1;
                           configPanel();
                           break;
                     }
                  }
               }
            }
         }
      } else {
         _currecOverTab = -1;
      }
   }
}
Esempio n. 14
0
bool RotateTool::keyPress(QKeyEvent* event)
{
	if (event->key() == Qt::Key_Control)
	{
		angle_helper->setActive(true, rotation_center);
		if (isDragging())
			dragMove();
	}
    return false;
}
Esempio n. 15
0
bool RotateTool::keyRelease(QKeyEvent* event)
{
	if (event->key() == Qt::Key_Control && angle_helper->isActive())
	{
		angle_helper->setActive(false);
		if (isDragging())
			dragMove();
		return true;
	}
	return false;
}
Esempio n. 16
0
void RotatePatternTool::drawImpl(QPainter* painter, MapWidget* widget)
{
	drawSelectionOrPreviewObjects(painter, widget);
	
	if (isDragging())
	{
		painter->setPen(MapEditorTool::active_color);
		painter->setBrush(Qt::NoBrush);
		painter->drawLine(widget->mapToViewport(click_pos_map), widget->mapToViewport(constrained_pos_map));
	}
}
Esempio n. 17
0
int RotatePatternTool::updateDirtyRectImpl(QRectF& rect)
{
	if (isDragging())
	{
		rectIncludeSafe(rect, click_pos_map);
		rectIncludeSafe(rect, constrained_pos_map);
		angle_helper->includeDirtyRect(rect);
	}
	
	return rect.isValid() ? angle_helper->getDisplayRadius() : -1;
}
Esempio n. 18
0
void CutoutTool::drawImpl(QPainter* painter, MapWidget* widget)
{
	// Draw selection renderables
	map()->drawSelection(painter, true, widget, NULL, false);
	
	// Draw cutout shape renderables
	drawSelectionOrPreviewObjects(painter, widget, true);

	// Box selection
	if (isDragging())
		drawSelectionBox(painter, widget, click_pos_map, cur_pos_map);
}
void ModuleWorldPage::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: この位置にメッセージ ハンドラ用のコードを追加するかまたはデフォルトの処理を呼び出してください
	if (isDragging() == false && getMouseButton() == MOUSE_BUTTON_LEFT && (point.x != mousex || point.y != mousey)) {
		ClientToScreen(&point);
		int n = isInsideImageList(point.x, point.y);
		if (0 <= n)
			DragBegin(n);
		ScreenToClient(&point);
	}
	
	CPropertyPage::OnMouseMove(nFlags, point);
}
Esempio n. 20
0
bool DrawPointTool::keyRelease(QKeyEvent* event)
{
	if (event->key() == Qt::Key_Control && angle_helper->isActive())
	{
		angle_helper->setActive(false);
		calcConstrainedPositions(cur_map_widget);
		if (isDragging())
			dragMove();
	}
	else if (event->key() == Qt::Key_Shift)
	{
		snap_helper->setFilter(SnappingToolHelper::NoSnapping);
		calcConstrainedPositions(cur_map_widget);
		if (isDragging())
			dragMove();
		else
			mouseMove();
	}
	else
		return false;
	return true;
}
Esempio n. 21
0
    Component* getTargetForGesture (ComponentPeer& peer, Point<float> positionWithinPeer,
                                    Time time, Point<float>& screenPos)
    {
        lastTime = time;
        ++mouseEventCounter;

        screenPos = peer.localToGlobal (positionWithinPeer);
        setPeer (peer, screenPos, time);
        setScreenPos (screenPos, time, false);
        triggerFakeMove();

        return isDragging() ? nullptr : getComponentUnderMouse();
    }
Esempio n. 22
0
	void
	DocWindowFrame::onMotionNotifyEvent(
		xcb_motion_notify_event_t*	event)
	{
		if(isDragging()){
			int32_t			x, y;
			getCurrentDragPos(x, y);
			drawDragOutline(x, y);

			continueDrag(event->root_x, event->root_y, x, y);

			drawDragOutline(x, y);
		}
	}
Esempio n. 23
0
    //==============================================================================
    // (returns true if the button change caused a modal event loop)
    bool setButtons (const Point<int>& screenPos, const Time& time, const ModifierKeys& newButtonState)
    {
        if (buttonState == newButtonState)
            return false;

        // (avoid sending a spurious mouse-drag when we receive a mouse-up)
        if (! (isDragging() && ! newButtonState.isAnyMouseButtonDown()))
            setScreenPos (screenPos, time, false);

        // (ignore secondary clicks when there's already a button down)
        if (buttonState.isAnyMouseButtonDown() == newButtonState.isAnyMouseButtonDown())
        {
            buttonState = newButtonState;
            return false;
        }

        const int lastCounter = mouseEventCounter;

        if (buttonState.isAnyMouseButtonDown())
        {
            Component* const current = getComponentUnderMouse();

            if (current != nullptr)
            {
                const ModifierKeys oldMods (getCurrentModifiers());
                buttonState = newButtonState; // must change this before calling sendMouseUp, in case it runs a modal loop

                sendMouseUp (current, screenPos + unboundedMouseOffset, time, oldMods);
            }

            enableUnboundedMouseMovement (false, false);
        }

        buttonState = newButtonState;

        if (buttonState.isAnyMouseButtonDown())
        {
            Desktop::getInstance().incrementMouseClickCounter();

            Component* const current = getComponentUnderMouse();

            if (current != nullptr)
            {
                registerMouseDown (screenPos, time, current, buttonState);
                sendMouseDown (current, screenPos, time);
            }
        }

        return lastCounter != mouseEventCounter;
    }
Esempio n. 24
0
    Component* getTargetForGesture (ComponentPeer* const peer, const Point<int>& positionWithinPeer,
                                    const Time& time, Point<int>& screenPos)
    {
        jassert (peer != nullptr);
        lastTime = time;
        ++mouseEventCounter;

        screenPos = peer->localToGlobal (positionWithinPeer);
        setPeer (peer, screenPos, time);
        setScreenPos (screenPos, time, false);
        triggerFakeMove();

        return isDragging() ? nullptr : getComponentUnderMouse();
    }
Esempio n. 25
0
// This function contains translations. Keep it close to the top of the file so
// that line numbers remain stable here when changing other parts of the file.
void RotatePatternTool::updateStatusText()
{
	QString text;
	if (isDragging())
	{
		constexpr auto pi_x_1_5 = M_PI * 1.5;
		constexpr auto pi_x_2 = M_PI * 2.0;
		constexpr auto to_deg = 180.0 / M_PI;
		const auto rotation = fmod(-(constrained_pos_map - click_pos_map).angle() + pi_x_1_5, pi_x_2) * to_deg;
		text = trUtf8("<b>Angle:</b> %1° ").arg(QLocale().toString(rotation, 'f', 1));
	}
	else
	{
		text = tr("<b>Drag</b>: Set the direction of area fill patterns or point objects. ");
	}
	if (!active_modifiers.testFlag(Qt::ControlModifier))
	{
		if (isDragging())
			text +=  QLatin1String("| ");
		text += tr("<b>%1</b>: Fixed angles. ").arg(ModifierKey::control());
	}
	setStatusBarText(text);
}
Esempio n. 26
0
int DrawPointTool::updateDirtyRectImpl(QRectF& rect)
{
	Q_ASSERT(preview_object);
	
	int result = 0;
	rectIncludeSafe(rect, preview_object->getExtent());
	if (isDragging() && preview_object->getSymbol()->asPoint()->isRotatable())
	{
		rectInclude(rect, constrained_click_pos_map);
		rectInclude(rect, constrained_pos_map);
		result = qMax(3, angle_helper->getDisplayRadius());
	}
	
	return result;
}
Esempio n. 27
0
void DrawPointTool::updateStatusText()
{
	if (isDragging() && rotating)
	{
		static const double pi_x_2 = M_PI * 2.0;
		static const double to_deg = 180.0 / M_PI;
		double angle = fmod(calculateRotation(constrained_pos, constrained_pos_map) + pi_x_2, pi_x_2) * to_deg;
		setStatusBarText( trUtf8("<b>Angle:</b> %1° ").arg(QLocale().toString(angle, 'f', 1)) + "| " +
		                  tr("<b>%1</b>: Fixed angles. ").arg(ModifierKey::control()) );
	}
	else
	{
		setStatusBarText( tr("<b>Click</b>: Create a point object. <b>Drag</b>: Create an object and set its orientation (if rotatable). "));
	}
}
Esempio n. 28
0
int CutoutTool::updateDirtyRectImpl(QRectF& rect)
{
	rectInclude(rect, cutout_object->getExtent());
	
	map()->includeSelectionRect(rect);
	
	// Box selection
	if (isDragging())
	{
		rectIncludeSafe(rect, click_pos_map);
		rectIncludeSafe(rect, cur_pos_map);
	}
	
	return 0;
}
Esempio n. 29
0
bool RotatePatternTool::keyReleaseEvent(QKeyEvent* event)
{
	if (event->key() == Qt::Key_Control)
	{
		active_modifiers &= ~Qt::ControlModifier;
		
		if (angle_helper->isActive())
		{
			if (!isDragging())
			{
				updateDirtyRect();
			}
			angle_helper->setActive(false);
			if (isDragging())
			{
				updateConstrainedPositions();
				dragMove();
			}
		}
		updateStatusText();
		return true;
	}
	return false;
}
Esempio n. 30
0
	void
	DocWindowFrame::onButtonReleaseEvent(
		xcb_button_release_event_t*	event)
	{
		if(isDragging()){
			int32_t			prevX, prevY;
			getCurrentDragPos(prevX, prevY);

			int32_t			x, y;
			if(endDrag(event->detail, event->root_x, event->root_y, x, y)){
				drawDragOutline(prevX, prevY);

				mFrameWindow.moveTo(x, y);
			}
		}
	}