50 if (numEnabled <= 1) {
51 return QRect(0, 0, outputSize.width(), outputSize.height());
54 const int w = outputSize.width();
55 const int h = outputSize.height();
58 if (numEnabled == 2) {
59 const int leftW = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
61 std::max(m_minPanePx, w - m_minPanePx));
62 const int rightW = std::max(1, w - leftW);
63 return (slot == 0) ? QRect(0, 0, leftW, h)
64 : QRect(leftW, 0, rightW, h);
68 if (numEnabled == 3) {
69 const int topH = std::clamp(
static_cast<int>(std::lround(h * m_splitY)),
71 std::max(m_minPanePx, h - m_minPanePx));
72 const int bottomH = std::max(1, h - topH);
74 return QRect(0, 0, w, topH);
76 const int leftW = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
78 std::max(m_minPanePx, w - m_minPanePx));
79 const int rightW = std::max(1, w - leftW);
80 return (slot == 1) ? QRect(0, topH, leftW, bottomH)
81 : QRect(leftW, topH, rightW, bottomH);
85 const int leftW = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
87 std::max(m_minPanePx, w - m_minPanePx));
88 const int rightW = std::max(1, w - leftW);
89 const int topH = std::clamp(
static_cast<int>(std::lround(h * m_splitY)),
91 std::max(m_minPanePx, h - m_minPanePx));
92 const int bottomH = std::max(1, h - topH);
94 const int col = slot % 2;
95 const int row = slot / 2;
96 return QRect((col == 0) ? 0 : leftW,
97 (row == 0) ? 0 : topH,
98 (col == 0) ? leftW : rightW,
99 (row == 0) ? topH : bottomH);
106 const QSize &outputSize)
const
108 if (numEnabled <= 1) {
112 const int w = outputSize.width();
113 const int h = outputSize.height();
116 if (numEnabled == 2) {
117 const int splitX = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
119 std::max(m_minPanePx, w - m_minPanePx));
120 return (std::abs(pos.x() -
splitX) <= m_hitTolerancePx)
126 const int splitX = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
128 std::max(m_minPanePx, w - m_minPanePx));
129 const int splitY = std::clamp(
static_cast<int>(std::lround(h * m_splitY)),
131 std::max(m_minPanePx, h - m_minPanePx));
133 const bool nearHorizontal = (std::abs(pos.y() -
splitY) <= m_hitTolerancePx);
136 const bool inBottomHalf = (pos.y() >
splitY);
137 const bool nearVertical = (std::abs(pos.x() -
splitX) <= m_hitTolerancePx);
138 const bool verticalActive = nearVertical && (numEnabled != 3 || inBottomHalf);
178 int numEnabled)
const
180 if (numEnabled <= 1) {
186 if (numEnabled == 2) {
188 r.setWidth(std::max(1, r.width() - m_separatorLinePx));
192 if (numEnabled == 3) {
194 r.setHeight(std::max(1, r.height() - m_separatorLinePx));
195 }
else if (slot == 1) {
196 r.setWidth(std::max(1, r.width() - m_separatorLinePx));
202 const int col = slot % 2;
203 const int row = slot / 2;
204 const bool hasRightNeighbor = (col == 0) && (slot + 1 < numEnabled)
205 && ((slot / 2) == ((slot + 1) / 2));
206 const bool hasBottomNeighbor = (row == 0) && (slot + 2 < numEnabled);
208 if (hasRightNeighbor)
209 r.setWidth(std::max(1, r.width() - m_separatorLinePx));
210 if (hasBottomNeighbor)
211 r.setHeight(std::max(1, r.height() - m_separatorLinePx));
219 const QSize &widgetSize,
221 QRect &horizontalRect)
const
223 verticalRect = QRect();
224 horizontalRect = QRect();
226 if (numEnabled <= 1)
return;
228 const int w = std::max(1, widgetSize.width());
229 const int h = std::max(1, widgetSize.height());
231 const int splitX = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
233 std::max(m_minPanePx, w - m_minPanePx));
235 if (numEnabled >= 3) {
236 const int splitY = std::clamp(
static_cast<int>(std::lround(h * m_splitY)),
238 std::max(m_minPanePx, h - m_minPanePx));
240 horizontalRect = QRect(0,
241 splitY - m_separatorLinePx / 2,
245 if (numEnabled == 3) {
247 verticalRect = QRect(
splitX - m_separatorLinePx / 2,
253 verticalRect = QRect(
splitX - m_separatorLinePx / 2,
260 verticalRect = QRect(
splitX - m_separatorLinePx / 2,
271 const QSize &widgetSize)
273 const int w = std::max(1, widgetSize.width());
274 const int h = std::max(1, widgetSize.height());
277 const int clampedX = std::clamp(pos.x(), m_minPanePx, std::max(m_minPanePx, w - m_minPanePx));
278 m_splitX = clampSplit(
static_cast<float>(clampedX) /
static_cast<float>(w));
282 const int clampedY = std::clamp(pos.y(), m_minPanePx, std::max(m_minPanePx, h - m_minPanePx));
283 m_splitY = clampSplit(
static_cast<float>(clampedY) /
static_cast<float>(h));