void CardHostWindow::resizeEventSync(int w, int h) { if (type() == WindowType::Type_Emergency) { if (m_adjustmentAngle == 90 || m_adjustmentAngle == -90){ setBoundingRect(h,w); } else { setBoundingRect(w,h); } } else { CardWindow::resizeEventSync(w, h); } }
DockModeClockWindow::DockModeClockWindow(const QPixmap& pixmap, DockModeWindowManager* dm, int zValue) : DockModeWindow (WindowType::Type_DockModeWindow, pixmap) { setFlag (QGraphicsItem::ItemHasNoContents); setBoundingRect (pixmap.width(), pixmap.height()); setName (LOCALIZED("Time")); setAppId ("com.palm.dockmodetime"); QDeclarativeEngine* qmlEngine = WindowServer::instance()->declarativeEngine(); if(qmlEngine) { QDeclarativeContext* context = qmlEngine->rootContext(); Settings* settings = Settings::LunaSettings(); std::string systemMenuQmlPath = settings->lunaQmlUiComponentsPath + "DockModeTime/Clocks.qml"; QUrl url = QUrl::fromLocalFile(systemMenuQmlPath.c_str()); m_qmlNotifMenu = new QDeclarativeComponent(qmlEngine, url, this); if(m_qmlNotifMenu) { m_clockObject = qobject_cast<QGraphicsObject *>(m_qmlNotifMenu->create()); if(m_clockObject) { m_clockObject->setPos (boundingRect().x(), boundingRect().y()); m_clockObject->setParentItem(this); } } } }
void ActionGraphicsItem::calculateLayout() { if(elementLayout() == 0) return; const ElementLayout & el = *elementLayout(); // calculate the size of the label QSizeF labelSize = calculateLabelSize(); QSize connectorSize = inputLayout()->connector().size(); // find the new width & height float height = labelSize.height() + 2*el.yMargin(); float width = labelSize.width() + 2*el.xMargin() + connectorSize.width(); if(width < el.minSize().width()) width = el.minSize().width(); if(height < el.minSize().height()) height = el.minSize().height(); // the height should be bigger or the same as the attached elements if(inputItem() && height < inputItem()->boundingRect().height()) height = inputItem()->boundingRect().height(); // update the bounding rect & position where text should start setInnerRect(QRectF(0, -height/2.0f, width, height)); setLabelStart(QPointF(connectorSize.width() + el.xMargin(), -labelSize.height()/2.0f)); setBoundingRect(innerRect().adjusted(-inputItem()->innerRect().width(), 0, 0, 0)); }
void QSGDefaultGlyphNode::update() { QRawFont font = m_glyphs.rawFont(); QMargins margins(0, 0, 0, 0); if (m_style == QQuickText::Normal) { m_material = new QSGTextMaskMaterial(font); } else if (m_style == QQuickText::Outline) { QSGOutlinedTextMaterial *material = new QSGOutlinedTextMaterial(font); material->setStyleColor(m_styleColor); m_material = material; margins = QMargins(1, 1, 1, 1); } else { QSGStyledTextMaterial *material = new QSGStyledTextMaterial(font); if (m_style == QQuickText::Sunken) { material->setStyleShift(QVector2D(0, -1)); margins.setTop(1); } else if (m_style == QQuickText::Raised) { material->setStyleShift(QVector2D(0, 1)); margins.setBottom(1); } material->setStyleColor(m_styleColor); m_material = material; } m_material->setColor(m_color); QRectF boundingRect; m_material->populate(m_position, m_glyphs.glyphIndexes(), m_glyphs.positions(), geometry(), &boundingRect, &m_baseLine, margins); setBoundingRect(boundingRect); setMaterial(m_material); markDirty(DirtyGeometry); }
void CardHostWindow::resizeWindowBufferEvent(int w, int h, QRect windowScreenBounds, bool forceSync) { //Don't rotate. Not now. Not ever. bool directRendering = m_maximized; if(Settings::LunaSettings()->displayUiRotates) { if(directRendering) setMaximized(false); // disable direct rendering for the resize event setBoundingRect(windowScreenBounds.width(), windowScreenBounds.height()); m_paintPath = QPainterPath(); m_paintPath.addRoundedRect(m_boundingRect, 25, 25); // reconstruct shadow CardDropShadowEffect* shadow = static_cast<CardDropShadowEffect*>(graphicsEffect()); if (shadow) { bool enable = shadow->isEnabled(); setGraphicsEffect(0); shadow = new CardDropShadowEffect(this); setGraphicsEffect(shadow); shadow->setEnabled(enable); } if(directRendering) setMaximized(true); // re-enable direct rendering } }
bool EllipseNode::fromJson(const json11::Json &json) { rectangle rect; if (!rect.parseString(json["bounds"].string_value())) return false; setBoundingRect(rect); return true; }
bool TriangleNode::fromJson(const json11::Json &json) { rectangle br; if (!br.parseString(json["bounds"].string_value())) return false; setBoundingRect(br); return true; }
void CardHostWindow::resizeEvent(int w, int h) { if (type() == WindowType::Type_Emergency) { if (m_adjustmentAngle == 90 || m_adjustmentAngle == -90){ setBoundingRect(h,w); } else { setBoundingRect(w,h); } } else { CardWindow::resizeEvent(w, h); /* int height = h; if(fullScreen()){ height = h - (isMaximized() ? 0 : Settings::LunaSettings()->positiveSpaceTopPadding); } m_boundingRect.setRect(-w/2, -height/2, w, height); CardWindow::resizeEvent(w, height); */ } }
void cCar::update(float deltaTime) { spritePos2D += spriteTranslation * deltaTime; setBoundingRect(&boundingRect); //Resetting the sprite to the right when it leaves the window if (spritePos2D.x < (0 - 128)) { spritePos2D.x = 1088; m_SoundMgr->getSnd("CarEnter")->playAudio(AL_TRUE); //Play sound on translation } }
void mousePressEvent(QMouseEvent * event) override { if (mIsAdding && event->button() == Qt::LeftButton) { QRectF rect = this->mapToScene(QRect(event->pos(), QSize(100, 100))).boundingRect(); auto editableRect = new SceneItemWithContextMenu<EditableRectangle>(); editableRect->setColor(currentColor()); editableRect->setBoundingRect(rect); editableRect->setColorSetup(this); this->scene()->addItem(editableRect); } else { TGraphicsView::mousePressEvent(event); } }
TimeSeriesFloodPlotData::TimeSeriesFloodPlotData(TimeSeries timeSeries, QwtDoubleInterval colorMapRange) : m_timeSeries(timeSeries), m_minValue(minimum(timeSeries.values())), m_maxValue(maximum(timeSeries.values())), m_minX(timeSeries.firstReportDateTime().date().dayOfYear()), m_maxX(ceil(timeSeries.daysFromFirstReport()[timeSeries.daysFromFirstReport().size()-1]+timeSeries.firstReportDateTime().date().dayOfYear()+timeSeries.firstReportDateTime().time().totalDays())), // end day m_minY(0), // start hour m_maxY(24), // end hour m_startFractionalDay(timeSeries.firstReportDateTime().date().dayOfYear()+timeSeries.firstReportDateTime().time().totalDays()), m_colorMapRange(colorMapRange) { // data range setBoundingRect(QwtDoubleRect(m_minX, m_minY, m_maxX-m_minX, m_maxY-m_minY)); }
void cAsteroid::update(float deltaTime) { //int score = 5; /*spriteRotation += 2.0f * deltaTime; if (spriteRotation > 360) { spriteRotation -= 360.0f; } spritePos2D += spriteTranslation * deltaTime; */ setBoundingRect(&boundingRect); if (speed == 0){ spritePos2D.y -= -1.0f ; } else if (speed == 1) { spritePos2D.y -= -1.5f; } else if (speed >= 2) { spritePos2D.y -= -2.0f; } // Respawn the enemies if they go past the bottom of the screen, increase speed of new wave, reduce score by one if (spritePos2D.y > 600) { spritePos2D.y = 32; speed +=1; score -= 1; enemyPassed = false; } if (spritePos2D.y> 590){ enemyPassed = true; } }
void cBullet::update(float deltaTime) { glm::vec2 spriteVelocityAdd = glm::vec2(0.0f, 0.0f); spriteVelocityAdd.x = (glm::sin(glm::radians(spriteRotation))); spriteVelocityAdd.y = -(glm::cos(glm::radians(spriteRotation))); spriteVelocityAdd *= spriteTranslation; bulletVelocity += spriteVelocityAdd; //glm::vec2 centrePos = getSpriteCentre(); //spritePos2D.x -= centrePos.x; //spritePos2D.y += centrePos.y; spritePos2D += bulletVelocity * deltaTime; bulletVelocity *= 0.97; setBoundingRect(&boundingRect); }
void QSGDefaultGlyphNode::setGlyphs(const QPointF &position, const QGlyphRun &glyphs) { if (m_material != 0) delete m_material; QRawFont font = glyphs.rawFont(); m_material = new QSGTextMaskMaterial(font); m_material->setColor(m_color); QRectF boundingRect; m_material->populate(position, glyphs.glyphIndexes(), glyphs.positions(), geometry(), &boundingRect, &m_baseLine); setMaterial(m_material); setBoundingRect(boundingRect); markDirty(DirtyGeometry); #ifdef QML_RUNTIME_TESTING description = QLatin1String("glyphs"); #endif }
// set ranges and bounding box void MatrixFloodPlotData::init(){ unsigned M = m_matrix.size1(); unsigned N = m_matrix.size2(); if ((M <= 1) || (N <= 1) || (M != m_xVector.size()) || (N != m_yVector.size())){ throw std::runtime_error("Incorrectly sized matrix or vector for MatrixFloodPlotData"); } m_minX = minimum(m_xVector); m_maxX = maximum(m_xVector); m_minY = minimum(m_yVector); m_maxY = maximum(m_yVector); m_minValue = minimum(m_matrix); m_maxValue = maximum(m_matrix); // default behavior is to have entire data range considered for colormapping // override by setting colorMapRange m_colorMapRange = QwtDoubleInterval(m_minValue, m_maxValue); // set the bounding box setBoundingRect(QwtDoubleRect(m_minX, m_minY, m_maxX-m_minX, m_maxY-m_minY)); }
void EmulatedCardWindow::resizeWindowBufferEvent(int w, int h, QRect windowScreenBounds, bool forceSync, bool ignoreFixedOrient) { bool directRendering = m_maximized; bool visible = isVisible() && this->sceneBoundingRect().intersects(WindowServer::instance()->sceneRect()); bool obscured = SystemUiController::instance()->maximizedCardWindow() ? (SystemUiController::instance()->maximizedCardWindow() != this) : false; bool synch = forceSync || m_maximized || (visible && !obscured); if((w == (int)m_bufWidth) && (h == (int)m_bufHeight)) { // already the right size, so do nothing return; } if(Settings::LunaSettings()->displayUiRotates) { if(directRendering) setMaximized(false); // disable direct rendering for the resize event //Emulated cards cannot resize to full screen, ever. int maxWidth = Settings::LunaSettings()->emulatedCardWidth; int maxHeight = Settings::LunaSettings()->emulatedCardHeight; m_screenMidLine = (SystemUiController::instance()->currentUiHeight() - Settings::LunaSettings()->positiveSpaceTopPadding)/2; if (!m_fullScreenMode) { maxHeight = maxHeight - Settings::LunaSettings()->positiveSpaceTopPadding; } w = (w > maxWidth ? maxWidth : w); h = (h > maxHeight ? maxHeight : h); if (w>h) { //Going to a landscape card setNewEmuRect(maxHeight, maxWidth); HostWindow::resizeEventSync(maxHeight,maxWidth); } else { //Going to a portrait card setNewEmuRect(maxWidth, maxHeight); HostWindow::resizeEventSync(maxWidth,maxHeight); } setBoundingRect(windowScreenBounds.width(), windowScreenBounds.height()); setVisibleDimensions(windowScreenBounds.width(), windowScreenBounds.height()); m_paintPath = QPainterPath(); m_paintPath.addRoundedRect(m_boundingRect, 25, 25); // reconstruct shadow CardDropShadowEffect* shadow = static_cast<CardDropShadowEffect*>(graphicsEffect()); if (shadow) { bool enable = shadow->isEnabled(); setGraphicsEffect(0); shadow = new CardDropShadowEffect(this); setGraphicsEffect(shadow); shadow->setEnabled(enable); } if(directRendering) setMaximized(true); // re-enable direct rendering } }
void DockModeClockWindow::resizeEventSync (int w, int h) { setBoundingRect (w, h); }
EllipseNode::EllipseNode(const rectangle &boundingRect) { setBoundingRect(boundingRect); }
TriangleNode::TriangleNode(const rectangle &boundingRect) { setBoundingRect(boundingRect); }