From: GiWoong Kim Date: Tue, 31 Mar 2015 09:35:27 +0000 (+0900) Subject: ui: move some controller files X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~515 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fe15fcb748bc0c6696d23aad1612fdf926c38364;p=sdk%2Femulator%2Fqemu.git ui: move some controller files tizen/src/ui/ -> tizen/src/ui/controller/ Change-Id: I3496f9dcd48e7fbe167aa8ca7e9068c1672a11be Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/display/qt5_supplement.cpp b/tizen/src/display/qt5_supplement.cpp index 2a3489e539..7a4368ee05 100644 --- a/tizen/src/display/qt5_supplement.cpp +++ b/tizen/src/display/qt5_supplement.cpp @@ -32,9 +32,7 @@ #include "qt5_supplement.h" #include "mainwindow.h" -#include "uiinformation.h" #include "hardwarekey.h" -#include "floatingcontroller.h" #include "xmllayoutparser.h" #include "uiutil.h" diff --git a/tizen/src/ui/Makefile.objs b/tizen/src/ui/Makefile.objs index 518a9140d8..499efb643a 100644 --- a/tizen/src/ui/Makefile.objs +++ b/tizen/src/ui/Makefile.objs @@ -6,10 +6,6 @@ $(obj)/qrc_resource.cpp: $(TIZEN_UI)/resource/resource.qrc rcc -name resource $< -o $@ obj-$(CONFIG_QT) += controllerform.o -obj-$(CONFIG_QT) += dockingcontroller.o moc_dockingcontroller.o -obj-$(CONFIG_QT) += dockingconview.o -obj-$(CONFIG_QT) += floatingcontroller.o moc_floatingcontroller.o -obj-$(CONFIG_QT) += floatingconview.o obj-$(CONFIG_QT) += displaybase.o obj-$(CONFIG_QT) += displayglwidget.o moc_displayglwidget.o obj-$(CONFIG_QT) += displayswwidget.o moc_displayswwidget.o @@ -33,12 +29,6 @@ obj-$(CONFIG_QT) += qrc_resource.o obj-$(CONFIG_QT) += controller/ obj-$(CONFIG_QT) += menu/ -$(obj)/moc_dockingcontroller.o: $(obj)/moc_dockingcontroller.cpp -$(obj)/moc_dockingcontroller.cpp: $(obj)/dockingcontroller.h - moc $< -o $@ -$(obj)/moc_floatingcontroller.o: $(obj)/moc_floatingcontroller.cpp -$(obj)/moc_floatingcontroller.cpp: $(obj)/floatingcontroller.h - moc $< -o $@ $(obj)/moc_displayglwidget.o: $(obj)/moc_displayglwidget.cpp $(obj)/moc_displayglwidget.cpp: $(obj)/displayglwidget.h moc $< -o $@ diff --git a/tizen/src/ui/controller/Makefile.objs b/tizen/src/ui/controller/Makefile.objs index 8149614438..2dd3fbb468 100644 --- a/tizen/src/ui/controller/Makefile.objs +++ b/tizen/src/ui/controller/Makefile.objs @@ -1 +1,12 @@ -obj-$(CONFIG_QT) += generalpurposecon.o \ No newline at end of file +obj-$(CONFIG_QT) += dockingcontroller.o moc_dockingcontroller.o +obj-$(CONFIG_QT) += dockingconview.o +obj-$(CONFIG_QT) += floatingcontroller.o moc_floatingcontroller.o +obj-$(CONFIG_QT) += floatingconview.o +obj-$(CONFIG_QT) += generalpurposecon.o + +$(obj)/moc_dockingcontroller.o: $(obj)/moc_dockingcontroller.cpp +$(obj)/moc_dockingcontroller.cpp: $(obj)/dockingcontroller.h + moc $< -o $@ +$(obj)/moc_floatingcontroller.o: $(obj)/moc_floatingcontroller.cpp +$(obj)/moc_floatingcontroller.cpp: $(obj)/floatingcontroller.h + moc $< -o $@ \ No newline at end of file diff --git a/tizen/src/ui/controller/dockingcontroller.cpp b/tizen/src/ui/controller/dockingcontroller.cpp new file mode 100644 index 0000000000..de5a135d04 --- /dev/null +++ b/tizen/src/ui/controller/dockingcontroller.cpp @@ -0,0 +1,92 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "dockingcontroller.h" +#include "mainwindow.h" + +DockingController::DockingController(ControllerForm *conForm, + QAction *menu, int dockPos, QWidget *parent) : QWidget(parent) +{ + this->conForm = conForm; + this->menu = menu; + this->dockPos = dockPos; + + setStyleSheet("border-style: none"); + setAttribute(Qt::WA_DeleteOnClose); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(0); + layout->setSpacing(0); + + if (dockPos & Qt::AlignCenter) { + layout->setAlignment(Qt::AlignCenter); + } else if (dockPos & Qt::AlignTop) { + layout->setAlignment(Qt::AlignTop); + } else if (dockPos & Qt::AlignBottom) { + layout->setAlignment(Qt::AlignBottom); + } + + QGraphicsScene *conScene = new QGraphicsScene(this); + conScene->setBackgroundBrush(Qt::black); + + conView = new DockingConView(conForm, conScene, this); + conView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + layout->addWidget(conView); +} + +DockingConView *DockingController::getConView() +{ + return conView; +} + +int DockingController::getDockPos() +{ + return dockPos; +} + +void DockingController::showEvent(QShowEvent *event) +{ + if (menu != NULL) { + menu->setChecked(true); + } +} + +void DockingController::closeEvent(QCloseEvent *event) { + if (menu != NULL) { + menu->setChecked(false); + } + + MainWindow *win = ((MainWindow *)this->parent()); + win->getUIState()->conState.dockingCon = NULL; +} + +DockingController::~DockingController() +{ + qDebug("destroy docking controller"); +} diff --git a/tizen/src/ui/controller/dockingcontroller.h b/tizen/src/ui/controller/dockingcontroller.h new file mode 100644 index 0000000000..a388030f56 --- /dev/null +++ b/tizen/src/ui/controller/dockingcontroller.h @@ -0,0 +1,61 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef DOCKINGCONTROLLER_H +#define DOCKINGCONTROLLER_H + +#include + +#include "controllerform.h" +#include "dockingconview.h" + +class DockingController : public QWidget +{ + Q_OBJECT + +public: + explicit DockingController(ControllerForm *conForm, + QAction *menu, int dockPos, QWidget *parent = 0); + ~DockingController(); + + DockingConView *getConView(); + int getDockPos(); + +protected: + void showEvent(QShowEvent *event); + void closeEvent(QCloseEvent *event); + +private: + DockingConView *conView; + ControllerForm *conForm; + QAction *menu; + int dockPos; +}; + +#endif // DOCKINGCONTROLLER_H diff --git a/tizen/src/ui/controller/dockingconview.cpp b/tizen/src/ui/controller/dockingconview.cpp new file mode 100644 index 0000000000..5ab54a55e6 --- /dev/null +++ b/tizen/src/ui/controller/dockingconview.cpp @@ -0,0 +1,169 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "dockingconview.h" +#include "mainwindow.h" +#include "skinkeyitem.h" +#include "controller/generalpurposecon.h" + +DockingConView::DockingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent) + : QGraphicsView(scene, parent) +{ + this->parent = (DockingController *)parent; + + setStyleSheet("background: transparent"); + setStyleSheet("border-style: none"); + + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setAlignment(Qt::AlignLeft | Qt::AlignTop); + + rubberPos = QPoint(-1, -1); + grabPos = QPoint(-1, -1); + rubberBand = new QRubberBand(QRubberBand::Rectangle, NULL); + + createItems(conForm); +} + +void DockingConView::createItems(ControllerForm *conForm) +{ + /* bezel */ + bezelItem = new SkinBezelItem(conForm->conImg[ControllerForm::normal]); + scene()->addItem(bezelItem); + + /* HW keys */ + keyList = conForm->keyList; + + if (conForm->isGeneralPurpose() == false) { + HardwareKey *hwKey = NULL; + for (int i = 0; i < keyList.count(); i++) { + hwKey = keyList.at(i); + if (hwKey != NULL) { + new SkinKeyItem(bezelItem, hwKey, + conForm->conImg[ControllerForm::pressed].copy(hwKey->region), + conForm->getHoverType()); + } + } + } else { + GeneralPurposeCon *generalCon = new GeneralPurposeCon(this, keyList, + QSize(conForm->centerRect.width(), + conForm->centerRect.height() - (GPC_HEAD_SPACING + GPC_TAIL_SPACING))); + scene()->addWidget(generalCon); + + QPoint topLeft = conForm->centerRect.topLeft(); + generalCon->move(topLeft.x(), topLeft.y() + GPC_HEAD_SPACING); + } +} + +void DockingConView::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event) + + /* do nothing */ +} + +void DockingConView::mousePressEvent(QMouseEvent *event) +{ + QGraphicsView::mousePressEvent(event); + + if (bezelItem->isHWKeyHandling() == true) { + /* do nothing */ + return; + } + + if (event->button() == Qt::LeftButton) { + QWidget *win = parent->parentWidget(); + + grabPos = event->globalPos(); + eventPos = event->pos(); + rubberPos.setX(win->pos().x() + parent->pos().x()); + rubberPos.setY(win->pos().y() + pos().y()); + + if (rubberBand != NULL) { + rubberBand->setGeometry(QRect(rubberPos, size())); + rubberBand->show(); + } + } +} + +void DockingConView::mouseReleaseEvent(QMouseEvent *event) +{ + QGraphicsView::mouseReleaseEvent(event); + + if (bezelItem->isHWKeyHandling() == true) { + /* do nothing */ + return; + } + + if (event->button() == Qt::LeftButton) { + if (grabPos != QPoint(-1, -1)) { + if (rubberBand != NULL) { + rubberBand->hide(); + } + + /* toggle */ + MainWindow *win = ((MainWindow *)parent->parent()); + win->getUIState()->conState.recentlyFloatPos = event->globalPos() - eventPos; + + win->openController(win->getUIState()->conState.conFormIndex, -1); + return; + } + } +} + +void DockingConView::mouseMoveEvent(QMouseEvent *event) +{ + QGraphicsView::mouseMoveEvent(event); + + if (bezelItem->isHWKeyHandling() == true) { + /* do nothing */ + return; + } + + if (grabPos != QPoint(-1, -1) && rubberBand != NULL) { + rubberBand->setGeometry( + QRect(rubberPos + (event->globalPos() - grabPos), size())); + } +} + +QList DockingConView::getKeyList() +{ + return keyList; +} + +DockingConView::~DockingConView() +{ + qDebug("destroy docking controller view"); + + if (rubberBand != NULL) { + rubberBand->close(); + delete rubberBand; + rubberBand = NULL; + } +} diff --git a/tizen/src/ui/controller/dockingconview.h b/tizen/src/ui/controller/dockingconview.h new file mode 100644 index 0000000000..9579b46cad --- /dev/null +++ b/tizen/src/ui/controller/dockingconview.h @@ -0,0 +1,67 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef DOCKINGCONVIEW_H +#define DOCKINGCONVIEW_H + +#include + +#include "skinview.h" +#include "skinbezelitem.h" +#include "controllerform.h" + +class DockingController; + +class DockingConView : public QGraphicsView +{ +public: + DockingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent = 0); + ~DockingConView(); + QList getKeyList(); + +protected: + void resizeEvent(QResizeEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + + QPoint grabPos; + QPoint eventPos; + QPoint rubberPos; + +private: + void createItems(ControllerForm *conForm); + + DockingController *parent; + SkinBezelItem *bezelItem; + QRubberBand *rubberBand; + QList keyList; +}; + +#endif // DOCKINGCONVIEW_H diff --git a/tizen/src/ui/controller/floatingcontroller.cpp b/tizen/src/ui/controller/floatingcontroller.cpp new file mode 100644 index 0000000000..23aff1e8ad --- /dev/null +++ b/tizen/src/ui/controller/floatingcontroller.cpp @@ -0,0 +1,95 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "floatingcontroller.h" +#include "mainwindow.h" + +FloatingController::FloatingController(ControllerForm *conForm, + QAction *menu, QWidget *parent) : QDialog(parent) +{ + this->conForm = conForm; + this->menu = menu; + + setStyleSheet("border-style: none"); + setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog); + setAttribute(Qt::WA_DeleteOnClose); + + setWindowTitle(conForm->getName()); + + QHBoxLayout *layout = new QHBoxLayout(this); + layout->setMargin(0); + layout->setSpacing(0); + + QGraphicsScene *conScene = new QGraphicsScene(this); + conScene->setBackgroundBrush(Qt::black); + + conView = new FloatingConView(conForm, conScene, this); + conView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + layout->addWidget(conView); +} + +FloatingConView *FloatingController::getConView() +{ + return conView; +} + +void FloatingController::showEvent(QShowEvent *event) +{ + if (menu != NULL) { + menu->setChecked(true); + } + + setRegion(&(conForm->conImg[ControllerForm::normal])); +} + +void FloatingController::closeEvent(QCloseEvent *event) { + if (menu != NULL) { + menu->setChecked(false); + } + + MainWindow *win = ((MainWindow *)this->parent()); + win->getUIState()->conState.floatingCon = NULL; +} + +void FloatingController::setRegion(QImage *baseImage) +{ + qDebug("set region"); + + if (baseImage->isNull() == true) { + qWarning("invalid image for region"); + return; + } + + setMask(QRegion(QBitmap::fromImage(baseImage->createAlphaMask()))); +} + +FloatingController::~FloatingController() +{ + qDebug("destroy floating controller"); +} diff --git a/tizen/src/ui/controller/floatingcontroller.h b/tizen/src/ui/controller/floatingcontroller.h new file mode 100644 index 0000000000..d9e7bf50c0 --- /dev/null +++ b/tizen/src/ui/controller/floatingcontroller.h @@ -0,0 +1,60 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef FLOATINGCONTROLLER_H +#define FLOATINGCONTROLLER_H + +#include + +#include "controllerform.h" +#include "floatingconview.h" + +class FloatingController : public QDialog +{ + Q_OBJECT + +public: + explicit FloatingController(ControllerForm *conForm, QAction *menu, QWidget *parent = 0); + ~FloatingController(); + + FloatingConView *getConView(); + +protected: + void showEvent(QShowEvent *event); + void closeEvent(QCloseEvent *event); + + void setRegion(QImage *baseImage); + +private: + FloatingConView *conView; + ControllerForm *conForm; + QAction *menu; +}; + +#endif // FLOATINGCONTROLLER_H diff --git a/tizen/src/ui/controller/floatingconview.cpp b/tizen/src/ui/controller/floatingconview.cpp new file mode 100644 index 0000000000..28bb576d6b --- /dev/null +++ b/tizen/src/ui/controller/floatingconview.cpp @@ -0,0 +1,246 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "floatingconview.h" +#include "mainwindow.h" +#include "skinkeyitem.h" +#include "controller/generalpurposecon.h" + +#define DOCKABLE_AREA_WIDTH 30 + +FloatingConView::FloatingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent) + : QGraphicsView(scene, parent) +{ + this->parent = (FloatingController *)parent; + + setStyleSheet("background: transparent"); + setStyleSheet("border-style: none"); + + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setAlignment(Qt::AlignLeft | Qt::AlignTop); + + conPos = QPoint(-1, -1); + grabPos = QPoint(-1, -1); + rubberBand = new QRubberBand(QRubberBand::Rectangle, NULL); + + createItems(conForm); +} + +void FloatingConView::createItems(ControllerForm *conForm) +{ + /* bezel */ + bezelItem = new SkinBezelItem(conForm->conImg[ControllerForm::normal]); + scene()->addItem(bezelItem); + + /* HW keys */ + keyList = conForm->keyList; + + if (conForm->isGeneralPurpose() == false) { + HardwareKey *hwKey = NULL; + for (int i = 0; i < keyList.count(); i++) { + hwKey = keyList.at(i); + if (hwKey != NULL) { + new SkinKeyItem(bezelItem, hwKey, + conForm->conImg[ControllerForm::pressed].copy(hwKey->region), + conForm->getHoverType()); + } + } + } else { + GeneralPurposeCon *generalCon = new GeneralPurposeCon(this, keyList, + QSize(conForm->centerRect.width(), + conForm->centerRect.height() - (GPC_HEAD_SPACING + GPC_TAIL_SPACING))); + scene()->addWidget(generalCon); + + QPoint topLeft = conForm->centerRect.topLeft(); + generalCon->move(topLeft.x(), topLeft.y() + GPC_HEAD_SPACING); + } +} + +void FloatingConView::resizeEvent(QResizeEvent *event) +{ + //qDebug("resize con view"); + + Q_UNUSED(event) +} + +int FloatingConView::isDockable(QWidget *object, QWidget *subject) +{ + const int heightOneThird = object->size().height() / 3; + + /* MainWindow */ + QRect rectDockableRC(object->pos().x() + object->size().width() - 1, + object->pos().y() + heightOneThird, + DOCKABLE_AREA_WIDTH, + heightOneThird); + + QRect rectDockableRT(object->pos().x() + object->size().width() - 1, + object->pos().y(), + DOCKABLE_AREA_WIDTH, + heightOneThird); + + QRect rectDockableRB(object->pos().x() + object->size().width() - 1, + object->pos().y() + (heightOneThird * 2), + DOCKABLE_AREA_WIDTH, + heightOneThird); + + /* ControllerWidget */ + QRect rectTarget(subject->pos().x() - 1, + subject->pos().y(), + DOCKABLE_AREA_WIDTH, + subject->size().height()); + + // 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; +} + +void FloatingConView::mousePressEvent(QMouseEvent *event) +{ + QGraphicsView::mousePressEvent(event); + + if (bezelItem->isHWKeyHandling() == true) { + /* do nothing */ + return; + } + + if (event->button() == Qt::LeftButton) { + grabPos = event->globalPos(); + conPos = parent->pos(); + } +} + +void FloatingConView::mouseReleaseEvent(QMouseEvent *event) +{ + QGraphicsView::mouseReleaseEvent(event); + + if (bezelItem->isHWKeyHandling() == true) { + /* do nothing */ + return; + } + + if (event->button() == Qt::LeftButton) { + grabPos = QPoint(-1, -1); + if (rubberBand != NULL) { + rubberBand->hide(); + } + } + + const FloatingController *con = parent; + MainWindow *win = ((MainWindow *)con->parent()); + + int dockPos = isDockable((QWidget *)win, (QWidget *)parent); + if (dockPos != -1) { + /* toggle */ + win->openController(win->getUIState()->conState.conFormIndex, dockPos); + return; + } +} + +void FloatingConView::mouseMoveEvent(QMouseEvent *event) +{ + QGraphicsView::mouseMoveEvent(event); + + if (bezelItem->isHWKeyHandling() == 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)); + } +} + +QList FloatingConView::getKeyList() +{ + return keyList; +} + +FloatingConView::~FloatingConView() +{ + qDebug("destroy floating controller view"); + + if (rubberBand != NULL) { + rubberBand->close(); + delete rubberBand; + rubberBand = NULL; + } +} diff --git a/tizen/src/ui/controller/floatingconview.h b/tizen/src/ui/controller/floatingconview.h new file mode 100644 index 0000000000..164e964433 --- /dev/null +++ b/tizen/src/ui/controller/floatingconview.h @@ -0,0 +1,68 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef FLOATINGCONVIEW_H +#define FLOATINGCONVIEW_H + +#include + +#include "skinview.h" +#include "skinbezelitem.h" +#include "controllerform.h" + +class FloatingController; + +class FloatingConView : public QGraphicsView +{ +public: + FloatingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent = 0); + ~FloatingConView(); + QList getKeyList(); + +protected: + void resizeEvent(QResizeEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + + int isDockable(QWidget *object, QWidget *subject); + + QPoint grabPos; + QPoint conPos; + +private: + void createItems(ControllerForm *conForm); + + FloatingController *parent; + SkinBezelItem *bezelItem; + QRubberBand *rubberBand; + QList keyList; +}; + +#endif // FLOATINGCONVIEW_H diff --git a/tizen/src/ui/dockingcontroller.cpp b/tizen/src/ui/dockingcontroller.cpp deleted file mode 100644 index de5a135d04..0000000000 --- a/tizen/src/ui/dockingcontroller.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#include "dockingcontroller.h" -#include "mainwindow.h" - -DockingController::DockingController(ControllerForm *conForm, - QAction *menu, int dockPos, QWidget *parent) : QWidget(parent) -{ - this->conForm = conForm; - this->menu = menu; - this->dockPos = dockPos; - - setStyleSheet("border-style: none"); - setAttribute(Qt::WA_DeleteOnClose); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); - layout->setSpacing(0); - - if (dockPos & Qt::AlignCenter) { - layout->setAlignment(Qt::AlignCenter); - } else if (dockPos & Qt::AlignTop) { - layout->setAlignment(Qt::AlignTop); - } else if (dockPos & Qt::AlignBottom) { - layout->setAlignment(Qt::AlignBottom); - } - - QGraphicsScene *conScene = new QGraphicsScene(this); - conScene->setBackgroundBrush(Qt::black); - - conView = new DockingConView(conForm, conScene, this); - conView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - layout->addWidget(conView); -} - -DockingConView *DockingController::getConView() -{ - return conView; -} - -int DockingController::getDockPos() -{ - return dockPos; -} - -void DockingController::showEvent(QShowEvent *event) -{ - if (menu != NULL) { - menu->setChecked(true); - } -} - -void DockingController::closeEvent(QCloseEvent *event) { - if (menu != NULL) { - menu->setChecked(false); - } - - MainWindow *win = ((MainWindow *)this->parent()); - win->getUIState()->conState.dockingCon = NULL; -} - -DockingController::~DockingController() -{ - qDebug("destroy docking controller"); -} diff --git a/tizen/src/ui/dockingcontroller.h b/tizen/src/ui/dockingcontroller.h deleted file mode 100644 index a388030f56..0000000000 --- a/tizen/src/ui/dockingcontroller.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#ifndef DOCKINGCONTROLLER_H -#define DOCKINGCONTROLLER_H - -#include - -#include "controllerform.h" -#include "dockingconview.h" - -class DockingController : public QWidget -{ - Q_OBJECT - -public: - explicit DockingController(ControllerForm *conForm, - QAction *menu, int dockPos, QWidget *parent = 0); - ~DockingController(); - - DockingConView *getConView(); - int getDockPos(); - -protected: - void showEvent(QShowEvent *event); - void closeEvent(QCloseEvent *event); - -private: - DockingConView *conView; - ControllerForm *conForm; - QAction *menu; - int dockPos; -}; - -#endif // DOCKINGCONTROLLER_H diff --git a/tizen/src/ui/dockingconview.cpp b/tizen/src/ui/dockingconview.cpp deleted file mode 100644 index 5ab54a55e6..0000000000 --- a/tizen/src/ui/dockingconview.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#include "dockingconview.h" -#include "mainwindow.h" -#include "skinkeyitem.h" -#include "controller/generalpurposecon.h" - -DockingConView::DockingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent) - : QGraphicsView(scene, parent) -{ - this->parent = (DockingController *)parent; - - setStyleSheet("background: transparent"); - setStyleSheet("border-style: none"); - - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setAlignment(Qt::AlignLeft | Qt::AlignTop); - - rubberPos = QPoint(-1, -1); - grabPos = QPoint(-1, -1); - rubberBand = new QRubberBand(QRubberBand::Rectangle, NULL); - - createItems(conForm); -} - -void DockingConView::createItems(ControllerForm *conForm) -{ - /* bezel */ - bezelItem = new SkinBezelItem(conForm->conImg[ControllerForm::normal]); - scene()->addItem(bezelItem); - - /* HW keys */ - keyList = conForm->keyList; - - if (conForm->isGeneralPurpose() == false) { - HardwareKey *hwKey = NULL; - for (int i = 0; i < keyList.count(); i++) { - hwKey = keyList.at(i); - if (hwKey != NULL) { - new SkinKeyItem(bezelItem, hwKey, - conForm->conImg[ControllerForm::pressed].copy(hwKey->region), - conForm->getHoverType()); - } - } - } else { - GeneralPurposeCon *generalCon = new GeneralPurposeCon(this, keyList, - QSize(conForm->centerRect.width(), - conForm->centerRect.height() - (GPC_HEAD_SPACING + GPC_TAIL_SPACING))); - scene()->addWidget(generalCon); - - QPoint topLeft = conForm->centerRect.topLeft(); - generalCon->move(topLeft.x(), topLeft.y() + GPC_HEAD_SPACING); - } -} - -void DockingConView::resizeEvent(QResizeEvent *event) -{ - Q_UNUSED(event) - - /* do nothing */ -} - -void DockingConView::mousePressEvent(QMouseEvent *event) -{ - QGraphicsView::mousePressEvent(event); - - if (bezelItem->isHWKeyHandling() == true) { - /* do nothing */ - return; - } - - if (event->button() == Qt::LeftButton) { - QWidget *win = parent->parentWidget(); - - grabPos = event->globalPos(); - eventPos = event->pos(); - rubberPos.setX(win->pos().x() + parent->pos().x()); - rubberPos.setY(win->pos().y() + pos().y()); - - if (rubberBand != NULL) { - rubberBand->setGeometry(QRect(rubberPos, size())); - rubberBand->show(); - } - } -} - -void DockingConView::mouseReleaseEvent(QMouseEvent *event) -{ - QGraphicsView::mouseReleaseEvent(event); - - if (bezelItem->isHWKeyHandling() == true) { - /* do nothing */ - return; - } - - if (event->button() == Qt::LeftButton) { - if (grabPos != QPoint(-1, -1)) { - if (rubberBand != NULL) { - rubberBand->hide(); - } - - /* toggle */ - MainWindow *win = ((MainWindow *)parent->parent()); - win->getUIState()->conState.recentlyFloatPos = event->globalPos() - eventPos; - - win->openController(win->getUIState()->conState.conFormIndex, -1); - return; - } - } -} - -void DockingConView::mouseMoveEvent(QMouseEvent *event) -{ - QGraphicsView::mouseMoveEvent(event); - - if (bezelItem->isHWKeyHandling() == true) { - /* do nothing */ - return; - } - - if (grabPos != QPoint(-1, -1) && rubberBand != NULL) { - rubberBand->setGeometry( - QRect(rubberPos + (event->globalPos() - grabPos), size())); - } -} - -QList DockingConView::getKeyList() -{ - return keyList; -} - -DockingConView::~DockingConView() -{ - qDebug("destroy docking controller view"); - - if (rubberBand != NULL) { - rubberBand->close(); - delete rubberBand; - rubberBand = NULL; - } -} diff --git a/tizen/src/ui/dockingconview.h b/tizen/src/ui/dockingconview.h deleted file mode 100644 index 9579b46cad..0000000000 --- a/tizen/src/ui/dockingconview.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#ifndef DOCKINGCONVIEW_H -#define DOCKINGCONVIEW_H - -#include - -#include "skinview.h" -#include "skinbezelitem.h" -#include "controllerform.h" - -class DockingController; - -class DockingConView : public QGraphicsView -{ -public: - DockingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent = 0); - ~DockingConView(); - QList getKeyList(); - -protected: - void resizeEvent(QResizeEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - - QPoint grabPos; - QPoint eventPos; - QPoint rubberPos; - -private: - void createItems(ControllerForm *conForm); - - DockingController *parent; - SkinBezelItem *bezelItem; - QRubberBand *rubberBand; - QList keyList; -}; - -#endif // DOCKINGCONVIEW_H diff --git a/tizen/src/ui/floatingcontroller.cpp b/tizen/src/ui/floatingcontroller.cpp deleted file mode 100644 index 23aff1e8ad..0000000000 --- a/tizen/src/ui/floatingcontroller.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#include "floatingcontroller.h" -#include "mainwindow.h" - -FloatingController::FloatingController(ControllerForm *conForm, - QAction *menu, QWidget *parent) : QDialog(parent) -{ - this->conForm = conForm; - this->menu = menu; - - setStyleSheet("border-style: none"); - setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog); - setAttribute(Qt::WA_DeleteOnClose); - - setWindowTitle(conForm->getName()); - - QHBoxLayout *layout = new QHBoxLayout(this); - layout->setMargin(0); - layout->setSpacing(0); - - QGraphicsScene *conScene = new QGraphicsScene(this); - conScene->setBackgroundBrush(Qt::black); - - conView = new FloatingConView(conForm, conScene, this); - conView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - layout->addWidget(conView); -} - -FloatingConView *FloatingController::getConView() -{ - return conView; -} - -void FloatingController::showEvent(QShowEvent *event) -{ - if (menu != NULL) { - menu->setChecked(true); - } - - setRegion(&(conForm->conImg[ControllerForm::normal])); -} - -void FloatingController::closeEvent(QCloseEvent *event) { - if (menu != NULL) { - menu->setChecked(false); - } - - MainWindow *win = ((MainWindow *)this->parent()); - win->getUIState()->conState.floatingCon = NULL; -} - -void FloatingController::setRegion(QImage *baseImage) -{ - qDebug("set region"); - - if (baseImage->isNull() == true) { - qWarning("invalid image for region"); - return; - } - - setMask(QRegion(QBitmap::fromImage(baseImage->createAlphaMask()))); -} - -FloatingController::~FloatingController() -{ - qDebug("destroy floating controller"); -} diff --git a/tizen/src/ui/floatingcontroller.h b/tizen/src/ui/floatingcontroller.h deleted file mode 100644 index d9e7bf50c0..0000000000 --- a/tizen/src/ui/floatingcontroller.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#ifndef FLOATINGCONTROLLER_H -#define FLOATINGCONTROLLER_H - -#include - -#include "controllerform.h" -#include "floatingconview.h" - -class FloatingController : public QDialog -{ - Q_OBJECT - -public: - explicit FloatingController(ControllerForm *conForm, QAction *menu, QWidget *parent = 0); - ~FloatingController(); - - FloatingConView *getConView(); - -protected: - void showEvent(QShowEvent *event); - void closeEvent(QCloseEvent *event); - - void setRegion(QImage *baseImage); - -private: - FloatingConView *conView; - ControllerForm *conForm; - QAction *menu; -}; - -#endif // FLOATINGCONTROLLER_H diff --git a/tizen/src/ui/floatingconview.cpp b/tizen/src/ui/floatingconview.cpp deleted file mode 100644 index 28bb576d6b..0000000000 --- a/tizen/src/ui/floatingconview.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#include "floatingconview.h" -#include "mainwindow.h" -#include "skinkeyitem.h" -#include "controller/generalpurposecon.h" - -#define DOCKABLE_AREA_WIDTH 30 - -FloatingConView::FloatingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent) - : QGraphicsView(scene, parent) -{ - this->parent = (FloatingController *)parent; - - setStyleSheet("background: transparent"); - setStyleSheet("border-style: none"); - - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setAlignment(Qt::AlignLeft | Qt::AlignTop); - - conPos = QPoint(-1, -1); - grabPos = QPoint(-1, -1); - rubberBand = new QRubberBand(QRubberBand::Rectangle, NULL); - - createItems(conForm); -} - -void FloatingConView::createItems(ControllerForm *conForm) -{ - /* bezel */ - bezelItem = new SkinBezelItem(conForm->conImg[ControllerForm::normal]); - scene()->addItem(bezelItem); - - /* HW keys */ - keyList = conForm->keyList; - - if (conForm->isGeneralPurpose() == false) { - HardwareKey *hwKey = NULL; - for (int i = 0; i < keyList.count(); i++) { - hwKey = keyList.at(i); - if (hwKey != NULL) { - new SkinKeyItem(bezelItem, hwKey, - conForm->conImg[ControllerForm::pressed].copy(hwKey->region), - conForm->getHoverType()); - } - } - } else { - GeneralPurposeCon *generalCon = new GeneralPurposeCon(this, keyList, - QSize(conForm->centerRect.width(), - conForm->centerRect.height() - (GPC_HEAD_SPACING + GPC_TAIL_SPACING))); - scene()->addWidget(generalCon); - - QPoint topLeft = conForm->centerRect.topLeft(); - generalCon->move(topLeft.x(), topLeft.y() + GPC_HEAD_SPACING); - } -} - -void FloatingConView::resizeEvent(QResizeEvent *event) -{ - //qDebug("resize con view"); - - Q_UNUSED(event) -} - -int FloatingConView::isDockable(QWidget *object, QWidget *subject) -{ - const int heightOneThird = object->size().height() / 3; - - /* MainWindow */ - QRect rectDockableRC(object->pos().x() + object->size().width() - 1, - object->pos().y() + heightOneThird, - DOCKABLE_AREA_WIDTH, - heightOneThird); - - QRect rectDockableRT(object->pos().x() + object->size().width() - 1, - object->pos().y(), - DOCKABLE_AREA_WIDTH, - heightOneThird); - - QRect rectDockableRB(object->pos().x() + object->size().width() - 1, - object->pos().y() + (heightOneThird * 2), - DOCKABLE_AREA_WIDTH, - heightOneThird); - - /* ControllerWidget */ - QRect rectTarget(subject->pos().x() - 1, - subject->pos().y(), - DOCKABLE_AREA_WIDTH, - subject->size().height()); - - // 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; -} - -void FloatingConView::mousePressEvent(QMouseEvent *event) -{ - QGraphicsView::mousePressEvent(event); - - if (bezelItem->isHWKeyHandling() == true) { - /* do nothing */ - return; - } - - if (event->button() == Qt::LeftButton) { - grabPos = event->globalPos(); - conPos = parent->pos(); - } -} - -void FloatingConView::mouseReleaseEvent(QMouseEvent *event) -{ - QGraphicsView::mouseReleaseEvent(event); - - if (bezelItem->isHWKeyHandling() == true) { - /* do nothing */ - return; - } - - if (event->button() == Qt::LeftButton) { - grabPos = QPoint(-1, -1); - if (rubberBand != NULL) { - rubberBand->hide(); - } - } - - const FloatingController *con = parent; - MainWindow *win = ((MainWindow *)con->parent()); - - int dockPos = isDockable((QWidget *)win, (QWidget *)parent); - if (dockPos != -1) { - /* toggle */ - win->openController(win->getUIState()->conState.conFormIndex, dockPos); - return; - } -} - -void FloatingConView::mouseMoveEvent(QMouseEvent *event) -{ - QGraphicsView::mouseMoveEvent(event); - - if (bezelItem->isHWKeyHandling() == 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)); - } -} - -QList FloatingConView::getKeyList() -{ - return keyList; -} - -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 deleted file mode 100644 index 164e964433..0000000000 --- a/tizen/src/ui/floatingconview.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#ifndef FLOATINGCONVIEW_H -#define FLOATINGCONVIEW_H - -#include - -#include "skinview.h" -#include "skinbezelitem.h" -#include "controllerform.h" - -class FloatingController; - -class FloatingConView : public QGraphicsView -{ -public: - FloatingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent = 0); - ~FloatingConView(); - QList getKeyList(); - -protected: - void resizeEvent(QResizeEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - - int isDockable(QWidget *object, QWidget *subject); - - QPoint grabPos; - QPoint conPos; - -private: - void createItems(ControllerForm *conForm); - - FloatingController *parent; - SkinBezelItem *bezelItem; - QRubberBand *rubberBand; - QList keyList; -}; - -#endif // FLOATINGCONVIEW_H diff --git a/tizen/src/ui/mainwindow.h b/tizen/src/ui/mainwindow.h index cd31462264..93fdc31524 100644 --- a/tizen/src/ui/mainwindow.h +++ b/tizen/src/ui/mainwindow.h @@ -41,8 +41,8 @@ #include "displaybase.h" #include "skinbezelitem.h" #include "uiinformation.h" -#include "dockingcontroller.h" -#include "floatingcontroller.h" +#include "controller/dockingcontroller.h" +#include "controller/floatingcontroller.h" #include "keyboardshortcut.h" extern "C" { diff --git a/tizen/src/ui/uistate.h b/tizen/src/ui/uistate.h index a77e9c507d..9d0bf0dbe9 100644 --- a/tizen/src/ui/uistate.h +++ b/tizen/src/ui/uistate.h @@ -30,8 +30,8 @@ #ifndef UISTATE_H #define UISTATE_H -#include "dockingcontroller.h" -#include "floatingcontroller.h" +#include "controller/dockingcontroller.h" +#include "controller/floatingcontroller.h" class ControllerState {