summaryrefslogtreecommitdiff
path: root/tizen/src
diff options
context:
space:
mode:
authorjihye <jihye424.kim@samsung.com>2017-03-11 15:58:19 +0900
committerjihye <jihye424.kim@samsung.com>2017-03-16 16:48:04 +0900
commit17a357d0327ebf0e8db43005ddc1fd0d4a1cf9b8 (patch)
tree76f911c1d229dd5ec23d96c931b31097c1070b3a /tizen/src
parentcc120344667f04d4f9dd72a1edc7425351e2f902 (diff)
downloadqemu-17a357d0327ebf0e8db43005ddc1fd0d4a1cf9b8.tar.gz
qemu-17a357d0327ebf0e8db43005ddc1fd0d4a1cf9b8.tar.bz2
qemu-17a357d0327ebf0e8db43005ddc1fd0d4a1cf9b8.zip
skin: control size of controller window
- if increases the number of buttons, window extended horizontally Change-Id: Ib21c19ca3ff0bed6c53bc127b31eada4dd4d48a1 Signed-off-by: jihye <jihye424.kim@samsung.com>
Diffstat (limited to 'tizen/src')
-rw-r--r--tizen/src/ui/controller/dockingconview.cpp2
-rw-r--r--tizen/src/ui/controller/floatingconview.cpp2
-rw-r--r--tizen/src/ui/controller/generalpurposecon.cpp42
-rw-r--r--tizen/src/ui/controller/generalpurposecon.h5
-rw-r--r--tizen/src/ui/layout/controllerform.cpp10
-rw-r--r--tizen/src/ui/layout/controllerform.h4
-rw-r--r--tizen/src/ui/skinpainter.cpp75
-rw-r--r--tizen/src/ui/skinpainter.h8
-rw-r--r--tizen/src/ui/xmllayoutparser.cpp58
9 files changed, 88 insertions, 118 deletions
diff --git a/tizen/src/ui/controller/dockingconview.cpp b/tizen/src/ui/controller/dockingconview.cpp
index d1e336c1fe..a37507c3dd 100644
--- a/tizen/src/ui/controller/dockingconview.cpp
+++ b/tizen/src/ui/controller/dockingconview.cpp
@@ -70,7 +70,7 @@ void DockingConView::createItems(ControllerForm *conForm)
generalCon->createHeaderBarAndBorder(scene(), parent->getMainWindow()->getUiInfo(), false);
QList<HWKeyButton *> buttons
- = generalCon->createButtons(parentWidget(), conForm);
+ = generalCon->createButtons(scene(), parentWidget(), conForm);
for (int i = 0; i < buttons.count(); i++) {
HWKeyButton *button = buttons.at(i);
diff --git a/tizen/src/ui/controller/floatingconview.cpp b/tizen/src/ui/controller/floatingconview.cpp
index 277e3f1b49..1e1429379a 100644
--- a/tizen/src/ui/controller/floatingconview.cpp
+++ b/tizen/src/ui/controller/floatingconview.cpp
@@ -70,7 +70,7 @@ void FloatingConView::createItems(ControllerForm *conForm)
generalCon->createHeaderBarAndBorder(scene(), parent->getMainWindow()->getUiInfo(), true);
QList<HWKeyButton *> buttons
- = generalCon->createButtons(parentWidget(), conForm);
+ = generalCon->createButtons(scene(), parentWidget(), conForm);
for (int i = 0; i < buttons.count(); i++) {
HWKeyButton *button = buttons.at(i);
diff --git a/tizen/src/ui/controller/generalpurposecon.cpp b/tizen/src/ui/controller/generalpurposecon.cpp
index 9a5c31e4cf..5c7efbc149 100644
--- a/tizen/src/ui/controller/generalpurposecon.cpp
+++ b/tizen/src/ui/controller/generalpurposecon.cpp
@@ -27,6 +27,7 @@
*
*/
+#include <math.h>
#include "config-host.h"
#include "generalpurposecon.h"
@@ -58,7 +59,7 @@ void GeneralPurposeCon::createHeaderBarAndBorder(QGraphicsScene *scene, UiInform
}
}
-QList<HWKeyButton *> GeneralPurposeCon::createButtons(QWidget *parent, ControllerForm *form)
+QList<HWKeyButton *> GeneralPurposeCon::createButtons(QGraphicsScene *scene, QWidget *parent, ControllerForm *form)
{
QPoint topLeft = form->getCenteralRect().topLeft();
topLeft.setX(topLeft.x() + GPC_LEFT_SPACING + GPC_BORDER_SIZE);
@@ -67,32 +68,49 @@ QList<HWKeyButton *> GeneralPurposeCon::createButtons(QWidget *parent, Controlle
QList<HWKeyButton *> buttonList;
// H/W key list
- createKeyList(parent, form->getKeyList(), topLeft, buttonList);
+ createKeyList(parent, form->getKeyList(), topLeft, form->getRowCount(), buttonList);
topLeft.setY(topLeft.y()
- + (GPC_KEYBUTTON_VSPACING + GPC_KEYBUTTON_HEIGHT) * form->getKeyList().count());
+ + (GPC_KEYBUTTON_HEIGHT + GPC_KEYBUTTON_VSPACING) * form->getRowCount());
// Menu key list
for (int i = 0; i < form->getSubFormList().count(); i++) {
+ // draw separator
+ QPen borderPen(QColor(153, 153, 153), 1, Qt::SolidLine);
+ scene->addLine(0, topLeft.y() - (GPC_KEYBUTTON_VSPACING / 2),
+ form->getCenteralRect().width() - GPC_BORDER_SIZE,
+ topLeft.y() - (GPC_KEYBUTTON_VSPACING / 2), borderPen);
+ //
ControllerForm *subForm = form->getSubFormList().at(i);
- createKeyList(parent, subForm->getKeyList(), topLeft, buttonList);
+ createKeyList(parent, subForm->getKeyList(), topLeft, subForm->getRowCount(), buttonList);
topLeft.setY(topLeft.y()
- + (GPC_KEYBUTTON_VSPACING + GPC_KEYBUTTON_HEIGHT) * subForm->getKeyList().count());
+ + (GPC_KEYBUTTON_HEIGHT + GPC_KEYBUTTON_VSPACING) * form->getRowCount());
}
return buttonList;
}
void GeneralPurposeCon::createKeyList(QWidget *parent, QList<HardwareKey *> keyList,
- QPoint topLeft, QList<HWKeyButton *> &buttonList)
+ QPoint topLeft, int count, QList<HWKeyButton *> &buttonList)
{
+ if (count == 0) {
+ return;
+ }
+
HardwareKey *hwKey = NULL;
HWKeyButton *keyButton = NULL;
- for (int i = 0; i < keyList.count(); i++) {
- hwKey = keyList.at(i);
- if (hwKey != NULL) {
+ int index = 0;
+ int loop = ceil(keyList.count() / (float) count);
+
+ for (int c = 0; c < loop; c++) {
+ for (int i = 0; i < count && index < keyList.count(); i++) {
+ hwKey = keyList.at(index++);
+ if (hwKey == NULL) {
+ continue;
+ }
+
keyButton = new HWKeyButton(parent, hwKey,
- QSize(GPC_KEYBUTTON_WIDTH, GPC_KEYBUTTON_HEIGHT));
+ QSize(GPC_KEYBUTTON_WIDTH, GPC_KEYBUTTON_HEIGHT));
QString tooltip = hwKey->getTooltip();
if (tooltip.isEmpty() == true) {
if (hwKey->getKeySequence().isEmpty() == false) {
@@ -104,8 +122,8 @@ void GeneralPurposeCon::createKeyList(QWidget *parent, QList<HardwareKey *> keyL
}
keyButton->setToolTip(hwKey->getName() + " " + tooltip);
- keyButton->move(topLeft.x(), topLeft.y()
- + (GPC_KEYBUTTON_VSPACING + GPC_KEYBUTTON_HEIGHT) * i);
+ keyButton->move(topLeft.x() + (GPC_KEYBUTTON_WIDTH + GPC_KEYBUTTON_HSPACING) * c,
+ topLeft.y() + (GPC_KEYBUTTON_HEIGHT + GPC_KEYBUTTON_VSPACING) * i);
buttonList.append(keyButton);
}
}
diff --git a/tizen/src/ui/controller/generalpurposecon.h b/tizen/src/ui/controller/generalpurposecon.h
index 8dfb18dd0e..fe319e5d6f 100644
--- a/tizen/src/ui/controller/generalpurposecon.h
+++ b/tizen/src/ui/controller/generalpurposecon.h
@@ -44,6 +44,7 @@
#define GPC_KEYBUTTON_HEIGHT (35)
#define GPC_KEYBUTTON_VSPACING (15)
#define GPC_KEYBUTTON_HSPACING (15)
+#define GPC_MINIUM_HEIGHT (272)
class GeneralPurposeCon
{
@@ -52,10 +53,10 @@ public:
GeneralPurposeCon();
~GeneralPurposeCon();
void createHeaderBarAndBorder(QGraphicsScene *scene, UiInformation *uiInfo, bool isFloating);
- QList<HWKeyButton *> createButtons(QWidget *parent, ControllerForm *form);
+ QList<HWKeyButton *> createButtons(QGraphicsScene *scene, QWidget *parent, ControllerForm *form);
private:
- void createKeyList(QWidget *parent, QList<HardwareKey *> keyList, QPoint topLeft, QList<HWKeyButton *> &buttonList);
+ void createKeyList(QWidget *parent, QList<HardwareKey *> keyList, QPoint topLeft, int count, QList<HWKeyButton *> &buttonList);
};
#endif // GENERALPURPOSECON_H
diff --git a/tizen/src/ui/layout/controllerform.cpp b/tizen/src/ui/layout/controllerform.cpp
index fffcf4d625..96e8712034 100644
--- a/tizen/src/ui/layout/controllerform.cpp
+++ b/tizen/src/ui/layout/controllerform.cpp
@@ -49,6 +49,16 @@ QList<ControllerForm *> &ControllerForm::getSubFormList()
return subFormList;
}
+int ControllerForm::getRowCount()
+{
+ return rowCount;
+}
+
+void ControllerForm::setRowCount(int count)
+{
+ rowCount = count;
+}
+
ControllerForm::~ControllerForm()
{
qDebug("destroy con layout");
diff --git a/tizen/src/ui/layout/controllerform.h b/tizen/src/ui/layout/controllerform.h
index 9cb3b4fc05..8be3e4eb58 100644
--- a/tizen/src/ui/layout/controllerform.h
+++ b/tizen/src/ui/layout/controllerform.h
@@ -46,7 +46,11 @@ public:
QRect getCenteralRect();
QList<ControllerForm *> &getSubFormList();
+ int getRowCount();
+ void setRowCount(int count);
+
private:
+ int rowCount; // for general purpose skin
QRect centeralRect;
QList<ControllerForm *> subFormList;
};
diff --git a/tizen/src/ui/skinpainter.cpp b/tizen/src/ui/skinpainter.cpp
index 3ee51ed84d..5428c170db 100644
--- a/tizen/src/ui/skinpainter.cpp
+++ b/tizen/src/ui/skinpainter.cpp
@@ -33,22 +33,12 @@
#include "skinpainter.h"
#include "resource/ui_strings.h"
-#define COLOR_TAG_SIZE (4)
-
-SkinPainter::SkinPainter(const QString &patchPath,
- QSize centerPatch, int degree, QPoint tagLeftTop, QColor tagColor)
-{
- QString path = ":/images/" + patchPath + "/";
-
- drawSkin(path, centerPatch, degree, tagLeftTop, tagColor);
-}
-
-SkinPainter::SkinPainter(QSize centerPatch, int degree, QList<Separator *> separators)
+SkinPainter::SkinPainter(QSize centerPatch, int degree)
{
- drawSkin(centerPatch, degree, separators);
+ drawSkin(centerPatch, degree);
}
-void SkinPainter::drawSkin(QSize center, int degree, QList<Separator *> separators) {
+void SkinPainter::drawSkin(QSize center, int degree) {
qDebug() << "draw skin surface";
QRect centeralRect(0, 0, center.width(), center.height());
@@ -58,13 +48,6 @@ void SkinPainter::drawSkin(QSize center, int degree, QList<Separator *> separato
QPainter painter(&image);
painter.fillRect(centeralRect, QBrush(QColor(244, 244, 244)));
- // add separators
- for (int i = 0; i < separators.count(); i++) {
- Separator *s = separators.at(i);
- painter.setPen(s->pen);
- painter.drawLine(0, s->hOffset, center.width(), s->hOffset);
- }
-
/* rotate */
QTransform transform;
skin = new QPixmap(image.transformed(transform.rotate(degree)));
@@ -73,58 +56,6 @@ void SkinPainter::drawSkin(QSize center, int degree, QList<Separator *> separato
transform.mapRect(centeralRect).size());
}
-void SkinPainter::drawSkin(QString patchPath, QSize center, int degree,
- QPoint tagLeftTop, QColor tagColor)
-{
- qDebug() << "load skin patches from:" << patchPath;
-
- QImage LT(patchPath + GENERAL_SKIN_LEFTTOP_FILE);
- QImage LC(patchPath + GENERAL_SKIN_LEFTCENTER_FILE);
- QImage LB(patchPath + GENERAL_SKIN_LEFTBOTTOM_FILE);
- QImage TC(patchPath + GENERAL_SKIN_TOPCENTER_FILE);
- QImage BC(patchPath + GENERAL_SKIN_BOTTOMCENTER_FILE);
- QImage RT(patchPath + GENERAL_SKIN_RIGHTTOP_FILE);
- QImage RC(patchPath + GENERAL_SKIN_RIGHTCENTER_FILE);
- QImage RB(patchPath + GENERAL_SKIN_RIGHTBOTTOM_FILE);
-
- QRect centeralRect0(LT.width(), LT.height(), center.width(), center.height());
-
- QPixmap image(center.width() + (LT.width() * 2),
- center.height() + (LT.height() * 2));
- image.fill(Qt::transparent);
-
- QPainter painter(&image);
-
- /* top side */
- painter.drawImage(0, 0, LT);
- 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(), center.height()), LC);
- painter.fillRect(centeralRect0, QBrush(QColor(38, 38, 38)));
- painter.drawImage(QRect(
- center.width() + LT.width(), LT.height(), RT.width(), center.height()), RC);
-
- /* bottom side */
- 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);
-
- /* color tag */
- painter.setPen(tagColor);
- painter.setBrush(QBrush(tagColor));
- painter.drawEllipse(tagLeftTop, COLOR_TAG_SIZE, COLOR_TAG_SIZE);
-
- /* rotate */
- QTransform transform;
- skin = new QPixmap(image.transformed(transform.rotate(degree)));
-
- centeralRect = QRect(
- centeralRect0.topLeft(), transform.mapRect(centeralRect0).size());
-}
-
QImage SkinPainter::getSkinImage() const
{
return skin->toImage();
diff --git a/tizen/src/ui/skinpainter.h b/tizen/src/ui/skinpainter.h
index 03e91fc781..8b5adad5ce 100644
--- a/tizen/src/ui/skinpainter.h
+++ b/tizen/src/ui/skinpainter.h
@@ -43,18 +43,14 @@ struct Separator
class SkinPainter
{
public:
- SkinPainter(const QString &patchPath, QSize centerPatch, int degree,
- QPoint tagLeftTop, QColor tagColor);
- SkinPainter(QSize centerPatch, int degree, QList<Separator *> separators);
+ SkinPainter(QSize centerPatch, int degree);
~SkinPainter();
QImage getSkinImage() const;
QRect getCenteralRect();
private:
- void drawSkin(QString patchPath, QSize center, int degree,
- QPoint tagLeftTop, QColor tagColor);
- void drawSkin(QSize center, int degree, QList<Separator *> separators);
+ void drawSkin(QSize center, int degree);
QPixmap *skin;
QRect centeralRect;
diff --git a/tizen/src/ui/xmllayoutparser.cpp b/tizen/src/ui/xmllayoutparser.cpp
index c2c4b20c78..9664e3bb58 100644
--- a/tizen/src/ui/xmllayoutparser.cpp
+++ b/tizen/src/ui/xmllayoutparser.cpp
@@ -28,6 +28,7 @@
*
*/
+#include <math.h>
#include "config-host.h"
#include "xmllayoutparser.h"
@@ -379,9 +380,8 @@ int XmlLayoutParser::parseMainFormList(QXmlStreamReader &xml,
/* image validation */
if (form->skinImg[LayoutForm::normal].size() == QSize(0, 0)) {
QDEBUG_INDENT(depth + 1) << "(general purpose skin type)";
- QList<Separator *> list;
SkinPainter painter(uiInfo->getResolution(),
- form->getDpyType()->getAngle(), list);
+ form->getDpyType()->getAngle());
form->setGeneralPurpose(true);
form->skinImg[LayoutForm::normal] = painter.getSkinImage();
@@ -800,34 +800,44 @@ QString XmlLayoutParser::parseControllerUI(QXmlStreamReader &xml)
void XmlLayoutParser::makeGeneralCon(ControllerForm *form)
{
- int keyCount = form->getKeyList().count();
+ int skinHeight = uiInfo->getResolution().height() / 2;
+ if (skinHeight < GPC_MINIUM_HEIGHT) {
+ skinHeight = GPC_MINIUM_HEIGHT;
+ } else {
+ // TODO: neet to determine extra space size.
+ // add extra space to the controller relative to several button size or height.
+ skinHeight += (GPC_KEYBUTTON_HEIGHT + GPC_KEYBUTTON_VSPACING) * 3;
+ }
+
+ int hOffset = GPC_HEAD_SPACING + GPC_BORDER_SIZE + GPC_TAIL_SPACING;
+
+ int conWidth = GPC_BORDER_SIZE * 2;
+ int conHeight = 0;
+ int columnCount = 0;
+ int keyCount = 0;
+
+ do {
+ columnCount++;
- int width = GPC_KEYBUTTON_WIDTH + GPC_KEYBUTTON_HSPACING + GPC_BORDER_SIZE * 2;
- int height = GPC_HEAD_SPACING + GPC_BORDER_SIZE;
- height += (GPC_KEYBUTTON_HEIGHT * keyCount) +
+ conWidth += (GPC_KEYBUTTON_WIDTH + GPC_KEYBUTTON_HSPACING);
+ conHeight = hOffset;
+
+ keyCount = ceil(form->getKeyList().count() / (float)columnCount);
+ form->setRowCount(keyCount);
+ conHeight += (GPC_KEYBUTTON_HEIGHT * keyCount) +
(GPC_KEYBUTTON_VSPACING * (keyCount - 1));
- // add sub form
- QList<Separator *> sList;
- QPen pen(QColor(205, 205, 205), 1, Qt::SolidLine);
- for (int i = 0; i < form->getSubFormList().count(); i++) {
- // for separator
- Separator *s = new Separator();
- s->pen = pen;
- s->hOffset = height + GPC_KEYBUTTON_VSPACING / 2;
- sList.append(s);
-
- ControllerForm *subForm = form->getSubFormList().at(i);
- keyCount = subForm->getKeyList().count();
-
- height += (GPC_KEYBUTTON_HEIGHT * keyCount) +
- (GPC_KEYBUTTON_VSPACING * keyCount);
- }
+ for (int i = 0; i < form->getSubFormList().count(); i++) {
+ ControllerForm *subForm = form->getSubFormList().at(i);
- height += GPC_TAIL_SPACING;
+ keyCount = ceil(subForm->getKeyList().count() / (float) columnCount);
+ subForm->setRowCount(keyCount);
+ conHeight += (GPC_KEYBUTTON_HEIGHT + GPC_KEYBUTTON_VSPACING) * keyCount;
+ }
- SkinPainter painter(QSize(width, qMax(height, QT_LAYOUT_MINIMUM - 20)), 0, sList);
+ } while (skinHeight < conHeight);
+ SkinPainter painter(QSize(conWidth, qMax(conHeight, QT_LAYOUT_MINIMUM - 20)), 0);
form->skinImg[LayoutForm::normal] = painter.getSkinImage();
form->setCenteralRect(painter.getCenteralRect());
form->setGeneralPurpose(true);