28 if (numEnabled <= 1) {
29 return QRect(0, 0, outputSize.width(), outputSize.height());
32 const int w = outputSize.width();
33 const int h = outputSize.height();
36 if (numEnabled == 2) {
37 const int leftW = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
39 std::max(m_minPanePx, w - m_minPanePx));
40 const int rightW = std::max(1, w - leftW);
41 return (slot == 0) ? QRect(0, 0, leftW, h)
42 : QRect(leftW, 0, rightW, h);
46 if (numEnabled == 3) {
47 const int topH = std::clamp(
static_cast<int>(std::lround(h * m_splitY)),
49 std::max(m_minPanePx, h - m_minPanePx));
50 const int bottomH = std::max(1, h - topH);
52 return QRect(0, 0, w, topH);
54 const int leftW = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
56 std::max(m_minPanePx, w - m_minPanePx));
57 const int rightW = std::max(1, w - leftW);
58 return (slot == 1) ? QRect(0, topH, leftW, bottomH)
59 : QRect(leftW, topH, rightW, bottomH);
63 const int leftW = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
65 std::max(m_minPanePx, w - m_minPanePx));
66 const int rightW = std::max(1, w - leftW);
67 const int topH = std::clamp(
static_cast<int>(std::lround(h * m_splitY)),
69 std::max(m_minPanePx, h - m_minPanePx));
70 const int bottomH = std::max(1, h - topH);
72 const int col = slot % 2;
73 const int row = slot / 2;
74 return QRect((col == 0) ? 0 : leftW,
75 (row == 0) ? 0 : topH,
76 (col == 0) ? leftW : rightW,
77 (row == 0) ? topH : bottomH);
84 const QSize &outputSize)
const
86 if (numEnabled <= 1) {
90 const int w = outputSize.width();
91 const int h = outputSize.height();
94 if (numEnabled == 2) {
95 const int splitX = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
97 std::max(m_minPanePx, w - m_minPanePx));
98 return (std::abs(pos.x() -
splitX) <= m_hitTolerancePx)
104 const int splitX = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
106 std::max(m_minPanePx, w - m_minPanePx));
107 const int splitY = std::clamp(
static_cast<int>(std::lround(h * m_splitY)),
109 std::max(m_minPanePx, h - m_minPanePx));
111 const bool nearHorizontal = (std::abs(pos.y() -
splitY) <= m_hitTolerancePx);
114 const bool inBottomHalf = (pos.y() >
splitY);
115 const bool nearVertical = (std::abs(pos.x() -
splitX) <= m_hitTolerancePx);
116 const bool verticalActive = nearVertical && (numEnabled != 3 || inBottomHalf);
156 int numEnabled)
const
158 if (numEnabled <= 1) {
164 if (numEnabled == 2) {
166 r.setWidth(std::max(1, r.width() - m_separatorLinePx));
170 if (numEnabled == 3) {
172 r.setHeight(std::max(1, r.height() - m_separatorLinePx));
173 }
else if (slot == 1) {
174 r.setWidth(std::max(1, r.width() - m_separatorLinePx));
180 const int col = slot % 2;
181 const int row = slot / 2;
182 const bool hasRightNeighbor = (col == 0) && (slot + 1 < numEnabled)
183 && ((slot / 2) == ((slot + 1) / 2));
184 const bool hasBottomNeighbor = (row == 0) && (slot + 2 < numEnabled);
186 if (hasRightNeighbor)
187 r.setWidth(std::max(1, r.width() - m_separatorLinePx));
188 if (hasBottomNeighbor)
189 r.setHeight(std::max(1, r.height() - m_separatorLinePx));
197 const QSize &widgetSize,
199 QRect &horizontalRect)
const
201 verticalRect = QRect();
202 horizontalRect = QRect();
204 if (numEnabled <= 1)
return;
206 const int w = std::max(1, widgetSize.width());
207 const int h = std::max(1, widgetSize.height());
209 const int splitX = std::clamp(
static_cast<int>(std::lround(w * m_splitX)),
211 std::max(m_minPanePx, w - m_minPanePx));
213 if (numEnabled >= 3) {
214 const int splitY = std::clamp(
static_cast<int>(std::lround(h * m_splitY)),
216 std::max(m_minPanePx, h - m_minPanePx));
218 horizontalRect = QRect(0,
219 splitY - m_separatorLinePx / 2,
223 if (numEnabled == 3) {
225 verticalRect = QRect(
splitX - m_separatorLinePx / 2,
231 verticalRect = QRect(
splitX - m_separatorLinePx / 2,
238 verticalRect = QRect(
splitX - m_separatorLinePx / 2,
249 const QSize &widgetSize)
251 const int w = std::max(1, widgetSize.width());
252 const int h = std::max(1, widgetSize.height());
255 const int clampedX = std::clamp(pos.x(), m_minPanePx, std::max(m_minPanePx, w - m_minPanePx));
256 m_splitX = clampSplit(
static_cast<float>(clampedX) /
static_cast<float>(w));
260 const int clampedY = std::clamp(pos.y(), m_minPanePx, std::max(m_minPanePx, h - m_minPanePx));
261 m_splitY = clampSplit(
static_cast<float>(clampedY) /
static_cast<float>(h));