[vlc-commits] skins2: slider fix notifyLayout wrongly removed

Erwan Tulou git at videolan.org
Thu Apr 25 22:59:33 CEST 2013


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Thu Apr 25 22:42:36 2013 +0200| [6d2b8a0ae2cc8bce56a8fb0ae4456550b459b443] | committer: Erwan Tulou

skins2: slider fix notifyLayout wrongly removed

redefining notifyLayout is mandatory for sliders, because the default
notifyLayout based on position doesn't work well for this complicated control.
This function is called when visibility is turned on or off.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6d2b8a0ae2cc8bce56a8fb0ae4456550b459b443
---

 modules/gui/skins2/controls/ctrl_slider.cpp |   18 ++++++++++++++++++
 modules/gui/skins2/controls/ctrl_slider.hpp |    4 ++++
 2 files changed, 22 insertions(+)

diff --git a/modules/gui/skins2/controls/ctrl_slider.cpp b/modules/gui/skins2/controls/ctrl_slider.cpp
index 17c3b73..3d627d9 100644
--- a/modules/gui/skins2/controls/ctrl_slider.cpp
+++ b/modules/gui/skins2/controls/ctrl_slider.cpp
@@ -153,6 +153,24 @@ void CtrlSliderCursor::onResize()
 }
 
 
+void CtrlSliderCursor::notifyLayout( int width, int height,
+                                     int xOffSet, int yOffSet )
+{
+    if( width > 0 && height > 0 )
+    {
+        CtrlGeneric::notifyLayout( width, height, xOffSet, yOffSet );
+    }
+    else
+    {
+        onPositionChange();
+        const Position *pPos = getPosition();
+        CtrlGeneric::notifyLayout( m_lastCursorRect.width,
+                                   m_lastCursorRect.height,
+                                   m_lastCursorRect.x - pPos->getLeft(),
+                                   m_lastCursorRect.y - pPos->getTop() );
+    }
+}
+
 void CtrlSliderCursor::onUpdate( Subject<VarPercent> &rVariable, void *arg  )
 {
     (void)rVariable; (void)arg;
diff --git a/modules/gui/skins2/controls/ctrl_slider.hpp b/modules/gui/skins2/controls/ctrl_slider.hpp
index 0b4e069..4be24de 100644
--- a/modules/gui/skins2/controls/ctrl_slider.hpp
+++ b/modules/gui/skins2/controls/ctrl_slider.hpp
@@ -71,6 +71,10 @@ public:
     /// Method called when the control is resized
     virtual void onResize();
 
+    /// Method called to notify are to be updated
+    virtual void notifyLayout( int witdh = -1, int height = -1,
+                               int xOffSet = 0, int yOffSet = 0 );
+
     /// Get the text of the tooltip
     virtual UString getTooltipText() const { return m_tooltip; }
 



More information about the vlc-commits mailing list