make slider orientation configurable into 4 directions
authorFelix Domke <tmbinc@elitedvb.net>
Mon, 19 Jan 2009 11:55:27 +0000 (12:55 +0100)
committerFelix Domke <tmbinc@elitedvb.net>
Mon, 19 Jan 2009 12:41:59 +0000 (13:41 +0100)
lib/gui/eslider.cpp
lib/gui/eslider.h
skin.py

index dd2aac9e73c329b9f3eb64ad73ae30c84263719b..c8b467c9a5231fbaa73b0eaf9cad89daaa4c45b1 100644 (file)
@@ -70,10 +70,14 @@ int eSlider::event(int event, void *data, void *data2)
 
                if (m_min < m_max)
                {
-                       num_pix = pixsize * (m_value - m_start) / (m_max - m_min);
-                       start_pix = pixsize * m_start / (m_max - m_min);
+                       int val_range = m_max - m_min;
+                       num_pix = (pixsize * (m_value - m_start) + val_range - 1) / val_range; /* properly round up */
+                       start_pix = (pixsize * m_start + val_range - 1) / val_range;
+
+                       if (m_orientation_swapped)
+                               start_pix = pixsize - num_pix - start_pix;
                }
-               
+
                if  (start_pix < 0)
                {
                        num_pix += start_pix;
@@ -113,9 +117,10 @@ void eSlider::setStartEnd(int start, int end)
        event(evtChangedSlider);
 }
 
-void eSlider::setOrientation(int orientation)
+void eSlider::setOrientation(int orientation, int swapped)
 {
        m_orientation = orientation;
+       m_orientation_swapped = swapped;
        event(evtChangedSlider);
 }
 
index c544072650a1ad2b1ce3ccb300536133a193f120..9a3e8395ca4809e73e2147bf3dd0d2c00eefaf3a 100644 (file)
@@ -11,7 +11,7 @@ public:
        void setStartEnd(int start, int end);
        void setRange(int min, int max);
        enum { orHorizontal, orVertical };
-       void setOrientation(int orientation);
+       void setOrientation(int orientation, int swapped = 0);
        void setBorderWidth(int pixel);
        void setBorderColor(const gRGB &color);
        void setPixmap(gPixmap *pixmap);
@@ -24,7 +24,7 @@ private:
                evtChangedSlider = evtUserWidget
        };
        bool m_have_border_color;
-       int m_min, m_max, m_value, m_start, m_orientation, m_border_width;
+       int m_min, m_max, m_value, m_start, m_orientation, m_orientation_swapped, m_border_width;
        ePtr<gPixmap> m_pixmap;
        
        gRegion m_currently_filled;
diff --git a/skin.py b/skin.py
index 97954715c4d94f6a1f765cfb4ec708f8aa88f8d0..dd10790580300f74a7f656aae06d2dc814e0441b 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -145,9 +145,13 @@ def applySingleAttribute(guiObject, desktop, attrib, value, scale = ((1,1),(1,1)
                                }[value])
                elif attrib == "orientation": # used by eSlider
                        try:
-                               guiObject.setOrientation(
-                                       { "orVertical": guiObject.orVertical,
-                                               "orHorizontal": guiObject.orHorizontal
+                               guiObject.setOrientation(*
+                                       { "orVertical": (guiObject.orVertical, False),
+                                               "orTopToBottom": (guiObject.olVertical, False),
+                                               "orBottomToTop": (guiObject.orVertical, True),
+                                               "orHorizontal": (guiObject.orHorizontal, False),
+                                               "orLeftToRight": (guiObject.orHorizontal, False),
+                                               "orRightToRight": (guiObject.orHorizontal, True),
                                        }[value])
                        except KeyError:
                                print "oprientation must be either orVertical or orHorizontal!"