Kaydet (Commit) 7760d306 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski Kaydeden (comit) Katarina Behrens

Qt5 convert broken clipping

localClipRegion was just set but never used, when KDE4 xlib
blitting was replaced by Cairo / QPainter blitting. So this
converts all the occurences to apply these clippings to the
drawing QPainter instance.

Change-Id: Ibfd60049ce604ac1415dc5c602ed5c952f972891
Reviewed-on: https://gerrit.libreoffice.org/70006
Tested-by: Jenkins
Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst 5e67b383
...@@ -146,13 +146,22 @@ void draw(QStyle::ComplexControl element, QStyleOptionComplex* option, QImage* i ...@@ -146,13 +146,22 @@ void draw(QStyle::ComplexControl element, QStyleOptionComplex* option, QImage* i
} }
void lcl_drawFrame(QStyle::PrimitiveElement element, QImage* image, QStyle::State const& state, void lcl_drawFrame(QStyle::PrimitiveElement element, QImage* image, QStyle::State const& state,
bool bClip = true,
QStyle::PixelMetric eLineMetric = QStyle::PM_DefaultFrameWidth) QStyle::PixelMetric eLineMetric = QStyle::PM_DefaultFrameWidth)
{ {
const int fw = QApplication::style()->pixelMetric(eLineMetric);
QStyleOptionFrame option; QStyleOptionFrame option;
option.frameShape = QFrame::StyledPanel; option.frameShape = QFrame::StyledPanel;
option.state = QStyle::State_Sunken; option.state = QStyle::State_Sunken | state;
option.lineWidth = QApplication::style()->pixelMetric(eLineMetric); option.lineWidth = fw;
draw(element, &option, image, state);
QRect aRect(image->rect());
option.rect = aRect;
QPainter painter(image);
if (bClip)
painter.setClipRegion(QRegion(aRect).subtracted(aRect.adjusted(fw, fw, -fw, -fw)));
QApplication::style()->drawPrimitive(element, &option, &painter);
} }
} }
...@@ -215,8 +224,6 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part, ...@@ -215,8 +224,6 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
break; break;
} }
QRegion* localClipRegion = nullptr;
if (type == ControlType::Pushbutton) if (type == ControlType::Pushbutton)
{ {
if (part == ControlPart::Entire) if (part == ControlPart::Entire)
...@@ -296,12 +303,14 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part, ...@@ -296,12 +303,14 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
QPoint center = rect.center(); QPoint center = rect.center();
rect.setHeight(size.height()); rect.setHeight(size.height());
rect.moveCenter(center); rect.moveCenter(center);
option.state |= vclStateValue2StateFlag(nControlState, value);
option.rect = rect;
QPainter painter(m_image.get());
// don't paint over popup frame border (like the hack above, but here it can be simpler) // don't paint over popup frame border (like the hack above, but here it can be simpler)
int fw = QApplication::style()->pixelMetric(QStyle::PM_MenuPanelWidth); const int fw = QApplication::style()->pixelMetric(QStyle::PM_MenuPanelWidth);
localClipRegion painter.setClipRect(rect.adjusted(fw, 0, -fw, 0));
= new QRegion(rect.translated(widgetRect.topLeft()).adjusted(fw, 0, -fw, 0)); QApplication::style()->drawControl(QStyle::CE_MenuItem, &option, &painter);
draw(QStyle::CE_MenuItem, &option, m_image.get(),
vclStateValue2StateFlag(nControlState, value), rect);
} }
else if (part == ControlPart::MenuItemCheckMark || part == ControlPart::MenuItemRadioMark) else if (part == ControlPart::MenuItemCheckMark || part == ControlPart::MenuItemRadioMark)
{ {
...@@ -368,30 +377,27 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part, ...@@ -368,30 +377,27 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
&& (part == ControlPart::ThumbVert || part == ControlPart::ThumbHorz)) && (part == ControlPart::ThumbVert || part == ControlPart::ThumbHorz))
{ // reduce paint area only to the handle area { // reduce paint area only to the handle area
const int handleExtend = QApplication::style()->pixelMetric(QStyle::PM_ToolBarHandleExtent); const int handleExtend = QApplication::style()->pixelMetric(QStyle::PM_ToolBarHandleExtent);
QRect rect;
QStyleOption option; QStyleOption option;
option.state = vclStateValue2StateFlag(nControlState, value);
QPainter painter(m_image.get());
if (part == ControlPart::ThumbVert) if (part == ControlPart::ThumbVert)
{ {
rect = QRect(0, 0, handleExtend, widgetRect.height()); option.rect = QRect(0, 0, handleExtend, widgetRect.height());
localClipRegion painter.setClipRect(widgetRect.x(), widgetRect.y(), handleExtend, widgetRect.height());
= new QRegion(widgetRect.x(), widgetRect.y(), handleExtend, widgetRect.height()); option.state |= QStyle::State_Horizontal;
option.state = QStyle::State_Horizontal;
} }
else else
{ {
rect = QRect(0, 0, widgetRect.width(), handleExtend); option.rect = QRect(0, 0, widgetRect.width(), handleExtend);
localClipRegion painter.setClipRect(widgetRect.x(), widgetRect.y(), widgetRect.width(), handleExtend);
= new QRegion(widgetRect.x(), widgetRect.y(), widgetRect.width(), handleExtend);
} }
QApplication::style()->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &option, &painter);
draw(QStyle::PE_IndicatorToolBarHandle, &option, m_image.get(),
vclStateValue2StateFlag(nControlState, value), rect);
} }
else if (type == ControlType::Editbox || type == ControlType::MultilineEditbox) else if (type == ControlType::Editbox || type == ControlType::MultilineEditbox)
{ {
lcl_drawFrame(QStyle::PE_FrameLineEdit, m_image.get(), lcl_drawFrame(QStyle::PE_FrameLineEdit, m_image.get(),
vclStateValue2StateFlag(nControlState, value)); vclStateValue2StateFlag(nControlState, value), false);
} }
else if (type == ControlType::Combobox) else if (type == ControlType::Combobox)
{ {
...@@ -408,7 +414,7 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part, ...@@ -408,7 +414,7 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
{ {
case ControlPart::ListboxWindow: case ControlPart::ListboxWindow:
lcl_drawFrame(QStyle::PE_Frame, m_image.get(), lcl_drawFrame(QStyle::PE_Frame, m_image.get(),
vclStateValue2StateFlag(nControlState, value), vclStateValue2StateFlag(nControlState, value), true,
QStyle::PM_ComboBoxFrameWidth); QStyle::PM_ComboBoxFrameWidth);
break; break;
case ControlPart::SubEdit: case ControlPart::SubEdit:
...@@ -555,10 +561,6 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part, ...@@ -555,10 +561,6 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
{ {
lcl_drawFrame(QStyle::PE_Frame, m_image.get(), lcl_drawFrame(QStyle::PE_Frame, m_image.get(),
vclStateValue2StateFlag(nControlState, value)); vclStateValue2StateFlag(nControlState, value));
// draw just the border, see http://qa.openoffice.org/issues/show_bug.cgi?id=107945
int fw = QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
localClipRegion
= new QRegion(QRegion(widgetRect).subtracted(widgetRect.adjusted(fw, fw, -fw, -fw)));
} }
else if (type == ControlType::WindowBackground) else if (type == ControlType::WindowBackground)
{ {
...@@ -612,7 +614,6 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part, ...@@ -612,7 +614,6 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
returnVal = false; returnVal = false;
} }
delete localClipRegion;
return returnVal; return returnVal;
} }
...@@ -916,15 +917,8 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart ...@@ -916,15 +917,8 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
} }
if (retVal) if (retVal)
{ {
// Bounding region nativeBoundingRegion = toRectangle(boundingRect);
Point aBPoint(boundingRect.x(), boundingRect.y()); nativeContentRegion = toRectangle(contentRect);
Size aBSize(boundingRect.width(), boundingRect.height());
nativeBoundingRegion = tools::Rectangle(aBPoint, aBSize);
// vcl::Region of the content
Point aPoint(contentRect.x(), contentRect.y());
Size aSize(contentRect.width(), contentRect.height());
nativeContentRegion = tools::Rectangle(aPoint, aSize);
} }
return retVal; return retVal;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment