31 if (numEnabled <= 1) {
32 return QRect(0, 0, outputSize.width(), outputSize.height());
35 const int w = outputSize.width();
36 const int h = outputSize.height();
39 if (numEnabled == 2) {
40 const int leftW = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
42 std::max(m_minPanePx, w - m_minPanePx));
43 const int rightW = std::max(1, w - leftW);
44 return (slot == 0) ? QRect(0, 0, leftW, h)
45 : QRect(leftW, 0, rightW, h);
49 if (numEnabled == 3) {
50 const int topH = std::clamp(
static_cast<int>(std::lround(h * m_splitY)),
52 std::max(m_minPanePx, h - m_minPanePx));
53 const int bottomH = std::max(1, h - topH);
55 return QRect(0, 0, w, topH);
57 const int leftW = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
59 std::max(m_minPanePx, w - m_minPanePx));
60 const int rightW = std::max(1, w - leftW);
61 return (slot == 1) ? QRect(0, topH, leftW, bottomH)
62 : QRect(leftW, topH, rightW, bottomH);
66 const int leftW = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
68 std::max(m_minPanePx, w - m_minPanePx));
69 const int rightW = std::max(1, w - leftW);
70 const int topH = std::clamp(
static_cast<int>(std::lround(h * m_splitY)),
72 std::max(m_minPanePx, h - m_minPanePx));
73 const int bottomH = std::max(1, h - topH);
75 const int col = slot % 2;
76 const int row = slot / 2;
77 return QRect((col == 0) ? 0 : leftW,
78 (row == 0) ? 0 : topH,
79 (col == 0) ? leftW : rightW,
80 (row == 0) ? topH : bottomH);
87 const QSize& outputSize)
const
89 if (numEnabled <= 1) {
93 const int w = outputSize.width();
94 const int h = outputSize.height();
97 if (numEnabled == 2) {
98 const int splitX = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
100 std::max(m_minPanePx, w - m_minPanePx));
101 return (std::abs(pos.x() -
splitX) <= m_hitTolerancePx)
107 const int splitX = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
109 std::max(m_minPanePx, w - m_minPanePx));
110 const int splitY = std::clamp(
static_cast<int>(std::lround(h * m_splitY)),
112 std::max(m_minPanePx, h - m_minPanePx));
114 const bool nearHorizontal = (std::abs(pos.y() -
splitY) <= m_hitTolerancePx);
117 const bool inBottomHalf = (pos.y() >
splitY);
118 const bool nearVertical = (std::abs(pos.x() -
splitX) <= m_hitTolerancePx);
119 const bool verticalActive = nearVertical && (numEnabled != 3 || inBottomHalf);
121 if (verticalActive && nearHorizontal)
166 int numEnabled)
const
168 if (numEnabled <= 1) {
174 if (numEnabled == 2) {
176 r.setWidth(std::max(1, r.width() - m_separatorLinePx));
180 if (numEnabled == 3) {
182 r.setHeight(std::max(1, r.height() - m_separatorLinePx));
183 }
else if (slot == 1) {
184 r.setWidth(std::max(1, r.width() - m_separatorLinePx));
190 const int col = slot % 2;
191 const int row = slot / 2;
192 const bool hasRightNeighbor = (col == 0) && (slot + 1 < numEnabled) && ((slot / 2) == ((slot + 1) / 2));
193 const bool hasBottomNeighbor = (row == 0) && (slot + 2 < numEnabled);
195 if (hasRightNeighbor)
196 r.setWidth(std::max(1, r.width() - m_separatorLinePx));
197 if (hasBottomNeighbor)
198 r.setHeight(std::max(1, r.height() - m_separatorLinePx));
206 const QSize& widgetSize,
208 QRect& horizontalRect)
const
210 verticalRect = QRect();
211 horizontalRect = QRect();
216 const int w = std::max(1, widgetSize.width());
217 const int h = std::max(1, widgetSize.height());
219 const int splitX = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
221 std::max(m_minPanePx, w - m_minPanePx));
223 if (numEnabled >= 3) {
224 const int splitY = std::clamp(
static_cast<int>(std::lround(h * m_splitY)),
226 std::max(m_minPanePx, h - m_minPanePx));
228 horizontalRect = QRect(0,
229 splitY - m_separatorLinePx / 2,
233 if (numEnabled == 3) {
235 verticalRect = QRect(
splitX - m_separatorLinePx / 2,
241 verticalRect = QRect(
splitX - m_separatorLinePx / 2,
248 verticalRect = QRect(
splitX - m_separatorLinePx / 2,
259 const QSize& widgetSize)
261 const int w = std::max(1, widgetSize.width());
262 const int h = std::max(1, widgetSize.height());
265 const int clampedX = std::clamp(pos.x(), m_minPanePx, std::max(m_minPanePx, w - m_minPanePx));
266 m_splitX = clampSplit(
static_cast<float>(clampedX) /
static_cast<float>(w));
270 const int clampedY = std::clamp(pos.y(), m_minPanePx, std::max(m_minPanePx, h - m_minPanePx));
271 m_splitY = clampSplit(
static_cast<float>(clampedY) /
static_cast<float>(h));