| |
| |
|
|
| #include "toonzqt/menubarcommand.h" |
| #include "docklayout.h" |
| |
| |
| #include <QEvent> |
| #include <QMouseEvent> |
| #include <QApplication> |
| #include <QDesktopWidget> |
| |
| |
| #include <assert.h> |
| #include <math.h> |
| #include <algorithm> |
| |
| |
| |
| |
| |
| |
| |
| DockingCheck *DockingCheck::instance() { |
| static DockingCheck _instance; |
| return &_instance; |
| } |
| |
| |
| |
| void DockingCheck::setToggle(QAction *toggle) { m_toggle = toggle; } |
| |
| |
| |
| void DockingCheck::setIsEnabled(bool on) { |
| m_enabled = on; |
| if (m_toggle) m_toggle->setChecked(on); |
| } |
| |
| |
| |
| class DockingToggleCommand final : public MenuItemHandler { |
| public: |
| DockingToggleCommand() : MenuItemHandler("MI_DockingCheck") {} |
| |
| void execute() override { |
| DockingCheck *dc = DockingCheck::instance(); |
| dc->setIsEnabled(!dc->isEnabled()); |
| } |
| |
| } dockingToggleCommand; |
| |
| |
| |
| |
| |
| |
| |
| |
| inline int absoluteDistance(const QPoint &a, const QPoint &b) { |
| return std::max(abs(a.x() - b.x()), abs(a.y() - b.y())); |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| inline QRect toRect(const QRectF &rect) { |
| |
| |
| return QRect(rect.topLeft().toPoint(), |
| rect.bottomRight().toPoint() -= QPoint(1, 1)); |
| } |
| |
| |
| |
| |
| namespace { |
| QDesktopWidget *desktop; |
| void getClosestAvailableMousePosition(QPoint &globalPos); |
| } |
| |
| |
| |
| |
| |
| |
| |
| inline void DockLayout::update() { |
| |
| applyGeometry(); |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| DockWidget::DockWidget(QWidget *parent, Qt::WindowFlags flags) |
| : QFrame(parent, flags) |
| , m_dragging(false) |
| , m_resizing(false) |
| , m_floating(true) |
| , m_undocking(false) |
| , m_parentLayout(0) |
| , m_selectedPlace(0) |
| , m_maximized(0) { |
| |
| |
| |
| |
| |
| setAttribute(Qt::WA_Hover); |
| |
| |
| setMinimumSize(QSize(50, 50)); |
| setMaximumSize(QSize(10000, 10000)); |
| |
| m_decoAllocator = new DockDecoAllocator; |
| |
| |
| desktop = qApp->desktop(); |
| } |
| |
| |
| |
| DockWidget::~DockWidget() { |
| |
| |
| if (QWidget::mouseGrabber() == this) releaseMouse(); |
| clearDockPlaceholders(); |
| |
| |
| delete m_decoAllocator; |
| } |
| |
| |
| |
| |
| |
| void DockWidget::clearDockPlaceholders() { |
| unsigned int i; |
| for (i = 0; i < m_placeholders.size(); ++i) delete m_placeholders[i]; |
| m_placeholders.clear(); |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| bool DockWidget::isDragGrip(QPoint p) { |
| if (isFloating()) { |
| QRect frame = frameGeometry(); |
| QRect conts = geometry(); |
| int margin = conts.left() - frame.left(); |
| int titleBarHeight = conts.top() - frame.top(); |
| |
| QRect titleArea(QPoint(0, margin - titleBarHeight), |
| QPoint(width() - 1, -1)); |
| |
| return titleArea.contains(p); |
| } |
| |
| return 0; |
| } |
| |
| |
| |
| bool DockWidget::event(QEvent *e) { |
| |
| |
| |
| switch (e->type()) { |
| |
| |
| case QEvent::HoverMove: |
| hoverMoveEvent(static_cast<QHoverEvent *>(e)); |
| return true; |
| |
| |
| |
| case QEvent::NonClientAreaMouseButtonPress: |
| |
| mousePressEvent(static_cast<QMouseEvent *>(e)); |
| return true; |
| |
| |
| |
| |
| case QEvent::WindowTitleChange: |
| windowTitleEvent(e); |
| return true; |
| |
| default: |
| return QWidget::event(e); |
| } |
| } |
| |
| |
| |
| |
| |
| |
| void DockWidget::hoverMoveEvent(QHoverEvent *he) { |
| if (m_floating && !m_resizing && !m_undocking) { |
| QCursor newCursor = Qt::ArrowCursor; |
| |
| if ((m_marginType = isResizeGrip(he->pos()))) { |
| |
| if (m_marginType & leftMargin) { |
| if (m_marginType & topMargin) |
| newCursor = Qt::SizeFDiagCursor; |
| else if (m_marginType & bottomMargin) |
| newCursor = Qt::SizeBDiagCursor; |
| else |
| newCursor = Qt::SizeHorCursor; |
| } else if (m_marginType & rightMargin) { |
| if (m_marginType & topMargin) |
| newCursor = Qt::SizeBDiagCursor; |
| else if (m_marginType & bottomMargin) |
| newCursor = Qt::SizeFDiagCursor; |
| else |
| newCursor = Qt::SizeHorCursor; |
| } else |
| newCursor = Qt::SizeVerCursor; |
| } |
| |
| if (newCursor.shape() != cursor().shape()) setCursor(newCursor); |
| } |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| void DockWidget::mousePressEvent(QMouseEvent *me) { |
| if ((m_marginType = m_floating ? isResizeGrip(me->pos()) : 0)) { |
| |
| |
| |
| |
| |
| |
| m_resizing = true; |
| m_dragMouseInitialPos = me->globalPos(); |
| } else if (isDragGrip(me->pos())) { |
| |
| DockingCheck *lock = DockingCheck::instance(); |
| |
| m_dragMouseInitialPos = me->globalPos(); |
| m_dragInitialPos = pos(); |
| |
| if (me->type() == QEvent::NonClientAreaMouseButtonPress) |
| |
| grabMouse(); |
| |
| if (m_floating) { |
| m_dragging = true; |
| |
| |
| if (m_parentLayout && !m_parentLayout->getMaximized() && |
| !lock->isEnabled()) |
| m_parentLayout->calculateDockPlaceholders(this); |
| } else { |
| if (!lock->isEnabled()) m_undocking = true; |
| m_dragInitialPos = parentWidget()->mapToGlobal(m_dragInitialPos); |
| } |
| } |
| } |
| |
| |
| |
| void DockWidget::mouseMoveEvent(QMouseEvent *me) { |
| QPoint correctedGlobalPos(me->globalPos()); |
| getClosestAvailableMousePosition(correctedGlobalPos); |
| |
| if (m_resizing) { |
| |
| int dx = correctedGlobalPos.x() - m_dragMouseInitialPos.x(); |
| int dy = correctedGlobalPos.y() - m_dragMouseInitialPos.y(); |
| |
| QRect geom = geometry(); |
| |
| if (m_marginType & leftMargin) { |
| int newWidth = geom.width() - dx; |
| if (newWidth >= minimumWidth() && newWidth <= maximumWidth()) |
| geom.setLeft(geom.left() + dx); |
| } else if (m_marginType & rightMargin) |
| geom.setRight(geom.right() + dx); |
| |
| if (m_marginType & topMargin) { |
| int newHeight = geom.height() - dy; |
| if (newHeight >= minimumHeight() && newHeight <= maximumHeight()) |
| geom.setTop(geom.top() + dy); |
| } else if (m_marginType & bottomMargin) |
| geom.setBottom(geom.bottom() + dy); |
| |
| setGeometry(geom); |
| |
| m_dragMouseInitialPos = correctedGlobalPos; |
| } else if (m_dragging) { |
| move(m_dragInitialPos + correctedGlobalPos - m_dragMouseInitialPos); |
| selectDockPlaceholder(me); |
| } else if (m_undocking) { |
| int distance = absoluteDistance(me->globalPos(), m_dragMouseInitialPos); |
| if (distance > 8) { |
| m_undocking = false; |
| |
| |
| if (m_parentLayout->undockItem(this)) { |
| m_dragging = true; |
| |
| |
| |
| move(m_dragInitialPos + correctedGlobalPos - m_dragMouseInitialPos); |
| show(); |
| |
| |
| |
| |
| grabMouse(); |
| |
| |
| |
| m_parentLayout->calculateDockPlaceholders(this); |
| selectDockPlaceholder(me); |
| } |
| } |
| } |
| } |
| |
| |
| |
| void DockWidget::mouseReleaseEvent(QMouseEvent *me) { |
| |
| releaseMouse(); |
| |
| if (m_dragging) { |
| m_dragging = false; |
| |
| if (m_floating && m_selectedPlace) { |
| m_parentLayout->dockItem(this, m_selectedPlace); |
| } else { |
| |
| } |
| |
| |
| clearDockPlaceholders(); |
| m_selectedPlace = 0; |
| } else if (m_undocking) { |
| |
| m_undocking = false; |
| } else if (m_resizing) { |
| m_resizing = false; |
| } |
| } |
| |
| |
| |
| |
| |
| void DockWidget::mouseDoubleClickEvent(QMouseEvent *me) { |
| if (!m_floating && isDragGrip(me->pos())) { |
| parentLayout()->setMaximized(this, !m_maximized); |
| } |
| } |
| |
| |
| |
| void DockWidget::maximizeDock() { |
| if (!m_floating) { |
| parentLayout()->setMaximized(this, !m_maximized); |
| } |
| } |
| |
| |
| |
| void DockWidget::wheelEvent(QWheelEvent *we) { |
| if (m_dragging) { |
| if (m_selectedPlace) { |
| DockPlaceholder *newSelected = |
| (we->delta() > 0) |
| ? m_selectedPlace->parentPlaceholder() |
| : m_selectedPlace->childPlaceholder( |
| parentWidget()->mapFromGlobal(we->globalPos())); |
| |
| if (newSelected != m_selectedPlace) { |
| m_selectedPlace->hide(); |
| newSelected->show(); |
| m_selectedPlace = newSelected; |
| } |
| } |
| } |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| QWidget *DockWidget::hoveredWidget(QMouseEvent *me) { |
| if (!m_parentLayout) return 0; |
| |
| QPoint point = parentWidget()->mapFromGlobal(me->globalPos()); |
| return m_parentLayout->containerOf(point); |
| } |
| |
| |
| |
| |
| |
| DockPlaceholder *DockWidget::placeAdjacentTo(DockWidget *dockWidget, |
| int boundary) { |
| Region *r = parentLayout()->find(dockWidget); |
| |
| if (((boundary == DockPlaceholder::left || |
| boundary == DockPlaceholder::right) && |
| r->getOrientation() == Region::horizontal) || |
| ((boundary == DockPlaceholder::top || |
| boundary == DockPlaceholder::bottom) && |
| r->getOrientation() == Region::vertical)) { |
| |
| return r->placeholders().size() ? r->placeholder(boundary % 2) : 0; |
| } else { |
| |
| Region *parent = r->getParent(); |
| if (parent) { |
| unsigned int i = parent->find(r); |
| return parent->placeholders().size() |
| ? parent->placeholder(i + (boundary % 2)) |
| : 0; |
| } else { |
| |
| |
| if (!m_placeholders[boundary % 2]->getParentRegion()) { |
| return m_placeholders.size() ? m_placeholders[boundary % 2] : 0; |
| } |
| } |
| } |
| |
| return 0; |
| } |
| |
| |
| |
| |
| DockPlaceholder *DockWidget::placeOfSeparator(DockSeparator *sep) { |
| Region *r = sep->getParentRegion(); |
| int idx = sep->getIndex(); |
| |
| return r->placeholders().size() ? r->placeholder(idx + 1) : 0; |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| void DockWidget::selectDockPlaceholder(QMouseEvent *me) { |
| |
| DockPlaceholder *selected = 0; |
| |
| |
| unsigned int i; |
| for (i = 0; i < m_placeholders.size(); ++i) { |
| if (m_placeholders[i]->geometry().contains(me->globalPos())) { |
| selected = m_placeholders[i]; |
| } |
| } |
| |
| |
| if (m_selectedPlace != selected) { |
| if (m_selectedPlace) m_selectedPlace->hide(); |
| if (selected) selected->show(); |
| } |
| |
| m_selectedPlace = selected; |
| } |
| |
| |
| |
| |
| |
| |
| |
| inline QRect DockPlaceholder::parentGeometry() const { |
| return m_region ? toRect(m_region->getGeometry()) |
| : m_owner->parentLayout()->contentsRect(); |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| inline void DockPlaceholder::buildGeometry() { |
| QRect relativeToMainRect; |
| |
| if (m_separator) |
| relativeToMainRect = m_separator->geometry(); |
| else { |
| QRect parentRect = parentGeometry(); |
| DockLayout *layout = m_owner->parentLayout(); |
| QRect mainRect = layout->contentsRect(); |
| int sepWidth = layout->spacing(); |
| int margin = 6; |
| |
| |
| if (isRoot()) { |
| |
| relativeToMainRect = parentRect; |
| |
| |
| |
| |
| |
| } else if (getParentRegion() == 0 || |
| getParentRegion() == layout->rootRegion()) { |
| |
| switch (getAttribute()) { |
| int leftBound, upperBound; |
| |
| case left: |
| leftBound = parentRect.left() - margin; |
| relativeToMainRect = |
| QRect(leftBound, parentRect.top(), margin, parentRect.height()); |
| break; |
| case right: |
| leftBound = parentRect.right() + 1; |
| relativeToMainRect = |
| QRect(leftBound, parentRect.top(), margin, parentRect.height()); |
| break; |
| case top: |
| upperBound = parentRect.top() - margin; |
| relativeToMainRect = |
| QRect(parentRect.left(), upperBound, parentRect.width(), margin); |
| break; |
| default: |
| upperBound = parentRect.bottom() + 1; |
| relativeToMainRect = |
| QRect(parentRect.left(), upperBound, parentRect.width(), margin); |
| break; |
| } |
| } else |
| switch (getAttribute()) { |
| int leftBound, upperBound; |
| |
| case left: |
| leftBound = parentRect.left(); |
| relativeToMainRect = |
| QRect(leftBound, parentRect.top(), sepWidth, parentRect.height()); |
| break; |
| case right: |
| leftBound = parentRect.right() - sepWidth + 1; |
| relativeToMainRect = |
| QRect(leftBound, parentRect.top(), sepWidth, parentRect.height()); |
| break; |
| case top: |
| upperBound = parentRect.top(); |
| relativeToMainRect = |
| QRect(parentRect.left(), upperBound, parentRect.width(), sepWidth); |
| break; |
| default: |
| upperBound = parentRect.bottom() - sepWidth + 1; |
| relativeToMainRect = |
| QRect(parentRect.left(), upperBound, parentRect.width(), sepWidth); |
| break; |
| } |
| } |
| |
| QPoint topLeft = |
| m_owner->parentWidget()->mapToGlobal(relativeToMainRect.topLeft()); |
| QPoint bottomRight = |
| m_owner->parentWidget()->mapToGlobal(relativeToMainRect.bottomRight()); |
| setGeometry(QRect(topLeft, bottomRight)); |
| } |
| |
| |
| |
| DockPlaceholder::DockPlaceholder(DockWidget *owner, Region *r, int idx, |
| int attributes) |
| : QWidget(owner) |
| , m_owner(owner) |
| , m_separator(0) |
| , m_region(r) |
| , m_idx(idx) |
| , m_attributes(attributes) { |
| setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); |
| |
| |
| if (r && idx && idx < (int)r->getChildList().size()) { |
| m_separator = r->separators()[idx - 1]; |
| } |
| } |
| |
| |
| |
| inline DockSeparator *DockPlaceholder::getSeparator() const { |
| return m_separator; |
| } |
| |
| |
| |
| |
| |
| |
| |
| DockPlaceholder *DockPlaceholder::parentPlaceholder() { |
| |
| |
| if (m_attributes == sepHor || m_attributes == sepVert || isRoot()) |
| return this; |
| |
| |
| Region *grandParent; |
| if (!m_region || !m_region->getParent()) return this; |
| |
| if ((grandParent = m_region->getParent()->getParent())) { |
| |
| |
| unsigned int idx = grandParent->find(m_region->getParent()); |
| |
| |
| if (m_attributes == left || m_attributes == top) |
| return grandParent->placeholders().size() ? grandParent->placeholder(idx) |
| : this; |
| else |
| return grandParent->placeholders().size() |
| ? grandParent->placeholder(idx + 1) |
| : this; |
| } else { |
| |
| |
| |
| if (m_owner->m_placeholders.size()) { |
| DockPlaceholder *result = m_owner->m_placeholders[m_attributes % 2]; |
| if (!result->m_region) return result; |
| } |
| |
| return this; |
| } |
| } |
| |
| |
| |
| |
| |
| DockPlaceholder *DockPlaceholder::childPlaceholder(QPoint p) { |
| |
| if (m_attributes == root) return this; |
| |
| |
| Region *r; |
| unsigned int i; |
| bool lastExtremity; |
| |
| if (m_region) { |
| if (!m_region->getChildList().size()) return this; |
| |
| |
| for (i = 0; i < m_region->getChildList().size(); ++i) |
| if (m_region->childRegion(i)->getGeometry().contains(p)) break; |
| |
| if (i == m_region->getChildList().size()) |
| return this; |
| |
| lastExtremity = (m_idx > (int)i); |
| |
| |
| r = m_region->childRegion(i); |
| if (!r->getChildList().size()) return this; |
| } else { |
| r = m_owner->parentLayout()->rootRegion(); |
| lastExtremity = m_attributes % 2; |
| } |
| |
| |
| for (i = 0; i < r->getChildList().size(); ++i) |
| if (r->childRegion(i)->getGeometry().contains(p)) break; |
| |
| if (i == r->getChildList().size()) return this; |
| |
| r = r->childRegion(i); |
| |
| |
| return r->placeholders().size() |
| ? lastExtremity ? r->placeholders().back() |
| : r->placeholders().front() |
| : this; |
| } |
| |
| |
| |
| |
| inline DockPlaceholder *DockPlaceholder::greatestPlaceholder() { |
| DockPlaceholder *old = this, *current = parentPlaceholder(); |
| |
| while (current != old) { |
| old = current; |
| current = old->parentPlaceholder(); |
| } |
| |
| return current; |
| } |
| |
| |
| |
| |
| |
| |
| inline DockPlaceholder *DockPlaceholder::smallestPlaceholder(QPoint p) { |
| DockPlaceholder *old = this, *current = childPlaceholder(p); |
| |
| while (current != old) { |
| old = current; |
| current = old->childPlaceholder(p); |
| } |
| |
| return current; |
| } |
| |
| |
| |
| |
| |
| |
| |
| DockSeparator::DockSeparator(DockLayout *owner, bool orientation, |
| Region *parentRegion) |
| : QWidget(owner->parentWidget()) |
| , m_owner(owner) |
| , m_orientation(orientation) |
| , m_parentRegion(parentRegion) |
| , m_pressed(false) { |
| setObjectName("DockSeparator"); |
| setWindowFlags(Qt::SubWindow); |
| setAutoFillBackground(false); |
| |
| |
| if (m_orientation == Region::horizontal) |
| setCursor(Qt::SplitHCursor); |
| else |
| setCursor(Qt::SplitVCursor); |
| |
| show(); |
| } |
| |
| |
| |
| void DockSeparator::mousePressEvent(QMouseEvent *me) { |
| m_pressed = true; |
| |
| m_oldPos = me->globalPos(); |
| |
| const std::deque<DockSeparator *> &sepList = m_parentRegion->separators(); |
| const std::deque<Region *> &childList = m_parentRegion->getChildList(); |
| |
| |
| unsigned int i; |
| |
| for (i = 0; i < sepList.size(); ++i) |
| if (sepList[i] == this) break; |
| |
| |
| |
| m_parentRegion->calculateExtremalSizes(); |
| |
| int sepWidth = m_owner->spacing(); |
| Region *r = getParentRegion(); |
| double parentLeft, parentRight; |
| int leftSepCount = m_index; |
| int rightSepCount = |
| r->separators().size() - leftSepCount; |
| |
| if (m_orientation == Region::horizontal) { |
| parentLeft = r->getGeometry().left(); |
| parentRight = r->getGeometry().right(); |
| } else { |
| parentLeft = r->getGeometry().top(); |
| parentRight = r->getGeometry().bottom(); |
| } |
| |
| |
| int j, leftMinSize = 0, rightMinSize = 0, leftMaxSize = 0, rightMaxSize = 0; |
| |
| for (j = 0; j <= m_index; ++j) { |
| leftMinSize += r->childRegion(j)->getMinimumSize(m_orientation); |
| leftMaxSize += r->childRegion(j)->getMaximumSize(m_orientation); |
| } |
| |
| int size = r->getChildList().size(); |
| for (j = m_index + 1; j < size; ++j) { |
| rightMinSize += r->childRegion(j)->getMinimumSize(m_orientation); |
| rightMaxSize += r->childRegion(j)->getMaximumSize(m_orientation); |
| } |
| |
| |
| m_leftBound = std::max(parentLeft + leftMinSize + leftSepCount * sepWidth, |
| parentRight - rightMaxSize - rightSepCount * sepWidth); |
| |
| m_rightBound = |
| std::min(parentLeft + leftMaxSize + leftSepCount * sepWidth, |
| parentRight - rightMinSize - rightSepCount * sepWidth); |
| } |
| |
| |
| |
| inline void DockSeparator::mouseReleaseEvent(QMouseEvent *me) { |
| m_pressed = false; |
| } |
| |
| |
| |
| void DockSeparator::mouseMoveEvent(QMouseEvent *me) { |
| if (m_pressed) { |
| double movedPosition, newPosition; |
| |
| if (m_orientation == Region::horizontal) { |
| double dx = me->globalX() - m_oldPos.x(); |
| movedPosition = |
| getParentRegion()->childRegion(m_index)->getGeometry().right() + dx; |
| newPosition = |
| std::min(std::max(movedPosition, m_leftBound), m_rightBound); |
| dx += newPosition - movedPosition; |
| |
| if (dx) { |
| Region *r; |
| QRectF newGeometry; |
| double newWidth, dxTemp = dx; |
| int i; |
| |
| |
| for (i = m_index; dx != 0 && i >= 0; --i) { |
| r = getParentRegion()->childRegion(i); |
| newGeometry = r->getGeometry(); |
| |
| |
| newGeometry.adjust(0, 0, dx, 0); |
| newWidth = newGeometry.width(); |
| |
| newWidth = std::min( |
| std::max(newWidth, (double)r->getMinimumSize(Region::horizontal)), |
| (double)r->getMaximumSize(Region::horizontal)); |
| newGeometry.adjust(dx = newGeometry.width() - newWidth, 0, 0, 0); |
| r->setGeometry(newGeometry); |
| r->redistribute(); |
| } |
| |
| dx = dxTemp; |
| int size = getParentRegion()->getChildList().size(); |
| |
| for (i = m_index + 1; dx != 0 && i < size; ++i) { |
| r = getParentRegion()->childRegion(i); |
| newGeometry = r->getGeometry(); |
| |
| newGeometry.adjust(dx, 0, 0, 0); |
| newWidth = newGeometry.width(); |
| newWidth = std::min( |
| std::max(newWidth, (double)r->getMinimumSize(Region::horizontal)), |
| (double)r->getMaximumSize(Region::horizontal)); |
| newGeometry.adjust(0, 0, dx = newWidth - newGeometry.width(), 0); |
| r->setGeometry(newGeometry); |
| r->redistribute(); |
| } |
| |
| m_owner->update(); |
| } |
| } else { |
| double dy = me->globalY() - m_oldPos.y(); |
| movedPosition = |
| getParentRegion()->childRegion(m_index)->getGeometry().bottom() + dy; |
| newPosition = |
| std::min(std::max(movedPosition, m_leftBound), m_rightBound); |
| dy += newPosition - movedPosition; |
| |
| if (dy) { |
| Region *r; |
| QRectF newGeometry; |
| double newHeight, dyTemp = dy; |
| int i; |
| |
| for (i = m_index; dy != 0 && i >= 0; --i) { |
| r = getParentRegion()->childRegion(i); |
| newGeometry = r->getGeometry(); |
| QRectF oldGeometry = newGeometry; |
| |
| newGeometry.adjust(0, 0, 0, dy); |
| newHeight = newGeometry.height(); |
| newHeight = std::min( |
| std::max(newHeight, (double)r->getMinimumSize(Region::vertical)), |
| (double)r->getMaximumSize(Region::vertical)); |
| newGeometry.adjust(0, dy = newGeometry.height() - newHeight, 0, 0); |
| r->setGeometry(newGeometry); |
| r->redistribute(); |
| } |
| |
| dy = dyTemp; |
| int size = getParentRegion()->getChildList().size(); |
| for (i = m_index + 1; dy != 0 && i < size; ++i) { |
| r = getParentRegion()->childRegion(i); |
| newGeometry = r->getGeometry(); |
| |
| newGeometry.adjust(0, dy, 0, 0); |
| newHeight = newGeometry.height(); |
| newHeight = std::min( |
| std::max(newHeight, (double)r->getMinimumSize(Region::vertical)), |
| (double)r->getMaximumSize(Region::vertical)); |
| newGeometry.adjust(0, 0, 0, dy = newHeight - newGeometry.height()); |
| r->setGeometry(newGeometry); |
| r->redistribute(); |
| } |
| |
| m_owner->update(); |
| } |
| } |
| |
| m_oldPos = QPoint(me->globalX(), me->globalY()); |
| } |
| } |
| |
| |
| |
| |
| |
| |
| |
| namespace { |
| |
| |
| |
| |
| void getClosestAvailableMousePosition(QPoint &globalPos) { |
| |
| int i, screens = desktop->numScreens(); |
| for (i = 0; i < screens; ++i) |
| if (desktop->screenGeometry(i).contains(globalPos)) break; |
| |
| |
| QRect rect(desktop->availableGeometry(i)); |
| if (rect.contains(globalPos)) return; |
| |
| |
| QPoint result; |
| if (globalPos.x() < rect.left()) |
| globalPos.setX(rect.left()); |
| else if (globalPos.x() > rect.right()) |
| globalPos.setX(rect.right()); |
| |
| if (globalPos.y() < rect.top()) |
| globalPos.setY(rect.top()); |
| else if (globalPos.y() > rect.bottom()) |
| globalPos.setY(rect.bottom()); |
| } |
| |
| } |
| |