示例#1
0
QPixmap KItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem* option,
                                          QWidget* widget)
{
    QPixmap pixmap(size().toSize() * widget->devicePixelRatio());
    pixmap.setDevicePixelRatio(widget->devicePixelRatio());
    pixmap.fill(Qt::transparent);

    QPainter painter(&pixmap);

    const bool oldAlternateBackground = m_alternateBackground;
    const bool wasSelected = m_selected;
    const bool wasHovered = m_hovered;

    setAlternateBackground(false);
    setSelected(false);
    setHovered(false);

    paint(&painter, option, widget);

    setAlternateBackground(oldAlternateBackground);
    setSelected(wasSelected);
    setHovered(wasHovered);

    return pixmap;
}
    //_____________________________________________
    void ScrolledWindowData::registerChild( GtkWidget* widget )
    {
        // make sure widget is not already in map
        if( _childrenData.find( widget ) == _childrenData.end() )
        {

            #if OXYGEN_DEBUG
            std::cerr
                << "Oxygen::ScrolledWindowData::registerChild -"
                << " " << widget << " (" << G_OBJECT_TYPE_NAME( widget ) << ")"
                << std::endl;
            #endif

            // adjust event mask
            gtk_widget_add_events( widget, GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK|GDK_FOCUS_CHANGE_MASK );

            // allocate new Hover data
            ChildData data;
            data._destroyId.connect( G_OBJECT(widget), "destroy", G_CALLBACK( childDestroyNotifyEvent ), this );
            data._enterId.connect( G_OBJECT(widget), "enter-notify-event", G_CALLBACK( enterNotifyEvent ), this );
            data._leaveId.connect( G_OBJECT(widget), "leave-notify-event", G_CALLBACK( leaveNotifyEvent ), this );
            data._focusInId.connect( G_OBJECT(widget), "focus-in-event", G_CALLBACK( focusInNotifyEvent ), this );
            data._focusOutId.connect( G_OBJECT(widget), "focus-out-event", G_CALLBACK( focusOutNotifyEvent ), this );

            // and insert in map
            _childrenData.insert( std::make_pair( widget, data ) );

            // set initial focus
            setFocused( widget, gtk_widget_has_focus( widget ) );

            // set initial hover
            const bool enabled( gtk_widget_get_state( widget ) != GTK_STATE_INSENSITIVE );

            // on connection, needs to check whether mouse pointer is in widget or not
            // to have the proper initial value of the hover flag
            if( enabled && gtk_widget_get_window( widget ) )
            {

                gint xPointer,yPointer;
                gdk_window_get_pointer( gtk_widget_get_window( widget ), &xPointer, &yPointer, 0L );
                const GtkAllocation allocation( Gtk::gtk_widget_get_allocation( widget ) );
                const GdkRectangle rect( Gtk::gdk_rectangle( 0, 0, allocation.width, allocation.height ) );
                setHovered( widget, Gtk::gdk_rectangle_contains( &rect, xPointer, yPointer ) );

            } else setHovered( widget, false );

        }

    }
