[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/runtime/kstyles/oxygen
From:       Hugo Pereira Da Costa <hugo.pereira () free ! fr>
Date:       2010-02-02 23:00:34
Message-ID: 1265151634.088059.15521.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1084358 by hpereiradacosta:

Revisited scrollbar animation logic so that arrows are highlighted even in \
non-animated mode

 M  +31 -12    animations/oxygenscrollbardata.cpp  
 M  +13 -0     animations/oxygenscrollbardata.h  
 M  +12 -2     animations/oxygenscrollbarengine.cpp  
 M  +15 -1     animations/oxygenscrollbarengine.h  
 M  +11 -5     animations/oxygensliderdata.cpp  
 M  +1 -5      oxygen.cpp  


--- trunk/KDE/kdebase/runtime/kstyles/oxygen/animations/oxygenscrollbardata.cpp \
#1084357:1084358 @@ -122,6 +122,7 @@
     {
         Q_UNUSED( object );
         Q_UNUSED( event );
+
         updateSlider( QStyle::SC_None );
         updateSubLineArrow( QStyle::SC_None );
         updateAddLineArrow( QStyle::SC_None );
@@ -136,8 +137,11 @@
 
             if( !sliderHovered() ) {
                 setSliderHovered( true );
-                animation().data()->setDirection( Animation::Forward );
-                if( !animation().data()->isRunning() ) animation().data()->start();
+                if( enabled() )
+                {
+                    animation().data()->setDirection( Animation::Forward );
+                    if( !animation().data()->isRunning() ) \
animation().data()->start(); +                } else setDirty();
             }
 
         } else {
@@ -145,8 +149,11 @@
             if( sliderHovered() )
             {
                 setSliderHovered( false );
-                animation().data()->setDirection( Animation::Backward );
-                if( !animation().data()->isRunning() ) animation().data()->start();
+                if( enabled() )
+                {
+                    animation().data()->setDirection( Animation::Backward );
+                    if( !animation().data()->isRunning() ) \
animation().data()->start(); +                } else setDirty();
             }
 
         }
@@ -161,8 +168,11 @@
             if( !subLineArrowHovered() )
             {
                 setSubLineArrowHovered( true );
-                subLineAnimation().data()->setDirection( Animation::Forward );
-                if( !subLineAnimation().data()->isRunning() ) \
subLineAnimation().data()->start(); +                if( enabled() )
+                {
+                    subLineAnimation().data()->setDirection( Animation::Forward );
+                    if( !subLineAnimation().data()->isRunning() ) \
subLineAnimation().data()->start(); +                } else setDirty();
              }
 
         } else {
@@ -170,8 +180,11 @@
             if( subLineArrowHovered() )
             {
                 setSubLineArrowHovered( false );
-                subLineAnimation().data()->setDirection( Animation::Backward );
-                if( !subLineAnimation().data()->isRunning() ) \
subLineAnimation().data()->start(); +                if( enabled() )
+                {
+                    subLineAnimation().data()->setDirection( Animation::Backward );
+                    if( !subLineAnimation().data()->isRunning() ) \
subLineAnimation().data()->start(); +                } else setDirty();
             }
 
         }
@@ -186,8 +199,11 @@
             if( !addLineArrowHovered() )
             {
                 setAddLineArrowHovered( true );
-                addLineAnimation().data()->setDirection( Animation::Forward );
-                if( !addLineAnimation().data()->isRunning() ) \
addLineAnimation().data()->start(); +                if( enabled() )
+                {
+                    addLineAnimation().data()->setDirection( Animation::Forward );
+                    if( !addLineAnimation().data()->isRunning() ) \
addLineAnimation().data()->start(); +                } else setDirty();
             }
 
         } else {
@@ -195,8 +211,11 @@
             if( addLineArrowHovered() )
             {
                 setAddLineArrowHovered( false );
-                addLineAnimation().data()->setDirection( Animation::Backward );
-                if( !addLineAnimation().data()->isRunning() ) \
addLineAnimation().data()->start(); +                if( enabled() )
+                {
+                    addLineAnimation().data()->setDirection( Animation::Backward );
+                    if( !addLineAnimation().data()->isRunning() ) \
addLineAnimation().data()->start(); +                } else setDirty();
             }
 
         }
--- trunk/KDE/kdebase/runtime/kstyles/oxygen/animations/oxygenscrollbardata.h \
#1084357:1084358 @@ -63,6 +63,19 @@
         //! return default opacity for a given subcontrol
         virtual qreal opacity( QStyle::SubControl ) const;
 
