ui: consider custom resolution for general purpose skin
authorGiWoong Kim <giwoong.kim@samsung.com>
Thu, 26 Mar 2015 13:10:56 +0000 (22:10 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Mon, 30 Mar 2015 01:54:19 +0000 (10:54 +0900)
Change-Id: I8327117494c2046ea24b9a007d442b5c11e47bcd
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/display/xmllayoutparser.cpp
tizen/src/ui/displaybase.cpp
tizen/src/ui/displaytype.cpp
tizen/src/ui/displaytype.h
tizen/src/ui/mainwindow.cpp
tizen/src/ui/mainwindow.h
tizen/src/ui/resource/skins/mobile-general-3btn/layout.xml
tizen/src/ui/skinpainter.cpp
tizen/src/ui/skinpainter.h
tizen/src/ui/uiinformation.cpp

index 8daf965..e2e1fd8 100644 (file)
@@ -286,13 +286,14 @@ int XmlLayoutParser::parseMainFormList(
             if (xml.name() == FORM_KEYWORD) {
                 form = parseMainForm(xml);
                 if (form != NULL) {
+                    /* image validation */
                     if (form->skinImg[MainForm::normal].size() == QSize(0, 0)) {
                         qDebug("general purpose skin form");
 
                         SkinPainter painter("main-skin",
-                            form->displayType->region.width(), form->displayType->region.height());
+                            uiInfo->resolution, form->displayType->getAngle());
                         form->skinImg[MainForm::normal] = painter.getSkinImage();
-                        form->displayType->region.translate(painter.getCenterRect().topLeft());
+                        form->displayType->setRect(painter.getCenterRect());
                         form->setGeneralPurpose(true);
                     }
 
@@ -625,13 +626,15 @@ QString XmlLayoutParser::parseControllerUI(QXmlStreamReader &xml)
             } else if (xml.name() == FORM_KEYWORD) {
                 form = parseControllerForm(xml);
                 if (form != NULL) {
+                    /* image validation */
                     if (form->conImg[ControllerForm::normal].size() == QSize(0, 0)) {
                         qDebug("general purpose con form");
 
-                        SkinPainter painter("controller-skin",
+                        SkinPainter painter("controller-skin", QSize(
                             GPC_KEYBUTTON_WIDTH + (GPC_SCROLLBAR_WIDTH + GPC_SCROLLBAR_HSPACING),
                             GPC_HEAD_SPACING + (GPC_KEYBUTTON_HEIGHT * GPC_KEYBUTTON_DEFAULT_CNT) +
-                            (GPC_KEYBUTTON_VSPACING * (GPC_KEYBUTTON_DEFAULT_CNT - 1)));
+                            (GPC_KEYBUTTON_VSPACING * (GPC_KEYBUTTON_DEFAULT_CNT - 1))),
+                            0);
                         form->conImg[ControllerForm::normal] = painter.getSkinImage();
                         form->centerRect = painter.getCenterRect();
                         form->setGeneralPurpose(true);
index 964f773..782b1c0 100644 (file)
@@ -96,10 +96,10 @@ void DisplayBase::handleResize(QResizeEvent *event)
     const qreal sx = scaleFactor;
     const qreal sy = scaleFactor;
 
-    widget->setGeometry(form->displayType->region.x() * sx,
-        form->displayType->region.y() * sy,
-        form->displayType->region.width() * sx,
-        form->displayType->region.height() * sy);
+    widget->setGeometry(form->displayType->getRect().x() * sx,
+        form->displayType->getRect().y() * sy,
+        form->displayType->getRect().width() * sx,
+        form->displayType->getRect().height() * sy);
 
     qt5_window_width = widget->width();
     qt5_window_height = widget->height();
index 90a708f..97073cf 100644 (file)
 
 #include "displaytype.h"
 
-DisplayType::DisplayType(QRect region, int angle)
+DisplayType::DisplayType(QRect rect, int angle)
 {
-    this->region = region;
+    this->rect = rect;
     this->angle = angle;
 }
 
+void DisplayType::setRect(QRect rect)
+{
+    this->rect = rect;
+}
+
+QRect DisplayType::getRect()
+{
+    return rect;
+}
+
 int DisplayType::getAngle()
 {
     return angle % 360;
index 7e2bb35..edfb59a 100644 (file)
 class DisplayType
 {
 public:
-    DisplayType(QRect region, int angle);
+    DisplayType(QRect rect, int angle);
     ~DisplayType();
 
+    void setRect(QRect rect);
+    QRect getRect();
     int getAngle();
 
-    QRect region;
-
 private:
+    QRect rect;
     int angle;
 };
 
index b649e07..a76a560 100644 (file)
@@ -86,10 +86,8 @@ MainWindow::MainWindow(UIInformation *uiInfo, QWidget *parent)
     /* windowing */
     setWindowTitle("Emulator");
     setWindowIcon(QIcon(QPixmap(":/icons/emulator_icon.ico")));
-
-    //setStyleSheet("background:transparent;");
-    //setAttribute(Qt::WA_TranslucentBackground);
     setWindowFlags(Qt::FramelessWindowHint);
+    setMinimumSize(0, 0);
 
     winLayout = new QHBoxLayout(this);
     winLayout->setMargin(0);
@@ -162,13 +160,17 @@ MainWindow::MainWindow(UIInformation *uiInfo, QWidget *parent)
 
 void MainWindow::startSwapper()
 {
-    QMetaObject::invokeMethod(swapper, "display", Qt::QueuedConnection);
+    if (swapper != NULL) {
+        QMetaObject::invokeMethod(swapper, "display", Qt::QueuedConnection);
+    }
 }
 
 void MainWindow::terminateSwapper()
 {
-    swapper->setTerminating();
-    qt5_graphic_hw_invalidate();
+    if (swapper != NULL) {
+        swapper->setTerminating();
+        qt5_graphic_hw_invalidate();
+    }
 }
 
 QLabel *MainWindow::getScreenWidget()
@@ -312,19 +314,21 @@ void MainWindow::closeController()
     keyboardShortcut->removeControllerShortcut();
 }
 
+/* override */
 void MainWindow::resizeEvent(QResizeEvent *event)
 {
     qDebug("resize main window");
 
     resize(uiInfo->getUiSize());
 
-    setRegion();
+    setMask(uiInfo->getUiRegion());
 }
 
-void MainWindow::setRegion()
+/* override */
+void MainWindow::setMask(const QRegion &region)
 {
-    if (uiInfo->getUiRegion().isEmpty() == false) {
-        setMask(uiInfo->getUiRegion());
+    if (region.isEmpty() == false) {
+        QWidget::setMask(region);
     }
 }
 
index 94714c5..cd31462 100644 (file)
@@ -99,10 +99,9 @@ public slots:
 
 protected:
     void resizeEvent(QResizeEvent *event);
+    void setMask(const QRegion &region);
     void closeEvent(QCloseEvent *);
 
-    void setRegion();
-
     QLabel *screenWidget;
 
 private:
index 8f6b2a7..9ba5dd1 100644 (file)
@@ -4,25 +4,21 @@
     <formList>
         <form name="Portrait">
             <display>
-                <region left="0" top="0" width="720" height="1280"/>
                 <angle>0</angle>
             </display>
         </form>
         <form name="Landscape">
             <display>
-                <region left="0" top="0" width="1280" height="720"/>
                 <angle>270</angle>
             </display>
         </form>
         <form name="Reverse Portrait">
             <display>
-                <region left="0" top="0" width="720" height="1280"/>
                 <angle>180</angle>
             </display>
         </form>
         <form name="Reverse Landscape">
             <display>
-                <region left="0" top="0" width="1280" height="720"/>
                 <angle>90</angle>
             </display>
         </form>
index 8a2ed0b..d09409f 100644 (file)
 
 #include "skinpainter.h"
 
-SkinPainter::SkinPainter(QString patchPath,
-    unsigned int displayWidth, unsigned int displayHeight)
+SkinPainter::SkinPainter(QString patchPath, QSize center, int degree)
 {
     QString path = ":/images/" + patchPath + "/";
 
-    drawSkinPatch(path, displayWidth, displayHeight);
+    drawSkin(path, center, degree);
 }
 
-void SkinPainter::drawSkinPatch(QString patchPath,
-    unsigned int displayWidth, unsigned int displayHeight)
+void SkinPainter::drawSkin(QString patchPath, QSize center, int degree)
 {
     qDebug() << "load skin patch from :" << patchPath;
 
@@ -54,27 +52,37 @@ void SkinPainter::drawSkinPatch(QString patchPath,
     QImage RC(patchPath + "RC.png");
     QImage RB(patchPath + "RB.png");
 
-    centerRect.setRect(LT.width(), LT.height(), displayWidth, displayHeight);
+    QRect centerRect0(LT.width(), LT.height(), center.width(), center.height());
 
-    skin = new QPixmap(displayWidth + (LT.width() * 2), displayHeight + (LT.height() * 2));
-    skin->fill(Qt::transparent);
+    QPixmap image(center.width() + (LT.width() * 2),
+        center.height() + (LT.height() * 2));
+    image.fill(Qt::transparent);
 
-    QPainter painter(skin);
+    QPainter painter(&image);
 
     /* top side */
     painter.drawImage(0, 0, LT);
-    painter.drawImage(QRect(LT.width(), 0, displayWidth, LT.height()), TC);
-    painter.drawImage(displayWidth + LT.width(), 0, RT);
+    painter.drawImage(QRect(LT.width(), 0, center.width(), LT.height()), TC);
+    painter.drawImage(center.width() + LT.width(), 0, RT);
 
     /* middle side */
-    painter.drawImage(QRect(0, LT.height(), LT.width(), displayHeight), LC);
-    painter.fillRect(centerRect, Qt::SolidPattern);
-    painter.drawImage(QRect(displayWidth + LT.width(), LT.height(), RT.width(), displayHeight), RC);
+    painter.drawImage(QRect(0, LT.height(), LT.width(), center.height()), LC);
+    painter.fillRect(centerRect0, Qt::SolidPattern);
+    painter.drawImage(QRect(
+        center.width() + LT.width(), LT.height(), RT.width(), center.height()), RC);
 
     /* bottom side */
-    painter.drawImage(0, displayHeight + LT.height(), LB);
-    painter.drawImage(QRect(LT.width(), displayHeight + LT.height(), displayWidth, LB.height()), BC);
-    painter.drawImage(displayWidth + LT.width(), displayHeight + LT.height(), RB);
+    painter.drawImage(0, center.height() + LT.height(), LB);
+    painter.drawImage(QRect(
+        LT.width(), center.height() + LT.height(), center.width(), LB.height()), BC);
+    painter.drawImage(center.width() + LT.width(), center.height() + LT.height(), RB);
+
+    /* rotate */
+    QMatrix matrix;
+    matrix.rotate(degree);
+    skin = new QPixmap(image.transformed(matrix));
+
+    centerRect = QRect(centerRect0.topLeft(), matrix.mapRect(centerRect0).size());
 }
 
 QImage SkinPainter::getSkinImage()
index 916ff2c..b524213 100644 (file)
 class SkinPainter
 {
 public:
-    SkinPainter(QString patchPath,
-        unsigned int displayWidth, unsigned int displayHeight);
+    SkinPainter(QString patchPath, QSize center, int degree);
 
     QImage getSkinImage();
     QRect getCenterRect();
 
 private:
-    void drawSkinPatch(QString patchPath,
-        unsigned int displayWidth, unsigned int displayHeight);
+    void drawSkin(QString patchPath, QSize center, int degree);
 
     QPixmap *skin;
     QRect centerRect;
index a60f0e1..17b5a50 100644 (file)
@@ -73,18 +73,7 @@ QSize UIInformation::getMainSize()
 {
     MainForm *mainForm = getMainForm();
     if (mainForm == NULL) {
-        qWarning("main form is null");
-        return QSize(100, 100);
-    }
-
-    if (mainForm->skinImg[MainForm::normal].size() == QSize(0, 0)) {
-        qWarning("invalid normal image size");
-
-        if (mainForm->displayType->region.size() == QSize(0, 0)) {
-            return QSize(100, 100);
-        } else {
-            return mainForm->displayType->region.size() * uiState.getScaleFactor();
-        }
+        qFatal("main form is null");
     }
 
     return mainForm->skinImg[MainForm::normal].size() * uiState.getScaleFactor();
@@ -109,6 +98,7 @@ QSize UIInformation::getUiSize()
     if (uiState.conState.dockingCon != NULL) {
         QSize conSize = getConSize();
         uiSize.setWidth(uiSize.width() + conSize.width());
+        uiSize.setHeight(qMax(uiSize.height(), conSize.height()));
     }
 
     return uiSize;