void HTMLCanvasElement::reset() { if (m_ignoreReset) return; resetDirtyRect(); bool ok; bool hadImageBuffer = hasImageBuffer(); int w = getAttribute(widthAttr).toInt(&ok); if (!ok || w < 0) w = DefaultWidth; int h = getAttribute(heightAttr).toInt(&ok); if (!ok || h < 0) h = DefaultHeight; if (m_contextStateSaver) { // Reset to the initial graphics context state. m_contextStateSaver->restore(); m_contextStateSaver->save(); } if (m_context && m_context->is2d()) toCanvasRenderingContext2D(m_context.get())->reset(); IntSize oldSize = size(); IntSize newSize(w, h); // If the size of an existing buffer matches, we can just clear it instead of reallocating. // This optimization is only done for 2D canvases for now. if (hadImageBuffer && oldSize == newSize && m_context && m_context->is2d()) { if (!m_didClearImageBuffer) clearImageBuffer(); return; } setSurfaceSize(newSize); if (m_context && m_context->is3d() && oldSize != size()) toWebGLRenderingContext(m_context.get())->reshape(width(), height()); if (RenderObject* renderer = this->renderer()) { if (renderer->isCanvas()) { if (oldSize != size()) { toRenderHTMLCanvas(renderer)->canvasSizeChanged(); if (renderBox() && renderBox()->hasAcceleratedCompositing()) renderBox()->contentChanged(CanvasChanged); } if (hadImageBuffer) renderer->setShouldDoFullPaintInvalidation(true); } } WillBeHeapHashSet<RawPtrWillBeWeakMember<CanvasObserver> >::iterator end = m_observers.end(); for (WillBeHeapHashSet<RawPtrWillBeWeakMember<CanvasObserver> >::iterator it = m_observers.begin(); it != end; ++it) (*it)->canvasResized(this); }
void GraphDraw::setZoomScale(const qreal zoom) { _zoomScale = zoom; QSizeF newSize(GraphDrawCanvasSize*this->zoomScale()); _image = QImage(newSize.width(), newSize.height(), QImage::Format_ARGB32); this->resize(_image.size()); this->render(); }
void PatMainTabView::resizeEvent( QResizeEvent * event ) { QSize size = event->size(); QSize newSize(size.width() - 7,size.height() - 30); m_mainWidget->resize(newSize); }
bool wxTopLevelWindowPalm::HandleSize(EventType* event) { wxSize newSize(event->data.winResized.newBounds.extent.x, event->data.winResized.newBounds.extent.y); wxSizeEvent eventWx(newSize,GetId()); eventWx.SetEventObject(this); return GetEventHandler()->ProcessEvent(eventWx); }
void ZoneViewWidget::resizeToZoneContents() { QRectF zoneRect = zone->getOptimumRect(); QSizeF newSize(qMax(QGraphicsWidget::layout()->effectiveSizeHint(Qt::MinimumSize, QSizeF()).width(), zoneRect.width() + 10), zoneRect.height() + extraHeight + 10); setMaximumSize(newSize); resize(newSize); if (layout()) layout()->invalidate(); }
void ZoneViewWidget::resizeToZoneContents() { QRectF zoneRect = zone->getOptimumRect(); QSizeF newSize(zoneRect.width() + 10, zoneRect.height() + extraHeight + 10); setMaximumSize(newSize); resize(newSize); if (layout()) layout()->invalidate(); }
void DeclarativeItemContainer::widthChanged() { if (!m_declarativeItem) { return; } QSizeF newSize(size()); newSize.setWidth(m_declarativeItem.data()->width()); resize(newSize); }
void DeclarativeItemContainer::heightChanged() { if (!m_declarativeItem) { return; } QSizeF newSize(size()); newSize.setHeight(m_declarativeItem.data()->height()); resize(newSize); }
void DashedLine::updateDashes() { sf::Vector2f newSize(this->width, getDashLength()); sf::Color newColor = this->color; std::vector<sf::RectangleShape>::iterator it; int i; for (it = dashes.begin(), i=0; it < dashes.end(); it++, i++) { it->setSize(newSize); it->setPosition(0, i*(newSize.y + dashSpacing)); it->setFillColor(newColor); } }
void FramesWeightFrame::paintEvent(QPaintEvent *) { QSize newSize(frames_count*FrameBarWidth, TrackHeight); if(newSize != size()) resize(newSize); drawWeights(); QPainter p(this); p.drawPixmap(0, 0, *offscreen); }
void Ut_mdetailedlistitem::testResizeEvent() { QGraphicsSceneResizeEvent event; event.setOldSize(QSizeF(100, 100)); QSizeF newSize(200, 200); event.setNewSize(newSize); m_subject->resizeEvent(&event); QVERIFY(m_subject->d_ptr->layout()); }
void Screen::flushImage(ImageFrame *frame, const Common::Point &pt, Common::Rect &newBounds, int scaleVal) { Common::Point newPos(newBounds.left, newBounds.top); Common::Point newSize(newBounds.width(), newBounds.height()); if (scaleVal == SCALE_THRESHOLD) flushImage(frame, pt, &newPos.x, &newPos.y, &newSize.x, &newSize.y); else flushScaleImage(frame, pt, &newPos.x, &newPos.y, &newSize.x, &newSize.y, scaleVal); // Transfer the pos and size amounts into a single bounds rect newBounds = Common::Rect(newPos.x, newPos.y, newPos.x + newSize.x, newPos.y + newSize.y); }
void ScheduleViewEx::OnDraw(CDC* pDC) { Periods& periods = static_cast<CScheduleApp*>(AfxGetApp())->m_periods; Period& period = periods.GetCurrentPeriod(); CTime startDay = period.m_dateRange.GetStartDate(); startDay = startDay + CTimeSpan(xDelta*GetXOffset(),0,0,0); CTime stopDay = startDay + CTimeSpan(xDelta,0,0,0); Truncate(startDay,period.m_dateRange.GetStartDate(), period.m_dateRange.GetEndDate()); Truncate(stopDay,period.m_dateRange.GetStartDate(), period.m_dateRange.GetEndDate()); int startNurse = yDelta * GetYOffset(); int stopNurse = startNurse + yDelta; CString outputText = ViewOutput(startDay,stopDay, startNurse,stopNurse); CFont tmpcourierFont; if (pDC->m_bPrinting) tmpcourierFont.CreatePointFont(printFontSize,_T("Lucida Console")); else tmpcourierFont.CreatePointFont(viewFontSize,_T("Lucida Console")); LOGFONT logFont; tmpcourierFont.GetLogFont(&logFont); logFont.lfUnderline = 1; CFont courierFont; courierFont.CreateFontIndirect(&logFont); CFont * oldFont; oldFont = pDC->SelectObject(&courierFont); pDC->DrawText(outputText,CRect(250,-250,250,-250),DT_NOCLIP); if (!pDC->m_bPrinting) { CRect rcOut(0,0,0,0); VERIFY(pDC->DrawText(outputText,&rcOut,DT_NOCLIP | DT_CALCRECT)); CSize newSize(rcOut.right*1.1,(rcOut.bottom*-1)*1.1); if (newSize != m_oldSize) { SetScrollSizes(MM_HIENGLISH,newSize); m_oldSize = newSize; } } CFont * tmpFont = pDC->SelectObject(oldFont); ASSERT(tmpFont = &courierFont); }
void wxPolarAreaChart::DoSetSize(const wxSize &size) { wxSize newSize( size.GetWidth() - m_options.GetPadding().GetTotalHorizontalPadding(), size.GetHeight() - m_options.GetPadding().GetTotalVerticalPadding() ); m_grid.Resize(newSize); for (size_t i = 0; i < m_slices.size(); ++i) { m_slices[i]->Resize(newSize); } }
void WebPage::scheduleAdjustPage() { if (view()->isLoading()) { m_adjustingScheduled = true; } else { const QSize originalSize = view()->size(); QSize newSize(originalSize.width() - 1, originalSize.height() - 1); view()->resize(newSize); view()->resize(originalSize); } }
void QAndroidMediaPlayerControl::onVideoSizeChanged(qint32 width, qint32 height) { QSize newSize(width, height); if (width == 0 || height == 0 || newSize == mVideoSize) return; setVideoAvailable(true); mVideoSize = newSize; if (mVideoOutput) mVideoOutput->setVideoSize(mVideoSize); }
ResizeVector ResizeDialog::resizeVector() const { ResizeVector rv; QSize s = newSize(); QPoint o = newOffset(); rv.top = o.y(); rv.left = o.x(); rv.right = s.width() - _oldsize.width() - o.x(); rv.bottom = s.height() - _oldsize.height() - o.y(); return rv; }
void LinearLayout::PositionSubviews() { const Rect &padding = this->GetPadding(); const Rect &margin = this->GetMargin(); const LayoutParams &layoutParams = this->GetLayoutParams(); Point offset(padding.left, padding.top); auto &subviews = this->GetSubviews(); for (View *view : subviews) { if (view->GetVisibility() != ViewVisible) { continue; } const Rect &viewMargin = view->GetMargin(); const Rect &viewPadding = view->GetPadding(); Point viewOffset = offset; const LayoutParams &viewLayoutParams = view->GetLayoutParams(); const Frame &frame = view->GetFrame(); Rect measureBounds(frame.origin.x, frame.origin.y, frame.origin.x + frame.size.width, frame.origin.y + frame.size.height); measureBounds.left = viewOffset.x + viewMargin.left; measureBounds.right = measureBounds.left + frame.size.width + viewPadding.right + viewPadding.left; measureBounds.top = viewOffset.y + viewMargin.top; measureBounds.bottom = measureBounds.top + frame.size.height + viewPadding.top + viewPadding.bottom; if (measureBounds.right + measureBounds.left > this->GetWidth()) { measureBounds.right = this->GetWidth(); } Size newSize(measureBounds.right - measureBounds.left, measureBounds.bottom - measureBounds.top); view->SetFrame(Frame(measureBounds.left, measureBounds.top, newSize.width, newSize.height)); if (mOrientation == LinearLayoutHorizontal) { offset.x = measureBounds.right + viewMargin.right; } else { offset.y = measureBounds.bottom + viewMargin.bottom; } } // Calculate weighted views }
cv::Mat FilterFeatureExtractor::extractAbsoluteResponse(const cv::Mat &inputImage) const { Matrix realResponse; Matrix imagResponse; cv::filter2D(inputImage, realResponse, CV_64F, realKernel); cv::filter2D(inputImage, imagResponse, CV_64F, imagKernel); /* { cv::Mat kernel1, kernel2; cv::normalize(realKernel, kernel1, 0, 255, cv::NORM_MINMAX, CV_8UC1); cv::normalize(imagKernel, kernel2, 0, 255, cv::NORM_MINMAX, CV_8UC1); cv::imshow("real", kernel1); cv::imshow("imag", kernel2); } { cv::Mat ds1, dst2; cv::normalize(realResponse, ds1, 0, 255, cv::NORM_MINMAX, CV_8UC1); cv::normalize(imagResponse, dst2, 0, 255, cv::NORM_MINMAX, CV_8UC1); cv::imshow("real resp", ds1); cv::imshow("imag resp", dst2); cv::Mat orig; cv::normalize(inputImage, orig, 0, 255, cv::NORM_MINMAX, CV_8UC1); cv::imshow("orig", orig); } */ cv::Size newSize(inputImage.cols * imageScale, inputImage.rows * imageScale); cv::resize(realResponse, realResponse, newSize); cv::resize(imagResponse, imagResponse, newSize); Matrix result(newSize); int i = 0; for (int r = 0; r < realResponse.rows; r++) { for (int c = 0; c < realResponse.cols; c++) { result(i++) = std::sqrt(realResponse(r, c) * realResponse(r, c) + imagResponse(r, c) * imagResponse(r, c)); } } /* { cv::Mat orig; cv::normalize(result, orig, 0, 255, cv::NORM_MINMAX, CV_8UC1); cv::imshow("result abs", orig); cv::waitKey(4000); }*/ return result; }
QRect KstGfxMouseHandlerUtils::resizeRectFromEdge(const QRect& originalSize, const QPoint& anchorPoint, const QPoint& movePoint, const QPoint& pos, const QRect &bounds, bool maintainAspect) { QRect newSize(originalSize); if (movePoint.y() == anchorPoint.y()) { int newWidth = pos.x() - anchorPoint.x(); //defined differently than in QRect. if (maintainAspect) { double newHalfHeight = originalSize.height() * (abs(newWidth) + 1) / originalSize.width() / 2.0; //defined with the QRect convention (height = bot - top + 1) newHalfHeight = kMin(double(movePoint.y() - bounds.top()) + 1, newHalfHeight); // ensure we are still within the bounds. newHalfHeight = kMin(double(bounds.bottom() - movePoint.y()) + 1, newHalfHeight); if (newWidth == 0) { // anything better to be done? newWidth = 1; } newWidth = (int(originalSize.width() * (newHalfHeight * 2.0) / originalSize.height()) - 1)*newWidth/abs(newWidth); // consistency of width w/ the newly calculated height. newSize.setTop(anchorPoint.y() + int(newHalfHeight - 0.5)); newSize.setBottom(anchorPoint.y() - int(newHalfHeight - 0.5)); } newSize.setLeft(anchorPoint.x()); newSize.setRight(anchorPoint.x() + newWidth); // +1 for the way widths are defined in QRect. } else if (movePoint.x() == anchorPoint.x()) { // mimic the case for (movePoint.y() == anchorPoint.y()). comments are there. int newHeight = pos.y() - anchorPoint.y(); if (maintainAspect) { double newHalfWidth = originalSize.width() * (abs(newHeight) + 1) / originalSize.height() / 2.0; newHalfWidth = kMin(double(movePoint.x() - bounds.left() + 1), newHalfWidth); newHalfWidth = kMin(double(bounds.right() - movePoint.x() + 1), newHalfWidth); if (newHeight == 0) { newHeight = 1; } newHeight = (int(originalSize.height() * newHalfWidth * 2.0 / originalSize.width()) - 1)*newHeight/abs(newHeight); newSize.setLeft(anchorPoint.x() + int(newHalfWidth - .5)); newSize.setRight(anchorPoint.x() - int(newHalfWidth - .5)); } newSize.setTop(anchorPoint.y()); newSize.setBottom(anchorPoint.y() + newHeight); } return newSize.normalize(); }
QJSValue Image::setScaledSize(int w, int h, const QJSValue &scaleMode) { QSize newSize(w, h); if (scaleMode.isNumber()) { int mode = scaleMode.toInt(); if (mode < 0 || mode > 2) { qWarning("Invalid scale mode"); } else { QSize original = m_reader->size(); newSize = original.scaled(newSize, (Qt::AspectRatioMode)mode); } } m_reader->setScaledSize(newSize); return self(); }
void ImageWindow::resizeImage() { QDialog dialog; Ui::ResizeDialog ui; ui.setupUi(&dialog); ui.widthSpinBox->setValue(imageLabel->pixmap()->width()); ui.heightSpinBox->setValue(imageLabel->pixmap()->height()); if (dialog.exec()) { QSize newSize(ui.widthSpinBox->value(), ui.heightSpinBox->value()); addTransaction(new ResizeTransaction(newSize)); } }
ForceMeter::ForceMeter(int posX, int posY, int sizeX, int sizeY){ sf::Vector2f newSize(sizeX, sizeY); m_size = newSize; m_body.setSize(m_size); m_body.setPosition(posX, posY); m_body.setFillColor(sf::Color::White); meterBody.setPosition(posX + sizeX/2, posY); meterBody.setSize(sf::Vector2f(sizeX/100.0, sizeY)); meterBody.setFillColor(sf::Color::Blue); setForce(0); update(); }
void OpenGL2Common::dispatchEvent(QEvent *e, QObject *p) { switch (e->type()) { case QEvent::Resize: newSize(((QResizeEvent *)e)->size()); break; case QEvent::Gesture: /* Pass gesture event to the parent */ QCoreApplication::sendEvent(p, e); break; default: break; } }
void QgsLocatorResultsView::recalculateSize() { // try to show about 20 rows int rowSize = 20 * itemDelegate()->sizeHint( viewOptions(), model()->index( 0, 0 ) ).height(); // try to take up a sensible portion of window width (about half) int width = std::max( 300, window()->size().width() / 2 ); QSize newSize( width, rowSize + frameWidth() * 2 ); // resize the floating widget this is contained within parentWidget()->resize( newSize ); QTreeView::resize( newSize ); header()->resizeSection( 0, width / 2 ); header()->resizeSection( 1, 0 ); }
QRect KstGfxMouseHandlerUtils::resizeRectFromEdgeCentered(const QRect& originalRect, const QPoint& anchorPoint, const QPoint& movePoint, const QPoint& pos, const QRect& bounds, bool maintainAspect) { QRect newRect; bool vertical; int newHalfWidth = abs((pos - anchorPoint).x()); int newHalfHeight = abs((pos - anchorPoint).y()); if (movePoint.x() == anchorPoint.x()) { vertical = true; } else { vertical = false; } if (maintainAspect) { QSize newSize(originalRect.size()); if (vertical) { newHalfHeight = kMin(newHalfHeight, anchorPoint.y() - bounds.top()); newHalfHeight = kMin(newHalfHeight, bounds.bottom() - anchorPoint.y()); if (newHalfHeight > originalRect.height()/2) { newSize.scale(originalRect.width(), 2*newHalfHeight, QSize::ScaleMax); } else { newSize.scale(originalRect.width(), 2*newHalfHeight, QSize::ScaleMin); } } else { newHalfWidth = kMin(newHalfWidth, anchorPoint.x() - bounds.left()); newHalfWidth = kMin(newHalfWidth, bounds.right() - anchorPoint.x()); if (newHalfWidth > originalRect.width()/2) { newSize.scale(2*newHalfWidth, originalRect.height(), QSize::ScaleMax); } else { newSize.scale(2*newHalfWidth, originalRect.height(), QSize::ScaleMin); } } newRect.setSize(newSize); newRect.moveCenter(anchorPoint); newRect = newRect.intersect(bounds); } else { if (vertical) { newRect = QRect(0, 0, originalRect.width(), 2*newHalfHeight); } else { newRect = QRect(0, 0, 2*newHalfWidth, originalRect.height()); } newRect.moveCenter(anchorPoint); newRect = newRect.intersect(bounds); } return newRect; }
void ZoneViewWidget::resizeToZoneContents() { QRectF zoneRect = zone->getOptimumRect(); qreal totalZoneHeight = zoneRect.height(); if (zoneRect.height() > 500) zoneRect.setHeight(500); QSizeF newSize(qMax(QGraphicsWidget::layout()->effectiveSizeHint(Qt::MinimumSize, QSizeF()).width(), zoneRect.width() + scrollBar->width() + 10), zoneRect.height() + extraHeight + 10); setMaximumSize(newSize); resize(newSize); zone->setGeometry(QRectF(0, -scrollBar->value(), zoneContainer->size().width(), totalZoneHeight)); scrollBar->setMaximum(totalZoneHeight - zoneRect.height()); if (layout()) layout()->invalidate(); }
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { m_qtSpinBox = new wxQtSpinButton( parent, this ); // Modify the size so that the text field is not visible. // TODO: Find out the width of the buttons i.e. take the style into account (QStyleOptionSpinBox). wxSize newSize( size ); newSize.SetWidth( 18 ); return QtCreateControl( parent, id, pos, newSize, style, wxDefaultValidator, name ); }
void KstTopLevelView::pressMoveLayoutModeResize(const QPoint& pos, bool maintainAspect) { const QRect old(_prevBand); _prevBand = newSize(_pressTarget->geometry(), _pressTarget->_parent->geometry(), _pressDirection, pos, maintainAspect); if (_prevBand != old) { KstPainter p; p.begin(_w); p.setRasterOp(Qt::NotROP); p.setPen(QPen(Qt::black, 0, Qt::DotLine)); if (old.topLeft() != QPoint(-1, -1)) { p.drawRect(old); } p.drawRect(_prevBand); p.end(); } }
void WebPage::scheduleAdjustPage() { WebView* webView = qobject_cast<WebView*>(view()); if (!webView) { return; } if (webView->isLoading()) { m_adjustingScheduled = true; } else { const QSize &originalSize = webView->size(); QSize newSize(originalSize.width() - 1, originalSize.height() - 1); webView->resize(newSize); webView->resize(originalSize); } }