void QDeclarative1MouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    Q_D(QDeclarative1MouseArea);
    d->moved = false;
    d->stealMouse = d->preventStealing;
    if (!d->absorb)
        QDeclarativeItem::mousePressEvent(event);
    else {
        d->longPress = false;
        d->saveEvent(event);
        if (d->drag) {
            d->dragX = drag()->axis() & QDeclarative1Drag::XAxis;
            d->dragY = drag()->axis() & QDeclarative1Drag::YAxis;
        }
        if (d->drag)
            d->drag->setActive(false);
        setHovered(true);
        d->startScene = event->scenePos();
        // we should only start timer if pressAndHold is connected to.
        if (d->isPressAndHoldConnected())
            d->pressAndHoldTimer.start(PressAndHoldDelay, this);
        setKeepMouseGrab(d->stealMouse);
        event->setAccepted(setPressed(true));
    }
}
示例#4
0
void QQuickMouseArea::mouseReleaseEvent(QMouseEvent *event)
{
    Q_D(QQuickMouseArea);
    d->stealMouse = false;
    if (!d->enabled && !d->pressed) {
        QQuickItem::mouseReleaseEvent(event);
    } else {
        d->saveEvent(event);
        setPressed(event->button(), false);
        if (!d->pressed) {
            // no other buttons are pressed
#ifndef QT_NO_DRAGANDDROP
            if (d->drag)
                d->drag->setActive(false);
#endif
            // If we don't accept hover, we need to reset containsMouse.
            if (!acceptHoverEvents())
                setHovered(false);
            QQuickWindow *w = window();
            if (w && w->mouseGrabberItem() == this)
                ungrabMouse();
            setKeepMouseGrab(false);
        }
    }
    d->doubleClick = false;
}
示例#5
0
	bool MarkupText::onMouseMove(void)
	{
		m_pt = transformToWndCoord(m_system.getCursor().getPosition());
		m_pt -= m_area.getPosition();

		bool linkhit = false;
		if(m_selectedlnk)
		{	
			linkhit = isHitChunk<LinkArea>(m_selectedlnk.get(), m_pt);
			if(!linkhit)
			{
				setHovered(m_selectedlnk.get(), false);
				m_selectedlnk.reset();
				invalidate();
			}
		}

		if(!m_selectedlnk)
		{
			std::vector<PLinkArea>::iterator ilink = std::find_if(m_links.begin(), m_links.end(), hovertester<LinkArea>(m_pt, *this));
			if(ilink != m_links.end())
			{
				m_selectedlnk = (*ilink);
				setHovered(m_selectedlnk.get(), true);
				invalidate();
			}
		}

		if(m_selectedtt)
		{	
			bool hit = isHitChunk<TooltipArea>(m_selectedtt.get(), m_pt);
			if(hit)
				return true;
			else
			{
				hideTooltip();
			}
		}

		std::vector<PTooltipArea>::iterator itt = std::find_if(m_tooltips.begin(), m_tooltips.end(), hovertester<TooltipArea>(m_pt, *this));
		if(itt != m_tooltips.end())
		{
			showTooltip(*itt);
		}

		return MarkupBase::onMouseMove();
	}
