]> git.sesse.net Git - vlc/commitdiff
* modules/gui/skins2/*: The second template argument of the Subject and
authorOlivier Teulière <ipkiss@videolan.org>
Sun, 4 Jun 2006 13:55:41 +0000 (13:55 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Sun, 4 Jun 2006 13:55:41 +0000 (13:55 +0000)
   Observer classes now has a default value. This simplifies the code in many
   places.

33 files changed:
modules/gui/skins2/controls/ctrl_button.cpp
modules/gui/skins2/controls/ctrl_button.hpp
modules/gui/skins2/controls/ctrl_checkbox.cpp
modules/gui/skins2/controls/ctrl_checkbox.hpp
modules/gui/skins2/controls/ctrl_generic.cpp
modules/gui/skins2/controls/ctrl_generic.hpp
modules/gui/skins2/controls/ctrl_list.cpp
modules/gui/skins2/controls/ctrl_list.hpp
modules/gui/skins2/controls/ctrl_radialslider.cpp
modules/gui/skins2/controls/ctrl_radialslider.hpp
modules/gui/skins2/controls/ctrl_slider.cpp
modules/gui/skins2/controls/ctrl_slider.hpp
modules/gui/skins2/controls/ctrl_text.cpp
modules/gui/skins2/controls/ctrl_text.hpp
modules/gui/skins2/controls/ctrl_tree.cpp
modules/gui/skins2/controls/ctrl_tree.hpp
modules/gui/skins2/controls/ctrl_video.cpp
modules/gui/skins2/controls/ctrl_video.hpp
modules/gui/skins2/src/anim_bitmap.hpp
modules/gui/skins2/src/generic_window.cpp
modules/gui/skins2/src/generic_window.hpp
modules/gui/skins2/src/tooltip.cpp
modules/gui/skins2/src/tooltip.hpp
modules/gui/skins2/utils/observer.hpp
modules/gui/skins2/utils/position.hpp
modules/gui/skins2/utils/var_bool.cpp
modules/gui/skins2/utils/var_bool.hpp
modules/gui/skins2/utils/var_list.hpp
modules/gui/skins2/utils/var_percent.hpp
modules/gui/skins2/utils/var_text.cpp
modules/gui/skins2/utils/var_text.hpp
modules/gui/skins2/vars/equalizer.cpp
modules/gui/skins2/vars/equalizer.hpp

index ca6f1dc3758e5bd7e090b6318cc06bb8935d5d7b..f379c40ac69b4152e45b3af42b16899c07b9fff4 100644 (file)
@@ -131,7 +131,7 @@ void CtrlButton::setImage( AnimBitmap *pImg )
 }
 
 
-void CtrlButton::onUpdate( Subject<AnimBitmap, void*> &rBitmap, void *arg )
+void CtrlButton::onUpdate( Subject<AnimBitmap> &rBitmap, void *arg )
 {
     notifyLayout();
 }
index b9c7efa75aa41b3d7dc3737640edde56916a365b..c315e2c7b0c4bd33336d1fb009234cc4a01e803f 100644 (file)
@@ -88,7 +88,7 @@ class CtrlButton: public CtrlGeneric, public Observer<AnimBitmap, void*>
         void setImage( AnimBitmap *pImg );
 
         /// Method called when an animated bitmap changes
-        virtual void onUpdate( Subject<AnimBitmap, void*> &rBitmap, void* );
+        virtual void onUpdate( Subject<AnimBitmap> &rBitmap, void* );
 };
 
 
index 358289001ca4d3d694a0bac88c5b88296144b0ff..89c2c57ea21d749d140acc92466d7dd452299adb 100644 (file)
@@ -246,7 +246,7 @@ void CtrlCheckbox::onVarBoolUpdate( VarBool &rVariable )
 }
 
 
-void CtrlCheckbox::onUpdate( Subject<AnimBitmap, void*> &rBitmap, void *arg )
+void CtrlCheckbox::onUpdate( Subject<AnimBitmap> &rBitmap, void *arg )
 {
     notifyLayout();
 }
index 10eeefc0b911fefa5eb66adc22d1c4c8fae29b18..d6c2bdf29b307ae582c9adb523aefae8763bf8f5 100644 (file)
@@ -109,7 +109,7 @@ class CtrlCheckbox: public CtrlGeneric, public Observer<AnimBitmap, void*>
         virtual void onVarBoolUpdate( VarBool &rVariable );
 
         /// Method called when an animated bitmap changes
-        virtual void onUpdate( Subject<AnimBitmap, void*> &rBitmap, void* );
+        virtual void onUpdate( Subject<AnimBitmap> &rBitmap, void* );
 
         /// Change the current image
         void setImage( AnimBitmap *pImg );
index 60940d1cf8c4db86b76d66a2198ec006ce66e3f9..7d4796f8b6f0c2682aa21e758e9fbc26458789c5 100644 (file)
@@ -155,7 +155,7 @@ bool CtrlGeneric::isVisible() const
 }
 
 
-void CtrlGeneric::onUpdate( Subject<VarBool, void*> &rVariable, void *arg  )
+void CtrlGeneric::onUpdate( Subject<VarBool> &rVariable, void *arg  )
 {
     // Is it the visibility variable ?
     if( &rVariable == m_pVisible )
index ec134cd58427b670adbe8cf3fd348b1e3eb7509e..0889fa14bd19f4e5a55f958730fe8b59e082122a 100644 (file)
@@ -128,7 +128,7 @@ class CtrlGeneric: public SkinObject, public Observer<VarBool, void*>
         VarBool *m_pVisible;
 
         /// Method called when an observed bool variable is changed
-        virtual void onUpdate( Subject<VarBool, void*> &rVariable , void* );
+        virtual void onUpdate( Subject<VarBool> &rVariable , void* );
 };
 
 typedef CountedPtr<CtrlGeneric> CtrlGenericPtr;
index 0817451d14a7ab539075100217d0816340d2328c..7bf3feb83e762ecfe3ce8206dada6be4041472be 100644 (file)
@@ -72,14 +72,14 @@ CtrlList::~CtrlList()
 }
 
 
-void CtrlList::onUpdate( Subject<VarList, void*> &rList, void *arg  )
+void CtrlList::onUpdate( Subject<VarList> &rList, void *arg  )
 {
     autoScroll();
     m_pLastSelected = NULL;
 }
 
 
-void CtrlList::onUpdate( Subject<VarPercent, void*> &rPercent, void *arg  )
+void CtrlList::onUpdate( Subject<VarPercent> &rPercent, void *arg  )
 {
     // Get the size of the control
     const Position *pPos = getPosition();
index cf1d62e452f57bcf6970417759fbe134fd7cd436..fbbe458dd8b38c88be32ec28c271d2b3f0ac9e20 100644 (file)
@@ -88,10 +88,10 @@ class CtrlList: public CtrlGeneric, public Observer<VarList, void*>,
         int m_lastPos;
 
         /// Method called when the list variable is modified
-        virtual void onUpdate( Subject<VarList, void*> &rList, void* );
+        virtual void onUpdate( Subject<VarList> &rList, void* );
 
         /// Method called when the position variable of the list is modified
-        virtual void onUpdate( Subject<VarPercent, void*> &rPercent, void*  );
+        virtual void onUpdate( Subject<VarPercent> &rPercent, void*  );
 
         /// Called when the position is set
         virtual void onPositionChange();
index 817c66d09f468eaf17458e8ea909b0d296674971..b12a51da99ce3debc69ec3427d86f588d6217573 100644 (file)
@@ -98,7 +98,7 @@ void CtrlRadialSlider::draw( OSGraphics &rImage, int xDest, int yDest )
 }
 
 
-void CtrlRadialSlider::onUpdate( Subject<VarPercent,void*> &rVariable,
+void CtrlRadialSlider::onUpdate( Subject<VarPercent> &rVariable,
                                  void *arg  )
 {
     m_position = (int)( m_rVariable.get() * m_numImg );
index 8780ba364a2b2ba80e8abc1110fa9bb32e2fe4b2..26747189f96e03d45f5f4e6a1037db809a60fe0f 100644 (file)
@@ -86,7 +86,7 @@ class CtrlRadialSlider: public CtrlGeneric, public Observer<VarPercent, void*>
         DEFINE_CALLBACK( CtrlRadialSlider, Move )
 
         /// Method called when the observed variable is modified
-        virtual void onUpdate( Subject<VarPercent,void*> &rVariable, void* );
+        virtual void onUpdate( Subject<VarPercent> &rVariable, void* );
 
         /// Change the position of the cursor, with the given position of
         /// the mouse (relative to the layout). Is blocking is true, the
index 22ec20c360b9fcead78c3685f81041c4bb7eab57..d15631b209b0073b21359db35fcd9271df1fe70c 100644 (file)
@@ -159,7 +159,7 @@ void CtrlSliderCursor::draw( OSGraphics &rImage, int xDest, int yDest )
 }
 
 
-void CtrlSliderCursor::onUpdate( Subject<VarPercent,void*> &rVariable,
+void CtrlSliderCursor::onUpdate( Subject<VarPercent> &rVariable,
                                  void *arg  )
 {
     // The position has changed
@@ -426,7 +426,7 @@ void CtrlSliderBg::associateCursor( CtrlSliderCursor &rCursor )
 }
 
 
-void CtrlSliderBg::onUpdate( Subject<VarPercent, void*> &rVariable, void*arg )
+void CtrlSliderBg::onUpdate( Subject<VarPercent> &rVariable, void*arg )
 {
     m_position = (int)( m_rVariable.get() * (m_nbHoriz * m_nbVert - 1) );
     notifyLayout( m_bgWidth, m_bgHeight );
index 1acd6024c70bc49576a826428238ded142a459c6..0597d598454f65723867321f5e29093bff3b8223 100644 (file)
@@ -98,7 +98,7 @@ class CtrlSliderCursor: public CtrlGeneric, public Observer<VarPercent, void*>
         const Bezier &m_rCurve;
 
         /// Method called when the position variable is modified
-        virtual void onUpdate( Subject<VarPercent,void*> &rVariable, void * );
+        virtual void onUpdate( Subject<VarPercent> &rVariable, void * );
 
         /// Method to compute the resize factors
         void getResizeFactors( float &rFactorX, float &rFactorY ) const;
@@ -157,7 +157,7 @@ class CtrlSliderBg: public CtrlGeneric, public Observer<VarPercent, void*>
         int m_position;
 
         /// Method called when the observed variable is modified
-        virtual void onUpdate( Subject<VarPercent,void*> &rVariable, void* );
+        virtual void onUpdate( Subject<VarPercent> &rVariable, void* );
 
         /// Method to compute the resize factors
         void getResizeFactors( float &rFactorX, float &rFactorY ) const;
index 1d3d4361045e9f4fd1945df1b25bd5c1e24a4779..4641c851616833f49d1f181c9a1a52785a658de9 100644 (file)
@@ -211,7 +211,7 @@ void CtrlText::setText( const UString &rText, uint32_t color )
 }
 
 
-void CtrlText::onUpdate( Subject<VarText, void*> &rVariable, void* arg )
+void CtrlText::onUpdate( Subject<VarText> &rVariable, void* arg )
 {
     if( isVisible() )
     {
index 62449627a50b2e263b8be723cf2cbfa6d8c171b0..1065b1c6cdcd260cc5316dd02f3327628d8712dd 100644 (file)
@@ -122,7 +122,7 @@ class CtrlText: public CtrlGeneric, public Observer<VarText, void*>
         DEFINE_CALLBACK( CtrlText, UpdateText );
 
         /// Method called when the observed variable is modified
-        virtual void onUpdate( Subject<VarText,void*> &rVariable, void* );
+        virtual void onUpdate( Subject<VarText> &rVariable, void* );
 
         /// Display the text on the control
         void displayText( const UString &rText );
index f89e075987e212aea78c0d0d83a626799a4b5db5..5ad257af4fa5457ec15b1a01a6cc8df9ea2fdb43 100644 (file)
@@ -189,7 +189,7 @@ void CtrlTree::onUpdate( Subject<VarTree, tree_update*> &rTree,
     notifyLayout();
 }
 
-void CtrlTree::onUpdate( Subject<VarPercent, void*> &rPercent, void* arg)
+void CtrlTree::onUpdate( Subject<VarPercent> &rPercent, void* arg)
 {
     // Determine what is the first item to display
     VarTree::Iterator it = m_flat ? m_rTree.firstLeaf() : m_rTree.begin();
index b0ca5d3cf3c696cbec806e045b972f8b777380bc..dbf5fb99830827327ea1231125f700470263fc9b 100644 (file)
@@ -123,7 +123,7 @@ class CtrlTree: public CtrlGeneric, public Observer<VarTree, tree_update*>,
                                tree_update *);
 
         // Method called when the position variable of the tree is modified
-        virtual void onUpdate( Subject<VarPercent, void *> &rPercent , void *);
+        virtual void onUpdate( Subject<VarPercent> &rPercent , void *);
 
         /// Called when the position is set
         virtual void onPositionChange();
index c3db573928ea320b038555b04b2633cacb05f2e7..ccd7366dc7c40a0fd864e2c2d8766dacf9412f3f 100644 (file)
@@ -101,7 +101,7 @@ void CtrlVideo::draw( OSGraphics &rImage, int xDest, int yDest )
 }
 
 
-void CtrlVideo::onUpdate( Subject<VarBox, void *> &rVoutSize, void *arg )
+void CtrlVideo::onUpdate( Subject<VarBox> &rVoutSize, void *arg )
 {
     int newWidth = ((VarBox&)rVoutSize).getWidth() + m_xShift;
     int newHeight = ((VarBox&)rVoutSize).getHeight() + m_yShift;
index 5a1ecb6f5c203e6fc6944e4848bd253e5d64cffe..1390707b96c36f98779c72d983abd122b725f8ce 100644 (file)
@@ -56,7 +56,7 @@ class CtrlVideo: public CtrlGeneric, public Observer<VarBox, void*>
         virtual string getType() const { return "video"; }
 
         /// Method called when the vout size is updated
-        virtual void onUpdate( Subject<VarBox,void*> &rVoutSize, void* );
+        virtual void onUpdate( Subject<VarBox> &rVoutSize, void* );
 
         /// Called by the layout when the control is show/hidden
         void setVisible( bool visible );
index c156905296b3dbf2880a65a110d95b6533471bea..d40bc7349ecd67926fbd1820a3d893a5989bbf6f 100644 (file)
@@ -35,7 +35,7 @@ class OSTimer;
 
 /// Animated bitmap
 class AnimBitmap: public SkinObject, public Box,
-                  public Subject<AnimBitmap, void*>
+                  public Subject<AnimBitmap>
 {
     public:
         AnimBitmap( intf_thread_t *pIntf, const GenericBitmap &rBitmap );
index 1dc4a6751f9b5afa5629126cb911c3e93930f501..2324185b309fb3ecab139adebfbfeb7c90510b8b 100644 (file)
@@ -127,7 +127,7 @@ void GenericWindow::toggleOnTop( bool onTop ) const
 }
 
 
-void GenericWindow::onUpdate( Subject<VarBool, void*> &rVariable, void*arg )
+void GenericWindow::onUpdate( Subject<VarBool> &rVariable, void*arg )
 {
     if( m_pVarVisible->get() )
     {
index 3b11bea2d93cbe78909d0f504e956a6a5270e49c..cae9d393403d16452365c46ac60fe3b72be24e07 100644 (file)
@@ -122,7 +122,7 @@ class GenericWindow: public SkinObject, public Observer<VarBool, void*>
         mutable VarBoolImpl *m_pVarVisible;
 
         /// Method called when the observed variable is modified
-        virtual void onUpdate( Subject<VarBool, void*> &rVariable , void*);
+        virtual void onUpdate( Subject<VarBool> &rVariable , void*);
 };
 
 
index ddaea9852cb5da52a6f2fe2042f53d623308f6a2..57744537bdfa94150ef7bf1731828cb73e1f78bc 100644 (file)
@@ -74,7 +74,7 @@ void Tooltip::hide()
 }
 
 
-void Tooltip::onUpdate( Subject<VarText, void*> &rVariable , void *arg)
+void Tooltip::onUpdate( Subject<VarText> &rVariable , void *arg)
 {
     // Redisplay the tooltip
     displayText( ((VarText&)rVariable).get() );
index fd1097a96a40d8e1cc9338d2e5c65ac07bdf683c..63e011df013d6542de8a550068c50234159f21f0 100644 (file)
@@ -65,7 +65,7 @@ class Tooltip: public SkinObject, public Observer<VarText, void*>
         int m_xPos, m_yPos;
 
         /// Method called when the observed variable is modified
-        virtual void onUpdate( Subject<VarText,void*> &rVariable, void * );
+        virtual void onUpdate( Subject<VarText> &rVariable, void * );
 
         /// Display text of the tooltip
         void displayText( const UString &rText );
index 3d56213e248f5223e949245c01fc4fef4b45a74c..7320d32b6672f009ec9b7b8ddd5140c3a2272e1d 100644 (file)
@@ -32,7 +32,7 @@ template <class S, class ARG> class Observer;
 
 
 /// Template for subjects in the Observer design pattern
-template <class S, class ARG> class Subject
+template <class S, class ARG = void*> class Subject
 {
     public:
         virtual ~Subject() {}
@@ -87,7 +87,7 @@ template <class S, class ARG> class Subject
 
 
 /// Template for observers in the Observer design pattern
-template <class S, class ARG> class Observer
+template <class S, class ARG = void*> class Observer
 {
     public:
         virtual ~Observer() {}
index 08550033bc7b0f52c8288e4c8e9895434ffe3f02..10ed3e5c1cf0fad86a86675c95806a08d5590aa6 100644 (file)
@@ -112,7 +112,7 @@ class Position
 
 
 /// Variable implementing the Box interface
-class VarBox: public Variable, public Box, public Subject<VarBox, void*>
+class VarBox: public Variable, public Box, public Subject<VarBox>
 {
     public:
         VarBox( intf_thread_t *pIntf, int width = 0, int height = 0 );
index 93cb6aa88508bf268d4d55ecca52c35a617e0ed6..6c004ee80500e40347c1e6868ef39ffaf792fa9b 100644 (file)
@@ -60,7 +60,7 @@ VarBoolAndBool::~VarBoolAndBool()
 }
 
 
-void VarBoolAndBool::onUpdate( Subject<VarBool,void *> &rVariable, void *arg )
+void VarBoolAndBool::onUpdate( Subject<VarBool> &rVariable, void *arg )
 {
     notify();
 }
@@ -82,7 +82,7 @@ VarBoolOrBool::~VarBoolOrBool()
 }
 
 
-void VarBoolOrBool::onUpdate( Subject<VarBool,void*> &rVariable , void*arg)
+void VarBoolOrBool::onUpdate( Subject<VarBool> &rVariable , void*arg)
 {
     notify();
 }
@@ -101,7 +101,7 @@ VarNotBool::~VarNotBool()
 }
 
 
-void VarNotBool::onUpdate( Subject<VarBool, void*> &rVariable, void*arg )
+void VarNotBool::onUpdate( Subject<VarBool> &rVariable, void*arg )
 {
     notify();
 }
index 2b086cfc7aa2341643a969564d27b5dd280d4ad2..4da4b7f3e5a31b0313d12c523eeede5ef72a8a86 100644 (file)
@@ -30,7 +30,7 @@
 
 
 /// Interface for read-only boolean variable
-class VarBool: public Variable, public Subject<VarBool, void *>
+class VarBool: public Variable, public Subject<VarBool>
 {
     public:
         /// Get the variable type
@@ -99,7 +99,7 @@ class VarBoolAndBool: public VarBool, public Observer<VarBool, void*>
         virtual bool get() const { return m_rVar1.get() && m_rVar2.get(); }
 
         // Called when one of the observed variables is changed
-        void onUpdate( Subject<VarBool, void*> &rVariable, void* );
+        void onUpdate( Subject<VarBool> &rVariable, void* );
 
     private:
         /// Boolean variables
@@ -118,7 +118,7 @@ class VarBoolOrBool: public VarBool, public Observer<VarBool, void*>
         virtual bool get() const { return m_rVar1.get() || m_rVar2.get(); }
 
         // Called when one of the observed variables is changed
-        void onUpdate( Subject<VarBool, void*> &rVariable, void* );
+        void onUpdate( Subject<VarBool> &rVariable, void* );
 
     private:
         /// Boolean variables
@@ -137,7 +137,7 @@ class VarNotBool: public VarBool, public Observer<VarBool, void*>
         virtual bool get() const { return !m_rVar.get(); }
 
         // Called when the observed variable is changed
-        void onUpdate( Subject<VarBool, void*> &rVariable, void* );
+        void onUpdate( Subject<VarBool> &rVariable, void* );
 
     private:
         /// Boolean variable
index 80dd69d6db384b905de82a9a412d21e6a4a733dd..d8d7f09cd92a79b5fee0d15e1ea5284ead4adb8f 100644 (file)
@@ -34,7 +34,7 @@
 
 
 /// List variable
-class VarList: public Variable, public Subject<VarList, void* >
+class VarList: public Variable, public Subject<VarList>
 {
     public:
         VarList( intf_thread_t *pIntf );
index ed5133a4fa1a97e8dad583e6860e2a1f26df3158..7a18ab672ecc746bd25af064d1de39ab7ebe8406 100644 (file)
@@ -32,7 +32,7 @@ class VarPercent;
 
 
 /// Percentage variable
-class VarPercent: public Variable, public Subject<VarPercent, void*>
+class VarPercent: public Variable, public Subject<VarPercent>
 {
     public:
         VarPercent( intf_thread_t *pIntf ): Variable( pIntf ), m_value( 0 ) {}
index 23ac5c72a2588bdcdce18b2f17bd3ab852a9ebba..e692433d5e3d5ee1c6edab725520e00c666538ca 100644 (file)
@@ -192,7 +192,7 @@ void VarText::set( const UString &rText )
 }
 
 
-void VarText::onUpdate( Subject<VarPercent, void*> &rVariable, void *arg )
+void VarText::onUpdate( Subject<VarPercent> &rVariable, void *arg )
 {
     UString newText = get();
     // If the text has changed, notify the observers
@@ -204,7 +204,7 @@ void VarText::onUpdate( Subject<VarPercent, void*> &rVariable, void *arg )
 }
 
 
-void VarText::onUpdate( Subject<VarText,void*> &rVariable, void *arg )
+void VarText::onUpdate( Subject<VarText> &rVariable, void *arg )
 {
     UString newText = get();
     // If the text has changed, notify the observers
index 1bde9262fc05c253a56e86e2a83c19d90b0a3fda..b0c141969762f8ba5adea0e674d257b382c21cbf 100644 (file)
@@ -32,7 +32,7 @@
 
 
 /// String variable
-class VarText: public Variable, public Subject<VarText, void*>,
+class VarText: public Variable, public Subject<VarText>,
                public Observer<VarPercent, void*>,
                public Observer< VarText,void*>
 {
@@ -49,8 +49,8 @@ class VarText: public Variable, public Subject<VarText, void*>,
         virtual const UString get() const;
 
         /// Methods called when an observed variable is modified
-        virtual void onUpdate( Subject<VarPercent, void*> &rVariable, void* );
-        virtual void onUpdate( Subject<VarText, void*> &rVariable, void* );
+        virtual void onUpdate( Subject<VarPercent> &rVariable, void* );
+        virtual void onUpdate( Subject<VarText> &rVariable, void* );
 
     private:
         /// Stop observing other variables
index e8fe687f59a668daddfbd914f663a55ea5185371..4e894c7fcdc35f1527eb0dd60a9b96aa558e61f1 100644 (file)
@@ -77,7 +77,7 @@ VariablePtr EqualizerBands::getBand( int band )
 }
 
 
-void EqualizerBands::onUpdate( Subject<VarPercent,void*> &rBand, void *arg )
+void EqualizerBands::onUpdate( Subject<VarPercent> &rBand, void *arg )
 {
     // Make sure we are not called from set()
     if (!m_isUpdating)
index 5d4b0ddfd6d2ad9b14c4dbc0d814c0a06e40db40..d08372413efd60d23d9ba29c7aa549df22ad88df 100644 (file)
@@ -52,7 +52,7 @@ class EqualizerBands: public SkinObject, public Observer<VarPercent, void*>
         bool m_isUpdating;
 
         /// Callback for band updates
-        virtual void onUpdate( Subject<VarPercent, void*> &rBand , void *);
+        virtual void onUpdate( Subject<VarPercent> &rBand , void *);
 };