conPos = QPoint(-1, -1);
grabPos = QPoint(-1, -1);
+ rubberBand = new QRubberBand(QRubberBand::Rectangle, NULL);
createItems(conForm);
}
DOCKABLE_AREA_WIDTH,
subject->size().height());
- if (rectTarget.intersects(rectDockableRC) == true) {
- return Qt::AlignRight | Qt::AlignCenter;
- } else if (rectTarget.intersects(rectDockableRT) == true) {
- return Qt::AlignRight | Qt::AlignTop;
- } else if (rectTarget.intersects(rectDockableRB) == true) {
- return Qt::AlignRight | Qt::AlignBottom;
+ // TODO: define recursive function
+ QRect interRC = rectTarget.intersected(rectDockableRC);
+ QRect interRT = rectTarget.intersected(rectDockableRT);
+ QRect interRB = rectTarget.intersected(rectDockableRB);
+
+ QRect *interBiggest = NULL;
+
+ if ((interRC.width() * interRC.height()) < (interRT.width() * interRT.height())) {
+ interBiggest = &interRT;
+ } else {
+ interBiggest = &interRC;
+ }
+
+ if ((interBiggest->width() * interBiggest->height()) < (interRB.width() * interRB.height())) {
+ interBiggest = &interRB;
+ }
+
+ if (interBiggest != NULL &&
+ interBiggest->isNull() == false && interBiggest->isEmpty() == false) {
+ if (interBiggest == &interRC) {
+ return Qt::AlignRight | Qt::AlignCenter;
+ } else if (interBiggest == &interRT) {
+ return Qt::AlignRight | Qt::AlignTop;
+ } else if (interBiggest == &interRB) {
+ return Qt::AlignRight | Qt::AlignBottom;
+ }
}
return -1;
QGraphicsView::mousePressEvent(event);
if (bezelItem->isKeyHandling() == true) {
+ /* do nothing */
return;
}
QGraphicsView::mouseReleaseEvent(event);
if (bezelItem->isKeyHandling() == true) {
+ /* do nothing */
return;
}
if (event->button() == Qt::LeftButton) {
grabPos = QPoint(-1, -1);
+ if (rubberBand != NULL) {
+ rubberBand->hide();
+ }
}
- QWidget *con = ((QWidget *)parent);
- QWidget *dst = ((QWidget *)con->parent());
+ const FloatingController *con = parent;
+ MainWindow *win = ((MainWindow *)con->parent());
- int dockPos = isDockable(dst, con);
+ int dockPos = isDockable((QWidget *)win, (QWidget *)parent);
if (dockPos != -1) {
/* toggle */
- MainWindow *win = (MainWindow *)dst;
win->openController(win->getUIState()->conState.conFormIndex, dockPos);
return;
}
QGraphicsView::mouseMoveEvent(event);
if (bezelItem->isKeyHandling() == true) {
+ /* do nothing */
return;
}
if (grabPos != QPoint(-1, -1)) {
+ /* draw guide for dockable position */
+ const FloatingController *con = parent;
+ MainWindow *win = ((MainWindow *)con->parent());
+
+ if (rubberBand != NULL) {
+ int dockPos = isDockable((QWidget *)win, (QWidget *)con);
+ if (dockPos != -1) {
+ int vShift = 0;
+
+ if (win->size().height() > size().height()) {
+ if (dockPos & Qt::AlignCenter) {
+ vShift = (win->size().height() / 2) - (size().height() / 2);
+ } else if (dockPos & Qt::AlignBottom) {
+ vShift = win->size().height() - size().height();
+ }
+ }
+
+ QPoint rubberPos(win->pos().x() + win->size().width(),
+ win->pos().y() + vShift);
+ rubberBand->setGeometry(QRect(rubberPos, size()));
+ rubberBand->show();
+ } else {
+ rubberBand->hide();
+ }
+ }
+
parent->move(conPos + (event->globalPos() - grabPos));
}
}
FloatingConView::~FloatingConView()
{
qDebug("destroy floating controller view");
+
+ if (rubberBand != NULL) {
+ rubberBand->close();
+ delete rubberBand;
+ rubberBand = NULL;
+ }
}