summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
diff options
context:
space:
mode:
authorFabien Freling <fabien.freling@nokia.com>2010-11-04 13:03:46 (GMT)
committerFabien Freling <fabien.freling@nokia.com>2010-11-04 13:04:11 (GMT)
commitfe5a15fc4248a9258d74eea6f64769a3cb173788 (patch)
treee08cdee07b2b3ec0c341479624ae076a3942e0e3 /src/gui/painting/qunifiedtoolbarsurface_mac.cpp
parent953ff11a1b424dd288b6504c5a6f918acaebaa60 (diff)
downloadQt-fe5a15fc4248a9258d74eea6f64769a3cb173788.zip
Qt-fe5a15fc4248a9258d74eea6f64769a3cb173788.tar.gz
Qt-fe5a15fc4248a9258d74eea6f64769a3cb173788.tar.bz2
Update the offsets of the QToolBars inside
the unified toolbar on Mac OS X. Task-number: QTBUG-12818 Reviewed-by: Samuel Rødal
Diffstat (limited to 'src/gui/painting/qunifiedtoolbarsurface_mac.cpp')
-rw-r--r--src/gui/painting/qunifiedtoolbarsurface_mac.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
index ab05dbd..3590993 100644
--- a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
+++ b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
@@ -42,6 +42,7 @@
#include "qunifiedtoolbarsurface_mac_p.h"
#include <private/qt_cocoa_helpers_mac_p.h>
#include <private/qbackingstore_p.h>
+#include <private/qmainwindowlayout_p.h>
#include <QDebug>
@@ -90,7 +91,6 @@ void QUnifiedToolbarSurface::insertToolbar(QWidget *toolbar, const QPoint &offse
{
setGeometry(QRect(QPoint(0, 0), QSize(offset.x() + toolbar->width(), 100))); // FIXME
recursiveRedirect(toolbar, offset);
-// toolbar->d_func()->toolbar_offset = offset;
}
void QUnifiedToolbarSurface::setGeometry(const QRect &rect)
@@ -101,6 +101,8 @@ void QUnifiedToolbarSurface::setGeometry(const QRect &rect)
if (d->image == 0 || d->image->width() < rect.width() || d->image->height() < rect.height())
prepareBuffer(QImage::Format_ARGB32_Premultiplied, window());
d->inSetGeometry = false;
+
+ // FIXME: set unified toolbar height.
}
void QUnifiedToolbarSurface::beginPaint(const QRegion &rgn)
@@ -114,10 +116,18 @@ void QUnifiedToolbarSurface::beginPaint(const QRegion &rgn)
}
}
+void QUnifiedToolbarSurface::updateToolbarOffset(QWidget *widget)
+{
+ QMainWindowLayout *mlayout = qobject_cast<QMainWindowLayout*> (widget->window()->layout());
+ mlayout->updateUnifiedToolbarOffset();
+}
+
void QUnifiedToolbarSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset)
{
Q_D(QUnifiedToolbarSurface);
+ QRegion flushingRegion(widget->rect());
+
if (!d->image || rgn.rectCount() == 0) {
return;
}
@@ -132,24 +142,29 @@ void QUnifiedToolbarSurface::flush(QWidget *widget, const QRegion &rgn, const QP
qt_mac_display(widget);
return;
} else {
+ // We render the content of the toolbar in the surface.
+ updateToolbarOffset(widget);
+ QRect beginPaintRect(widget->d_func()->toolbar_offset.x(), widget->d_func()->toolbar_offset.y(), widget->geometry().width(), widget->geometry().height());
+ QRegion beginPaintRegion(beginPaintRect);
+
context = widget->d_func()->cgContext;
+ beginPaint(beginPaintRegion);
widget->render(widget->d_func()->unifiedSurface->paintDevice(), widget->d_func()->toolbar_offset, QRegion(), QWidget::DrawChildren);
}
CGContextSaveGState(context);
- int areaX = widget->geometry().x() + widget->d_func()->toolbar_offset.x();
- int areaY = widget->geometry().y() + widget->d_func()->toolbar_offset.y();
+ int areaX = widget->d_func()->toolbar_offset.x();
+ int areaY = widget->d_func()->toolbar_offset.y();
int areaWidth = widget->geometry().width();
int areaHeight = widget->geometry().height();
const CGRect area = CGRectMake(areaX, areaY, areaWidth, areaHeight);
// Clip to region.
- const QVector<QRect> &rects = rgn.rects();
+ const QVector<QRect> &rects = flushingRegion.rects();
for (int i = 0; i < rects.size(); ++i) {
const QRect &rect = rects.at(i);
- // CGContextAddRect(context, CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()));
- CGContextAddRect(context, CGRectMake(0, 0, 1000, 1000)); //FIXME: Set correct size.
+ CGContextAddRect(context, CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()));
}
CGContextAddRect(context, area);
CGContextClip(context);