Exemplo n.º 1
0
void fillItemFromText(QGraphicsItemGroup *item, const CLBoundingBox *pBB, const CLText *pText, const CLGroup *group, const CLRenderResolver* resolver)
{
  double x = pBB->getPosition().getX() + pText->getX().getAbsoluteValue() + pText->getX().getRelativeValue() / 100.0 * pBB->getDimensions().getWidth();
  double y = pBB->getPosition().getY() + pText->getY().getAbsoluteValue() + pText->getY().getRelativeValue() / 100.0 * pBB->getDimensions().getHeight();

  QGraphicsTextItem* result = new QGraphicsTextItem(pText->getText().c_str());
  result ->setPos(x, y);

  if (pText->isSetStroke())
    {
      result->setDefaultTextColor(getColor(pText->getStroke(), resolver));
    }
  else if (group->isSetStroke())
    {
      result->setDefaultTextColor(getColor(group->getStroke(), resolver));
    }

  QFont *font = getFont(pText, group, resolver, pBB);

  if (font != NULL)
    {
      result->setFont(*font);

      adjustPosition(result, pBB, pText, group);

      delete font;
    }

  transform(result, pText, group);
  item->addToGroup(result);
}
Exemplo n.º 2
0
	void Ball::Update()
	{
		calcSpeedXY();
		x += vx;
		y += vy;

		//bounce
		if (x - radius < range_left)
		{
			vx = std::abs(vx);
			calcAngle();
		}
		else if (x + radius >= range_right)
		{
			vx = -std::abs(vx);
			calcAngle();
		}
		if (y - radius < range_top)
		{
			vy = std::abs(vy);
			calcAngle();
		}
		else if (y + radius >= range_bottom)
		{
			vy = -std::abs(vy);
			calcAngle();
		}

		adjustPosition();
	}
Exemplo n.º 3
0
void AutoComplete::showSuggestions(const QList<Suggestion *> &suggestions) {
    if (suggestions.isEmpty()) {
        hideSuggestions();
        return;
    }
    popup->setUpdatesEnabled(false);
    popup->clear();
    for (int i = 0; i < suggestions.count(); ++i) {
        QListWidgetItem *item = new QListWidgetItem(popup);
        Suggestion *s = suggestions[i];
        item->setText(s->value);
        if (!s->type.isEmpty())
            item->setIcon(QIcon(":/images/" + s->type + ".png"));
    }
    popup->setCurrentItem(0);
    int h = popup->frameWidth() * 2;
    for (int i = 0; i < suggestions.count(); ++i)
        h += popup->sizeHintForRow(i);

    popup->resize(buddy->width(), h);
    adjustPosition();
    popup->setUpdatesEnabled(true);

    if (popup->isHidden()) {
        itemHovering = false;
        popup->show();
        QTimer::singleShot(100, this, SLOT(enableItemHovering()));
    }
}
Exemplo n.º 4
0
void WizStatusBar::showText(const QString& strText /* = QString() */)
{
    setText(strText);
    adjustSize();
    adjustPosition();
    show();
    raise();
}
Exemplo n.º 5
0
void EmberEntity::onPositioningModeChanged(PositioningMode newMode)
{
	if (newMode != mPositioningMode) {
		adjustPosition();
	}
	EventPositioningModeChanged.emit(newMode);
	mPositioningMode = newMode;
}
Exemplo n.º 6
0
	void Ball::adjustSize()
	{
		if (radius < 0)
		{
			radius = 0;
		}
		else if (radius * 2 > range_right - range_left)
		{
			radius = (range_right - range_left) / 2;
		}
		adjustPosition();
	}
