ui: add general purpose skin for QT UI
authorGiWoong Kim <giwoong.kim@samsung.com>
Fri, 13 Mar 2015 06:28:11 +0000 (15:28 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Thu, 26 Mar 2015 07:08:55 +0000 (16:08 +0900)
Change-Id: I2b7297231e5ae664a5c6f32a9447b44476f0ddba
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
18 files changed:
tizen/src/display/xmllayoutparser.cpp
tizen/src/ui/Makefile.objs
tizen/src/ui/resource/images/main-skin/BC.png [new file with mode: 0644]
tizen/src/ui/resource/images/main-skin/LB.png [new file with mode: 0644]
tizen/src/ui/resource/images/main-skin/LC.png [new file with mode: 0644]
tizen/src/ui/resource/images/main-skin/LT.png [new file with mode: 0644]
tizen/src/ui/resource/images/main-skin/RB.png [new file with mode: 0644]
tizen/src/ui/resource/images/main-skin/RC.png [new file with mode: 0644]
tizen/src/ui/resource/images/main-skin/RT.png [new file with mode: 0644]
tizen/src/ui/resource/images/main-skin/TC.png [new file with mode: 0644]
tizen/src/ui/resource/images/main-skin/arrow_hover.png [new file with mode: 0644]
tizen/src/ui/resource/images/main-skin/arrow_normal.png [new file with mode: 0644]
tizen/src/ui/resource/images/main-skin/arrow_pushed.png [new file with mode: 0644]
tizen/src/ui/resource/mobile-general-3btn/info.ini [new file with mode: 0644]
tizen/src/ui/resource/mobile-general-3btn/layout.xml [new file with mode: 0644]
tizen/src/ui/resource/resource.qrc
tizen/src/ui/skinpainter.cpp [new file with mode: 0644]
tizen/src/ui/skinpainter.h [new file with mode: 0644]

index e1accfc..e0e8ed1 100644 (file)
@@ -28,6 +28,7 @@
  */
 
 #include "xmllayoutparser.h"
+#include "skinpainter.h"
 
 #define NAME_ATTR_KEYWORD "name"
 #define PROP_ATTR_KEYWORD "property"
@@ -182,9 +183,7 @@ MainForm *XmlLayoutParser::parseMainForm(QXmlStreamReader &xml)
                 QString normalImageFileName = xml.readElementText();
                 qDebug() << "- normalImage :" << normalImageFileName;
 
-                if (normalImageFileName.isEmpty() == true) {
-                    // TODO: general purpose skin
-                } else if (form->skinImg[MainForm::normal].load(
+                if (form->skinImg[MainForm::normal].load(
                     xmlPath + QDir::separator() + normalImageFileName) == false) {
                     qWarning() << "failed to load normal image";
                 }
@@ -230,6 +229,15 @@ int XmlLayoutParser::parseMainFormList(
             if (xml.name() == FORM_KEYWORD) {
                 form = parseMainForm(xml);
                 if (form != NULL) {
+                    if (form->skinImg[MainForm::normal].size() == QSize(0, 0)) {
+                        qDebug("general purpose skin form");
+
+                        SkinPainter skinPainter("main-skin",
+                            form->displayType->region.width(), form->displayType->region.height());
+                        form->skinImg[MainForm::normal] = skinPainter.getSkinImage();
+                        form->displayType->region.translate(skinPainter.getDisplayRect().topLeft());
+                    }
+
                     list.append(form);
                 }
             }
index a798bd3..e9f8bf7 100644 (file)
@@ -22,6 +22,7 @@ obj-$(CONFIG_QT) += mainform.o
 obj-$(CONFIG_QT) += keyboardhelper.o
 obj-$(CONFIG_QT) += keyboardshortcut.o moc_keyboardshortcut.o
 obj-$(CONFIG_QT) += skinview.o
+obj-$(CONFIG_QT) += skinpainter.o
 obj-$(CONFIG_QT) += uiinformation.o
 obj-$(CONFIG_QT) += uistate.o
 obj-$(CONFIG_QT) += uiutil.o
diff --git a/tizen/src/ui/resource/images/main-skin/BC.png b/tizen/src/ui/resource/images/main-skin/BC.png
new file mode 100644 (file)
index 0000000..fc512a1
Binary files /dev/null and b/tizen/src/ui/resource/images/main-skin/BC.png differ
diff --git a/tizen/src/ui/resource/images/main-skin/LB.png b/tizen/src/ui/resource/images/main-skin/LB.png
new file mode 100644 (file)
index 0000000..6e4775a
Binary files /dev/null and b/tizen/src/ui/resource/images/main-skin/LB.png differ
diff --git a/tizen/src/ui/resource/images/main-skin/LC.png b/tizen/src/ui/resource/images/main-skin/LC.png
new file mode 100644 (file)
index 0000000..33e409c
Binary files /dev/null and b/tizen/src/ui/resource/images/main-skin/LC.png differ
diff --git a/tizen/src/ui/resource/images/main-skin/LT.png b/tizen/src/ui/resource/images/main-skin/LT.png
new file mode 100644 (file)
index 0000000..ed6dd3d
Binary files /dev/null and b/tizen/src/ui/resource/images/main-skin/LT.png differ
diff --git a/tizen/src/ui/resource/images/main-skin/RB.png b/tizen/src/ui/resource/images/main-skin/RB.png
new file mode 100644 (file)
index 0000000..64533f7
Binary files /dev/null and b/tizen/src/ui/resource/images/main-skin/RB.png differ
diff --git a/tizen/src/ui/resource/images/main-skin/RC.png b/tizen/src/ui/resource/images/main-skin/RC.png
new file mode 100644 (file)
index 0000000..edd377d
Binary files /dev/null and b/tizen/src/ui/resource/images/main-skin/RC.png differ
diff --git a/tizen/src/ui/resource/images/main-skin/RT.png b/tizen/src/ui/resource/images/main-skin/RT.png
new file mode 100644 (file)
index 0000000..eb4210f
Binary files /dev/null and b/tizen/src/ui/resource/images/main-skin/RT.png differ
diff --git a/tizen/src/ui/resource/images/main-skin/TC.png b/tizen/src/ui/resource/images/main-skin/TC.png
new file mode 100644 (file)
index 0000000..bf81220
Binary files /dev/null and b/tizen/src/ui/resource/images/main-skin/TC.png differ
diff --git a/tizen/src/ui/resource/images/main-skin/arrow_hover.png b/tizen/src/ui/resource/images/main-skin/arrow_hover.png
new file mode 100644 (file)
index 0000000..f3f5565
Binary files /dev/null and b/tizen/src/ui/resource/images/main-skin/arrow_hover.png differ
diff --git a/tizen/src/ui/resource/images/main-skin/arrow_normal.png b/tizen/src/ui/resource/images/main-skin/arrow_normal.png
new file mode 100644 (file)
index 0000000..6012237
Binary files /dev/null and b/tizen/src/ui/resource/images/main-skin/arrow_normal.png differ
diff --git a/tizen/src/ui/resource/images/main-skin/arrow_pushed.png b/tizen/src/ui/resource/images/main-skin/arrow_pushed.png
new file mode 100644 (file)
index 0000000..75c3908
Binary files /dev/null and b/tizen/src/ui/resource/images/main-skin/arrow_pushed.png differ
diff --git a/tizen/src/ui/resource/mobile-general-3btn/info.ini b/tizen/src/ui/resource/mobile-general-3btn/info.ini
new file mode 100644 (file)
index 0000000..59ea685
--- /dev/null
@@ -0,0 +1,4 @@
+skin.name=General purpose mobile
+resolution.width=all
+resolution.height=all
+manager.priority=2
diff --git a/tizen/src/ui/resource/mobile-general-3btn/layout.xml b/tizen/src/ui/resource/mobile-general-3btn/layout.xml
new file mode 100644 (file)
index 0000000..3af033f
--- /dev/null
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<EmulatorUI xmlns="http://www.tizen.org/emulator/ui/layout">
+    <layoutVersion>2.4</layoutVersion>
+    <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>
+    </formList>
+
+    <menuList>
+        <infoItem>
+            <shortcut>Ctrl+F1</shortcut>
+        </infoItem>
+        <separator/>
+        <onTopItem name="Always on Top">
+            <shortcut>Ctrl+F2</shortcut>
+        </onTopItem>
+        <switchItem name="Rotate">
+            <shortcut property="prev">Ctrl+Num+7</shortcut>
+            <shortcut property="next">Ctrl+Num+9</shortcut>
+        </switchItem>
+        <scaleItem name="Scale">
+            <shortcut property="prev">Ctrl+F9</shortcut>
+            <shortcut property="next">Ctrl+F10</shortcut>
+            <factorList>
+                <factor name="1x">100</factor>
+                <factor name="3/4x">75</factor>
+                <factor name="1/2x">50</factor>
+                <factor name="1/4x">25</factor>
+            </factorList>
+        </scaleItem>
+        <separator/>
+        <advancedItem>
+            <menuList>
+                <screenShotItem name="Screen Shot">
+                    <shortcut>Ctrl+F7</shortcut>
+                </screenShotItem>
+                <hostKeyboardItem name="Host Keyboard">
+                </hostKeyboardItem>
+                <separator/>
+                <aboutItem name="About"/>
+                <forceCloseItem name="Force Close">
+                    <shortcut>Ctrl+F4</shortcut>
+                </forceCloseItem>
+            </menuList>
+        </advancedItem>
+        <controllerItem/>
+        <shellItem name="Shell">
+            <shortcut>Ctrl+F5</shortcut>
+        </shellItem>
+        <controlPanelItem name="Control Panel">
+            <shortcut>Ctrl+F6</shortcut>
+        </controlPanelItem>
+        <separator/>
+        <closeItem name="Close">
+            <shortcut>F4</shortcut>
+        </closeItem>
+    </menuList>
+
+</EmulatorUI>
index 34e2982..6fba2c1 100644 (file)
@@ -3,6 +3,18 @@
         <file>images/tizen_sdk.png</file>
         <file>images/display_off_guide.png</file>
 
+        <file>images/main-skin/arrow_normal.png</file>
+        <file>images/main-skin/arrow_hover.png</file>
+        <file>images/main-skin/arrow_pushed.png</file>
+        <file>images/main-skin/LT.png</file>
+        <file>images/main-skin/LC.png</file>
+        <file>images/main-skin/LB.png</file>
+        <file>images/main-skin/TC.png</file>
+        <file>images/main-skin/BC.png</file>
+        <file>images/main-skin/RT.png</file>
+        <file>images/main-skin/RC.png</file>
+        <file>images/main-skin/RB.png</file>
+
         <file>icons/emulator_icon.ico</file>
         <file>icons/shell.png</file>
         <file>icons/about.png</file>
diff --git a/tizen/src/ui/skinpainter.cpp b/tizen/src/ui/skinpainter.cpp
new file mode 100644 (file)
index 0000000..2051698
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * 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 <QPainter>
+#include <QDebug>
+
+#include "skinpainter.h"
+
+SkinPainter::SkinPainter(QString patchPath,
+    unsigned int displayWidth, unsigned int displayHeight)
+{
+    QString path = ":/images/" + patchPath + "/";
+
+    drawSkinPatch(path, displayWidth, displayHeight);
+}
+
+void SkinPainter::drawSkinPatch(QString patchPath,
+    unsigned int displayWidth, unsigned int displayHeight)
+{
+    qDebug() << "load skin patch from :" << patchPath;
+
+    QImage LT(patchPath + "LT.png");
+    QImage LC(patchPath + "LC.png");
+    QImage LB(patchPath + "LB.png");
+    QImage TC(patchPath + "TC.png");
+    QImage BC(patchPath + "BC.png");
+    QImage RT(patchPath + "RT.png");
+    QImage RC(patchPath + "RC.png");
+    QImage RB(patchPath + "RB.png");
+
+    displayRect.setRect(LT.width(), LT.height(), displayWidth, displayHeight);
+
+    skin = new QPixmap(displayWidth + (LT.width() * 2), displayHeight + (LT.height() * 2));
+    skin->fill(Qt::transparent);
+
+    QPainter painter(skin);
+
+    /* top side */
+    painter.drawImage(0, 0, LT);
+    painter.drawImage(QRect(LT.width(), 0, displayWidth, LT.height()), TC);
+    painter.drawImage(displayWidth + LT.width(), 0, RT);
+
+    /* middle side */
+    painter.drawImage(QRect(0, LT.height(), LT.width(), displayHeight), LC);
+    painter.fillRect(displayRect, Qt::SolidPattern);
+    painter.drawImage(QRect(displayWidth + LT.width(), LT.height(), RT.width(), displayHeight), 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);
+}
+
+QImage SkinPainter::getSkinImage()
+{
+    return skin->toImage();
+}
+
+QRect SkinPainter::getDisplayRect()
+{
+    return displayRect;
+}
diff --git a/tizen/src/ui/skinpainter.h b/tizen/src/ui/skinpainter.h
new file mode 100644 (file)
index 0000000..437089e
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * 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 SKINPAINTER_H
+#define SKINPAINTER_H
+
+#include <QWidget>
+
+#include "displaytype.h"
+
+class SkinPainter
+{
+public:
+    SkinPainter(QString patchPath,
+        unsigned int displayWidth, unsigned int displayHeight);
+
+    QImage getSkinImage();
+    QRect getDisplayRect();
+
+private:
+    void drawSkinPatch(QString patchPath,
+        unsigned int displayWidth, unsigned int displayHeight);
+
+    QPixmap *skin;
+    QRect displayRect;
+};
+
+#endif // SKINPAINTER_H