summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeokYeon Hwang <syeon.hwang@samsung.com>2014-10-28 01:23:16 -0700
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>2014-10-28 01:23:16 -0700
commit27a98560f96160b421410d67601cf97dea43f6d1 (patch)
tree4a042aeba7977c1888fb3e53d0a1205a5e7f78bd
parent21c8f6d13fb67054412b7741b12bc8b1fab9c2f1 (diff)
parent874c46d30aaa2659c369ea437301d2a2c5a9b172 (diff)
downloadqemu-27a98560f96160b421410d67601cf97dea43f6d1.tar.gz
qemu-27a98560f96160b421410d67601cf97dea43f6d1.tar.bz2
qemu-27a98560f96160b421410d67601cf97dea43f6d1.zip
Merge "controller: draw a docking guide line" into features/qt_dr
-rw-r--r--tizen/src/ui/dockingconview.cpp5
-rw-r--r--tizen/src/ui/floatingconview.cpp78
-rw-r--r--tizen/src/ui/floatingconview.h3
3 files changed, 75 insertions, 11 deletions
diff --git a/tizen/src/ui/dockingconview.cpp b/tizen/src/ui/dockingconview.cpp
index 81919de264..dee2b3f1b5 100644
--- a/tizen/src/ui/dockingconview.cpp
+++ b/tizen/src/ui/dockingconview.cpp
@@ -81,6 +81,7 @@ void DockingConView::mousePressEvent(QMouseEvent *event)
QGraphicsView::mousePressEvent(event);
if (bezelItem->isKeyHandling() == true) {
+ /* do nothing */
return;
}
@@ -104,6 +105,7 @@ void DockingConView::mouseReleaseEvent(QMouseEvent *event)
QGraphicsView::mouseReleaseEvent(event);
if (bezelItem->isKeyHandling() == true) {
+ /* do nothing */
return;
}
@@ -128,10 +130,11 @@ void DockingConView::mouseMoveEvent(QMouseEvent *event)
QGraphicsView::mouseMoveEvent(event);
if (bezelItem->isKeyHandling() == true) {
+ /* do nothing */
return;
}
- if (grabPos != QPoint(-1, -1)) {
+ if (grabPos != QPoint(-1, -1) && rubberBand != NULL) {
rubberBand->setGeometry(
QRect(rubberPos + (event->globalPos() - grabPos), size()));
}
diff --git a/tizen/src/ui/floatingconview.cpp b/tizen/src/ui/floatingconview.cpp
index ca1c6b2219..a6572dcbad 100644
--- a/tizen/src/ui/floatingconview.cpp
+++ b/tizen/src/ui/floatingconview.cpp
@@ -47,6 +47,7 @@ FloatingConView::FloatingConView(ControllerForm *conForm, QGraphicsScene *scene,
conPos = QPoint(-1, -1);
grabPos = QPoint(-1, -1);
+ rubberBand = new QRubberBand(QRubberBand::Rectangle, NULL);
createItems(conForm);
}
@@ -103,12 +104,32 @@ int FloatingConView::isDockable(QWidget *object, QWidget *subject)
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;
@@ -119,6 +140,7 @@ void FloatingConView::mousePressEvent(QMouseEvent *event)
QGraphicsView::mousePressEvent(event);
if (bezelItem->isKeyHandling() == true) {
+ /* do nothing */
return;
}
@@ -133,20 +155,23 @@ void FloatingConView::mouseReleaseEvent(QMouseEvent *event)
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;
}
@@ -157,10 +182,37 @@ void FloatingConView::mouseMoveEvent(QMouseEvent *event)
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));
}
}
@@ -168,4 +220,10 @@ void FloatingConView::mouseMoveEvent(QMouseEvent *event)
FloatingConView::~FloatingConView()
{
qDebug("destroy floating controller view");
+
+ if (rubberBand != NULL) {
+ rubberBand->close();
+ delete rubberBand;
+ rubberBand = NULL;
+ }
}
diff --git a/tizen/src/ui/floatingconview.h b/tizen/src/ui/floatingconview.h
index 71ef154bb3..f2e996f468 100644
--- a/tizen/src/ui/floatingconview.h
+++ b/tizen/src/ui/floatingconview.h
@@ -30,6 +30,8 @@
#ifndef FLOATINGCONVIEW_H
#define FLOATINGCONVIEW_H
+#include <QRubberBand>
+
#include "skinview.h"
#include "skinbezelitem.h"
#include "controllerform.h"
@@ -58,6 +60,7 @@ private:
FloatingController *parent;
SkinBezelItem *bezelItem;
+ QRubberBand *rubberBand;
};
#endif // FLOATINGCONVIEW_H