示例#6
0
void KListItem::hoverEnterEvent( QGraphicsSceneHoverEvent *event )
{
	if(!itemSelected())
	{
		QVariant v = m_listWidget->itemHoveredBackgroundVariant();
		setHovered(v);
	}
}
示例#7
0
void QQuickMouseArea::hoverLeaveEvent(QHoverEvent *event)
{
    Q_D(QQuickMouseArea);
    if (!d->enabled && !d->pressed)
        QQuickItem::hoverLeaveEvent(event);
    else
        setHovered(false);
}
示例#8
0
void QDeclarativeMouseArea::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
    Q_D(QDeclarativeMouseArea);
    if (!d->absorb)
        QDeclarativeItem::hoverLeaveEvent(event);
    else
        setHovered(false);
}
示例#9
0
void QDeclarativeGeoMapMouseArea::exitEvent()
{
    if (!enabled_ || !hoverEnabled())
        return;

    setHovered(false);

    emit exited();
}
示例#10
0
void QDeclarativeGeoMapMouseArea::enterEvent()
{
    if (!enabled_ || !hoverEnabled())
        return;

    setHovered(true);

    emit entered();
}
示例#11
0
void QDeclarativeMouseArea::setHoverEnabled(bool h)
{
    Q_D(QDeclarativeMouseArea);
    if (h == acceptHoverEvents())
        return;

    setAcceptHoverEvents(h);
    emit hoverEnabledChanged();
    if (d->hovered != isUnderMouse())
        setHovered(!d->hovered);
}
示例#12
0
void QDeclarativeMouseArea::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
    Q_D(QDeclarativeMouseArea);
    if (!d->absorb)
        QDeclarativeItem::hoverEnterEvent(event);
    else {
        d->lastPos = event->pos();
        setHovered(true);
        QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, Qt::NoButton, event->modifiers(), false, false);
        emit mousePositionChanged(&me);
    }
}
示例#13
0
QVariant QDeclarativeMouseArea::itemChange(GraphicsItemChange change,
                                       const QVariant &value)
{
    Q_D(QDeclarativeMouseArea);
    switch (change) {
    case ItemVisibleHasChanged:
        if (acceptHoverEvents() && d->hovered != (isVisible() && isUnderMouse()))
            setHovered(!d->hovered);
        break;
    default:
        break;
    }

    return QDeclarativeItem::itemChange(change, value);
}
示例#14
0
bool CardItem::animationEvent()
{
    int delta = 18;
    if (!tapped)
        delta *= -1;
    
    tapAngle += delta;
    
    setTransform(QTransform().translate((float) CARD_WIDTH / 2, (float) CARD_HEIGHT / 2).rotate(tapAngle).translate((float) -CARD_WIDTH / 2, (float) -CARD_HEIGHT / 2));
    setHovered(false);
    update();

    if ((tapped && (tapAngle >= 90)) || (!tapped && (tapAngle <= 0)))
        return false;
    return true;
}
示例#15
0
void QQuickMouseArea::hoverEnterEvent(QHoverEvent *event)
{
    Q_D(QQuickMouseArea);
    if (!d->enabled && !d->pressed) {
        QQuickItem::hoverEnterEvent(event);
    } else {
        d->lastPos = event->posF();
        d->lastModifiers = event->modifiers();
        setHovered(true);
        QQuickMouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, Qt::NoButton, d->lastModifiers, false, false);
        emit mouseXChanged(&me);
        me.setPosition(d->lastPos);
        emit mouseYChanged(&me);
        me.setPosition(d->lastPos);
    }
}
示例#16
0
    void TransparentScrollButtonH::hoverOff()
    {
        setHovered(true);
        maxSizeAnimation_->stop();
        maxSizeAnimation_->setDuration(L::thinTime);
        maxSizeAnimation_->setStartValue(maximumHeight());
        maxSizeAnimation_->setEndValue(minScrollButtonHeight_);
        maxSizeAnimation_->start();

        minSizeAnimation_->stop();
        minSizeAnimation_->setDuration(L::thinTime);
        minSizeAnimation_->setStartValue(maximumHeight());
        minSizeAnimation_->setEndValue(minScrollButtonHeight_);
        minSizeAnimation_->start();
        update();
    }
示例#17
0
void QDeclarativeMouseArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    Q_D(QDeclarativeMouseArea);
    if (!d->absorb) {
        QDeclarativeItem::mouseReleaseEvent(event);
    } else {
        d->saveEvent(event);
        setPressed(false);
        if (d->drag)
            d->drag->setActive(false);
        // If we don't accept hover, we need to reset containsMouse.
        if (!acceptHoverEvents())
            setHovered(false);
        setKeepMouseGrab(false);
    }
}
示例#18
0
bool CardItem::animationEvent()
{
    int rotation = ROTATION_DEGREES_PER_FRAME;
    if (!tapped)
        rotation *= -1;

    tapAngle += rotation;

    setTransform(QTransform().translate(CARD_WIDTH_HALF, CARD_HEIGHT_HALF).rotate(tapAngle).translate(-CARD_WIDTH_HALF, -CARD_HEIGHT_HALF));
    setHovered(false);
    update();

    if ((tapped && (tapAngle >= 90)) || (!tapped && (tapAngle <= 0)))
        return false;
    return true;
}
示例#19
0
    void TransparentScrollButtonV::hoverOn()
    {
        setHovered(true);
        maxSizeAnimation_->stop();
        maxSizeAnimation_->setDuration(L::wideTime);
        maxSizeAnimation_->setStartValue(maximumWidth());
        maxSizeAnimation_->setEndValue(maxScrollButtonWidth_);
        maxSizeAnimation_->start();

        minSizeAnimation_->stop();
        minSizeAnimation_->setDuration(L::wideTime);
        minSizeAnimation_->setStartValue(maximumWidth());
        minSizeAnimation_->setEndValue(maxScrollButtonWidth_);
        minSizeAnimation_->start();
        update();
    }