Exemplo n.º 7
0
bool ColorWheel::mouseButtonEvent(const Vector2i &p, int button, bool down,
                                  int modifiers) {
    Widget::mouseButtonEvent(p, button, down, modifiers);
    if (!mEnabled || button != GLFW_MOUSE_BUTTON_1)
        return false;

    if (down) {
        mDragRegion = adjustPosition(p);
        return mDragRegion != None;
    } else {
        mDragRegion = None;
        return true;
    }
}
Exemplo n.º 8
0
MiniBoss01::MiniBoss01(int imageHandle, Vector& position, float life) :
    EnemyUnit(imageHandle, position, life, true),
    m_fp_update(&MiniBoss01::update01),
    m_move01(nullptr)
{
    hitCircle.resize(1);
    for(int i = 0; i < 1; ++i) {
        hitCircle[i].radius = 35.0f;
    }
    adjustHitCircle();
    adjustPosition();

    m_move01 = new Move01_t();
    m_move01->speed = 4.0f;
}
Exemplo n.º 9
0
void ToolTip::resizeEvent(QResizeEvent *e)
{
    QWidget::resizeEvent(e);
    d->background->resizeFrame(size());
    if (Plasma::Theme::defaultTheme()->windowTranslucencyEnabled()) {
        WindowEffects::enableBlurBehind(winId(), true, d->background->mask());
        clearMask();
    } else {
        setMask(d->background->mask());
    }
    d->preview->setInfo();

    if (isVisible()) {
        adjustPosition(e->oldSize(), e->size());
    }
}
Exemplo n.º 10
0
//-------------------------------------------------------------------------
void IoProgressDialog::reset()
{
    setProgress(0);
    ui.progressBar->setVisible( true );
    ui.progressBar->setTextVisible(false);
    ui.progressBar->reset();
    ui.pushButton->setText( "Cancel" );
    ui.label->clear();
    _hasCancled = false;
    ui.msgLabel->clear();
    ui.pushButton->show();
    setIoHealth( 0 );
    resize( 10,10 );
    setSizeAndPosition( _parent );
    adjustPosition( _parent );
}
Exemplo n.º 11
0
void CQRenderConverter::applyStyle(QGraphicsTextItem *item, const CLBoundingBox* bounds, const CLGroup *style, const CLRenderResolver* resolver)
{
  if (resolver == NULL || style == NULL || bounds == NULL || item == NULL)
    return;

  if (style->isSetStroke())
    item->setDefaultTextColor(getColor(style->getStroke(), resolver));

  QSharedPointer<QFont> font = getFont(NULL, style, resolver, bounds);

  if (!font.isNull())
    {
      item->setFont(*font);

      adjustPosition(item, bounds, NULL, style);
    }
}
Exemplo n.º 12
0
void TimeTooltip::setTip( const QPoint& target, const QString& time, const QString& text )
{
    mDisplayedText = time;
    if ( !text.isEmpty() )
        mDisplayedText.append( " - " ).append( text );

    if( mTarget != target || time.length() != mTime.length() || mText != text )
    {
        mTarget = target;
        mTime = time;
        mText = text;
        adjustPosition();
    }

    update();
    raise();
}
Exemplo n.º 13
0
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: next(); break;
        case 1: prev(); break;
        case 2: zoomIn(); break;
        case 3: zoomOut(); break;
        case 4: adjustPosition(); break;
        default: ;
        }
        _id -= 5;
    }
    return _id;
}
Exemplo n.º 14
0
void UBDesktopPalette::showEvent(QShowEvent *event)
{
    Q_UNUSED(event);
    QIcon penIcon;
    QIcon markerIcon;
    QIcon eraserIcon;
    penIcon.addPixmap(QPixmap(":images/stylusPalette/penArrow.png"), QIcon::Normal, QIcon::Off);
    penIcon.addPixmap(QPixmap(":images/stylusPalette/penOnArrow.png"), QIcon::Normal, QIcon::On);
    UBApplication::mainWindow->actionPen->setIcon(penIcon);
    markerIcon.addPixmap(QPixmap(":images/stylusPalette/markerArrow.png"), QIcon::Normal, QIcon::Off);
    markerIcon.addPixmap(QPixmap(":images/stylusPalette/markerOnArrow.png"), QIcon::Normal, QIcon::On);
    UBApplication::mainWindow->actionMarker->setIcon(markerIcon);
    eraserIcon.addPixmap(QPixmap(":images/stylusPalette/eraserArrow.png"), QIcon::Normal, QIcon::Off);
    eraserIcon.addPixmap(QPixmap(":images/stylusPalette/eraserOnArrow.png"), QIcon::Normal, QIcon::On);
    UBApplication::mainWindow->actionEraser->setIcon(eraserIcon);

    adjustPosition();
}
Exemplo n.º 15
0
void MiniBoss01::update() {
    (this->*m_fp_update)();
    adjustHitCircle();
    adjustPosition();

    if(life <= 0.0f) {
        EnemyBulletMng.explosion(true);
        ScoreMng.addScore(5000);
        needDelete = true;
        ObjectMng.set(ENEMY_EXPLOSION, new EnemyExplosion(ImageMng.get(EE_02), position));
        int handle = ImageMng.get(ENERGY_S);
        createEnergy(handle, getVector(position.x - 30.0f, position.y - 5.0f), 2);
        createEnergy(handle, getVector(position.x + 20.0f, position.y), 2);
        createEnergy(handle, getVector(position.x, position.y + 20.0f), 2);
        PlaySound(SoundMng.get(SE_EXPLOSION03));
    }

    EnemyMng.update(this);
}
Exemplo n.º 16
0
BattleIcon::BattleIcon(GameSprite* parentGS)
{
    frameHeight = 64;
    frameWidth = 128;
    
    x_frameno = 0;
    x_maxframeno = 4;
    x_offset = 0;
    y_offset = 0;
    
    delay_animFrame = 0.1f;
    delay_curr = 0.1f;
    
    parent = parentGS;
    battleIconTexture = CCTextureCache::sharedTextureCache()->addImage("swordAnimation.png");
    battleIconRect = CCRectMake(0, 0, frameWidth, frameHeight);
    battleSprite = CCSprite::createWithTexture(battleIconTexture, battleIconRect);
    adjustPosition();
    battleSprite->setVisible(false);
    parent->spriteRep->addChild(battleSprite);
}
Exemplo n.º 17
0
void Element::advance(int step) {

    if (!step)
        return;

    /* Update x and y state based on gravity laws */
    updateStateY();
    updateStateX();

    /* Detect and resolve collisions with other objects */
    QList<Manifold *> listOfCollidingObjects = detectCollidingObjects();

    while (!listOfCollidingObjects.isEmpty()) {
        Manifold * secondObjectManifold = listOfCollidingObjects.takeFirst();

        /* Calculate relative velocity between two colliding objects */
        qreal rv_x = secondObjectManifold->second_object->getVelocityX() - this->getVelocityX();
        qreal rv_y = secondObjectManifold->second_object->getVelocityY() - this->getVelocityY();

        /* Calculate velocity along normal direction */
        qreal vetAlongNormal = secondObjectManifold->normal_x * rv_x + secondObjectManifold->normal_y * rv_y;

        if (vetAlongNormal <= 0.0) {

            qreal minElasticity = std::min(this->getElasticity(), secondObjectManifold->second_object->getElasticity());
            qreal j = -(1 + minElasticity) * vetAlongNormal;
            j /= this->getInvWeight() + secondObjectManifold->second_object->getInvWeight();

            this->setVelocityX(this->getVelocityX() - this->getInvWeight() * j * secondObjectManifold->normal_x);
            this->setVelocityY(this->getVelocityY() - this->getInvWeight() * j * secondObjectManifold->normal_y);

            secondObjectManifold->second_object->setVelocityX(secondObjectManifold->second_object->getVelocityX() + secondObjectManifold->second_object->getInvWeight() * j * secondObjectManifold->normal_x);
            secondObjectManifold->second_object->setVelocityY(secondObjectManifold->second_object->getVelocityY() + secondObjectManifold->second_object->getInvWeight() * j * secondObjectManifold->normal_y);

            adjustPosition(secondObjectManifold);
        }
    }

}
Exemplo n.º 18
0
	void Ball::SetMovableRange(int left, int top, int right, int bottom)
	{
		if (left > right)
		{
			range_left = right * unit;
			range_right = left * unit;
		}
		else
		{
			range_left = left * unit;
			range_right = right * unit;
		}
		if (top > bottom)
		{
			range_top = bottom * unit;
			range_bottom = top * unit;
		}
		else
		{
			range_top = top * unit;
			range_bottom = bottom * unit;
		}
		adjustPosition();
	}
