Exemplo n.º 1
0
void OSScreenManager::fillRect(SurfaceNum surfaceNum, Rect *rect, byte r, byte g, byte b) {
	DirectDrawSurface *surface = getDDSurface(surfaceNum);
	if (!surface)
		return;

	// If bounds are provided, clip and use them. Otherwise, use entire surface area
	Rect surfaceRect(0, 0, surface->getWidth(), surface->getHeight());
	Rect tempRect;

	if (rect) {
		tempRect = *rect;
		tempRect.clip(surfaceRect);
	} else {
		tempRect = surfaceRect;
	}

	// Constrain the fill area to the set modification area of the surface
	Rect surfaceBounds = (surfaceNum == SURFACE_PRIMARY) ? _frontSurfaceBounds :
		_backSurfaces[surfaceNum]._bounds;
	if (!surfaceBounds.isEmpty())
		tempRect.constrain(surfaceBounds);

	// If there is any area defined, clear it
	if (tempRect.isValidRect())
		surface->fillRect(&tempRect, r, g, b);
}
Exemplo n.º 2
0
/*!
    Returns the static content inside the \a parent if non-zero; otherwise the static content
    for the entire backing store is returned. The content will be clipped to \a withinClipRect
    if non-empty.
*/
QRegion QWidgetBackingStore::staticContents(QWidget *parent, const QRect &withinClipRect) const
{
    if (!parent && tlw->testAttribute(Qt::WA_StaticContents)) {
        const QRect surfaceGeometry(windowSurface->geometry());
        QRect surfaceRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height());
        if (!withinClipRect.isEmpty())
            surfaceRect &= withinClipRect;
        return QRegion(surfaceRect);
    }

    QRegion region;
    if (parent && parent->d_func()->children.isEmpty())
        return region;

    const bool clipToRect = !withinClipRect.isEmpty();
    const int count = staticWidgets.count();
    for (int i = 0; i < count; ++i) {
        QWidget *w = staticWidgets.at(i);
        QWidgetPrivate *wd = w->d_func();
        if (!wd->isOpaque || !wd->extra || wd->extra->staticContentsSize.isEmpty()
            || !w->isVisible() || (parent && !parent->isAncestorOf(w))) {
            continue;
        }

        QRect rect(0, 0, wd->extra->staticContentsSize.width(), wd->extra->staticContentsSize.height());
        const QPoint offset = w->mapTo(parent ? parent : tlw, QPoint());
        if (clipToRect)
            rect &= withinClipRect.translated(-offset);
        if (rect.isEmpty())
            continue;

        rect &= wd->clipRect();
        if (rect.isEmpty())
            continue;

        QRegion visible(rect);
        wd->clipToEffectiveMask(visible);
        if (visible.isEmpty())
            continue;
        wd->subtractOpaqueSiblings(visible, 0, /*alsoNonOpaque=*/true);

        visible.translate(offset);
        region += visible;
    }

    return region;
}
Exemplo n.º 3
0
void OSScreenManager::fillRect(SurfaceNum surfaceNum, Rect *rect, byte r, byte g, byte b) {
	DirectDrawSurface *surface = getDDSurface(surfaceNum);
	if (!surface)
		return;

	// If bounds are provided, clip and use them. Otherwise, use entire surface area
	Rect surfaceRect(0, 0, surface->getWidth(), surface->getHeight());
	Rect tempRect;

	if (rect) {
		tempRect = *rect;
		tempRect.clip(surfaceRect);
	} else {
		tempRect = surfaceRect;
	}

	if (tempRect.isValidRect())
		surface->fillRect(&tempRect, r, g, b);
}
Exemplo n.º 4
0
void QWaylandMaterialDecoration::paint(QPaintDevice *device)
{
    QRect surfaceRect(QPoint(), window()->frameGeometry().size());
    QRect top(QPoint(), QSize(window()->frameGeometry().width(), margins().top()));

    QPainter p(device);
    p.setRenderHint(QPainter::Antialiasing);

    // Title bar
    int radius = waylandWindow()->isMaximized() ? 0 : dp(3);
    QPainterPath roundedRect;
    roundedRect.addRoundedRect(0, 0, window()->frameGeometry().width(), margins().top() * 1.5,
                               radius, radius);

    p.fillPath(roundedRect.simplified(), m_backgroundColor);

    // Window icon
    QIcon icon = waylandWindow()->windowIcon();
    if (!icon.isNull()) {
        QPixmap pixmap = icon.pixmap(QSize(128, 128));
        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);

        QRectF iconRect(0, 0, 22, 22);
        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
                                       margins().left() + BUTTON_SPACING, 4),
                     scaled, iconRect);
    }

    // Window title
    QString windowTitleText = window()->title();
    if (!windowTitleText.isEmpty()) {
        if (m_windowTitle.text() != windowTitleText) {
            m_windowTitle.setText(windowTitleText);
            m_windowTitle.prepare();
        }

        QRect titleBar = top;
        titleBar.setLeft(margins().left() + BUTTON_SPACING +
                         (icon.isNull() ? 0 : 22 + BUTTON_SPACING));
        titleBar.setRight(minimizeButtonRect().left() - BUTTON_SPACING);

        p.save();
        p.setClipRect(titleBar);
        p.setPen(m_textColor);
        QSizeF size = m_windowTitle.size();
        int dx = (top.width() - size.width()) / 2;
        int dy = (top.height() - size.height()) / 2;
        QFont font = p.font();
        font.setBold(true);
        font.setFamily("Roboto");
        p.setFont(font);
        QPoint windowTitlePoint(top.topLeft().x() + dx, top.topLeft().y() + dy);
        p.drawStaticText(windowTitlePoint, m_windowTitle);
        p.restore();
    }

    p.save();
    p.setPen(m_iconColor);

    // Close button
    QBitmap closeIcon = buttonIcon("window-close");
    p.drawPixmap(closeButtonRect(), closeIcon, closeIcon.rect());

    // Maximize button
    QBitmap maximizeIcon =
            buttonIcon(waylandWindow()->isMaximized() ? "window-restore" : "window-maximize");
    p.drawPixmap(maximizeButtonRect(), maximizeIcon, maximizeIcon.rect());

    // Minimize button
    QBitmap minimizeIcon = buttonIcon("window-minimize");
    p.drawPixmap(minimizeButtonRect(), minimizeIcon, minimizeIcon.rect());

    p.restore();
}