Modified dragging area restrictions for IndicatorButton and ZoomButtonPanel
authorPekka Nissinen <pekka.nissinen@ixonos.com>
Thu, 5 Aug 2010 12:06:40 +0000 (15:06 +0300)
committerPekka Nissinen <pekka.nissinen@ixonos.com>
Thu, 5 Aug 2010 12:06:40 +0000 (15:06 +0300)
src/ui/indicatorbutton.cpp
src/ui/indicatorbutton.h
src/ui/listcommon.h
src/ui/zoombuttonpanel.cpp

index f6c2aeb..7c699ee 100644 (file)
@@ -1,23 +1,23 @@
 /*
-   Situare - A location system for Facebook
-   Copyright (C) 2010  Ixonos Plc. Authors:
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
 
-       Kaj Wallin - kaj.wallin@ixonos.com
-       Katri Kaikkonen - katri.kaikkonen@ixonos.com
+        Kaj Wallin - kaj.wallin@ixonos.com
+        Katri Kaikkonen - katri.kaikkonen@ixonos.com
 
-   Situare is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License
-   version 2 as published by the Free Software Foundation.
+    Situare is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    version 2 as published by the Free Software Foundation.
 
-   Situare 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.
+    Situare 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 Situare; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
-   USA.
+    You should have received a copy of the GNU General Public License
+    along with Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
 */
 
 #include <QDebug>
@@ -122,10 +122,10 @@ void IndicatorButton::mouseMoveEvent(QMouseEvent *event)
         if (event->buttons() & Qt::LeftButton) {
             QPoint newLocation = mapToParent(event->pos()) - m_dragPosition;
 
-            if (newLocation.x() < SIDEBAR_WIDTH)
-                newLocation.rx() = SIDEBAR_WIDTH;
-             else if (newLocation.x() > m_screenSize.width() - width() - SIDEBAR_WIDTH)
-                newLocation.rx() =  m_screenSize.width() - width() - SIDEBAR_WIDTH;
+            if (newLocation.x() < 0)
+                newLocation.rx() = 0;
+            else if (newLocation.x() > m_screenSize.width() - width() - PANEL_PEEK_AMOUNT)
+                newLocation.rx() =  m_screenSize.width() - width() - PANEL_PEEK_AMOUNT;
 
             if (newLocation.y() < 0)
                 newLocation.ry() = 0;
@@ -202,14 +202,16 @@ void IndicatorButton::screenResized(const QSize &newSize)
     m_screenSize = newSize;
 
     QPoint resizedPosition = pos();
-    if(resizedPosition.x() > (newSize.width() - rect().width()))
+
+    if (resizedPosition.x() < 0)
+        resizedPosition.rx() = 0;
+    else if(resizedPosition.x() > (newSize.width() - rect().width()))
         resizedPosition.rx() = newSize.width() - rect().width();
-    else if (resizedPosition.x() < SIDEBAR_WIDTH)
-        resizedPosition.rx() = SIDEBAR_WIDTH;
-    if(resizedPosition.y() > (newSize.height() - rect().height()))
-        resizedPosition.ry() = newSize.height() - rect().height();
-    else if (resizedPosition.y() < 0)
+
+    if (resizedPosition.y() < 0)
         resizedPosition.ry() = 0;
+    else if(resizedPosition.y() > (newSize.height() - rect().height()))
+        resizedPosition.ry() = newSize.height() - rect().height();
 
     if((pos().y() + rect().center().y()) > (oldHeight/2))
         resizedPosition.ry() = newSize.height() - (oldHeight - pos().y());
index 4dc31f7..f8e737c 100644 (file)
@@ -26,7 +26,6 @@
 #include <QMouseEvent>
 #include <QTimer>
 #include <QToolButton>
-#include <QWidget>
 
 /**
  * @brief Indicator button class
index 17338cc..dd6dbc0 100644 (file)
@@ -38,14 +38,14 @@ const int MARGIN = 5;           ///< Text and image margin
 *
 * @brief Name label's maximum width
 */
-const int NAME_LABEL_MAX_WIDTH = ITEM_WIDTH - 3*MARGIN - IMAGE_WIDTH;
+const int NAME_LABEL_MAX_WIDTH = ITEM_WIDTH - 3 * MARGIN - IMAGE_WIDTH;
 
 /**
 * @var LABEL_MAX_WIDTH
 *
 * @brief All label's maximum width
 */
-const int LABEL_MAX_WIDTH = ITEM_WIDTH - 3 * MARGIN - IMAGE_WIDTH - MARGIN - ICON_WIDTH - MARGIN*2;
+const int LABEL_MAX_WIDTH = ITEM_WIDTH - 3 * MARGIN - IMAGE_WIDTH - MARGIN - ICON_WIDTH - MARGIN * 2;
 
 const int NAME_DISPLAY_INDEX = Qt::DisplayRole;
 const int AVATAR_IMAGE_INDEX = Qt::DecorationRole;
index de96043..64ea554 100644 (file)
@@ -95,10 +95,10 @@ void ZoomButtonPanel::mouseMoveEvent(QMouseEvent *event)
         if (event->buttons() & Qt::LeftButton) {
             QPoint newLocation = mapToParent(event->pos()) - m_dragPosition;
 
-            if (newLocation.x() < SIDEBAR_WIDTH)
-                newLocation.rx() = SIDEBAR_WIDTH;
-            else if (newLocation.x() > m_screenSize.width() - width() - SIDEBAR_WIDTH)
-                newLocation.rx() =  m_screenSize.width() - width() - SIDEBAR_WIDTH;
+            if (newLocation.x() < 0)
+                newLocation.rx() = 0;
+            else if (newLocation.x() > m_screenSize.width() - width() - PANEL_PEEK_AMOUNT)
+                newLocation.rx() =  m_screenSize.width() - width() - PANEL_PEEK_AMOUNT;
 
             if (newLocation.y() < 0)
                 newLocation.ry() = 0;
@@ -253,16 +253,17 @@ void ZoomButtonPanel::screenResized(const QSize &newSize)
     m_screenSize = newSize;
 
     QPoint resizedPosition = pos();
-    
-    if(resizedPosition.x() > (newSize.width() - rect().width()))
+
+    if(resizedPosition.x() < 0)
+        resizedPosition.rx() = 0;
+    else if(resizedPosition.x() > (newSize.width() - rect().width()))
         resizedPosition.rx() = newSize.width() - rect().width();
-    else if (resizedPosition.x() < SIDEBAR_WIDTH)
-        resizedPosition.rx() = SIDEBAR_WIDTH;
-    
-    if(resizedPosition.y() > (newSize.height() - rect().height()))
-        resizedPosition.ry() = newSize.height() - rect().height();
-    else if (resizedPosition.y() < 0)
+
+    if(resizedPosition.y() < 0)
         resizedPosition.ry() = 0;
+    else if(resizedPosition.y() > (newSize.height() - rect().height()))
+        resizedPosition.ry() = newSize.height() - rect().height();
+
 
     if((pos().y() + rect().center().y()) > (oldHeight/2))
         resizedPosition.ry() = newSize.height() - (oldHeight - pos().y());