Exemplo n.º 19
0
bool AutoComplete::eventFilter(QObject *obj, QEvent *ev) {

    if (obj != popup) {
        switch (ev->type()) {
        case QEvent::Move:
        case QEvent::Resize:
            adjustPosition();
            break;
        default:
            break;
        }
        return false;
    }

    // qDebug() << ev;

    if (ev->type() == QEvent::Leave) {
        popup->setCurrentItem(0);
        popup->clearSelection();
        if (!originalText.isEmpty()) buddy->setText(originalText);
        return true;
    }

    if (ev->type() == QEvent::FocusOut || ev->type() == QEvent::MouseButtonPress) {
        hideSuggestions();
        return true;
    }

    if (ev->type() == QEvent::KeyPress) {
        bool consumed = false;
        QKeyEvent *keyEvent = static_cast<QKeyEvent*>(ev);
        // qWarning() << keyEvent->text();
        switch (keyEvent->key()) {
        case Qt::Key_Enter:
        case Qt::Key_Return:
            if (popup->currentItem()) {
                acceptSuggestion();
                consumed = true;
            } else {
                lineEdit->event(ev);
                hideSuggestions();
            }
            break;

        case Qt::Key_Escape:
            hideSuggestions();
            consumed = true;
            break;

        case Qt::Key_Up:
            if (popup->currentRow() == 0) {
                popup->setCurrentItem(0);
                popup->clearSelection();
                buddy->setText(originalText);
                buddy->setFocus();
                consumed = true;
            }
            break;

        case Qt::Key_Down:
        case Qt::Key_Home:
        case Qt::Key_End:
        case Qt::Key_PageUp:
        case Qt::Key_PageDown:
            // qDebug() << key;
            break;

        default:
            // qDebug() << keyEvent->text();
            lineEdit->event(ev);
            consumed = true;
            break;
        }

        return consumed;
    }

    return false;
}
Exemplo n.º 20
0
	void Ball::MoveTo(int x, int y)
	{
		this->x = x * unit;
		this->y = y * unit;
		adjustPosition();
	}
Exemplo n.º 21
0
bool ColorWheel::mouseDragEvent(const Vector2i &p, const Vector2i &,
                                int, int) {
    return adjustPosition(p, mDragRegion) != None;
}
Exemplo n.º 22
0
	void Ball::Move(int x, int y)
	{
		this->x += x * unit;
		this->y += y * unit;
		adjustPosition();
	}