+        //! return default opacity for a given subcontrol
+        virtual bool isHovered( QStyle::SubControl control ) const
+        {
+            switch( control )
+            {
+                case QStyle::SC_ScrollBarAddLine: return addLineArrowHovered();
+                case QStyle::SC_ScrollBarSubLine: return subLineArrowHovered();
+                default: return false;
+            }
+
+
+        }
+
         //! subControlRect
         virtual QRect subControlRect( QStyle::SubControl control ) const
         {
--- trunk/KDE/kdebase/runtime/kstyles/oxygen/animations/oxygenscrollbarengine.cpp \
#1084357:1084358 @@ -36,10 +36,20 @@
     bool ScrollBarEngine::registerWidget( QWidget* widget )
     {
 
-        if( !(enabled() && widget ) ) return false;
+        // check widget
+        /*
+        note: widget is registered even if animation is disabled because \
OxygenScrollBarData +        is also used in non-animated mode to store arrow rect \
for hover highlight +        */
+        if( !widget ) return false;
 
         // create new data class
-        if( !data_.contains( widget ) ) data_.insert( widget, new ScrollBarData( \
this, widget, duration() ) ); +        if( !data_.contains( widget ) )
+        {
+            ScrollBarData* data = new ScrollBarData( this, widget, duration() );
+            data->setEnabled( enabled() );
+            data_.insert( widget, data );
+        }
 
         // connect destruction signal
         disconnect( widget, SIGNAL( destroyed( QObject* ) ), this, SLOT( \
                unregisterWidget( QObject* ) ) );
--- trunk/KDE/kdebase/runtime/kstyles/oxygen/animations/oxygenscrollbarengine.h \
#1084357:1084358 @@ -61,6 +61,13 @@
         virtual qreal opacity( const QObject* object, QStyle::SubControl control )
         { return isAnimated( object, control ) ? data_.find( object \
).data()->opacity( control ):AnimationData::OpacityInvalid; }  
+        //! return true if given subcontrol is hovered
+        virtual bool isHovered( const QObject* object, QStyle::SubControl control )
+        {
+            if( DataMap<ScrollBarData>::Value data = data_.find( object ) ) return \
data.data()->isHovered( control ); +            else return false;
+        }
+
         //! control rect associated to object
         virtual QRect subControlRect( const QObject* object, QStyle::SubControl \
control )  {
@@ -79,7 +86,14 @@
         virtual void setEnabled( bool value )
         {
             BaseEngine::setEnabled( value );
-            data_.setEnabled( value );
+            /*
+            do not disable the map directly, because the contained \
OxygenScrollbarData +            are also used in non animated mode to store \
scrollbar arrows rect. However +            do disable all contains DATA object, in \
order to prevent actual animations +            */
+            foreach( const DataMap<ScrollBarData>::Value data, data_ )
+            { if( data ) data.data()->setEnabled( value ); }
+
         }
 
         //! duration
--- trunk/KDE/kdebase/runtime/kstyles/oxygen/animations/oxygensliderdata.cpp \
#1084357:1084358 @@ -41,7 +41,7 @@
     bool SliderData::eventFilter( QObject* object, QEvent* event )
     {
 
-        if( !( enabled() && object == target().data() ) )
+        if( object != target().data() )
         { return GenericData::eventFilter( object, event ); }
 
         // check event type
@@ -103,8 +103,11 @@
 
             if( !sliderHovered() ) {
                 setSliderHovered( true );
-                animation().data()->setDirection( Animation::Forward );
-                if( !animation().data()->isRunning() ) animation().data()->start();
+                if( enabled() )
+                {
+                    animation().data()->setDirection( Animation::Forward );
+                    if( !animation().data()->isRunning() ) \
animation().data()->start(); +                } else setDirty();
             }
 
         } else {
@@ -112,8 +115,11 @@
             if( sliderHovered() )
             {
                 setSliderHovered( false );
-                animation().data()->setDirection( Animation::Backward );
-                if( !animation().data()->isRunning() ) animation().data()->start();
+                if( enabled() )
+                {
+                    animation().data()->setDirection( Animation::Backward );
+                    if( !animation().data()->isRunning() ) \
animation().data()->start(); +                } else setDirty();
             }
 
         }
--- trunk/KDE/kdebase/runtime/kstyles/oxygen/oxygen.cpp #1084357:1084358
@@ -3258,14 +3258,10 @@
                 else if( opt->direction == Qt::LeftToRight ) subcontrol = (primitive \
                == Generic::ArrowLeft) ? SC_ScrollBarSubLine:SC_ScrollBarAddLine;
                 else subcontrol = (primitive == Generic::ArrowLeft) ? \
SC_ScrollBarAddLine:SC_ScrollBarSubLine;  
-                // check if active subControl matches current
-                bool hover( false );
-                if( const QStyleOptionSlider *sbOpt = qstyleoption_cast<const \
                QStyleOptionSlider*>(opt) )
-                { if( sbOpt->activeSubControls & subcontrol ) hover = true; }
-
                 if( enabled )
                 {
 
+                    bool hover( animations().scrollBarEngine().isHovered( widget, \
                subcontrol ) );
                     bool animated( animations().scrollBarEngine().isAnimated( \
                widget, subcontrol ) );
                     qreal opacity( animations().scrollBarEngine().opacity( widget, \
subcontrol ) );  


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic