summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp6
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicswidget.h8
-rw-r--r--src/gui/itemviews/qheaderview.cpp24
-rw-r--r--src/gui/kernel/qapplication.cpp16
-rw-r--r--src/gui/kernel/qtooltip.cpp11
-rw-r--r--src/gui/kernel/qwidget_x11.cpp38
-rw-r--r--src/gui/painting/qpainter.cpp9
-rw-r--r--src/gui/s60framework/qs60mainapplication.cpp7
-rw-r--r--src/gui/s60framework/qs60mainappui.cpp10
-rw-r--r--src/gui/s60framework/s60framework.pri3
-rw-r--r--src/gui/styles/qs60style.cpp15
-rw-r--r--src/gui/styles/qs60style_s60.cpp2
-rw-r--r--src/gui/styles/qwindowsmobilestyle.cpp17
-rw-r--r--src/gui/text/qtextlayout.cpp123
15 files changed, 183 insertions, 108 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 159c997..bcdc7d3 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -4301,6 +4301,12 @@ static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion &
if (!subPix.isNull()) {
// Blit the subpixmap into the main pixmap.
pixmapPainter.begin(pix);
+ if (item->cacheMode() == QGraphicsItem::DeviceCoordinateCache
+ && itemToPixmap.type() > QTransform::TxTranslate) {
+ pixmapPainter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
+ } else {
+ pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source);
+ }
pixmapPainter.setClipRegion(pixmapExposed);
pixmapPainter.drawPixmap(br.topLeft(), subPix);
pixmapPainter.end();
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 87416b4..669dd61 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -384,7 +384,7 @@ void QGraphicsWidget::setGeometry(const QRectF &rect)
}
QSizeF oldSize = size();
QGraphicsLayoutItem::setGeometry(newGeom);
-
+ emit geometryChanged();
// Send resize event
bool resized = newGeom.size() != oldSize;
if (resized) {
diff --git a/src/gui/graphicsview/qgraphicswidget.h b/src/gui/graphicsview/qgraphicswidget.h
index 4bea5be..87c669b 100644
--- a/src/gui/graphicsview/qgraphicswidget.h
+++ b/src/gui/graphicsview/qgraphicswidget.h
@@ -73,7 +73,7 @@ class Q_GUI_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphicsLay
Q_PROPERTY(QPalette palette READ palette WRITE setPalette)
Q_PROPERTY(QFont font READ font WRITE setFont)
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection)
- Q_PROPERTY(QSizeF size READ size WRITE resize)
+ Q_PROPERTY(QSizeF size READ size WRITE resize NOTIFY geometryChanged)
Q_PROPERTY(QSizeF minimumSize READ minimumSize WRITE setMinimumSize)
Q_PROPERTY(QSizeF preferredSize READ preferredSize WRITE setPreferredSize)
Q_PROPERTY(QSizeF maximumSize READ maximumSize WRITE setMaximumSize)
@@ -81,12 +81,11 @@ class Q_GUI_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphicsLay
Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy)
Q_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags)
Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle)
- Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry)
+ Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry NOTIFY geometryChanged)
Q_PROPERTY(bool autoFillBackground READ autoFillBackground WRITE setAutoFillBackground)
public:
QGraphicsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
~QGraphicsWidget();
-
QGraphicsLayout *layout() const;
void setLayout(QGraphicsLayout *layout);
void adjustSize();
@@ -179,6 +178,9 @@ public:
using QObject::children;
#endif
+Q_SIGNALS:
+ void geometryChanged();
+
public Q_SLOTS:
bool close();
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index 586e5d4..cd9ee15 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -2220,16 +2220,24 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e)
case QHeaderViewPrivate::MoveSection: {
if (qAbs(pos - d->firstPos) >= QApplication::startDragDistance()
|| !d->sectionIndicator->isHidden()) {
- int indicatorCenter = (d->orientation == Qt::Horizontal
- ? d->sectionIndicator->width()
- : d->sectionIndicator->height()) / 2;
- int centerOffset = indicatorCenter - d->sectionIndicatorOffset;
- // This will drop the moved section to the position under the center of the indicator.
- // If centerOffset is 0, the section will be moved to the position of the mouse cursor.
- int visual = visualIndexAt(pos + centerOffset);
+ int visual = visualIndexAt(pos);
if (visual == -1)
return;
- d->target = d->logicalIndex(visual);
+ int posThreshold = d->headerSectionPosition(visual) + d->headerSectionSize(visual) / 2;
+ int moving = visualIndex(d->section);
+ if (visual < moving) {
+ if (pos < posThreshold)
+ d->target = d->logicalIndex(visual);
+ else
+ d->target = d->logicalIndex(visual + 1);
+ } else if (visual > moving) {
+ if (pos > posThreshold)
+ d->target = d->logicalIndex(visual);
+ else
+ d->target = d->logicalIndex(visual - 1);
+ } else {
+ d->target = d->section;
+ }
d->updateSectionIndicator(d->section, pos);
}
return;
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index fea8c37..9fe6c87 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -903,6 +903,14 @@ void QApplicationPrivate::initialize()
{
QWidgetPrivate::mapper = new QWidgetMapper;
QWidgetPrivate::allWidgets = new QWidgetSet;
+
+#if !defined(Q_WS_X11) && !defined(Q_WS_QWS)
+ // initialize the graphics system - on X11 this is initialized inside
+ // qt_init() in qapplication_x11.cpp because of several reasons.
+ // On QWS, the graphics system is set by the QScreen plugin.
+ graphics_system = QGraphicsSystemFactory::create(graphics_system_name);
+#endif
+
if (qt_appType != QApplication::Tty)
(void) QApplication::style(); // trigger creation of application style
// trigger registering of QVariant's GUI types
@@ -936,13 +944,7 @@ void QApplicationPrivate::initialize()
// Set up which span functions should be used in raster engine...
qInitDrawhelperAsm();
-
-#if !defined(Q_WS_X11) && !defined(Q_WS_QWS)
- // initialize the graphics system - on X11 this is initialized inside
- // qt_init() in qapplication_x11.cpp because of several reasons.
- // On QWS, the graphics system is set by the QScreen plugin.
- graphics_system = QGraphicsSystemFactory::create(graphics_system_name);
-#endif
+
#ifndef QT_NO_WHEELEVENT
QApplicationPrivate::wheel_scroll_lines = 3;
#endif
diff --git a/src/gui/kernel/qtooltip.cpp b/src/gui/kernel/qtooltip.cpp
index c912129..1343959 100644
--- a/src/gui/kernel/qtooltip.cpp
+++ b/src/gui/kernel/qtooltip.cpp
@@ -368,7 +368,16 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w)
#ifdef Q_WS_MAC
- QRect screen = QApplication::desktop()->availableGeometry(getTipScreen(pos, w));
+ // When in full screen mode, there is no Dock nor Menu so we can use
+ // the whole screen for displaying the tooltip. However when not in
+ // full screen mode we need to save space for the dock, so we use
+ // availableGeometry instead.
+ extern bool qt_mac_app_fullscreen; //qapplication_mac.mm
+ QRect screen;
+ if(qt_mac_app_fullscreen)
+ screen = QApplication::desktop()->screenGeometry(getTipScreen(pos, w));
+ else
+ screen = QApplication::desktop()->availableGeometry(getTipScreen(pos, w));
#else
QRect screen = QApplication::desktop()->screenGeometry(getTipScreen(pos, w));
#endif
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index 10fb009..9660de5 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -369,7 +369,7 @@ Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget* w)
// ConfigureNotify ... MapNotify ... Expose
enum State {
- Initial, Reparented, Mapped
+ Initial, Mapped
} state = Initial;
do {
@@ -377,33 +377,15 @@ Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget* w)
XNextEvent(X11->display, &ev);
qApp->x11ProcessEvent(&ev);
- if (w->windowFlags() & Qt::X11BypassWindowManagerHint) {
- switch (state) {
- case Initial:
- case Reparented:
- if (ev.type == MapNotify && ev.xany.window == winid)
- state = Mapped;
- break;
- case Mapped:
- if (ev.type == Expose && ev.xany.window == winid)
- return;
- break;
- }
- } else {
- switch (state) {
- case Initial:
- if (ev.type == ReparentNotify && ev.xany.window == winid)
- state = Reparented;
- break;
- case Reparented:
- if (ev.type == MapNotify && ev.xany.window == winid)
- state = Mapped;
- break;
- case Mapped:
- if (ev.type == Expose && ev.xany.window == winid)
- return;
- break;
- }
+ switch (state) {
+ case Initial:
+ if (ev.type == MapNotify && ev.xany.window == winid)
+ state = Mapped;
+ break;
+ case Mapped:
+ if (ev.type == Expose && ev.xany.window == winid)
+ return;
+ break;
}
} else {
if (!XEventsQueued(X11->display, QueuedAfterFlush))
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index a1ed8f5..db4ace4 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -5414,10 +5414,15 @@ void QPainter::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
scale(w / sw, h / sh);
setBackgroundMode(Qt::TransparentMode);
setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform);
- QBrush brush(d->state->pen.color(), pm);
+ QBrush brush;
+
+ if (sw == pm.width() && sh == pm.height())
+ brush = QBrush(d->state->pen.color(), pm);
+ else
+ brush = QBrush(d->state->pen.color(), pm.copy(sx, sy, sw, sh));
+
setBrush(brush);
setPen(Qt::NoPen);
- setBrushOrigin(QPointF(-sx, -sy));
drawRect(QRectF(0, 0, sw, sh));
restore();
diff --git a/src/gui/s60framework/qs60mainapplication.cpp b/src/gui/s60framework/qs60mainapplication.cpp
index 2a7c4aa..41ac1a8 100644
--- a/src/gui/s60framework/qs60mainapplication.cpp
+++ b/src/gui/s60framework/qs60mainapplication.cpp
@@ -41,6 +41,7 @@
// INCLUDE FILES
#include <exception>
+#include <private/qcore_symbian_p.h>
#include "qs60maindocument.h"
#include "qs60mainapplication_p.h"
#include "qs60mainapplication.h"
@@ -57,17 +58,17 @@ CApaApplication *newS60Application()
return new QS60MainApplication;
}
-_LIT(KQtWrapperResourceFile, "\\resource\\apps\\s60main.rsc");
+_LIT(KQtWrapperResourceFile, "\\resource\\apps\\s60main" QT_LIBINFIX_UNICODE L".rsc");
/*!
\class QS60MainApplication
\since 4.6
\brief The QS60MainApplication class provides support for migration from S60.
-
+
\warning This class is provided only to get access to S60 specific
functionality in the application framework classes. It is not
portable. We strongly recommend against using it in new applications.
-
+
The QS60MainApplication provides a helper class for use in migrating
from existing S60 based applications to Qt based applications. It is
used in the exact same way as the \c CAknApplication class from
diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp
index 012985b..3b5b9d3 100644
--- a/src/gui/s60framework/qs60mainappui.cpp
+++ b/src/gui/s60framework/qs60mainappui.cpp
@@ -45,7 +45,15 @@
#include <eikmenub.h>
#include <eikmenup.h>
#include <barsread.h>
-#include <s60main.rsg>
+#include <qconfig.h>
+#if defined(QT_LIBINFIX_UNQUOTED)
+// Two level macro needed for proper expansion of libinfix
+# define QT_S60MAIN_RSG_2(x) <s60main##x##.rsg>
+# define QT_S60MAIN_RSG(x) QT_S60MAIN_RSG_2(x)
+# include QT_S60MAIN_RSG(QT_LIBINFIX_UNQUOTED)
+#else
+# include <s60main.rsg>
+#endif
#include <avkon.rsg>
#include "qs60mainappui.h"
diff --git a/src/gui/s60framework/s60framework.pri b/src/gui/s60framework/s60framework.pri
index e177a33..f9d89dc 100644
--- a/src/gui/s60framework/s60framework.pri
+++ b/src/gui/s60framework/s60framework.pri
@@ -4,6 +4,7 @@
minimalAppResource31 = \
"SOURCEPATH s60framework" \
"START RESOURCE s60main.rss" \
+ "TARGET s60main$${QT_LIBINFIX}" \
"HEADER" \
"TARGETPATH /resource/apps" \
"END"
@@ -19,3 +20,5 @@ HEADERS += s60framework/qs60mainapplication_p.h \
s60framework/qs60mainapplication.h \
s60framework/qs60mainappui.h \
s60framework/qs60maindocument.h
+
+!isEmpty(QT_LIBINFIX): DEFINES += QT_LIBINFIX_UNQUOTED=$$QT_LIBINFIX \ No newline at end of file
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index a2ebebb..750e19f 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -2069,11 +2069,11 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
break;
case PE_IndicatorViewItemCheck:
#ifndef QT_NO_ITEMVIEWS
- if (const QListView *listItem = (qobject_cast<const QListView *>(widget))) {
+ if (const QAbstractItemView *itemView = (qobject_cast<const QAbstractItemView *>(widget))) {
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) {
const bool checkBoxVisible = vopt->features & QStyleOptionViewItemV2::HasCheckIndicator;
- const bool singleSelection = listItem->selectionMode() ==
- QAbstractItemView::SingleSelection || listItem->selectionMode() == QAbstractItemView::NoSelection;
+ const bool singleSelection = itemView->selectionMode() ==
+ QAbstractItemView::SingleSelection || itemView->selectionMode() == QAbstractItemView::NoSelection;
// draw either checkbox at the beginning
if (checkBoxVisible && singleSelection) {
drawPrimitive(PE_IndicatorCheckBox, option, painter, widget);
@@ -2475,6 +2475,12 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
{
int retValue = -1;
switch (sh) {
+ case SH_RequestSoftwareInputPanel:
+ if (QS60StylePrivate::isSingleClickUi())
+ retValue = RSIP_OnMouseClick;
+ else
+ retValue = RSIP_OnMouseClickAndAlreadyFocused;
+ break;
case SH_ComboBox_Popup:
retValue = true;
break;
@@ -2531,9 +2537,6 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
case SH_UnderlineShortcut:
retValue = 0;
break;
- case SH_RequestSoftwareInputPanel:
- retValue = RSIP_OnMouseClickAndAlreadyFocused;
- break;
case SH_FormLayoutWrapPolicy:
retValue = QFormLayout::WrapLongRows;
break;
diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp
index ecac3d6..6138e85 100644
--- a/src/gui/styles/qs60style_s60.cpp
+++ b/src/gui/styles/qs60style_s60.cpp
@@ -1121,7 +1121,7 @@ QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list,
&KAknsIIDQsnParentColors,
&KAknsIIDQsnTextColors
};
- Q_ASSERT((int)list <= (int)sizeof(idMap)/sizeof(idMap[0]));
+ Q_ASSERT((int)list < (int)sizeof(idMap)/sizeof(idMap[0]));
const QColor color = QS60StyleModeSpecifics::colorValue(*idMap[(int) list], index - 1);
return option ? QS60StylePrivate::stateColor(color, option) : color;
}
diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp
index 6e77409..5f939d0 100644
--- a/src/gui/styles/qwindowsmobilestyle.cpp
+++ b/src/gui/styles/qwindowsmobilestyle.cpp
@@ -5076,6 +5076,10 @@ void QWindowsMobileStyle::drawPrimitive(PrimitiveElement element, const QStyleOp
color = option->palette.buttonText().color();
QImage image;
int xoffset, yoffset;
+ bool isTabBarArrow = widget && widget->parent()
+ && widget->inherits("QToolButton")
+ && widget->parent()->inherits("QTabBar");
+
switch (element) {
case PE_IndicatorArrowUp:
image = d->imageArrowUp;
@@ -5090,12 +5094,12 @@ void QWindowsMobileStyle::drawPrimitive(PrimitiveElement element, const QStyleOp
case PE_IndicatorArrowLeft:
image = d->imageArrowLeft;
xoffset = 8;
- yoffset = 2;
+ yoffset = isTabBarArrow ? 12 : 2;
break;
case PE_IndicatorArrowRight:
image = d->imageArrowRight;
xoffset = 8;
- yoffset = 2;
+ yoffset = isTabBarArrow ? 12 : 2;
break;
case PE_IndicatorArrowUpBig:
image = d->imageArrowUpBig;
@@ -6949,10 +6953,11 @@ int QWindowsMobileStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, co
case PM_SliderThickness:
ret = d->doubleControls ? windowsMobileSliderThickness * 2: windowsMobileSliderThickness;
break;
- case PM_TabBarScrollButtonWidth:
- ret = d->doubleControls ? 14 * 2 : 18;
- case PM_CheckBoxLabelSpacing:
- case PM_RadioButtonLabelSpacing:
+ case PM_TabBarScrollButtonWidth:
+ ret = d->doubleControls ? 14 * 2 : 18;
+ break;
+ case PM_CheckBoxLabelSpacing:
+ case PM_RadioButtonLabelSpacing:
ret = d->doubleControls ? 6 * 2 : 6;
break;
// Returns the number of pixels to use for the business part of the
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index cc6793d..766053c 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1644,28 +1644,67 @@ namespace {
struct LineBreakHelper
{
- LineBreakHelper() : glyphCount(0), maxGlyphs(0), manualWrap(false) {}
+ LineBreakHelper()
+ : glyphCount(0), maxGlyphs(0), currentPosition(0), fontEngine(0), logClusters(0),
+ manualWrap(false)
+ {
+ }
+
QScriptLine tmpData;
QScriptLine spaceData;
+ QGlyphLayout glyphs;
+
int glyphCount;
int maxGlyphs;
+ int currentPosition;
QFixed minw;
QFixed softHyphenWidth;
QFixed rightBearing;
+ QFixed minimumRightBearing;
+
+ QFontEngine *fontEngine;
+ const unsigned short *logClusters;
bool manualWrap;
bool checkFullOtherwiseExtend(QScriptLine &line);
+
+ QFixed calculateNewWidth(const QScriptLine &line) const {
+ return line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth
+ - qMin(rightBearing, QFixed());
+ }
+
+ inline glyph_t currentGlyph() const
+ {
+ Q_ASSERT(currentPosition > 0);
+ return glyphs.glyphs[logClusters[currentPosition - 1]];
+ }
+
+ inline void adjustRightBearing()
+ {
+ if (currentPosition <= 0)
+ return;
+
+ glyph_metrics_t gi = fontEngine->boundingBox(currentGlyph());
+ if (gi.isValid())
+ rightBearing = qMin(QFixed(), gi.xoff - gi.x - gi.width);
+ }
+
+ inline void resetRightBearing()
+ {
+ rightBearing = QFixed(1); // Any positive number is defined as invalid since only
+ // negative right bearings are interesting to us.
+ }
};
inline bool LineBreakHelper::checkFullOtherwiseExtend(QScriptLine &line)
{
LB_DEBUG("possible break width %f, spacew=%f", tmpData.textWidth.toReal(), spaceData.textWidth.toReal());
- QFixed newWidth = line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth + rightBearing;
+ QFixed newWidth = calculateNewWidth(line);
if (line.length && !manualWrap && (newWidth > line.width || glyphCount > maxGlyphs))
return true;
@@ -1741,13 +1780,12 @@ void QTextLine::layout_helper(int maxGlyphs)
Qt::Alignment alignment = eng->option.alignment();
const HB_CharAttributes *attributes = eng->attributes();
- int pos = line.from;
+ lbh.currentPosition = line.from;
int end = 0;
- QGlyphLayout glyphs;
- const unsigned short *logClusters = eng->layoutData->logClustersPtr;
+ lbh.logClusters = eng->layoutData->logClustersPtr;
while (newItem < eng->layoutData->items.size()) {
- lbh.rightBearing = 0;
+ lbh.resetRightBearing();
lbh.softHyphenWidth = 0;
if (newItem != item) {
item = newItem;
@@ -1755,13 +1793,19 @@ void QTextLine::layout_helper(int maxGlyphs)
if (!current.num_glyphs) {
eng->shape(item);
attributes = eng->attributes();
- logClusters = eng->layoutData->logClustersPtr;
+ lbh.logClusters = eng->layoutData->logClustersPtr;
}
- pos = qMax(line.from, current.position);
+ lbh.currentPosition = qMax(line.from, current.position);
end = current.position + eng->length(item);
- glyphs = eng->shapedGlyphs(&current);
+ lbh.glyphs = eng->shapedGlyphs(&current);
}
const QScriptItem &current = eng->layoutData->items[item];
+ QFontEngine *fontEngine = eng->fontEngine(current);
+ if (lbh.fontEngine != fontEngine) {
+ lbh.fontEngine = fontEngine;
+ lbh.minimumRightBearing = qMin(QFixed(),
+ QFixed::fromReal(fontEngine->minRightBearing()));
+ }
lbh.tmpData.leading = qMax(lbh.tmpData.leading + lbh.tmpData.ascent,
current.leading + current.ascent) - qMax(lbh.tmpData.ascent,
@@ -1791,8 +1835,8 @@ void QTextLine::layout_helper(int maxGlyphs)
if (!line.length && !lbh.tmpData.length)
line.setDefaultHeight(eng);
if (eng->option.flags() & QTextOption::ShowLineAndParagraphSeparators) {
- addNextCluster(pos, end, lbh.tmpData, lbh.glyphCount,
- current, logClusters, glyphs);
+ addNextCluster(lbh.currentPosition, end, lbh.tmpData, lbh.glyphCount,
+ current, lbh.logClusters, lbh.glyphs);
} else {
lbh.tmpData.length++;
}
@@ -1811,10 +1855,10 @@ void QTextLine::layout_helper(int maxGlyphs)
++lbh.glyphCount;
if (lbh.checkFullOtherwiseExtend(line))
goto found;
- } else if (attributes[pos].whiteSpace) {
- while (pos < end && attributes[pos].whiteSpace)
- addNextCluster(pos, end, lbh.spaceData, lbh.glyphCount,
- current, logClusters, glyphs);
+ } else if (attributes[lbh.currentPosition].whiteSpace) {
+ while (lbh.currentPosition < end && attributes[lbh.currentPosition].whiteSpace)
+ addNextCluster(lbh.currentPosition, end, lbh.spaceData, lbh.glyphCount,
+ current, lbh.logClusters, lbh.glyphs);
if (!lbh.manualWrap && lbh.spaceData.textWidth > line.width) {
lbh.spaceData.textWidth = line.width; // ignore spaces that fall out of the line.
@@ -1823,19 +1867,19 @@ void QTextLine::layout_helper(int maxGlyphs)
} else {
bool sb_or_ws = false;
do {
- addNextCluster(pos, end, lbh.tmpData, lbh.glyphCount,
- current, logClusters, glyphs);
+ addNextCluster(lbh.currentPosition, end, lbh.tmpData, lbh.glyphCount,
+ current, lbh.logClusters, lbh.glyphs);
- if (attributes[pos].whiteSpace || attributes[pos-1].lineBreakType != HB_NoBreak) {
+ if (attributes[lbh.currentPosition].whiteSpace || attributes[lbh.currentPosition-1].lineBreakType != HB_NoBreak) {
sb_or_ws = true;
break;
- } else if (breakany && attributes[pos].charStop) {
+ } else if (breakany && attributes[lbh.currentPosition].charStop) {
break;
}
- } while (pos < end);
+ } while (lbh.currentPosition < end);
lbh.minw = qMax(lbh.tmpData.textWidth, lbh.minw);
- if (pos && attributes[pos - 1].lineBreakType == HB_SoftHyphen) {
+ if (lbh.currentPosition && attributes[lbh.currentPosition - 1].lineBreakType == HB_SoftHyphen) {
// if we are splitting up a word because of
// a soft hyphen then we ...
//
@@ -1853,43 +1897,40 @@ void QTextLine::layout_helper(int maxGlyphs)
// and thus become invisible again.
//
if (line.length)
- lbh.softHyphenWidth = glyphs.advances_x[logClusters[pos - 1]];
+ lbh.softHyphenWidth = lbh.glyphs.advances_x[lbh.logClusters[lbh.currentPosition - 1]];
else if (breakany)
- lbh.tmpData.textWidth += glyphs.advances_x[logClusters[pos - 1]];
+ lbh.tmpData.textWidth += lbh.glyphs.advances_x[lbh.logClusters[lbh.currentPosition - 1]];
}
// The actual width of the text needs to take the right bearing into account. The
// right bearing is left-ward, which means that if the rightmost pixel is to the right
// of the advance of the glyph, the bearing will be negative. We flip the sign
// for the code to be more readable. Logic borrowed from qfontmetrics.cpp.
- if (pos) {
- QFontEngine *fontEngine = eng->fontEngine(current);
- glyph_t glyph = glyphs.glyphs[logClusters[pos - 1]];
- glyph_metrics_t gi = fontEngine->boundingBox(glyph);
- if (gi.isValid())
- lbh.rightBearing = qMax(QFixed(), -(gi.xoff - gi.x - gi.width));
- }
+ // We ignore the right bearing if the minimum negative bearing is too little to
+ // expand the text beyond the edge.
+ if (sb_or_ws|breakany) {
+ if (lbh.calculateNewWidth(line) + lbh.minimumRightBearing > line.width)
+ lbh.adjustRightBearing();
+ if (lbh.checkFullOtherwiseExtend(line)) {
+ if (!breakany) {
+ line.textWidth += lbh.softHyphenWidth;
+ }
- if ((sb_or_ws|breakany) && lbh.checkFullOtherwiseExtend(line)) {
- if (!breakany) {
- line.textWidth += lbh.softHyphenWidth;
+ goto found;
}
-
- line.textAdvance = line.textWidth;
- line.textWidth += lbh.rightBearing;
-
- goto found;
}
}
- if (pos == end)
+ if (lbh.currentPosition == end)
newItem = item + 1;
}
LB_DEBUG("reached end of line");
lbh.checkFullOtherwiseExtend(line);
+found:
+ if (lbh.rightBearing > 0) // If right bearing has not yet been adjusted
+ lbh.adjustRightBearing();
line.textAdvance = line.textWidth;
- line.textWidth += lbh.rightBearing;
+ line.textWidth -= qMin(QFixed(), lbh.rightBearing);
-found:
if (line.length == 0) {
LB_DEBUG("no break available in line, adding temp: length %d, width %f, space: length %d, width %f",
lbh.tmpData.length, lbh.tmpData.textWidth.toReal(),