controller: consider the key button count
authorGiWoong Kim <giwoong.kim@samsung.com>
Mon, 6 Apr 2015 10:25:19 +0000 (19:25 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Tue, 7 Apr 2015 07:16:07 +0000 (16:16 +0900)
General purpose skin considers the button layout
having less than four button conunt.
1. fit to content's size
2. no need to create a  vertical scrollbar
And remove unnecessary function calls.

Change-Id: Ia92ca6e7a7c89274a38c30830723f4f850abceb2
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/display/xmllayoutparser.cpp
tizen/src/ui/controller/dockingcontroller.cpp
tizen/src/ui/controller/dockingconview.cpp
tizen/src/ui/controller/floatingcontroller.cpp
tizen/src/ui/controller/floatingcontroller.h
tizen/src/ui/controller/floatingconview.cpp
tizen/src/ui/controller/generalpurposecon.cpp

index c37456da15675b9d7e95b06ef57ca957536d911d..1b69eb078fc82154bf54a3bb23ced93283e9334b 100644 (file)
@@ -48,6 +48,9 @@
 #define SHORTCUT_KEYWORD "shortcut"
 #define MENULIST_KEYWORD "menuList"
 
+/* Qt Qlayout has a minimum size */
+#define QT_LAYOUT_MINIMUM (73)
+
 XmlLayoutParser::XmlLayoutParser(QString path, UIInformation *uiInfo)
 {
     this->xmlPath = path;
@@ -632,11 +635,25 @@ QString XmlLayoutParser::parseControllerUI(QXmlStreamReader &xml)
                     if (form->conImg[ControllerForm::normal].size() == QSize(0, 0)) {
                         qDebug("general purpose con form");
 
-                        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))), 0,
-                            QPoint(GPC_SCROLLBAR_WIDTH, GPC_HEAD_SPACING - 1), uiInfo->getVMColor());
+                        int keyCount = form->keyList.count();
+
+                        int width = GPC_KEYBUTTON_WIDTH;
+                        int height = GPC_HEAD_SPACING;
+                        if (keyCount < GPC_KEYBUTTON_DEFAULT_CNT) {
+                            height += (GPC_KEYBUTTON_HEIGHT * keyCount) +
+                                (GPC_KEYBUTTON_VSPACING * (keyCount - 1)) +
+                                GPC_TAIL_SPACING;
+                        } else {
+                            width += (GPC_SCROLLBAR_WIDTH + GPC_SCROLLBAR_HSPACING);
+                            height += (GPC_KEYBUTTON_HEIGHT * GPC_KEYBUTTON_DEFAULT_CNT) +
+                                (GPC_KEYBUTTON_VSPACING * (GPC_KEYBUTTON_DEFAULT_CNT - 1)) +
+                                GPC_TAIL_SPACING;
+                        }
+
+                        SkinPainter painter("controller-skin",
+                            QSize(width, qMax(height, QT_LAYOUT_MINIMUM - 20)),
+                            0, QPoint(14, GPC_HEAD_SPACING - 1),
+                            uiInfo->getVMColor());
                         form->setGeneralPurpose(true);
 
                         form->conImg[ControllerForm::normal] = painter.getSkinImage();
index de5a135d04ad8d125151b52101e69dd50f876b1a..a4414e6ace69a3290622d77db495e65b9422a480 100644 (file)
@@ -70,13 +70,17 @@ int DockingController::getDockPos()
     return dockPos;
 }
 
+/* override */
 void DockingController::showEvent(QShowEvent *event)
 {
     if (menu != NULL) {
         menu->setChecked(true);
     }
+
+    QWidget::showEvent(event);
 }
 
