EXPORT_C void CHuiTexture::SetSize(const TSize& aSize) { // if there are multiple // segments already defined we have to recalculate (rescale) // the logical sizes and offsets for the individual segments // to match the new logical size if (SegmentCount()>0 && iSize.iWidth > 0 && iSize.iHeight > 0) { for (TInt s = 0; s < SegmentCount(); s++) { TSize oldSize(SegmentSize(s)); TSize newSize(oldSize.iWidth * aSize.iWidth / iSize.iWidth, oldSize.iHeight * aSize.iHeight / iSize.iHeight); TPoint oldOffset(SegmentOffset(s)); TPoint newOffset(oldOffset.iX * aSize.iWidth / iSize.iWidth, oldOffset.iY * aSize.iHeight / iSize.iHeight); SetSegmentSize(s, newSize); SetSegmentOffset(s, newOffset); } } // assign new logical size iSize = aSize; }
void ImageDocument::UpdateSizeFromLayout() { // Pull an updated size from the content frame to account for any size // change due to CSS properties like |image-orientation|. Element* contentElement = mImageContent->AsElement(); if (!contentElement) { return; } nsIFrame* contentFrame = contentElement->GetPrimaryFrame(Flush_Frames); if (!contentFrame) { return; } nsIntSize oldSize(mImageWidth, mImageHeight); IntrinsicSize newSize = contentFrame->GetIntrinsicSize(); if (newSize.width.GetUnit() == eStyleUnit_Coord) { mImageWidth = nsPresContext::AppUnitsToFloatCSSPixels(newSize.width.GetCoordValue()); } if (newSize.height.GetUnit() == eStyleUnit_Coord) { mImageHeight = nsPresContext::AppUnitsToFloatCSSPixels(newSize.height.GetCoordValue()); } // Ensure that our information about overflow is up-to-date if needed. if (mImageWidth != oldSize.width || mImageHeight != oldSize.height) { CheckOverflowing(false); } }
void RenderSVGRoot::layout() { ASSERT(needsLayout()); // Arbitrary affine transforms are incompatible with LayoutState. LayoutStateDisabler layoutStateDisabler(view()); bool needsLayout = selfNeedsLayout(); LayoutRepainter repainter(*this, checkForRepaintDuringLayout() && needsLayout); IntSize oldSize(width(), height()); negotiateSizeWithHostDocumentIfNeeded(); computeLogicalWidth(); computeLogicalHeight(); calcViewport(); SVGSVGElement* svg = static_cast<SVGSVGElement*>(node()); m_isLayoutSizeChanged = svg->hasRelativeLengths() && oldSize != size(); SVGRenderSupport::layoutChildren(this, needsLayout); m_isLayoutSizeChanged = false; // At this point LayoutRepainter already grabbed the old bounds, // recalculate them now so repaintAfterLayout() uses the new bounds. if (m_needsBoundariesOrTransformUpdate) { updateCachedBoundaries(); m_needsBoundariesOrTransformUpdate = false; } repainter.repaintAfterLayout(); setNeedsLayout(false); }
void PiqslImageView::resizeEvent(QResizeEvent* event) { if(!event->oldSize().isValid()) return; // Reposition image such that the pixel in the center of the widget stays // in the center after the resize. QPointF size(event->size().width(), event->size().height()); QPointF oldSize(event->oldSize().width(), event->oldSize().height()); m_tlPos += 0.5f*(size - oldSize); }
Real getAlpha0(RealVector::size_type i) const { RealVector& alphaTable( this->alphaTable[0] ); RealVector::size_type oldSize( alphaTable.size() ); if( oldSize <= i ) { alphaTable.resize( i+1 ); for( RealVector::size_type m( oldSize ); m <= i; ++m ) { alphaTable[m] = alpha0_i( m ); } } return alphaTable[i]; }
void State<T_>::append(const State<T_>& tail) { #ifndef NDEBUG for (const auto var_ptr: tail) if (is_our_var(var_ptr->name())) throw_FigException(std::string("variable \"") .append(var_ptr->name()) .append("\" already exists in this state")); #endif size_t oldSize(pvars_.size()); pvars_.insert(::end(pvars_), ::begin(tail), ::end(tail)); positionOfVar_.insert(::begin(tail.positionOfVar_), ::end(tail.positionOfVar_)); // Compute new variables global positions, // taking into account the offset from the ones we already have for (const auto& pair: tail.positionOfVar_) positionOfVar_[pair.first] += oldSize; build_concrete_bound(); }
void RenderSVGRoot::layout() { ASSERT(needsLayout()); m_resourcesNeedingToInvalidateClients.clear(); // Arbitrary affine transforms are incompatible with LayoutState. LayoutStateDisabler layoutStateDisabler(view()); bool needsLayout = selfNeedsLayout(); LayoutRepainter repainter(*this, checkForRepaintDuringLayout() && needsLayout); LayoutSize oldSize(width(), height()); computeLogicalWidth(); computeLogicalHeight(); buildLocalToBorderBoxTransform(); SVGSVGElement* svg = static_cast<SVGSVGElement*>(node()); m_isLayoutSizeChanged = needsLayout || (svg->hasRelativeLengths() && oldSize != size()); SVGRenderSupport::layoutChildren(this, needsLayout || SVGRenderSupport::filtersForceContainerLayout(this)); m_isLayoutSizeChanged = false; if (!m_resourcesNeedingToInvalidateClients.isEmpty()) { // Invalidate resource clients, which may mark some nodes for layout. HashSet<RenderSVGResourceContainer*>::iterator end = m_resourcesNeedingToInvalidateClients.end(); for (HashSet<RenderSVGResourceContainer*>::iterator it = m_resourcesNeedingToInvalidateClients.begin(); it != end; ++it) (*it)->removeAllClientsFromCache(); m_isLayoutSizeChanged = false; SVGRenderSupport::layoutChildren(this, false); } // At this point LayoutRepainter already grabbed the old bounds, // recalculate them now so repaintAfterLayout() uses the new bounds. if (m_needsBoundariesOrTransformUpdate) { updateCachedBoundaries(); m_needsBoundariesOrTransformUpdate = false; } repainter.repaintAfterLayout(); setNeedsLayout(false); }
void TextSprite::OnAtlasLayerChange(const AbstractAtlas* atlas, AbstractImage* oldLayer, AbstractImage* newLayer) { NazaraUnused(atlas); #ifdef NAZARA_DEBUG if (m_atlases.find(atlas) == m_atlases.end()) { NazaraInternalError("Not listening to " + String::Pointer(atlas)); return; } #endif // The texture of an atlas have just been recreated (size change) // we have to adjust the coordinates of the texture and the rendering texture Texture* oldTexture = static_cast<Texture*>(oldLayer); Texture* newTexture = static_cast<Texture*>(newLayer); // It is possible that we don't use the texture (the atlas warning us for each of its layers) auto it = m_renderInfos.find(oldTexture); if (it != m_renderInfos.end()) { // We indeed use this texture, we have to update its coordinates RenderIndices indices = std::move(it->second); Vector2ui oldSize(oldTexture->GetSize()); Vector2ui newSize(newTexture->GetSize()); Vector2f scale = Vector2f(oldSize) / Vector2f(newSize); // ratio of the old one to the new one // Now we will iterate through each coordinates of the concerned texture to multiply them by the ratio SparsePtr<Vector2f> texCoordPtr(&m_localVertices[indices.first].uv, sizeof(VertexStruct_XYZ_Color_UV)); for (unsigned int i = 0; i < indices.count; ++i) { for (unsigned int j = 0; j < 4; ++j) m_localVertices[i*4 + j].uv *= scale; } // We get rid off the old texture and we set the new one at the place (same for indices) m_renderInfos.erase(it); m_renderInfos.insert(std::make_pair(newTexture, std::move(indices))); } }
void RenderSVGRoot::layout() { ASSERT(needsLayout()); // Arbitrary affine transforms are incompatible with LayoutState. LayoutStateDisabler layoutStateDisabler(view()); bool needsLayout = selfNeedsLayout(); LayoutRepainter repainter(*this, checkForRepaintDuringLayout() && needsLayout); LayoutSize oldSize(width(), height()); computeLogicalWidth(); computeLogicalHeight(); SVGSVGElement* svg = static_cast<SVGSVGElement*>(node()); m_isLayoutSizeChanged = needsLayout || (svg->hasRelativeLengths() && oldSize != size()); if (view() && view()->frameView() && view()->frameView()->embeddedContentBox()) { if (!m_needsSizeNegotiationWithHostDocument) m_needsSizeNegotiationWithHostDocument = !m_everHadLayout || oldSize != size(); } else ASSERT(!m_needsSizeNegotiationWithHostDocument); SVGRenderSupport::layoutChildren(this, needsLayout || SVGRenderSupport::filtersForceContainerLayout(this)); m_isLayoutSizeChanged = false; // At this point LayoutRepainter already grabbed the old bounds, // recalculate them now so repaintAfterLayout() uses the new bounds. if (m_needsBoundariesOrTransformUpdate) { updateCachedBoundaries(); m_needsBoundariesOrTransformUpdate = false; } repainter.repaintAfterLayout(); setNeedsLayout(false); }
Real getAlpha(size_t n, RealVector::size_type i) const { RealVector& alphaTable( this->alphaTable[n] ); RealVector::size_type oldSize( alphaTable.size() ); if( oldSize <= i ) { alphaTable.resize( i+1 ); unsigned int offset( alphaOffset( n ) ); gsl_root_fsolver* solver( gsl_root_fsolver_alloc(gsl_root_fsolver_brent)); for( RealVector::size_type m( oldSize ); m <= i; ++m ) { alphaTable[m] = alpha_i( m + offset, n, solver ); } gsl_root_fsolver_free( solver ); } return alphaTable[i]; }
void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) { Q_Q(QWidget); Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); if ((q->windowType() == Qt::Desktop)) return; QPoint oldPos(q->pos()); QSize oldSize(q->size()); QRect oldGeom(data.crect); // Lose maximized status if deliberate resize if (w != oldSize.width() || h != oldSize.height()) data.window_state &= ~Qt::WindowMaximized; if (extra) { // any size restrictions? w = qMin(w,extra->maxw); h = qMin(h,extra->maxh); w = qMax(w,extra->minw); h = qMax(h,extra->minh); } if (q->isWindow()) topData()->normalGeometry = QRect(0, 0, -1, -1); else { uint s = data.window_state; s &= ~(Qt::WindowMaximized | Qt::WindowFullScreen); data.window_state = s; } bool isResize = w != oldSize.width() || h != oldSize.height(); if (!isMove && !isResize) return; if (q->isWindow()) { if (w == 0 || h == 0) { q->setAttribute(Qt::WA_OutsideWSRange, true); if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) hide_sys(); data.crect = QRect(x, y, w, h); data.window_state &= ~Qt::WindowFullScreen; } else if (q->isVisible() && q->testAttribute(Qt::WA_OutsideWSRange)) { q->setAttribute(Qt::WA_OutsideWSRange, false); // put the window in its place and show it q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h))); data.crect.setRect(x, y, w, h); show_sys(); } else { QRect r = QRect(x, y, w, h); data.crect = r; q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h))); topData()->normalGeometry = data.crect; } } else { data.crect.setRect(x, y, w, h); QTLWExtra *tlwExtra = q->window()->d_func()->maybeTopData(); const bool inTopLevelResize = tlwExtra ? tlwExtra->inTopLevelResize : false; if (q->isVisible() && (!inTopLevelResize || q->internalWinId())) { // Top-level resize optimization does not work for native child widgets; // disable it for this particular widget. if (inTopLevelResize) tlwExtra->inTopLevelResize = false; if (!isResize && maybeBackingStore()) moveRect(QRect(oldPos, oldSize), x - oldPos.x(), y - oldPos.y()); else invalidateBuffer_resizeHelper(oldPos, oldSize); if (inTopLevelResize) tlwExtra->inTopLevelResize = true; } if (q->testAttribute(Qt::WA_WState_Created)) setWSGeometry(); } if (q->isVisible()) { if (isMove && q->pos() != oldPos) { QMoveEvent e(q->pos(), oldPos); QApplication::sendEvent(q, &e); } if (isResize) { bool slowResize = qgetenv("QT_SLOW_TOPLEVEL_RESIZE").toInt(); const bool setTopLevelResize = !slowResize && q->isWindow() && extra && extra->topextra && !extra->topextra->inTopLevelResize; if (setTopLevelResize) extra->topextra->inTopLevelResize = true; QResizeEvent e(q->size(), oldSize); QApplication::sendEvent(q, &e); if (!q->testAttribute(Qt::WA_StaticContents) && q->internalWinId()) q->internalWinId()->DrawDeferred(); if (setTopLevelResize) extra->topextra->inTopLevelResize = false; } } else { if (isMove && q->pos() != oldPos) q->setAttribute(Qt::WA_PendingMoveEvent, true); if (isResize) q->setAttribute(Qt::WA_PendingResizeEvent, true); } }