示例#20
0
bool QDeclarativeMouseArea::sceneEvent(QEvent *event)
{
    bool rv = QDeclarativeItem::sceneEvent(event);
    if (event->type() == QEvent::UngrabMouse) {
        Q_D(QDeclarativeMouseArea);
        if (d->pressed) {
            // if our mouse grab has been removed (probably by Flickable), fix our
            // state
            d->pressed = false;
            setKeepMouseGrab(false);
            QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, false);
            emit released(&me);
            emit pressedChanged();
            setHovered(false);
        }
    }
    return rv;
}
示例#21
0
void QQuickMouseArea::itemChange(ItemChange change, const ItemChangeData &value)
{
    Q_D(QQuickMouseArea);
    switch (change) {
    case ItemVisibleHasChanged:
        if (acceptHoverEvents() && d->hovered != (isVisible() && isUnderMouse())) {
            if (!d->hovered) {
                QPointF cursorPos = QGuiApplicationPrivate::lastCursorPosition;
                d->lastScenePos = d->window->mapFromGlobal(cursorPos.toPoint());
                d->lastPos = mapFromScene(d->lastScenePos);
            }
            setHovered(!d->hovered);
        }
        break;
    default:
        break;
    }

    QQuickItem::itemChange(change, value);
}
示例#22
0
void QDeclarativeMouseArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    Q_D(QDeclarativeMouseArea);
    d->stealMouse = false;
    if (!d->absorb) {
        QDeclarativeItem::mouseReleaseEvent(event);
    } else {
        d->saveEvent(event);
        setPressed(false);
        if (d->drag)
            d->drag->setActive(false);
        // If we don't accept hover, we need to reset containsMouse.
        if (!acceptHoverEvents())
            setHovered(false);
        QGraphicsScene *s = scene();
        if (s && s->mouseGrabberItem() == this)
            ungrabMouse();
        setKeepMouseGrab(false);
    }
    d->doubleClick = false;
}
示例#23
0
void QQuickMouseArea::mousePressEvent(QMouseEvent *event)
{
    Q_D(QQuickMouseArea);
    d->moved = false;
    d->stealMouse = d->preventStealing;
    if (!d->enabled || !(event->button() & acceptedMouseButtons())) {
        QQuickItem::mousePressEvent(event);
    } else {
        d->longPress = false;
        d->saveEvent(event);
#ifndef QT_NO_DRAGANDDROP
        if (d->drag)
            d->drag->setActive(false);
#endif
        setHovered(true);
        d->startScene = event->windowPos();
        d->pressAndHoldTimer.start(QGuiApplication::styleHints()->mousePressAndHoldInterval(), this);
        setKeepMouseGrab(d->stealMouse);
        event->setAccepted(setPressed(event->button(), true));
    }
}
示例#24
0
void Button::motionHandler(int, int)
{
	setHovered(true);
}
示例#25
0
void MenuButton::enterEvent(QEvent *)
{
  setHovered();
}
示例#26
0
void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event)
{
    Q_D(QQuickMouseArea);
    if (!d->enabled && !d->pressed) {
        QQuickItem::mouseMoveEvent(event);
        return;
    }

    d->saveEvent(event);

    // ### we should skip this if these signals aren't used
    // ### can GV handle this for us?
    const bool isInside = contains(d->lastPos);
    if (d->hovered && !isInside)
        setHovered(false);
    else if (!d->hovered && isInside)
        setHovered(true);

#ifndef QT_NO_DRAGANDDROP
    if (d->drag && d->drag->target()) {
        if (!d->moved) {
            d->targetStartPos = d->drag->target()->parentItem()
                    ? d->drag->target()->parentItem()->mapToScene(d->drag->target()->position())
                    : d->drag->target()->position();
        }

        QPointF startLocalPos;
        QPointF curLocalPos;
        if (drag()->target()->parentItem()) {
            startLocalPos = drag()->target()->parentItem()->mapFromScene(d->startScene);
            curLocalPos = drag()->target()->parentItem()->mapFromScene(event->windowPos());
        } else {
            startLocalPos = d->startScene;
            curLocalPos = event->windowPos();
        }

        qreal dx = qAbs(curLocalPos.x() - startLocalPos.x());
        qreal dy = qAbs(curLocalPos.y() - startLocalPos.y());

        if (keepMouseGrab() && d->stealMouse && !d->drag->active())
            d->drag->setActive(true);

        QPointF startPos = d->drag->target()->parentItem()
                ? d->drag->target()->parentItem()->mapFromScene(d->targetStartPos)
                : d->targetStartPos;

        QPointF dragPos = d->drag->target()->position();

        bool dragX = drag()->axis() & QQuickDrag::XAxis;
        bool dragY = drag()->axis() & QQuickDrag::YAxis;

        if (dragX && d->drag->active()) {
            qreal x = (curLocalPos.x() - startLocalPos.x()) + startPos.x();
            if (x < drag()->xmin())
                x = drag()->xmin();
            else if (x > drag()->xmax())
                x = drag()->xmax();
            dragPos.setX(x);
        }
        if (dragY && d->drag->active()) {
            qreal y = (curLocalPos.y() - startLocalPos.y()) + startPos.y();
            if (y < drag()->ymin())
                y = drag()->ymin();
            else if (y > drag()->ymax())
                y = drag()->ymax();
            dragPos.setY(y);
        }
        d->drag->target()->setPosition(dragPos);

        if (!keepMouseGrab()) {
            bool xDragged = QQuickWindowPrivate::dragOverThreshold(dx, Qt::XAxis, event);
            bool yDragged = QQuickWindowPrivate::dragOverThreshold(dy, Qt::YAxis, event);
            if ((!dragY && !yDragged && dragX && xDragged)
                || (!dragX && !xDragged && dragY && yDragged)
                || (dragX && dragY && (xDragged || yDragged))) {
                setKeepMouseGrab(true);
                d->stealMouse = true;
            }
        }

        d->moved = true;
    }
#endif

    QQuickMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
    emit mouseXChanged(&me);
    me.setPosition(d->lastPos);
    emit mouseYChanged(&me);
    me.setPosition(d->lastPos);
    emit positionChanged(&me);
}
示例#27
0
void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event)
{
    Q_D(QQuickMouseArea);
    if (!d->enabled && !d->pressed) {
        QQuickItem::mouseMoveEvent(event);
        return;
    }

    d->saveEvent(event);

    // ### we should skip this if these signals aren't used
    // ### can GV handle this for us?
    setHovered(contains(d->lastPos));

#ifndef QT_NO_DRAGANDDROP
    if (d->drag && d->drag->target()) {
        if (!d->moved) {
            d->targetStartPos = d->drag->target()->parentItem()
                    ? d->drag->target()->parentItem()->mapToScene(d->drag->target()->position())
                    : d->drag->target()->position();
        }

        QPointF startLocalPos;
        QPointF curLocalPos;
        if (drag()->target()->parentItem()) {
            startLocalPos = drag()->target()->parentItem()->mapFromScene(d->startScene);
            curLocalPos = drag()->target()->parentItem()->mapFromScene(event->windowPos());
        } else {
            startLocalPos = d->startScene;
            curLocalPos = event->windowPos();
        }

        if (keepMouseGrab() && d->stealMouse && !d->drag->active())
            d->drag->setActive(true);

        QPointF startPos = d->drag->target()->parentItem()
                ? d->drag->target()->parentItem()->mapFromScene(d->targetStartPos)
                : d->targetStartPos;

        bool dragX = drag()->axis() & QQuickDrag::XAxis;
        bool dragY = drag()->axis() & QQuickDrag::YAxis;

        QPointF dragPos = d->drag->target()->position();
        if (dragX) {
            dragPos.setX(qBound(
                    d->drag->xmin(),
                    startPos.x() + curLocalPos.x() - startLocalPos.x(),
                    d->drag->xmax()));
        }
        if (dragY) {
            dragPos.setY(qBound(
                    d->drag->ymin(),
                    startPos.y() + curLocalPos.y() - startLocalPos.y(),
                    d->drag->ymax()));
        }
        if (d->drag->active())
            d->drag->target()->setPosition(dragPos);

        if (!keepMouseGrab()
                && (QQuickWindowPrivate::dragOverThreshold(dragPos.x() - startPos.x(), Qt::XAxis, event, d->drag->threshold())
                || QQuickWindowPrivate::dragOverThreshold(dragPos.y() - startPos.y(), Qt::YAxis, event, d->drag->threshold()))) {
            setKeepMouseGrab(true);
            d->stealMouse = true;

            if (d->drag->smoothed())
                d->startScene = event->windowPos();
        }

        d->moved = true;
    }
#endif

    QQuickMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
    emit mouseXChanged(&me);
    me.setPosition(d->lastPos);
    emit mouseYChanged(&me);
    me.setPosition(d->lastPos);
    emit positionChanged(&me);
}
示例#28
0
void QDeclarativeMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    Q_D(QDeclarativeMouseArea);
    if (!d->absorb) {
        QDeclarativeItem::mouseMoveEvent(event);
        return;
    }

    d->saveEvent(event);

    // ### we should skip this if these signals aren't used
    // ### can GV handle this for us?
    bool contains = boundingRect().contains(d->lastPos);
    if (d->hovered && !contains)
        setHovered(false);
    else if (!d->hovered && contains)
        setHovered(true);

    if (d->drag && d->drag->target()) {
        if (!d->moved) {
            d->startX = drag()->target()->x();
            d->startY = drag()->target()->y();
        }

        QPointF startLocalPos;
        QPointF curLocalPos;
        if (drag()->target()->parentItem()) {
            startLocalPos = drag()->target()->parentItem()->mapFromScene(d->startScene);
            curLocalPos = drag()->target()->parentItem()->mapFromScene(event->scenePos());
        } else {
            startLocalPos = d->startScene;
            curLocalPos = event->scenePos();
        }

        const int dragThreshold = QApplication::startDragDistance();
        qreal dx = qAbs(curLocalPos.x() - startLocalPos.x());
        qreal dy = qAbs(curLocalPos.y() - startLocalPos.y());

        if (keepMouseGrab() && d->stealMouse)
            d->drag->setActive(true);

        bool dragX = drag()->axis() & QDeclarativeDrag::XAxis;
        bool dragY = drag()->axis() & QDeclarativeDrag::YAxis;

        if (dragX && d->drag->active()) {
            qreal x = (curLocalPos.x() - startLocalPos.x()) + d->startX;
            if (x < drag()->xmin())
                x = drag()->xmin();
            else if (x > drag()->xmax())
                x = drag()->xmax();
            drag()->target()->setX(x);
        }
        if (dragY && d->drag->active()) {
            qreal y = (curLocalPos.y() - startLocalPos.y()) + d->startY;
            if (y < drag()->ymin())
                y = drag()->ymin();
            else if (y > drag()->ymax())
                y = drag()->ymax();
            drag()->target()->setY(y);
        }

        if (!keepMouseGrab()) {
            if ((!dragY && dy < dragThreshold && dragX && dx > dragThreshold)
                || (!dragX && dx < dragThreshold && dragY && dy > dragThreshold)
                || (dragX && dragY && (dx > dragThreshold || dy > dragThreshold))) {
                setKeepMouseGrab(true);
                d->stealMouse = true;
            }
        }

        d->moved = true;
    }
    QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
    emit mousePositionChanged(&me);
    me.setX(d->lastPos.x());
    me.setY(d->lastPos.y());
    emit positionChanged(&me);
}
示例#29
0
void Button::leaveHandler()
{
	setHovered(false);
}