107 const QMarginsF shadowMargins(
108 std::max({topLeft.width(), left.width(), bottomLeft.width()}),
109 std::max({topLeft.height(), top.height(), topRight.height()}),
110 std::max({topRight.width(), right.width(), bottomRight.width()}),
111 std::max({bottomRight.height(), bottom.height(), bottomLeft.height()}));
113 const QRectF outerRect =
rect();
115 const int width = shadowMargins.left() + std::max(top.width(), bottom.width()) + shadowMargins.right();
116 const int height = shadowMargins.top() + std::max(left.height(), right.height()) + shadowMargins.bottom();
119 if (!topLeft.isEmpty()) {
120 topLeftRect = QRectF(outerRect.topLeft(), topLeft);
122 topLeftRect = QRectF(outerRect.left() + shadowMargins.left(),
123 outerRect.top() + shadowMargins.top(), 0, 0);
127 if (!topRight.isEmpty()) {
128 topRightRect = QRectF(outerRect.right() - topRight.width(), outerRect.top(),
129 topRight.width(), topRight.height());
131 topRightRect = QRectF(outerRect.right() - shadowMargins.right(),
132 outerRect.top() + shadowMargins.top(), 0, 0);
135 QRectF bottomRightRect;
136 if (!bottomRight.isEmpty()) {
137 bottomRightRect = QRectF(outerRect.right() - bottomRight.width(),
138 outerRect.bottom() - bottomRight.height(),
139 bottomRight.width(), bottomRight.height());
141 bottomRightRect = QRectF(outerRect.right() - shadowMargins.right(),
142 outerRect.bottom() - shadowMargins.bottom(), 0, 0);
145 QRectF bottomLeftRect;
146 if (!bottomLeft.isEmpty()) {
147 bottomLeftRect = QRectF(outerRect.left(), outerRect.bottom() - bottomLeft.height(),
148 bottomLeft.width(), bottomLeft.height());
150 bottomLeftRect = QRectF(outerRect.left() + shadowMargins.left(),
151 outerRect.bottom() - shadowMargins.bottom(), 0, 0);
161 distributeHorizontally(topLeftRect, topRightRect);
162 distributeHorizontally(bottomLeftRect, bottomRightRect);
163 distributeVertically(topLeftRect, bottomLeftRect);
164 distributeVertically(topRightRect, bottomRightRect);
174 if (topLeftRect.isValid()) {
177 tx2 = topLeftRect.width();
178 ty2 = topLeftRect.height();
180 topLeftQuad[0] =
WindowVertex(topLeftRect.left(), topLeftRect.top(), tx1, ty1);
181 topLeftQuad[1] =
WindowVertex(topLeftRect.right(), topLeftRect.top(), tx2, ty1);
182 topLeftQuad[2] =
WindowVertex(topLeftRect.right(), topLeftRect.bottom(), tx2, ty2);
183 topLeftQuad[3] =
WindowVertex(topLeftRect.left(), topLeftRect.bottom(), tx1, ty2);
184 quads.append(topLeftQuad);
187 if (topRightRect.isValid()) {
188 tx1 = width - topRightRect.width();
191 ty2 = topRightRect.height();
193 topRightQuad[0] =
WindowVertex(topRightRect.left(), topRightRect.top(), tx1, ty1);
194 topRightQuad[1] =
WindowVertex(topRightRect.right(), topRightRect.top(), tx2, ty1);
195 topRightQuad[2] =
WindowVertex(topRightRect.right(), topRightRect.bottom(), tx2, ty2);
196 topRightQuad[3] =
WindowVertex(topRightRect.left(), topRightRect.bottom(), tx1, ty2);
197 quads.append(topRightQuad);
200 if (bottomRightRect.isValid()) {
201 tx1 = width - bottomRightRect.width();
203 ty1 = height - bottomRightRect.height();
206 bottomRightQuad[0] =
WindowVertex(bottomRightRect.left(), bottomRightRect.top(), tx1, ty1);
207 bottomRightQuad[1] =
WindowVertex(bottomRightRect.right(), bottomRightRect.top(), tx2, ty1);
208 bottomRightQuad[2] =
WindowVertex(bottomRightRect.right(), bottomRightRect.bottom(), tx2, ty2);
209 bottomRightQuad[3] =
WindowVertex(bottomRightRect.left(), bottomRightRect.bottom(), tx1, ty2);
210 quads.append(bottomRightQuad);
213 if (bottomLeftRect.isValid()) {
215 tx2 = bottomLeftRect.width();
216 ty1 = height - bottomLeftRect.height();
219 bottomLeftQuad[0] =
WindowVertex(bottomLeftRect.left(), bottomLeftRect.top(), tx1, ty1);
220 bottomLeftQuad[1] =
WindowVertex(bottomLeftRect.right(), bottomLeftRect.top(), tx2, ty1);
221 bottomLeftQuad[2] =
WindowVertex(bottomLeftRect.right(), bottomLeftRect.bottom(), tx2, ty2);
222 bottomLeftQuad[3] =
WindowVertex(bottomLeftRect.left(), bottomLeftRect.bottom(), tx1, ty2);
223 quads.append(bottomLeftQuad);
226 QRectF topRect(QPointF(topLeftRect.right(), outerRect.top()),
227 QPointF(topRightRect.left(), outerRect.top() + top.height()));
229 QRectF rightRect(QPointF(outerRect.right() - right.width(), topRightRect.bottom()),
230 QPointF(outerRect.right(), bottomRightRect.top()));
232 QRectF bottomRect(QPointF(bottomLeftRect.right(), outerRect.bottom() - bottom.height()),
233 QPointF(bottomRightRect.left(), outerRect.bottom()));
235 QRectF leftRect(QPointF(outerRect.left(), topLeftRect.bottom()),
236 QPointF(outerRect.left() + left.width(), bottomLeftRect.top()));
243 distributeHorizontally(leftRect, rightRect);
244 distributeVertically(topRect, bottomRect);
246 if (topRect.isValid()) {
247 tx1 = shadowMargins.left();
249 tx2 = tx1 + top.width();
250 ty2 = topRect.height();
252 topQuad[0] =
WindowVertex(topRect.left(), topRect.top(), tx1, ty1);
253 topQuad[1] =
WindowVertex(topRect.right(), topRect.top(), tx2, ty1);
254 topQuad[2] =
WindowVertex(topRect.right(), topRect.bottom(), tx2, ty2);
255 topQuad[3] =
WindowVertex(topRect.left(), topRect.bottom(), tx1, ty2);
256 quads.append(topQuad);
259 if (rightRect.isValid()) {
260 tx1 = width - rightRect.width();
261 ty1 = shadowMargins.top();
263 ty2 = ty1 + right.height();
265 rightQuad[0] =
WindowVertex(rightRect.left(), rightRect.top(), tx1, ty1);
266 rightQuad[1] =
WindowVertex(rightRect.right(), rightRect.top(), tx2, ty1);
267 rightQuad[2] =
WindowVertex(rightRect.right(), rightRect.bottom(), tx2, ty2);
268 rightQuad[3] =
WindowVertex(rightRect.left(), rightRect.bottom(), tx1, ty2);
269 quads.append(rightQuad);
272 if (bottomRect.isValid()) {
273 tx1 = shadowMargins.left();
274 ty1 = height - bottomRect.height();
275 tx2 = tx1 + bottom.width();
278 bottomQuad[0] =
WindowVertex(bottomRect.left(), bottomRect.top(), tx1, ty1);
279 bottomQuad[1] =
WindowVertex(bottomRect.right(), bottomRect.top(), tx2, ty1);
280 bottomQuad[2] =
WindowVertex(bottomRect.right(), bottomRect.bottom(), tx2, ty2);
281 bottomQuad[3] =
WindowVertex(bottomRect.left(), bottomRect.bottom(), tx1, ty2);
282 quads.append(bottomQuad);
285 if (leftRect.isValid()) {
287 ty1 = shadowMargins.top();
288 tx2 = leftRect.width();
289 ty2 = ty1 + left.height();
291 leftQuad[0] =
WindowVertex(leftRect.left(), leftRect.top(), tx1, ty1);
292 leftQuad[1] =
WindowVertex(leftRect.right(), leftRect.top(), tx2, ty1);
293 leftQuad[2] =
WindowVertex(leftRect.right(), leftRect.bottom(), tx2, ty2);
294 leftQuad[3] =
WindowVertex(leftRect.left(), leftRect.bottom(), tx1, ty2);
295 quads.append(leftQuad);