+/* override */
 void DockingController::closeEvent(QCloseEvent *event) {
     if (menu != NULL) {
         menu->setChecked(false);
@@ -84,6 +88,8 @@ void DockingController::closeEvent(QCloseEvent *event) {
 
     MainWindow *win = ((MainWindow *)this->parent());
     win->getUIState()->conState.dockingCon = NULL;
+
+    QWidget::closeEvent(event);
 }
 
 DockingController::~DockingController()
index 02ae4c203e2e22b647ed04e81809d6d553e3d09e..a73a9c954b100dcc75b7e17bedd2243a6ba1ba88 100644 (file)
@@ -73,8 +73,7 @@ void DockingConView::createItems(ControllerForm *conForm)
     } else {
         GeneralPurposeCon *generalCon = new GeneralPurposeCon(this, keyList,
             QSize(conForm->centerRect.width(),
-                conForm->centerRect.height() - (GPC_HEAD_SPACING + GPC_TAIL_SPACING)));
-        scene()->addWidget(generalCon);
+                conForm->centerRect.height() - GPC_HEAD_SPACING));
 
         QPoint topLeft = conForm->centerRect.topLeft();
         generalCon->move(topLeft.x(), topLeft.y() + GPC_HEAD_SPACING);
index 23aff1e8ad8786a4fe802ba5cc879a2ef7bddd99..46afedee4a0aa7492852be1090f96d8be131e27f 100644 (file)
@@ -59,15 +59,32 @@ FloatingConView *FloatingController::getConView()
     return conView;
 }
 
+/* override */
 void FloatingController::showEvent(QShowEvent *event)
 {
     if (menu != NULL) {
         menu->setChecked(true);
     }
 
-    setRegion(&(conForm->conImg[ControllerForm::normal]));
+    QImage *baseImage = &(conForm->conImg[ControllerForm::normal]);
+    if (baseImage->isNull() == true) {
+        qWarning("invalid image for region");
+    } else {
+        setMask(QRegion(QBitmap::fromImage(baseImage->createAlphaMask())));
+    }
+
+    QWidget::showEvent(event);
+}
+
+/* override */
+void FloatingController::setMask(const QRegion &region)
+{
+    if (region.isEmpty() == false) {
+        QWidget::setMask(region);
+    }
 }
 
+/* override */
 void FloatingController::closeEvent(QCloseEvent *event) {
     if (menu != NULL) {
         menu->setChecked(false);
@@ -75,18 +92,8 @@ void FloatingController::closeEvent(QCloseEvent *event) {
 
     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())));
+    QWidget::closeEvent(event);
 }
 
 FloatingController::~FloatingController()
index d9e7bf50c0d21510b41647b77a7389ea0b8d806e..24aabab9574d364a0c457a56b8fb9acec469b1af 100644 (file)
@@ -47,10 +47,9 @@ public:
 
 protected:
     void showEvent(QShowEvent *event);
+    void setMask(const QRegion &region);
     void closeEvent(QCloseEvent *event);
 
-    void setRegion(QImage *baseImage);
-
 private:
     FloatingConView *conView;
     ControllerForm *conForm;
index cf2b78e4257fc92fa42e3113d6aa3b316ef9818a..a4630a727f999f92ecf2a6c344c45cd6d8c9c975 100644 (file)
@@ -76,7 +76,6 @@ void FloatingConView::createItems(ControllerForm *conForm)
         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);
index e800b598fbc498190f6ae372245be24ff04b33e7..1357c40c9092d2baeff009aaa75549b744bcc426 100644 (file)
@@ -27,6 +27,8 @@
  *
  */
 
+#include "config-host.h"
+
 #include "generalpurposecon.h"
 #include "hwkeybutton.h"
 
@@ -44,7 +46,13 @@ void GeneralPurposeCon::createItems(QList<HardwareKey *> keyList, QSize size)
 
     QVBoxLayout *layout = new QVBoxLayout(buttonGroup);
     layout->setMargin(0);
+
+#ifndef CONFIG_DARWIN
     layout->setSpacing(GPC_KEYBUTTON_VSPACING);
+#else
+    /* need more spacing on MacOS */
+    layout->setSpacing(GPC_KEYBUTTON_VSPACING + 11);
+#endif
 
     HardwareKey *hwKey = NULL;
     HWKeyButton *keyButton = NULL;
@@ -70,7 +78,7 @@ void GeneralPurposeCon::createItems(QList<HardwareKey *> keyList, QSize size)
             "margin: 14px 2px 14px 2px;"
             "background-color: QLinearGradient(x1: 1, y1: 0, x2: 0, y2: 0," +
             "stop: 0 #3C3C3C, stop: 1 #737373);"
-            "border-radius: 2px;"
+            "border-radius: 3px;"
         "}"
         "QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {"
             "background: none;"